Nostr tools
Sign in with a real account, prepare and verify posts, discover relays, and read or publish Nostr events. This is the part a social app like Deepink uses most.
Try it in context: Read the guide.
import { Nostr } from '@chaoticka/nsite-loopy-sdk';
What you can call (32)
androidIntent
Prepare an Amber/Android signing request that the host app can launch. It does not mean the request was approved.
Call it as: Nostr.androidIntent
For developers: TypeScript signature
function androidIntent(input:{type?:'get_public_key'|'sign_event';requestId:string;event?:UnsignedEvent;currentPubkey?:Hex;callbackUrl?:string}):string;
Code location: src/nostr/nip55.js
assertSignedEvent
Reject a signed event if its contents or signature do not pass verification.
Call it as: Nostr.assertSignedEvent
For developers: TypeScript signature
function assertSignedEvent(event:SignedEvent):SignedEvent;
Code location: src/nostr/events.js
blossomServers
Read Blossom storage-server addresses from a verified account server-list event.
Call it as: Nostr.blossomServers
For developers: TypeScript signature
function blossomServers(event:SignedEvent):string[];
Code location: src/nostr/discovery.js
browserSigner
Use a NIP-07 browser signer when one is installed and available.
Call it as: Nostr.browserSigner
For developers: TypeScript signature
function browserSigner(provider?:Signer):Signer;
Code location: src/nostr/signers.js
bunkerSigner
Connect to a remote NIP-46 signer while keeping its secret out of the app’s saved data.
Call it as: Nostr.bunkerSigner
For developers: TypeScript signature
function bunkerSigner(uri:string,options?:object):Promise<Signer&{connect():Promise<Hex>;close():Promise<void>}>;
Code location: src/nostr/signers.js
checkedSign
Ask an approved signer to sign and confirm it signed the event we actually requested.
Call it as: Nostr.checkedSign
For developers: TypeScript signature
function checkedSign(signer:Signer,template:UnsignedEvent,pubkey:Hex):Promise<SignedEvent>;
Code location: src/nostr/events.js
connectIdentity
Ask the signer which account it controls and confirm a usable signing session.
Call it as: Nostr.connectIdentity
For developers: TypeScript signature
function connectIdentity(signer:Signer):Promise<{pubkey:Hex;signer:Signer}>;
Code location: src/nostr/signers.js
discoverBlossom
Look up storage servers from the account’s signed Blossom preferences.
Call it as: Nostr.discoverBlossom
For developers: TypeScript signature
function discoverBlossom(pubkey:Hex,options?:{bootstrap?:string[];query?:(url:string,filter:object)=>Promise<SignedEvent[]>}):Promise<{sourceEvent:string|null;servers:string[];verified:boolean}>;
Code location: src/nostr/discovery.js
discoverRelays
Find the read and write relays an account has advertised.
Call it as: Nostr.discoverRelays
For developers: TypeScript signature
function discoverRelays(pubkey:Hex,options?:{bootstrap?:string[];query?:(url:string,filter:object)=>Promise<SignedEvent[]>;defaults?:string[];max?:number}):Promise<{status:string;records:RelayListEntry[];relays:string[];sourceEvent:string|null;errors:Array<{relay:string;error:string}>}>;
Code location: src/nostr/discovery.js
encryptionAdapter
Delegate message encryption or decryption to an approved signer that supports it.
Call it as: Nostr.encryptionAdapter
For developers: TypeScript signature
function encryptionAdapter(signer:{nip44?:{encrypt(peer:string,plaintext:string):Promise<string>;decrypt(peer:string,ciphertext:string):Promise<string>}}):{encrypt(peer:string,plaintext:string):Promise<string>;decrypt(peer:string,ciphertext:string):Promise<string>};
Code location: src/nostr/other-nips.js
eventTemplate
Create the unsigned event data that a signer will later approve.
Call it as: Nostr.eventTemplate
For developers: TypeScript signature
function eventTemplate(input?:Partial<UnsignedEvent>):UnsignedEvent;
Code location: src/nostr/events.js
fetchFeed
Fetch verified posts from selected relays and return errors from relays that fail.
Call it as: Nostr.fetchFeed
For developers: TypeScript signature
function fetchFeed(options:{authors:Hex[];kinds?:number[];relays:string[];limit?:number;query?:(url:string,filter:object)=>Promise<SignedEvent[]>}):Promise<{events:SignedEvent[];failed:Array<{relay:string;error:string}>;status:string}>;
Code location: src/nostr/feed.js
fetchProfiles
Fetch and verify public profile information for a set of Nostr accounts.
Call it as: Nostr.fetchProfiles
For developers: TypeScript signature
function fetchProfiles(options:{pubkeys:Hex[];relays:string[];query?:(url:string,filter:object)=>Promise<SignedEvent[]>}):Promise<{profiles:Map<Hex,Record<string,string|number>>;failed:object[];status:string}>;
Code location: src/nostr/profiles.js
finalizeEvent
Sign an event with a supplied secret key; intended for controlled tooling and tests.
Call it as: Nostr.finalizeEvent
For developers: TypeScript signature
function finalizeEvent(template:UnsignedEvent,secret:Uint8Array):SignedEvent;
generateSecretKey
Create a new secret key for controlled tests or authorized key generation.
Call it as: Nostr.generateSecretKey
For developers: TypeScript signature
function generateSecretKey():Uint8Array;
getPublicKey
Derive the public key corresponding to a supplied secret key.
Call it as: Nostr.getPublicKey
For developers: TypeScript signature
function getPublicKey(secret:Uint8Array):Hex;
httpAuthHeader
Create a signed header for a Nostr-authenticated HTTPS request.
Call it as: Nostr.httpAuthHeader
For developers: TypeScript signature
function httpAuthHeader(options:{url:string;method:string;signer:Signer;pubkey:Hex;created_at?:number}):Promise<string>;
Code location: src/nostr/other-nips.js
nostrConnectRequest
Create a Nostr Connect pairing request and a listener for a remote signer such as Amber.
Call it as: Nostr.nostrConnectRequest
For developers: TypeScript signature
function nostrConnectRequest(options:{relays:string[];name?:string;perms?:string[];secret?:string;clientSecret?:Uint8Array}):{uri:string;mode:'nip46';start(signal?:AbortSignal):Promise<Signer>};
Code location: src/nostr/signers.js
npubEncode
Convert a public key into its recognizable npub form.
Call it as: Nostr.npubEncode
For developers: TypeScript signature
function npubEncode(pubkey:Hex):string;
parseProfile
Read bounded profile fields from a verified kind-0 profile event.
Call it as: Nostr.parseProfile
For developers: TypeScript signature
function parseProfile(event:SignedEvent):Record<string,string|number>;
Code location: src/nostr/profiles.js
planRelays
Select suitable sending and receiving relays using the account and recipients’ published preferences.
Call it as: Nostr.planRelays
For developers: TypeScript signature
function planRelays(options:{authorList?:RelayListEntry[];recipientLists?:RelayListEntry[][];defaults?:string[];max?:number}):string[];
Code location: src/nostr/nip65.js
publishMany
Send one signed event to several relays and retain each relay’s result.
Call it as: Nostr.publishMany
For developers: TypeScript signature
function publishMany(event:SignedEvent,relays:string[],options?:{writer?:(url:string,event:SignedEvent,options:object)=>Promise<RelayReceipt>}):Promise<PublishReceipts>;
Code location: src/nostr/relay-transport.js
publishRelay
Send a signed event to a relay and confirm it can be fetched back.
Call it as: Nostr.publishRelay
For developers: TypeScript signature
function publishRelay(url:string,event:SignedEvent,options?:{Socket?:any;timeoutMs?:number;signal?:AbortSignal;verify?:boolean}):Promise<RelayReceipt>;
Code location: src/nostr/relay-transport.js
publishTemplate
Ask the signer to approve an unsigned event, publish it, and verify the result.
Call it as: Nostr.publishTemplate
For developers: TypeScript signature
function publishTemplate(template:UnsignedEvent,options:{signer:Signer;pubkey:Hex;relays:string[];publisher?:(event:SignedEvent,relays:string[])=>Promise<PublishReceipts>}):Promise<{event:SignedEvent;receipts:PublishReceipts}>;
Code location: src/nostr/feed.js
queryRelay
Ask a relay for matching signed events, with a time limit and event verification.
Call it as: Nostr.queryRelay
For developers: TypeScript signature
function queryRelay(url:string,filter:object,options?:{Socket?:any;timeoutMs?:number;signal?:AbortSignal;verify?:boolean;maxEvents?:number}):Promise<SignedEvent[]>;
Code location: src/nostr/relay-transport.js
reaction
Prepare a reaction linked to an existing post.
Call it as: Nostr.reaction
For developers: TypeScript signature
function reaction(target:SignedEvent,emoji?:string,options?:{created_at?:number}):UnsignedEvent;
Code location: src/nostr/feed.js
relayAuthTemplate
Prepare a NIP-42 authentication response for a relay challenge.
Call it as: Nostr.relayAuthTemplate
For developers: TypeScript signature
function relayAuthTemplate(options:{challenge:string;relay:string;created_at?:number}):UnsignedEvent;
Code location: src/nostr/other-nips.js
relayInfo
Read a relay’s published capabilities and access-policy information.
Call it as: Nostr.relayInfo
For developers: TypeScript signature
function relayInfo(url:string,options?:object):Promise<Record<string,unknown>>;
Code location: src/nostr/nip65.js
relayList
Read the account’s signed NIP-65 list of read and write relays.
Call it as: Nostr.relayList
For developers: TypeScript signature
function relayList(event:SignedEvent):RelayListEntry[];
Code location: src/nostr/nip65.js
textNote
Prepare an ordinary text post or a reply with the correct reply links.
Call it as: Nostr.textNote
For developers: TypeScript signature
function textNote(content:string,options?:{replyTo?:SignedEvent;created_at?:number}):UnsignedEvent;
Code location: src/nostr/feed.js
verifyAndroidResult
Check that Amber’s returned signature matches the pending Android request.
Call it as: Nostr.verifyAndroidResult
For developers: TypeScript signature
function verifyAndroidResult(input:{requestId:string;returnedId:string;event:SignedEvent;template:UnsignedEvent;expectedPubkey:Hex;rejected?:boolean}):SignedEvent;
Code location: src/nostr/nip55.js
verifyEvent
Check whether an event has a valid canonical identifier and cryptographic signature.
Call it as: Nostr.verifyEvent
For developers: TypeScript signature
function verifyEvent(event:SignedEvent):boolean;
Code location: src/nostr/events.js