diff --git a/apps/web/src/app/auth/core/services/webauthn/response/webauthn-credential.response.ts b/apps/web/src/app/auth/core/services/webauthn/response/webauthn-credential.response.ts new file mode 100644 index 0000000000..32459d5e2d --- /dev/null +++ b/apps/web/src/app/auth/core/services/webauthn/response/webauthn-credential.response.ts @@ -0,0 +1,14 @@ +import { BaseResponse } from "@bitwarden/common/models/response/base.response"; + +export class WebauthnCredentialResponse extends BaseResponse { + id: string; + name: string; + prf: "active" | "inactive" | "unsupported"; + + constructor(response: unknown) { + super(response); + this.id = this.getResponseProperty("id"); + this.name = this.getResponseProperty("name"); + this.prf = this.getResponseProperty("prf"); + } +} diff --git a/apps/web/src/app/auth/core/services/webauthn/webauthn-api.service.ts b/apps/web/src/app/auth/core/services/webauthn/webauthn-api.service.ts index 11fec06962..c525eda725 100644 --- a/apps/web/src/app/auth/core/services/webauthn/webauthn-api.service.ts +++ b/apps/web/src/app/auth/core/services/webauthn/webauthn-api.service.ts @@ -2,12 +2,14 @@ import { Injectable } from "@angular/core"; import { ApiService } from "@bitwarden/common/abstractions/api.service"; import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification/userVerification.service.abstraction"; +import { ListResponse } from "@bitwarden/common/models/response/list.response"; import { Verification } from "@bitwarden/common/types/verification"; import { CoreAuthModule } from "../../core.module"; import { SaveCredentialRequest } from "./request/save-credential.request"; import { CredentialCreateOptionsResponse } from "./response/credential-create-options.response"; +import { WebauthnCredentialResponse } from "./response/webauthn-credential.response"; @Injectable({ providedIn: CoreAuthModule }) export class WebauthnApiService { @@ -28,4 +30,8 @@ export class WebauthnApiService { await this.apiService.send("POST", "/webauthn", request, true, true); return true; } + + getCredentials(): Promise> { + return this.apiService.send("GET", "/webauthn", null, true, true); + } } diff --git a/apps/web/src/app/auth/core/services/webauthn/webauthn.service.ts b/apps/web/src/app/auth/core/services/webauthn/webauthn.service.ts index 3474af231c..717cd8cdc9 100644 --- a/apps/web/src/app/auth/core/services/webauthn/webauthn.service.ts +++ b/apps/web/src/app/auth/core/services/webauthn/webauthn.service.ts @@ -1,4 +1,5 @@ import { Injectable, Optional } from "@angular/core"; +import { from, map, Observable } from "rxjs"; import { I18nService } from "@bitwarden/common/abstractions/i18n.service"; import { LogService } from "@bitwarden/common/abstractions/log.service"; @@ -8,6 +9,7 @@ import { Verification } from "@bitwarden/common/types/verification"; import { CoreAuthModule } from "../../core.module"; import { CredentialCreateOptionsView } from "../../views/credential-create-options.view"; +import { WebauthnCredentialView } from "../../views/webauth-credential.view"; import { SaveCredentialRequest } from "./request/save-credential.request"; import { WebauthnAttestationResponseRequest } from "./request/webauthn-attestation-response.request"; @@ -86,4 +88,8 @@ export class WebauthnService { return false; } } + + getCredentials$(): Observable { + return from(this.apiService.getCredentials()).pipe(map((response) => response.data)); + } } diff --git a/apps/web/src/app/auth/core/views/webauth-credential.view.ts b/apps/web/src/app/auth/core/views/webauth-credential.view.ts new file mode 100644 index 0000000000..c89546070f --- /dev/null +++ b/apps/web/src/app/auth/core/views/webauth-credential.view.ts @@ -0,0 +1,5 @@ +export class WebauthnCredentialView { + id: string; + name: string; + prf: "active" | "inactive" | "unsupported"; +} diff --git a/apps/web/src/app/auth/settings/fido2-login-settings/fido2-login-settings.component.html b/apps/web/src/app/auth/settings/fido2-login-settings/fido2-login-settings.component.html index 1dbcdcab2e..07dc7c12c6 100644 --- a/apps/web/src/app/auth/settings/fido2-login-settings/fido2-login-settings.component.html +++ b/apps/web/src/app/auth/settings/fido2-login-settings/fido2-login-settings.component.html @@ -6,6 +6,10 @@ {{ "learnMoreAboutPasswordless" | i18n }}

+ +