import { API } from '../core/api'; import { ReadableStream } from 'web-streams-polyfill/ponyfill'; /** * IPFS is an API module for working with an underlying IPFS peer * * @extends API */ export default class IPFS extends API { /** * Retrieves underlying IPFS peer ID * @returns The underlying IPFS peer ID */ id(): Promise; /** * Lists the set of peers to which this node is connected * * @param verbose Display all extra information * @param latency Also list information about latency to each peer * @param streams Also list information about open streams for each peer * @param direction Also list information about the direction of connection */ peers(verbose?: boolean, latency?: boolean, streams?: boolean, direction?: boolean): Promise; /** * Retrieves the data behind an IPFS CID path * * @param path IPFS/IPNS CID path * @param key Key to decrypt the underlying data on-the-fly * @returns The underlying data behind the given IPFS CID path */ cat(path: string, key?: string): Promise; /** * Opens a new direct connection to a peer using an IPFS multiaddr * * @param addr Peer IPFS multiaddr * @returns Whether the peer swarm connect was successfull */ connect(addr: string): Promise; /** * Publishes a message to a given pubsub topic * * @param topic The topic to publish to * @param data The payload of message to publish * @returns Whether the publish was successfull */ pubsubPub(topic: string, data: string | object): Promise; /** * Subscribes to messages on a given topic with GET * * @param topic The ipfs pubsub sub topic * @returns A ReadableStream of ArrayBuffer */ pubsubSubGet(topic: string, queryId: string): Promise>; /** * Subscribes to messages on a given topic with EventSource or GET * * @param topic The ipfs pubsub sub topic * @param useEventSource Whether to use EventSource or GET * @returns An object with queryId and EventSource or a ReadableStream of ArrayBuffer */ pubsubSub(topic: string, useEventSource?: boolean): Promise<{ queryId: string; queryHandle: EventSource | ReadableStream; }>; }