UNPKG

@konemono/nostr-content-parser

Version:
158 lines (157 loc) 4.3 kB
export declare const TokenType: { readonly TEXT: "text"; readonly NIP19: "nip19"; readonly RELAY: "relay"; readonly URL: "url"; readonly CUSTOM_EMOJI: "custom_emoji"; readonly HASHTAG: "hashtag"; readonly LN_ADDRESS: "ln_address"; readonly LN_URL: "ln_url"; readonly LNBC: "lnbc"; readonly EMAIL: "email"; readonly CASHU_TOKEN: "cashu_token"; readonly BITCOIN_ADDRESS: "bitcoin_address"; readonly NIP_IDENTIFIER: "nip_identifier"; readonly LEGACY_REFERENCE: "legacy_reference"; }; export type TokenTypeValue = (typeof TokenType)[keyof typeof TokenType]; export declare const NIP19SubType: { readonly NPUB: "npub"; readonly NPROFILE: "nprofile"; readonly NOTE: "note"; readonly NEVENT: "nevent"; readonly NADDR: "naddr"; readonly NSEC: "nsec"; }; export type NIP19SubType = (typeof NIP19SubType)[keyof typeof NIP19SubType]; export declare const NIP19_TYPE_MAP: Record<string, NIP19SubType>; type TokenBase = { content: string; start: number; end: number; }; export type Token = (TokenBase & { type: "nip19"; metadata: { plainNip19: string; subType: NIP19SubType; hasNostrPrefix: boolean; }; }) | (TokenBase & { type: "nip_identifier"; metadata: { number: string; }; }) | (TokenBase & { type: "custom_emoji"; metadata: { url: string; name: string; hasMetadata: true; }; }) | (TokenBase & { type: "custom_emoji"; metadata: { name: string; hasMetadata: false; }; }) | (TokenBase & { type: "legacy_reference"; metadata: { tagIndex: number; tagType: string; referenceId: string; referenceType: "npub" | "note" | "naddr" | "unknown"; }; }) | (TokenBase & { type: "relay"; metadata: { scheme: string; }; }) | (TokenBase & { type: "bitcoin_address"; metadata: { addressType: string; }; }) | (TokenBase & { type: "ln_address"; metadata: { domain: string; }; }) | (TokenBase & { type: "cashu_token"; metadata?: undefined; }) | (TokenBase & { type: "email"; metadata?: undefined; }) | (TokenBase & { type: "hashtag"; metadata: { tag: string; validated: boolean; }; }) | (TokenBase & { type: "url"; metadata?: { scheme?: string; type?: "image" | "video" | "audio"; }; }) | (TokenBase & { type: "ln_url"; metadata?: undefined; }) | (TokenBase & { type: "lnbc"; metadata?: undefined; }) | (TokenBase & { type: "text"; metadata?: undefined; }); export declare const LN_ADDRESS_PATTERN: RegExp; export declare function isLightningAddress(emailLike: string): boolean; export declare function findCustomEmojiMetadata(emojiName: string, tags: string[][]): { url: string; } | null; export declare const NIP19_PATTERNS: { readonly npub: RegExp; readonly nprofile: RegExp; readonly note: RegExp; readonly nevent: RegExp; readonly naddr: RegExp; readonly nsec: RegExp; }; export declare const NIP19_PLAIN_PATTERNS: { npub: RegExp; nprofile: RegExp; note: RegExp; nevent: RegExp; naddr: RegExp; nsec: RegExp; }; export declare const URL_PATTERN: RegExp; export declare const LN_URL_PATTERN: RegExp; export declare const LNBC_PATTERN: RegExp; export declare const CASHU_TOKEN_PATTERN: RegExp; export declare const EMAIL_PATTERN: RegExp; export declare const CUSTOM_EMOJI_PATTERN: RegExp; export declare const HASHTAG_PATTERN: RegExp; export declare const RELAY_URL_PATTERN: RegExp; export declare const LEGACY_REFERENCE_PATTERN: RegExp; export declare const BITCOIN_ADDRESS_PATTERNS: { readonly legacy: RegExp; readonly script: RegExp; readonly bech32: RegExp; }; export declare const NIP_IDENTIFIER_PATTERN: RegExp; export declare function parseNipIdentifier(nipId: string): { number: string; hasAlpha: boolean; hasDigit: boolean; }; export declare const cleanUrlEnd: (url: string) => string; export declare function findLegacyReferenceMetadata(referenceMatch: string, tags: string[][]): { tagIndex: number; tagType: string; referenceId: string; referenceType: "npub" | "note" | "naddr" | "unknown"; } | null; export {};