Ensure NostrTools nip04 helper persists

This commit is contained in:
thePR0M3TH3AN committed 2025-10-05 08:44:23 -04:00
1 parent 2529ab1314
commit ad4f56a1d4
4 files changed
+108 -14

No files matched your search

+16 -1
View File
@@ -29,7 +29,22 @@ function getGlobalWindow() {
function getNostrTools() {
const win = getGlobalWindow();
return win?.NostrTools || null;
const tools = win?.NostrTools || null;
const canonical = win?.__BITVID_CANONICAL_NOSTR_TOOLS__ || null;
if (tools && canonical && !tools.nip04 && canonical.nip04) {
try {
tools.nip04 = canonical.nip04;
} catch (error) {
return { ...canonical, ...tools, nip04: canonical.nip04 };
}
}
if (tools) {
return tools;
}
return canonical || null;
}
function assertNostrTools(methods = []) {
+12 -1
View File
@@ -21,7 +21,18 @@ function getGlobalWindow() {
function getNostrTools() {
const win = getGlobalWindow();
return win?.NostrTools || null;
const tools = win?.NostrTools || null;
const canonical = win?.__BITVID_CANONICAL_NOSTR_TOOLS__ || null;
if (tools && canonical && !tools.nip04 && canonical.nip04) {
try {
tools.nip04 = canonical.nip04;
} catch (error) {
return { ...canonical, ...tools, nip04: canonical.nip04 };
}
}
return tools || canonical || null;
}
function decodeAdminPubkey() {
+20 -2
View File
@@ -81,12 +81,30 @@ function mergeDependencies(overrides = {}) {
}
function getNostrTools() {
if (typeof window !== "undefined" && window?.NostrTools) {
return window.NostrTools;
const scope = typeof window !== "undefined" ? window : globalThis;
const tools = scope?.NostrTools || null;
const canonical = scope?.__BITVID_CANONICAL_NOSTR_TOOLS__ || null;
if (tools && canonical && !tools.nip04 && canonical.nip04) {
try {
tools.nip04 = canonical.nip04;
} catch (error) {
return { ...canonical, ...tools, nip04: canonical.nip04 };
}
}
if (tools) {
return tools;
}
if (canonical) {
return canonical;
}
if (typeof globalThis !== "undefined" && globalThis?.NostrTools) {
return globalThis.NostrTools;
}
return null;
}