fix(smirk): grant the Nostr scope via getNostrPublicKey() before signNostrEvent()

The Smirk dapp API requires the origin to hold the Nostr scope before signNostrEvent(); without it the wallet throws 'Origin lacks the Nostr scope — call getNostrPublicKey() first'. getNostrPublicKey() establishes that grant (prompts once), so call it first in the NIP-98 path.
This commit is contained in:
jwinterm
2026-07-10 10:29:52 -04:00
parent 057767152c
commit 65305bf7de
+5
View File
@@ -141,6 +141,11 @@ const SmirkAuth = {
* @returns {Promise<{verifyData: object, pubkey: string|null}>}
*/
async _verifyNip98(socketId, challenge) {
// Grant this origin the Nostr scope first. Per the Smirk dapp API, getNostrPublicKey()
// IS the connection for a Nostr origin (it prompts on first use); signNostrEvent() throws
// "Origin lacks the Nostr scope — call getNostrPublicKey() first" without it.
await window.smirk.getNostrPublicKey();
// Build the NIP-98 HTTP auth event. The wallet fills in pubkey/id/sig.
const evt = {
kind: 27235,