1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-09-27 04:03:00 +02:00

[PM-3198][PM-3199] Rename PasswordlessLoginStrategy (#6425)

* rename to LoginWithDeviceLoginStrategy

* rename LoginWithDeviceComponent

* update translation for web route

* rename strategy to AuthRequestLoginStrategy

* rename PasswordlessLogInCredentials and PasswordlessCreateAuthRequest

* rename setPasswordlessAccessCode

* rename startPasswordlessLogin() in template files

* rename startPasswordlessLogin() for browser template file

* rename AuthenticationType.Passwordless

* standardize LogInStrategy to LoginStrategy

* standardize PasswordLogInStrategy to PasswordLoginStrategy

* standardize SsoLogInStrategy to SsoLoginStrategy

* standardize UserApiLogInStrategy to UserApiLoginStrategy

* standardize naming of login credentials

* rename log-in-credentials.ts to login-credentials.ts
This commit is contained in:
rr-bw 2023-10-25 11:15:05 -07:00 committed by GitHub
parent 8dd17bd55a
commit 5868d76b91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
38 changed files with 250 additions and 254 deletions

View File

@ -25,7 +25,7 @@
</div>
<div class="resend-notification" *ngIf="showResendNotification">
<a (click)="startPasswordlessLogin()">{{ "resendNotification" | i18n }}</a>
<a (click)="startAuthRequestLogin()">{{ "resendNotification" | i18n }}</a>
</div>
<div class="footer">

View File

@ -2,7 +2,7 @@ import { Location } from "@angular/common";
import { Component, OnDestroy, OnInit } from "@angular/core";
import { Router } from "@angular/router";
import { LoginWithDeviceComponent as BaseLoginWithDeviceComponent } from "@bitwarden/angular/auth/components/login-with-device.component";
import { LoginViaAuthRequestComponent as BaseLoginWithDeviceComponent } from "@bitwarden/angular/auth/components/login-via-auth-request.component";
import { AnonymousHubService } from "@bitwarden/common/abstractions/anonymousHub.service";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { AuthRequestCryptoServiceAbstraction } from "@bitwarden/common/auth/abstractions/auth-request-crypto.service.abstraction";
@ -22,10 +22,10 @@ import { PasswordGenerationServiceAbstraction } from "@bitwarden/common/tools/ge
import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.service.abstraction";
@Component({
selector: "app-login-with-device",
templateUrl: "login-with-device.component.html",
selector: "app-login-via-auth-request",
templateUrl: "login-via-auth-request.component.html",
})
export class LoginWithDeviceComponent
export class LoginViaAuthRequestComponent
extends BaseLoginWithDeviceComponent
implements OnInit, OnDestroy
{

View File

@ -66,7 +66,7 @@
<i class="bwi bwi-spinner bwi-lg bwi-spin" [hidden]="!form.loading" aria-hidden="true"></i>
</button>
<div class="tw-mb-3" *ngIf="showLoginWithDevice && showPasswordless">
<button type="button" class="btn block" (click)="startPasswordlessLogin()">
<button type="button" class="btn block" (click)="startAuthRequestLogin()">
<span> <i class="bwi bwi-mobile"></i> {{ "loginWithDevice" | i18n }} </span>
</button>
</div>

View File

@ -17,7 +17,7 @@ import { HintComponent } from "../auth/popup/hint.component";
import { HomeComponent } from "../auth/popup/home.component";
import { LockComponent } from "../auth/popup/lock.component";
import { LoginDecryptionOptionsComponent } from "../auth/popup/login-decryption-options/login-decryption-options.component";
import { LoginWithDeviceComponent } from "../auth/popup/login-with-device.component";
import { LoginViaAuthRequestComponent } from "../auth/popup/login-via-auth-request.component";
import { LoginComponent } from "../auth/popup/login.component";
import { RegisterComponent } from "../auth/popup/register.component";
import { RemovePasswordComponent } from "../auth/popup/remove-password.component";
@ -90,13 +90,13 @@ const routes: Routes = [
},
{
path: "login-with-device",
component: LoginWithDeviceComponent,
component: LoginViaAuthRequestComponent,
canActivate: [],
data: { state: "login-with-device" },
},
{
path: "admin-approval-requested",
component: LoginWithDeviceComponent,
component: LoginViaAuthRequestComponent,
canActivate: [],
data: { state: "login-with-device" },
},

View File

@ -22,7 +22,7 @@ import { HintComponent } from "../auth/popup/hint.component";
import { HomeComponent } from "../auth/popup/home.component";
import { LockComponent } from "../auth/popup/lock.component";
import { LoginDecryptionOptionsComponent } from "../auth/popup/login-decryption-options/login-decryption-options.component";
import { LoginWithDeviceComponent } from "../auth/popup/login-with-device.component";
import { LoginViaAuthRequestComponent } from "../auth/popup/login-via-auth-request.component";
import { LoginComponent } from "../auth/popup/login.component";
import { RegisterComponent } from "../auth/popup/register.component";
import { RemovePasswordComponent } from "../auth/popup/remove-password.component";
@ -125,7 +125,7 @@ import "../platform/popup/locales";
HomeComponent,
LockComponent,
LoginComponent,
LoginWithDeviceComponent,
LoginViaAuthRequestComponent,
LoginDecryptionOptionsComponent,
OptionsComponent,
GeneratorComponent,

View File

@ -16,10 +16,10 @@ import { TwoFactorProviderType } from "@bitwarden/common/auth/enums/two-factor-p
import { AuthResult } from "@bitwarden/common/auth/models/domain/auth-result";
import { ForceResetPasswordReason } from "@bitwarden/common/auth/models/domain/force-reset-password-reason";
import {
PasswordLogInCredentials,
SsoLogInCredentials,
UserApiLogInCredentials,
} from "@bitwarden/common/auth/models/domain/log-in-credentials";
PasswordLoginCredentials,
SsoLoginCredentials,
UserApiLoginCredentials,
} from "@bitwarden/common/auth/models/domain/login-credentials";
import { TokenTwoFactorRequest } from "@bitwarden/common/auth/models/request/identity-token/token-two-factor.request";
import { PasswordRequest } from "@bitwarden/common/auth/models/request/password.request";
import { TwoFactorEmailRequest } from "@bitwarden/common/auth/models/request/two-factor-email.request";
@ -179,7 +179,7 @@ export class LoginCommand {
}
try {
response = await this.authService.logIn(
new UserApiLogInCredentials(clientId, clientSecret)
new UserApiLoginCredentials(clientId, clientSecret)
);
} catch (e) {
// handle API key login failures
@ -196,7 +196,7 @@ export class LoginCommand {
}
} else if (ssoCode != null && ssoCodeVerifier != null) {
response = await this.authService.logIn(
new SsoLogInCredentials(
new SsoLoginCredentials(
ssoCode,
ssoCodeVerifier,
this.ssoRedirectUri,
@ -206,7 +206,7 @@ export class LoginCommand {
);
} else {
response = await this.authService.logIn(
new PasswordLogInCredentials(email, password, null, twoFactor)
new PasswordLoginCredentials(email, password, null, twoFactor)
);
}
if (response.requiresEncryptionKeyMigration) {
@ -215,7 +215,7 @@ export class LoginCommand {
);
}
if (response.captchaSiteKey) {
const credentials = new PasswordLogInCredentials(email, password);
const credentials = new PasswordLoginCredentials(email, password);
const handledResponse = await this.handleCaptchaRequired(twoFactor, credentials);
// Error Response
@ -586,7 +586,7 @@ export class LoginCommand {
private async handleCaptchaRequired(
twoFactorRequest: TokenTwoFactorRequest,
credentials: PasswordLogInCredentials = null
credentials: PasswordLoginCredentials = null
): Promise<AuthResult | Response> {
const badCaptcha = Response.badRequest(
"Your authentication request has been flagged and will require user interaction to proceed.\n" +

View File

@ -15,7 +15,7 @@ import { LoginGuard } from "../auth/guards/login.guard";
import { HintComponent } from "../auth/hint.component";
import { LockComponent } from "../auth/lock.component";
import { LoginDecryptionOptionsComponent } from "../auth/login/login-decryption-options/login-decryption-options.component";
import { LoginWithDeviceComponent } from "../auth/login/login-with-device.component";
import { LoginViaAuthRequestComponent } from "../auth/login/login-via-auth-request.component";
import { LoginComponent } from "../auth/login/login.component";
import { RegisterComponent } from "../auth/register.component";
import { RemovePasswordComponent } from "../auth/remove-password.component";
@ -46,11 +46,11 @@ const routes: Routes = [
},
{
path: "login-with-device",
component: LoginWithDeviceComponent,
component: LoginViaAuthRequestComponent,
},
{
path: "admin-approval-requested",
component: LoginWithDeviceComponent,
component: LoginViaAuthRequestComponent,
},
{ path: "2fa", component: TwoFactorComponent },
{

View File

@ -21,7 +21,7 @@
</div>
<div class="section" *ngIf="showResendNotification">
<a [routerLink]="[]" disabled="true" (click)="startPasswordlessLogin()">{{
<a [routerLink]="[]" disabled="true" (click)="startAuthRequestLogin()">{{
"resendNotification" | i18n
}}</a>
</div>

View File

@ -2,7 +2,7 @@ import { Location } from "@angular/common";
import { Component, OnDestroy, OnInit, ViewChild, ViewContainerRef } from "@angular/core";
import { Router } from "@angular/router";
import { LoginWithDeviceComponent as BaseLoginWithDeviceComponent } from "@bitwarden/angular/auth/components/login-with-device.component";
import { LoginViaAuthRequestComponent as BaseLoginWithDeviceComponent } from "@bitwarden/angular/auth/components/login-via-auth-request.component";
import { ModalService } from "@bitwarden/angular/services/modal.service";
import { AnonymousHubService } from "@bitwarden/common/abstractions/anonymousHub.service";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
@ -25,10 +25,10 @@ import { SyncService } from "@bitwarden/common/vault/abstractions/sync/sync.serv
import { EnvironmentComponent } from "../environment.component";
@Component({
selector: "app-login-with-device",
templateUrl: "login-with-device.component.html",
selector: "app-login-via-auth-request",
templateUrl: "login-via-auth-request.component.html",
})
export class LoginWithDeviceComponent
export class LoginViaAuthRequestComponent
extends BaseLoginWithDeviceComponent
implements OnInit, OnDestroy
{

View File

@ -118,7 +118,7 @@
</button>
</div>
<div class="buttons-row" *ngIf="showLoginWithDevice">
<button type="button" class="btn block" (click)="startPasswordlessLogin()">
<button type="button" class="btn block" (click)="startAuthRequestLogin()">
<i class="bwi bwi-mobile" aria-hidden="true"></i>
{{ "logInWithAnotherDevice" | i18n }}
</button>

View File

@ -6,17 +6,17 @@ import { EnvironmentSelectorComponent } from "@bitwarden/angular/auth/components
import { SharedModule } from "../../app/shared/shared.module";
import { LoginDecryptionOptionsComponent } from "./login-decryption-options/login-decryption-options.component";
import { LoginWithDeviceComponent } from "./login-with-device.component";
import { LoginViaAuthRequestComponent } from "./login-via-auth-request.component";
import { LoginComponent } from "./login.component";
@NgModule({
imports: [SharedModule, RouterModule],
declarations: [
LoginComponent,
LoginWithDeviceComponent,
LoginViaAuthRequestComponent,
EnvironmentSelectorComponent,
LoginDecryptionOptionsComponent,
],
exports: [LoginComponent, LoginWithDeviceComponent],
exports: [LoginComponent, LoginViaAuthRequestComponent],
})
export class LoginModule {}

View File

@ -32,7 +32,7 @@
</div>
<div class="tw-my-10" *ngIf="showResendNotification">
<a [routerLink]="[]" disabled="true" (click)="startPasswordlessLogin()">{{
<a [routerLink]="[]" disabled="true" (click)="startAuthRequestLogin()">{{
"resendNotification" | i18n
}}</a>
</div>

View File

@ -1,7 +1,7 @@
import { Component, OnDestroy, OnInit } from "@angular/core";
import { Router } from "@angular/router";
import { LoginWithDeviceComponent as BaseLoginWithDeviceComponent } from "@bitwarden/angular/auth/components/login-with-device.component";
import { LoginViaAuthRequestComponent as BaseLoginWithDeviceComponent } from "@bitwarden/angular/auth/components/login-via-auth-request.component";
import { AnonymousHubService } from "@bitwarden/common/abstractions/anonymousHub.service";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { AuthRequestCryptoServiceAbstraction } from "@bitwarden/common/auth/abstractions/auth-request-crypto.service.abstraction";
@ -21,10 +21,10 @@ import { PasswordGenerationServiceAbstraction } from "@bitwarden/common/tools/ge
import { StateService } from "../../core";
@Component({
selector: "app-login-with-device",
templateUrl: "login-with-device.component.html",
selector: "app-login-via-auth-request",
templateUrl: "login-via-auth-request.component.html",
})
export class LoginWithDeviceComponent
export class LoginViaAuthRequestComponent
extends BaseLoginWithDeviceComponent
implements OnInit, OnDestroy
{

View File

@ -108,7 +108,7 @@
type="button"
[block]="true"
buttonType="secondary"
(click)="startPasswordlessLogin()"
(click)="startAuthRequestLogin()"
>
<span> <i class="bwi bwi-mobile"></i> {{ "loginWithDevice" | i18n }} </span>
</button>

View File

@ -5,12 +5,12 @@ import { CheckboxModule } from "@bitwarden/components";
import { SharedModule } from "../../../app/shared";
import { LoginDecryptionOptionsComponent } from "./login-decryption-options/login-decryption-options.component";
import { LoginWithDeviceComponent } from "./login-with-device.component";
import { LoginViaAuthRequestComponent } from "./login-via-auth-request.component";
import { LoginComponent } from "./login.component";
@NgModule({
imports: [SharedModule, CheckboxModule],
declarations: [LoginComponent, LoginWithDeviceComponent, LoginDecryptionOptionsComponent],
exports: [LoginComponent, LoginWithDeviceComponent, LoginDecryptionOptionsComponent],
declarations: [LoginComponent, LoginViaAuthRequestComponent, LoginDecryptionOptionsComponent],
exports: [LoginComponent, LoginViaAuthRequestComponent, LoginDecryptionOptionsComponent],
})
export class LoginModule {}

View File

@ -22,7 +22,7 @@ import { AcceptOrganizationComponent } from "./auth/accept-organization.componen
import { HintComponent } from "./auth/hint.component";
import { LockComponent } from "./auth/lock.component";
import { LoginDecryptionOptionsComponent } from "./auth/login/login-decryption-options/login-decryption-options.component";
import { LoginWithDeviceComponent } from "./auth/login/login-with-device.component";
import { LoginViaAuthRequestComponent } from "./auth/login/login-via-auth-request.component";
import { LoginComponent } from "./auth/login/login.component";
import { RecoverDeleteComponent } from "./auth/recover-delete.component";
import { RecoverTwoFactorComponent } from "./auth/recover-two-factor.component";
@ -66,13 +66,13 @@ const routes: Routes = [
{ path: "login", component: LoginComponent, canActivate: [UnauthGuard] },
{
path: "login-with-device",
component: LoginWithDeviceComponent,
component: LoginViaAuthRequestComponent,
data: { titleId: "loginWithDevice" },
},
{
path: "admin-approval-requested",
component: LoginWithDeviceComponent,
data: { titleId: "loginWithDevice" },
component: LoginViaAuthRequestComponent,
data: { titleId: "adminApprovalRequested" },
},
{ path: "2fa", component: TwoFactorComponent, canActivate: [UnauthGuard] },
{

View File

@ -13,8 +13,8 @@ import { AuthenticationStatus } from "@bitwarden/common/auth/enums/authenticatio
import { AdminAuthRequestStorable } from "@bitwarden/common/auth/models/domain/admin-auth-req-storable";
import { AuthResult } from "@bitwarden/common/auth/models/domain/auth-result";
import { ForceResetPasswordReason } from "@bitwarden/common/auth/models/domain/force-reset-password-reason";
import { PasswordlessLogInCredentials } from "@bitwarden/common/auth/models/domain/log-in-credentials";
import { PasswordlessCreateAuthRequest } from "@bitwarden/common/auth/models/request/passwordless-create-auth.request";
import { AuthRequestLoginCredentials } from "@bitwarden/common/auth/models/domain/login-credentials";
import { CreateAuthRequest } from "@bitwarden/common/auth/models/request/create-auth.request";
import { AuthRequestResponse } from "@bitwarden/common/auth/models/response/auth-request.response";
import { HttpStatusCode } from "@bitwarden/common/enums/http-status-code.enum";
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
@ -32,15 +32,13 @@ import { PasswordGenerationServiceAbstraction } from "@bitwarden/common/tools/ge
import { CaptchaProtectedComponent } from "./captcha-protected.component";
// TODO: consider renaming this component something like LoginViaAuthReqComponent
enum State {
StandardAuthRequest,
AdminAuthRequest,
}
@Directive()
export class LoginWithDeviceComponent
export class LoginViaAuthRequestComponent
extends CaptchaProtectedComponent
implements OnInit, OnDestroy
{
@ -48,7 +46,7 @@ export class LoginWithDeviceComponent
userAuthNStatus: AuthenticationStatus;
email: string;
showResendNotification = false;
passwordlessRequest: PasswordlessCreateAuthRequest;
authRequest: CreateAuthRequest;
fingerprintPhrase: string;
onSuccessfulLoginTwoFactorNavigate: () => Promise<any>;
onSuccessfulLogin: () => Promise<any>;
@ -140,7 +138,7 @@ export class LoginWithDeviceComponent
await this.handleExistingAdminAuthRequest(adminAuthReqStorable);
} else {
// No existing admin auth request; so we need to create one
await this.startPasswordlessLogin();
await this.startAuthRequestLogin();
}
} else {
// Standard auth request
@ -153,7 +151,7 @@ export class LoginWithDeviceComponent
return;
}
await this.startPasswordlessLogin();
await this.startAuthRequestLogin();
}
}
@ -214,7 +212,7 @@ export class LoginWithDeviceComponent
await this.stateService.setAdminAuthRequest(null);
// start new auth request
this.startPasswordlessLogin();
this.startAuthRequestLogin();
}
private async buildAuthRequest(authRequestType: AuthRequestType) {
@ -233,7 +231,7 @@ export class LoginWithDeviceComponent
await this.cryptoService.getFingerprint(this.email, this.authRequestKeyPair.publicKey)
).join("-");
this.passwordlessRequest = new PasswordlessCreateAuthRequest(
this.authRequest = new CreateAuthRequest(
this.email,
deviceIdentifier,
publicKey,
@ -242,7 +240,7 @@ export class LoginWithDeviceComponent
);
}
async startPasswordlessLogin() {
async startAuthRequestLogin() {
this.showResendNotification = false;
try {
@ -250,7 +248,7 @@ export class LoginWithDeviceComponent
if (this.state === State.AdminAuthRequest) {
await this.buildAuthRequest(AuthRequestType.AdminApproval);
reqResponse = await this.apiService.postAdminAuthRequest(this.passwordlessRequest);
reqResponse = await this.apiService.postAdminAuthRequest(this.authRequest);
const adminAuthReqStorable = new AdminAuthRequestStorable({
id: reqResponse.id,
@ -260,7 +258,7 @@ export class LoginWithDeviceComponent
await this.stateService.setAdminAuthRequest(adminAuthReqStorable);
} else {
await this.buildAuthRequest(AuthRequestType.AuthenticateAndUnlock);
reqResponse = await this.apiService.postAuthRequest(this.passwordlessRequest);
reqResponse = await this.apiService.postAuthRequest(this.authRequest);
}
if (reqResponse.id) {
@ -285,7 +283,7 @@ export class LoginWithDeviceComponent
// Unauthed - access code required for user verification
authReqResponse = await this.apiService.getAuthResponse(
requestId,
this.passwordlessRequest.accessCode
this.authRequest.accessCode
);
break;
@ -328,7 +326,7 @@ export class LoginWithDeviceComponent
}
// Flow 1 and 4:
const loginAuthResult = await this.loginViaPasswordlessStrategy(requestId, authReqResponse);
const loginAuthResult = await this.loginViaAuthRequestStrategy(requestId, authReqResponse);
await this.handlePostLoginNavigation(loginAuthResult);
} catch (error) {
if (error instanceof ErrorResponse) {
@ -384,10 +382,10 @@ export class LoginWithDeviceComponent
}
// Authentication helper
private async buildPasswordlessLoginCredentials(
private async buildAuthRequestLoginCredentials(
requestId: string,
response: AuthRequestResponse
): Promise<PasswordlessLogInCredentials> {
): Promise<AuthRequestLoginCredentials> {
// if masterPasswordHash has a value, we will always receive key as authRequestPublicKey(masterKey) + authRequestPublicKey(masterPasswordHash)
// if masterPasswordHash is null, we will always receive key as authRequestPublicKey(userKey)
if (response.masterPasswordHash) {
@ -398,9 +396,9 @@ export class LoginWithDeviceComponent
this.authRequestKeyPair.privateKey
);
return new PasswordlessLogInCredentials(
return new AuthRequestLoginCredentials(
this.email,
this.passwordlessRequest.accessCode,
this.authRequest.accessCode,
requestId,
null, // no userKey
masterKey,
@ -411,9 +409,9 @@ export class LoginWithDeviceComponent
response.key,
this.authRequestKeyPair.privateKey
);
return new PasswordlessLogInCredentials(
return new AuthRequestLoginCredentials(
this.email,
this.passwordlessRequest.accessCode,
this.authRequest.accessCode,
requestId,
userKey,
null, // no masterKey
@ -422,14 +420,14 @@ export class LoginWithDeviceComponent
}
}
private async loginViaPasswordlessStrategy(
private async loginViaAuthRequestStrategy(
requestId: string,
authReqResponse: AuthRequestResponse
): Promise<AuthResult> {
// Note: credentials change based on if the authReqResponse.key is a encryptedMasterKey or UserKey
const credentials = await this.buildPasswordlessLoginCredentials(requestId, authReqResponse);
const credentials = await this.buildAuthRequestLoginCredentials(requestId, authReqResponse);
// Note: keys are set by PasswordlessLogInStrategy success handling
// Note: keys are set by AuthRequestLoginStrategy success handling
return await this.authService.logIn(credentials);
}

View File

@ -9,7 +9,7 @@ import { DevicesApiServiceAbstraction } from "@bitwarden/common/auth/abstraction
import { LoginService } from "@bitwarden/common/auth/abstractions/login.service";
import { AuthResult } from "@bitwarden/common/auth/models/domain/auth-result";
import { ForceResetPasswordReason } from "@bitwarden/common/auth/models/domain/force-reset-password-reason";
import { PasswordLogInCredentials } from "@bitwarden/common/auth/models/domain/log-in-credentials";
import { PasswordLoginCredentials } from "@bitwarden/common/auth/models/domain/login-credentials";
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
import { CryptoFunctionService } from "@bitwarden/common/platform/abstractions/crypto-function.service";
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
@ -140,7 +140,7 @@ export class LoginComponent extends CaptchaProtectedComponent implements OnInit,
}
try {
const credentials = new PasswordLogInCredentials(
const credentials = new PasswordLoginCredentials(
data.email,
data.masterPassword,
this.captchaToken,
@ -192,7 +192,7 @@ export class LoginComponent extends CaptchaProtectedComponent implements OnInit,
}
}
async startPasswordlessLogin() {
async startAuthRequestLogin() {
this.formGroup.get("masterPassword")?.clearValidators();
this.formGroup.get("masterPassword")?.updateValueAndValidity();

View File

@ -5,7 +5,7 @@ import { Router } from "@angular/router";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { AuditService } from "@bitwarden/common/abstractions/audit.service";
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
import { PasswordLogInCredentials } from "@bitwarden/common/auth/models/domain/log-in-credentials";
import { PasswordLoginCredentials } from "@bitwarden/common/auth/models/domain/login-credentials";
import { RegisterResponse } from "@bitwarden/common/auth/models/response/register.response";
import { DEFAULT_KDF_CONFIG, DEFAULT_KDF_TYPE } from "@bitwarden/common/enums";
import { KeysRequest } from "@bitwarden/common/models/request/keys.request";
@ -323,7 +323,7 @@ export class RegisterComponent extends CaptchaProtectedComponent implements OnIn
masterPassword: string,
captchaBypassToken: string
): Promise<{ captchaRequired: boolean }> {
const credentials = new PasswordLogInCredentials(
const credentials = new PasswordLoginCredentials(
email,
masterPassword,
captchaBypassToken,

View File

@ -6,7 +6,7 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
import { AuthResult } from "@bitwarden/common/auth/models/domain/auth-result";
import { ForceResetPasswordReason } from "@bitwarden/common/auth/models/domain/force-reset-password-reason";
import { SsoLogInCredentials } from "@bitwarden/common/auth/models/domain/log-in-credentials";
import { SsoLoginCredentials } from "@bitwarden/common/auth/models/domain/login-credentials";
import { TrustedDeviceUserDecryptionOption } from "@bitwarden/common/auth/models/domain/user-decryption-options/trusted-device-user-decryption-option";
import { SsoPreValidateResponse } from "@bitwarden/common/auth/models/response/sso-pre-validate.response";
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
@ -182,7 +182,7 @@ export class SsoComponent {
private async logIn(code: string, codeVerifier: string, orgSsoIdentifier: string): Promise<void> {
this.loggingIn = true;
try {
const credentials = new SsoLogInCredentials(
const credentials = new SsoLoginCredentials(
code,
codeVerifier,
this.redirectUri,

View File

@ -32,6 +32,7 @@ import {
} from "../admin-console/models/response/provider/provider-user.response";
import { ProviderResponse } from "../admin-console/models/response/provider/provider.response";
import { SelectionReadOnlyResponse } from "../admin-console/models/response/selection-read-only.response";
import { CreateAuthRequest } from "../auth/models/request/create-auth.request";
import { DeviceVerificationRequest } from "../auth/models/request/device-verification.request";
import { EmailTokenRequest } from "../auth/models/request/email-token.request";
import { EmailRequest } from "../auth/models/request/email.request";
@ -47,7 +48,6 @@ import { KeyConnectorUserKeyRequest } from "../auth/models/request/key-connector
import { PasswordHintRequest } from "../auth/models/request/password-hint.request";
import { PasswordRequest } from "../auth/models/request/password.request";
import { PasswordlessAuthRequest } from "../auth/models/request/passwordless-auth.request";
import { PasswordlessCreateAuthRequest } from "../auth/models/request/passwordless-create-auth.request";
import { SecretVerificationRequest } from "../auth/models/request/secret-verification.request";
import { SetKeyConnectorKeyRequest } from "../auth/models/request/set-key-connector-key.request";
import { SetPasswordRequest } from "../auth/models/request/set-password.request";
@ -199,8 +199,8 @@ export abstract class ApiService {
putUpdateTempPassword: (request: UpdateTempPasswordRequest) => Promise<any>;
postConvertToKeyConnector: () => Promise<void>;
//passwordless
postAuthRequest: (request: PasswordlessCreateAuthRequest) => Promise<AuthRequestResponse>;
postAdminAuthRequest: (request: PasswordlessCreateAuthRequest) => Promise<AuthRequestResponse>;
postAuthRequest: (request: CreateAuthRequest) => Promise<AuthRequestResponse>;
postAdminAuthRequest: (request: CreateAuthRequest) => Promise<AuthRequestResponse>;
getAuthResponse: (id: string, accessCode: string) => Promise<AuthRequestResponse>;
getAuthRequest: (id: string) => Promise<AuthRequestResponse>;
putAuthRequest: (id: string, request: PasswordlessAuthRequest) => Promise<AuthRequestResponse>;

View File

@ -5,11 +5,11 @@ import { MasterKey } from "../../platform/models/domain/symmetric-crypto-key";
import { AuthenticationStatus } from "../enums/authentication-status";
import { AuthResult } from "../models/domain/auth-result";
import {
UserApiLogInCredentials,
PasswordLogInCredentials,
SsoLogInCredentials,
PasswordlessLogInCredentials,
} from "../models/domain/log-in-credentials";
UserApiLoginCredentials,
PasswordLoginCredentials,
SsoLoginCredentials,
AuthRequestLoginCredentials,
} from "../models/domain/login-credentials";
import { TokenTwoFactorRequest } from "../models/request/identity-token/token-two-factor.request";
import { AuthRequestResponse } from "../models/response/auth-request.response";
@ -22,10 +22,10 @@ export abstract class AuthService {
logIn: (
credentials:
| UserApiLogInCredentials
| PasswordLogInCredentials
| SsoLogInCredentials
| PasswordlessLogInCredentials
| UserApiLoginCredentials
| PasswordLoginCredentials
| SsoLoginCredentials
| AuthRequestLoginCredentials
) => Promise<AuthResult>;
logInTwoFactor: (
twoFactor: TokenTwoFactorRequest,

View File

@ -2,5 +2,5 @@ export enum AuthenticationType {
Password = 0,
Sso = 1,
UserApi = 2,
Passwordless = 3,
AuthRequest = 3,
}

View File

@ -17,13 +17,13 @@ import { CsprngArray } from "../../types/csprng";
import { DeviceTrustCryptoServiceAbstraction } from "../abstractions/device-trust-crypto.service.abstraction";
import { TokenService } from "../abstractions/token.service";
import { TwoFactorService } from "../abstractions/two-factor.service";
import { PasswordlessLogInCredentials } from "../models/domain/log-in-credentials";
import { AuthRequestLoginCredentials } from "../models/domain/login-credentials";
import { IdentityTokenResponse } from "../models/response/identity-token.response";
import { AuthRequestLoginStrategy } from "./auth-request-login.strategy";
import { identityTokenResponseFactory } from "./login.strategy.spec";
import { PasswordlessLogInStrategy } from "./passwordless-login.strategy";
describe("PasswordlessLogInStrategy", () => {
describe("AuthRequestLoginStrategy", () => {
let cryptoService: MockProxy<CryptoService>;
let apiService: MockProxy<ApiService>;
let tokenService: MockProxy<TokenService>;
@ -35,8 +35,8 @@ describe("PasswordlessLogInStrategy", () => {
let twoFactorService: MockProxy<TwoFactorService>;
let deviceTrustCryptoService: MockProxy<DeviceTrustCryptoServiceAbstraction>;
let passwordlessLoginStrategy: PasswordlessLogInStrategy;
let credentials: PasswordlessLogInCredentials;
let authRequestLoginStrategy: AuthRequestLoginStrategy;
let credentials: AuthRequestLoginCredentials;
let tokenResponse: IdentityTokenResponse;
const deviceId = Utils.newGuid();
@ -66,7 +66,7 @@ describe("PasswordlessLogInStrategy", () => {
appIdService.getAppId.mockResolvedValue(deviceId);
tokenService.decodeToken.mockResolvedValue({});
passwordlessLoginStrategy = new PasswordlessLogInStrategy(
authRequestLoginStrategy = new AuthRequestLoginStrategy(
cryptoService,
apiService,
tokenService,
@ -84,7 +84,7 @@ describe("PasswordlessLogInStrategy", () => {
});
it("sets keys after a successful authentication when masterKey and masterKeyHash provided in login credentials", async () => {
credentials = new PasswordlessLogInCredentials(
credentials = new AuthRequestLoginCredentials(
email,
accessCode,
authRequestId,
@ -99,7 +99,7 @@ describe("PasswordlessLogInStrategy", () => {
cryptoService.getMasterKey.mockResolvedValue(masterKey);
cryptoService.decryptUserKeyWithMasterKey.mockResolvedValue(userKey);
await passwordlessLoginStrategy.logIn(credentials);
await authRequestLoginStrategy.logIn(credentials);
expect(cryptoService.setMasterKey).toHaveBeenCalledWith(masterKey);
expect(cryptoService.setMasterKeyHash).toHaveBeenCalledWith(decMasterKeyHash);
@ -111,7 +111,7 @@ describe("PasswordlessLogInStrategy", () => {
it("sets keys after a successful authentication when only userKey provided in login credentials", async () => {
// Initialize credentials with only userKey
credentials = new PasswordlessLogInCredentials(
credentials = new AuthRequestLoginCredentials(
email,
accessCode,
authRequestId,
@ -121,7 +121,7 @@ describe("PasswordlessLogInStrategy", () => {
);
// Call logIn
await passwordlessLoginStrategy.logIn(credentials);
await authRequestLoginStrategy.logIn(credentials);
// setMasterKey and setMasterKeyHash should not be called
expect(cryptoService.setMasterKey).not.toHaveBeenCalled();

View File

@ -9,28 +9,28 @@ import { DeviceTrustCryptoServiceAbstraction } from "../abstractions/device-trus
import { TokenService } from "../abstractions/token.service";
import { TwoFactorService } from "../abstractions/two-factor.service";
import { AuthResult } from "../models/domain/auth-result";
import { PasswordlessLogInCredentials } from "../models/domain/log-in-credentials";
import { AuthRequestLoginCredentials } from "../models/domain/login-credentials";
import { PasswordTokenRequest } from "../models/request/identity-token/password-token.request";
import { TokenTwoFactorRequest } from "../models/request/identity-token/token-two-factor.request";
import { IdentityTokenResponse } from "../models/response/identity-token.response";
import { LogInStrategy } from "./login.strategy";
import { LoginStrategy } from "./login.strategy";
export class PasswordlessLogInStrategy extends LogInStrategy {
export class AuthRequestLoginStrategy extends LoginStrategy {
get email() {
return this.tokenRequest.email;
}
get accessCode() {
return this.passwordlessCredentials.accessCode;
return this.authRequestCredentials.accessCode;
}
get authRequestId() {
return this.passwordlessCredentials.authRequestId;
return this.authRequestCredentials.authRequestId;
}
tokenRequest: PasswordTokenRequest;
private passwordlessCredentials: PasswordlessLogInCredentials;
private authRequestCredentials: AuthRequestLoginCredentials;
constructor(
cryptoService: CryptoService,
@ -57,8 +57,8 @@ export class PasswordlessLogInStrategy extends LogInStrategy {
);
}
override async logIn(credentials: PasswordlessLogInCredentials) {
this.passwordlessCredentials = credentials;
override async logIn(credentials: AuthRequestLoginCredentials) {
this.authRequestCredentials = credentials;
this.tokenRequest = new PasswordTokenRequest(
credentials.email,
@ -68,7 +68,7 @@ export class PasswordlessLogInStrategy extends LogInStrategy {
await this.buildDeviceRequest()
);
this.tokenRequest.setPasswordlessAccessCode(credentials.authRequestId);
this.tokenRequest.setAuthRequestAccessCode(credentials.authRequestId);
const [authResult] = await this.startLogIn();
return authResult;
}
@ -83,13 +83,11 @@ export class PasswordlessLogInStrategy extends LogInStrategy {
protected override async setMasterKey(response: IdentityTokenResponse) {
if (
this.passwordlessCredentials.decryptedMasterKey &&
this.passwordlessCredentials.decryptedMasterKeyHash
this.authRequestCredentials.decryptedMasterKey &&
this.authRequestCredentials.decryptedMasterKeyHash
) {
await this.cryptoService.setMasterKey(this.passwordlessCredentials.decryptedMasterKey);
await this.cryptoService.setMasterKeyHash(
this.passwordlessCredentials.decryptedMasterKeyHash
);
await this.cryptoService.setMasterKey(this.authRequestCredentials.decryptedMasterKey);
await this.cryptoService.setMasterKeyHash(this.authRequestCredentials.decryptedMasterKeyHash);
}
}
@ -98,8 +96,8 @@ export class PasswordlessLogInStrategy extends LogInStrategy {
// but set the master key encrypted user key if it exists regardless
await this.cryptoService.setMasterKeyEncryptedUserKey(response.key);
if (this.passwordlessCredentials.decryptedUserKey) {
await this.cryptoService.setUserKey(this.passwordlessCredentials.decryptedUserKey);
if (this.authRequestCredentials.decryptedUserKey) {
await this.cryptoService.setUserKey(this.authRequestCredentials.decryptedUserKey);
} else {
await this.trySetUserKeyWithMasterKey();
// Establish trust if required after setting user key

View File

@ -34,7 +34,7 @@ import { TwoFactorService } from "../abstractions/two-factor.service";
import { TwoFactorProviderType } from "../enums/two-factor-provider-type";
import { AuthResult } from "../models/domain/auth-result";
import { ForceResetPasswordReason } from "../models/domain/force-reset-password-reason";
import { PasswordLogInCredentials } from "../models/domain/log-in-credentials";
import { PasswordLoginCredentials } from "../models/domain/login-credentials";
import { PasswordTokenRequest } from "../models/request/identity-token/password-token.request";
import { TokenTwoFactorRequest } from "../models/request/identity-token/token-two-factor.request";
import { IdentityCaptchaResponse } from "../models/response/identity-captcha.response";
@ -43,7 +43,7 @@ import { IdentityTwoFactorResponse } from "../models/response/identity-two-facto
import { MasterPasswordPolicyResponse } from "../models/response/master-password-policy.response";
import { IUserDecryptionOptionsServerResponse } from "../models/response/user-decryption-options/user-decryption-options.response";
import { PasswordLogInStrategy } from "./password-login.strategy";
import { PasswordLoginStrategy } from "./password-login.strategy";
const email = "hello@world.com";
const masterPassword = "password";
@ -96,7 +96,7 @@ export function identityTokenResponseFactory(
}
// TODO: add tests for latest changes to base class for TDE
describe("LogInStrategy", () => {
describe("LoginStrategy", () => {
let cryptoService: MockProxy<CryptoService>;
let apiService: MockProxy<ApiService>;
let tokenService: MockProxy<TokenService>;
@ -110,8 +110,8 @@ describe("LogInStrategy", () => {
let policyService: MockProxy<PolicyService>;
let passwordStrengthService: MockProxy<PasswordStrengthServiceAbstraction>;
let passwordLogInStrategy: PasswordLogInStrategy;
let credentials: PasswordLogInCredentials;
let passwordLoginStrategy: PasswordLoginStrategy;
let credentials: PasswordLoginCredentials;
beforeEach(async () => {
cryptoService = mock<CryptoService>();
@ -130,8 +130,8 @@ describe("LogInStrategy", () => {
appIdService.getAppId.mockResolvedValue(deviceId);
tokenService.decodeToken.calledWith(accessToken).mockResolvedValue(decodedToken);
// The base class is abstract so we test it via PasswordLogInStrategy
passwordLogInStrategy = new PasswordLogInStrategy(
// The base class is abstract so we test it via PasswordLoginStrategy
passwordLoginStrategy = new PasswordLoginStrategy(
cryptoService,
apiService,
tokenService,
@ -145,7 +145,7 @@ describe("LogInStrategy", () => {
policyService,
authService
);
credentials = new PasswordLogInCredentials(email, masterPassword);
credentials = new PasswordLoginCredentials(email, masterPassword);
});
describe("base class", () => {
@ -167,7 +167,7 @@ describe("LogInStrategy", () => {
const idTokenResponse = identityTokenResponseFactory();
apiService.postIdentityToken.mockResolvedValue(idTokenResponse);
await passwordLogInStrategy.logIn(credentials);
await passwordLoginStrategy.logIn(credentials);
expect(stateService.addAccount).toHaveBeenCalledWith(
new Account({
@ -211,7 +211,7 @@ describe("LogInStrategy", () => {
accountKeys.deviceKey = deviceKey;
// Act
await passwordLogInStrategy.logIn(credentials);
await passwordLoginStrategy.logIn(credentials);
// Assert
expect(stateService.addAccount).toHaveBeenCalledWith(
@ -226,7 +226,7 @@ describe("LogInStrategy", () => {
apiService.postIdentityToken.mockResolvedValue(tokenResponse);
const result = await passwordLogInStrategy.logIn(credentials);
const result = await passwordLoginStrategy.logIn(credentials);
expect(result).toEqual({
forcePasswordReset: ForceResetPasswordReason.AdminForcePasswordReset,
@ -248,7 +248,7 @@ describe("LogInStrategy", () => {
cryptoService.getMasterKey.mockResolvedValue(masterKey);
cryptoService.decryptUserKeyWithMasterKey.mockResolvedValue(userKey);
const result = await passwordLogInStrategy.logIn(credentials);
const result = await passwordLoginStrategy.logIn(credentials);
expect(stateService.addAccount).not.toHaveBeenCalled();
expect(messagingService.send).not.toHaveBeenCalled();
@ -267,7 +267,7 @@ describe("LogInStrategy", () => {
cryptoService.getMasterKey.mockResolvedValue(masterKey);
cryptoService.decryptUserKeyWithMasterKey.mockResolvedValue(userKey);
await passwordLogInStrategy.logIn(credentials);
await passwordLoginStrategy.logIn(credentials);
// User symmetric key must be set before the new RSA keypair is generated
expect(cryptoService.setUserKey).toHaveBeenCalled();
@ -295,7 +295,7 @@ describe("LogInStrategy", () => {
apiService.postIdentityToken.mockResolvedValue(tokenResponse);
const result = await passwordLogInStrategy.logIn(credentials);
const result = await passwordLoginStrategy.logIn(credentials);
expect(stateService.addAccount).not.toHaveBeenCalled();
expect(messagingService.send).not.toHaveBeenCalled();
@ -325,7 +325,7 @@ describe("LogInStrategy", () => {
apiService.postIdentityToken.mockResolvedValue(tokenResponse);
const result = await passwordLogInStrategy.logIn(credentials);
const result = await passwordLoginStrategy.logIn(credentials);
expect(stateService.addAccount).not.toHaveBeenCalled();
expect(messagingService.send).not.toHaveBeenCalled();
@ -343,7 +343,7 @@ describe("LogInStrategy", () => {
tokenService.getTwoFactorToken.mockResolvedValue(twoFactorToken);
apiService.postIdentityToken.mockResolvedValue(identityTokenResponseFactory());
await passwordLogInStrategy.logIn(credentials);
await passwordLoginStrategy.logIn(credentials);
expect(apiService.postIdentityToken).toHaveBeenCalledWith(
expect.objectContaining({
@ -365,7 +365,7 @@ describe("LogInStrategy", () => {
twoFactorRemember
);
await passwordLogInStrategy.logIn(credentials);
await passwordLoginStrategy.logIn(credentials);
expect(apiService.postIdentityToken).toHaveBeenCalledWith(
expect.objectContaining({
@ -380,7 +380,7 @@ describe("LogInStrategy", () => {
it("sends 2FA token provided by user to server (two-step)", async () => {
// Simulate a partially completed login
passwordLogInStrategy.tokenRequest = new PasswordTokenRequest(
passwordLoginStrategy.tokenRequest = new PasswordTokenRequest(
email,
masterPasswordHash,
null,
@ -389,7 +389,7 @@ describe("LogInStrategy", () => {
apiService.postIdentityToken.mockResolvedValue(identityTokenResponseFactory());
await passwordLogInStrategy.logInTwoFactor(
await passwordLoginStrategy.logInTwoFactor(
new TokenTwoFactorRequest(twoFactorProviderType, twoFactorToken, twoFactorRemember),
null
);

View File

@ -20,11 +20,11 @@ import { TwoFactorProviderType } from "../enums/two-factor-provider-type";
import { AuthResult } from "../models/domain/auth-result";
import { ForceResetPasswordReason } from "../models/domain/force-reset-password-reason";
import {
PasswordlessLogInCredentials,
PasswordLogInCredentials,
SsoLogInCredentials,
UserApiLogInCredentials,
} from "../models/domain/log-in-credentials";
AuthRequestLoginCredentials,
PasswordLoginCredentials,
SsoLoginCredentials,
UserApiLoginCredentials,
} from "../models/domain/login-credentials";
import { DeviceRequest } from "../models/request/identity-token/device.request";
import { PasswordTokenRequest } from "../models/request/identity-token/password-token.request";
import { SsoTokenRequest } from "../models/request/identity-token/sso-token.request";
@ -36,7 +36,7 @@ import { IdentityTwoFactorResponse } from "../models/response/identity-two-facto
type IdentityResponse = IdentityTokenResponse | IdentityTwoFactorResponse | IdentityCaptchaResponse;
export abstract class LogInStrategy {
export abstract class LoginStrategy {
protected abstract tokenRequest: UserApiTokenRequest | PasswordTokenRequest | SsoTokenRequest;
protected captchaBypassToken: string = null;
@ -54,10 +54,10 @@ export abstract class LogInStrategy {
abstract logIn(
credentials:
| UserApiLogInCredentials
| PasswordLogInCredentials
| SsoLogInCredentials
| PasswordlessLogInCredentials
| UserApiLoginCredentials
| PasswordLoginCredentials
| SsoLoginCredentials
| AuthRequestLoginCredentials
): Promise<AuthResult>;
async logInTwoFactor(

View File

@ -25,13 +25,13 @@ import { TokenService } from "../abstractions/token.service";
import { TwoFactorService } from "../abstractions/two-factor.service";
import { TwoFactorProviderType } from "../enums/two-factor-provider-type";
import { ForceResetPasswordReason } from "../models/domain/force-reset-password-reason";
import { PasswordLogInCredentials } from "../models/domain/log-in-credentials";
import { PasswordLoginCredentials } from "../models/domain/login-credentials";
import { IdentityTokenResponse } from "../models/response/identity-token.response";
import { IdentityTwoFactorResponse } from "../models/response/identity-two-factor.response";
import { MasterPasswordPolicyResponse } from "../models/response/master-password-policy.response";
import { identityTokenResponseFactory } from "./login.strategy.spec";
import { PasswordLogInStrategy } from "./password-login.strategy";
import { PasswordLoginStrategy } from "./password-login.strategy";
const email = "hello@world.com";
const masterPassword = "password";
@ -48,7 +48,7 @@ const masterPasswordPolicy = new MasterPasswordPolicyResponse({
MinLength: 8,
});
describe("PasswordLogInStrategy", () => {
describe("PasswordLoginStrategy", () => {
let cryptoService: MockProxy<CryptoService>;
let apiService: MockProxy<ApiService>;
let tokenService: MockProxy<TokenService>;
@ -62,8 +62,8 @@ describe("PasswordLogInStrategy", () => {
let policyService: MockProxy<PolicyService>;
let passwordStrengthService: MockProxy<PasswordStrengthServiceAbstraction>;
let passwordLogInStrategy: PasswordLogInStrategy;
let credentials: PasswordLogInCredentials;
let passwordLoginStrategy: PasswordLoginStrategy;
let credentials: PasswordLoginCredentials;
let tokenResponse: IdentityTokenResponse;
beforeEach(async () => {
@ -94,7 +94,7 @@ describe("PasswordLogInStrategy", () => {
policyService.evaluateMasterPassword.mockReturnValue(true);
passwordLogInStrategy = new PasswordLogInStrategy(
passwordLoginStrategy = new PasswordLoginStrategy(
cryptoService,
apiService,
tokenService,
@ -108,14 +108,14 @@ describe("PasswordLogInStrategy", () => {
policyService,
authService
);
credentials = new PasswordLogInCredentials(email, masterPassword);
credentials = new PasswordLoginCredentials(email, masterPassword);
tokenResponse = identityTokenResponseFactory(masterPasswordPolicy);
apiService.postIdentityToken.mockResolvedValue(tokenResponse);
});
it("sends master password credentials to the server", async () => {
await passwordLogInStrategy.logIn(credentials);
await passwordLoginStrategy.logIn(credentials);
expect(apiService.postIdentityToken).toHaveBeenCalledWith(
expect.objectContaining({
@ -139,7 +139,7 @@ describe("PasswordLogInStrategy", () => {
cryptoService.getMasterKey.mockResolvedValue(masterKey);
cryptoService.decryptUserKeyWithMasterKey.mockResolvedValue(userKey);
await passwordLogInStrategy.logIn(credentials);
await passwordLoginStrategy.logIn(credentials);
expect(cryptoService.setMasterKey).toHaveBeenCalledWith(masterKey);
expect(cryptoService.setMasterKeyHash).toHaveBeenCalledWith(localHashedPassword);
@ -151,7 +151,7 @@ describe("PasswordLogInStrategy", () => {
it("does not force the user to update their master password when there are no requirements", async () => {
apiService.postIdentityToken.mockResolvedValueOnce(identityTokenResponseFactory());
const result = await passwordLogInStrategy.logIn(credentials);
const result = await passwordLoginStrategy.logIn(credentials);
expect(policyService.evaluateMasterPassword).not.toHaveBeenCalled();
expect(result.forcePasswordReset).toEqual(ForceResetPasswordReason.None);
@ -161,7 +161,7 @@ describe("PasswordLogInStrategy", () => {
passwordStrengthService.getPasswordStrength.mockReturnValue({ score: 5 } as any);
policyService.evaluateMasterPassword.mockReturnValue(true);
const result = await passwordLogInStrategy.logIn(credentials);
const result = await passwordLoginStrategy.logIn(credentials);
expect(policyService.evaluateMasterPassword).toHaveBeenCalled();
expect(result.forcePasswordReset).toEqual(ForceResetPasswordReason.None);
@ -171,7 +171,7 @@ describe("PasswordLogInStrategy", () => {
passwordStrengthService.getPasswordStrength.mockReturnValue({ score: 0 } as any);
policyService.evaluateMasterPassword.mockReturnValue(false);
const result = await passwordLogInStrategy.logIn(credentials);
const result = await passwordLoginStrategy.logIn(credentials);
expect(policyService.evaluateMasterPassword).toHaveBeenCalled();
expect(stateService.setForcePasswordResetReason).toHaveBeenCalledWith(
@ -194,13 +194,13 @@ describe("PasswordLogInStrategy", () => {
// First login request fails requiring 2FA
apiService.postIdentityToken.mockResolvedValueOnce(token2FAResponse);
const firstResult = await passwordLogInStrategy.logIn(credentials);
const firstResult = await passwordLoginStrategy.logIn(credentials);
// Second login request succeeds
apiService.postIdentityToken.mockResolvedValueOnce(
identityTokenResponseFactory(masterPasswordPolicy)
);
const secondResult = await passwordLogInStrategy.logInTwoFactor(
const secondResult = await passwordLoginStrategy.logInTwoFactor(
{
provider: TwoFactorProviderType.Authenticator,
token: "123456",

View File

@ -15,16 +15,16 @@ import { TokenService } from "../abstractions/token.service";
import { TwoFactorService } from "../abstractions/two-factor.service";
import { AuthResult } from "../models/domain/auth-result";
import { ForceResetPasswordReason } from "../models/domain/force-reset-password-reason";
import { PasswordLogInCredentials } from "../models/domain/log-in-credentials";
import { PasswordLoginCredentials } from "../models/domain/login-credentials";
import { PasswordTokenRequest } from "../models/request/identity-token/password-token.request";
import { TokenTwoFactorRequest } from "../models/request/identity-token/token-two-factor.request";
import { IdentityCaptchaResponse } from "../models/response/identity-captcha.response";
import { IdentityTokenResponse } from "../models/response/identity-token.response";
import { IdentityTwoFactorResponse } from "../models/response/identity-two-factor.response";
import { LogInStrategy } from "./login.strategy";
import { LoginStrategy } from "./login.strategy";
export class PasswordLogInStrategy extends LogInStrategy {
export class PasswordLoginStrategy extends LoginStrategy {
get email() {
return this.tokenRequest.email;
}
@ -91,7 +91,7 @@ export class PasswordLogInStrategy extends LogInStrategy {
return result;
}
override async logIn(credentials: PasswordLogInCredentials) {
override async logIn(credentials: PasswordLoginCredentials) {
const { email, masterPassword, captchaToken, twoFactor } = credentials;
this.masterKey = await this.authService.makePreloginKey(masterPassword, email);
@ -180,7 +180,7 @@ export class PasswordLogInStrategy extends LogInStrategy {
}
private evaluateMasterPassword(
{ masterPassword, email }: PasswordLogInCredentials,
{ masterPassword, email }: PasswordLoginCredentials,
options: MasterPasswordPolicyOptions
): boolean {
const passwordStrength = this.passwordStrengthService.getPasswordStrength(

View File

@ -21,17 +21,17 @@ import { DeviceTrustCryptoServiceAbstraction } from "../abstractions/device-trus
import { KeyConnectorService } from "../abstractions/key-connector.service";
import { TokenService } from "../abstractions/token.service";
import { TwoFactorService } from "../abstractions/two-factor.service";
import { SsoLogInCredentials } from "../models/domain/log-in-credentials";
import { SsoLoginCredentials } from "../models/domain/login-credentials";
import { IdentityTokenResponse } from "../models/response/identity-token.response";
import { IUserDecryptionOptionsServerResponse } from "../models/response/user-decryption-options/user-decryption-options.response";
import { identityTokenResponseFactory } from "./login.strategy.spec";
import { SsoLogInStrategy } from "./sso-login.strategy";
import { SsoLoginStrategy } from "./sso-login.strategy";
// TODO: Add tests for new trySetUserKeyWithApprovedAdminRequestIfExists logic
// https://bitwarden.atlassian.net/browse/PM-3339
describe("SsoLogInStrategy", () => {
describe("SsoLoginStrategy", () => {
let cryptoService: MockProxy<CryptoService>;
let apiService: MockProxy<ApiService>;
let tokenService: MockProxy<TokenService>;
@ -46,8 +46,8 @@ describe("SsoLogInStrategy", () => {
let authRequestCryptoService: MockProxy<AuthRequestCryptoServiceAbstraction>;
let i18nService: MockProxy<I18nService>;
let ssoLogInStrategy: SsoLogInStrategy;
let credentials: SsoLogInCredentials;
let ssoLoginStrategy: SsoLoginStrategy;
let credentials: SsoLoginCredentials;
const deviceId = Utils.newGuid();
const keyConnectorUrl = "KEY_CONNECTOR_URL";
@ -76,7 +76,7 @@ describe("SsoLogInStrategy", () => {
appIdService.getAppId.mockResolvedValue(deviceId);
tokenService.decodeToken.mockResolvedValue({});
ssoLogInStrategy = new SsoLogInStrategy(
ssoLoginStrategy = new SsoLoginStrategy(
cryptoService,
apiService,
tokenService,
@ -91,13 +91,13 @@ describe("SsoLogInStrategy", () => {
authRequestCryptoService,
i18nService
);
credentials = new SsoLogInCredentials(ssoCode, ssoCodeVerifier, ssoRedirectUrl, ssoOrgId);
credentials = new SsoLoginCredentials(ssoCode, ssoCodeVerifier, ssoRedirectUrl, ssoOrgId);
});
it("sends SSO information to server", async () => {
apiService.postIdentityToken.mockResolvedValue(identityTokenResponseFactory());
await ssoLogInStrategy.logIn(credentials);
await ssoLoginStrategy.logIn(credentials);
expect(apiService.postIdentityToken).toHaveBeenCalledWith(
expect.objectContaining({
@ -120,7 +120,7 @@ describe("SsoLogInStrategy", () => {
tokenResponse.key = null;
apiService.postIdentityToken.mockResolvedValue(tokenResponse);
await ssoLogInStrategy.logIn(credentials);
await ssoLoginStrategy.logIn(credentials);
expect(cryptoService.setMasterKey).not.toHaveBeenCalled();
expect(cryptoService.setUserKey).not.toHaveBeenCalled();
@ -133,7 +133,7 @@ describe("SsoLogInStrategy", () => {
apiService.postIdentityToken.mockResolvedValue(tokenResponse);
// Act
await ssoLogInStrategy.logIn(credentials);
await ssoLoginStrategy.logIn(credentials);
// Assert
expect(cryptoService.setMasterKeyEncryptedUserKey).toHaveBeenCalledTimes(1);
@ -195,7 +195,7 @@ describe("SsoLogInStrategy", () => {
const cryptoSvcSetUserKeySpy = jest.spyOn(cryptoService, "setUserKey");
// Act
await ssoLogInStrategy.logIn(credentials);
await ssoLoginStrategy.logIn(credentials);
// Assert
expect(deviceTrustCryptoService.getDeviceKey).toHaveBeenCalledTimes(1);
@ -216,7 +216,7 @@ describe("SsoLogInStrategy", () => {
deviceTrustCryptoService.decryptUserKeyWithDeviceKey.mockResolvedValue(mockUserKey);
// Act
await ssoLogInStrategy.logIn(credentials);
await ssoLoginStrategy.logIn(credentials);
// Assert
expect(cryptoService.setUserKey).not.toHaveBeenCalled();
@ -237,7 +237,7 @@ describe("SsoLogInStrategy", () => {
deviceTrustCryptoService.getDeviceKey.mockResolvedValue(mockDeviceKey);
// Act
await ssoLogInStrategy.logIn(credentials);
await ssoLoginStrategy.logIn(credentials);
// Assert
expect(cryptoService.setUserKey).not.toHaveBeenCalled();
@ -256,7 +256,7 @@ describe("SsoLogInStrategy", () => {
deviceTrustCryptoService.decryptUserKeyWithDeviceKey.mockResolvedValue(null);
// Act
await ssoLogInStrategy.logIn(credentials);
await ssoLoginStrategy.logIn(credentials);
// Assert
expect(cryptoService.setUserKey).not.toHaveBeenCalled();
@ -281,7 +281,7 @@ describe("SsoLogInStrategy", () => {
apiService.postIdentityToken.mockResolvedValue(tokenResponse);
cryptoService.getMasterKey.mockResolvedValue(masterKey);
await ssoLogInStrategy.logIn(credentials);
await ssoLoginStrategy.logIn(credentials);
expect(keyConnectorService.setMasterKeyFromUrl).toHaveBeenCalledWith(keyConnectorUrl);
});
@ -291,7 +291,7 @@ describe("SsoLogInStrategy", () => {
apiService.postIdentityToken.mockResolvedValue(tokenResponse);
await ssoLogInStrategy.logIn(credentials);
await ssoLoginStrategy.logIn(credentials);
expect(keyConnectorService.convertNewSsoUserToKeyConnector).toHaveBeenCalledWith(
tokenResponse,
@ -309,7 +309,7 @@ describe("SsoLogInStrategy", () => {
cryptoService.getMasterKey.mockResolvedValue(masterKey);
cryptoService.decryptUserKeyWithMasterKey.mockResolvedValue(userKey);
await ssoLogInStrategy.logIn(credentials);
await ssoLoginStrategy.logIn(credentials);
expect(cryptoService.decryptUserKeyWithMasterKey).toHaveBeenCalledWith(masterKey);
expect(cryptoService.setUserKey).toHaveBeenCalledWith(userKey);
@ -332,7 +332,7 @@ describe("SsoLogInStrategy", () => {
apiService.postIdentityToken.mockResolvedValue(tokenResponse);
cryptoService.getMasterKey.mockResolvedValue(masterKey);
await ssoLogInStrategy.logIn(credentials);
await ssoLoginStrategy.logIn(credentials);
expect(keyConnectorService.setMasterKeyFromUrl).toHaveBeenCalledWith(keyConnectorUrl);
});
@ -342,7 +342,7 @@ describe("SsoLogInStrategy", () => {
apiService.postIdentityToken.mockResolvedValue(tokenResponse);
await ssoLogInStrategy.logIn(credentials);
await ssoLoginStrategy.logIn(credentials);
expect(keyConnectorService.convertNewSsoUserToKeyConnector).toHaveBeenCalledWith(
tokenResponse,
@ -360,7 +360,7 @@ describe("SsoLogInStrategy", () => {
cryptoService.getMasterKey.mockResolvedValue(masterKey);
cryptoService.decryptUserKeyWithMasterKey.mockResolvedValue(userKey);
await ssoLogInStrategy.logIn(credentials);
await ssoLoginStrategy.logIn(credentials);
expect(cryptoService.decryptUserKeyWithMasterKey).toHaveBeenCalledWith(masterKey);
expect(cryptoService.setUserKey).toHaveBeenCalledWith(userKey);

View File

@ -15,13 +15,13 @@ import { KeyConnectorService } from "../abstractions/key-connector.service";
import { TokenService } from "../abstractions/token.service";
import { TwoFactorService } from "../abstractions/two-factor.service";
import { ForceResetPasswordReason } from "../models/domain/force-reset-password-reason";
import { SsoLogInCredentials } from "../models/domain/log-in-credentials";
import { SsoLoginCredentials } from "../models/domain/login-credentials";
import { SsoTokenRequest } from "../models/request/identity-token/sso-token.request";
import { IdentityTokenResponse } from "../models/response/identity-token.response";
import { LogInStrategy } from "./login.strategy";
import { LoginStrategy } from "./login.strategy";
export class SsoLogInStrategy extends LogInStrategy {
export class SsoLoginStrategy extends LoginStrategy {
tokenRequest: SsoTokenRequest;
orgId: string;
@ -59,7 +59,7 @@ export class SsoLogInStrategy extends LogInStrategy {
);
}
async logIn(credentials: SsoLogInCredentials) {
async logIn(credentials: SsoLoginCredentials) {
this.orgId = credentials.orgId;
this.tokenRequest = new SsoTokenRequest(
credentials.code,

View File

@ -18,12 +18,12 @@ import { CsprngArray } from "../../types/csprng";
import { KeyConnectorService } from "../abstractions/key-connector.service";
import { TokenService } from "../abstractions/token.service";
import { TwoFactorService } from "../abstractions/two-factor.service";
import { UserApiLogInCredentials } from "../models/domain/log-in-credentials";
import { UserApiLoginCredentials } from "../models/domain/login-credentials";
import { identityTokenResponseFactory } from "./login.strategy.spec";
import { UserApiLogInStrategy } from "./user-api-login.strategy";
import { UserApiLoginStrategy } from "./user-api-login.strategy";
describe("UserApiLogInStrategy", () => {
describe("UserApiLoginStrategy", () => {
let cryptoService: MockProxy<CryptoService>;
let apiService: MockProxy<ApiService>;
let tokenService: MockProxy<TokenService>;
@ -36,8 +36,8 @@ describe("UserApiLogInStrategy", () => {
let keyConnectorService: MockProxy<KeyConnectorService>;
let environmentService: MockProxy<EnvironmentService>;
let apiLogInStrategy: UserApiLogInStrategy;
let credentials: UserApiLogInCredentials;
let apiLogInStrategy: UserApiLoginStrategy;
let credentials: UserApiLoginCredentials;
const deviceId = Utils.newGuid();
const keyConnectorUrl = "KEY_CONNECTOR_URL";
@ -61,7 +61,7 @@ describe("UserApiLogInStrategy", () => {
tokenService.getTwoFactorToken.mockResolvedValue(null);
tokenService.decodeToken.mockResolvedValue({});
apiLogInStrategy = new UserApiLogInStrategy(
apiLogInStrategy = new UserApiLoginStrategy(
cryptoService,
apiService,
tokenService,
@ -75,7 +75,7 @@ describe("UserApiLogInStrategy", () => {
keyConnectorService
);
credentials = new UserApiLogInCredentials(apiClientId, apiClientSecret);
credentials = new UserApiLoginCredentials(apiClientId, apiClientSecret);
});
it("sends api key credentials to the server", async () => {

View File

@ -9,13 +9,13 @@ import { MessagingService } from "../../platform/abstractions/messaging.service"
import { PlatformUtilsService } from "../../platform/abstractions/platform-utils.service";
import { StateService } from "../../platform/abstractions/state.service";
import { KeyConnectorService } from "../abstractions/key-connector.service";
import { UserApiLogInCredentials } from "../models/domain/log-in-credentials";
import { UserApiLoginCredentials } from "../models/domain/login-credentials";
import { UserApiTokenRequest } from "../models/request/identity-token/user-api-token.request";
import { IdentityTokenResponse } from "../models/response/identity-token.response";
import { LogInStrategy } from "./login.strategy";
import { LoginStrategy } from "./login.strategy";
export class UserApiLogInStrategy extends LogInStrategy {
export class UserApiLoginStrategy extends LoginStrategy {
tokenRequest: UserApiTokenRequest;
constructor(
@ -44,7 +44,7 @@ export class UserApiLogInStrategy extends LogInStrategy {
);
}
override async logIn(credentials: UserApiLogInCredentials) {
override async logIn(credentials: UserApiLoginCredentials) {
this.tokenRequest = new UserApiTokenRequest(
credentials.clientId,
credentials.clientSecret,

View File

@ -2,7 +2,7 @@ import { MasterKey, UserKey } from "../../../platform/models/domain/symmetric-cr
import { AuthenticationType } from "../../enums/authentication-type";
import { TokenTwoFactorRequest } from "../request/identity-token/token-two-factor.request";
export class PasswordLogInCredentials {
export class PasswordLoginCredentials {
readonly type = AuthenticationType.Password;
constructor(
@ -13,7 +13,7 @@ export class PasswordLogInCredentials {
) {}
}
export class SsoLogInCredentials {
export class SsoLoginCredentials {
readonly type = AuthenticationType.Sso;
constructor(
@ -25,14 +25,14 @@ export class SsoLogInCredentials {
) {}
}
export class UserApiLogInCredentials {
export class UserApiLoginCredentials {
readonly type = AuthenticationType.UserApi;
constructor(public clientId: string, public clientSecret: string) {}
}
export class PasswordlessLogInCredentials {
readonly type = AuthenticationType.Passwordless;
export class AuthRequestLoginCredentials {
readonly type = AuthenticationType.AuthRequest;
constructor(
public email: string,

View File

@ -1,6 +1,6 @@
import { AuthRequestType } from "../../enums/auth-request-type";
export class PasswordlessCreateAuthRequest {
export class CreateAuthRequest {
constructor(
readonly email: string,
readonly deviceIdentifier: string,

View File

@ -3,7 +3,7 @@ import { TokenTwoFactorRequest } from "./token-two-factor.request";
export abstract class TokenRequest {
protected device?: DeviceRequest;
protected passwordlessAuthRequest: string;
protected authRequest: string;
constructor(protected twoFactor: TokenTwoFactorRequest, device?: DeviceRequest) {
this.device = device != null ? device : null;
@ -18,8 +18,8 @@ export abstract class TokenRequest {
this.twoFactor = twoFactor;
}
setPasswordlessAccessCode(accessCode: string) {
this.passwordlessAuthRequest = accessCode;
setAuthRequestAccessCode(accessCode: string) {
this.authRequest = accessCode;
}
protected toIdentityToken(clientId: string) {
@ -37,8 +37,8 @@ export abstract class TokenRequest {
}
//passswordless login
if (this.passwordlessAuthRequest) {
obj.authRequest = this.passwordlessAuthRequest;
if (this.authRequest) {
obj.authRequest = this.authRequest;
}
if (this.twoFactor) {

View File

@ -26,18 +26,18 @@ import { TokenService } from "../abstractions/token.service";
import { TwoFactorService } from "../abstractions/two-factor.service";
import { AuthenticationStatus } from "../enums/authentication-status";
import { AuthenticationType } from "../enums/authentication-type";
import { PasswordLogInStrategy } from "../login-strategies/password-login.strategy";
import { PasswordlessLogInStrategy } from "../login-strategies/passwordless-login.strategy";
import { SsoLogInStrategy } from "../login-strategies/sso-login.strategy";
import { UserApiLogInStrategy } from "../login-strategies/user-api-login.strategy";
import { AuthRequestLoginStrategy } from "../login-strategies/auth-request-login.strategy";
import { PasswordLoginStrategy } from "../login-strategies/password-login.strategy";
import { SsoLoginStrategy } from "../login-strategies/sso-login.strategy";
import { UserApiLoginStrategy } from "../login-strategies/user-api-login.strategy";
import { AuthResult } from "../models/domain/auth-result";
import { KdfConfig } from "../models/domain/kdf-config";
import {
PasswordlessLogInCredentials,
PasswordLogInCredentials,
SsoLogInCredentials,
UserApiLogInCredentials,
} from "../models/domain/log-in-credentials";
AuthRequestLoginCredentials,
PasswordLoginCredentials,
SsoLoginCredentials,
UserApiLoginCredentials,
} from "../models/domain/login-credentials";
import { TokenTwoFactorRequest } from "../models/request/identity-token/token-two-factor.request";
import { PasswordlessAuthRequest } from "../models/request/passwordless-auth.request";
import { AuthRequestResponse } from "../models/response/auth-request.response";
@ -47,9 +47,9 @@ const sessionTimeoutLength = 2 * 60 * 1000; // 2 minutes
export class AuthService implements AuthServiceAbstraction {
get email(): string {
if (
this.logInStrategy instanceof PasswordLogInStrategy ||
this.logInStrategy instanceof PasswordlessLogInStrategy ||
this.logInStrategy instanceof SsoLogInStrategy
this.logInStrategy instanceof PasswordLoginStrategy ||
this.logInStrategy instanceof AuthRequestLoginStrategy ||
this.logInStrategy instanceof SsoLoginStrategy
) {
return this.logInStrategy.email;
}
@ -58,34 +58,34 @@ export class AuthService implements AuthServiceAbstraction {
}
get masterPasswordHash(): string {
return this.logInStrategy instanceof PasswordLogInStrategy
return this.logInStrategy instanceof PasswordLoginStrategy
? this.logInStrategy.masterPasswordHash
: null;
}
get accessCode(): string {
return this.logInStrategy instanceof PasswordlessLogInStrategy
return this.logInStrategy instanceof AuthRequestLoginStrategy
? this.logInStrategy.accessCode
: null;
}
get authRequestId(): string {
return this.logInStrategy instanceof PasswordlessLogInStrategy
return this.logInStrategy instanceof AuthRequestLoginStrategy
? this.logInStrategy.authRequestId
: null;
}
get ssoEmail2FaSessionToken(): string {
return this.logInStrategy instanceof SsoLogInStrategy
return this.logInStrategy instanceof SsoLoginStrategy
? this.logInStrategy.ssoEmail2FaSessionToken
: null;
}
private logInStrategy:
| UserApiLogInStrategy
| PasswordLogInStrategy
| SsoLogInStrategy
| PasswordlessLogInStrategy;
| UserApiLoginStrategy
| PasswordLoginStrategy
| SsoLoginStrategy
| AuthRequestLoginStrategy;
private sessionTimeout: any;
private pushNotificationSubject = new Subject<string>();
@ -112,22 +112,22 @@ export class AuthService implements AuthServiceAbstraction {
async logIn(
credentials:
| UserApiLogInCredentials
| PasswordLogInCredentials
| SsoLogInCredentials
| PasswordlessLogInCredentials
| UserApiLoginCredentials
| PasswordLoginCredentials
| SsoLoginCredentials
| AuthRequestLoginCredentials
): Promise<AuthResult> {
this.clearState();
let strategy:
| UserApiLogInStrategy
| PasswordLogInStrategy
| SsoLogInStrategy
| PasswordlessLogInStrategy;
| UserApiLoginStrategy
| PasswordLoginStrategy
| SsoLoginStrategy
| AuthRequestLoginStrategy;
switch (credentials.type) {
case AuthenticationType.Password:
strategy = new PasswordLogInStrategy(
strategy = new PasswordLoginStrategy(
this.cryptoService,
this.apiService,
this.tokenService,
@ -143,7 +143,7 @@ export class AuthService implements AuthServiceAbstraction {
);
break;
case AuthenticationType.Sso:
strategy = new SsoLogInStrategy(
strategy = new SsoLoginStrategy(
this.cryptoService,
this.apiService,
this.tokenService,
@ -160,7 +160,7 @@ export class AuthService implements AuthServiceAbstraction {
);
break;
case AuthenticationType.UserApi:
strategy = new UserApiLogInStrategy(
strategy = new UserApiLoginStrategy(
this.cryptoService,
this.apiService,
this.tokenService,
@ -174,8 +174,8 @@ export class AuthService implements AuthServiceAbstraction {
this.keyConnectorService
);
break;
case AuthenticationType.Passwordless:
strategy = new PasswordlessLogInStrategy(
case AuthenticationType.AuthRequest:
strategy = new AuthRequestLoginStrategy(
this.cryptoService,
this.apiService,
this.tokenService,
@ -229,19 +229,19 @@ export class AuthService implements AuthServiceAbstraction {
}
authingWithUserApiKey(): boolean {
return this.logInStrategy instanceof UserApiLogInStrategy;
return this.logInStrategy instanceof UserApiLoginStrategy;
}
authingWithSso(): boolean {
return this.logInStrategy instanceof SsoLogInStrategy;
return this.logInStrategy instanceof SsoLoginStrategy;
}
authingWithPassword(): boolean {
return this.logInStrategy instanceof PasswordLogInStrategy;
return this.logInStrategy instanceof PasswordLoginStrategy;
}
authingWithPasswordless(): boolean {
return this.logInStrategy instanceof PasswordlessLogInStrategy;
return this.logInStrategy instanceof AuthRequestLoginStrategy;
}
async getAuthStatus(userId?: string): Promise<AuthenticationStatus> {
@ -349,10 +349,10 @@ export class AuthService implements AuthServiceAbstraction {
private saveState(
strategy:
| UserApiLogInStrategy
| PasswordLogInStrategy
| SsoLogInStrategy
| PasswordlessLogInStrategy
| UserApiLoginStrategy
| PasswordLoginStrategy
| SsoLoginStrategy
| AuthRequestLoginStrategy
) {
this.logInStrategy = strategy;
this.startSessionTimeout();

View File

@ -34,6 +34,7 @@ import {
import { ProviderResponse } from "../admin-console/models/response/provider/provider.response";
import { SelectionReadOnlyResponse } from "../admin-console/models/response/selection-read-only.response";
import { TokenService } from "../auth/abstractions/token.service";
import { CreateAuthRequest } from "../auth/models/request/create-auth.request";
import { DeviceVerificationRequest } from "../auth/models/request/device-verification.request";
import { EmailTokenRequest } from "../auth/models/request/email-token.request";
import { EmailRequest } from "../auth/models/request/email.request";
@ -51,7 +52,6 @@ import { KeyConnectorUserKeyRequest } from "../auth/models/request/key-connector
import { PasswordHintRequest } from "../auth/models/request/password-hint.request";
import { PasswordRequest } from "../auth/models/request/password.request";
import { PasswordlessAuthRequest } from "../auth/models/request/passwordless-auth.request";
import { PasswordlessCreateAuthRequest } from "../auth/models/request/passwordless-create-auth.request";
import { SecretVerificationRequest } from "../auth/models/request/secret-verification.request";
import { SetKeyConnectorKeyRequest } from "../auth/models/request/set-key-connector-key.request";
import { SetPasswordRequest } from "../auth/models/request/set-password.request";
@ -252,11 +252,11 @@ export class ApiService implements ApiServiceAbstraction {
}
// TODO: PM-3519: Create and move to AuthRequest Api service
async postAuthRequest(request: PasswordlessCreateAuthRequest): Promise<AuthRequestResponse> {
async postAuthRequest(request: CreateAuthRequest): Promise<AuthRequestResponse> {
const r = await this.send("POST", "/auth-requests/", request, false, true);
return new AuthRequestResponse(r);
}
async postAdminAuthRequest(request: PasswordlessCreateAuthRequest): Promise<AuthRequestResponse> {
async postAdminAuthRequest(request: CreateAuthRequest): Promise<AuthRequestResponse> {
const r = await this.send("POST", "/auth-requests/admin-request", request, true, true);
return new AuthRequestResponse(r);
}