strip html from description

This commit is contained in:
2023-11-24 14:39:28 -05:00
parent f7c6034fb0
commit 5f6e638903
526 changed files with 4373 additions and 23270 deletions
+148 -78
View File
@@ -1,7 +1,8 @@
import EventEmitter from 'eventemitter3';
import { EventEmitter } from 'tseep';
import debug$1 from 'debug';
import { LRUCache } from 'typescript-lru-cache';
import { Relay } from 'nostr-tools';
import EventEmitter$1 from 'eventemitter3';
declare enum NDKKind {
Metadata = 0,
@@ -13,6 +14,8 @@ declare enum NDKKind {
Repost = 6,
Reaction = 7,
BadgeAward = 8,
GroupNote = 9,
GroupChat = 11,
GenericRepost = 16,
ChannelCreation = 40,
ChannelMetadata = 41,
@@ -28,29 +31,44 @@ declare enum NDKKind {
DVMReqImageGeneration = 5100,
DVMReqDiscoveryNostrContent = 5300,
DVMReqDiscoveryNostrPeople = 5301,
DVMReqTimestamping = 5900,
DVMJobFeedback = 7000,
ZapRequest = 9734,
Zap = 9735,
Highlight = 9802,
MuteList = 10000,
PinList = 10001,
RelayList = 10002,
ClientAuth = 22242,
NostrConnect = 24133,
BookmarkList = 10003,
CommunityList = 10004,
PublicChatList = 10005,
BlockRelayList = 10006,
SearchRelayList = 10007,
InterestList = 10015,
EmojiList = 10030,
FollowSet = 30000,
CategorizedPeopleList = 30000,
CategorizedBookmarkList = 30001,
RelaySet = 30002,
CategorizedRelayList = 30002,
BookmarkSet = 30003,
CurationSet = 30004,
InterestSet = 30015,
InterestsList = 30015,
EmojiSet = 30030,
HighlightSet = 39802,
CategorizedHighlightList = 39802,
ZapRequest = 9734,
Zap = 9735,
Highlight = 9802,
ClientAuth = 22242,
NostrConnect = 24133,
ProfileBadge = 30008,
BadgeDefinition = 30009,
InterestsList = 30015,
MarketStall = 30017,
MarketProduct = 30018,
CategorizedRelayList = 30022,
Article = 30023,
AppSpecificData = 30078,
Classified = 30402,
AppRecommendation = 31989,
AppHandler = 31990,
CategorizedHighlightList = 39802
AppHandler = 31990
}
declare const NDKListKinds: NDKKind[];
@@ -351,6 +369,11 @@ interface NDKSigner {
* @returns A promise that resolves to the signature of the signed event.
*/
sign(event: NostrEvent): Promise<string>;
/**
* Getter for the preferred relays.
* @returns A promise containing a simple map of preferred relays and their read/write policies.
*/
relays?(): Promise<NDKRelay[]>;
/**
* Encrypts the given Nostr event for the given recipient.
* @param value - The value to be encrypted.
@@ -366,6 +389,16 @@ interface NDKSigner {
type Hexpubkey = string;
type Npub = string;
type ProfilePointer = {
pubkey: string;
relays?: string[];
};
type EventPointer = {
id: string;
relays?: string[];
author?: string;
kind?: number;
};
interface NDKUserParams {
npub?: Npub;
hexpubkey?: Hexpubkey;
@@ -424,6 +457,10 @@ declare class NDKUser {
* Returns a set of users that this user follows.
*/
follows: (opts?: NDKSubscriptionOptions | undefined, outbox?: boolean | undefined) => Promise<Set<NDKUser>>;
/**
* Pins a user or an event
*/
pin: (event: NDKEvent, pinEvent?: NDKEvent | undefined, publish?: boolean | undefined) => Promise<NDKEvent>;
/**
* Returns a set of relay list events for a user.
* @returns {Promise<Set<NDKEvent>>} A set of NDKEvents returned for the given user.
@@ -440,7 +477,7 @@ declare class NDKUser {
* Get the tags that can be used to reference this user in an event
* @returns {NDKTag[]} an array of NDKTag
*/
referenceTags(): NDKTag[];
referenceTags(marker?: string): NDKTag[];
/**
* Publishes the current profile.
*/
@@ -457,8 +494,8 @@ declare class NDKUser {
* Validate a user's NIP-05 identifier (usually fetched from their kind:0 profile data)
*
* @param nip05Id The NIP-05 string to validate
* @returns {Promise<boolean | null>} True if the NIP-05 is found and matches this user's hexpubkey,
* False if the NIP-05 is found but doesn't match this user's hexpubkey,
* @returns {Promise<boolean | null>} True if the NIP-05 is found and matches this user's pubkey,
* False if the NIP-05 is found but doesn't match this user's pubkey,
* null if the NIP-05 isn't found on the domain or we're unable to verify (because of network issues, etc.)
*/
validateNip05(nip05Id: string): Promise<boolean | null>;
@@ -687,6 +724,10 @@ interface NDKConstructorParams {
* Muted pubkeys and eventIds
*/
mutedIds?: Map<Hexpubkey | NDKEventId, string>;
/**
* Client ID to add to events' tag
*/
client?: string;
}
interface GetUserParams extends NDKUserParams {
npub?: string;
@@ -707,6 +748,7 @@ declare class NDK extends EventEmitter {
devWriteRelaySet?: NDKRelaySet;
outboxTracker?: OutboxTracker;
mutedIds: Map<Hexpubkey | NDKEventId, string>;
readonly client?: string;
private autoConnectUserRelays;
private autoFetchUserMutelist;
constructor(opts?: NDKConstructorParams);
@@ -850,7 +892,7 @@ declare class NDKEvent extends EventEmitter {
*
* @returns {string} - Encoded naddr, note or nevent.
*/
encode: () => `nevent1${string}` | `naddr1${string}` | `note1${string}`;
encode: () => `naddr1${string}` | `nevent1${string}` | `note1${string}`;
encrypt: (recipient?: NDKUser | undefined, signer?: NDKSigner | undefined) => Promise<void>;
decrypt: (sender?: NDKUser | undefined, signer?: NDKSigner | undefined) => Promise<void>;
/**
@@ -918,9 +960,11 @@ declare class NDKEvent extends EventEmitter {
* @returns {string} The id
*/
tagAddress(): string;
/** @deprecated Use referenceTags instead. */
/**
* Get the tag that can be used to reference this event from another event
* Get the tag that can be used to reference this event from another event.
*
* Consider using referenceTags() instead (unless you have a good reason to use this)
*
* @example
* event = new NDKEvent(ndk, { kind: 30000, pubkey: 'pubkey', tags: [ ["d", "d-code"] ] });
* event.tagReference(); // ["a", "30000:pubkey:d-code"]
@@ -929,7 +973,7 @@ declare class NDKEvent extends EventEmitter {
* event.tagReference(); // ["e", "eventid"]
* @returns {NDKTag} The NDKTag object referencing this event
*/
tagReference(): NDKTag;
tagReference(marker?: string): NDKTag;
/**
* Get the tags that can be used to reference this event from another event
* @param marker The marker to use in the tag
@@ -941,7 +985,7 @@ declare class NDKEvent extends EventEmitter {
* event.referenceTags(); // [["e", "parent-id"]]
* @returns {NDKTag} The NDKTag object referencing this event
*/
referenceTags(marker?: string): NDKTag[];
referenceTags(marker?: string, skipAuthorTag?: boolean): NDKTag[];
/**
* Provides the filter that will return matching events for this event.
*
@@ -1339,6 +1383,12 @@ type Nip04QueueItem = {
resolve: (value: string) => void;
reject: (reason?: Error) => void;
};
type Nip07RelayMap = {
[key: string]: {
read: boolean;
write: boolean;
};
};
/**
* NDKNip07Signer implements the NDKSigner interface for signing Nostr events
* with a NIP-07 browser extension (e.g., getalby, nos2x).
@@ -1366,6 +1416,7 @@ declare class NDKNip07Signer implements NDKSigner {
* @throws Error if the NIP-07 is not available on the window object.
*/
sign(event: NostrEvent): Promise<string>;
relays(): Promise<NDKRelay[]>;
encrypt(recipient: NDKUser, value: string): Promise<string>;
decrypt(sender: NDKUser, value: string): Promise<string>;
private queueNip04;
@@ -1379,7 +1430,8 @@ declare global {
signEvent(event: NostrEvent): Promise<{
sig: string;
}>;
nip04: {
getRelays?: () => Promise<Nip07RelayMap>;
nip04?: {
encrypt(recipientHexPubKey: string, value: string): Promise<string>;
decrypt(senderHexPubKey: string, value: string): Promise<string>;
};
@@ -1399,62 +1451,6 @@ declare class NDKPrivateKeySigner implements NDKSigner {
decrypt(sender: NDKUser, value: string): Promise<string>;
}
type Nip46PermitCallback = (pubkey: string, method: string, params?: any) => Promise<boolean>;
type Nip46ApplyTokenCallback = (pubkey: string, token: string) => Promise<void>;
interface IEventHandlingStrategy {
handle(backend: NDKNip46Backend, remotePubkey: string, params: string[]): Promise<string | undefined>;
}
/**
* This class implements a NIP-46 backend, meaning that it will hold a private key
* of the npub that wants to be published as.
*
* This backend is meant to be used by an NDKNip46Signer, which is the class that
* should run client-side, where the user wants to sign events from.
*/
declare class NDKNip46Backend {
readonly ndk: NDK;
readonly signer: NDKPrivateKeySigner;
localUser?: NDKUser;
readonly debug: debug.Debugger;
private rpc;
private permitCallback;
/**
* @param ndk The NDK instance to use
* @param privateKey The private key of the npub that wants to be published as
*/
constructor(ndk: NDK, privateKey: string, permitCallback: Nip46PermitCallback);
/**
* This method starts the backend, which will start listening for incoming
* requests.
*/
start(): Promise<void>;
handlers: {
[method: string]: IEventHandlingStrategy;
};
/**
* Enables the user to set a custom strategy for handling incoming events.
* @param method - The method to set the strategy for
* @param strategy - The strategy to set
*/
setStrategy(method: string, strategy: IEventHandlingStrategy): void;
/**
* Overload this method to apply tokens, which can
* wrap permission sets to be applied to a pubkey.
* @param pubkey public key to apply token to
* @param token token to apply
*/
applyToken(pubkey: string, token: string): Promise<void>;
protected handleIncomingEvent(event: NDKEvent): Promise<void>;
decrypt(remotePubkey: string, senderUser: NDKUser, payload: string): Promise<string | undefined>;
encrypt(remotePubkey: string, recipientUser: NDKUser, payload: string): Promise<string | undefined>;
signEvent(remotePubkey: string, params: string[]): Promise<NDKEvent | undefined>;
/**
* This method should be overriden by the user to allow or reject incoming
* connections.
*/
pubkeyAllowed(pubkey: string, method: string, params?: any): Promise<boolean>;
}
interface NDKRpcRequest {
id: string;
pubkey: string;
@@ -1490,16 +1486,84 @@ declare class NDKNostrRpc extends EventEmitter {
sendRequest(remotePubkey: string, method: string, params?: string[], kind?: number, cb?: (res: NDKRpcResponse) => void): Promise<NDKRpcResponse>;
}
type NIP46Method = "connect" | "sign_event" | "encrypt" | "decrypt";
type Nip46PermitCallbackParams = {
/**
* ID of the request
*/
id: string;
pubkey: string;
method: NIP46Method;
params?: any;
};
type Nip46PermitCallback = (params: Nip46PermitCallbackParams) => Promise<boolean>;
type Nip46ApplyTokenCallback = (pubkey: string, token: string) => Promise<void>;
interface IEventHandlingStrategy {
handle(backend: NDKNip46Backend, id: string, remotePubkey: string, params: string[]): Promise<string | undefined>;
}
/**
* This class implements a NIP-46 backend, meaning that it will hold a private key
* of the npub that wants to be published as.
*
* This backend is meant to be used by an NDKNip46Signer, which is the class that
* should run client-side, where the user wants to sign events from.
*/
declare class NDKNip46Backend {
readonly ndk: NDK;
readonly signer: NDKPrivateKeySigner;
localUser?: NDKUser;
readonly debug: debug.Debugger;
rpc: NDKNostrRpc;
private permitCallback;
/**
* @param ndk The NDK instance to use
* @param privateKey The private key of the npub that wants to be published as
*/
constructor(ndk: NDK, privateKey: string, permitCallback: Nip46PermitCallback);
/**
* This method starts the backend, which will start listening for incoming
* requests.
*/
start(): Promise<void>;
handlers: {
[method: string]: IEventHandlingStrategy;
};
/**
* Enables the user to set a custom strategy for handling incoming events.
* @param method - The method to set the strategy for
* @param strategy - The strategy to set
*/
setStrategy(method: string, strategy: IEventHandlingStrategy): void;
/**
* Overload this method to apply tokens, which can
* wrap permission sets to be applied to a pubkey.
* @param pubkey public key to apply token to
* @param token token to apply
*/
applyToken(pubkey: string, token: string): Promise<void>;
protected handleIncomingEvent(event: NDKEvent): Promise<void>;
/**
* This method should be overriden by the user to allow or reject incoming
* connections.
*/
pubkeyAllowed(params: Nip46PermitCallbackParams): Promise<boolean>;
}
/**
* This NDKSigner implements NIP-46, which allows remote signing of events.
* This class is meant to be used client-side, paired with the NDKNip46Backend or a NIP-46 backend (like Nostr-Connect)
*
* @emits authUrl -- Emitted when the user should take an action in certain URL.
* When a client receives this event, it should direct the user
* to go to that URL to authorize the application.
*/
declare class NDKNip46Signer implements NDKSigner {
declare class NDKNip46Signer extends EventEmitter$1 implements NDKSigner {
private ndk;
remoteUser: NDKUser;
remotePubkey: string;
remotePubkey: string | undefined;
token: string | undefined;
localSigner: NDKSigner;
private nip05?;
private rpc;
private debug;
/**
@@ -1514,6 +1578,12 @@ declare class NDKNip46Signer implements NDKSigner {
* @param localSigner - The signer that will be used to request events to be signed
*/
constructor(ndk: NDK, remoteNpub: string, localSigner?: NDKSigner);
/**
* @param ndk - The NDK instance to use
* @param remoteNip05 - The nip05 that wants to be published as
* @param localSigner - The signer that will be used to request events to be signed
*/
constructor(ndk: NDK, remoteNip05: string, localSigner?: NDKSigner);
/**
* @param ndk - The NDK instance to use
* @param remotePubkey - The public key of the npub that wants to be published as
@@ -1567,4 +1637,4 @@ interface NDKZapInvoice {
*/
declare function zapInvoiceFromEvent(event: NDKEvent): NDKZapInvoice | null;
export { Hexpubkey, IEventHandlingStrategy, NDKAppHandlerEvent, NDKArticle, NDKCacheAdapter, NDKConstructorParams, NDKDVMJobFeedback, NDKDVMJobResult, NDKDVMRequest, NDKDvmJobFeedbackStatus, NDKDvmParam, NDKEvent, NDKEventId, NDKFilter, NDKFilterGroupingId, NDKHighlight, NDKKind, NDKList, NDKListItem, NDKListKinds, NDKNip07Signer, NDKNip46Backend, NDKNip46Signer, NDKNostrRpc, NDKPrivateKeySigner, NDKRelay, NDKRelayConnectionStats, NDKRelayList, NDKRelaySet, NDKRelayStatus, NDKRelayUrl, NDKRepost, NDKRpcRequest, NDKRpcResponse, NDKSigner, NDKSubscription, NDKSubscriptionCacheUsage, NDKSubscriptionOptions, NDKTag, NDKTranscriptionDVM, NDKUser, NDKUserParams, NDKUserProfile, NDKZapInvoice, Nip46ApplyTokenCallback, Nip46PermitCallback, NostrEvent, Npub, calculateGroupableId, NDK as default, defaultOpts, mergeFilters, profileFromEvent, serializeProfile, zapInvoiceFromEvent };
export { EventPointer, Hexpubkey, IEventHandlingStrategy, NDKAppHandlerEvent, NDKArticle, NDKCacheAdapter, NDKConstructorParams, NDKDVMJobFeedback, NDKDVMJobResult, NDKDVMRequest, NDKDvmJobFeedbackStatus, NDKDvmParam, NDKEvent, NDKEventId, NDKFilter, NDKFilterGroupingId, NDKHighlight, NDKKind, NDKList, NDKListItem, NDKListKinds, NDKNip07Signer, NDKNip46Backend, NDKNip46Signer, NDKNostrRpc, NDKPrivateKeySigner, NDKRelay, NDKRelayConnectionStats, NDKRelayList, NDKRelaySet, NDKRelayStatus, NDKRelayUrl, NDKRepost, NDKRpcRequest, NDKRpcResponse, NDKSigner, NDKSubscription, NDKSubscriptionCacheUsage, NDKSubscriptionOptions, NDKTag, NDKTranscriptionDVM, NDKUser, NDKUserParams, NDKUserProfile, NDKZapInvoice, NIP46Method, Nip46ApplyTokenCallback, Nip46PermitCallback, Nip46PermitCallbackParams, NostrEvent, Npub, ProfilePointer, calculateGroupableId, NDK as default, defaultOpts, mergeFilters, profileFromEvent, serializeProfile, zapInvoiceFromEvent };