mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-08-19 00:56:28 -05:00
Move f generation server to a separate repository
This commit is contained in:
109
docs/cli.md
109
docs/cli.md
@@ -566,111 +566,4 @@ This command has no options, but environment variables can still be used.
|
||||
|
||||
A server for controlling the Nintendo Switch Online app on an Android device/emulator using Frida can be used instead of the imink/flapg APIs to generate `f` parameters for authentication.
|
||||
|
||||
This server has a single endpoint, `/api/znca/f`, which is fully compatible with [the imink API](https://github.com/JoneWang/imink/wiki/imink-API-Documentation)'s `/f` endpoint. The following data should be sent as JSON:
|
||||
|
||||
```ts
|
||||
interface AndroidZncaApiRequest {
|
||||
/**
|
||||
* `"1"` or `1` for Coral (Nintendo Switch Online app) authentication (`Account/Login` and `Account/GetToken`).
|
||||
* `"2"` or `2` for web service authentication (`Game/GetWebServiceToken`).
|
||||
*/
|
||||
hash_method: '1' | '2' | 1 | 2;
|
||||
/**
|
||||
* The token used to authenticate to the Coral API:
|
||||
* The Nintendo Account `id_token` for Coral authentication.
|
||||
* The Coral access token for web service authentication.
|
||||
*/
|
||||
token: string;
|
||||
/**
|
||||
* The current timestamp in milliseconds, either as a number or a string.
|
||||
*/
|
||||
timestamp?: string | number;
|
||||
/**
|
||||
* A random (v4) UUID.
|
||||
*/
|
||||
request_id?: string;
|
||||
}
|
||||
```
|
||||
|
||||
Due to changes to Nintendo's API on [23/08/2022](https://github.com/samuelthomas2774/nxapi/discussions/10#discussioncomment-3464443) the `timestamp` parameter should not be sent. If the `timestamp` or `request_id` parameters are not sent their values will be generated and returned in the response. Note that unlike the imink API and [nsotokengen](https://github.com/clovervidia/nsotokengen), only parameters not included in the request will be included in the response.
|
||||
|
||||
This requires:
|
||||
|
||||
- adb is installed on the computer running nxapi
|
||||
- The Android device is running adbd as root or a su-like command can be used to escalate to root
|
||||
- The frida-server executable is located at `/data/local/tmp/frida-server` on the Android device (a different path can be provided using the `--frida-server-path` option)
|
||||
- The Nintendo Switch Online app is installed on the Android device
|
||||
|
||||
No other software (e.g. frida-tools) needs to be installed on the computer running nxapi. The Android device must be constantly reachable using ADB. The server will attempt to reconnect to the Android device and will automatically retry any requests that would fail due to the device disconnecting. The server will exit if it fails to reconnect to the device. A service manager should be used to restart the server if it exits.
|
||||
|
||||
```sh
|
||||
# Start the server using the ADB server "android.local:5555" listening on all interfaces on a random port
|
||||
nxapi android-znca-api-server-frida android.local:5555
|
||||
|
||||
# Start the server listening on a specific address/port
|
||||
# The `--listen` option can be used multiple times
|
||||
nxapi android-znca-api-server-frida android.local:5555 --listen "[::1]:12345"
|
||||
|
||||
# Use a command to escalate to root to start frida-server and the Nintendo Switch Online app
|
||||
# "{cmd}" will be replaced with the path to a temporary script in double quotes
|
||||
nxapi android-znca-api-server-frida android.local:5555 --exec-command "/system/bin/su -c {cmd}"
|
||||
|
||||
# Specify a different location for the adb executable if it is not in the search path
|
||||
nxapi android-znca-api-server-frida android.local:5555 --adb-path "/usr/local/bin/adb"
|
||||
|
||||
# Run `adb root` when connecting to the device to restart adbd as root
|
||||
nxapi android-znca-api-server-frida android.local:5555 --adb-root
|
||||
|
||||
# Specify a different location for the frida-server executable on the device
|
||||
nxapi android-znca-api-server-frida android.local:5555 --frida-server-path "/data/local/tmp/frida-server-15.1.17-android-arm"
|
||||
|
||||
# Use Frida to start the app on the device (even if it is already running) (recommended)
|
||||
nxapi android-znca-api-server-frida android.local:5555 --start-method spawn
|
||||
# Use `am start-activity` to ensure the app process is running
|
||||
nxapi android-znca-api-server-frida android.local:5555 --start-method activity
|
||||
# Use `am start-service` to ensure the app process is running, without causing Android to show the app (default)
|
||||
nxapi android-znca-api-server-frida android.local:5555 --start-method service
|
||||
# Do not attempt to start the app on the device automatically - this will cause the server to fail if the app is not already running
|
||||
nxapi android-znca-api-server-frida android.local:5555 --start-method none
|
||||
|
||||
# Strictly validate the timestamp and request_id parameters sent by the client are likely to be accepted by Nintendo's API
|
||||
nxapi android-znca-api-server-frida android.local:5555 --strict-validate
|
||||
|
||||
# Don't validate the token sent by the client
|
||||
nxapi android-znca-api-server-frida android.local:5555 --no-validate-tokens
|
||||
|
||||
# Make imink-compatible API requests using curl
|
||||
curl --header "Content-Type: application/json" --data '{"hash_method": "1", "token": "..."}' "http://[::1]:12345/api/znca/f"
|
||||
curl --header "Content-Type: application/json" --data '{"hash_method": "1", "token": "...", "request_id": "..."}' "http://[::1]:12345/api/znca/f"
|
||||
curl --header "Content-Type: application/json" --data '{"hash_method": "1", "token": "...", "timestamp": "...", "request_id": "..."}' "http://[::1]:12345/api/znca/f"
|
||||
|
||||
# Make legacy nxapi v1.3.0-compatible API requests using curl
|
||||
curl --header "Content-Type: application/json" --data '{"type": "nso", "token": "..."}' "http://[::1]:12345/api/znca/f"
|
||||
curl --header "Content-Type: application/json" --data '{"type": "nso", "token": "...", "uuid": "..."}' "http://[::1]:12345/api/znca/f"
|
||||
curl --header "Content-Type: application/json" --data '{"type": "nso", "token": "...", "timestamp": "...", "uuid": "..."}' "http://[::1]:12345/api/znca/f"
|
||||
|
||||
# Use the znca API server in other commands
|
||||
# This should be set when running any nso commands as the access token will be refreshed automatically when it expires
|
||||
ZNCA_API_URL=http://[::1]:12345/api/znca nxapi nso ...
|
||||
```
|
||||
|
||||
Information about the device and the Nintendo Switch Online app, as well as information on how long the request took to process will be included in the response headers.
|
||||
|
||||
Header | Description
|
||||
--------------------------------|------------------
|
||||
`X-Android-Build-Type` | Android build type, e.g. `user`
|
||||
`X-Android-Release` | Android release/marketing version, e.g. `8.0.0`
|
||||
`X-Android-Platform-Version` | Android SDK version, e.g. `26`
|
||||
`X-znca-Platform` | Device platform - always `Android`
|
||||
`X-znca-Version` | App release/marketing version, e.g. `2.2.0`
|
||||
`X-znca-Build` | App build/internal version, e.g. `2832`
|
||||
|
||||
The following performance metrics are included in the `Server-Timing` header:
|
||||
|
||||
Name | Description
|
||||
------------|------------------
|
||||
`validate` | Time validating the request body.
|
||||
`attach` | Time waiting for the device to become available, start frida-server, start the app and attach the Frida script to the app process. This metric will not be included if the server is already connected to the device.
|
||||
`queue` | Time waiting for the processing thread to become available.
|
||||
`init` | Time waiting for `com.nintendo.coral.core.services.voip.Libvoipjni.init`.
|
||||
`process` | Time waiting for `com.nintendo.coral.core.services.voip.Libvoipjni.genAudioH`/`genAudioH2`.
|
||||
This is now a separate project at https://gitlab.fancy.org.uk/samuel/nxapi-znca-api or https://github.com/samuelthomas2774/nxapi-znca-api.
|
||||
|
||||
Reference in New Issue
Block a user