1
0
mirror of https://github.com/bitwarden/jslib synced 2025-12-19 01:33:22 +00:00

Minor fixes when integrating with web client

This commit is contained in:
Thomas Rittson
2021-12-21 09:09:23 +10:00
parent 35d894223d
commit 581e9ad83a
5 changed files with 15 additions and 4 deletions

View File

@@ -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,
],
},
{

View File

@@ -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,

View File

@@ -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;

View File

@@ -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

View File

@@ -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<SymmetricCryptoKey> {
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);