update sdk calls

This commit is contained in:
Thomas Avery 2024-11-13 17:41:00 -06:00
parent 3a70a6b222
commit e877375158
No known key found for this signature in database
GPG Key ID: 44A02A0410B0F429
2 changed files with 15 additions and 15 deletions

View File

@ -31,19 +31,17 @@ function setupVerificationResponse(
userKeyEncryptedPrivateKey: "userKeyEncryptedPrivateKey",
};
sdkService.userClient$.mockReturnValue(
of({
crypto: () => ({
verify_asymmetric_keys: jest.fn().mockReturnValue(mockVerificationResponse),
make_key_pair: jest.fn().mockReturnValue(mockKeyPairResponse),
}),
free: jest.fn(),
echo: jest.fn(),
version: jest.fn(),
throw: jest.fn(),
catch: jest.fn(),
} as unknown as BitwardenClient),
);
sdkService.client$ = of({
crypto: () => ({
verify_asymmetric_keys: jest.fn().mockReturnValue(mockVerificationResponse),
make_key_pair: jest.fn().mockReturnValue(mockKeyPairResponse),
}),
free: jest.fn(),
echo: jest.fn(),
version: jest.fn(),
throw: jest.fn(),
catch: jest.fn(),
} as unknown as BitwardenClient);
}
function setupUserKeyValidation(

View File

@ -56,9 +56,10 @@ export class DefaultUserAsymmetricKeysRegenerationService
]);
const verificationResponse = await firstValueFrom(
this.sdkService.userClient$(userId).pipe(
this.sdkService.client$.pipe(
map((sdk) =>
sdk.crypto().verify_asymmetric_keys({
userKey: userKey.keyB64,
userPublicKey: publicKeyResponse.publicKey,
userKeyEncryptedPrivateKey: userKeyEncryptedPrivateKey,
}),
@ -89,8 +90,9 @@ export class DefaultUserAsymmetricKeysRegenerationService
}
private async regenerateUserAsymmetricKeys(userId: UserId): Promise<void> {
const userKey = await firstValueFrom(this.keyService.userKey$(userId));
const makeKeyPairResponse = await firstValueFrom(
this.sdkService.userClient$(userId).pipe(map((sdk) => sdk.crypto().make_key_pair())),
this.sdkService.client$.pipe(map((sdk) => sdk.crypto().make_key_pair(userKey.keyB64))),
);
try {