fix(game-api): revoke token after prestart deletion

This commit is contained in:
2026-07-31 17:42:03 +00:00
parent 21d204c749
commit 596d01b6f4
6 changed files with 78 additions and 2 deletions
+12
View File
@@ -6,6 +6,7 @@ import { isValid, parseISO } from 'date-fns';
interface RedisClientLike {
get(key: string): Promise<string | null>;
set(key: string, value: string, options?: { EX?: number; NX?: boolean }): Promise<string | null>;
del?(key: string): Promise<number>;
}
const ACCESS_TOKEN_PREFIX = 'ga_';
@@ -72,6 +73,17 @@ export class RedisAccessTokenStore {
}
}
async revoke(accessToken: string): Promise<boolean> {
if (!RedisAccessTokenStore.isAccessToken(accessToken)) {
return false;
}
if (!this.client.del) {
throw new Error('Redis client does not support access token revocation.');
}
const key = buildAccessKey(this.profileName, accessToken);
return (await this.client.del(key)) > 0;
}
async markGatewayTokenUsed(sessionId: string, ttlSeconds: number): Promise<boolean> {
if (ttlSeconds <= 0) {
return false;