mirror of
https://github.com/bitwarden/browser.git
synced 2024-11-22 11:45:59 +01:00
[PS-1107] User Verification Service Refactor (#3219)
* UserVerificationService refactor * Remove temp change * move import order * Address PR feedback
This commit is contained in:
parent
43d428b3df
commit
1ba76dec16
@ -31,7 +31,8 @@ import { SystemService as SystemServiceAbstraction } from "@bitwarden/common/abs
|
|||||||
import { TokenService as TokenServiceAbstraction } from "@bitwarden/common/abstractions/token.service";
|
import { TokenService as TokenServiceAbstraction } from "@bitwarden/common/abstractions/token.service";
|
||||||
import { TotpService as TotpServiceAbstraction } from "@bitwarden/common/abstractions/totp.service";
|
import { TotpService as TotpServiceAbstraction } from "@bitwarden/common/abstractions/totp.service";
|
||||||
import { TwoFactorService as TwoFactorServiceAbstraction } from "@bitwarden/common/abstractions/twoFactor.service";
|
import { TwoFactorService as TwoFactorServiceAbstraction } from "@bitwarden/common/abstractions/twoFactor.service";
|
||||||
import { UserVerificationService as UserVerificationServiceAbstraction } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationApiServiceAbstraction } from "@bitwarden/common/abstractions/userVerification/userVerification-api.service.abstraction";
|
||||||
|
import { UserVerificationService as UserVerificationServiceAbstraction } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { UsernameGenerationService as UsernameGenerationServiceAbstraction } from "@bitwarden/common/abstractions/usernameGeneration.service";
|
import { UsernameGenerationService as UsernameGenerationServiceAbstraction } from "@bitwarden/common/abstractions/usernameGeneration.service";
|
||||||
import { VaultTimeoutService as VaultTimeoutServiceAbstraction } from "@bitwarden/common/abstractions/vaultTimeout.service";
|
import { VaultTimeoutService as VaultTimeoutServiceAbstraction } from "@bitwarden/common/abstractions/vaultTimeout.service";
|
||||||
import { AuthenticationStatus } from "@bitwarden/common/enums/authenticationStatus";
|
import { AuthenticationStatus } from "@bitwarden/common/enums/authenticationStatus";
|
||||||
@ -71,7 +72,8 @@ import { SystemService } from "@bitwarden/common/services/system.service";
|
|||||||
import { TokenService } from "@bitwarden/common/services/token.service";
|
import { TokenService } from "@bitwarden/common/services/token.service";
|
||||||
import { TotpService } from "@bitwarden/common/services/totp.service";
|
import { TotpService } from "@bitwarden/common/services/totp.service";
|
||||||
import { TwoFactorService } from "@bitwarden/common/services/twoFactor.service";
|
import { TwoFactorService } from "@bitwarden/common/services/twoFactor.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/services/userVerification.service";
|
import { UserVerificationApiService } from "@bitwarden/common/services/userVerification/userVerification-api.service";
|
||||||
|
import { UserVerificationService } from "@bitwarden/common/services/userVerification/userVerification.service";
|
||||||
import { UsernameGenerationService } from "@bitwarden/common/services/usernameGeneration.service";
|
import { UsernameGenerationService } from "@bitwarden/common/services/usernameGeneration.service";
|
||||||
import { WebCryptoFunctionService } from "@bitwarden/common/services/webCryptoFunction.service";
|
import { WebCryptoFunctionService } from "@bitwarden/common/services/webCryptoFunction.service";
|
||||||
|
|
||||||
@ -152,6 +154,7 @@ export default class MainBackground {
|
|||||||
encryptService: EncryptService;
|
encryptService: EncryptService;
|
||||||
folderApiService: FolderApiServiceAbstraction;
|
folderApiService: FolderApiServiceAbstraction;
|
||||||
policyApiService: PolicyApiServiceAbstraction;
|
policyApiService: PolicyApiServiceAbstraction;
|
||||||
|
userVerificationApiService: UserVerificationApiServiceAbstraction;
|
||||||
|
|
||||||
// Passed to the popup for Safari to workaround issues with theming, downloading, etc.
|
// Passed to the popup for Safari to workaround issues with theming, downloading, etc.
|
||||||
backgroundWindow = window;
|
backgroundWindow = window;
|
||||||
@ -422,10 +425,12 @@ export default class MainBackground {
|
|||||||
);
|
);
|
||||||
this.popupUtilsService = new PopupUtilsService(isPrivateMode);
|
this.popupUtilsService = new PopupUtilsService(isPrivateMode);
|
||||||
|
|
||||||
|
this.userVerificationApiService = new UserVerificationApiService(this.apiService);
|
||||||
|
|
||||||
this.userVerificationService = new UserVerificationService(
|
this.userVerificationService = new UserVerificationService(
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.apiService
|
this.userVerificationApiService
|
||||||
);
|
);
|
||||||
|
|
||||||
const systemUtilsServiceReloadCallback = () => {
|
const systemUtilsServiceReloadCallback = () => {
|
||||||
|
@ -45,7 +45,7 @@ import { SyncService } from "@bitwarden/common/abstractions/sync.service";
|
|||||||
import { TokenService } from "@bitwarden/common/abstractions/token.service";
|
import { TokenService } from "@bitwarden/common/abstractions/token.service";
|
||||||
import { TotpService } from "@bitwarden/common/abstractions/totp.service";
|
import { TotpService } from "@bitwarden/common/abstractions/totp.service";
|
||||||
import { TwoFactorService } from "@bitwarden/common/abstractions/twoFactor.service";
|
import { TwoFactorService } from "@bitwarden/common/abstractions/twoFactor.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { UsernameGenerationService } from "@bitwarden/common/abstractions/usernameGeneration.service";
|
import { UsernameGenerationService } from "@bitwarden/common/abstractions/usernameGeneration.service";
|
||||||
import { VaultTimeoutService } from "@bitwarden/common/abstractions/vaultTimeout.service";
|
import { VaultTimeoutService } from "@bitwarden/common/abstractions/vaultTimeout.service";
|
||||||
import { AuthService } from "@bitwarden/common/services/auth.service";
|
import { AuthService } from "@bitwarden/common/services/auth.service";
|
||||||
|
@ -11,7 +11,7 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
|||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-export",
|
selector: "app-export",
|
||||||
|
@ -42,7 +42,8 @@ import { SyncService } from "@bitwarden/common/services/sync.service";
|
|||||||
import { TokenService } from "@bitwarden/common/services/token.service";
|
import { TokenService } from "@bitwarden/common/services/token.service";
|
||||||
import { TotpService } from "@bitwarden/common/services/totp.service";
|
import { TotpService } from "@bitwarden/common/services/totp.service";
|
||||||
import { TwoFactorService } from "@bitwarden/common/services/twoFactor.service";
|
import { TwoFactorService } from "@bitwarden/common/services/twoFactor.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/services/userVerification.service";
|
import { UserVerificationApiService } from "@bitwarden/common/services/userVerification/userVerification-api.service";
|
||||||
|
import { UserVerificationService } from "@bitwarden/common/services/userVerification/userVerification.service";
|
||||||
import { VaultTimeoutService } from "@bitwarden/common/services/vaultTimeout.service";
|
import { VaultTimeoutService } from "@bitwarden/common/services/vaultTimeout.service";
|
||||||
import { CliPlatformUtilsService } from "@bitwarden/node/cli/services/cliPlatformUtils.service";
|
import { CliPlatformUtilsService } from "@bitwarden/node/cli/services/cliPlatformUtils.service";
|
||||||
import { ConsoleLogService } from "@bitwarden/node/cli/services/consoleLog.service";
|
import { ConsoleLogService } from "@bitwarden/node/cli/services/consoleLog.service";
|
||||||
@ -106,6 +107,7 @@ export class Main {
|
|||||||
twoFactorService: TwoFactorService;
|
twoFactorService: TwoFactorService;
|
||||||
broadcasterService: BroadcasterService;
|
broadcasterService: BroadcasterService;
|
||||||
folderApiService: FolderApiService;
|
folderApiService: FolderApiService;
|
||||||
|
userVerificationApiService: UserVerificationApiService;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
let p = null;
|
let p = null;
|
||||||
@ -330,10 +332,13 @@ export class Main {
|
|||||||
this.program = new Program(this);
|
this.program = new Program(this);
|
||||||
this.vaultProgram = new VaultProgram(this);
|
this.vaultProgram = new VaultProgram(this);
|
||||||
this.sendProgram = new SendProgram(this);
|
this.sendProgram = new SendProgram(this);
|
||||||
|
|
||||||
|
this.userVerificationApiService = new UserVerificationApiService(this.apiService);
|
||||||
|
|
||||||
this.userVerificationService = new UserVerificationService(
|
this.userVerificationService = new UserVerificationService(
|
||||||
this.cryptoService,
|
this.cryptoService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.apiService
|
this.userVerificationApiService
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
|||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
|
|
||||||
const BroadcasterSubscriptionId = "ExportComponent";
|
const BroadcasterSubscriptionId = "ExportComponent";
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import { PasswordGenerationService } from "@bitwarden/common/abstractions/passwo
|
|||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
||||||
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-update-password",
|
selector: "app-update-password",
|
||||||
|
@ -3,7 +3,7 @@ import { Component } from "@angular/core";
|
|||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { OrganizationApiKeyType } from "@bitwarden/common/enums/organizationApiKeyType";
|
import { OrganizationApiKeyType } from "@bitwarden/common/enums/organizationApiKeyType";
|
||||||
import { OrganizationApiKeyRequest } from "@bitwarden/common/models/request/organizationApiKeyRequest";
|
import { OrganizationApiKeyRequest } from "@bitwarden/common/models/request/organizationApiKeyRequest";
|
||||||
import { ApiKeyResponse } from "@bitwarden/common/models/response/apiKeyResponse";
|
import { ApiKeyResponse } from "@bitwarden/common/models/response/apiKeyResponse";
|
||||||
|
@ -6,7 +6,7 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
|||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
import { OrganizationService } from "@bitwarden/common/abstractions/organization.service";
|
import { OrganizationService } from "@bitwarden/common/abstractions/organization.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { CipherType } from "@bitwarden/common/enums/cipherType";
|
import { CipherType } from "@bitwarden/common/enums/cipherType";
|
||||||
import { Utils } from "@bitwarden/common/misc/utils";
|
import { Utils } from "@bitwarden/common/misc/utils";
|
||||||
import { CipherView } from "@bitwarden/common/models/view/cipherView";
|
import { CipherView } from "@bitwarden/common/models/view/cipherView";
|
||||||
@ -53,10 +53,10 @@ export class DeleteOrganizationComponent implements OnInit {
|
|||||||
deleteOrganizationRequestType: "InvalidFamiliesForEnterprise" | "RegularDelete" = "RegularDelete";
|
deleteOrganizationRequestType: "InvalidFamiliesForEnterprise" | "RegularDelete" = "RegularDelete";
|
||||||
organizationName: string;
|
organizationName: string;
|
||||||
organizationContentSummary: OrganizationContentSummary = new OrganizationContentSummary();
|
organizationContentSummary: OrganizationContentSummary = new OrganizationContentSummary();
|
||||||
@Output() onSuccess: EventEmitter<any> = new EventEmitter();
|
@Output() onSuccess: EventEmitter<unknown> = new EventEmitter();
|
||||||
|
|
||||||
masterPassword: Verification;
|
masterPassword: Verification;
|
||||||
formPromise: Promise<any>;
|
formPromise: Promise<unknown>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
|
@ -10,7 +10,7 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
|||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { EventType } from "@bitwarden/common/enums/eventType";
|
import { EventType } from "@bitwarden/common/enums/eventType";
|
||||||
|
|
||||||
import { ExportComponent } from "../../../tools/import-export/export.component";
|
import { ExportComponent } from "../../../tools/import-export/export.component";
|
||||||
@ -66,7 +66,7 @@ export class OrganizationExportComponent extends ExportComponent {
|
|||||||
return super.getFileName("org");
|
return super.getFileName("org");
|
||||||
}
|
}
|
||||||
|
|
||||||
async collectEvent(): Promise<any> {
|
async collectEvent(): Promise<void> {
|
||||||
await this.eventService.collect(
|
await this.eventService.collect(
|
||||||
EventType.Organization_ClientExportedVault,
|
EventType.Organization_ClientExportedVault,
|
||||||
null,
|
null,
|
||||||
|
@ -8,7 +8,7 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
|||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { SyncService } from "@bitwarden/common/abstractions/sync.service";
|
import { SyncService } from "@bitwarden/common/abstractions/sync.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { Utils } from "@bitwarden/common/misc/utils";
|
import { Utils } from "@bitwarden/common/misc/utils";
|
||||||
import { Organization } from "@bitwarden/common/models/domain/organization";
|
import { Organization } from "@bitwarden/common/models/domain/organization";
|
||||||
import { OrganizationUserResetPasswordEnrollmentRequest } from "@bitwarden/common/models/request/organizationUserResetPasswordEnrollmentRequest";
|
import { OrganizationUserResetPasswordEnrollmentRequest } from "@bitwarden/common/models/request/organizationUserResetPasswordEnrollmentRequest";
|
||||||
@ -22,7 +22,7 @@ export class EnrollMasterPasswordReset {
|
|||||||
organization: Organization;
|
organization: Organization;
|
||||||
|
|
||||||
verification: Verification;
|
verification: Verification;
|
||||||
formPromise: Promise<any>;
|
formPromise: Promise<void>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private userVerificationService: UserVerificationService,
|
private userVerificationService: UserVerificationService,
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { Component } from "@angular/core";
|
import { Component } from "@angular/core";
|
||||||
|
|
||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { SecretVerificationRequest } from "@bitwarden/common/models/request/secretVerificationRequest";
|
import { SecretVerificationRequest } from "@bitwarden/common/models/request/secretVerificationRequest";
|
||||||
import { ApiKeyResponse } from "@bitwarden/common/models/response/apiKeyResponse";
|
import { ApiKeyResponse } from "@bitwarden/common/models/response/apiKeyResponse";
|
||||||
import { Verification } from "@bitwarden/common/types/verification";
|
import { Verification } from "@bitwarden/common/types/verification";
|
||||||
|
@ -5,7 +5,7 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
|||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { Verification } from "@bitwarden/common/types/verification";
|
import { Verification } from "@bitwarden/common/types/verification";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -14,7 +14,7 @@ import { Verification } from "@bitwarden/common/types/verification";
|
|||||||
})
|
})
|
||||||
export class DeauthorizeSessionsComponent {
|
export class DeauthorizeSessionsComponent {
|
||||||
masterPassword: Verification;
|
masterPassword: Verification;
|
||||||
formPromise: Promise<any>;
|
formPromise: Promise<unknown>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
|
@ -5,7 +5,7 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
|||||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { Verification } from "@bitwarden/common/types/verification";
|
import { Verification } from "@bitwarden/common/types/verification";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -16,7 +16,7 @@ export class PurgeVaultComponent {
|
|||||||
@Input() organizationId?: string = null;
|
@Input() organizationId?: string = null;
|
||||||
|
|
||||||
masterPassword: Verification;
|
masterPassword: Verification;
|
||||||
formPromise: Promise<any>;
|
formPromise: Promise<unknown>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private apiService: ApiService,
|
private apiService: ApiService,
|
||||||
|
@ -5,13 +5,28 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
|||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { TwoFactorProviderType } from "@bitwarden/common/enums/twoFactorProviderType";
|
import { TwoFactorProviderType } from "@bitwarden/common/enums/twoFactorProviderType";
|
||||||
import { UpdateTwoFactorAuthenticatorRequest } from "@bitwarden/common/models/request/updateTwoFactorAuthenticatorRequest";
|
import { UpdateTwoFactorAuthenticatorRequest } from "@bitwarden/common/models/request/updateTwoFactorAuthenticatorRequest";
|
||||||
import { TwoFactorAuthenticatorResponse } from "@bitwarden/common/models/response/twoFactorAuthenticatorResponse";
|
import { TwoFactorAuthenticatorResponse } from "@bitwarden/common/models/response/twoFactorAuthenticatorResponse";
|
||||||
|
import { AuthResponse } from "@bitwarden/common/types/authResponse";
|
||||||
|
|
||||||
import { TwoFactorBaseComponent } from "./two-factor-base.component";
|
import { TwoFactorBaseComponent } from "./two-factor-base.component";
|
||||||
|
|
||||||
|
// NOTE: There are additional options available but these are just the ones we are current using.
|
||||||
|
// See: https://github.com/neocotic/qrious#examples
|
||||||
|
interface QRiousOptions {
|
||||||
|
element: HTMLElement;
|
||||||
|
value: string;
|
||||||
|
size: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface Window {
|
||||||
|
QRious: new (options: QRiousOptions) => unknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-two-factor-authenticator",
|
selector: "app-two-factor-authenticator",
|
||||||
templateUrl: "two-factor-authenticator.component.html",
|
templateUrl: "two-factor-authenticator.component.html",
|
||||||
@ -23,7 +38,7 @@ export class TwoFactorAuthenticatorComponent
|
|||||||
type = TwoFactorProviderType.Authenticator;
|
type = TwoFactorProviderType.Authenticator;
|
||||||
key: string;
|
key: string;
|
||||||
token: string;
|
token: string;
|
||||||
formPromise: Promise<any>;
|
formPromise: Promise<TwoFactorAuthenticatorResponse>;
|
||||||
|
|
||||||
private qrScript: HTMLScriptElement;
|
private qrScript: HTMLScriptElement;
|
||||||
|
|
||||||
@ -49,7 +64,7 @@ export class TwoFactorAuthenticatorComponent
|
|||||||
window.document.body.removeChild(this.qrScript);
|
window.document.body.removeChild(this.qrScript);
|
||||||
}
|
}
|
||||||
|
|
||||||
auth(authResponse: any) {
|
auth(authResponse: AuthResponse<TwoFactorAuthenticatorResponse>) {
|
||||||
super.auth(authResponse);
|
super.auth(authResponse);
|
||||||
return this.processResponse(authResponse.response);
|
return this.processResponse(authResponse.response);
|
||||||
}
|
}
|
||||||
@ -80,7 +95,7 @@ export class TwoFactorAuthenticatorComponent
|
|||||||
this.key = response.key;
|
this.key = response.key;
|
||||||
const email = await this.stateService.getEmail();
|
const email = await this.stateService.getEmail();
|
||||||
window.setTimeout(() => {
|
window.setTimeout(() => {
|
||||||
new (window as any).QRious({
|
new window.QRious({
|
||||||
element: document.getElementById("qr"),
|
element: document.getElementById("qr"),
|
||||||
value:
|
value:
|
||||||
"otpauth://totp/Bitwarden:" +
|
"otpauth://totp/Bitwarden:" +
|
||||||
|
@ -4,11 +4,12 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
|||||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { TwoFactorProviderType } from "@bitwarden/common/enums/twoFactorProviderType";
|
import { TwoFactorProviderType } from "@bitwarden/common/enums/twoFactorProviderType";
|
||||||
import { VerificationType } from "@bitwarden/common/enums/verificationType";
|
import { VerificationType } from "@bitwarden/common/enums/verificationType";
|
||||||
import { SecretVerificationRequest } from "@bitwarden/common/models/request/secretVerificationRequest";
|
import { SecretVerificationRequest } from "@bitwarden/common/models/request/secretVerificationRequest";
|
||||||
import { TwoFactorProviderRequest } from "@bitwarden/common/models/request/twoFactorProviderRequest";
|
import { TwoFactorProviderRequest } from "@bitwarden/common/models/request/twoFactorProviderRequest";
|
||||||
|
import { AuthResponseBase } from "@bitwarden/common/types/authResponse";
|
||||||
|
|
||||||
@Directive()
|
@Directive()
|
||||||
export abstract class TwoFactorBaseComponent {
|
export abstract class TwoFactorBaseComponent {
|
||||||
@ -31,7 +32,7 @@ export abstract class TwoFactorBaseComponent {
|
|||||||
protected userVerificationService: UserVerificationService
|
protected userVerificationService: UserVerificationService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
protected auth(authResponse: any) {
|
protected auth(authResponse: AuthResponseBase) {
|
||||||
this.hashedSecret = authResponse.secret;
|
this.hashedSecret = authResponse.secret;
|
||||||
this.verificationType = authResponse.verificationType;
|
this.verificationType = authResponse.verificationType;
|
||||||
this.authed = true;
|
this.authed = true;
|
||||||
@ -46,7 +47,7 @@ export abstract class TwoFactorBaseComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async disable(promise: Promise<any>) {
|
protected async disable(promise: Promise<unknown>) {
|
||||||
const confirmed = await this.platformUtilsService.showDialog(
|
const confirmed = await this.platformUtilsService.showDialog(
|
||||||
this.i18nService.t("twoStepDisableDesc"),
|
this.i18nService.t("twoStepDisableDesc"),
|
||||||
this.i18nService.t("disable"),
|
this.i18nService.t("disable"),
|
||||||
|
@ -4,10 +4,11 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
|||||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { TwoFactorProviderType } from "@bitwarden/common/enums/twoFactorProviderType";
|
import { TwoFactorProviderType } from "@bitwarden/common/enums/twoFactorProviderType";
|
||||||
import { UpdateTwoFactorDuoRequest } from "@bitwarden/common/models/request/updateTwoFactorDuoRequest";
|
import { UpdateTwoFactorDuoRequest } from "@bitwarden/common/models/request/updateTwoFactorDuoRequest";
|
||||||
import { TwoFactorDuoResponse } from "@bitwarden/common/models/response/twoFactorDuoResponse";
|
import { TwoFactorDuoResponse } from "@bitwarden/common/models/response/twoFactorDuoResponse";
|
||||||
|
import { AuthResponse } from "@bitwarden/common/types/authResponse";
|
||||||
|
|
||||||
import { TwoFactorBaseComponent } from "./two-factor-base.component";
|
import { TwoFactorBaseComponent } from "./two-factor-base.component";
|
||||||
|
|
||||||
@ -20,7 +21,7 @@ export class TwoFactorDuoComponent extends TwoFactorBaseComponent {
|
|||||||
ikey: string;
|
ikey: string;
|
||||||
skey: string;
|
skey: string;
|
||||||
host: string;
|
host: string;
|
||||||
formPromise: Promise<any>;
|
formPromise: Promise<TwoFactorDuoResponse>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
apiService: ApiService,
|
apiService: ApiService,
|
||||||
@ -32,7 +33,7 @@ export class TwoFactorDuoComponent extends TwoFactorBaseComponent {
|
|||||||
super(apiService, i18nService, platformUtilsService, logService, userVerificationService);
|
super(apiService, i18nService, platformUtilsService, logService, userVerificationService);
|
||||||
}
|
}
|
||||||
|
|
||||||
auth(authResponse: any) {
|
auth(authResponse: AuthResponse<TwoFactorDuoResponse>) {
|
||||||
super.auth(authResponse);
|
super.auth(authResponse);
|
||||||
this.processResponse(authResponse.response);
|
this.processResponse(authResponse.response);
|
||||||
}
|
}
|
||||||
|
@ -5,11 +5,12 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
|||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { TwoFactorProviderType } from "@bitwarden/common/enums/twoFactorProviderType";
|
import { TwoFactorProviderType } from "@bitwarden/common/enums/twoFactorProviderType";
|
||||||
import { TwoFactorEmailRequest } from "@bitwarden/common/models/request/twoFactorEmailRequest";
|
import { TwoFactorEmailRequest } from "@bitwarden/common/models/request/twoFactorEmailRequest";
|
||||||
import { UpdateTwoFactorEmailRequest } from "@bitwarden/common/models/request/updateTwoFactorEmailRequest";
|
import { UpdateTwoFactorEmailRequest } from "@bitwarden/common/models/request/updateTwoFactorEmailRequest";
|
||||||
import { TwoFactorEmailResponse } from "@bitwarden/common/models/response/twoFactorEmailResponse";
|
import { TwoFactorEmailResponse } from "@bitwarden/common/models/response/twoFactorEmailResponse";
|
||||||
|
import { AuthResponse } from "@bitwarden/common/types/authResponse";
|
||||||
|
|
||||||
import { TwoFactorBaseComponent } from "./two-factor-base.component";
|
import { TwoFactorBaseComponent } from "./two-factor-base.component";
|
||||||
|
|
||||||
@ -22,8 +23,8 @@ export class TwoFactorEmailComponent extends TwoFactorBaseComponent {
|
|||||||
email: string;
|
email: string;
|
||||||
token: string;
|
token: string;
|
||||||
sentEmail: string;
|
sentEmail: string;
|
||||||
formPromise: Promise<any>;
|
formPromise: Promise<TwoFactorEmailResponse>;
|
||||||
emailPromise: Promise<any>;
|
emailPromise: Promise<unknown>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
apiService: ApiService,
|
apiService: ApiService,
|
||||||
@ -36,7 +37,7 @@ export class TwoFactorEmailComponent extends TwoFactorBaseComponent {
|
|||||||
super(apiService, i18nService, platformUtilsService, logService, userVerificationService);
|
super(apiService, i18nService, platformUtilsService, logService, userVerificationService);
|
||||||
}
|
}
|
||||||
|
|
||||||
auth(authResponse: any) {
|
auth(authResponse: AuthResponse<TwoFactorEmailResponse>) {
|
||||||
super.auth(authResponse);
|
super.auth(authResponse);
|
||||||
return this.processResponse(authResponse.response);
|
return this.processResponse(authResponse.response);
|
||||||
}
|
}
|
||||||
|
@ -2,26 +2,14 @@ import { Component, EventEmitter, Input, Output } from "@angular/core";
|
|||||||
|
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { TwoFactorProviderType } from "@bitwarden/common/enums/twoFactorProviderType";
|
import { TwoFactorProviderType } from "@bitwarden/common/enums/twoFactorProviderType";
|
||||||
import { VerificationType } from "@bitwarden/common/enums/verificationType";
|
import { VerificationType } from "@bitwarden/common/enums/verificationType";
|
||||||
import { SecretVerificationRequest } from "@bitwarden/common/models/request/secretVerificationRequest";
|
import { SecretVerificationRequest } from "@bitwarden/common/models/request/secretVerificationRequest";
|
||||||
import { TwoFactorAuthenticatorResponse } from "@bitwarden/common/models/response/twoFactorAuthenticatorResponse";
|
import { AuthResponse } from "@bitwarden/common/types/authResponse";
|
||||||
import { TwoFactorDuoResponse } from "@bitwarden/common/models/response/twoFactorDuoResponse";
|
import { TwoFactorResponse } from "@bitwarden/common/types/twoFactorResponse";
|
||||||
import { TwoFactorEmailResponse } from "@bitwarden/common/models/response/twoFactorEmailResponse";
|
|
||||||
import { TwoFactorRecoverResponse } from "@bitwarden/common/models/response/twoFactorRescoverResponse";
|
|
||||||
import { TwoFactorWebAuthnResponse } from "@bitwarden/common/models/response/twoFactorWebAuthnResponse";
|
|
||||||
import { TwoFactorYubiKeyResponse } from "@bitwarden/common/models/response/twoFactorYubiKeyResponse";
|
|
||||||
import { Verification } from "@bitwarden/common/types/verification";
|
import { Verification } from "@bitwarden/common/types/verification";
|
||||||
|
|
||||||
type TwoFactorResponse =
|
|
||||||
| TwoFactorRecoverResponse
|
|
||||||
| TwoFactorDuoResponse
|
|
||||||
| TwoFactorEmailResponse
|
|
||||||
| TwoFactorWebAuthnResponse
|
|
||||||
| TwoFactorAuthenticatorResponse
|
|
||||||
| TwoFactorYubiKeyResponse;
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-two-factor-verify",
|
selector: "app-two-factor-verify",
|
||||||
templateUrl: "two-factor-verify.component.html",
|
templateUrl: "two-factor-verify.component.html",
|
||||||
@ -29,7 +17,7 @@ type TwoFactorResponse =
|
|||||||
export class TwoFactorVerifyComponent {
|
export class TwoFactorVerifyComponent {
|
||||||
@Input() type: TwoFactorProviderType;
|
@Input() type: TwoFactorProviderType;
|
||||||
@Input() organizationId: string;
|
@Input() organizationId: string;
|
||||||
@Output() onAuthed = new EventEmitter<any>();
|
@Output() onAuthed = new EventEmitter<AuthResponse<TwoFactorResponse>>();
|
||||||
|
|
||||||
secret: Verification;
|
secret: Verification;
|
||||||
formPromise: Promise<TwoFactorResponse>;
|
formPromise: Promise<TwoFactorResponse>;
|
||||||
|
@ -4,7 +4,7 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
|||||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { TwoFactorProviderType } from "@bitwarden/common/enums/twoFactorProviderType";
|
import { TwoFactorProviderType } from "@bitwarden/common/enums/twoFactorProviderType";
|
||||||
import { SecretVerificationRequest } from "@bitwarden/common/models/request/secretVerificationRequest";
|
import { SecretVerificationRequest } from "@bitwarden/common/models/request/secretVerificationRequest";
|
||||||
import { UpdateTwoFactorWebAuthnDeleteRequest } from "@bitwarden/common/models/request/updateTwoFactorWebAuthnDeleteRequest";
|
import { UpdateTwoFactorWebAuthnDeleteRequest } from "@bitwarden/common/models/request/updateTwoFactorWebAuthnDeleteRequest";
|
||||||
@ -13,9 +13,18 @@ import {
|
|||||||
ChallengeResponse,
|
ChallengeResponse,
|
||||||
TwoFactorWebAuthnResponse,
|
TwoFactorWebAuthnResponse,
|
||||||
} from "@bitwarden/common/models/response/twoFactorWebAuthnResponse";
|
} from "@bitwarden/common/models/response/twoFactorWebAuthnResponse";
|
||||||
|
import { AuthResponse } from "@bitwarden/common/types/authResponse";
|
||||||
|
|
||||||
import { TwoFactorBaseComponent } from "./two-factor-base.component";
|
import { TwoFactorBaseComponent } from "./two-factor-base.component";
|
||||||
|
|
||||||
|
interface Key {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
configured: boolean;
|
||||||
|
migrated?: boolean;
|
||||||
|
removePromise: Promise<TwoFactorWebAuthnResponse> | null;
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-two-factor-webauthn",
|
selector: "app-two-factor-webauthn",
|
||||||
templateUrl: "two-factor-webauthn.component.html",
|
templateUrl: "two-factor-webauthn.component.html",
|
||||||
@ -23,14 +32,14 @@ import { TwoFactorBaseComponent } from "./two-factor-base.component";
|
|||||||
export class TwoFactorWebAuthnComponent extends TwoFactorBaseComponent {
|
export class TwoFactorWebAuthnComponent extends TwoFactorBaseComponent {
|
||||||
type = TwoFactorProviderType.WebAuthn;
|
type = TwoFactorProviderType.WebAuthn;
|
||||||
name: string;
|
name: string;
|
||||||
keys: any[];
|
keys: Key[];
|
||||||
keyIdAvailable: number = null;
|
keyIdAvailable: number = null;
|
||||||
keysConfiguredCount = 0;
|
keysConfiguredCount = 0;
|
||||||
webAuthnError: boolean;
|
webAuthnError: boolean;
|
||||||
webAuthnListening: boolean;
|
webAuthnListening: boolean;
|
||||||
webAuthnResponse: PublicKeyCredential;
|
webAuthnResponse: PublicKeyCredential;
|
||||||
challengePromise: Promise<ChallengeResponse>;
|
challengePromise: Promise<ChallengeResponse>;
|
||||||
formPromise: Promise<any>;
|
formPromise: Promise<TwoFactorWebAuthnResponse>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
apiService: ApiService,
|
apiService: ApiService,
|
||||||
@ -43,7 +52,7 @@ export class TwoFactorWebAuthnComponent extends TwoFactorBaseComponent {
|
|||||||
super(apiService, i18nService, platformUtilsService, logService, userVerificationService);
|
super(apiService, i18nService, platformUtilsService, logService, userVerificationService);
|
||||||
}
|
}
|
||||||
|
|
||||||
auth(authResponse: any) {
|
auth(authResponse: AuthResponse<TwoFactorWebAuthnResponse>) {
|
||||||
super.auth(authResponse);
|
super.auth(authResponse);
|
||||||
this.processResponse(authResponse.response);
|
this.processResponse(authResponse.response);
|
||||||
}
|
}
|
||||||
@ -69,11 +78,11 @@ export class TwoFactorWebAuthnComponent extends TwoFactorBaseComponent {
|
|||||||
return super.disable(this.formPromise);
|
return super.disable(this.formPromise);
|
||||||
}
|
}
|
||||||
|
|
||||||
async remove(key: any) {
|
async remove(key: Key) {
|
||||||
if (this.keysConfiguredCount <= 1 || key.removePromise != null) {
|
if (this.keysConfiguredCount <= 1 || key.removePromise != null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const name = key.name != null ? key.name : this.i18nService.t("webAuthnkeyX", key.id);
|
const name = key.name != null ? key.name : this.i18nService.t("webAuthnkeyX", key.id as any);
|
||||||
const confirmed = await this.platformUtilsService.showDialog(
|
const confirmed = await this.platformUtilsService.showDialog(
|
||||||
this.i18nService.t("removeU2fConfirmation"),
|
this.i18nService.t("removeU2fConfirmation"),
|
||||||
name,
|
name,
|
||||||
|
@ -4,24 +4,30 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
|||||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { TwoFactorProviderType } from "@bitwarden/common/enums/twoFactorProviderType";
|
import { TwoFactorProviderType } from "@bitwarden/common/enums/twoFactorProviderType";
|
||||||
import { UpdateTwoFactorYubioOtpRequest } from "@bitwarden/common/models/request/updateTwoFactorYubioOtpRequest";
|
import { UpdateTwoFactorYubioOtpRequest } from "@bitwarden/common/models/request/updateTwoFactorYubioOtpRequest";
|
||||||
import { TwoFactorYubiKeyResponse } from "@bitwarden/common/models/response/twoFactorYubiKeyResponse";
|
import { TwoFactorYubiKeyResponse } from "@bitwarden/common/models/response/twoFactorYubiKeyResponse";
|
||||||
|
import { AuthResponse } from "@bitwarden/common/types/authResponse";
|
||||||
|
|
||||||
import { TwoFactorBaseComponent } from "./two-factor-base.component";
|
import { TwoFactorBaseComponent } from "./two-factor-base.component";
|
||||||
|
|
||||||
|
interface Key {
|
||||||
|
key: string;
|
||||||
|
existingKey: string;
|
||||||
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-two-factor-yubikey",
|
selector: "app-two-factor-yubikey",
|
||||||
templateUrl: "two-factor-yubikey.component.html",
|
templateUrl: "two-factor-yubikey.component.html",
|
||||||
})
|
})
|
||||||
export class TwoFactorYubiKeyComponent extends TwoFactorBaseComponent {
|
export class TwoFactorYubiKeyComponent extends TwoFactorBaseComponent {
|
||||||
type = TwoFactorProviderType.Yubikey;
|
type = TwoFactorProviderType.Yubikey;
|
||||||
keys: any[];
|
keys: Key[];
|
||||||
nfc = false;
|
nfc = false;
|
||||||
|
|
||||||
formPromise: Promise<any>;
|
formPromise: Promise<TwoFactorYubiKeyResponse>;
|
||||||
disablePromise: Promise<any>;
|
disablePromise: Promise<unknown>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
apiService: ApiService,
|
apiService: ApiService,
|
||||||
@ -33,7 +39,7 @@ export class TwoFactorYubiKeyComponent extends TwoFactorBaseComponent {
|
|||||||
super(apiService, i18nService, platformUtilsService, logService, userVerificationService);
|
super(apiService, i18nService, platformUtilsService, logService, userVerificationService);
|
||||||
}
|
}
|
||||||
|
|
||||||
auth(authResponse: any) {
|
auth(authResponse: AuthResponse<TwoFactorYubiKeyResponse>) {
|
||||||
super.auth(authResponse);
|
super.auth(authResponse);
|
||||||
this.processResponse(authResponse.response);
|
this.processResponse(authResponse.response);
|
||||||
}
|
}
|
||||||
@ -59,7 +65,7 @@ export class TwoFactorYubiKeyComponent extends TwoFactorBaseComponent {
|
|||||||
return super.disable(this.disablePromise);
|
return super.disable(this.disablePromise);
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(key: any) {
|
remove(key: Key) {
|
||||||
key.existingKey = null;
|
key.existingKey = null;
|
||||||
key.key = null;
|
key.key = null;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
|||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: "app-export",
|
selector: "app-export",
|
||||||
|
@ -9,7 +9,7 @@ import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
|||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { EventType } from "@bitwarden/common/enums/eventType";
|
import { EventType } from "@bitwarden/common/enums/eventType";
|
||||||
import { PolicyType } from "@bitwarden/common/enums/policyType";
|
import { PolicyType } from "@bitwarden/common/enums/policyType";
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ export class ExportComponent implements OnInit {
|
|||||||
return this.exportService.getFileName(prefix, extension);
|
return this.exportService.getFileName(prefix, extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async collectEvent(): Promise<any> {
|
protected async collectEvent(): Promise<void> {
|
||||||
await this.eventService.collect(EventType.User_ClientExportedVault);
|
await this.eventService.collect(EventType.User_ClientExportedVault);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import { PasswordGenerationService } from "@bitwarden/common/abstractions/passwo
|
|||||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||||
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
import { PolicyService } from "@bitwarden/common/abstractions/policy/policy.service.abstraction";
|
||||||
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
import { StateService } from "@bitwarden/common/abstractions/state.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { VerificationType } from "@bitwarden/common/enums/verificationType";
|
import { VerificationType } from "@bitwarden/common/enums/verificationType";
|
||||||
import { EncString } from "@bitwarden/common/models/domain/encString";
|
import { EncString } from "@bitwarden/common/models/domain/encString";
|
||||||
import { MasterPasswordPolicyOptions } from "@bitwarden/common/models/domain/masterPasswordPolicyOptions";
|
import { MasterPasswordPolicyOptions } from "@bitwarden/common/models/domain/masterPasswordPolicyOptions";
|
||||||
@ -28,7 +28,7 @@ export class UpdatePasswordComponent extends BaseChangePasswordComponent {
|
|||||||
showPassword = false;
|
showPassword = false;
|
||||||
currentMasterPassword: string;
|
currentMasterPassword: string;
|
||||||
|
|
||||||
onSuccessfulChangePassword: () => Promise<any>;
|
onSuccessfulChangePassword: () => Promise<void>;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected router: Router,
|
protected router: Router,
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { animate, style, transition, trigger } from "@angular/animations";
|
import { animate, style, transition, trigger } from "@angular/animations";
|
||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit } from "@angular/core";
|
||||||
import { ControlValueAccessor, UntypedFormControl, NG_VALUE_ACCESSOR } from "@angular/forms";
|
import { ControlValueAccessor, NG_VALUE_ACCESSOR, FormControl } from "@angular/forms";
|
||||||
|
|
||||||
import { KeyConnectorService } from "@bitwarden/common/abstractions/keyConnector.service";
|
import { KeyConnectorService } from "@bitwarden/common/abstractions/keyConnector.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { VerificationType } from "@bitwarden/common/enums/verificationType";
|
import { VerificationType } from "@bitwarden/common/enums/verificationType";
|
||||||
import { Utils } from "@bitwarden/common/misc/utils";
|
import { Utils } from "@bitwarden/common/misc/utils";
|
||||||
import { Verification } from "@bitwarden/common/types/verification";
|
import { Verification } from "@bitwarden/common/types/verification";
|
||||||
@ -35,7 +35,7 @@ export class UserVerificationComponent implements ControlValueAccessor, OnInit {
|
|||||||
disableRequestOTP = false;
|
disableRequestOTP = false;
|
||||||
sentCode = false;
|
sentCode = false;
|
||||||
|
|
||||||
secret = new UntypedFormControl("");
|
secret = new FormControl("");
|
||||||
|
|
||||||
private onChange: (value: Verification) => void;
|
private onChange: (value: Verification) => void;
|
||||||
|
|
||||||
|
@ -49,7 +49,8 @@ import { SyncService as SyncServiceAbstraction } from "@bitwarden/common/abstrac
|
|||||||
import { TokenService as TokenServiceAbstraction } from "@bitwarden/common/abstractions/token.service";
|
import { TokenService as TokenServiceAbstraction } from "@bitwarden/common/abstractions/token.service";
|
||||||
import { TotpService as TotpServiceAbstraction } from "@bitwarden/common/abstractions/totp.service";
|
import { TotpService as TotpServiceAbstraction } from "@bitwarden/common/abstractions/totp.service";
|
||||||
import { TwoFactorService as TwoFactorServiceAbstraction } from "@bitwarden/common/abstractions/twoFactor.service";
|
import { TwoFactorService as TwoFactorServiceAbstraction } from "@bitwarden/common/abstractions/twoFactor.service";
|
||||||
import { UserVerificationService as UserVerificationServiceAbstraction } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationApiServiceAbstraction } from "@bitwarden/common/abstractions/userVerification/userVerification-api.service.abstraction";
|
||||||
|
import { UserVerificationService as UserVerificationServiceAbstraction } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { UsernameGenerationService as UsernameGenerationServiceAbstraction } from "@bitwarden/common/abstractions/usernameGeneration.service";
|
import { UsernameGenerationService as UsernameGenerationServiceAbstraction } from "@bitwarden/common/abstractions/usernameGeneration.service";
|
||||||
import { VaultTimeoutService as VaultTimeoutServiceAbstraction } from "@bitwarden/common/abstractions/vaultTimeout.service";
|
import { VaultTimeoutService as VaultTimeoutServiceAbstraction } from "@bitwarden/common/abstractions/vaultTimeout.service";
|
||||||
import { StateFactory } from "@bitwarden/common/factories/stateFactory";
|
import { StateFactory } from "@bitwarden/common/factories/stateFactory";
|
||||||
@ -89,7 +90,8 @@ import { SyncService } from "@bitwarden/common/services/sync.service";
|
|||||||
import { TokenService } from "@bitwarden/common/services/token.service";
|
import { TokenService } from "@bitwarden/common/services/token.service";
|
||||||
import { TotpService } from "@bitwarden/common/services/totp.service";
|
import { TotpService } from "@bitwarden/common/services/totp.service";
|
||||||
import { TwoFactorService } from "@bitwarden/common/services/twoFactor.service";
|
import { TwoFactorService } from "@bitwarden/common/services/twoFactor.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/services/userVerification.service";
|
import { UserVerificationApiService } from "@bitwarden/common/services/userVerification/userVerification-api.service";
|
||||||
|
import { UserVerificationService } from "@bitwarden/common/services/userVerification/userVerification.service";
|
||||||
import { UsernameGenerationService } from "@bitwarden/common/services/usernameGeneration.service";
|
import { UsernameGenerationService } from "@bitwarden/common/services/usernameGeneration.service";
|
||||||
import { VaultTimeoutService } from "@bitwarden/common/services/vaultTimeout.service";
|
import { VaultTimeoutService } from "@bitwarden/common/services/vaultTimeout.service";
|
||||||
import { WebCryptoFunctionService } from "@bitwarden/common/services/webCryptoFunction.service";
|
import { WebCryptoFunctionService } from "@bitwarden/common/services/webCryptoFunction.service";
|
||||||
@ -476,7 +478,11 @@ export const LOG_MAC_FAILURES = new InjectionToken<string>("LOG_MAC_FAILURES");
|
|||||||
{
|
{
|
||||||
provide: UserVerificationServiceAbstraction,
|
provide: UserVerificationServiceAbstraction,
|
||||||
useClass: UserVerificationService,
|
useClass: UserVerificationService,
|
||||||
deps: [CryptoServiceAbstraction, I18nServiceAbstraction, ApiServiceAbstraction],
|
deps: [
|
||||||
|
CryptoServiceAbstraction,
|
||||||
|
I18nServiceAbstraction,
|
||||||
|
UserVerificationApiServiceAbstraction,
|
||||||
|
],
|
||||||
},
|
},
|
||||||
{ provide: PasswordRepromptServiceAbstraction, useClass: PasswordRepromptService },
|
{ provide: PasswordRepromptServiceAbstraction, useClass: PasswordRepromptService },
|
||||||
{
|
{
|
||||||
@ -502,6 +508,11 @@ export const LOG_MAC_FAILURES = new InjectionToken<string>("LOG_MAC_FAILURES");
|
|||||||
provide: FormValidationErrorsServiceAbstraction,
|
provide: FormValidationErrorsServiceAbstraction,
|
||||||
useClass: FormValidationErrorsService,
|
useClass: FormValidationErrorsService,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
provide: UserVerificationApiServiceAbstraction,
|
||||||
|
useClass: UserVerificationApiService,
|
||||||
|
deps: [ApiServiceAbstraction],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class JslibServicesModule {}
|
export class JslibServicesModule {}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
import { OrganizationApiKeyType } from "../enums/organizationApiKeyType";
|
import { OrganizationApiKeyType } from "../enums/organizationApiKeyType";
|
||||||
import { OrganizationConnectionType } from "../enums/organizationConnectionType";
|
import { OrganizationConnectionType } from "../enums/organizationConnectionType";
|
||||||
import { SetKeyConnectorKeyRequest } from "../models/request/account/setKeyConnectorKeyRequest";
|
import { SetKeyConnectorKeyRequest } from "../models/request/account/setKeyConnectorKeyRequest";
|
||||||
import { VerifyOTPRequest } from "../models/request/account/verifyOTPRequest";
|
|
||||||
import { AttachmentRequest } from "../models/request/attachmentRequest";
|
import { AttachmentRequest } from "../models/request/attachmentRequest";
|
||||||
import { BitPayInvoiceRequest } from "../models/request/bitPayInvoiceRequest";
|
import { BitPayInvoiceRequest } from "../models/request/bitPayInvoiceRequest";
|
||||||
import { CipherBulkDeleteRequest } from "../models/request/cipherBulkDeleteRequest";
|
import { CipherBulkDeleteRequest } from "../models/request/cipherBulkDeleteRequest";
|
||||||
@ -228,8 +227,6 @@ export abstract class ApiService {
|
|||||||
postUserApiKey: (id: string, request: SecretVerificationRequest) => Promise<ApiKeyResponse>;
|
postUserApiKey: (id: string, request: SecretVerificationRequest) => Promise<ApiKeyResponse>;
|
||||||
postUserRotateApiKey: (id: string, request: SecretVerificationRequest) => Promise<ApiKeyResponse>;
|
postUserRotateApiKey: (id: string, request: SecretVerificationRequest) => Promise<ApiKeyResponse>;
|
||||||
putUpdateTempPassword: (request: UpdateTempPasswordRequest) => Promise<any>;
|
putUpdateTempPassword: (request: UpdateTempPasswordRequest) => Promise<any>;
|
||||||
postAccountRequestOTP: () => Promise<void>;
|
|
||||||
postAccountVerifyOTP: (request: VerifyOTPRequest) => Promise<void>;
|
|
||||||
postConvertToKeyConnector: () => Promise<void>;
|
postConvertToKeyConnector: () => Promise<void>;
|
||||||
|
|
||||||
getUserBillingHistory: () => Promise<BillingHistoryResponse>;
|
getUserBillingHistory: () => Promise<BillingHistoryResponse>;
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
import { VerifyOTPRequest } from "@bitwarden/common/models/request/account/verifyOTPRequest";
|
||||||
|
|
||||||
|
export abstract class UserVerificationApiServiceAbstraction {
|
||||||
|
postAccountVerifyOTP: (request: VerifyOTPRequest) => Promise<void>;
|
||||||
|
postAccountRequestOTP: () => Promise<void>;
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
import { SecretVerificationRequest } from "../models/request/secretVerificationRequest";
|
import { SecretVerificationRequest } from "../../models/request/secretVerificationRequest";
|
||||||
import { Verification } from "../types/verification";
|
import { Verification } from "../../types/verification";
|
||||||
|
|
||||||
export abstract class UserVerificationService {
|
export abstract class UserVerificationService {
|
||||||
buildRequest: <T extends SecretVerificationRequest>(
|
buildRequest: <T extends SecretVerificationRequest>(
|
@ -1,7 +1,7 @@
|
|||||||
import { AccountApiService } from "@bitwarden/common/abstractions/account/account-api.service.abstraction";
|
import { AccountApiService } from "@bitwarden/common/abstractions/account/account-api.service.abstraction";
|
||||||
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||||
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
|
import { MessagingService } from "@bitwarden/common/abstractions/messaging.service";
|
||||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction";
|
||||||
|
|
||||||
import { AccountService as AccountServiceAbstraction } from "../../abstractions/account/account.service.abstraction";
|
import { AccountService as AccountServiceAbstraction } from "../../abstractions/account/account.service.abstraction";
|
||||||
import { Verification } from "../../types/verification";
|
import { Verification } from "../../types/verification";
|
||||||
@ -14,7 +14,7 @@ export class AccountService implements AccountServiceAbstraction {
|
|||||||
private logService: LogService
|
private logService: LogService
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async delete(verification: Verification): Promise<any> {
|
async delete(verification: Verification): Promise<void> {
|
||||||
try {
|
try {
|
||||||
const verificationRequest = await this.userVerificationService.buildRequest(verification);
|
const verificationRequest = await this.userVerificationService.buildRequest(verification);
|
||||||
await this.accountApiService.deleteAccount(verificationRequest);
|
await this.accountApiService.deleteAccount(verificationRequest);
|
||||||
|
@ -8,7 +8,6 @@ import { OrganizationApiKeyType } from "../enums/organizationApiKeyType";
|
|||||||
import { OrganizationConnectionType } from "../enums/organizationConnectionType";
|
import { OrganizationConnectionType } from "../enums/organizationConnectionType";
|
||||||
import { Utils } from "../misc/utils";
|
import { Utils } from "../misc/utils";
|
||||||
import { SetKeyConnectorKeyRequest } from "../models/request/account/setKeyConnectorKeyRequest";
|
import { SetKeyConnectorKeyRequest } from "../models/request/account/setKeyConnectorKeyRequest";
|
||||||
import { VerifyOTPRequest } from "../models/request/account/verifyOTPRequest";
|
|
||||||
import { AttachmentRequest } from "../models/request/attachmentRequest";
|
import { AttachmentRequest } from "../models/request/attachmentRequest";
|
||||||
import { BitPayInvoiceRequest } from "../models/request/bitPayInvoiceRequest";
|
import { BitPayInvoiceRequest } from "../models/request/bitPayInvoiceRequest";
|
||||||
import { CipherBulkDeleteRequest } from "../models/request/cipherBulkDeleteRequest";
|
import { CipherBulkDeleteRequest } from "../models/request/cipherBulkDeleteRequest";
|
||||||
@ -457,14 +456,6 @@ export class ApiService implements ApiServiceAbstraction {
|
|||||||
return this.send("PUT", "/accounts/update-temp-password", request, true, false);
|
return this.send("PUT", "/accounts/update-temp-password", request, true, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
postAccountRequestOTP(): Promise<void> {
|
|
||||||
return this.send("POST", "/accounts/request-otp", null, true, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
postAccountVerifyOTP(request: VerifyOTPRequest): Promise<void> {
|
|
||||||
return this.send("POST", "/accounts/verify-otp", request, true, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
postConvertToKeyConnector(): Promise<void> {
|
postConvertToKeyConnector(): Promise<void> {
|
||||||
return this.send("POST", "/accounts/convert-to-key-connector", null, true, false);
|
return this.send("POST", "/accounts/convert-to-key-connector", null, true, false);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
import { ApiService } from "../../abstractions/api.service";
|
||||||
|
import { UserVerificationApiServiceAbstraction } from "../../abstractions/userVerification/userVerification-api.service.abstraction";
|
||||||
|
import { VerifyOTPRequest } from "../../models/request/account/verifyOTPRequest";
|
||||||
|
|
||||||
|
export class UserVerificationApiService implements UserVerificationApiServiceAbstraction {
|
||||||
|
constructor(private apiService: ApiService) {}
|
||||||
|
|
||||||
|
postAccountVerifyOTP(request: VerifyOTPRequest): Promise<void> {
|
||||||
|
return this.apiService.send("POST", "/accounts/verify-otp", request, true, false);
|
||||||
|
}
|
||||||
|
async postAccountRequestOTP(): Promise<void> {
|
||||||
|
return this.apiService.send("POST", "/accounts/request-otp", null, true, false);
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,11 @@
|
|||||||
import { ApiService } from "../abstractions/api.service";
|
import { CryptoService } from "../../abstractions/crypto.service";
|
||||||
import { CryptoService } from "../abstractions/crypto.service";
|
import { I18nService } from "../../abstractions/i18n.service";
|
||||||
import { I18nService } from "../abstractions/i18n.service";
|
import { UserVerificationApiServiceAbstraction } from "../../abstractions/userVerification/userVerification-api.service.abstraction";
|
||||||
import { UserVerificationService as UserVerificationServiceAbstraction } from "../abstractions/userVerification.service";
|
import { UserVerificationService as UserVerificationServiceAbstraction } from "../../abstractions/userVerification/userVerification.service.abstraction";
|
||||||
import { VerificationType } from "../enums/verificationType";
|
import { VerificationType } from "../../enums/verificationType";
|
||||||
import { VerifyOTPRequest } from "../models/request/account/verifyOTPRequest";
|
import { VerifyOTPRequest } from "../../models/request/account/verifyOTPRequest";
|
||||||
import { SecretVerificationRequest } from "../models/request/secretVerificationRequest";
|
import { SecretVerificationRequest } from "../../models/request/secretVerificationRequest";
|
||||||
import { Verification } from "../types/verification";
|
import { Verification } from "../../types/verification";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for general-purpose user verification throughout the app.
|
* Used for general-purpose user verification throughout the app.
|
||||||
@ -15,7 +15,7 @@ export class UserVerificationService implements UserVerificationServiceAbstracti
|
|||||||
constructor(
|
constructor(
|
||||||
private cryptoService: CryptoService,
|
private cryptoService: CryptoService,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
private apiService: ApiService
|
private userVerificationApiService: UserVerificationApiServiceAbstraction
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -56,7 +56,7 @@ export class UserVerificationService implements UserVerificationServiceAbstracti
|
|||||||
if (verification.type === VerificationType.OTP) {
|
if (verification.type === VerificationType.OTP) {
|
||||||
const request = new VerifyOTPRequest(verification.secret);
|
const request = new VerifyOTPRequest(verification.secret);
|
||||||
try {
|
try {
|
||||||
await this.apiService.postAccountVerifyOTP(request);
|
await this.userVerificationApiService.postAccountVerifyOTP(request);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw new Error(this.i18nService.t("invalidVerificationCode"));
|
throw new Error(this.i18nService.t("invalidVerificationCode"));
|
||||||
}
|
}
|
||||||
@ -73,7 +73,7 @@ export class UserVerificationService implements UserVerificationServiceAbstracti
|
|||||||
}
|
}
|
||||||
|
|
||||||
async requestOTP() {
|
async requestOTP() {
|
||||||
await this.apiService.postAccountRequestOTP();
|
await this.userVerificationApiService.postAccountRequestOTP();
|
||||||
}
|
}
|
||||||
|
|
||||||
private validateInput(verification: Verification) {
|
private validateInput(verification: Verification) {
|
12
libs/common/src/types/authResponse.ts
Normal file
12
libs/common/src/types/authResponse.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import { VerificationType } from "../enums/verificationType";
|
||||||
|
|
||||||
|
import { TwoFactorResponse } from "./twoFactorResponse";
|
||||||
|
|
||||||
|
export type AuthResponseBase = {
|
||||||
|
secret: string;
|
||||||
|
verificationType: VerificationType;
|
||||||
|
};
|
||||||
|
|
||||||
|
export type AuthResponse<T extends TwoFactorResponse> = AuthResponseBase & {
|
||||||
|
response: T;
|
||||||
|
};
|
14
libs/common/src/types/twoFactorResponse.ts
Normal file
14
libs/common/src/types/twoFactorResponse.ts
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
import { TwoFactorAuthenticatorResponse } from "../models/response/twoFactorAuthenticatorResponse";
|
||||||
|
import { TwoFactorDuoResponse } from "../models/response/twoFactorDuoResponse";
|
||||||
|
import { TwoFactorEmailResponse } from "../models/response/twoFactorEmailResponse";
|
||||||
|
import { TwoFactorRecoverResponse } from "../models/response/twoFactorRescoverResponse";
|
||||||
|
import { TwoFactorWebAuthnResponse } from "../models/response/twoFactorWebAuthnResponse";
|
||||||
|
import { TwoFactorYubiKeyResponse } from "../models/response/twoFactorYubiKeyResponse";
|
||||||
|
|
||||||
|
export type TwoFactorResponse =
|
||||||
|
| TwoFactorRecoverResponse
|
||||||
|
| TwoFactorDuoResponse
|
||||||
|
| TwoFactorEmailResponse
|
||||||
|
| TwoFactorWebAuthnResponse
|
||||||
|
| TwoFactorAuthenticatorResponse
|
||||||
|
| TwoFactorYubiKeyResponse;
|
@ -5,23 +5,48 @@ import { ipcMain } from "electron";
|
|||||||
import { AbstractStorageService } from "@bitwarden/common/abstractions/storage.service";
|
import { AbstractStorageService } from "@bitwarden/common/abstractions/storage.service";
|
||||||
import { NodeUtils } from "@bitwarden/common/misc/nodeUtils";
|
import { NodeUtils } from "@bitwarden/common/misc/nodeUtils";
|
||||||
|
|
||||||
|
// See: https://github.com/sindresorhus/electron-store/blob/main/index.d.ts
|
||||||
|
interface ElectronStoreOptions {
|
||||||
|
defaults: unknown;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
type ElectronStoreConstructor = new (options: ElectronStoreOptions) => ElectronStore;
|
||||||
|
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
const Store = require("electron-store");
|
const Store: ElectronStoreConstructor = require("electron-store");
|
||||||
|
|
||||||
|
interface ElectronStore {
|
||||||
|
get: (key: string) => unknown;
|
||||||
|
set: (key: string, obj: unknown) => void;
|
||||||
|
delete: (key: string) => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface BaseOptions<T extends string> {
|
||||||
|
action: T;
|
||||||
|
key: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SaveOptions extends BaseOptions<"save"> {
|
||||||
|
obj: unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
type Options = BaseOptions<"get"> | BaseOptions<"has"> | SaveOptions | BaseOptions<"remove">;
|
||||||
|
|
||||||
export class ElectronStorageService implements AbstractStorageService {
|
export class ElectronStorageService implements AbstractStorageService {
|
||||||
private store: any;
|
private store: ElectronStore;
|
||||||
|
|
||||||
constructor(dir: string, defaults = {}) {
|
constructor(dir: string, defaults = {}) {
|
||||||
if (!fs.existsSync(dir)) {
|
if (!fs.existsSync(dir)) {
|
||||||
NodeUtils.mkdirpSync(dir, "700");
|
NodeUtils.mkdirpSync(dir, "700");
|
||||||
}
|
}
|
||||||
const storeConfig: any = {
|
const storeConfig: ElectronStoreOptions = {
|
||||||
defaults: defaults,
|
defaults: defaults,
|
||||||
name: "data",
|
name: "data",
|
||||||
};
|
};
|
||||||
this.store = new Store(storeConfig);
|
this.store = new Store(storeConfig);
|
||||||
|
|
||||||
ipcMain.handle("storageService", (event, options) => {
|
ipcMain.handle("storageService", (event, options: Options) => {
|
||||||
switch (options.action) {
|
switch (options.action) {
|
||||||
case "get":
|
case "get":
|
||||||
return this.get(options.key);
|
return this.get(options.key);
|
||||||
@ -45,7 +70,7 @@ export class ElectronStorageService implements AbstractStorageService {
|
|||||||
return Promise.resolve(val != null);
|
return Promise.resolve(val != null);
|
||||||
}
|
}
|
||||||
|
|
||||||
save(key: string, obj: any): Promise<any> {
|
save(key: string, obj: unknown): Promise<void> {
|
||||||
if (obj instanceof Set) {
|
if (obj instanceof Set) {
|
||||||
obj = Array.from(obj);
|
obj = Array.from(obj);
|
||||||
}
|
}
|
||||||
@ -53,7 +78,7 @@ export class ElectronStorageService implements AbstractStorageService {
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
remove(key: string): Promise<any> {
|
remove(key: string): Promise<void> {
|
||||||
this.store.delete(key);
|
this.store.delete(key);
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user