Step 1 of 5
Keys stay in the extension
Web apps never touch your nsec. They ask the extension, which asks you.
NIP-07
DraftBehaviour
A browser extension exposes window.nostr so websites can get your public key, sign events and encrypt messages without ever seeing your secret key.
Edit the form or the JSON: both stay in sync, the badge says whether the result is valid, and tapping any field explains it.
Step 1 of 5
Web apps never touch your nsec. They ask the extension, which asks you.
Ready. Press play or step forward to send the first message.
| # | From | To | Message |
|---|---|---|---|
| 1 | Web app | Web app | The app checks for the object before offering "log in with extension". |
| 2 | Web app | Signer extension | The app asks who you are. |
| 3 | Signer extension | You | The extension asks you whether this site may use your key. |
| 4 | Signer extension | Web app | The extension returns the hex pubkey. |
| 5 | Web app | Signer extension | The app hands over an unsigned template. |
| 6 | Signer extension | Web app | pubkey, id and sig are filled in; the app can publish it. |
| 7 | Web app | Signer extension | Optional: the app asks for ciphertext for a DM. |
signEvent returns a NIP-01 event.
window.nostr.nip44 encrypts with NIP-44.
Remote signing over Nostr for apps outside the browser.
The Android signer app equivalent.
Specification text is quoted in English from the nostr-protocol/nips repository. Our explanations and the interface are translated. Source on GitHub at commit 0046368
The window.nostr object may be made available by web browsers or extensions and websites or web-apps may make use of it after checking its availability.
That object must define the following methods:
async window.nostr.getPublicKey(): string // returns a public key as hex
async window.nostr.signEvent(event: { created_at: number, kind: number, tags: string[][], content: string }): Event // takes an event object, adds `id`, `pubkey` and `sig` and returns it
Aside from these two basic above, the following functions can also be implemented optionally:
async window.nostr.nip04.encrypt(pubkey, plaintext): string // returns ciphertext and iv as specified in nip-04 (deprecated)
async window.nostr.nip04.decrypt(pubkey, ciphertext): string // takes ciphertext and iv as specified in nip-04 (deprecated)
async window.nostr.nip44.encrypt(pubkey, plaintext): string // returns ciphertext as specified in nip-44
async window.nostr.nip44.decrypt(pubkey, ciphertext): string // takes ciphertext as specified in nip-44
To make sure that the window.nostr is available to nostr clients on page load, the authors who create Chromium and Firefox extensions should load their scripts by specifying "run_at": "document_end" in the extension's manifest.
See https://github.com/aljazceru/awesome-nostr#nip-07-browser-extensions.