mirror of
https://github.com/bitwarden/browser.git
synced 2025-01-23 21:31:29 +01:00
remove extra unused method (#9500)
This commit is contained in:
parent
d3f1992ad5
commit
917c5fff5b
@ -3,7 +3,6 @@ import { Observable } from "rxjs";
|
|||||||
import { AuthenticationType } from "@bitwarden/common/auth/enums/authentication-type";
|
import { AuthenticationType } from "@bitwarden/common/auth/enums/authentication-type";
|
||||||
import { AuthResult } from "@bitwarden/common/auth/models/domain/auth-result";
|
import { AuthResult } from "@bitwarden/common/auth/models/domain/auth-result";
|
||||||
import { TokenTwoFactorRequest } from "@bitwarden/common/auth/models/request/identity-token/token-two-factor.request";
|
import { TokenTwoFactorRequest } from "@bitwarden/common/auth/models/request/identity-token/token-two-factor.request";
|
||||||
import { AuthRequestResponse } from "@bitwarden/common/auth/models/response/auth-request.response";
|
|
||||||
import { MasterKey } from "@bitwarden/common/types/key";
|
import { MasterKey } from "@bitwarden/common/types/key";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -72,12 +71,4 @@ export abstract class LoginStrategyServiceAbstraction {
|
|||||||
* Creates a master key from the provided master password and email.
|
* Creates a master key from the provided master password and email.
|
||||||
*/
|
*/
|
||||||
makePreloginKey: (masterPassword: string, email: string) => Promise<MasterKey>;
|
makePreloginKey: (masterPassword: string, email: string) => Promise<MasterKey>;
|
||||||
/**
|
|
||||||
* Sends a response to an auth request.
|
|
||||||
*/
|
|
||||||
passwordlessLogin: (
|
|
||||||
id: string,
|
|
||||||
key: string,
|
|
||||||
requestApproved: boolean,
|
|
||||||
) => Promise<AuthRequestResponse>;
|
|
||||||
}
|
}
|
||||||
|
@ -24,8 +24,6 @@ import {
|
|||||||
PBKDF2KdfConfig,
|
PBKDF2KdfConfig,
|
||||||
} from "@bitwarden/common/auth/models/domain/kdf-config";
|
} from "@bitwarden/common/auth/models/domain/kdf-config";
|
||||||
import { TokenTwoFactorRequest } from "@bitwarden/common/auth/models/request/identity-token/token-two-factor.request";
|
import { TokenTwoFactorRequest } from "@bitwarden/common/auth/models/request/identity-token/token-two-factor.request";
|
||||||
import { PasswordlessAuthRequest } from "@bitwarden/common/auth/models/request/passwordless-auth.request";
|
|
||||||
import { AuthRequestResponse } from "@bitwarden/common/auth/models/response/auth-request.response";
|
|
||||||
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
|
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
|
||||||
import { PreloginRequest } from "@bitwarden/common/models/request/prelogin.request";
|
import { PreloginRequest } from "@bitwarden/common/models/request/prelogin.request";
|
||||||
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
||||||
@ -39,7 +37,6 @@ import { MessagingService } from "@bitwarden/common/platform/abstractions/messag
|
|||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
||||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
||||||
import { KdfType } from "@bitwarden/common/platform/enums/kdf-type.enum";
|
import { KdfType } from "@bitwarden/common/platform/enums/kdf-type.enum";
|
||||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
|
||||||
import { GlobalState, GlobalStateProvider } from "@bitwarden/common/platform/state";
|
import { GlobalState, GlobalStateProvider } from "@bitwarden/common/platform/state";
|
||||||
import { DeviceTrustServiceAbstraction } from "@bitwarden/common/src/auth/abstractions/device-trust.service.abstraction";
|
import { DeviceTrustServiceAbstraction } from "@bitwarden/common/src/auth/abstractions/device-trust.service.abstraction";
|
||||||
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
||||||
@ -263,47 +260,6 @@ export class LoginStrategyService implements LoginStrategyServiceAbstraction {
|
|||||||
return await this.cryptoService.makeMasterKey(masterPassword, email, kdfConfig);
|
return await this.cryptoService.makeMasterKey(masterPassword, email, kdfConfig);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move to auth request service
|
|
||||||
async passwordlessLogin(
|
|
||||||
id: string,
|
|
||||||
key: string,
|
|
||||||
requestApproved: boolean,
|
|
||||||
): Promise<AuthRequestResponse> {
|
|
||||||
const pubKey = Utils.fromB64ToArray(key);
|
|
||||||
|
|
||||||
const userId = (await firstValueFrom(this.accountService.activeAccount$)).id;
|
|
||||||
const masterKey = await firstValueFrom(this.masterPasswordService.masterKey$(userId));
|
|
||||||
let keyToEncrypt;
|
|
||||||
let encryptedMasterKeyHash = null;
|
|
||||||
|
|
||||||
if (masterKey) {
|
|
||||||
keyToEncrypt = masterKey.encKey;
|
|
||||||
|
|
||||||
// Only encrypt the master password hash if masterKey exists as
|
|
||||||
// we won't have a masterKeyHash without a masterKey
|
|
||||||
const masterKeyHash = await firstValueFrom(this.masterPasswordService.masterKeyHash$(userId));
|
|
||||||
if (masterKeyHash != null) {
|
|
||||||
encryptedMasterKeyHash = await this.cryptoService.rsaEncrypt(
|
|
||||||
Utils.fromUtf8ToArray(masterKeyHash),
|
|
||||||
pubKey,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
const userKey = await this.cryptoService.getUserKey();
|
|
||||||
keyToEncrypt = userKey.key;
|
|
||||||
}
|
|
||||||
|
|
||||||
const encryptedKey = await this.cryptoService.rsaEncrypt(keyToEncrypt, pubKey);
|
|
||||||
|
|
||||||
const request = new PasswordlessAuthRequest(
|
|
||||||
encryptedKey.encryptedString,
|
|
||||||
encryptedMasterKeyHash?.encryptedString,
|
|
||||||
await this.appIdService.getAppId(),
|
|
||||||
requestApproved,
|
|
||||||
);
|
|
||||||
return await this.apiService.putAuthRequest(id, request);
|
|
||||||
}
|
|
||||||
|
|
||||||
private async clearCache(): Promise<void> {
|
private async clearCache(): Promise<void> {
|
||||||
await this.currentAuthnTypeState.update((_) => null);
|
await this.currentAuthnTypeState.update((_) => null);
|
||||||
await this.loginStrategyCacheState.update((_) => null);
|
await this.loginStrategyCacheState.update((_) => null);
|
||||||
|
Loading…
Reference in New Issue
Block a user