diff options
| author | Adam Soltys <[email protected]> | 2026-02-05 09:34:30 -0800 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-02-11 15:34:32 -0800 |
| commit | ec304f8bd1ffef69a85b75da033fbccbe6bfc72f (patch) | |
| tree | 664e765f3d7e9c4f26463760ed155dabca76486b /src/components | |
| parent | 59fbd17aad12acfa19eb730c4ede67d50962ba9b (diff) | |
| download | coinos-ui-ec304f8bd1ffef69a85b75da033fbccbe6bfc72f.tar.gz coinos-ui-ec304f8bd1ffef69a85b75da033fbccbe6bfc72f.zip | |
fix ark payment notifications
Diffstat (limited to 'src/components')
| -rw-r--r-- | src/components/Account.svelte | 28 | ||||
| -rw-r--r-- | src/components/WalletPass.svelte | 33 |
2 files changed, 57 insertions, 4 deletions
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(); + }; </script> <div @@ -16,7 +32,7 @@ <h1 class="text-center text-2xl font-semibold"> {$t("payments.enterWalletPass")} </h1> - <form onsubmit={preventDefault(submit)}> + <form onsubmit={preventDefault(handleSubmit)}> <div class="relative mb-5"> {#if revealPassword} <input @@ -49,6 +65,21 @@ ></iconify-icon> </button> </div> + <div class="mb-5 space-y-2"> + <label for="rememberFor" class="text-sm text-gray-500"> + Remember for + </label> + <select + id="rememberFor" + class="w-full" + value={rememberForMs} + onchange={(e) => (rememberForMs = Number(e.target.value))} + > + {#each rememberForOptions as option} + <option value={option.ms}>{option.label}</option> + {/each} + </select> + </div> <div class="w-full flex justify-center gap-2"> <button type="button" |
