aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-03-01 21:17:58 -0800
committerAdam Soltys <[email protected]>2026-03-01 21:17:58 -0800
commit77f407e06d21152546ccee3d8f4b21766d598c6f (patch)
treee418d46678aed6b01ce6016849577e1c338ea6ae /src/lib
parent10b627b0345689df74800cd64b142395dc591142 (diff)
downloadcoinos-ui-77f407e06d21152546ccee3d8f4b21766d598c6f.tar.gz
coinos-ui-77f407e06d21152546ccee3d8f4b21766d598c6f.zip
fix nip7 issue
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/nip07.ts24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/lib/nip07.ts b/src/lib/nip07.ts
index ce1cddaf..be3f42e2 100644
--- a/src/lib/nip07.ts
+++ b/src/lib/nip07.ts
@@ -32,18 +32,6 @@ const tryNsecFromStorage = async (): Promise<Uint8Array | null> => {
// Ensures we have access to a secret key, triggering the signer modal if needed.
// Returns the sk as Uint8Array, or null if using NIP-07 extension.
export const ensureSigner = async (userPubkey: string): Promise<Uint8Array | null> => {
- // Check if NIP-07 extension is available and matches user
- if (window.nostr) {
- try {
- const extPubkey = await window.nostr.getPublicKey();
- if (extPubkey === userPubkey) {
- return null; // Use NIP-07
- }
- } catch (e) {
- // Extension didn't work, fall through to signer
- }
- }
-
// Check if signer already has a valid sk (64 hex chars = 32 bytes)
const currentSigner = get(signer);
if (currentSigner?.ready && currentSigner?.params?.sk && currentSigner.params.sk.length === 64) {
@@ -54,6 +42,18 @@ export const ensureSigner = async (userPubkey: string): Promise<Uint8Array | nul
const skFromStorage = await tryNsecFromStorage();
if (skFromStorage) return skFromStorage;
+ // Fall back to NIP-07 extension if available and matches user
+ if (window.nostr) {
+ try {
+ const extPubkey = await window.nostr.getPublicKey();
+ if (extPubkey === userPubkey) {
+ return null; // Use NIP-07
+ }
+ } catch (e) {
+ // Extension didn't work, fall through to signer modal
+ }
+ }
+
// Clear invalid signer state before triggering modal
if (
currentSigner?.ready &&