fix: Add username to the tokenStoreKey so the saved token is invalidated when the user changes in the environment (#426)

Co-authored-by: Gregory Schier <gschier1990@gmail.com>
This commit is contained in:
Michaël Arnauts
2026-08-14 13:50:48 -07:00
committed by GitHub
co-authored by Gregory Schier
parent 4f03c5c390
commit be004425fa
4 changed files with 68 additions and 0 deletions
+2
View File
@@ -47,6 +47,7 @@ export interface TokenStoreArgs {
clientId: string;
accessTokenUrl: string | null;
authorizationUrl: string | null;
username?: string | null;
}
/**
@@ -59,6 +60,7 @@ function tokenStoreKey(args: TokenStoreArgs) {
if (args.clientId) hash.update(args.clientId.trim());
if (args.accessTokenUrl) hash.update(args.accessTokenUrl.trim().replace(/^https?:\/\//, ""));
if (args.authorizationUrl) hash.update(args.authorizationUrl.trim().replace(/^https?:\/\//, ""));
if (args.username) hash.update(args.username);
const key = hash.digest("hex");
return ["token", key].join("::");
}