From 581e9ad83a10f542c0ab587f96b0a25e8e99c87e Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Tue, 21 Dec 2021 09:09:23 +1000 Subject: [PATCH] Minor fixes when integrating with web client --- angular/src/services/jslib-services.module.ts | 4 ++-- common/src/abstractions/auth.service.ts | 2 ++ common/src/abstractions/twoFactor.service.ts | 1 + .../request/identityToken/passwordTokenRequest.ts | 2 +- common/src/services/auth.service.ts | 10 +++++++++- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/angular/src/services/jslib-services.module.ts b/angular/src/services/jslib-services.module.ts index e9755471..3b95bea0 100644 --- a/angular/src/services/jslib-services.module.ts +++ b/angular/src/services/jslib-services.module.ts @@ -113,11 +113,10 @@ import { ValidationService } from "./validation.service"; PlatformUtilsServiceAbstraction, MessagingServiceAbstraction, LogService, - CryptoFunctionServiceAbstraction, KeyConnectorServiceAbstraction, EnvironmentServiceAbstraction, - TwoFactorServiceAbstraction, StateServiceAbstraction, + TwoFactorServiceAbstraction, ], }, { @@ -430,6 +429,7 @@ import { ValidationService } from "./validation.service"; TokenServiceAbstraction, LogService, OrganizationServiceAbstraction, + CryptoFunctionServiceAbstraction, ], }, { diff --git a/common/src/abstractions/auth.service.ts b/common/src/abstractions/auth.service.ts index 24081ec3..7a4d3b05 100644 --- a/common/src/abstractions/auth.service.ts +++ b/common/src/abstractions/auth.service.ts @@ -3,6 +3,8 @@ import { SymmetricCryptoKey } from "../models/domain/symmetricCryptoKey"; import { TokenRequestTwoFactor } from "../models/request/identityToken/tokenRequest"; export abstract class AuthService { + masterPasswordHash: string; + email: string; logIn: ( email: string, masterPassword: string, diff --git a/common/src/abstractions/twoFactor.service.ts b/common/src/abstractions/twoFactor.service.ts index 155633c9..009ac386 100644 --- a/common/src/abstractions/twoFactor.service.ts +++ b/common/src/abstractions/twoFactor.service.ts @@ -1,6 +1,7 @@ import { TwoFactorProviderType } from "../enums/twoFactorProviderType"; export abstract class TwoFactorService { + init: () => void; getSupportedProviders: (win: Window) => any[]; getDefaultProvider: (webAuthnSupported: boolean) => TwoFactorProviderType; clearSelectedProvider: () => void; diff --git a/common/src/models/request/identityToken/passwordTokenRequest.ts b/common/src/models/request/identityToken/passwordTokenRequest.ts index c9499678..a1d8466b 100644 --- a/common/src/models/request/identityToken/passwordTokenRequest.ts +++ b/common/src/models/request/identityToken/passwordTokenRequest.ts @@ -8,7 +8,7 @@ import { Utils } from "../../../misc/utils"; export class PasswordTokenRequest extends TokenRequest implements CaptchaProtectedRequest { constructor( public email: string, - private masterPasswordHash: string, + public masterPasswordHash: string, public captchaResponse: string, protected twoFactor: TokenRequestTwoFactor, device?: DeviceRequest diff --git a/common/src/services/auth.service.ts b/common/src/services/auth.service.ts index 801acd6d..76df1c68 100644 --- a/common/src/services/auth.service.ts +++ b/common/src/services/auth.service.ts @@ -219,6 +219,14 @@ export class AuthService implements AuthServiceAbstraction { return this.savedTokenRequest instanceof PasswordTokenRequest; } + get email(): string { + return (this.savedTokenRequest as PasswordTokenRequest).email; + } + + get masterPasswordHash(): string { + return (this.savedTokenRequest as PasswordTokenRequest).masterPasswordHash; + } + async makePreloginKey(masterPassword: string, email: string): Promise { email = email.trim().toLowerCase(); let kdf: KdfType = null; @@ -259,7 +267,7 @@ export class AuthService implements AuthServiceAbstraction { result.resetMasterPassword = tokenResponse.resetMasterPassword; result.forcePasswordReset = tokenResponse.forcePasswordReset; - this.saveAccountInformation(tokenResponse); + await this.saveAccountInformation(tokenResponse); if (tokenResponse.twoFactorToken != null) { await this.tokenService.setTwoFactorToken(tokenResponse.twoFactorToken);