From 8c911d5bcaf0e64cfee05e7b2d0aac3b37a3803d Mon Sep 17 00:00:00 2001 From: Samuel Elliott Date: Sat, 29 Mar 2025 00:48:15 +0000 Subject: [PATCH] Coral 2.12.0 --- resources/common/remote-config.json | 2 +- src/api/coral.ts | 21 ++++++++++++++++++--- src/api/f.ts | 9 ++++++--- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/resources/common/remote-config.json b/resources/common/remote-config.json index 438e70e..b73f119 100644 --- a/resources/common/remote-config.json +++ b/resources/common/remote-config.json @@ -1,7 +1,7 @@ { "require_version": [], "coral": { - "znca_version": "2.7.0" + "znca_version": "2.12.0" }, "coral_auth": { "default": [ diff --git a/src/api/coral.ts b/src/api/coral.ts index 94f0bab..db99de6 100644 --- a/src/api/coral.ts +++ b/src/api/coral.ts @@ -15,7 +15,7 @@ const debug = createDebug('nxapi:api:coral'); const ZNCA_PLATFORM = 'Android'; const ZNCA_PLATFORM_VERSION = '8.0.0'; -const ZNCA_VERSION = '2.2.0'; +export const ZNCA_VERSION = '2.12.0'; const ZNCA_USER_AGENT = `com.nintendo.znca/${ZNCA_VERSION}(${ZNCA_PLATFORM}/${ZNCA_PLATFORM_VERSION})`; const ZNC_URL = 'https://api-lp1.znc.srv.nintendo.net'; @@ -295,7 +295,14 @@ export default class CoralApi implements CoralApiInterface { }; try { - return await this.call('/v2/Game/GetWebServiceToken', req, false); + const uuid = randomUUID(); + + return this.fetch('/v2/Game/GetWebServiceToken', 'POST', JSON.stringify({ + parameter: req, + requestId: uuid, + }), { + 'X-IntegrityTokenError': 'NETWORK_ERROR', + }, false); } catch (err) { if (err instanceof CoralErrorResponse && err.status === CoralStatus.TOKEN_EXPIRED && !_attempt && this.onTokenExpired) { debug('Error getting web service token, renewing token before retrying', err); @@ -336,7 +343,14 @@ export default class CoralApi implements CoralApiInterface { naIdToken: nintendoAccountToken.id_token, }; - const data = await this.call('/v3/Account/GetToken', req, false); + const uuid = randomUUID(); + + const data = await this.fetch('/v3/Account/GetToken', 'POST', JSON.stringify({ + parameter: req, + requestId: uuid, + }), { + 'X-IntegrityTokenError': 'NETWORK_ERROR', + }, false); return { nintendoAccountToken, @@ -438,6 +452,7 @@ export default class CoralApi implements CoralApiInterface { headers: { 'X-Platform': ZNCA_PLATFORM, 'X-ProductVersion': config.znca_version, + 'X-IntegrityTokenError': 'NETWORK_ERROR', 'Content-Type': 'application/json; charset=utf-8', 'User-Agent': znca_useragent, }, diff --git a/src/api/f.ts b/src/api/f.ts index 72d74b0..9058cd8 100644 --- a/src/api/f.ts +++ b/src/api/f.ts @@ -5,6 +5,7 @@ import { defineResponse, ErrorResponse } from './util.js'; import createDebug from '../util/debug.js'; import { timeoutSignal } from '../util/misc.js'; import { getUserAgent } from '../util/useragent.js'; +import { ZNCA_VERSION } from './coral.js'; const debugFlapg = createDebug('nxapi:api:flapg'); const debugImink = createDebug('nxapi:api:imink'); @@ -219,6 +220,7 @@ export async function genf( }); if (app?.platform) headers.append('X-znca-Platform', app.platform); if (app?.version) headers.append('X-znca-Version', app.version); + if (ZNCA_VERSION) headers.append('X-znca-Client-Version', ZNCA_VERSION); const [signal, cancel] = timeoutSignal(); const response = await fetch(url, { @@ -271,16 +273,17 @@ export class ZncaApiNxapi extends ZncaApi { } async genf(token: string, hash_method: HashMethod, user?: {na_id: string; coral_user_id?: string}) { - const request_id = randomUUID(); + // const request_id = randomUUID(); - const result = await genf(this.url + '/f', hash_method, token, undefined, request_id, + const result = await genf(this.url + '/f', hash_method, token, undefined, undefined, user, this.app, this.useragent); return { provider: 'nxapi' as const, url: this.url + '/f', - hash_method, token, request_id, + hash_method, token, timestamp: result.timestamp!, // will be included as not sent in request + request_id: result.request_id!, f: result.f, user, result,