diff --git a/package-lock.json b/package-lock.json index 1ca9442..260c941 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,7 +25,6 @@ "supports-color": "^8.1.1", "tslib": "^2.4.1", "undici": "^5.22.1", - "uuid": "^8.3.2", "yargs": "^17.6.2" }, "bin": { @@ -51,7 +50,6 @@ "@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.14", "electron": "^21.3.1", "electron-builder": "^23.6.0", @@ -632,12 +630,6 @@ "@types/node": "*" } }, - "node_modules/@types/uuid": { - "version": "8.3.4", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", - "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==", - "dev": true - }, "node_modules/@types/verror": { "version": "1.10.6", "resolved": "https://registry.npmjs.org/@types/verror/-/verror-1.10.6.tgz", @@ -5045,12 +5037,6 @@ "@types/node": "*" } }, - "@types/uuid": { - "version": "8.3.4", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-8.3.4.tgz", - "integrity": "sha512-c/I8ZRb51j+pYGAu5CrFMRxqZ2ke4y2grEBO5AUjgSkSk+qT2Ea+OdWElz/OiMf5MNpn2b17kuVBwZLQJXzihw==", - "dev": true - }, "@types/verror": { "version": "1.10.6", "resolved": "https://registry.npmjs.org/@types/verror/-/verror-1.10.6.tgz", diff --git a/package.json b/package.json index db10dc1..c9f0d69 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,6 @@ "supports-color": "^8.1.1", "tslib": "^2.4.1", "undici": "^5.22.1", - "uuid": "^8.3.2", "yargs": "^17.6.2" }, "devDependencies": { @@ -75,7 +74,6 @@ "@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.14", "electron": "^21.3.1", "electron-builder": "^23.6.0", diff --git a/src/api/coral.ts b/src/api/coral.ts index 066407d..5d2f455 100644 --- a/src/api/coral.ts +++ b/src/api/coral.ts @@ -1,5 +1,5 @@ +import { randomUUID } from 'node:crypto'; import { fetch, Response } from 'undici'; -import { v4 as uuidgen } from 'uuid'; import createDebug from '../util/debug.js'; import { JwtPayload } from '../util/jwt.js'; import { timeoutSignal } from '../util/misc.js'; @@ -185,7 +185,7 @@ export default class CoralApi implements CoralApiInterface { url: string, parameter = {}, /** @internal */ _autoRenewToken = true ) { - const uuid = uuidgen(); + const uuid = randomUUID(); return this.fetch(url, 'POST', JSON.stringify({ parameter, diff --git a/src/api/f.ts b/src/api/f.ts index d182827..f045818 100644 --- a/src/api/f.ts +++ b/src/api/f.ts @@ -1,6 +1,6 @@ import process from 'node:process'; +import { randomUUID } from 'node:crypto'; import { fetch, Headers } from 'undici'; -import { v4 as uuidgen } from 'uuid'; import { defineResponse, ErrorResponse } from './util.js'; import createDebug from '../util/debug.js'; import { timeoutSignal } from '../util/misc.js'; @@ -91,7 +91,7 @@ export type FlapgApiError = IminkFError; export class ZncaApiFlapg extends ZncaApi { async genf(token: string, hash_method: HashMethod) { - const request_id = uuidgen(); + const request_id = randomUUID(); const result = await flapg(hash_method, token, undefined, request_id, this.useragent); @@ -174,7 +174,7 @@ export interface IminkFError { export class ZncaApiImink extends ZncaApi { async genf(token: string, hash_method: HashMethod, user?: {na_id: string; coral_user_id?: string;}) { - const request_id = uuidgen(); + const request_id = randomUUID(); const result = await iminkf(hash_method, token, undefined, request_id, user, this.useragent); @@ -271,7 +271,7 @@ export class ZncaApiNxapi extends ZncaApi { } async genf(token: string, hash_method: HashMethod, user?: {na_id: string; coral_user_id?: string}) { - const request_id = uuidgen(); + const request_id = randomUUID(); const result = await genf(this.url + '/f', hash_method, token, undefined, request_id, user, this.app, this.useragent); diff --git a/src/api/splatnet2.ts b/src/api/splatnet2.ts index aa68f96..a167963 100644 --- a/src/api/splatnet2.ts +++ b/src/api/splatnet2.ts @@ -1,5 +1,5 @@ +import { randomUUID } from 'node:crypto'; import { Cookie, fetch, FormData, getSetCookies } from 'undici'; -import { v4 as uuidgen } from 'uuid'; import { WebServiceToken } from './coral-types.js'; import { NintendoAccountUser } from './na.js'; import { defineResponse, ErrorResponse } from './util.js'; @@ -193,7 +193,7 @@ export default class SplatNet2Api { } async shareProfile(stage: string, colour: ShareColour) { - const boundary = uuidgen(); + const boundary = randomUUID(); const data = `--${boundary} Content-Disposition: form-data; name="stage" diff --git a/src/cli/nso/http-server.ts b/src/cli/nso/http-server.ts index 8b48800..0b41c39 100644 --- a/src/cli/nso/http-server.ts +++ b/src/cli/nso/http-server.ts @@ -1,9 +1,9 @@ import * as net from 'node:net'; import * as os from 'node:os'; +import { randomUUID } from 'node:crypto'; import * as persist from 'node-persist'; import express, { Request, RequestHandler, Response } from 'express'; import bodyParser from 'body-parser'; -import { v4 as uuidgen } from 'uuid'; import type { Arguments as ParentArguments } from '../nso.js'; import CoralApi, { CoralApiInterface, CoralErrorResponse } from '../../api/coral.js'; import { Announcement, CoralStatus, CurrentUser, Friend, FriendCodeUrl, FriendCodeUser, Presence } from '../../api/coral-types.js'; @@ -361,7 +361,8 @@ class Server extends HttpServer { } async handleCreateTokenRequest({req, user}: RequestDataWithUser) { - const token = uuidgen(); + const token = randomUUID(); + const auth: AuthToken = { user: user.data.user.id, policy: req.body.policy,