2022-09-06 12:25:28 +10:00
|
|
|
import type { Stream } from "@libp2p/interface-connection";
|
|
|
|
|
import type { PeerId } from "@libp2p/interface-peer-id";
|
|
|
|
|
import type { Multiaddr } from "@multiformats/multiaddr";
|
|
|
|
|
import type { Libp2p } from "libp2p";
|
|
|
|
|
|
|
|
|
|
import type { Protocols } from "./waku";
|
|
|
|
|
import type { WakuFilter } from "./waku_filter";
|
|
|
|
|
import type { WakuLightPush } from "./waku_light_push";
|
|
|
|
|
import type { WakuRelay } from "./waku_relay";
|
|
|
|
|
import type { WakuStore } from "./waku_store";
|
|
|
|
|
|
|
|
|
|
export interface Waku {
|
|
|
|
|
libp2p: Libp2p;
|
2022-09-07 16:51:43 +10:00
|
|
|
relay?: WakuRelay;
|
|
|
|
|
store?: WakuStore;
|
|
|
|
|
filter?: WakuFilter;
|
|
|
|
|
lightPush?: WakuLightPush;
|
2022-09-06 12:25:28 +10:00
|
|
|
|
|
|
|
|
dial(peer: PeerId | Multiaddr, protocols?: Protocols[]): Promise<Stream>;
|
|
|
|
|
|
|
|
|
|
addPeerToAddressBook(
|
|
|
|
|
peerId: PeerId | string,
|
|
|
|
|
multiaddrs: Multiaddr[] | string[]
|
|
|
|
|
): void;
|
|
|
|
|
|
|
|
|
|
start(): Promise<void>;
|
|
|
|
|
|
|
|
|
|
stop(): Promise<void>;
|
|
|
|
|
|
|
|
|
|
isStarted(): boolean;
|
|
|
|
|
}
|
2022-09-07 16:51:43 +10:00
|
|
|
|
|
|
|
|
export interface WakuLight extends Waku {
|
|
|
|
|
relay: undefined;
|
|
|
|
|
store: WakuStore;
|
|
|
|
|
filter: WakuFilter;
|
|
|
|
|
lightPush: WakuLightPush;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface WakuPrivacy extends Waku {
|
|
|
|
|
relay: WakuRelay;
|
|
|
|
|
store: undefined;
|
|
|
|
|
filter: undefined;
|
|
|
|
|
lightPush: undefined;
|
|
|
|
|
}
|
2022-09-08 11:25:18 +10:00
|
|
|
|
|
|
|
|
export interface WakuFull extends Waku {
|
|
|
|
|
relay: WakuRelay;
|
|
|
|
|
store: WakuStore;
|
|
|
|
|
filter: WakuFilter;
|
|
|
|
|
lightPush: WakuLightPush;
|
|
|
|
|
}
|
2022-09-19 13:50:29 +10:00
|
|
|
|
|
|
|
|
export interface ProtoMessage {
|
|
|
|
|
payload?: Uint8Array;
|
|
|
|
|
contentTopic?: string;
|
|
|
|
|
version?: number;
|
|
|
|
|
timestamp?: bigint;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface Message {
|
|
|
|
|
payload?: Uint8Array;
|
|
|
|
|
contentTopic?: string;
|
|
|
|
|
timestamp?: Date;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface Encoder {
|
|
|
|
|
contentTopic: string;
|
|
|
|
|
encode: (message: Message) => Promise<Uint8Array | undefined>;
|
|
|
|
|
encodeProto: (message: Message) => Promise<ProtoMessage | undefined>;
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-19 16:06:03 +10:00
|
|
|
export interface Decoder<T extends Message> {
|
2022-09-19 13:50:29 +10:00
|
|
|
contentTopic: string;
|
|
|
|
|
decodeProto: (bytes: Uint8Array) => Promise<ProtoMessage | undefined>;
|
2022-09-19 16:06:03 +10:00
|
|
|
decode: (proto: ProtoMessage) => Promise<T | undefined>;
|
2022-09-19 13:50:29 +10:00
|
|
|
}
|
2022-09-20 14:18:32 +10:00
|
|
|
|
|
|
|
|
export interface SendResult {
|
|
|
|
|
recipients: PeerId[];
|
|
|
|
|
}
|