From ec304f8bd1ffef69a85b75da033fbccbe6bfc72f Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Thu, 5 Feb 2026 09:34:30 -0800 Subject: fix ark payment notifications --- src/components/Account.svelte | 28 ++++++++-- src/components/WalletPass.svelte | 33 +++++++++++- src/lib/passwordCache.ts | 61 ++++++++++++++++++++++ src/routes/(app)/+layout.svelte | 28 ++++++++-- src/routes/(app)/account/[id]/+page.svelte | 38 ++++++++++++-- src/routes/(app)/account/ark/+page.svelte | 28 ++++++++++ src/routes/(app)/account/pass/+page.svelte | 28 ++++++++++ src/routes/(app)/invoice/[id]/tip/+page.svelte | 8 +-- .../[address]/[amount]/[...feeRate]/+page.svelte | 28 +++++++++- 9 files changed, 259 insertions(+), 21 deletions(-) create mode 100644 src/lib/passwordCache.ts diff --git a/src/components/Account.svelte b/src/components/Account.svelte index 04ff97ae..aaef428b 100644 --- a/src/components/Account.svelte +++ b/src/components/Account.svelte @@ -6,6 +6,10 @@ import { goto } from "$app/navigation"; import Balance from "$comp/Balance.svelte"; import { t } from "$lib/translations"; import { arkkey } from "$lib/ark"; + import { + getRememberedWalletPassword, + forgetWalletPassword, + } from "$lib/passwordCache"; let { user, rate, account } = $props(); let { @@ -27,14 +31,32 @@ pendingUrl = undefined; }); - let setAccount = (event, url) => { + let tryUnlockArk = async () => { + const cached = getRememberedWalletPassword(); + if (!cached) return false; + try { + const { decrypt } = await import("nostr-tools/nip49"); + $arkkey = hex.encode(decrypt(seed, cached)); + return true; + } catch (e) { + forgetWalletPassword(); + return false; + } + }; + + let setAccount = async (event, url) => { event.preventDefault(); event.stopPropagation(); document.cookie = `aid=${id}; path=/; max-age=86400`; if (isArk) { pendingUrl = url; - if ($arkkey) goto(pendingUrl); - else passwordPrompt = true; + if ($arkkey) { + goto(pendingUrl); + } else if (await tryUnlockArk()) { + goto(pendingUrl); + } else { + passwordPrompt = true; + } } else { $arkkey = undefined; goto(url); diff --git a/src/components/WalletPass.svelte b/src/components/WalletPass.svelte index e3291f61..e0dcf961 100644 --- a/src/components/WalletPass.svelte +++ b/src/components/WalletPass.svelte @@ -3,8 +3,24 @@ import { focus } from "$lib/utils"; import { t } from "$lib/translations"; + import { + rememberForOptions, + defaultRememberForMs, + rememberWalletPassword, + forgetWalletPassword, + } from "$lib/passwordCache"; let { cancel, password = $bindable(), submit } = $props(); let revealPassword = $state(); + let rememberForMs = $state(defaultRememberForMs); + + let handleSubmit = async () => { + if (rememberForMs) { + rememberWalletPassword(password, rememberForMs); + } else { + forgetWalletPassword(); + } + await submit(); + };
{$t("payments.enterWalletPass")} -
+
{#if revealPassword}
+
+ + +
{:else if seed} - +
+ + +
+