Files
nsecbunkerd/src/daemon/backend/publish-event.ts
2023-05-15 20:05:55 +02:00

13 lines
555 B
TypeScript

import { NDKNip46Backend } from "@nostr-dev-kit/ndk";
import { IEventHandlingStrategy } from '@nostr-dev-kit/ndk/lib/src/signers/nip46/backend';
export default class PublishEventHandlingStrategy implements IEventHandlingStrategy {
async handle(backend: NDKNip46Backend, remotePubkey: string, params: string[]): Promise<string|undefined> {
const event = await backend.signEvent(remotePubkey, params);
if (!event) return undefined;
backend.ndk.publish(event);
return JSON.stringify(await event.toNostrEvent());
}
}