1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-04-09 19:17:09 +02:00

[PM-2014] chore: rename everything to WebauthnLogin to follow new naming scheme

This commit is contained in:
Andreas Coroiu 2023-09-27 10:32:08 +02:00
parent 0518470303
commit 32ba34eafe
No known key found for this signature in database
GPG Key ID: E70B5FFC81DFEC1A
16 changed files with 43 additions and 40 deletions

View File

@ -1,10 +1,10 @@
import { NgModule, Optional, SkipSelf } from "@angular/core";
import { WebauthnApiService } from "./services/webauthn/webauthn-api.service";
import { WebauthnService } from "./services/webauthn/webauthn.service";
import { WebauthnLoginApiService } from "./services/webauthn-login/webauthn-login-api.service";
import { WebauthnLoginService } from "./services/webauthn-login/webauthn-login.service";
@NgModule({
providers: [WebauthnService, WebauthnApiService],
providers: [WebauthnLoginService, WebauthnLoginApiService],
})
export class CoreAuthModule {
constructor(@Optional() @SkipSelf() parentModule?: CoreAuthModule) {

View File

@ -1 +1 @@
export * from "./webauthn";
export * from "./webauthn-login";

View File

@ -0,0 +1 @@
export * from "./webauthn-login.service";

View File

@ -0,0 +1,7 @@
import { WebauthnLoginResponseRequest } from "./webauthn-login-response.request";
export class SaveCredentialRequest {
deviceResponse: WebauthnLoginResponseRequest;
name: string;
token: string;
}

View File

@ -1,8 +1,8 @@
import { Utils } from "@bitwarden/common/platform/misc/utils";
import { WebauthnResponseRequest } from "./webauthn-response.request";
import { WebauthnLoginResponseRequest } from "./webauthn-login-response.request";
export class WebauthnAttestationResponseRequest extends WebauthnResponseRequest {
export class WebauthnLoginAttestationResponseRequest extends WebauthnLoginResponseRequest {
response: {
attestationObject: string;
clientDataJson: string;

View File

@ -1,6 +1,6 @@
import { Utils } from "@bitwarden/common/platform/misc/utils";
export abstract class WebauthnResponseRequest {
export abstract class WebauthnLoginResponseRequest {
id: string;
rawId: string;
type: string;

View File

@ -1,7 +1,7 @@
import { ChallengeResponse } from "@bitwarden/common/auth/models/response/two-factor-web-authn.response";
import { BaseResponse } from "@bitwarden/common/models/response/base.response";
export class CredentialCreateOptionsResponse extends BaseResponse {
export class WebauthnLoginCredentialCreateOptionsResponse extends BaseResponse {
options: ChallengeResponse;
token: string;

View File

@ -1,6 +1,6 @@
import { BaseResponse } from "@bitwarden/common/models/response/base.response";
export class WebauthnCredentialResponse extends BaseResponse {
export class WebauthnLoginCredentialResponse extends BaseResponse {
id: string;
name: string;
prfSupport: boolean;

View File

@ -6,11 +6,11 @@ import { ListResponse } from "@bitwarden/common/models/response/list.response";
import { Verification } from "@bitwarden/common/types/verification";
import { SaveCredentialRequest } from "./request/save-credential.request";
import { CredentialCreateOptionsResponse } from "./response/credential-create-options.response";
import { WebauthnCredentialResponse } from "./response/webauthn-credential.response";
import { WebauthnLoginCredentialCreateOptionsResponse } from "./response/webauthn-login-credential-create-options.response";
import { WebauthnLoginCredentialResponse } from "./response/webauthn-login-credential.response";
@Injectable()
export class WebauthnApiService {
export class WebauthnLoginApiService {
constructor(
private apiService: ApiService,
private userVerificationService: UserVerificationService
@ -18,10 +18,10 @@ export class WebauthnApiService {
async getCredentialCreateOptions(
verification: Verification
): Promise<CredentialCreateOptionsResponse> {
): Promise<WebauthnLoginCredentialCreateOptionsResponse> {
const request = await this.userVerificationService.buildRequest(verification);
const response = await this.apiService.send("POST", "/webauthn/options", request, true, true);
return new CredentialCreateOptionsResponse(response);
return new WebauthnLoginCredentialCreateOptionsResponse(response);
}
async saveCredential(request: SaveCredentialRequest): Promise<boolean> {
@ -29,7 +29,7 @@ export class WebauthnApiService {
return true;
}
getCredentials(): Promise<ListResponse<WebauthnCredentialResponse>> {
getCredentials(): Promise<ListResponse<WebauthnLoginCredentialResponse>> {
return this.apiService.send("GET", "/webauthn", null, true, true);
}

View File

@ -2,21 +2,21 @@ import { mock, MockProxy } from "jest-mock-extended";
import { CredentialCreateOptionsView } from "../../views/credential-create-options.view";
import { WebauthnApiService } from "./webauthn-api.service";
import { WebauthnService } from "./webauthn.service";
import { WebauthnLoginApiService } from "./webauthn-login-api.service";
import { WebauthnLoginService } from "./webauthn-login.service";
describe("WebauthnService", () => {
let apiService!: MockProxy<WebauthnApiService>;
let apiService!: MockProxy<WebauthnLoginApiService>;
let credentials: MockProxy<CredentialsContainer>;
let webauthnService!: WebauthnService;
let webauthnService!: WebauthnLoginService;
beforeAll(() => {
// Polyfill missing class
window.PublicKeyCredential = class {} as any;
window.AuthenticatorAttestationResponse = class {} as any;
apiService = mock<WebauthnApiService>();
apiService = mock<WebauthnLoginApiService>();
credentials = mock<CredentialsContainer>();
webauthnService = new WebauthnService(apiService, credentials);
webauthnService = new WebauthnLoginService(apiService, credentials);
});
describe("createCredential", () => {

View File

@ -8,11 +8,11 @@ import { CredentialCreateOptionsView } from "../../views/credential-create-optio
import { WebauthnCredentialView } from "../../views/webauth-credential.view";
import { SaveCredentialRequest } from "./request/save-credential.request";
import { WebauthnAttestationResponseRequest } from "./request/webauthn-attestation-response.request";
import { WebauthnApiService } from "./webauthn-api.service";
import { WebauthnLoginAttestationResponseRequest } from "./request/webauthn-login-attestation-response.request";
import { WebauthnLoginApiService } from "./webauthn-login-api.service";
@Injectable()
export class WebauthnService {
export class WebauthnLoginService {
private navigatorCredentials: CredentialsContainer;
private _refresh$ = new BehaviorSubject<void>(undefined);
private _loading$ = new BehaviorSubject<boolean>(true);
@ -26,7 +26,7 @@ export class WebauthnService {
readonly loading$ = this._loading$.asObservable();
constructor(
private apiService: WebauthnApiService,
private apiService: WebauthnLoginApiService,
@Optional() navigatorCredentials?: CredentialsContainer,
@Optional() private logService?: LogService
) {
@ -66,7 +66,7 @@ export class WebauthnService {
name: string
) {
const request = new SaveCredentialRequest();
request.deviceResponse = new WebauthnAttestationResponseRequest(deviceResponse);
request.deviceResponse = new WebauthnLoginAttestationResponseRequest(deviceResponse);
request.token = credentialOptions.token;
request.name = name;
await this.apiService.saveCredential(request);

View File

@ -1 +0,0 @@
export * from "./webauthn.service";

View File

@ -1,7 +0,0 @@
import { WebauthnResponseRequest } from "./webauthn-response.request";
export class SaveCredentialRequest {
deviceResponse: WebauthnResponseRequest;
name: string;
token: string;
}

View File

@ -10,7 +10,7 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service"
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { DialogService } from "@bitwarden/components";
import { WebauthnService } from "../../../core";
import { WebauthnLoginService } from "../../../core";
import { CredentialCreateOptionsView } from "../../../core/views/credential-create-options.view";
import { CreatePasskeyFailedIcon } from "./create-passkey-failed.icon";
@ -50,7 +50,7 @@ export class CreateCredentialDialogComponent implements OnInit {
constructor(
private formBuilder: FormBuilder,
private dialogRef: DialogRef,
private webauthnService: WebauthnService,
private webauthnService: WebauthnLoginService,
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private logService: LogService

View File

@ -10,7 +10,7 @@ import { LogService } from "@bitwarden/common/platform/abstractions/log.service"
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { DialogService } from "@bitwarden/components";
import { WebauthnService } from "../../../core";
import { WebauthnLoginService } from "../../../core";
import { WebauthnCredentialView } from "../../../core/views/webauth-credential.view";
export interface DeleteCredentialDialogParams {
@ -32,7 +32,7 @@ export class DeleteCredentialDialogComponent implements OnInit, OnDestroy {
@Inject(DIALOG_DATA) private params: DeleteCredentialDialogParams,
private formBuilder: FormBuilder,
private dialogRef: DialogRef,
private webauthnService: WebauthnService,
private webauthnService: WebauthnLoginService,
private platformUtilsService: PlatformUtilsService,
private i18nService: I18nService,
private logService: LogService

View File

@ -3,7 +3,7 @@ import { Subject, takeUntil } from "rxjs";
import { DialogService } from "@bitwarden/components";
import { WebauthnService } from "../../core";
import { WebauthnLoginService } from "../../core";
import { WebauthnCredentialView } from "../../core/views/webauth-credential.view";
import { openCreateCredentialDialog } from "./create-credential-dialog/create-credential-dialog.component";
@ -24,7 +24,10 @@ export class WebauthnLoginSettingsComponent implements OnInit, OnDestroy {
protected credentials?: WebauthnCredentialView[];
protected loading = true;
constructor(private webauthnService: WebauthnService, private dialogService: DialogService) {}
constructor(
private webauthnService: WebauthnLoginService,
private dialogService: DialogService
) {}
@HostBinding("attr.aria-busy")
get ariaBusy() {