1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-22 03:03:43 +00:00
Files
browser/libs/common/src/key-management/pin/pin.state.ts
Bernd Schoolmann 51d29f777e [PM-24353] Drop legacy pin support (#17328)
* Drop legacy pin support

* Fix cli build

* Fix browser build

* Remove pin key

* Fix comment

* Fix CI / tests

* Add migration to remove key

* Inline export key

* Extract vault export key generation

* Cleanup

* Add migrator

* Fix mv2 build
2025-12-11 13:01:09 +01:00

46 lines
1.4 KiB
TypeScript

import { PIN_DISK, PIN_MEMORY, UserKeyDefinition } from "@bitwarden/common/platform/state";
import { PasswordProtectedKeyEnvelope } from "@bitwarden/sdk-internal";
import { EncryptedString } from "../crypto/models/enc-string";
/**
* The persistent (stored on disk) version of the UserKey, stored in a `PasswordProtectedKeyEnvelope`.
*
* @remarks Persists through a client reset. Used when `requireMasterPasswordOnClientRestart` is disabled.
* @see SetPinComponent.setPinForm.requireMasterPasswordOnClientRestart
*/
export const PIN_PROTECTED_USER_KEY_ENVELOPE_PERSISTENT =
new UserKeyDefinition<PasswordProtectedKeyEnvelope>(
PIN_DISK,
"pinProtectedUserKeyEnvelopePersistent",
{
deserializer: (jsonValue) => jsonValue,
clearOn: ["logout"],
},
);
/**
* The ephemeral (stored in memory) version of the UserKey, stored in a `PasswordProtectedKeyEnvelope`.
*/
export const PIN_PROTECTED_USER_KEY_ENVELOPE_EPHEMERAL =
new UserKeyDefinition<PasswordProtectedKeyEnvelope>(
PIN_MEMORY,
"pinProtectedUserKeyEnvelopeEphemeral",
{
deserializer: (jsonValue) => jsonValue,
clearOn: ["logout"],
},
);
/**
* The PIN, encrypted by the UserKey.
*/
export const USER_KEY_ENCRYPTED_PIN = new UserKeyDefinition<EncryptedString>(
PIN_DISK,
"userKeyEncryptedPin",
{
deserializer: (jsonValue) => jsonValue,
clearOn: ["logout"],
},
);