mirror of
https://github.com/samuelthomas2774/nxapi.git
synced 2026-10-20 00:27:40 -05:00
Add a command to get a SplatNet 2 iksm_session cookie
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
export * as user from './user.js';
|
||||
export * as token from './token.js';
|
||||
export * as stages from './stages.js';
|
||||
export * as challenges from './challenges.js';
|
||||
export * as weapons from './weapons.js';
|
||||
|
||||
51
src/cli/splatnet2/token.ts
Normal file
51
src/cli/splatnet2/token.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import createDebug from 'debug';
|
||||
import type { Arguments as ParentArguments } from '../splatnet2.js';
|
||||
import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js';
|
||||
import { initStorage } from '../../util/storage.js';
|
||||
import { getIksmToken } from '../../common/auth/splatnet2.js';
|
||||
|
||||
const debug = createDebug('cli:splatnet2:token');
|
||||
|
||||
export const command = 'token';
|
||||
export const desc = 'Get the authenticated Nintendo Account\'s SplatNet 2 user data and iksm_session cookie';
|
||||
|
||||
export function builder(yargs: Argv<ParentArguments>) {
|
||||
return yargs.option('user', {
|
||||
describe: 'Nintendo Account ID',
|
||||
type: 'string',
|
||||
}).option('token', {
|
||||
describe: 'Nintendo Account session token',
|
||||
type: 'string',
|
||||
}).option('json', {
|
||||
describe: 'Output raw JSON',
|
||||
type: 'boolean',
|
||||
}).option('json-pretty-print', {
|
||||
describe: 'Output pretty-printed JSON',
|
||||
type: 'boolean',
|
||||
});
|
||||
}
|
||||
|
||||
type Arguments = YargsArguments<ReturnType<typeof builder>>;
|
||||
|
||||
export async function handler(argv: ArgumentsCamelCase<Arguments>) {
|
||||
const storage = await initStorage(argv.dataPath);
|
||||
|
||||
const usernsid = argv.user ?? await storage.getItem('SelectedUser');
|
||||
const token: string = argv.token || await storage.getItem('NintendoAccountToken.' + usernsid);
|
||||
const {splatnet, data} = await getIksmToken(storage, token, argv.zncProxyUrl, argv.autoUpdateSession);
|
||||
|
||||
if (argv.json || argv.jsonPrettyPrint) {
|
||||
const result = {
|
||||
iksm_session: data.iksm_session,
|
||||
language: data.language,
|
||||
region: data.region,
|
||||
user_id: data.user_id,
|
||||
nsa_id: data.nsa_id,
|
||||
};
|
||||
|
||||
console.log(JSON.stringify(result, null, argv.jsonPrettyPrint ? 4 : 0));
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(data.iksm_session);
|
||||
}
|
||||
@@ -43,6 +43,4 @@ export async function handler(argv: ArgumentsCamelCase<Arguments>) {
|
||||
records.records.player.principal_id,
|
||||
records.records.player.player_rank,
|
||||
records.records.player.player_type);
|
||||
|
||||
console.log(data.iksm_session);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user