Send client compatibility version to remote config API

This commit is contained in:
Samuel Elliott 2025-07-22 01:37:01 +01:00
parent 57ce3c21de
commit e00a0a6e3b
No known key found for this signature in database
GPG Key ID: 8420C7CDE43DC4D6
2 changed files with 14 additions and 1 deletions

View File

@ -10,7 +10,7 @@ const debug = createDebug('nxapi:api:moon');
const MOON_URL = 'https://api-lp1.pctl.srv.nintendo.net/moon';
export const ZNMA_CLIENT_ID = '54789befb391a838';
const ZNMA_VERSION = '1.17.0';
export const ZNMA_VERSION = '1.17.0';
const ZNMA_BUILD = '261';
const ZNMA_USER_AGENT = 'moon_ANDROID/' + ZNMA_VERSION + ' (com.nintendo.znma; build:' + ZNMA_BUILD +
'; ANDROID 26)';

View File

@ -2,6 +2,8 @@ import * as path from 'node:path';
import * as fs from 'node:fs/promises';
import { fileURLToPath } from 'node:url';
import { fetch } from 'undici';
import { ZNCA_VERSION } from '../api/coral.js';
import { ZNMA_VERSION } from '../api/moon.js';
import { ErrorResponse, ResponseSymbol } from '../api/util.js';
import createDebug from '../util/debug.js';
import { timeoutSignal } from '../util/misc.js';
@ -53,6 +55,10 @@ async function loadRemoteConfig() {
expires_at: Date.now(),
version,
revision: git?.revision ?? null,
compatible_versions: {
znca: ZNCA_VERSION,
znma: ZNMA_VERSION,
},
url: url_parsed.toString(),
headers: {},
data: config,
@ -122,6 +128,10 @@ async function loadRemoteConfig() {
expires_at,
version,
revision: git?.revision ?? null,
compatible_versions: {
znca: ZNCA_VERSION,
znma: ZNMA_VERSION,
},
url: response.url,
headers: Object.fromEntries(response.headers.entries()),
data: config,
@ -147,6 +157,8 @@ async function getRemoteConfig(url: string, useragent?: string, cache?: {
'User-Agent': getUserAgent(),
'X-nxapi-Version': version,
'X-nxapi-Revision': git?.revision ?? undefined!,
'X-znca-Compatible-Version': ZNCA_VERSION,
'X-znma-Compatible-Version': ZNMA_VERSION,
'If-Modified-Since': cache ? cache.updated_at.toUTCString() : undefined!,
'If-None-Match': cache?.etag ?? undefined!,
},
@ -239,6 +251,7 @@ export interface RemoteConfigCacheData {
expires_at: number;
version: string;
revision: string | null;
compatible_versions?: Partial<Record<'znca' | 'znma', string>>;
url: string;
headers: Record<string, string> | Record<string, string[]>;
data: NxapiRemoteConfig;