Identify: hold onto access token
2 files changed, 4 insertions, 1 deletions
diff --git a/src/gateway/opcodes/Identify.ts b/src/gateway/opcodes/Identify.ts
index e9b91a3d..77421765 100644
--- a/src/gateway/opcodes/Identify.ts
+++ b/src/gateway/opcodes/Identify.ts
@@ -96,6 +96,8 @@ export async function onIdentify(this: WebSocket, data: Payload) {
}),
);
+ this.accessToken = identify.token;
+
taskSw.reset(); // don't include checkToken time...
const user = tokenData.user;
@@ -634,7 +636,7 @@ export async function onIdentify(this: WebSocket, data: Payload) {
});
if (this.capabilities.has(Capabilities.FLAGS.AUTH_TOKEN_REFRESH) && tokenData.tokenVersion != CurrentTokenFormatVersion) {
- d.auth_token = await generateToken(this.user_id);
+ d.auth_token = this.accessToken = (await generateToken(this.user_id))!;
}
// const buildReadyEventDataTime = taskSw.getElapsedAndReset();
diff --git a/src/gateway/util/WebSocket.ts b/src/gateway/util/WebSocket.ts
index af085421..301b0515 100644
--- a/src/gateway/util/WebSocket.ts
+++ b/src/gateway/util/WebSocket.ts
@@ -27,6 +27,7 @@ export interface WebSocket extends WS {
version: number;
user_id: string;
session_id: string;
+ accessToken: string;
encoding: "etf" | "json";
compress?: "zlib-stream" | "zstd-stream";
ipAddress?: string;
|