aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-10-13 16:23:39 -0700
committerAdam Soltys <[email protected]>2026-10-13 16:23:39 -0700
commit558a7c5a08cb172dbe229675a6b330611000d3fc (patch)
tree417137684074004e4334e78be9d682d61c1d4797 /src/lib
parente9ae62fe22c104e9403dfba299d6ac6a3210b757 (diff)
downloadcoinos-ui-master.tar.gz
coinos-ui-master.zip
nostr: fetch the encrypted key with the password when there's no session keyHEADmaster
Without the sk cookie from a password login (nostr logins, older sessions) the reveal button was hidden and signing failed. Ask for the password and get the key from /nsec instead. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UjHzoBmW1iPpEe5qC2LDYB
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/nostr.ts7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/lib/nostr.ts b/src/lib/nostr.ts
index 69e21286..2e993f9d 100644
--- a/src/lib/nostr.ts
+++ b/src/lib/nostr.ts
@@ -75,8 +75,13 @@ export const getPrivateKey = async (user: User): Promise<Uint8Array> => {
// /me no longer returns the encrypted key; /login decrypts it into the
// sk cookie instead. user.nsec is only present on a fresh login response.
+ // Sessions without either (nostr or older logins) fetch it with the
+ // password.
const sk = browser && cookies.get("sk");
- const { nsec } = user;
+ let { nsec } = user;
+
+ if (!sk && !nsec && user.hasnsec)
+ ({ nsec } = await post("/nsec", { password: await getPassword() }));
if (sk) {
k = hexToBytes(sk);