From 399a100248792fe8d6aaf19849eab3ee3baa1984 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Tue, 4 Aug 2026 09:46:54 -0700 Subject: The Nostr card owns its built-in account; the exported key opens this wallet anywhere Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01M5kFodm9azZJVTQxnkDdKe --- src/nostr.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/nostr.js') diff --git a/src/nostr.js b/src/nostr.js index cf3cc88..98515fe 100644 --- a/src/nostr.js +++ b/src/nostr.js @@ -13,7 +13,7 @@ import * as nip06 from 'nostr-tools/nip06'; import * as nip44 from 'nostr-tools/nip44'; import * as nip04 from 'nostr-tools/nip04'; import { getPublicKey, finalizeEvent, generateSecretKey } from 'nostr-tools/pure'; -import { decode as nip19decode, npubEncode } from 'nostr-tools/nip19'; +import { decode as nip19decode, npubEncode, nsecEncode } from 'nostr-tools/nip19'; import { SimplePool } from 'nostr-tools/pool'; import { randomBytes } from '@noble/hashes/utils'; import { base64urlnopad } from '@scure/base'; @@ -112,6 +112,8 @@ export function parseNostrPubkey(input) { } // An npub or 64-hex nostr pubkey → hex, or null if it isn't one. export function npubOf(pkHex) { try { return npubEncode(pkHex); } catch { return null; } } +// A raw secret key → nsec, for the one place that deliberately exports it. +export function nsecOf(sk) { try { return nsecEncode(sk); } catch { return null; } } // Profiles live across the network, so look them up on popular relays (broader // than the sync relays). -- cgit v1.2.3