1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-16 16:23:44 +00:00

add setUserSymKeyMasterKey so we can set the encrypted user sym key from server

This commit is contained in:
Jacob Fink
2023-05-30 10:45:03 -04:00
parent c7feae6238
commit f0438e5dd2
2 changed files with 11 additions and 0 deletions

View File

@@ -25,6 +25,7 @@ export abstract class CryptoService {
makeUserSymKey: (key: SymmetricCryptoKey) => Promise<[SymmetricCryptoKey, EncString]>; makeUserSymKey: (key: SymmetricCryptoKey) => Promise<[SymmetricCryptoKey, EncString]>;
clearUserKey: (clearSecretStorage?: boolean, userId?: string) => Promise<void>; clearUserKey: (clearSecretStorage?: boolean, userId?: string) => Promise<void>;
clearUserKeyFromStorage: (keySuffix: KeySuffixOptions) => Promise<void>; clearUserKeyFromStorage: (keySuffix: KeySuffixOptions) => Promise<void>;
setUserSymKeyMasterKey: (UserSymKeyMasterKey: string, userId?: string) => Promise<void>;
setMasterKey: (key: MasterKey, userId?: string) => Promise<void>; setMasterKey: (key: MasterKey, userId?: string) => Promise<void>;
getMasterKey: (userId?: string) => Promise<MasterKey>; getMasterKey: (userId?: string) => Promise<MasterKey>;
makeMasterKey: ( makeMasterKey: (

View File

@@ -180,6 +180,16 @@ export class CryptoService implements CryptoServiceAbstraction {
: await this.stateService.setUserSymKeyBiometric(null); : await this.stateService.setUserSymKeyBiometric(null);
} }
/**
* Stores the master key encrypted user symmetric key
* @param userSymKeyMasterKey The master key encrypted user symmetric key to set
* @param userId The desired user
*/
async setUserSymKeyMasterKey(userSymKeyMasterKey: string, userId?: string): Promise<void> {
// TODO: is this the best way to handle this from the identity token?
await this.stateService.setUserSymKeyMasterKey(userSymKeyMasterKey, { userId: userId });
}
/** /**
* Sets the user's master key * Sets the user's master key
* @param key The user's master key to set * @param key The user's master key to set