From b972f10e60acc393e1405d657d29e6439fdd9984 Mon Sep 17 00:00:00 2001 From: GW_MC <72297530+GWMCwing@users.noreply.github.com> Date: Fri, 23 Jan 2026 18:02:03 +0800 Subject: [PATCH] patched discord rpc for refresh token --- package.json | 6 ++++++ patches/@types__discord-rpc@4.0.10.patch | 14 ++++++++++++ patches/discord-rpc@4.0.1.patch | 27 ++++++++++++++++++++++++ pnpm-lock.yaml | 16 ++++++++++---- 4 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 patches/@types__discord-rpc@4.0.10.patch create mode 100644 patches/discord-rpc@4.0.1.patch diff --git a/package.json b/package.json index 9733aa3..8d853d4 100644 --- a/package.json +++ b/package.json @@ -22,5 +22,11 @@ "@types/node": "^25.0.10", "tsx": "^4.21.0", "typescript": "^5.9.3" + }, + "pnpm": { + "patchedDependencies": { + "discord-rpc@4.0.1": "patches/discord-rpc@4.0.1.patch", + "@types/discord-rpc@4.0.10": "patches/@types__discord-rpc@4.0.10.patch" + } } } \ No newline at end of file diff --git a/patches/@types__discord-rpc@4.0.10.patch b/patches/@types__discord-rpc@4.0.10.patch new file mode 100644 index 0000000..7e4534f --- /dev/null +++ b/patches/@types__discord-rpc@4.0.10.patch @@ -0,0 +1,14 @@ +diff --git a/index.d.ts b/index.d.ts +index 04480d88d0cd2e21f8a7e2ef9878d6984b14fff5..81285e7e54381362925cc93ccd3f51ff087b5763 100644 +--- a/index.d.ts ++++ b/index.d.ts +@@ -52,6 +52,9 @@ export class BaseClient extends EventEmitter {} + * The main hub for interacting with Discord RPC + */ + export class Client extends BaseClient { ++ accessToken: string | null; ++ refreshToken: string | null; ++ accessTokenExpiresAt: number | null; + /** + * @param options Options for the client. + * You must provide a transport diff --git a/patches/discord-rpc@4.0.1.patch b/patches/discord-rpc@4.0.1.patch new file mode 100644 index 0000000..55d350e --- /dev/null +++ b/patches/discord-rpc@4.0.1.patch @@ -0,0 +1,27 @@ +diff --git a/src/client.js b/src/client.js +index 0ff29daa9ac1cd4f406944b3e195738d520b2c57..90ef5dc7228e8b1678f72e2573b42bd222a527c1 100644 +--- a/src/client.js ++++ b/src/client.js +@@ -32,6 +32,8 @@ class RPCClient extends EventEmitter { + this.options = options; + + this.accessToken = null; ++ this.refreshToken = null; ++ this.accessTokenExpiresAt = null; + this.clientId = null; + + /** +@@ -222,6 +224,13 @@ class RPCClient extends EventEmitter { + }), + }); + ++ const { ++ access_token, refresh_token, expires_in ++ } = response; ++ ++ this.refreshToken = refresh_token; ++ this.accessTokenExpiresAt = Date.now() + (expires_in * 1000); ++ + return response.access_token; + } + diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index b8012ab..7d016c7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,14 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +patchedDependencies: + '@types/discord-rpc@4.0.10': + hash: jkq6l3q3zsza22tiqsryj6war4 + path: patches/@types__discord-rpc@4.0.10.patch + discord-rpc@4.0.1: + hash: sqrsp2dfxm56uqm2hxrxu3bbpi + path: patches/discord-rpc@4.0.1.patch + importers: .: @@ -13,14 +21,14 @@ importers: version: 1.13.2 discord-rpc: specifier: ^4.0.1 - version: 4.0.1 + version: 4.0.1(patch_hash=sqrsp2dfxm56uqm2hxrxu3bbpi) dotenv: specifier: ^17.2.3 version: 17.2.3 devDependencies: '@types/discord-rpc': specifier: ^4.0.10 - version: 4.0.10 + version: 4.0.10(patch_hash=jkq6l3q3zsza22tiqsryj6war4) '@types/node': specifier: ^25.0.10 version: 25.0.10 @@ -450,7 +458,7 @@ snapshots: '@esbuild/win32-x64@0.27.2': optional: true - '@types/discord-rpc@4.0.10': + '@types/discord-rpc@4.0.10(patch_hash=jkq6l3q3zsza22tiqsryj6war4)': dependencies: '@types/events': 3.0.3 @@ -486,7 +494,7 @@ snapshots: delayed-stream@1.0.0: {} - discord-rpc@4.0.1: + discord-rpc@4.0.1(patch_hash=sqrsp2dfxm56uqm2hxrxu3bbpi): dependencies: node-fetch: 2.7.0 ws: 7.5.10