1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-10 21:50:15 +00:00

halfbaked

This commit is contained in:
Anders Åberg
2025-01-23 21:10:49 +01:00
parent 8d2fd7247e
commit 137bc8ace8
2 changed files with 59 additions and 1 deletions

View File

@@ -1,6 +1,11 @@
import { Component } from "@angular/core";
import { Router } from "@angular/router";
import {
Fido2UserInterfaceService as Fido2UserInterfaceServiceAbstraction
} from "@bitwarden/common/platform/abstractions/fido2/fido2-user-interface.service.abstraction";
import { DesktopFido2UserInterfaceService } from "../../autofill/services/desktop-fido2-user-interface.service";
import { DesktopSettingsService } from "../../platform/services/desktop-settings.service";
@Component({
@@ -11,6 +16,15 @@ import { DesktopSettingsService } from "../../platform/services/desktop-settings
>
<h1 style="color: black">Select your passkey</h1>
<br />
<button
style="color:black; padding: 10px 20px; border: 1px solid black; margin: 10px"
bitButton
type="button"
buttonType="secondary"
(click)="confirmPasskey()"
>
Confirm passkey
</button>
<button
style="color:black; padding: 10px 20px; border: 1px solid black; margin: 10px"
bitButton
@@ -26,9 +40,38 @@ import { DesktopSettingsService } from "../../platform/services/desktop-settings
export class Fido2PlaceholderComponent {
constructor(
private readonly desktopSettingsService: DesktopSettingsService,
private readonly fido2UserInterfaceService: Fido2UserInterfaceServiceAbstraction<void>,
private readonly router: Router,
) {}
async confirmPasskey() {
// placeholder, actual api arguments needed here should be discussed
// just show casing we can call into the session to create the credential or change it.
console.log("checking for session", this.fido2UserInterfaceService);
const desktopService = this.fido2UserInterfaceService as DesktopFido2UserInterfaceService;
const session = await desktopService.getCurrentSession();
console.log("Got session", session);
await session.createCredential({
userHandle: "userHandle",
userName: "",
credentialName: "",
rpId: "",
userVerification: true,
});
console.log("Created credential, will notify complete");
session.notifyOperationCompleted();
await this.router.navigate(["/"]);
await this.desktopSettingsService.setInModalMode(false);
}
async closeModal() {
await this.router.navigate(["/"]);
await this.desktopSettingsService.setInModalMode(false);

View File

@@ -1,4 +1,4 @@
import { firstValueFrom, map } from "rxjs";
import { filter, firstValueFrom, map, shareReplay, Subject } from "rxjs";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { AuthService } from "@bitwarden/common/auth/abstractions/auth.service";
@@ -31,6 +31,21 @@ export class DesktopFido2UserInterfaceService
private messagingService: MessagingService,
) {}
private currentSessionSubject = new Subject<DesktopFido2UserInterfaceSession | undefined>();
private currentSubject$ = this.currentSessionSubject.pipe(
shareReplay({ refCount: true, bufferSize: 1 }),
filter(c => c !== undefined)
);
setCurrentSession(session: DesktopFido2UserInterfaceSession) {
this.currentSessionSubject.next(session);
}
getCurrentSession(): Promise<DesktopFido2UserInterfaceSession> {
return firstValueFrom(this.currentSubject$);
}
async newSession(
fallbackSupported: boolean,
_tab: void,