import type { PeerId } from "@libp2p/interface-peer-id"; import type { Peer } from "@libp2p/interface-peer-store"; import type { Libp2p } from "libp2p"; import { Decoder, Message } from "../interfaces"; import { ContentFilter } from "./filter_rpc"; export { ContentFilter }; export declare const FilterCodec = "/vac/waku/filter/2.0.0-beta1"; export interface CreateOptions { /** * The PubSub Topic to use. Defaults to {@link DefaultPubSubTopic}. * * The usage of the default pubsub topic is recommended. * See [Waku v2 Topic Usage Recommendations](https://rfc.vac.dev/spec/23/) for details. * * @default {@link DefaultPubSubTopic} */ pubSubTopic?: string; } export declare type FilterSubscriptionOpts = { /** * The Pubsub topic for the subscription */ pubsubTopic?: string; /** * Optionally specify a PeerId for the subscription. If not included, will use a random peer. */ peerId?: PeerId; }; export declare type FilterCallback = (msg: T) => void | Promise; export declare type UnsubscribeFunction = () => Promise; /** * Implements client side of the [Waku v2 Filter protocol](https://rfc.vac.dev/spec/12/). * * Note this currently only works in NodeJS when the Waku node is listening on a port, see: * - https://github.com/status-im/go-waku/issues/245 * - https://github.com/status-im/nwaku/issues/948 */ export declare class WakuFilter { libp2p: Libp2p; pubSubTopic: string; private subscriptions; private decoders; constructor(libp2p: Libp2p, options?: CreateOptions); /** * @param decoders Array of Decoders to use to decode messages, it also specifies the content topics. * @param callback A function that will be called on each message returned by the filter. * @param opts The FilterSubscriptionOpts used to narrow which messages are returned, and which peer to connect to. * @returns Unsubscribe function that can be used to end the subscription. */ subscribe(decoders: Decoder[], callback: FilterCallback, opts?: FilterSubscriptionOpts): Promise; private onRequest; private pushMessages; private addCallback; private deleteCallback; private addDecoders; private deleteDecoders; private unsubscribe; private newStream; private getPeer; peers(): Promise; randomPeer(): Promise; }