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,8 +31,7 @@ function setupVerificationResponse(
userKeyEncryptedPrivateKey: "userKeyEncryptedPrivateKey", userKeyEncryptedPrivateKey: "userKeyEncryptedPrivateKey",
}; };
sdkService.userClient$.mockReturnValue( sdkService.client$ = of({
of({
crypto: () => ({ crypto: () => ({
verify_asymmetric_keys: jest.fn().mockReturnValue(mockVerificationResponse), verify_asymmetric_keys: jest.fn().mockReturnValue(mockVerificationResponse),
make_key_pair: jest.fn().mockReturnValue(mockKeyPairResponse), make_key_pair: jest.fn().mockReturnValue(mockKeyPairResponse),
@ -42,8 +41,7 @@ function setupVerificationResponse(
version: jest.fn(), version: jest.fn(),
throw: jest.fn(), throw: jest.fn(),
catch: jest.fn(), catch: jest.fn(),
} as unknown as BitwardenClient), } as unknown as BitwardenClient);
);
} }
function setupUserKeyValidation( function setupUserKeyValidation(

View File

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