Merge pull request #2213 from PR0M3TH3AN/add-nip07-signing-adapter-tests-7079316761627658374

🧪 Add tests for NIP-07 signing adapter factory
This commit is contained in:
thePR0M3TH3AN authored and GitHub committed 2026-02-07 19:37:11 -05:00
commit d32ab04c50
2 files changed
+115

No files matched your search

+24
View File
@@ -0,0 +1,24 @@
export function createNip07SigningAdapter({ extension } = {}) {
const resolvedExtension =
extension ||
(typeof window !== "undefined" && window?.nostr ? window.nostr : null);
const getPubkey = async () => {
if (!resolvedExtension) {
throw new Error("NIP-07 extension unavailable.");
}
return resolvedExtension.getPublicKey();
};
const signEvent = async (event) => {
if (!resolvedExtension) {
throw new Error("NIP-07 extension unavailable.");
}
return resolvedExtension.signEvent(event);
};
return {
getPubkey,
signEvent,
};
}