Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-12700] Add private key regeneration process #11829

Merged
merged 44 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
6f16953
add api service
Thomas-Avery Oct 25, 2024
fc65449
Add user asymmetric key regen service
Thomas-Avery Oct 25, 2024
3a709cb
add index files
Thomas-Avery Oct 25, 2024
e0647a2
add feature flag
Thomas-Avery Oct 25, 2024
7c32f5c
wire up service call in login flow.
Thomas-Avery Oct 25, 2024
65b5fae
Merge branch 'main' into km/pm-12700-private-key-regen
Thomas-Avery Oct 25, 2024
04b78e9
Merge branch 'main' into km/pm-12700-private-key-regen
Thomas-Avery Oct 31, 2024
654ae05
fix sdk calls
Thomas-Avery Oct 31, 2024
5c090ce
change interface
Thomas-Avery Nov 1, 2024
630eb14
fix unit tests
Thomas-Avery Nov 1, 2024
c6ce0c1
Add try catch to handler
Thomas-Avery Nov 1, 2024
42ce721
Add call to lock component
Thomas-Avery Nov 1, 2024
9f1f8cf
Add km libs to jest config
Thomas-Avery Nov 6, 2024
ac1e08a
Add missing service to lock component
Thomas-Avery Nov 6, 2024
8ac7d64
cleanup and refactoring of service
Thomas-Avery Nov 6, 2024
c049384
Add unit tests to service
Thomas-Avery Nov 6, 2024
0596c25
Merge branch 'main' into km/pm-12700-private-key-regen
Thomas-Avery Nov 12, 2024
3a70a6b
Merge branch 'main' into km/pm-12700-private-key-regen
Thomas-Avery Nov 13, 2024
e877375
update sdk calls
Thomas-Avery Nov 13, 2024
4769f86
remove from login strategy
Thomas-Avery Nov 19, 2024
6d2e7ee
[Proposal] Add private key regen to onSuccessfulLogin
Thomas-Avery Nov 21, 2024
7fa765c
revert login v1 proposal
Thomas-Avery Nov 21, 2024
fccf892
Merge branch 'main' into km/pm-12700-private-key-regen
Thomas-Avery Nov 21, 2024
d3e9610
only target refresh components
Thomas-Avery Nov 21, 2024
112a239
Rename method
Thomas-Avery Nov 22, 2024
77b525c
Add LoginSuccessHandlerService
Thomas-Avery Nov 22, 2024
8b79a4d
Merge branch 'main' into km/pm-12700-private-key-regen
Thomas-Avery Nov 26, 2024
960ece2
add loginSuccessHandlerService to BaseLoginViaWebAuthnComponent
Thomas-Avery Nov 26, 2024
eb2a400
Merge branch 'main' into km/pm-12700-private-key-regen
Thomas-Avery Dec 4, 2024
03bab1c
Only run loginSuccessHandlerService if webAuthn is used for vault dec…
Thomas-Avery Dec 9, 2024
b0cd1e2
Update logging wording
Thomas-Avery Dec 9, 2024
e587062
Remove unused service injection
Thomas-Avery Dec 9, 2024
36322f7
update test naming
Thomas-Avery Dec 9, 2024
9abc0ce
Merge branch 'main' into km/pm-12700-private-key-regen
Thomas-Avery Dec 9, 2024
b6637fa
Updates for TS strict
Thomas-Avery Dec 9, 2024
4779dc7
Merge branch 'main' into km/pm-12700-private-key-regen
Thomas-Avery Dec 11, 2024
4e39e01
bump SDK version
Thomas-Avery Dec 11, 2024
b6f9272
Merge branch 'main' into km/pm-12700-private-key-regen
Thomas-Avery Dec 12, 2024
d677b9e
swap to combineLatest
Thomas-Avery Dec 12, 2024
5466be0
Update abstractions
Thomas-Avery Dec 12, 2024
5736d40
Merge branch 'main' into km/pm-12700-private-key-regen
Thomas-Avery Dec 13, 2024
d775217
Merge branch 'main' into km/pm-12700-private-key-regen
Thomas-Avery Dec 16, 2024
c827822
Merge branch 'main' into km/pm-12700-private-key-regen
Thomas-Avery Dec 16, 2024
26ee44f
Merge branch 'main' into km/pm-12700-private-key-regen
Thomas-Avery Dec 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,17 @@
// @ts-strict-ignore
import { Directive, OnInit } from "@angular/core";
import { Router } from "@angular/router";
import { firstValueFrom } from "rxjs";

Check warning on line 5 in libs/angular/src/auth/components/base-login-via-webauthn.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/angular/src/auth/components/base-login-via-webauthn.component.ts#L5

Added line #L5 was not covered by tests

import { LoginSuccessHandlerService } from "@bitwarden/auth/common";

Check warning on line 7 in libs/angular/src/auth/components/base-login-via-webauthn.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/angular/src/auth/components/base-login-via-webauthn.component.ts#L7

Added line #L7 was not covered by tests
import { WebAuthnLoginServiceAbstraction } from "@bitwarden/common/auth/abstractions/webauthn/webauthn-login.service.abstraction";
import { ForceSetPasswordReason } from "@bitwarden/common/auth/models/domain/force-set-password-reason";
import { WebAuthnLoginCredentialAssertionView } from "@bitwarden/common/auth/models/view/webauthn-login/webauthn-login-credential-assertion.view";
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
import { KeyService } from "@bitwarden/key-management";

Check warning on line 15 in libs/angular/src/auth/components/base-login-via-webauthn.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/angular/src/auth/components/base-login-via-webauthn.component.ts#L15

Added line #L15 was not covered by tests

export type State = "assert" | "assertFailed";

Expand All @@ -26,6 +29,8 @@
private logService: LogService,
private validationService: ValidationService,
private i18nService: I18nService,
private loginSuccessHandlerService: LoginSuccessHandlerService,
private keyService: KeyService,

Check warning on line 33 in libs/angular/src/auth/components/base-login-via-webauthn.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/angular/src/auth/components/base-login-via-webauthn.component.ts#L33

Added line #L33 was not covered by tests
) {}

ngOnInit(): void {
Expand Down Expand Up @@ -59,11 +64,21 @@
this.i18nService.t("twoFactorForPasskeysNotSupportedOnClientUpdateToLogIn"),
);
this.currentState = "assertFailed";
} else if (authResult.forcePasswordReset == ForceSetPasswordReason.AdminForcePasswordReset) {
return;

Check warning on line 67 in libs/angular/src/auth/components/base-login-via-webauthn.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/angular/src/auth/components/base-login-via-webauthn.component.ts#L67

Added line #L67 was not covered by tests
}

// Only run loginSuccessHandlerService if webAuthn is used for vault decryption.
const userKey = await firstValueFrom(this.keyService.userKey$(authResult.userId));

Check warning on line 71 in libs/angular/src/auth/components/base-login-via-webauthn.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/angular/src/auth/components/base-login-via-webauthn.component.ts#L71

Added line #L71 was not covered by tests
if (userKey) {
await this.loginSuccessHandlerService.run(authResult.userId);

Check warning on line 73 in libs/angular/src/auth/components/base-login-via-webauthn.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/angular/src/auth/components/base-login-via-webauthn.component.ts#L73

Added line #L73 was not covered by tests
}

if (authResult.forcePasswordReset == ForceSetPasswordReason.AdminForcePasswordReset) {
await this.router.navigate([this.forcePasswordResetRoute]);
} else {
await this.router.navigate([this.successRoute]);
return;

Check warning on line 78 in libs/angular/src/auth/components/base-login-via-webauthn.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/angular/src/auth/components/base-login-via-webauthn.component.ts#L78

Added line #L78 was not covered by tests
}

await this.router.navigate([this.successRoute]);

Check warning on line 81 in libs/angular/src/auth/components/base-login-via-webauthn.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/angular/src/auth/components/base-login-via-webauthn.component.ts#L81

Added line #L81 was not covered by tests
} catch (error) {
if (error instanceof ErrorResponse) {
this.validationService.showError(this.i18nService.t("invalidPasskeyPleaseTryAgain"));
Expand Down
29 changes: 29 additions & 0 deletions libs/angular/src/services/jslib-services.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import {
RegisterRouteService,
AuthRequestApiService,
DefaultAuthRequestApiService,
DefaultLoginSuccessHandlerService,
LoginSuccessHandlerService,
} from "@bitwarden/auth/common";
import { ApiService as ApiServiceAbstraction } from "@bitwarden/common/abstractions/api.service";
import { AuditService as AuditServiceAbstraction } from "@bitwarden/common/abstractions/audit.service";
Expand Down Expand Up @@ -281,6 +283,10 @@ import {
DefaultBiometricStateService,
KdfConfigService,
DefaultKdfConfigService,
UserAsymmetricKeysRegenerationService,
DefaultUserAsymmetricKeysRegenerationService,
UserAsymmetricKeysRegenerationApiService,
DefaultUserAsymmetricKeysRegenerationApiService,
} from "@bitwarden/key-management";
import { PasswordRepromptService } from "@bitwarden/vault";
import {
Expand Down Expand Up @@ -1395,6 +1401,29 @@ const safeProviders: SafeProvider[] = [
useClass: DefaultLoginDecryptionOptionsService,
deps: [MessagingServiceAbstraction],
}),
safeProvider({
provide: UserAsymmetricKeysRegenerationApiService,
useClass: DefaultUserAsymmetricKeysRegenerationApiService,
deps: [ApiServiceAbstraction],
}),
safeProvider({
provide: UserAsymmetricKeysRegenerationService,
useClass: DefaultUserAsymmetricKeysRegenerationService,
deps: [
KeyServiceAbstraction,
CipherServiceAbstraction,
UserAsymmetricKeysRegenerationApiService,
LogService,
SdkService,
ApiServiceAbstraction,
ConfigService,
],
}),
safeProvider({
provide: LoginSuccessHandlerService,
useClass: DefaultLoginSuccessHandlerService,
deps: [SyncService, UserAsymmetricKeysRegenerationService],
}),
];

@NgModule({
Expand Down
9 changes: 8 additions & 1 deletion libs/auth/src/angular/lock/lock.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@
IconButtonModule,
ToastService,
} from "@bitwarden/components";
import { KeyService, BiometricStateService } from "@bitwarden/key-management";
import {

Check warning on line 40 in libs/auth/src/angular/lock/lock.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/auth/src/angular/lock/lock.component.ts#L40

Added line #L40 was not covered by tests
KeyService,
BiometricStateService,
UserAsymmetricKeysRegenerationService,
} from "@bitwarden/key-management";

import { PinServiceAbstraction } from "../../common/abstractions";
import { AnonLayoutWrapperDataService } from "../anon-layout/anon-layout-wrapper-data.service";
Expand Down Expand Up @@ -139,6 +143,7 @@
private passwordStrengthService: PasswordStrengthServiceAbstraction,
private formBuilder: FormBuilder,
private toastService: ToastService,
private userAsymmetricKeysRegenerationService: UserAsymmetricKeysRegenerationService,

private lockComponentService: LockComponentService,
private anonLayoutWrapperDataService: AnonLayoutWrapperDataService,
Expand Down Expand Up @@ -532,6 +537,8 @@
// Vault can be de-synced since notifications get ignored while locked. Need to check whether sync is required using the sync service.
await this.syncService.fullSync(false);

await this.userAsymmetricKeysRegenerationService.regenerateIfNeeded(this.activeAccount.id);

Check warning on line 540 in libs/auth/src/angular/lock/lock.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/auth/src/angular/lock/lock.component.ts#L540

Added line #L540 was not covered by tests

if (this.clientType === "browser") {
const previousUrl = this.lockComponentService.getPreviousUrl();
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
AuthRequestServiceAbstraction,
LoginEmailServiceAbstraction,
LoginStrategyServiceAbstraction,
LoginSuccessHandlerService,
} from "@bitwarden/auth/common";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { AnonymousHubService } from "@bitwarden/common/auth/abstractions/anonymous-hub.service";
Expand All @@ -34,7 +35,6 @@
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { UserId } from "@bitwarden/common/types/guid";
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
import { ButtonModule, LinkModule, ToastService } from "@bitwarden/components";
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";

Expand Down Expand Up @@ -88,9 +88,9 @@
private passwordGenerationService: PasswordGenerationServiceAbstraction,
private platformUtilsService: PlatformUtilsService,
private router: Router,
private syncService: SyncService,
private toastService: ToastService,
private validationService: ValidationService,
private loginSuccessHandlerService: LoginSuccessHandlerService,

Check warning on line 93 in libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts#L93

Added line #L93 was not covered by tests
) {
this.clientType = this.platformUtilsService.getClientType();

Expand Down Expand Up @@ -485,7 +485,7 @@
const activeAccount = await firstValueFrom(this.accountService.activeAccount$);
await this.deviceTrustService.trustDeviceIfRequired(activeAccount.id);

await this.handleSuccessfulLoginNavigation();
await this.handleSuccessfulLoginNavigation(userId);

Check warning on line 488 in libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts#L488

Added line #L488 was not covered by tests
}

/**
Expand Down Expand Up @@ -555,17 +555,17 @@
} else if (loginResponse.forcePasswordReset != ForceSetPasswordReason.None) {
await this.router.navigate(["update-temp-password"]);
} else {
await this.handleSuccessfulLoginNavigation();
await this.handleSuccessfulLoginNavigation(loginResponse.userId);

Check warning on line 558 in libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts#L558

Added line #L558 was not covered by tests
}
}

private async handleSuccessfulLoginNavigation() {
private async handleSuccessfulLoginNavigation(userId: UserId) {
if (this.flow === Flow.StandardAuthRequest) {
// Only need to set remembered email on standard login with auth req flow
await this.loginEmailService.saveEmailSettings();
}

await this.syncService.fullSync(true);
await this.loginSuccessHandlerService.run(userId);

Check warning on line 568 in libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/auth/src/angular/login-via-auth-request/login-via-auth-request.component.ts#L568

Added line #L568 was not covered by tests
await this.router.navigate(["vault"]);
}
}
6 changes: 3 additions & 3 deletions libs/auth/src/angular/login/login.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import {
LoginEmailServiceAbstraction,
LoginStrategyServiceAbstraction,
LoginSuccessHandlerService,
PasswordLoginCredentials,
RegisterRouteService,
} from "@bitwarden/auth/common";
Expand All @@ -31,7 +32,6 @@
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { ValidationService } from "@bitwarden/common/platform/abstractions/validation.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { SyncService } from "@bitwarden/common/platform/sync";
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
import {
AsyncActionsModule,
Expand Down Expand Up @@ -127,11 +127,11 @@
private policyService: InternalPolicyService,
private registerRouteService: RegisterRouteService,
private router: Router,
private syncService: SyncService,
private toastService: ToastService,
private logService: LogService,
private validationService: ValidationService,
private configService: ConfigService,
private loginSuccessHandlerService: LoginSuccessHandlerService,

Check warning on line 134 in libs/auth/src/angular/login/login.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/auth/src/angular/login/login.component.ts#L134

Added line #L134 was not covered by tests
) {
this.clientType = this.platformUtilsService.getClientType();
}
Expand Down Expand Up @@ -280,7 +280,7 @@
return;
}

await this.syncService.fullSync(true);
await this.loginSuccessHandlerService.run(authResult.userId);

Check warning on line 283 in libs/auth/src/angular/login/login.component.ts

View check run for this annotation

Codecov / codecov/patch

libs/auth/src/angular/login/login.component.ts#L283

Added line #L283 was not covered by tests

if (authResult.forcePasswordReset != ForceSetPasswordReason.None) {
this.loginEmailService.clearValues();
Expand Down
1 change: 1 addition & 0 deletions libs/auth/src/common/abstractions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ export * from "./login-strategy.service";
export * from "./user-decryption-options.service.abstraction";
export * from "./auth-request.service.abstraction";
export * from "./login-approval-component.service.abstraction";
export * from "./login-success-handler.service";
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { UserId } from "@bitwarden/common/types/guid";

export abstract class LoginSuccessHandlerService {
/**
* Runs any service calls required after a successful login.
* Service calls that should be included in this method are only those required to be awaited after successful login.
* @param userId The user id.
*/
abstract run(userId: UserId): Promise<void>;
}
1 change: 1 addition & 0 deletions libs/auth/src/common/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ export * from "./auth-request/auth-request.service";
export * from "./auth-request/auth-request-api.service";
export * from "./register-route.service";
export * from "./accounts/lock.service";
export * from "./login-success-handler/default-login-success-handler.service";
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { SyncService } from "@bitwarden/common/platform/sync";
import { UserId } from "@bitwarden/common/types/guid";
import { UserAsymmetricKeysRegenerationService } from "@bitwarden/key-management";

import { LoginSuccessHandlerService } from "../../abstractions/login-success-handler.service";

export class DefaultLoginSuccessHandlerService implements LoginSuccessHandlerService {
constructor(
private syncService: SyncService,
private userAsymmetricKeysRegenerationService: UserAsymmetricKeysRegenerationService,

Check warning on line 10 in libs/auth/src/common/services/login-success-handler/default-login-success-handler.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/auth/src/common/services/login-success-handler/default-login-success-handler.service.ts#L9-L10

Added lines #L9 - L10 were not covered by tests
) {}
async run(userId: UserId): Promise<void> {
await this.syncService.fullSync(true);
await this.userAsymmetricKeysRegenerationService.regenerateIfNeeded(userId);

Check warning on line 14 in libs/auth/src/common/services/login-success-handler/default-login-success-handler.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/auth/src/common/services/login-success-handler/default-login-success-handler.service.ts#L13-L14

Added lines #L13 - L14 were not covered by tests
}
}
2 changes: 2 additions & 0 deletions libs/common/src/enums/feature-flag.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export enum FeatureFlag {
MacOsNativeCredentialSync = "macos-native-credential-sync",
PM11360RemoveProviderExportPermission = "pm-11360-remove-provider-export-permission",
PM12443RemovePagingLogic = "pm-12443-remove-paging-logic",
PrivateKeyRegeneration = "pm-12241-private-key-regeneration",
}

export type AllowedFeatureFlagTypes = boolean | number | string;
Expand Down Expand Up @@ -94,6 +95,7 @@ export const DefaultFeatureFlagValue = {
[FeatureFlag.MacOsNativeCredentialSync]: FALSE,
[FeatureFlag.PM11360RemoveProviderExportPermission]: FALSE,
[FeatureFlag.PM12443RemovePagingLogic]: FALSE,
[FeatureFlag.PrivateKeyRegeneration]: FALSE,
} satisfies Record<FeatureFlag, AllowedFeatureFlagTypes>;

export type DefaultFeatureFlagValueType = typeof DefaultFeatureFlagValue;
Expand Down
2 changes: 2 additions & 0 deletions libs/key-management/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@
export { KdfConfigService } from "./abstractions/kdf-config.service";
export { DefaultKdfConfigService } from "./kdf-config.service";
export { KdfType } from "./enums/kdf-type.enum";

export * from "./user-asymmetric-key-regeneration";

Check warning on line 21 in libs/key-management/src/index.ts

View check run for this annotation

Codecov / codecov/patch

libs/key-management/src/index.ts#L21

Added line #L21 was not covered by tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";

export abstract class UserAsymmetricKeysRegenerationApiService {

Check warning on line 3 in libs/key-management/src/user-asymmetric-key-regeneration/abstractions/user-asymmetric-key-regeneration-api.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/key-management/src/user-asymmetric-key-regeneration/abstractions/user-asymmetric-key-regeneration-api.service.ts#L3

Added line #L3 was not covered by tests
abstract regenerateUserAsymmetricKeys(
userPublicKey: string,
userKeyEncryptedUserPrivateKey: EncString,
): Promise<void>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { UserId } from "@bitwarden/common/types/guid";

export abstract class UserAsymmetricKeysRegenerationService {

Check warning on line 3 in libs/key-management/src/user-asymmetric-key-regeneration/abstractions/user-asymmetric-key-regeneration.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/key-management/src/user-asymmetric-key-regeneration/abstractions/user-asymmetric-key-regeneration.service.ts#L3

Added line #L3 was not covered by tests
/**
* Attempts to regenerate the user's asymmetric keys if they are invalid.
* Requires the PrivateKeyRegeneration feature flag to be enabled if not the method will do nothing.
* @param userId The user id.
*/
abstract regenerateIfNeeded(userId: UserId): Promise<void>;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export { UserAsymmetricKeysRegenerationService } from "./abstractions/user-asymmetric-key-regeneration.service";
export { DefaultUserAsymmetricKeysRegenerationService } from "./services/default-user-asymmetric-key-regeneration.service";

Check warning on line 2 in libs/key-management/src/user-asymmetric-key-regeneration/index.ts

View check run for this annotation

Codecov / codecov/patch

libs/key-management/src/user-asymmetric-key-regeneration/index.ts#L1-L2

Added lines #L1 - L2 were not covered by tests

export { UserAsymmetricKeysRegenerationApiService } from "./abstractions/user-asymmetric-key-regeneration-api.service";
export { DefaultUserAsymmetricKeysRegenerationApiService } from "./services/default-user-asymmetric-key-regeneration-api.service";

Check warning on line 5 in libs/key-management/src/user-asymmetric-key-regeneration/index.ts

View check run for this annotation

Codecov / codecov/patch

libs/key-management/src/user-asymmetric-key-regeneration/index.ts#L4-L5

Added lines #L4 - L5 were not covered by tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";

export class KeyRegenerationRequest {

Check warning on line 3 in libs/key-management/src/user-asymmetric-key-regeneration/models/requests/key-regeneration.request.ts

View check run for this annotation

Codecov / codecov/patch

libs/key-management/src/user-asymmetric-key-regeneration/models/requests/key-regeneration.request.ts#L3

Added line #L3 was not covered by tests
userPublicKey: string;
userKeyEncryptedUserPrivateKey: EncString;

constructor(userPublicKey: string, userKeyEncryptedUserPrivateKey: EncString) {
this.userPublicKey = userPublicKey;
this.userKeyEncryptedUserPrivateKey = userKeyEncryptedUserPrivateKey;

Check warning on line 9 in libs/key-management/src/user-asymmetric-key-regeneration/models/requests/key-regeneration.request.ts

View check run for this annotation

Codecov / codecov/patch

libs/key-management/src/user-asymmetric-key-regeneration/models/requests/key-regeneration.request.ts#L8-L9

Added lines #L8 - L9 were not covered by tests
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { EncString } from "@bitwarden/common/platform/models/domain/enc-string";

import { UserAsymmetricKeysRegenerationApiService } from "../abstractions/user-asymmetric-key-regeneration-api.service";
import { KeyRegenerationRequest } from "../models/requests/key-regeneration.request";

export class DefaultUserAsymmetricKeysRegenerationApiService

Check warning on line 7 in libs/key-management/src/user-asymmetric-key-regeneration/services/default-user-asymmetric-key-regeneration-api.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/key-management/src/user-asymmetric-key-regeneration/services/default-user-asymmetric-key-regeneration-api.service.ts#L7

Added line #L7 was not covered by tests
implements UserAsymmetricKeysRegenerationApiService
{
constructor(private apiService: ApiService) {}

Check warning on line 10 in libs/key-management/src/user-asymmetric-key-regeneration/services/default-user-asymmetric-key-regeneration-api.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/key-management/src/user-asymmetric-key-regeneration/services/default-user-asymmetric-key-regeneration-api.service.ts#L10

Added line #L10 was not covered by tests

async regenerateUserAsymmetricKeys(
userPublicKey: string,
userKeyEncryptedUserPrivateKey: EncString,
): Promise<void> {
const request: KeyRegenerationRequest = {

Check warning on line 16 in libs/key-management/src/user-asymmetric-key-regeneration/services/default-user-asymmetric-key-regeneration-api.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/key-management/src/user-asymmetric-key-regeneration/services/default-user-asymmetric-key-regeneration-api.service.ts#L16

Added line #L16 was not covered by tests
userPublicKey,
userKeyEncryptedUserPrivateKey,
};

await this.apiService.send(

Check warning on line 21 in libs/key-management/src/user-asymmetric-key-regeneration/services/default-user-asymmetric-key-regeneration-api.service.ts

View check run for this annotation

Codecov / codecov/patch

libs/key-management/src/user-asymmetric-key-regeneration/services/default-user-asymmetric-key-regeneration-api.service.ts#L21

Added line #L21 was not covered by tests
"POST",
"/accounts/key-management/regenerate-keys",
request,
true,
true,
);
}
}
Loading
Loading