snstr
Version:
Secure Nostr Software Toolkit for Renegades - A comprehensive TypeScript library for Nostr protocol implementation
28 lines (27 loc) • 962 B
TypeScript
/**
* NIP-21: `nostr:` URI scheme
*
* Provides helpers to create and parse `nostr:` URIs which
* wrap NIP-19 bech32 identifiers.
*
* @see https://github.com/nostr-protocol/nips/blob/master/21.md
*/
import { Bech32String, DecodedEntity } from "../nip19";
/** Prefix for nostr URIs */
export declare const NOSTR_URI_PREFIX = "nostr:";
/**
* Create a `nostr:` URI from a NIP-19 identifier.
*
* @param entity - Bech32 encoded entity (npub, note, nprofile, nevent, naddr)
* @returns URI string in the form `nostr:<entity>`
* @throws Error if the entity is an nsec or invalid string
*/
export declare function encodeNostrURI(entity: Bech32String): string;
/**
* Parse a `nostr:` URI and decode the underlying NIP-19 entity.
*
* @param uri - URI string starting with `nostr:`
* @returns Decoded NIP-19 entity
* @throws Error if the URI is malformed or contains an invalid entity
*/
export declare function decodeNostrURI(uri: string): DecodedEntity;