mirror of
https://github.com/bitwarden/browser
synced 2025-12-22 19:23:52 +00:00
[deps] Autofill: Update prettier to v3 (#7014)
* [deps] Autofill: Update prettier to v3 * prettier formatting updates --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jonathan Prusik <jprusik@classynemesis.com>
This commit is contained in:
@@ -10,7 +10,7 @@ export class AccountApiServiceImplementation implements AccountApiService {
|
||||
private apiService: ApiService,
|
||||
private userVerificationService: UserVerificationService,
|
||||
private logService: LogService,
|
||||
private accountService: InternalAccountService
|
||||
private accountService: InternalAccountService,
|
||||
) {}
|
||||
|
||||
async deleteAccount(verification: Verification): Promise<void> {
|
||||
|
||||
@@ -21,7 +21,7 @@ export const ACCOUNT_ACCOUNTS = KeyDefinition.record<AccountInfo, UserId>(
|
||||
"accounts",
|
||||
{
|
||||
deserializer: (accountInfo) => accountInfo,
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
export const ACCOUNT_ACTIVE_ACCOUNT_ID = new KeyDefinition(ACCOUNT_MEMORY, "activeAccountId", {
|
||||
@@ -42,19 +42,19 @@ export class AccountServiceImplementation implements InternalAccountService {
|
||||
constructor(
|
||||
private messagingService: MessagingService,
|
||||
private logService: LogService,
|
||||
private globalStateProvider: GlobalStateProvider
|
||||
private globalStateProvider: GlobalStateProvider,
|
||||
) {
|
||||
this.accountsState = this.globalStateProvider.get(ACCOUNT_ACCOUNTS);
|
||||
this.activeAccountIdState = this.globalStateProvider.get(ACCOUNT_ACTIVE_ACCOUNT_ID);
|
||||
|
||||
this.accounts$ = this.accountsState.state$.pipe(
|
||||
map((accounts) => (accounts == null ? {} : accounts))
|
||||
map((accounts) => (accounts == null ? {} : accounts)),
|
||||
);
|
||||
this.activeAccount$ = this.activeAccountIdState.state$.pipe(
|
||||
combineLatestWith(this.accounts$),
|
||||
map(([id, accounts]) => (id ? { id, ...accounts[id] } : undefined)),
|
||||
distinctUntilChanged((a, b) => a?.id === b?.id && accountInfoEqual(a, b)),
|
||||
shareReplay({ bufferSize: 1, refCount: false })
|
||||
shareReplay({ bufferSize: 1, refCount: false }),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ export class AccountServiceImplementation implements InternalAccountService {
|
||||
// update only if userId changes
|
||||
return id !== userId;
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ export class AccountServiceImplementation implements InternalAccountService {
|
||||
|
||||
return !accountInfoEqual(accounts[userId], newAccountInfo(accounts[userId]));
|
||||
},
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ export class AnonymousHubService implements AnonymousHubServiceAbstraction {
|
||||
constructor(
|
||||
private environmentService: EnvironmentService,
|
||||
private authService: AuthService,
|
||||
private logService: LogService
|
||||
private logService: LogService,
|
||||
) {}
|
||||
|
||||
async createHubConnection(token: string) {
|
||||
@@ -51,7 +51,7 @@ export class AnonymousHubService implements AnonymousHubServiceAbstraction {
|
||||
|
||||
private async ProcessNotification(notification: NotificationResponse) {
|
||||
await this.authService.authResponsePushNotification(
|
||||
notification.payload as AuthRequestPushNotification
|
||||
notification.payload as AuthRequestPushNotification,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,23 +13,23 @@ export class AuthRequestCryptoServiceImplementation implements AuthRequestCrypto
|
||||
|
||||
async setUserKeyAfterDecryptingSharedUserKey(
|
||||
authReqResponse: AuthRequestResponse,
|
||||
authReqPrivateKey: Uint8Array
|
||||
authReqPrivateKey: Uint8Array,
|
||||
) {
|
||||
const userKey = await this.decryptPubKeyEncryptedUserKey(
|
||||
authReqResponse.key,
|
||||
authReqPrivateKey
|
||||
authReqPrivateKey,
|
||||
);
|
||||
await this.cryptoService.setUserKey(userKey);
|
||||
}
|
||||
|
||||
async setKeysAfterDecryptingSharedMasterKeyAndHash(
|
||||
authReqResponse: AuthRequestResponse,
|
||||
authReqPrivateKey: Uint8Array
|
||||
authReqPrivateKey: Uint8Array,
|
||||
) {
|
||||
const { masterKey, masterKeyHash } = await this.decryptPubKeyEncryptedMasterKeyAndHash(
|
||||
authReqResponse.key,
|
||||
authReqResponse.masterPasswordHash,
|
||||
authReqPrivateKey
|
||||
authReqPrivateKey,
|
||||
);
|
||||
|
||||
// Decrypt and set user key in state
|
||||
@@ -45,11 +45,11 @@ export class AuthRequestCryptoServiceImplementation implements AuthRequestCrypto
|
||||
// Decryption helpers
|
||||
async decryptPubKeyEncryptedUserKey(
|
||||
pubKeyEncryptedUserKey: string,
|
||||
privateKey: Uint8Array
|
||||
privateKey: Uint8Array,
|
||||
): Promise<UserKey> {
|
||||
const decryptedUserKeyBytes = await this.cryptoService.rsaDecrypt(
|
||||
pubKeyEncryptedUserKey,
|
||||
privateKey
|
||||
privateKey,
|
||||
);
|
||||
|
||||
return new SymmetricCryptoKey(decryptedUserKeyBytes) as UserKey;
|
||||
@@ -58,16 +58,16 @@ export class AuthRequestCryptoServiceImplementation implements AuthRequestCrypto
|
||||
async decryptPubKeyEncryptedMasterKeyAndHash(
|
||||
pubKeyEncryptedMasterKey: string,
|
||||
pubKeyEncryptedMasterKeyHash: string,
|
||||
privateKey: Uint8Array
|
||||
privateKey: Uint8Array,
|
||||
): Promise<{ masterKey: MasterKey; masterKeyHash: string }> {
|
||||
const decryptedMasterKeyArrayBuffer = await this.cryptoService.rsaDecrypt(
|
||||
pubKeyEncryptedMasterKey,
|
||||
privateKey
|
||||
privateKey,
|
||||
);
|
||||
|
||||
const decryptedMasterKeyHashArrayBuffer = await this.cryptoService.rsaDecrypt(
|
||||
pubKeyEncryptedMasterKeyHash,
|
||||
privateKey
|
||||
privateKey,
|
||||
);
|
||||
|
||||
const masterKey = new SymmetricCryptoKey(decryptedMasterKeyArrayBuffer) as MasterKey;
|
||||
|
||||
@@ -47,13 +47,13 @@ describe("AuthRequestCryptoService", () => {
|
||||
// Act
|
||||
await authReqCryptoService.setUserKeyAfterDecryptingSharedUserKey(
|
||||
mockAuthReqResponse,
|
||||
mockPrivateKey
|
||||
mockPrivateKey,
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(authReqCryptoService.decryptPubKeyEncryptedUserKey).toBeCalledWith(
|
||||
mockAuthReqResponse.key,
|
||||
mockPrivateKey
|
||||
mockPrivateKey,
|
||||
);
|
||||
expect(cryptoService.setUserKey).toBeCalledWith(mockDecryptedUserKey);
|
||||
});
|
||||
@@ -86,14 +86,14 @@ describe("AuthRequestCryptoService", () => {
|
||||
// Act
|
||||
await authReqCryptoService.setKeysAfterDecryptingSharedMasterKeyAndHash(
|
||||
mockAuthReqResponse,
|
||||
mockPrivateKey
|
||||
mockPrivateKey,
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(authReqCryptoService.decryptPubKeyEncryptedMasterKeyAndHash).toBeCalledWith(
|
||||
mockAuthReqResponse.key,
|
||||
mockAuthReqResponse.masterPasswordHash,
|
||||
mockPrivateKey
|
||||
mockPrivateKey,
|
||||
);
|
||||
expect(cryptoService.setMasterKey).toBeCalledWith(mockDecryptedMasterKey);
|
||||
expect(cryptoService.setMasterKeyHash).toBeCalledWith(mockDecryptedMasterKeyHash);
|
||||
@@ -114,7 +114,7 @@ describe("AuthRequestCryptoService", () => {
|
||||
// Act
|
||||
const result = await authReqCryptoService.decryptPubKeyEncryptedUserKey(
|
||||
mockPubKeyEncryptedUserKey,
|
||||
mockPrivateKey
|
||||
mockPrivateKey,
|
||||
);
|
||||
|
||||
// Assert
|
||||
@@ -131,7 +131,7 @@ describe("AuthRequestCryptoService", () => {
|
||||
|
||||
const mockDecryptedMasterKeyBytes = new Uint8Array(64);
|
||||
const mockDecryptedMasterKey = new SymmetricCryptoKey(
|
||||
mockDecryptedMasterKeyBytes
|
||||
mockDecryptedMasterKeyBytes,
|
||||
) as MasterKey;
|
||||
const mockDecryptedMasterKeyHashBytes = new Uint8Array(64);
|
||||
const mockDecryptedMasterKeyHash = Utils.fromBufferToUtf8(mockDecryptedMasterKeyHashBytes);
|
||||
@@ -144,19 +144,19 @@ describe("AuthRequestCryptoService", () => {
|
||||
const result = await authReqCryptoService.decryptPubKeyEncryptedMasterKeyAndHash(
|
||||
mockPubKeyEncryptedMasterKey,
|
||||
mockPubKeyEncryptedMasterKeyHash,
|
||||
mockPrivateKey
|
||||
mockPrivateKey,
|
||||
);
|
||||
|
||||
// Assert
|
||||
expect(cryptoService.rsaDecrypt).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
mockPubKeyEncryptedMasterKey,
|
||||
mockPrivateKey
|
||||
mockPrivateKey,
|
||||
);
|
||||
expect(cryptoService.rsaDecrypt).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
mockPubKeyEncryptedMasterKeyHash,
|
||||
mockPrivateKey
|
||||
mockPrivateKey,
|
||||
);
|
||||
expect(result.masterKey).toEqual(mockDecryptedMasterKey);
|
||||
expect(result.masterKeyHash).toEqual(mockDecryptedMasterKeyHash);
|
||||
|
||||
@@ -110,7 +110,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
protected passwordStrengthService: PasswordStrengthServiceAbstraction,
|
||||
protected policyService: PolicyService,
|
||||
protected deviceTrustCryptoService: DeviceTrustCryptoServiceAbstraction,
|
||||
protected authReqCryptoService: AuthRequestCryptoServiceAbstraction
|
||||
protected authReqCryptoService: AuthRequestCryptoServiceAbstraction,
|
||||
) {}
|
||||
|
||||
async logIn(
|
||||
@@ -119,7 +119,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
| PasswordLoginCredentials
|
||||
| SsoLoginCredentials
|
||||
| AuthRequestLoginCredentials
|
||||
| WebAuthnLoginCredentials
|
||||
| WebAuthnLoginCredentials,
|
||||
): Promise<AuthResult> {
|
||||
this.clearState();
|
||||
|
||||
@@ -144,7 +144,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
this.twoFactorService,
|
||||
this.passwordStrengthService,
|
||||
this.policyService,
|
||||
this
|
||||
this,
|
||||
);
|
||||
break;
|
||||
case AuthenticationType.Sso:
|
||||
@@ -161,7 +161,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
this.keyConnectorService,
|
||||
this.deviceTrustCryptoService,
|
||||
this.authReqCryptoService,
|
||||
this.i18nService
|
||||
this.i18nService,
|
||||
);
|
||||
break;
|
||||
case AuthenticationType.UserApi:
|
||||
@@ -176,7 +176,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
this.stateService,
|
||||
this.twoFactorService,
|
||||
this.environmentService,
|
||||
this.keyConnectorService
|
||||
this.keyConnectorService,
|
||||
);
|
||||
break;
|
||||
case AuthenticationType.AuthRequest:
|
||||
@@ -190,7 +190,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
this.logService,
|
||||
this.stateService,
|
||||
this.twoFactorService,
|
||||
this.deviceTrustCryptoService
|
||||
this.deviceTrustCryptoService,
|
||||
);
|
||||
break;
|
||||
case AuthenticationType.WebAuthn:
|
||||
@@ -203,7 +203,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
this.messagingService,
|
||||
this.logService,
|
||||
this.stateService,
|
||||
this.twoFactorService
|
||||
this.twoFactorService,
|
||||
);
|
||||
break;
|
||||
}
|
||||
@@ -218,7 +218,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
|
||||
async logInTwoFactor(
|
||||
twoFactor: TokenTwoFactorRequest,
|
||||
captchaResponse: string
|
||||
captchaResponse: string,
|
||||
): Promise<AuthResult> {
|
||||
if (this.logInStrategy == null) {
|
||||
throw new Error(this.i18nService.t("sessionTimeout"));
|
||||
@@ -281,7 +281,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
// Attempt to get the key from storage and set it in memory
|
||||
const userKey = await this.cryptoService.getUserKeyFromStorage(
|
||||
KeySuffixOptions.Auto,
|
||||
userId
|
||||
userId,
|
||||
);
|
||||
await this.cryptoService.setUserKey(userKey, userId);
|
||||
}
|
||||
@@ -307,7 +307,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
kdfConfig = new KdfConfig(
|
||||
preloginResponse.kdfIterations,
|
||||
preloginResponse.kdfMemory,
|
||||
preloginResponse.kdfParallelism
|
||||
preloginResponse.kdfParallelism,
|
||||
);
|
||||
}
|
||||
} catch (e) {
|
||||
@@ -329,7 +329,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
async passwordlessLogin(
|
||||
id: string,
|
||||
key: string,
|
||||
requestApproved: boolean
|
||||
requestApproved: boolean,
|
||||
): Promise<AuthRequestResponse> {
|
||||
const pubKey = Utils.fromB64ToArray(key);
|
||||
|
||||
@@ -346,7 +346,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
if (masterKeyHash != null) {
|
||||
encryptedMasterKeyHash = await this.cryptoService.rsaEncrypt(
|
||||
Utils.fromUtf8ToArray(masterKeyHash),
|
||||
pubKey
|
||||
pubKey,
|
||||
);
|
||||
}
|
||||
} else {
|
||||
@@ -360,7 +360,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
encryptedKey.encryptedString,
|
||||
encryptedMasterKeyHash?.encryptedString,
|
||||
await this.appIdService.getAppId(),
|
||||
requestApproved
|
||||
requestApproved,
|
||||
);
|
||||
return await this.apiService.putAuthRequest(id, request);
|
||||
}
|
||||
@@ -371,7 +371,7 @@ export class AuthService implements AuthServiceAbstraction {
|
||||
| PasswordLoginStrategy
|
||||
| SsoLoginStrategy
|
||||
| AuthRequestLoginStrategy
|
||||
| WebAuthnLoginStrategy
|
||||
| WebAuthnLoginStrategy,
|
||||
) {
|
||||
this.logInStrategy = strategy;
|
||||
this.startSessionTimeout();
|
||||
|
||||
@@ -30,7 +30,7 @@ export class DeviceTrustCryptoService implements DeviceTrustCryptoServiceAbstrac
|
||||
private appIdService: AppIdService,
|
||||
private devicesApiService: DevicesApiServiceAbstraction,
|
||||
private i18nService: I18nService,
|
||||
private platformUtilsService: PlatformUtilsService
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -67,9 +67,8 @@ export class DeviceTrustCryptoService implements DeviceTrustCryptoServiceAbstrac
|
||||
const deviceKey = await this.makeDeviceKey();
|
||||
|
||||
// Generate asymmetric RSA key pair: devicePrivateKey, devicePublicKey
|
||||
const [devicePublicKey, devicePrivateKey] = await this.cryptoFunctionService.rsaGenerateKeyPair(
|
||||
2048
|
||||
);
|
||||
const [devicePublicKey, devicePrivateKey] =
|
||||
await this.cryptoFunctionService.rsaGenerateKeyPair(2048);
|
||||
|
||||
const [
|
||||
devicePublicKeyEncryptedUserKey,
|
||||
@@ -92,7 +91,7 @@ export class DeviceTrustCryptoService implements DeviceTrustCryptoServiceAbstrac
|
||||
deviceIdentifier,
|
||||
devicePublicKeyEncryptedUserKey.encryptedString,
|
||||
userKeyEncryptedDevicePublicKey.encryptedString,
|
||||
deviceKeyEncryptedDevicePrivateKey.encryptedString
|
||||
deviceKeyEncryptedDevicePrivateKey.encryptedString,
|
||||
);
|
||||
|
||||
// store device key in local/secure storage if enc keys posted to server successfully
|
||||
@@ -121,25 +120,25 @@ export class DeviceTrustCryptoService implements DeviceTrustCryptoServiceAbstrac
|
||||
// Get the keys that are used in rotating a devices keys from the server
|
||||
const currentDeviceKeys = await this.devicesApiService.getDeviceKeys(
|
||||
deviceIdentifier,
|
||||
secretVerificationRequest
|
||||
secretVerificationRequest,
|
||||
);
|
||||
|
||||
// Decrypt the existing device public key with the old user key
|
||||
const decryptedDevicePublicKey = await this.encryptService.decryptToBytes(
|
||||
currentDeviceKeys.encryptedPublicKey,
|
||||
oldUserKey
|
||||
oldUserKey,
|
||||
);
|
||||
|
||||
// Encrypt the brand new user key with the now-decrypted public key for the device
|
||||
const encryptedNewUserKey = await this.cryptoService.rsaEncrypt(
|
||||
newUserKey.key,
|
||||
decryptedDevicePublicKey
|
||||
decryptedDevicePublicKey,
|
||||
);
|
||||
|
||||
// Re-encrypt the device public key with the new user key
|
||||
const encryptedDevicePublicKey = await this.encryptService.encrypt(
|
||||
decryptedDevicePublicKey,
|
||||
newUserKey
|
||||
newUserKey,
|
||||
);
|
||||
|
||||
const currentDeviceUpdateRequest = new DeviceKeysUpdateRequest();
|
||||
@@ -176,7 +175,7 @@ export class DeviceTrustCryptoService implements DeviceTrustCryptoServiceAbstrac
|
||||
async decryptUserKeyWithDeviceKey(
|
||||
encryptedDevicePrivateKey: EncString,
|
||||
encryptedUserKey: EncString,
|
||||
deviceKey?: DeviceKey
|
||||
deviceKey?: DeviceKey,
|
||||
): Promise<UserKey | null> {
|
||||
// If device key provided use it, otherwise try to retrieve from storage
|
||||
deviceKey ||= await this.getDeviceKey();
|
||||
@@ -190,13 +189,13 @@ export class DeviceTrustCryptoService implements DeviceTrustCryptoServiceAbstrac
|
||||
// attempt to decrypt encryptedDevicePrivateKey with device key
|
||||
const devicePrivateKey = await this.encryptService.decryptToBytes(
|
||||
encryptedDevicePrivateKey,
|
||||
deviceKey
|
||||
deviceKey,
|
||||
);
|
||||
|
||||
// Attempt to decrypt encryptedUserDataKey with devicePrivateKey
|
||||
const userKey = await this.cryptoService.rsaDecrypt(
|
||||
encryptedUserKey.encryptedString,
|
||||
devicePrivateKey
|
||||
devicePrivateKey,
|
||||
);
|
||||
|
||||
return new SymmetricCryptoKey(userKey) as UserKey;
|
||||
|
||||
@@ -45,7 +45,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
appIdService,
|
||||
devicesApiService,
|
||||
i18nService,
|
||||
platformUtilsService
|
||||
platformUtilsService,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -118,7 +118,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
existingDeviceKey = new SymmetricCryptoKey(
|
||||
new Uint8Array(deviceKeyBytesLength) as CsprngArray
|
||||
new Uint8Array(deviceKeyBytesLength) as CsprngArray,
|
||||
) as DeviceKey;
|
||||
|
||||
stateSvcGetDeviceKeySpy = jest.spyOn(stateService, "getDeviceKey");
|
||||
@@ -152,7 +152,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
const stateSvcSetDeviceKeySpy = jest.spyOn(stateService, "setDeviceKey");
|
||||
|
||||
const deviceKey = new SymmetricCryptoKey(
|
||||
new Uint8Array(deviceKeyBytesLength) as CsprngArray
|
||||
new Uint8Array(deviceKeyBytesLength) as CsprngArray,
|
||||
) as DeviceKey;
|
||||
|
||||
// TypeScript will allow calling private methods if the object is of type 'any'
|
||||
@@ -236,17 +236,17 @@ describe("deviceTrustCryptoService", () => {
|
||||
|
||||
mockDevicePublicKeyEncryptedUserKey = new EncString(
|
||||
EncryptionType.Rsa2048_OaepSha1_B64,
|
||||
"mockDevicePublicKeyEncryptedUserKey"
|
||||
"mockDevicePublicKeyEncryptedUserKey",
|
||||
);
|
||||
|
||||
mockUserKeyEncryptedDevicePublicKey = new EncString(
|
||||
EncryptionType.AesCbc256_HmacSha256_B64,
|
||||
"mockUserKeyEncryptedDevicePublicKey"
|
||||
"mockUserKeyEncryptedDevicePublicKey",
|
||||
);
|
||||
|
||||
mockDeviceKeyEncryptedDevicePrivateKey = new EncString(
|
||||
EncryptionType.AesCbc256_HmacSha256_B64,
|
||||
"mockDeviceKeyEncryptedDevicePrivateKey"
|
||||
"mockDeviceKeyEncryptedDevicePrivateKey",
|
||||
);
|
||||
|
||||
// TypeScript will allow calling private methods if the object is of type 'any'
|
||||
@@ -307,7 +307,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
mockDeviceId,
|
||||
mockDevicePublicKeyEncryptedUserKey.encryptedString,
|
||||
mockUserKeyEncryptedDevicePublicKey.encryptedString,
|
||||
mockDeviceKeyEncryptedDevicePrivateKey.encryptedString
|
||||
mockDeviceKeyEncryptedDevicePrivateKey.encryptedString,
|
||||
);
|
||||
|
||||
expect(response).toBeInstanceOf(DeviceResponse);
|
||||
@@ -319,7 +319,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
cryptoSvcGetUserKeySpy.mockResolvedValue(null);
|
||||
// check if the expected error is thrown
|
||||
await expect(deviceTrustCryptoService.trustDevice()).rejects.toThrow(
|
||||
"User symmetric key not found"
|
||||
"User symmetric key not found",
|
||||
);
|
||||
|
||||
// reset the spy
|
||||
@@ -329,7 +329,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
cryptoSvcGetUserKeySpy.mockResolvedValue(undefined);
|
||||
// check if the expected error is thrown
|
||||
await expect(deviceTrustCryptoService.trustDevice()).rejects.toThrow(
|
||||
"User symmetric key not found"
|
||||
"User symmetric key not found",
|
||||
);
|
||||
});
|
||||
|
||||
@@ -377,9 +377,9 @@ describe("deviceTrustCryptoService", () => {
|
||||
const methodSpy = spy();
|
||||
methodSpy.mockResolvedValue(invalidValue);
|
||||
await expect(deviceTrustCryptoService.trustDevice()).rejects.toThrow();
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -398,12 +398,12 @@ describe("deviceTrustCryptoService", () => {
|
||||
|
||||
mockEncryptedDevicePrivateKey = new EncString(
|
||||
EncryptionType.AesCbc256_HmacSha256_B64,
|
||||
"mockEncryptedDevicePrivateKey"
|
||||
"mockEncryptedDevicePrivateKey",
|
||||
);
|
||||
|
||||
mockEncryptedUserKey = new EncString(
|
||||
EncryptionType.AesCbc256_HmacSha256_B64,
|
||||
"mockEncryptedUserKey"
|
||||
"mockEncryptedUserKey",
|
||||
);
|
||||
|
||||
jest.clearAllMocks();
|
||||
@@ -416,7 +416,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
|
||||
const result = await deviceTrustCryptoService.decryptUserKeyWithDeviceKey(
|
||||
mockEncryptedDevicePrivateKey,
|
||||
mockEncryptedUserKey
|
||||
mockEncryptedUserKey,
|
||||
);
|
||||
|
||||
expect(result).toBeNull();
|
||||
@@ -435,7 +435,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
const result = await deviceTrustCryptoService.decryptUserKeyWithDeviceKey(
|
||||
mockEncryptedDevicePrivateKey,
|
||||
mockEncryptedUserKey,
|
||||
mockDeviceKey
|
||||
mockDeviceKey,
|
||||
);
|
||||
|
||||
expect(result).toEqual(mockUserKey);
|
||||
@@ -458,7 +458,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
// Call without providing a device key
|
||||
const result = await deviceTrustCryptoService.decryptUserKeyWithDeviceKey(
|
||||
mockEncryptedDevicePrivateKey,
|
||||
mockEncryptedUserKey
|
||||
mockEncryptedUserKey,
|
||||
);
|
||||
|
||||
expect(getDeviceKeySpy).toHaveBeenCalledTimes(1);
|
||||
@@ -477,7 +477,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
const result = await deviceTrustCryptoService.decryptUserKeyWithDeviceKey(
|
||||
mockEncryptedDevicePrivateKey,
|
||||
mockEncryptedUserKey,
|
||||
mockDeviceKey
|
||||
mockDeviceKey,
|
||||
);
|
||||
|
||||
expect(result).toBeNull();
|
||||
@@ -511,7 +511,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
describe("is on a trusted device", () => {
|
||||
beforeEach(() => {
|
||||
stateService.getDeviceKey.mockResolvedValue(
|
||||
new SymmetricCryptoKey(new Uint8Array(deviceKeyBytesLength)) as DeviceKey
|
||||
new SymmetricCryptoKey(new Uint8Array(deviceKeyBytesLength)) as DeviceKey,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -525,7 +525,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
|
||||
// Mock the retrieval of a user key that differs from the new one passed into the method
|
||||
stateService.getUserKey.mockResolvedValue(
|
||||
new SymmetricCryptoKey(fakeOldUserKeyData) as UserKey
|
||||
new SymmetricCryptoKey(fakeOldUserKeyData) as UserKey,
|
||||
);
|
||||
|
||||
appIdService.getAppId.mockResolvedValue("test_device_identifier");
|
||||
@@ -547,7 +547,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
type: DeviceType.FirefoxBrowser,
|
||||
encryptedPublicKey: currentEncryptedPublicKey.encryptedString,
|
||||
encryptedUserKey: currentEncryptedUserKey.encryptedString,
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -576,7 +576,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
|
||||
expect(new Uint8Array(key.key)[0]).toBe(FakeNewUserKeyMarker);
|
||||
return Promise.resolve(
|
||||
new EncString("2.ZW5jcnlwdGVkcHVibGlj|ZW5jcnlwdGVkcHVibGlj|ZW5jcnlwdGVkcHVibGlj")
|
||||
new EncString("2.ZW5jcnlwdGVkcHVibGlj|ZW5jcnlwdGVkcHVibGlj|ZW5jcnlwdGVkcHVibGlj"),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -589,7 +589,7 @@ describe("deviceTrustCryptoService", () => {
|
||||
"2.ZW5jcnlwdGVkcHVibGlj|ZW5jcnlwdGVkcHVibGlj|ZW5jcnlwdGVkcHVibGlj" &&
|
||||
updateTrustModel.currentDevice.encryptedUserKey === "4.ZW5jcnlwdGVkdXNlcg=="
|
||||
);
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -23,7 +23,7 @@ export class DevicesApiServiceImplementation implements DevicesApiServiceAbstrac
|
||||
(headers) => {
|
||||
headers.set("X-Device-Identifier", deviceIdentifier);
|
||||
headers.set("X-Request-Email", Utils.fromUtf8ToUrlB64(email));
|
||||
}
|
||||
},
|
||||
);
|
||||
return r as boolean;
|
||||
}
|
||||
@@ -38,7 +38,7 @@ export class DevicesApiServiceImplementation implements DevicesApiServiceAbstrac
|
||||
`/devices/identifier/${deviceIdentifier}`,
|
||||
null,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new DeviceResponse(r);
|
||||
}
|
||||
@@ -52,12 +52,12 @@ export class DevicesApiServiceImplementation implements DevicesApiServiceAbstrac
|
||||
deviceIdentifier: string,
|
||||
devicePublicKeyEncryptedUserKey: string,
|
||||
userKeyEncryptedDevicePublicKey: string,
|
||||
deviceKeyEncryptedDevicePrivateKey: string
|
||||
deviceKeyEncryptedDevicePrivateKey: string,
|
||||
): Promise<DeviceResponse> {
|
||||
const request = new TrustedDeviceKeysRequest(
|
||||
devicePublicKeyEncryptedUserKey,
|
||||
userKeyEncryptedDevicePublicKey,
|
||||
deviceKeyEncryptedDevicePrivateKey
|
||||
deviceKeyEncryptedDevicePrivateKey,
|
||||
);
|
||||
|
||||
const result = await this.apiService.send(
|
||||
@@ -65,7 +65,7 @@ export class DevicesApiServiceImplementation implements DevicesApiServiceAbstrac
|
||||
`/devices/${deviceIdentifier}/keys`,
|
||||
request,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
|
||||
return new DeviceResponse(result);
|
||||
@@ -77,20 +77,20 @@ export class DevicesApiServiceImplementation implements DevicesApiServiceAbstrac
|
||||
"/devices/update-trust",
|
||||
updateDevicesTrustRequestModel,
|
||||
true,
|
||||
false
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
async getDeviceKeys(
|
||||
deviceIdentifier: string,
|
||||
secretVerificationRequest: SecretVerificationRequest
|
||||
secretVerificationRequest: SecretVerificationRequest,
|
||||
): Promise<ProtectedDeviceResponse> {
|
||||
const result = await this.apiService.send(
|
||||
"POST",
|
||||
`/devices/${deviceIdentifier}/retrieve-keys`,
|
||||
secretVerificationRequest,
|
||||
true,
|
||||
true
|
||||
true,
|
||||
);
|
||||
return new ProtectedDeviceResponse(result);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export class DevicesServiceImplementation implements DevicesServiceAbstraction {
|
||||
return deviceResponses.data.map((deviceResponse: DeviceResponse) => {
|
||||
return new DeviceView(deviceResponse);
|
||||
});
|
||||
})
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ export class DevicesServiceImplementation implements DevicesServiceAbstraction {
|
||||
*/
|
||||
getDeviceByIdentifier$(deviceIdentifier: string): Observable<DeviceView> {
|
||||
return defer(() => this.devicesApiService.getDeviceByIdentifier(deviceIdentifier)).pipe(
|
||||
map((deviceResponse: DeviceResponse) => new DeviceView(deviceResponse))
|
||||
map((deviceResponse: DeviceResponse) => new DeviceView(deviceResponse)),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -54,15 +54,15 @@ export class DevicesServiceImplementation implements DevicesServiceAbstraction {
|
||||
deviceIdentifier: string,
|
||||
devicePublicKeyEncryptedUserKey: string,
|
||||
userKeyEncryptedDevicePublicKey: string,
|
||||
deviceKeyEncryptedDevicePrivateKey: string
|
||||
deviceKeyEncryptedDevicePrivateKey: string,
|
||||
): Observable<DeviceView> {
|
||||
return defer(() =>
|
||||
this.devicesApiService.updateTrustedDeviceKeys(
|
||||
deviceIdentifier,
|
||||
devicePublicKeyEncryptedUserKey,
|
||||
userKeyEncryptedDevicePublicKey,
|
||||
deviceKeyEncryptedDevicePrivateKey
|
||||
)
|
||||
deviceKeyEncryptedDevicePrivateKey,
|
||||
),
|
||||
).pipe(map((deviceResponse: DeviceResponse) => new DeviceView(deviceResponse)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ export class TrustedDeviceKeysRequest {
|
||||
constructor(
|
||||
public encryptedUserKey: string,
|
||||
public encryptedPublicKey: string,
|
||||
public encryptedPrivateKey: string
|
||||
public encryptedPrivateKey: string,
|
||||
) {}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
||||
private logService: LogService,
|
||||
private organizationService: OrganizationService,
|
||||
private cryptoFunctionService: CryptoFunctionService,
|
||||
private logoutCallback: (expired: boolean, userId?: string) => Promise<void>
|
||||
private logoutCallback: (expired: boolean, userId?: string) => Promise<void>,
|
||||
) {}
|
||||
|
||||
setUsesKeyConnector(usesKeyConnector: boolean) {
|
||||
@@ -51,7 +51,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
||||
try {
|
||||
await this.apiService.postUserKeyToKeyConnector(
|
||||
organization.keyConnectorUrl,
|
||||
keyConnectorRequest
|
||||
keyConnectorRequest,
|
||||
);
|
||||
} catch (e) {
|
||||
this.handleKeyConnectorError(e);
|
||||
@@ -79,7 +79,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
||||
o.keyConnectorEnabled &&
|
||||
o.type !== OrganizationUserType.Admin &&
|
||||
o.type !== OrganizationUserType.Owner &&
|
||||
!o.isProviderUser
|
||||
!o.isProviderUser,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
||||
Utils.fromBufferToB64(password),
|
||||
await this.tokenService.getEmail(),
|
||||
kdf,
|
||||
kdfConfig
|
||||
kdfConfig,
|
||||
);
|
||||
const keyConnectorRequest = new KeyConnectorUserKeyRequest(masterKey.encKeyB64);
|
||||
await this.cryptoService.setMasterKey(masterKey);
|
||||
@@ -125,7 +125,7 @@ export class KeyConnectorService implements KeyConnectorServiceAbstraction {
|
||||
kdf,
|
||||
kdfConfig,
|
||||
orgId,
|
||||
keys
|
||||
keys,
|
||||
);
|
||||
await this.apiService.postSetKeyConnectorKey(setPasswordRequest);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ describe("PasswordResetEnrollmentServiceImplementation", () => {
|
||||
stateService,
|
||||
cryptoService,
|
||||
organizationUserService,
|
||||
i18nService
|
||||
i18nService,
|
||||
);
|
||||
});
|
||||
|
||||
@@ -88,13 +88,13 @@ describe("PasswordResetEnrollmentServiceImplementation", () => {
|
||||
await service.enroll("orgId");
|
||||
|
||||
expect(
|
||||
organizationUserService.putOrganizationUserResetPasswordEnrollment
|
||||
organizationUserService.putOrganizationUserResetPasswordEnrollment,
|
||||
).toHaveBeenCalledWith(
|
||||
"orgId",
|
||||
"userId",
|
||||
expect.objectContaining({
|
||||
resetPasswordKey: encryptedKey.encryptedString,
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -110,13 +110,13 @@ describe("PasswordResetEnrollmentServiceImplementation", () => {
|
||||
await service.enroll("orgId", "userId", { key: "key" } as any);
|
||||
|
||||
expect(
|
||||
organizationUserService.putOrganizationUserResetPasswordEnrollment
|
||||
organizationUserService.putOrganizationUserResetPasswordEnrollment,
|
||||
).toHaveBeenCalledWith(
|
||||
"orgId",
|
||||
"userId",
|
||||
expect.objectContaining({
|
||||
resetPasswordKey: encryptedKey.encryptedString,
|
||||
})
|
||||
}),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -16,13 +16,12 @@ export class PasswordResetEnrollmentServiceImplementation
|
||||
protected stateService: StateService,
|
||||
protected cryptoService: CryptoService,
|
||||
protected organizationUserService: OrganizationUserService,
|
||||
protected i18nService: I18nService
|
||||
protected i18nService: I18nService,
|
||||
) {}
|
||||
|
||||
async enrollIfRequired(organizationSsoIdentifier: string): Promise<void> {
|
||||
const orgAutoEnrollStatusResponse = await this.organizationApiService.getAutoEnrollStatus(
|
||||
organizationSsoIdentifier
|
||||
);
|
||||
const orgAutoEnrollStatusResponse =
|
||||
await this.organizationApiService.getAutoEnrollStatus(organizationSsoIdentifier);
|
||||
|
||||
if (!orgAutoEnrollStatusResponse.resetPasswordEnabled) {
|
||||
await this.enroll(orgAutoEnrollStatusResponse.id, null, null);
|
||||
@@ -50,7 +49,7 @@ export class PasswordResetEnrollmentServiceImplementation
|
||||
await this.organizationUserService.putOrganizationUserResetPasswordEnrollment(
|
||||
organizationId,
|
||||
userId,
|
||||
resetRequest
|
||||
resetRequest,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ export class TokenService implements TokenServiceAbstraction {
|
||||
async setTokens(
|
||||
accessToken: string,
|
||||
refreshToken: string,
|
||||
clientIdClientSecret: [string, string]
|
||||
clientIdClientSecret: [string, string],
|
||||
): Promise<any> {
|
||||
await this.setToken(accessToken);
|
||||
await this.setRefreshToken(refreshToken);
|
||||
|
||||
@@ -65,7 +65,7 @@ export class TwoFactorService implements TwoFactorServiceAbstraction {
|
||||
|
||||
constructor(
|
||||
private i18nService: I18nService,
|
||||
private platformUtilsService: PlatformUtilsService
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
) {}
|
||||
|
||||
init() {
|
||||
|
||||
@@ -17,7 +17,7 @@ export class UserVerificationService implements UserVerificationServiceAbstracti
|
||||
private stateService: StateService,
|
||||
private cryptoService: CryptoService,
|
||||
private i18nService: I18nService,
|
||||
private userVerificationApiService: UserVerificationApiServiceAbstraction
|
||||
private userVerificationApiService: UserVerificationApiServiceAbstraction,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -29,7 +29,7 @@ export class UserVerificationService implements UserVerificationServiceAbstracti
|
||||
async buildRequest<T extends SecretVerificationRequest>(
|
||||
verification: Verification,
|
||||
requestClass?: new () => T,
|
||||
alreadyHashed?: boolean
|
||||
alreadyHashed?: boolean,
|
||||
) {
|
||||
this.validateInput(verification);
|
||||
|
||||
@@ -45,7 +45,7 @@ export class UserVerificationService implements UserVerificationServiceAbstracti
|
||||
verification.secret,
|
||||
await this.stateService.getEmail(),
|
||||
await this.stateService.getKdfType(),
|
||||
await this.stateService.getKdfConfig()
|
||||
await this.stateService.getKdfConfig(),
|
||||
);
|
||||
}
|
||||
request.masterPasswordHash = alreadyHashed
|
||||
@@ -78,12 +78,12 @@ export class UserVerificationService implements UserVerificationServiceAbstracti
|
||||
verification.secret,
|
||||
await this.stateService.getEmail(),
|
||||
await this.stateService.getKdfType(),
|
||||
await this.stateService.getKdfConfig()
|
||||
await this.stateService.getKdfConfig(),
|
||||
);
|
||||
}
|
||||
const passwordValid = await this.cryptoService.compareAndUpdateKeyHash(
|
||||
verification.secret,
|
||||
masterKey
|
||||
masterKey,
|
||||
);
|
||||
if (!passwordValid) {
|
||||
throw new Error(this.i18nService.t("invalidMasterPassword"));
|
||||
|
||||
@@ -5,7 +5,10 @@ import { WebAuthnLoginApiServiceAbstraction } from "../../abstractions/webauthn/
|
||||
import { CredentialAssertionOptionsResponse } from "./response/credential-assertion-options.response";
|
||||
|
||||
export class WebAuthnLoginApiService implements WebAuthnLoginApiServiceAbstraction {
|
||||
constructor(private apiService: ApiService, private environmentService: EnvironmentService) {}
|
||||
constructor(
|
||||
private apiService: ApiService,
|
||||
private environmentService: EnvironmentService,
|
||||
) {}
|
||||
|
||||
async getCredentialAssertionOptions(): Promise<CredentialAssertionOptionsResponse> {
|
||||
const response = await this.apiService.send(
|
||||
@@ -14,7 +17,7 @@ export class WebAuthnLoginApiService implements WebAuthnLoginApiServiceAbstracti
|
||||
null,
|
||||
false,
|
||||
true,
|
||||
this.environmentService.getIdentityUrl()
|
||||
this.environmentService.getIdentityUrl(),
|
||||
);
|
||||
return new CredentialAssertionOptionsResponse(response);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ describe("WebAuthnLoginPrfCryptoService", () => {
|
||||
describe("createSymmetricKeyFromPrf", () => {
|
||||
it("should stretch the key to 64 bytes when given a key with 32 bytes", async () => {
|
||||
cryptoFunctionService.hkdfExpand.mockImplementation((key, salt, length) =>
|
||||
Promise.resolve(randomBytes(length))
|
||||
Promise.resolve(randomBytes(length)),
|
||||
);
|
||||
|
||||
const result = await service.createSymmetricKeyFromPrf(randomBytes(32));
|
||||
|
||||
@@ -78,7 +78,7 @@ describe("WebAuthnLoginService", () => {
|
||||
configService,
|
||||
webAuthnLoginPrfCryptoService,
|
||||
window,
|
||||
logService
|
||||
logService,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -135,11 +135,11 @@ describe("WebAuthnLoginService", () => {
|
||||
};
|
||||
|
||||
const mockedCredentialAssertionOptionsResponse = new CredentialAssertionOptionsResponse(
|
||||
mockedCredentialAssertionOptionsServerResponse
|
||||
mockedCredentialAssertionOptionsServerResponse,
|
||||
);
|
||||
|
||||
webAuthnLoginApiService.getCredentialAssertionOptions.mockResolvedValue(
|
||||
mockedCredentialAssertionOptionsResponse
|
||||
mockedCredentialAssertionOptionsResponse,
|
||||
);
|
||||
|
||||
// Act
|
||||
@@ -190,11 +190,11 @@ describe("WebAuthnLoginService", () => {
|
||||
}),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
expect(webAuthnLoginPrfCryptoService.createSymmetricKeyFromPrf).toHaveBeenCalledWith(
|
||||
prfResult
|
||||
prfResult,
|
||||
);
|
||||
|
||||
expect(result).toBeInstanceOf(WebAuthnLoginCredentialAssertionView);
|
||||
@@ -320,7 +320,7 @@ class MockPublicKeyCredential implements PublicKeyCredential {
|
||||
// Creating the array buffer from a known hex value allows us to
|
||||
// assert on the value in tests
|
||||
private prfKeyArrayBuffer: ArrayBuffer = Utils.hexStringToArrayBuffer(
|
||||
"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef"
|
||||
"1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
|
||||
);
|
||||
|
||||
getClientExtensionResults(): any {
|
||||
@@ -367,11 +367,11 @@ function buildCredentialAssertionOptions(): WebAuthnLoginCredentialAssertionOpti
|
||||
};
|
||||
|
||||
const credentialAssertionOptionsResponse = new CredentialAssertionOptionsResponse(
|
||||
credentialAssertionOptionsServerResponse
|
||||
credentialAssertionOptionsServerResponse,
|
||||
);
|
||||
|
||||
return new WebAuthnLoginCredentialAssertionOptionsView(
|
||||
credentialAssertionOptionsResponse.options,
|
||||
credentialAssertionOptionsResponse.token
|
||||
credentialAssertionOptionsResponse.token,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ export class WebAuthnLoginService implements WebAuthnLoginServiceAbstraction {
|
||||
private configService: ConfigServiceAbstraction,
|
||||
private webAuthnLoginPrfCryptoService: WebAuthnLoginPrfCryptoServiceAbstraction,
|
||||
private window: Window,
|
||||
private logService?: LogService
|
||||
private logService?: LogService,
|
||||
) {
|
||||
this.enabled$ = this.configService.getFeatureFlag$(FeatureFlag.PasswordlessLogin, false);
|
||||
this.navigatorCredentials = this.window.navigator.credentials;
|
||||
@@ -38,7 +38,7 @@ export class WebAuthnLoginService implements WebAuthnLoginServiceAbstraction {
|
||||
}
|
||||
|
||||
async assertCredential(
|
||||
credentialAssertionOptions: WebAuthnLoginCredentialAssertionOptionsView
|
||||
credentialAssertionOptions: WebAuthnLoginCredentialAssertionOptionsView,
|
||||
): Promise<WebAuthnLoginCredentialAssertionView> {
|
||||
const nativeOptions: CredentialRequestOptions = {
|
||||
publicKey: credentialAssertionOptions.options,
|
||||
@@ -57,9 +57,8 @@ export class WebAuthnLoginService implements WebAuthnLoginServiceAbstraction {
|
||||
const prfResult = (response.getClientExtensionResults() as any).prf?.results?.first;
|
||||
let symmetricPrfKey: PrfKey | undefined;
|
||||
if (prfResult != undefined) {
|
||||
symmetricPrfKey = await this.webAuthnLoginPrfCryptoService.createSymmetricKeyFromPrf(
|
||||
prfResult
|
||||
);
|
||||
symmetricPrfKey =
|
||||
await this.webAuthnLoginPrfCryptoService.createSymmetricKeyFromPrf(prfResult);
|
||||
}
|
||||
|
||||
const deviceResponse = new WebAuthnLoginAssertionResponseRequest(response);
|
||||
@@ -73,7 +72,7 @@ export class WebAuthnLoginService implements WebAuthnLoginServiceAbstraction {
|
||||
return new WebAuthnLoginCredentialAssertionView(
|
||||
credentialAssertionOptions.token,
|
||||
deviceResponse,
|
||||
symmetricPrfKey
|
||||
symmetricPrfKey,
|
||||
);
|
||||
} catch (error) {
|
||||
this.logService?.error(error);
|
||||
@@ -85,7 +84,7 @@ export class WebAuthnLoginService implements WebAuthnLoginServiceAbstraction {
|
||||
const credential = new WebAuthnLoginCredentials(
|
||||
assertion.token,
|
||||
assertion.deviceResponse,
|
||||
assertion.prfKey
|
||||
assertion.prfKey,
|
||||
);
|
||||
const result = await this.authService.logIn(credential);
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user