mirror of
https://github.com/bitwarden/browser
synced 2026-02-09 05:00:10 +00:00
Moved token state to disk to persist through application close.
This commit is contained in:
@@ -42,7 +42,7 @@ import {
|
||||
EMAIL_TWO_FACTOR_TOKEN_RECORD_DISK_LOCAL,
|
||||
REFRESH_TOKEN_DISK,
|
||||
REFRESH_TOKEN_MEMORY,
|
||||
SECURITY_STAMP_MEMORY,
|
||||
SECURITY_STAMP_DISK,
|
||||
} from "./token.state";
|
||||
|
||||
// FIXME: update to use a const object instead of a typescript enum
|
||||
@@ -1045,7 +1045,7 @@ export class TokenService implements TokenServiceAbstraction {
|
||||
throw new Error("User id not found. Cannot get security stamp.");
|
||||
}
|
||||
|
||||
const securityStamp = await this.getStateValueByUserIdAndKeyDef(userId, SECURITY_STAMP_MEMORY);
|
||||
const securityStamp = await this.getStateValueByUserIdAndKeyDef(userId, SECURITY_STAMP_DISK);
|
||||
|
||||
return securityStamp;
|
||||
}
|
||||
@@ -1058,7 +1058,7 @@ export class TokenService implements TokenServiceAbstraction {
|
||||
}
|
||||
|
||||
await this.singleUserStateProvider
|
||||
.get(userId, SECURITY_STAMP_MEMORY)
|
||||
.get(userId, SECURITY_STAMP_DISK)
|
||||
.update((_) => securityStamp);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
EMAIL_TWO_FACTOR_TOKEN_RECORD_DISK_LOCAL,
|
||||
REFRESH_TOKEN_DISK,
|
||||
REFRESH_TOKEN_MEMORY,
|
||||
SECURITY_STAMP_MEMORY,
|
||||
SECURITY_STAMP_DISK,
|
||||
} from "./token.state";
|
||||
|
||||
describe.each([
|
||||
@@ -23,7 +23,7 @@ describe.each([
|
||||
[API_KEY_CLIENT_ID_MEMORY, "apiKeyClientIdMemory"],
|
||||
[API_KEY_CLIENT_SECRET_DISK, "apiKeyClientSecretDisk"],
|
||||
[API_KEY_CLIENT_SECRET_MEMORY, "apiKeyClientSecretMemory"],
|
||||
[SECURITY_STAMP_MEMORY, "securityStamp"],
|
||||
[SECURITY_STAMP_DISK, "securityStamp"],
|
||||
])(
|
||||
"deserializes state key definitions",
|
||||
(
|
||||
|
||||
@@ -70,7 +70,7 @@ export const API_KEY_CLIENT_SECRET_MEMORY = new UserKeyDefinition<string>(
|
||||
},
|
||||
);
|
||||
|
||||
export const SECURITY_STAMP_MEMORY = new UserKeyDefinition<string>(TOKEN_MEMORY, "securityStamp", {
|
||||
export const SECURITY_STAMP_DISK = new UserKeyDefinition<string>(TOKEN_DISK, "securityStamp", {
|
||||
deserializer: (securityStamp) => securityStamp,
|
||||
clearOn: ["logout"],
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user