Update dependencies

This commit is contained in:
Samuel Elliott
2022-05-29 19:07:18 +01:00
parent 5328ada1e7
commit 18761bbb31
46 changed files with 547 additions and 1557 deletions

1848
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -23,56 +23,55 @@
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"body-parser": "^1.19.2",
"body-parser": "^1.20.0",
"cli-table": "^0.3.11",
"debug": "^4.3.3",
"debug": "^4.3.4",
"discord-rpc": "^4.0.1",
"dotenv": "^16.0.0",
"dotenv": "^16.0.1",
"dotenv-expand": "^8.0.3",
"env-paths": "^3.0.0",
"express": "^4.17.3",
"express": "^4.18.1",
"frida": "^15.1.17",
"mkdirp": "^1.0.4",
"node-fetch": "^3.2.2",
"node-fetch": "^3.2.4",
"node-notifier": "^10.0.1",
"node-persist": "^3.1.0",
"read": "^1.0.7",
"supports-color": "^8.1.1",
"tslib": "^2.4.0",
"uuid": "^8.3.2",
"yargs": "^17.3.1"
"yargs": "^17.5.1"
},
"devDependencies": {
"@rollup/plugin-alias": "^3.1.9",
"@rollup/plugin-commonjs": "^21.0.3",
"@rollup/plugin-commonjs": "^21.1.0",
"@rollup/plugin-html": "^0.2.4",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^13.1.3",
"@rollup/plugin-node-resolve": "^13.3.0",
"@rollup/plugin-replace": "^4.0.0",
"@rollup/plugin-typescript": "^8.3.1",
"@rollup/plugin-typescript": "^8.3.2",
"@types/cli-table": "^0.3.0",
"@types/debug": "^4.1.7",
"@types/discord-rpc": "^4.0.0",
"@types/discord-rpc": "^4.0.3",
"@types/express": "^4.17.13",
"@types/mkdirp": "^1.0.2",
"@types/node": "^17.0.21",
"@types/node": "^17.0.36",
"@types/node-notifier": "^8.0.2",
"@types/node-persist": "^3.1.2",
"@types/react": "^17.0.43",
"@types/react-native": "^0.67.3",
"@types/react": "^17.0.45",
"@types/react-native": "^0.67.7",
"@types/read": "^0.0.29",
"@types/uuid": "^8.3.4",
"@types/yargs": "^17.0.9",
"caxa": "^2.1.0",
"electron": "^17.2.0",
"@types/yargs": "^17.0.10",
"electron": "^19.0.1",
"electron-builder": "^23.0.3",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-native-web": "^0.17.7",
"rollup": "^2.70.1",
"rollup": "^2.75.3",
"rollup-plugin-polyfill-node": "^0.8.0",
"ts-json-schema-generator": "^1.0.0",
"tslib": "^2.4.0",
"typescript": "^4.7.0-dev.20220308"
"typescript": "^4.7.2"
},
"build": {
"appId": "uk.org.fancy.nxapi.app",

View File

@@ -1,3 +1,4 @@
import process from 'node:process';
import fetch from 'node-fetch';
import createDebug from 'debug';
import { ErrorResponse } from './util.js';

View File

@@ -3,7 +3,7 @@ Electron app
The Electron app is bundled into ~4 files in `dist/app/bundle` using Rollup. The main process code is not bundled for development, but is when packaging the app at `dist/bundle/app-main-bundle.cjs` (with the command line executable at `dist/bundle/cli-bundle.js`).
[electron.ts](electron.ts) exports all Electron APIs used in the main process. This is because the `electron` module doesn't actually exist - Electron patches the `require` function, but not the module importer. Additionally Electron does not support using a standard JavaScript module as the app entrypoint, so [main/app-entry.cts](main/app-entry.cts) is used to import the actual app entrypoint after the `ready` event.
[electron.ts](electron.ts) exports all Electron APIs used in the main process. This is because the `electron` module doesn't actually exist - Electron patches the `require` function (but not the module importer). Additionally Electron does not support using a standard JavaScript module as the app entrypoint, so [main/app-entry.cts](main/app-entry.cts) (a CommonJS module) is used to import the actual app entrypoint after the `ready` event.
Electron APIs used in renderer processes should be imported directly from the `electron` module as they are always bundled into a CommonJS module.

View File

@@ -1,4 +1,4 @@
import type { EventEmitter } from 'events';
import type { EventEmitter } from 'node:events';
import createDebug from 'debug';
import type { NxapiElectronIpc } from '../preload/index.js';

View File

@@ -1,4 +1,4 @@
import { createRequire } from 'module';
import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const electron = require('electron');

View File

@@ -1,6 +1,7 @@
import { app, BrowserWindow, dialog, ipcMain, Notification } from './electron.js';
import * as path from 'path';
import { EventEmitter } from 'events';
import process from 'node:process';
import * as path from 'node:path';
import { EventEmitter } from 'node:events';
import createDebug from 'debug';
import * as persist from 'node-persist';
import dotenv from 'dotenv';
@@ -173,6 +174,8 @@ export class PresenceMonitorManager {
i.notifications = this.notifications;
i.presence_user = null;
i.user_notifications = false;
i.friend_notifications = false;
this.monitors.push(i);

View File

@@ -1,4 +1,5 @@
import { app, dialog, Menu, Tray, nativeImage, MenuItem } from './electron.js';
import process from 'node:process';
import createDebug from 'debug';
import { addNsoAccount, addPctlAccount } from './na-auth.js';
import { PresenceMonitorManager, Store } from './index.js';

View File

@@ -1,4 +1,5 @@
import * as crypto from 'crypto';
import process from 'node:process';
import * as crypto from 'node:crypto';
import createDebug from 'debug';
import * as persist from 'node-persist';
import { BrowserWindow, Notification, session, shell } from './electron.js';

View File

@@ -1,5 +1,5 @@
import { nativeImage } from './electron.js';
import { Buffer } from 'buffer';
import { Buffer } from 'node:buffer';
import fetch from 'node-fetch';
export async function getNativeImageFromUrl(url: URL | string) {

View File

@@ -1,7 +1,7 @@
import * as path from 'path';
import { constants } from 'fs';
import * as fs from 'fs/promises';
import { Buffer } from 'buffer';
import * as path from 'node:path';
import { constants } from 'node:fs';
import * as fs from 'node:fs/promises';
import { Buffer } from 'node:buffer';
import createDebug from 'debug';
import { app, BrowserWindow, IpcMainInvokeEvent, session, ShareMenu, shell, WebContents } from './electron.js';
import fetch from 'node-fetch';

View File

@@ -1,5 +1,5 @@
import { BrowserWindow, WebContents } from './electron.js';
import * as path from 'path';
import * as path from 'node:path';
import { bundlepath } from './index.js';
import { dev } from '../../util/product.js';
import { WindowConfiguration, WindowType } from '../common/types.js';

View File

@@ -1,5 +1,5 @@
import { contextBridge, ipcRenderer } from 'electron';
import { EventEmitter } from 'events';
import { EventEmitter } from 'node:events';
import { WindowConfiguration } from '../common/types.js';
import { SavedToken } from '../../common/auth/nso.js';
import { SavedMoonToken } from '../../common/auth/moon.js';

View File

@@ -1,4 +1,5 @@
import * as path from 'path';
import process from 'node:process';
import * as path from 'node:path';
import createDebug from 'debug';
import Yargs from 'yargs';
import dotenv from 'dotenv';

View File

@@ -1,8 +1,8 @@
import * as path from 'path';
import process from 'node:process';
import * as path from 'node:path';
import { execFileSync } from 'node:child_process';
import * as net from 'node:net';
import createDebug from 'debug';
import { execFileSync } from 'child_process';
import * as net from 'net';
import frida, { Session } from 'frida';
import express from 'express';
import bodyParser from 'body-parser';
import type { Arguments as ParentArguments } from '../cli.js';
@@ -27,6 +27,10 @@ export function builder(yargs: Argv<ParentArguments>) {
}).option('exec-command', {
describe: 'Command to use to run a file on the device',
type: 'string',
}).option('validate-tokens', {
describe: 'Validate tokens before passing them to znca',
type: 'boolean',
default: true,
}).option('listen', {
describe: 'Server address and port',
type: 'array',
@@ -49,7 +53,7 @@ export async function handler(argv: ArgumentsCamelCase<Arguments>) {
genAudioH2(token: string, timestamp: string, uuid: string): Promise<string>;
} = script.exports as any;
process.on('exit', () => {
const onexit = () => {
debug('Releasing wake lock', argv.device);
execFileSync('adb', [
'-s',
@@ -59,7 +63,11 @@ export async function handler(argv: ArgumentsCamelCase<Arguments>) {
], {
stdio: 'inherit',
});
});
};
process.on('exit', onexit);
process.on('SIGTERM', onexit);
process.on('SIGINT', onexit);
function reattach() {
// Already attempting to reattach
@@ -157,10 +165,15 @@ export async function handler(argv: ArgumentsCamelCase<Arguments>) {
else debug('JWT signature is not valid or not checked');
}
} catch (err) {
res.statusCode = 400;
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify({error: 'invalid_token', error_message: (err as Error).message}));
return;
if (argv.validateTokens) {
debug('Error validating token from %s', req.ip, err);
res.statusCode = 400;
res.setHeader('Content-Type', 'application/json');
res.end(JSON.stringify({error: 'invalid_token', error_message: (err as Error).message}));
return;
} else {
debug('Error validating token from %s, continuing anyway', req.ip, err);
}
}
debugApi('Calling %s', data.type === 'app' ? 'genAudioH2' : 'genAudioH');
@@ -290,6 +303,9 @@ async function setup(argv: ArgumentsCamelCase<Arguments>) {
}
async function attach(argv: ArgumentsCamelCase<Arguments>) {
const frida = await import('frida');
type Session = import('frida').Session;
debug('Running scripts');
execFileSync('adb', [
'-s',

View File

@@ -1,5 +1,6 @@
import { createRequire } from 'module';
import { execFileSync } from 'child_process';
import process from 'node:process';
import { createRequire } from 'node:module';
import { execFileSync } from 'node:child_process';
import createDebug from 'debug';
import type { Arguments as ParentArguments } from '../cli.js';
import { ArgumentsCamelCase, Argv, YargsArguments } from '../util/yargs.js';

View File

@@ -1,3 +1,4 @@
import process from 'node:process';
import createDebug from 'debug';
import type { Arguments as ParentArguments } from '../cli.js';
import { Argv, YargsArguments } from '../util/yargs.js';

View File

@@ -1,5 +1,5 @@
import * as fs from 'fs/promises';
import * as path from 'path';
import * as fs from 'node:fs/promises';
import * as path from 'node:path';
import createDebug from 'debug';
import mkdirp from 'mkdirp';
import type { Arguments as ParentArguments } from '../nooklink.js';

View File

@@ -1,9 +1,9 @@
import { promisify } from 'util';
import createDebug from 'debug';
import type { Arguments as ParentArguments } from '../nooklink.js';
import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js';
import { initStorage } from '../../util/storage.js';
import { getUserToken } from '../../common/auth/nooklink.js';
import prompt from '../util/prompt.js';
const debug = createDebug('cli:nooklink:keyboard');
@@ -30,13 +30,8 @@ type Arguments = YargsArguments<ReturnType<typeof builder>>;
export async function handler(argv: ArgumentsCamelCase<Arguments>) {
if (!argv.message) {
const read = await import('read');
// @ts-expect-error
const prompt = promisify(read.default as typeof read);
argv.message = await prompt({
prompt: `Message: `,
output: process.stderr,
prompt: 'Message: ',
});
}

View File

@@ -1,3 +1,4 @@
import process from 'node:process';
import createDebug from 'debug';
import type { Arguments as ParentArguments } from '../cli.js';
import { Argv, YargsArguments } from '../util/yargs.js';

View File

@@ -1,12 +1,12 @@
import * as util from 'util';
import * as crypto from 'node:crypto';
import createDebug from 'debug';
import * as crypto from 'crypto';
import type { Arguments as ParentArguments } from '../nso.js';
import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js';
import { initStorage } from '../../util/storage.js';
import { getToken } from '../../common/auth/nso.js';
import { getNintendoAccountSessionToken } from '../../api/na.js';
import { ZNCA_CLIENT_ID } from '../../api/znc.js';
import prompt from '../util/prompt.js';
const debug = createDebug('cli:nso:auth');
@@ -59,13 +59,8 @@ export async function handler(argv: ArgumentsCamelCase<Arguments>) {
console.log('2. On the "Linking an External Account" page, right click "Select this person" and copy the link. It should start with "npf71b963c1b7b6d119://auth".');
console.log('');
const read = await import('read');
// @ts-expect-error
const prompt = util.promisify(read.default as typeof read);
const applink = await prompt({
prompt: `Paste the link: `,
output: process.stderr,
});
console.log('');

View File

@@ -1,4 +1,4 @@
import * as net from 'net';
import * as net from 'node:net';
import createDebug from 'debug';
import express, { Request, Response } from 'express';
import bodyParser from 'body-parser';

View File

@@ -1,4 +1,4 @@
import * as path from 'path';
import * as path from 'node:path';
import createDebug from 'debug';
import persist from 'node-persist';
import notifier from 'node-notifier';

View File

@@ -146,7 +146,7 @@ export async function handler(argv: ArgumentsCamelCase<Arguments>) {
DiscordPresencePlayTime.DETAILED_PLAY_TIME_SINCE;
i.discord_preconnect = argv.discordPreconnect;
if (argv.discordUser) i.discord_client_filter = (client, id) => client.user.id === argv.discordUser;
if (argv.discordUser) i.discord_client_filter = (client, id) => client.user?.id === argv.discordUser;
if (argv.splatnet2Monitor) {
const storage = await initStorage(argv.dataPath);
@@ -213,7 +213,7 @@ export async function handler(argv: ArgumentsCamelCase<Arguments>) {
i.presence_user = argv.friendNsaid ?? data?.nsoAccount.user.nsaId;
i.discord_preconnect = argv.discordPreconnect;
if (argv.discordUser) i.discord_client_filter = (client, id) => client.user.id === argv.discordUser;
if (argv.discordUser) i.discord_client_filter = (client, id) => client.user?.id === argv.discordUser;
console.warn('Authenticated as Nintendo Account %s (NA %s, NSO %s)',
data.user.screenName, data.user.nickname, data.nsoAccount.user.name);

View File

@@ -1,9 +1,9 @@
import * as util from 'util';
import createDebug from 'debug';
import type { Arguments as ParentArguments } from '../nso.js';
import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js';
import { initStorage } from '../../util/storage.js';
import { getToken } from '../../common/auth/nso.js';
import prompt from '../util/prompt.js';
const debug = createDebug('cli:nso:token');
@@ -26,14 +26,9 @@ export async function handler(argv: ArgumentsCamelCase<Arguments>) {
const storage = await initStorage(argv.dataPath);
if (!argv.token) {
const read = await import('read');
// @ts-expect-error
const prompt = util.promisify(read.default as typeof read);
argv.token = await prompt({
prompt: `Token: `,
silent: true,
output: process.stderr,
});
}

View File

@@ -1,5 +1,4 @@
import * as util from 'util';
import * as crypto from 'crypto';
import * as crypto from 'node:crypto';
import createDebug from 'debug';
import type { Arguments as ParentArguments } from '../pctl.js';
import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js';
@@ -7,6 +6,7 @@ import { initStorage } from '../../util/storage.js';
import { getPctlToken } from '../../common/auth/moon.js';
import { getNintendoAccountSessionToken } from '../../api/na.js';
import { ZNMA_CLIENT_ID } from '../../api/moon.js';
import prompt from '../util/prompt.js';
const debug = createDebug('cli:pctl:auth');
@@ -72,14 +72,8 @@ export async function handler(argv: ArgumentsCamelCase<Arguments>) {
console.log('2. On the "Linking an External Account" page, right click "Select this person" and copy the link. It should start with "npf54789befb391a838://auth".');
console.log('');
const read = await import('read');
// @ts-expect-error
const prompt = util.promisify(read.default as typeof read);
const applink = await prompt({
prompt: `Paste the link: `,
// silent: true,
output: process.stderr,
});
console.log('');

View File

@@ -1,5 +1,5 @@
import * as path from 'path';
import * as fs from 'fs/promises';
import * as path from 'node:path';
import * as fs from 'node:fs/promises';
import createDebug from 'debug';
import mkdirp from 'mkdirp';
import type { Arguments as ParentArguments } from '../pctl.js';

View File

@@ -1,9 +1,9 @@
import * as util from 'util';
import createDebug from 'debug';
import type { Arguments as ParentArguments } from '../pctl.js';
import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js';
import { initStorage } from '../../util/storage.js';
import { getPctlToken } from '../../common/auth/moon.js';
import prompt from '../util/prompt.js';
const debug = createDebug('cli:pctl:token');
@@ -26,14 +26,9 @@ export async function handler(argv: ArgumentsCamelCase<Arguments>) {
const storage = await initStorage(argv.dataPath);
if (!argv.token) {
const read = await import('read');
// @ts-expect-error
const prompt = util.promisify(read.default as typeof read);
argv.token = await prompt({
prompt: `Token: `,
silent: true,
output: process.stderr,
});
}

View File

@@ -1,3 +1,4 @@
import process from 'node:process';
import createDebug from 'debug';
import type { Arguments as ParentArguments } from '../cli.js';
import { Argv, YargsArguments } from '../util/yargs.js';

View File

@@ -1,5 +1,5 @@
import * as path from 'path';
import * as fs from 'fs/promises';
import * as path from 'node:path';
import * as fs from 'node:fs/promises';
import createDebug from 'debug';
import mkdirp from 'mkdirp';
import type { Arguments as ParentArguments } from '../splatnet2.js';

View File

@@ -1,4 +1,4 @@
import * as path from 'path';
import * as path from 'node:path';
import createDebug from 'debug';
import mkdirp from 'mkdirp';
import type { Arguments as ParentArguments } from '../splatnet2.js';

View File

@@ -1,4 +1,4 @@
import * as path from 'path';
import * as path from 'node:path';
import createDebug from 'debug';
import { getIksmToken } from '../../common/auth/splatnet2.js';
import { ArgumentsCamelCase, Argv, YargsArguments } from '../../util/yargs.js';

View File

@@ -1,5 +1,5 @@
import * as path from 'path';
import * as fs from 'fs/promises';
import * as path from 'node:path';
import * as fs from 'node:fs/promises';
import fetch from 'node-fetch';
import createDebug from 'debug';
import mkdirp from 'mkdirp';

View File

@@ -1,5 +1,5 @@
import * as crypto from 'crypto';
import { Buffer } from 'buffer';
import * as crypto from 'node:crypto';
import { Buffer } from 'node:buffer';
import createDebug from 'debug';
import type { Arguments as ParentArguments } from '../util.js';
import { Argv } from '../../util/yargs.js';

View File

@@ -1,3 +1,4 @@
import process from 'node:process';
import createDebug from 'debug';
import fetch from 'node-fetch';
import { getPresenceFromUrl } from '../../api/znc-proxy.js';

17
src/cli/util/prompt.ts Normal file
View File

@@ -0,0 +1,17 @@
import process from 'node:process';
import { promisify } from 'node:util';
import { Options } from 'read';
export default async function prompt(options: Options) {
const read = await import('read');
const prompt = promisify(read.default);
return await prompt({
output: process.stderr,
...options,
});
}
export {
Options,
};

View File

@@ -1,3 +1,4 @@
import process from 'node:process';
import createDebug from 'debug';
import type { Arguments as ParentArguments } from '../util.js';
import { ArgumentsCamelCase } from '../../util/yargs.js';

View File

@@ -1,4 +1,5 @@
import * as fs from 'fs';
import process from 'node:process';
import * as fs from 'node:fs';
import createDebug from 'debug';
import persist from 'node-persist';
import { getToken } from './nso.js';

View File

@@ -1,8 +1,9 @@
import * as path from 'path';
import * as fs from 'fs/promises';
import * as path from 'node:path';
import * as fs from 'node:fs/promises';
import * as crypto from 'node:crypto';
import { Buffer } from 'node:buffer';
import createDebug from 'debug';
import fetch from 'node-fetch';
import * as crypto from 'crypto';
import SplatNet2Api, { ShareColour } from '../../api/splatnet2.js';
import { Challenge, NicknameAndIcon, Records, Stages } from '../../api/splatnet2-types.js';

View File

@@ -1,5 +1,6 @@
import * as path from 'path';
import * as fs from 'fs/promises';
import * as path from 'node:path';
import * as fs from 'node:fs/promises';
import { Buffer } from 'node:buffer';
import createDebug from 'debug';
import fetch from 'node-fetch';
import SplatNet2Api from '../../api/splatnet2.js';

View File

@@ -1,5 +1,5 @@
import * as path from 'path';
import * as fs from 'fs/promises';
import * as path from 'node:path';
import * as fs from 'node:fs/promises';
import createDebug from 'debug';
import persist from 'node-persist';
import mkdirp from 'mkdirp';

View File

@@ -1,5 +1,6 @@
import * as net from 'net';
import { createRequire } from 'module';
import process from 'node:process';
import * as net from 'node:net';
import { createRequire } from 'node:module';
import createDebug from 'debug';
import fetch from 'node-fetch';
import DiscordRPC from 'discord-rpc';

View File

@@ -1,4 +1,5 @@
import * as crypto from 'crypto';
import * as crypto from 'node:crypto';
import { Buffer } from 'node:buffer';
import createDebug from 'debug';
import persist from 'node-persist';
import fetch from 'node-fetch';

View File

@@ -1,7 +1,8 @@
import * as path from 'path';
import { fileURLToPath } from 'url';
import * as fs from 'fs';
import * as child_process from 'child_process';
import process from 'node:process';
import * as path from 'node:path';
import { fileURLToPath } from 'node:url';
import * as fs from 'node:fs';
import * as child_process from 'node:child_process';
import createDebug from 'debug';
const debug = createDebug('nxapi:util:product');

View File

@@ -1,4 +1,4 @@
import * as path from 'path';
import * as path from 'node:path';
import createDebug from 'debug';
import persist from 'node-persist';
import getPaths from 'env-paths';

View File

@@ -1,13 +1,18 @@
{
"compilerOptions": {
"strict": true,
"target": "es2015",
"target": "es2020",
"module": "es2022",
"jsx": "react",
"moduleResolution": "node12",
"moduleResolution": "node16",
"allowSyntheticDefaultImports": true,
"declaration": true,
"importHelpers": true,
"rootDir": "src",
"outDir": "dist",
"lib": [
"es2020"
],
"skipLibCheck": true,
"allowJs": true
},