From 0f97a89a87a7f97abbcc518b15d67c92521925a0 Mon Sep 17 00:00:00 2001 From: Jacob Fink Date: Fri, 7 Jul 2023 09:39:37 -0400 Subject: [PATCH] rename enc user key setter in crypto service --- .../src/auth/login-strategies/password-login.strategy.spec.ts | 2 +- .../common/src/auth/login-strategies/password-login.strategy.ts | 2 +- .../auth/login-strategies/passwordless-login.strategy.spec.ts | 2 +- .../src/auth/login-strategies/passwordless-login.strategy.ts | 2 +- libs/common/src/auth/login-strategies/sso-login.strategy.ts | 2 +- .../src/auth/login-strategies/user-api-login.strategy.spec.ts | 2 +- .../common/src/auth/login-strategies/user-api-login.strategy.ts | 2 +- libs/common/src/auth/services/key-connector.service.ts | 2 +- libs/common/src/platform/abstractions/crypto.service.ts | 2 +- libs/common/src/platform/services/crypto.service.ts | 2 +- libs/common/src/vault/services/sync/sync.service.ts | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/libs/common/src/auth/login-strategies/password-login.strategy.spec.ts b/libs/common/src/auth/login-strategies/password-login.strategy.spec.ts index fd6a32ddcb..52100d1749 100644 --- a/libs/common/src/auth/login-strategies/password-login.strategy.spec.ts +++ b/libs/common/src/auth/login-strategies/password-login.strategy.spec.ts @@ -143,7 +143,7 @@ describe("PasswordLogInStrategy", () => { expect(cryptoService.setMasterKey).toHaveBeenCalledWith(masterKey); expect(cryptoService.setPasswordHash).toHaveBeenCalledWith(localHashedPassword); - expect(cryptoService.setUserKeyMasterKey).toHaveBeenCalledWith(tokenResponse.key); + expect(cryptoService.setMasterKeyEncryptedUserKey).toHaveBeenCalledWith(tokenResponse.key); expect(cryptoService.setUserKey).toHaveBeenCalledWith(userKey); expect(cryptoService.setPrivateKey).toHaveBeenCalledWith(tokenResponse.privateKey); }); diff --git a/libs/common/src/auth/login-strategies/password-login.strategy.ts b/libs/common/src/auth/login-strategies/password-login.strategy.ts index 744e0b2b7b..27311346c4 100644 --- a/libs/common/src/auth/login-strategies/password-login.strategy.ts +++ b/libs/common/src/auth/login-strategies/password-login.strategy.ts @@ -147,7 +147,7 @@ export class PasswordLogInStrategy extends LogInStrategy { } protected override async setUserKey(response: IdentityTokenResponse): Promise { - await this.cryptoService.setUserKeyMasterKey(response.key); + await this.cryptoService.setMasterKeyEncryptedUserKey(response.key); const masterKey = await this.cryptoService.getMasterKey(); if (masterKey) { diff --git a/libs/common/src/auth/login-strategies/passwordless-login.strategy.spec.ts b/libs/common/src/auth/login-strategies/passwordless-login.strategy.spec.ts index 49b2f76927..62d7b20349 100644 --- a/libs/common/src/auth/login-strategies/passwordless-login.strategy.spec.ts +++ b/libs/common/src/auth/login-strategies/passwordless-login.strategy.spec.ts @@ -94,7 +94,7 @@ describe("SsoLogInStrategy", () => { expect(cryptoService.setMasterKey).toHaveBeenCalledWith(masterKey); expect(cryptoService.setPasswordHash).toHaveBeenCalledWith(localPasswordHash); - expect(cryptoService.setUserKeyMasterKey).toHaveBeenCalledWith(tokenResponse.key); + expect(cryptoService.setMasterKeyEncryptedUserKey).toHaveBeenCalledWith(tokenResponse.key); expect(cryptoService.setUserKey).toHaveBeenCalledWith(userKey); expect(cryptoService.setPrivateKey).toHaveBeenCalledWith(tokenResponse.privateKey); }); diff --git a/libs/common/src/auth/login-strategies/passwordless-login.strategy.ts b/libs/common/src/auth/login-strategies/passwordless-login.strategy.ts index 2138b6159f..de2a3c2a19 100644 --- a/libs/common/src/auth/login-strategies/passwordless-login.strategy.ts +++ b/libs/common/src/auth/login-strategies/passwordless-login.strategy.ts @@ -85,7 +85,7 @@ export class PasswordlessLogInStrategy extends LogInStrategy { } protected override async setUserKey(response: IdentityTokenResponse): Promise { - await this.cryptoService.setUserKeyMasterKey(response.key); + await this.cryptoService.setMasterKeyEncryptedUserKey(response.key); const masterKey = await this.cryptoService.getMasterKey(); if (masterKey) { diff --git a/libs/common/src/auth/login-strategies/sso-login.strategy.ts b/libs/common/src/auth/login-strategies/sso-login.strategy.ts index d29fa83afc..2c4e9aad86 100644 --- a/libs/common/src/auth/login-strategies/sso-login.strategy.ts +++ b/libs/common/src/auth/login-strategies/sso-login.strategy.ts @@ -83,7 +83,7 @@ export class SsoLogInStrategy extends LogInStrategy { const newSsoUser = tokenResponse.key == null; if (!newSsoUser) { - await this.cryptoService.setUserKeyMasterKey(tokenResponse.key); + await this.cryptoService.setMasterKeyEncryptedUserKey(tokenResponse.key); if (tokenResponse.keyConnectorUrl != null) { const masterKey = await this.cryptoService.getMasterKey(); diff --git a/libs/common/src/auth/login-strategies/user-api-login.strategy.spec.ts b/libs/common/src/auth/login-strategies/user-api-login.strategy.spec.ts index 57121674d6..8c55ff164a 100644 --- a/libs/common/src/auth/login-strategies/user-api-login.strategy.spec.ts +++ b/libs/common/src/auth/login-strategies/user-api-login.strategy.spec.ts @@ -114,7 +114,7 @@ describe("UserApiLogInStrategy", () => { await apiLogInStrategy.logIn(credentials); - expect(cryptoService.setUserKeyMasterKey).toHaveBeenCalledWith(tokenResponse.key); + expect(cryptoService.setMasterKeyEncryptedUserKey).toHaveBeenCalledWith(tokenResponse.key); expect(cryptoService.setPrivateKey).toHaveBeenCalledWith(tokenResponse.privateKey); }); diff --git a/libs/common/src/auth/login-strategies/user-api-login.strategy.ts b/libs/common/src/auth/login-strategies/user-api-login.strategy.ts index 286d861f11..bfb9349a9b 100644 --- a/libs/common/src/auth/login-strategies/user-api-login.strategy.ts +++ b/libs/common/src/auth/login-strategies/user-api-login.strategy.ts @@ -64,7 +64,7 @@ export class UserApiLogInStrategy extends LogInStrategy { } protected override async setUserKey(response: IdentityTokenResponse): Promise { - await this.cryptoService.setUserKeyMasterKey(response.key); + await this.cryptoService.setMasterKeyEncryptedUserKey(response.key); if (response.apiUseKeyConnector) { const masterKey = await this.cryptoService.getMasterKey(); diff --git a/libs/common/src/auth/services/key-connector.service.ts b/libs/common/src/auth/services/key-connector.service.ts index 52c7f810c1..c57e522dd7 100644 --- a/libs/common/src/auth/services/key-connector.service.ts +++ b/libs/common/src/auth/services/key-connector.service.ts @@ -99,7 +99,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction { const userKey = await this.cryptoService.makeUserKey(masterKey); await this.cryptoService.setUserKey(userKey[0]); - await this.cryptoService.setUserKeyMasterKey(userKey[1].encryptedString); + await this.cryptoService.setMasterKeyEncryptedUserKey(userKey[1].encryptedString); const [pubKey, privKey] = await this.cryptoService.makeKeyPair(); diff --git a/libs/common/src/platform/abstractions/crypto.service.ts b/libs/common/src/platform/abstractions/crypto.service.ts index 01c8a6198a..6894edb625 100644 --- a/libs/common/src/platform/abstractions/crypto.service.ts +++ b/libs/common/src/platform/abstractions/crypto.service.ts @@ -90,7 +90,7 @@ export abstract class CryptoService { * @param userKeyMasterKey The master key encrypted user key to set * @param userId The desired user */ - setUserKeyMasterKey: (UserKeyMasterKey: string, userId?: string) => Promise; + setMasterKeyEncryptedUserKey: (UserKeyMasterKey: string, userId?: string) => Promise; /** * Sets the user's master key * @param key The user's master key to set diff --git a/libs/common/src/platform/services/crypto.service.ts b/libs/common/src/platform/services/crypto.service.ts index fe4a867909..e2c7576994 100644 --- a/libs/common/src/platform/services/crypto.service.ts +++ b/libs/common/src/platform/services/crypto.service.ts @@ -134,7 +134,7 @@ export class CryptoService implements CryptoServiceAbstraction { } } - async setUserKeyMasterKey(userKeyMasterKey: string, userId?: string): Promise { + async setMasterKeyEncryptedUserKey(userKeyMasterKey: string, userId?: string): Promise { await this.stateService.setUserKeyMasterKey(userKeyMasterKey, { userId: userId }); } diff --git a/libs/common/src/vault/services/sync/sync.service.ts b/libs/common/src/vault/services/sync/sync.service.ts index c17deca359..60ed0ee4b6 100644 --- a/libs/common/src/vault/services/sync/sync.service.ts +++ b/libs/common/src/vault/services/sync/sync.service.ts @@ -303,7 +303,7 @@ export class SyncService implements SyncServiceAbstraction { throw new Error("Stamp has changed"); } - await this.cryptoService.setUserKeyMasterKey(response.key); + await this.cryptoService.setMasterKeyEncryptedUserKey(response.key); await this.cryptoService.setPrivateKey(response.privateKey); await this.cryptoService.setProviderKeys(response.providers); await this.cryptoService.setOrgKeys(response.organizations, response.providerOrganizations);