I'd like to add 'sign in with nostr' to Sats-Man and our upcoming nostr-themed 8-bit game. 👀

How do I do this using Javascript?

Currently people are just copy/pasting npubs or nip-05:

https://github.com/Game-r-tron/Sats-Man-Scoreboard/blob/main/satsmanscoreboard/templates/enterUserDetails.html

Reply to this note

Please Login to reply.

Discussion

Call `window.nostr.getPublicKey()` to get the npub

Wow, that's simple.

Is there a JavaScript SDK for other, more advanced functions?

I looked at NDK, but rust only for now.

nostr:npub1l2vyh47mk2p0qlsku7hg0vn29faehy9hy34ygaclpn66ukqp3afqutajft

You can look at the NIP-07 docs it has the list of functions: https://nips.be/7

I guess 'sign in' should really be backed by signing a message. Similar to WebLN.

getPublicKey() probably good enough for me as it's not a high security app.

Just get the client to sign an event, you know they have the private key then