NIP-7

NIP-07 introduces the window.nostr object for web browsers or extensions, providing essential methods for working with public keys and events, as well as optional functions for relay management

NIP-07 proposes the window.nostr object for web browsers or extensions, which can be utilized by websites or web apps after checking their availability. The window.nostr object must define two essential methods:

  1. async window.nostr.getPublicKey(): string - returns a public key as a hex string.

  2. async window.nostr.signEvent(event: Event): Event - takes an event object, adds id, pubkey, and sig, then returns it.

Additionally, the following optional functions can be implemented:

  1. async window.nostr.getRelays(): { [url: string]: {read: boolean, write: boolean} } - returns a basic map of relay URLs to relay policies.

  2. async window.nostr.nip04.encrypt(pubkey, plaintext): string - returns ciphertext and iv as specified in NIP-04.

  3. async window.nostr.nip04.decrypt(pubkey, ciphertext): string - takes ciphertext and iv as specified in NIP-04.

Several implementations of NIP-07 are available for different browsers and extensions, including Horse, nos2x, Alby, Blockcore, nos2x-fox, and Flamingo, compatible with Chrome and its derivatives, Firefox, and Safari.

Last updated