UNPKG

@nostr-dev-kit/ndk

Version:

NDK - Nostr Development Kit. Includes AI Guardrails to catch common mistakes during development.

26 lines (21 loc) 763 B
import type { IEventHandlingStrategy, NDKNip46Backend } from "./index.js"; /** * "ping" method handler. */ export default class PingEventHandlingStrategy implements IEventHandlingStrategy { async handle( backend: NDKNip46Backend, id: string, remotePubkey: string, _params: string[], ): Promise<string | undefined> { const debug = backend.debug.extend("ping"); debug(`ping request from ${remotePubkey}`); if (await backend.pubkeyAllowed({ id, pubkey: remotePubkey, method: "ping" })) { debug(`connection request from ${remotePubkey} allowed`); return "pong"; } debug(`connection request from ${remotePubkey} rejected`); return undefined; } }