1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 15:53:27 +00:00
Files
browser/apps/web/src/app/auth/settings/webauthn-login-settings/webauthn-login-settings.component.ts
Andreas Coroiu 65d2d74348 [PM-2241] Add PRF attestation flow during passkey registration (#6525)
* [PM-2241] chore: refactor into new "pending" view type

* [PM-2241] feat: record PRF support

* [PM-2241] feat: add prf checkbox to dialog

* [PM-2241] chore: remove `disableMargin` instead

Will expressed his concern that these things aren't sustainable, and that we should try using `!important` statements instead, which is a good point!

* [PM-2241] feat: add prf registration

* [PM-2241] feat: add support for `prfStatus`

* [PM-2241] feat: add rotateable key set

* [PM-2241] feat: add PRF creation error handling

* [PM-2241] chore: improve rotateable key docs

* [PM-2241] feat: add basic test

* [PM-2241] chore: update `SaveCredentialRequest` docs

* [PM-2241] chore: rename to `WebauthnLoginAdminService`

* [PM-2241] fix: typo in `save-credential.request.ts`

* [PM-2241] fix: typo in more places
2023-11-08 14:35:36 +01:00

75 lines
2.3 KiB
TypeScript

import { Component, HostBinding, OnDestroy, OnInit } from "@angular/core";
import { Subject, takeUntil } from "rxjs";
import { DialogService } from "@bitwarden/components";
import { WebauthnLoginAdminService } from "../../core";
import { WebauthnLoginCredentialPrfStatus } from "../../core/enums/webauthn-login-credential-prf-status.enum";
import { WebauthnLoginCredentialView } from "../../core/views/webauthn-login-credential.view";
import { openCreateCredentialDialog } from "./create-credential-dialog/create-credential-dialog.component";
import { openDeleteCredentialDialogComponent } from "./delete-credential-dialog/delete-credential-dialog.component";
@Component({
selector: "app-webauthn-login-settings",
templateUrl: "webauthn-login-settings.component.html",
host: {
"aria-live": "polite",
},
})
export class WebauthnLoginSettingsComponent implements OnInit, OnDestroy {
private destroy$ = new Subject<void>();
protected readonly MaxCredentialCount = WebauthnLoginAdminService.MaxCredentialCount;
protected readonly WebauthnLoginCredentialPrfStatus = WebauthnLoginCredentialPrfStatus;
protected credentials?: WebauthnLoginCredentialView[];
protected loading = true;
constructor(
private webauthnService: WebauthnLoginAdminService,
private dialogService: DialogService
) {}
@HostBinding("attr.aria-busy")
get ariaBusy() {
return this.loading ? "true" : "false";
}
get hasCredentials() {
return this.credentials && this.credentials.length > 0;
}
get hasData() {
return this.credentials !== undefined;
}
get limitReached() {
return this.credentials?.length >= this.MaxCredentialCount;
}
ngOnInit(): void {
this.webauthnService
.getCredentials$()
.pipe(takeUntil(this.destroy$))
.subscribe((credentials) => (this.credentials = credentials));
this.webauthnService.loading$
.pipe(takeUntil(this.destroy$))
.subscribe((loading) => (this.loading = loading));
}
ngOnDestroy(): void {
this.destroy$.next();
this.destroy$.complete();
}
protected createCredential() {
openCreateCredentialDialog(this.dialogService, {});
}
protected deleteCredential(credentialId: string) {
openDeleteCredentialDialogComponent(this.dialogService, { data: { credentialId } });
}
}