strfry-policies/src/types.ts

28 lines
616 B
TypeScript
Raw Normal View History

interface InputMessage {
type: 'new' | 'lookback';
event: Event;
receivedAt: number;
sourceType: 'IP4' | 'IP6' | 'Import' | 'Stream' | 'Sync';
sourceInfo: string;
}
interface OutputMessage {
id: string;
action: 'accept' | 'reject' | 'shadowReject';
msg: string;
}
interface Event<K extends number = number> {
id: string;
sig: string;
kind: K;
tags: string[][];
pubkey: string;
content: string;
created_at: number;
}
2023-03-25 00:55:58 +00:00
type Policy<Opts = unknown> = (msg: InputMessage, opts?: Opts) => Promise<OutputMessage> | OutputMessage;
2023-03-24 19:36:11 +00:00
export type { Event, InputMessage, OutputMessage, Policy };