Interface NDKConstructorParams

interface NDKConstructorParams {
    autoConnectUserRelays?: boolean;
    autoFetchUserMutelist?: boolean;
    blacklistRelayUrls?: string[];
    cacheAdapter?: NDKCacheAdapter;
    clientName?: string;
    clientNip89?: string;
    debug?: Debugger;
    devWriteRelayUrls?: string[];
    enableOutboxModel?: boolean;
    explicitRelayUrls?: string[];
    initialValidationRatio?: number;
    lowestValidationRatio?: number;
    mutedIds?: Map<string, string>;
    netDebug?: NDKNetDebug;
    outboxRelayUrls?: string[];
    relayAuthDefaultPolicy?: NDKAuthPolicy;
    signatureVerificationWorker?: Worker;
    signer?: NDKSigner;
    validationRatioFn?: NDKValidationRatioFn;
}

Properties

autoConnectUserRelays?: boolean

Auto-connect to main user's relays. The "main" user is determined by the presence of a signer. Upon connection to the explicit relays, the user's relays will be fetched and connected to if this is set to true.

true
autoFetchUserMutelist?: boolean

Automatically fetch user's mutelist

true
blacklistRelayUrls?: string[]

Relays we should never connect to

cacheAdapter?: NDKCacheAdapter

Cache adapter to use for caching events

clientName?: string

Client name to add to events' tag

clientNip89?: string

Client nip89 to add to events' tag

debug?: Debugger

Debug instance to use

devWriteRelayUrls?: string[]

When this is set, we always write only to this relays.

enableOutboxModel?: boolean

Enable outbox model (defaults to false)

explicitRelayUrls?: string[]

Relays we should explicitly connect to

initialValidationRatio?: number

The signature verification validation ratio for new relays.

lowestValidationRatio?: number

The lowest validation ratio any single relay can have. Relays will have a sample of events verified based on this ratio. When using this, you MUST listen for event:invalid-sig events to handle invalid signatures and disconnect from evil relays.

0.1
mutedIds?: Map<string, string>

Muted pubkeys and eventIds

netDebug?: NDKNetDebug

Provide a caller function to receive all networking traffic from relays

outboxRelayUrls?: string[]

Outbox relay URLs.

relayAuthDefaultPolicy?: NDKAuthPolicy

Default relay-auth policy

signatureVerificationWorker?: Worker

Whether to verify signatures on events synchronously or asynchronously.

undefined

When set to true, the signature verification will processed in a web worker. You should listen for the event:invalid-sig event to handle invalid signatures.

const worker = new Worker("path/to/signature-verification.js");
ndk.delayedSigVerification = worker;
ndk.on("event:invalid-sig", (event) => {
console.error("Invalid signature", event);
signer?: NDKSigner

Signer to use for signing events by default

validationRatioFn?: NDKValidationRatioFn

A function that is invoked to calculate the validation ratio for a relay.