diff options
| author | Adam Soltys <[email protected]> | 2026-02-27 10:09:16 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-02-27 10:09:16 -0800 |
| commit | bf7d8d373c11cd7a6e1487175147c9a84e775a98 (patch) | |
| tree | 82fb58568de073ff03dfca3d55d8ce5adcf51608 /src/routes/(app)/settings/security | |
| parent | 2aa2ac29eb241fc8ded3671e728e578e72652056 (diff) | |
| download | coinos-ui-bf7d8d373c11cd7a6e1487175147c9a84e775a98.tar.gz coinos-ui-bf7d8d373c11cd7a6e1487175147c9a84e775a98.zip | |
map updates
Diffstat (limited to 'src/routes/(app)/settings/security')
| -rw-r--r-- | src/routes/(app)/settings/security/+page.svelte | 35 |
1 files changed, 29 insertions, 6 deletions
diff --git a/src/routes/(app)/settings/security/+page.svelte b/src/routes/(app)/settings/security/+page.svelte index 33981645..0991c679 100644 --- a/src/routes/(app)/settings/security/+page.svelte +++ b/src/routes/(app)/settings/security/+page.svelte @@ -4,9 +4,12 @@ import { t } from "$lib/translations"; import Pin from "$comp/Pin.svelte"; import Qr from "$comp/Qr.svelte"; + import Spinner from "$comp/Spinner.svelte"; import { copy, post, success, fail } from "$lib/utils"; import { save, pin as current } from "$lib/store"; import { getNsec } from "$lib/nostr"; + import { registerPasskey } from "$lib/passkey"; + import { rememberPrfKey, defaultRememberForMs } from "$lib/passwordCache"; import { invalidate } from "$app/navigation"; import { page } from "$app/stores"; @@ -147,6 +150,22 @@ fail("Failed to disable 2FA, try again"); } }; + let passkeyLoading = $state(false); + + let addPasskey = async () => { + passkeyLoading = true; + try { + const prfKey = await registerPasskey(); + rememberPrfKey(prfKey, defaultRememberForMs); + success("Passkey added"); + } catch (e: any) { + if (e.name !== "NotAllowedError") { + fail(e.message || "Passkey registration failed"); + } + } + passkeyLoading = false; + }; + let verifying = $derived(pin?.length > 5); $effect(() => { @@ -220,10 +239,14 @@ </div> <div> - <a href={`/account/seed`} class="contents"> - <button class="btn btn-lg w-full rounded-2xl whitespace-nowrap"> - <iconify-icon noobserver icon="ph:plus-circle-bold" width="32"></iconify-icon> - {$t("accounts.addAccount")} - </button> - </a> + <span class="font-bold mb-1">Passkey</span> + <p class="text-secondary mb-1">Add a passkey for passwordless sign-in</p> + <button type="button" class="btn" onclick={addPasskey} disabled={passkeyLoading}> + {#if passkeyLoading} + <Spinner /> + {:else} + <iconify-icon noobserver icon="ph:fingerprint-bold" width="32"></iconify-icon> + {/if} + Add Passkey + </button> </div> |
