From f0438e5dd2f84b77d9fc4fa765584ff3f3621e07 Mon Sep 17 00:00:00 2001 From: Jacob Fink Date: Tue, 30 May 2023 10:45:03 -0400 Subject: [PATCH] add setUserSymKeyMasterKey so we can set the encrypted user sym key from server --- .../common/src/platform/abstractions/crypto.service.ts | 1 + libs/common/src/platform/services/crypto.service.ts | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/libs/common/src/platform/abstractions/crypto.service.ts b/libs/common/src/platform/abstractions/crypto.service.ts index 8dee1002426..62aa2d4ebe1 100644 --- a/libs/common/src/platform/abstractions/crypto.service.ts +++ b/libs/common/src/platform/abstractions/crypto.service.ts @@ -25,6 +25,7 @@ export abstract class CryptoService { makeUserSymKey: (key: SymmetricCryptoKey) => Promise<[SymmetricCryptoKey, EncString]>; clearUserKey: (clearSecretStorage?: boolean, userId?: string) => Promise; clearUserKeyFromStorage: (keySuffix: KeySuffixOptions) => Promise; + setUserSymKeyMasterKey: (UserSymKeyMasterKey: string, userId?: string) => Promise; setMasterKey: (key: MasterKey, userId?: string) => Promise; getMasterKey: (userId?: string) => Promise; makeMasterKey: ( diff --git a/libs/common/src/platform/services/crypto.service.ts b/libs/common/src/platform/services/crypto.service.ts index bed1218fddf..5b880850fdb 100644 --- a/libs/common/src/platform/services/crypto.service.ts +++ b/libs/common/src/platform/services/crypto.service.ts @@ -180,6 +180,16 @@ export class CryptoService implements CryptoServiceAbstraction { : 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 { + // 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 * @param key The user's master key to set