Tools for developing Nostr clients.
Calculate the intrinsic limit of a filter.
This function returns a positive integer, or Infinity
if there is no intrinsic limit.
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.
Designates a verified event signature.
- _WebSocket
- _connected
- _onmessage
- auth
- authPromise
- baseEoseTimeout
- challenge
- close
- closeAllSubscriptions
- connect
- connected
- connectionPromise
- connectionTimeout
- connectionTimeoutHandle
- count
- handleNext
- incomingMessageQueue
- onclose
- onnotice
- openCountRequests
- openEventPublishes
- openSubs
- prepareSubscription
- publish
- publishTimeout
- queueRunning
- runQueue
- send
- serial
- subscribe
- url
- verifyEvent
- ws
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.
Designates a verified event signature.
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.
Classification of the event kind.
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.
Classification of the event kind.
NIP-05 regex. The localpart is optional, and should be assumed to be _
otherwise.
NIP-05 regex. The localpart is optional, and should be assumed to be _
otherwise.
Relay Information Document
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.
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.
Relay Information Document
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.
A URL pointing to an image to be used as an icon for the relay. Recommended to be squared in shape.
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.
Relays that require payments may want to expose their fee schedules.
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.
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.
Bech32 regex.
Bech32 regex.
Nostr URI regex, eg nostr:npub1...
Parse and decode a Nostr URI.
Test whether the value is a Nostr URI.
Nostr URI regex, eg nostr:npub1...
Parse and decode a Nostr URI.
Test whether the value is a Nostr URI.
Encodes a group reference into a string.
Fetches the group admins event from the specified pool. If the normalizedRelayURL is not provided, it will be obtained from the groupReference. If the relayInformation is not provided, it will be fetched using the normalizedRelayURL.
Fetches the group members event from the specified relay. If the normalizedRelayURL is not provided, it will be obtained using the groupReference. If the relayInformation is not provided, it will be fetched using the normalizedRelayURL.
Fetches the group metadata event from the specified pool. If the normalizedRelayURL is not provided, it will be obtained using the groupReference. If the relayInformation is not provided, it will be fetched using the normalizedRelayURL.
Fetches relay information by group reference.
Generates an event template for group admins.
Generates an event template for a group with its members.
Generates a group metadata event template.
Returns the normalized relay URL based on the provided group reference.
Represents the permissions that a NIP29 group admin can have.
Fetches and parses the group metadata event, group admins event, and group members event from the specified pool. If the normalized relay URL is not provided, it will be obtained using the group reference. If the relay information is not provided, it will be fetched using the normalized relay URL.
Loads a group from the specified pool using the provided group code.
Parses a group admins event and returns an array of GroupAdmin objects.
Parses a group code and returns a GroupReference object.
Parses a group members event and returns an array of GroupMember objects.
Parses a group metadata event and returns the corresponding GroupMetadata object.
Subscribes to relay groups metadata events and calls the provided event handler function when an event is received.
Validates a group admins event.
Validates a group members event.
Validates a group metadata event.
Regex for a single emoji shortcode.
Find all custom emoji shortcodes.
Regex for a single emoji shortcode.
Find all custom emoji shortcodes.
Regex to find emoji shortcodes in content.
Replace all emoji shortcodes in the content.
Regex to find emoji shortcodes in content.
Replace all emoji shortcodes in the content.
creates an EventTemplate for an AUTH event to be signed.
creates an EventTemplate for an AUTH event to be signed.
Creates an account with the specified username, domain, and optional email.
Fetches info on available providers that announce themselves using NIP-89 events.
This takes either a bunker:// URL or a name@domain.com NIP-05 identifier and returns a BunkerPointer -- or null in case of error
Represents the structure for awarding a badge to one or more recipients within the Nostr network. This structure is used to create templates for badge award events, which are immutable and signify the recognition of individuals' achievements or contributions.
Represents the structure for defining a badge within the Nostr network. This structure is used to create templates for badge definition events, facilitating the recognition and awarding of badges to users for various achievements.
Generates an EventTemplate based on the provided BadgeAward.
Generates an EventTemplate based on the provided BadgeDefinition.
Generates an EventTemplate based on the provided ProfileBadges.
Represents the collection of badges a user chooses to display on their profile. This structure is crucial for applications that allow users to showcase achievements or recognitions in the form of badges, following the specifications of NIP-58.
Validates a badge award event.
Validates a badge definition event.
Validates a profile badges event.
Generates an EventTemplate for a fundraising goal based on the provided ZapGoal object. This function is tailored to fit the structure of EventTemplate as defined in the library.
Generates an event template based on a file metadata object.
Parses an event and returns a file metadata object.
Validates an event to ensure it is a valid file metadata event.
Generate token for NIP-98 flow.
Calculates the hash of a payload.
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.
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.
Represents a classified listing object.
Generates an event template based on a classified listing object.
Parses an event and returns a classified listing object.
Validates an event to ensure it is a valid classified listing event.
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.
Designates a verified event signature.
- _WebSocket
- _connected
- _onmessage
- auth
- authPromise
- baseEoseTimeout
- challenge
- close
- closeAllSubscriptions
- connect
- connected
- connectionPromise
- connectionTimeout
- connectionTimeoutHandle
- count
- handleNext
- incomingMessageQueue
- onclose
- onnotice
- openCountRequests
- openEventPublishes
- openSubs
- prepareSubscription
- publish
- publishTimeout
- queueRunning
- runQueue
- send
- serial
- subscribe
- url
- verifyEvent
- ws
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.
Designates a verified event signature.