Tools for developing Nostr clients.
Classes
- _bound(): { timestamp: number; id: Uint8Array; }timestamp: number,id?: Uint8ArrayNo documentation available
- decodeBound(encoded: WrappedBuffer): { timestamp: number; id: Uint8Array; }No documentation available
- decodeTimestampIn(encoded: WrappedBuffer): numberNo documentation available
- encodeBound(key: { timestamp: number; id: Uint8Array; }): WrappedBufferNo documentation available
- encodeTimestampOut(timestamp: number): WrappedBufferNo documentation available
- exceededFrameSizeLimit(n: number): booleanNo documentation available
- frameSizeLimit: numberNo documentation available
- getMinimalBound(): { timestamp: number; id: Uint8Array; }prev: { timestamp: number; id: Uint8Array; },curr: { timestamp: number; id: Uint8Array; }No documentation available
- initiate(): stringNo documentation available
- lastTimestampIn: numberNo documentation available
- lastTimestampOut: numberNo documentation available
- reconcile(): string | nullqueryMsg: string,onhave?: (id: string) => void,onneed?: (id: string) => voidNo documentation available
- splitRange(): voidlower: number,upper: number,upperBound: { timestamp: number; id: Uint8Array; },o: WrappedBufferNo documentation available
- storage: NegentropyStorageVectorNo documentation available
- _binarySearch(): numberarr: { timestamp: number; id: Uint8Array; }[],first: number,last: number,cmp: (a: { timestamp: number; id: Uint8Array; }) => booleanNo documentation available
- _checkBounds(): voidbegin: number,end: numberNo documentation available
- _checkSealed(): voidNo documentation available
- findLowerBound(): numberbegin: number,end: number,bound: { timestamp: number; id: Uint8Array; }No documentation available
- fingerprint(): Uint8Arraybegin: number,end: numberNo documentation available
- getItem(i: number): { timestamp: number; id: Uint8Array; }No documentation available
- insert(): voidtimestamp: number,id: stringNo documentation available
- items: { timestamp: number; id: Uint8Array; }[]No documentation available
- iterate(): voidbegin: number,end: number,cb: () => booleanitem: { timestamp: number; id: Uint8Array; },i: numberNo documentation available
- seal(): voidNo documentation available
- sealed: booleanNo documentation available
- size(): numberNo documentation available
- unseal(): voidNo documentation available
- close(): voidNo documentation available
- filter: FilterNo documentation available
- neg: NegentropyNo documentation available
- onhave: (id: string) => voidNo documentation available
- onneed: (id: string) => voidNo documentation available
- relay: AbstractRelayNo documentation available
- start(): Promise<void>No documentation available
- storage: NegentropyStorageVectorNo documentation available
- subscription: SubscriptionNo documentation available
- connect(): Promise<Relay>url: string,options?: Pick<>AbstractRelayConstructorOptions,"enablePing" | "enableReconnect"No documentation available
Functions
Calculate the intrinsic limit of a filter.
This function returns a positive integer, or Infinity if there is no intrinsic limit.
Determine the classification of this kind of event if known, or unknown.
Events are addressable, which means that, for each combination of pubkey, kind and the d tag, only the latest event is expected to be stored by relays, older versions are expected to be discarded.
Events are ephemeral, which means they are not expected to be stored by relays.
Events are regular, which means they're all expected to be stored by relays.
Events are replaceable, which means that, for each combination of pubkey and kind, only the latest event is expected to (SHOULD) be stored by relays, older versions are expected to be discarded.
Get POW difficulty from a Nostr hex ID.
Mine an event with the desired POW. This function mutates the event. Note that this operation is synchronous and should be run in a worker context to avoid blocking the main thread.
Parse and decode a Nostr URI.
Test whether the value is a Nostr URI.
Find all custom emoji shortcodes.
Regex to find emoji shortcodes in content.
Replace all emoji shortcodes in the content.
creates an EventTemplate for an AUTH event to be signed.
Generate token for NIP-98 flow.
Calculates the hash of a payload.
Unpacks an event from a token.
Validates a Nostr event for the NIP-98 flow.
Validates the kind of an event.
Validates if the given event has a method tag that matches the specified method.
Validates the event payload tag against the provided payload.
Validates the timestamp of an event.
Validates if the given URL matches the URL tag of the event.
Validate token for NIP-98 flow.
Sort events in reverse-chronological order by the created_at timestamp,
and then by the event id (lexicographically) in case of ties.
This mutates the array.
Interfaces
Relay Information Document
- contact: stringNo documentation available
- description: stringNo documentation available
- name: stringNo documentation available
- pubkey: stringNo documentation available
- software: stringNo documentation available
- supported_nips: number[]No documentation available
- version: stringNo documentation available
Community Preferences
- language_tags: string[]No documentation available
- posting_policy: stringNo documentation available
- tags: string[]No documentation available
Some relays may be governed by the arbitrary laws of a nation state. This may limit what content can be stored in cleartext on those relays. All clients are encouraged to use encryption to work around this limitation.
- relay_countries: string[]No documentation available
- admission: Amount[]No documentation available
- publication: PublicationAmount[]No documentation available
- subscription: Subscription[]No documentation available
A URL pointing to an image to be used as an icon for the relay. Recommended to be squared in shape.
- icon: stringNo documentation available
These are limitations imposed by the relay on clients. Your client should expect that requests which exceed these practical_ limitations are rejected or fail immediately.
- auth_required: booleanNo documentation available
- created_at_lower_limit: numberNo documentation available
- created_at_upper_limit: numberNo documentation available
- max_content_length: numberNo documentation available
- max_event_tags: numberNo documentation available
- max_filters: numberNo documentation available
- max_limit: numberNo documentation available
- max_message_length: numberNo documentation available
- max_subid_length: numberNo documentation available
- max_subscriptions: numberNo documentation available
- min_pow_difficulty: numberNo documentation available
- min_prefix: numberNo documentation available
- payment_required: booleanNo documentation available
- restricted_writes: booleanNo documentation available
Relays that require payments may want to expose their fee schedules.
- fees: FeesNo documentation available
- payments_url: stringNo documentation available
- kinds: number[]No documentation available
Event Retention
- retention: AnyRetentionDetails[]No documentation available
- period: numberNo documentation available
Parsed Nostr URI data.
- decoded:{ type: "nevent"; data: EventPointer; }
| { type: "nprofile"; data: ProfilePointer; }
| { type: "naddr"; data: AddressPointer; }
| { type: "npub"; data: string; }
| { type: "nsec"; data: Uint8Array; }
| { type: "note"; data: string; }Decoded bech32 string, according to NIP-19.
- uri: `nostr:${string}`
Full URI including the
nostr:protocol. - value: string
The bech32-encoded data (eg
npub1...).
- content: string | ChannelMetadataNo documentation available
- created_at: numberNo documentation available
- tags: string[][]No documentation available
- channel_message_event_id: stringNo documentation available
- content: string | { reason: string; }No documentation available
- created_at: numberNo documentation available
- tags: string[][]No documentation available
- channel_create_event_id: stringNo documentation available
- content: stringNo documentation available
- created_at: numberNo documentation available
- relay_url: stringNo documentation available
- No documentation available
- tags: string[][]No documentation available
- channel_create_event_id: stringNo documentation available
- content: string | ChannelMetadataNo documentation available
- created_at: numberNo documentation available
- tags: string[][]No documentation available
- content: string | { reason: string; }No documentation available
- created_at: numberNo documentation available
- pubkey_to_mute: stringNo documentation available
- tags: string[][]No documentation available
Represents a Nostr custom emoji.
Match result for a custom emoji in text content.
- finalizeEvent(): VerifiedEventevent: EventTemplate,secretKey: Uint8ArrayNo documentation available
- generateSecretKey(): Uint8ArrayNo documentation available
- getPublicKey(secretKey: Uint8Array): stringNo documentation available
- verifyEvent(event: Event): event is VerifiedEventNo documentation available
An event whose signature has been verified.
- verifiedSymbol: trueNo documentation available
Namespaces
Type Aliases
| "replaceable"
| "ephemeral"
| "parameterized"
| "unknown"
Classification of the event kind.
& Partial<Retention>
& { limitation?: Partial<Limitations>; }
& Partial<ContentLimitations>
& Partial<CommunityPreferences>
& Partial<PayToRelay>
& Partial<Icon>
- skipVerification: booleanNo documentation available
- content: ""
Pass an empty string to NOT include the stringified JSON of the reposted event. Any other content will be ignored and replaced with the stringified JSON of the reposted event.
- created_at: numberNo documentation available
- tags: string[][]
Pass only non-nip18 tags if you have to. Nip18 tags ('e' and 'p' tags pointing to the reposted event) will be added automatically.
- identifier: stringNo documentation available
- kind: numberNo documentation available
- pubkey: stringNo documentation available
- relays: string[]No documentation available
| DecodedNprofile
| DecodedNaddr
| DecodedNpub
| DecodedNsec
| DecodedNote
- content: stringNo documentation available
- created_at: numberNo documentation available
- tags: string[][]
Pass only non-nip25 tags if you have to. Nip25 tags ('e' and 'p' tags from reacted event) will be added automatically.
| { type: "reference"; pointer: ProfilePointer | AddressPointer | EventPointer; }
| { type: "url"; url: string; }
| { type: "relay"; url: string; }
| { type: "image"; url: string; }
| { type: "video"; url: string; }
| { type: "audio"; url: string; }
| { type: "emoji"; shortcode: string; url: string; }
| { type: "hashtag"; value: string; }
- content: stringNo documentation available
- created_at: numberNo documentation available
- id: stringNo documentation available
- kind: numberNo documentation available
- pubkey: stringNo documentation available
- sig: stringNo documentation available
- tags: string[][]No documentation available
- verifiedSymbol: booleanNo documentation available
Variables
NIP-05 regex. The localpart is optional, and should be assumed to be _ otherwise.
Bech32 regex.
- isNAddr: (value?: string | null) => value is NAddrNo documentation available
- isNEvent: (value?: string | null) => value is NEventNo documentation available
- isNProfile: (value?: string | null) => value is NProfileNo documentation available
- isNPub: (value?: string | null) => value is NPubNo documentation available
- isNSec: (value?: string | null) => value is NSecNo documentation available
- isNcryptsec: (value?: string | null) => value is NcryptsecNo documentation available
- isNote: (value?: string | null) => value is NoteNo documentation available
Nostr URI regex, eg nostr:npub1...
Regex for a single emoji shortcode.
- No documentation available
- No documentation available
- utils: { getConversationKey; calcPaddedLen; }No documentation available
Designates a verified event signature.