0.2.1 • Published 7 months ago
@joyid/nostr v0.2.1
@joyid/nostr
Installation
npm install @joyid/nostrUsage
NIP-07
import { nostr } from '@joyid/nostr'The nostr variable implements NIP-07 and can be used to interact with the Nostr protocol. Following are the methods available on the nostr variable:
nostr.getPublicKey(): Promise<string>
Returns the public key of the authenticated user.
nostr.signEvent(event: UnsignEvent): Promise<event>
Signs an event with the private key of the authenticated user. Note that You must first call getPublicKey() once before you can use the authorized nostr account to call signEvent(). Alternatively, you can pass pubkey as event.pubkey to skip the getPublicKey() call.
NIP-04
NIP-04 is under development and not yet implemented.
Config
import { initConfig } from '@joyid/nostr'
// in your app entry file
initConfig({
// your app name
name: 'Nostr demo',
// your app logo,
logo: 'https://fav.farm/🆔',
// optional, default to 'https://poc.joyid.dev'
// joyidAppURL: 'https://poc.joyid.dev',
})logout()
Logs out the authenticated user.
import { logout } from '@joyid/nostr'
function logoutOnClick() {
logout()
}