mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-04-24 16:32:32 +00:00
chore: remove generated types from vsc
This commit is contained in:
parent
6a95834570
commit
bac57b05dc
258
src/connection/connection.d.ts
vendored
258
src/connection/connection.d.ts
vendored
@ -1,258 +0,0 @@
|
||||
export = Connection;
|
||||
/**
|
||||
* @typedef {import('../stream-muxer/types').MuxedStream} MuxedStream
|
||||
*/
|
||||
/**
|
||||
* @typedef {Object} ConectionStat
|
||||
* @property {string} direction - connection establishment direction ("inbound" or "outbound").
|
||||
* @property {object} timeline - connection relevant events timestamp.
|
||||
* @property {number} timeline.open - connection opening timestamp.
|
||||
* @property {number} [timeline.upgraded] - connection upgraded timestamp.
|
||||
* @property {number} [timeline.close] - connection upgraded timestamp.
|
||||
* @property {string} [multiplexer] - connection multiplexing identifier.
|
||||
* @property {string} [encryption] - connection encryption method identifier.
|
||||
*
|
||||
* @typedef {Object} ConnectionOptions
|
||||
* @property {multiaddr} [localAddr] - local multiaddr of the connection if known.
|
||||
* @property {multiaddr} remoteAddr - remote multiaddr of the connection.
|
||||
* @property {PeerId} localPeer - local peer-id.
|
||||
* @property {PeerId} remotePeer - remote peer-id.
|
||||
* @property {(protocols: string|string[]) => Promise<{stream: MuxedStream, protocol: string}>} newStream - new stream muxer function.
|
||||
* @property {() => Promise<void>} close - close raw connection function.
|
||||
* @property {() => MuxedStream[]} getStreams - get streams from muxer function.
|
||||
* @property {ConectionStat} stat - metadata of the connection.
|
||||
*/
|
||||
/**
|
||||
* An implementation of the js-libp2p connection.
|
||||
* Any libp2p transport should use an upgrader to return this connection.
|
||||
*/
|
||||
declare class Connection {
|
||||
/**
|
||||
* Checks if the given value is a `Connection` instance.
|
||||
*
|
||||
* @param {any} other
|
||||
* @returns {other is Connection}
|
||||
*/
|
||||
static isConnection(other: any): other is Connection;
|
||||
/**
|
||||
* An implementation of the js-libp2p connection.
|
||||
* Any libp2p transport should use an upgrader to return this connection.
|
||||
*
|
||||
* @class
|
||||
* @param {ConnectionOptions} options
|
||||
*/
|
||||
constructor({ localAddr, remoteAddr, localPeer, remotePeer, newStream, close, getStreams, stat }: ConnectionOptions);
|
||||
/**
|
||||
* Connection identifier.
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* Observed multiaddr of the local peer
|
||||
*/
|
||||
localAddr: import("multiaddr") | undefined;
|
||||
/**
|
||||
* Observed multiaddr of the remote peer
|
||||
*/
|
||||
remoteAddr: import("multiaddr");
|
||||
/**
|
||||
* Local peer id.
|
||||
*/
|
||||
localPeer: import("peer-id");
|
||||
/**
|
||||
* Remote peer id.
|
||||
*/
|
||||
remotePeer: import("peer-id");
|
||||
/**
|
||||
* Connection metadata.
|
||||
*/
|
||||
_stat: {
|
||||
status: "open";
|
||||
/**
|
||||
* - connection establishment direction ("inbound" or "outbound").
|
||||
*/
|
||||
direction: string;
|
||||
/**
|
||||
* - connection relevant events timestamp.
|
||||
*/
|
||||
timeline: {
|
||||
open: number;
|
||||
upgraded: number | undefined;
|
||||
close: number | undefined;
|
||||
};
|
||||
/**
|
||||
* - connection multiplexing identifier.
|
||||
*/
|
||||
multiplexer?: string | undefined;
|
||||
/**
|
||||
* - connection encryption method identifier.
|
||||
*/
|
||||
encryption?: string | undefined;
|
||||
};
|
||||
/**
|
||||
* Reference to the new stream function of the multiplexer
|
||||
*/
|
||||
_newStream: (protocols: string | string[]) => Promise<{
|
||||
stream: MuxedStream;
|
||||
protocol: string;
|
||||
}>;
|
||||
/**
|
||||
* Reference to the close function of the raw connection
|
||||
*/
|
||||
_close: () => Promise<void>;
|
||||
/**
|
||||
* Reference to the getStreams function of the muxer
|
||||
*/
|
||||
_getStreams: () => MuxedStream[];
|
||||
/**
|
||||
* Connection streams registry
|
||||
*/
|
||||
registry: Map<any, any>;
|
||||
/**
|
||||
* User provided tags
|
||||
*
|
||||
* @type {string[]}
|
||||
*/
|
||||
tags: string[];
|
||||
get [Symbol.toStringTag](): string;
|
||||
/**
|
||||
* Get connection metadata
|
||||
*
|
||||
* @this {Connection}
|
||||
*/
|
||||
get stat(): {
|
||||
status: "open";
|
||||
/**
|
||||
* - connection establishment direction ("inbound" or "outbound").
|
||||
*/
|
||||
direction: string;
|
||||
/**
|
||||
* - connection relevant events timestamp.
|
||||
*/
|
||||
timeline: {
|
||||
open: number;
|
||||
upgraded: number | undefined;
|
||||
close: number | undefined;
|
||||
};
|
||||
/**
|
||||
* - connection multiplexing identifier.
|
||||
*/
|
||||
multiplexer?: string | undefined;
|
||||
/**
|
||||
* - connection encryption method identifier.
|
||||
*/
|
||||
encryption?: string | undefined;
|
||||
};
|
||||
/**
|
||||
* Get all the streams of the muxer.
|
||||
*
|
||||
* @this {Connection}
|
||||
*/
|
||||
get streams(): import("../stream-muxer/types").MuxedStream[];
|
||||
/**
|
||||
* Create a new stream from this connection
|
||||
*
|
||||
* @param {string|string[]} protocols - intended protocol for the stream
|
||||
* @returns {Promise<{stream: MuxedStream, protocol: string}>} with muxed+multistream-selected stream and selected protocol
|
||||
*/
|
||||
newStream(protocols: string | string[]): Promise<{
|
||||
stream: MuxedStream;
|
||||
protocol: string;
|
||||
}>;
|
||||
/**
|
||||
* Add a stream when it is opened to the registry.
|
||||
*
|
||||
* @param {MuxedStream} muxedStream - a muxed stream
|
||||
* @param {object} properties - the stream properties to be registered
|
||||
* @param {string} properties.protocol - the protocol used by the stream
|
||||
* @param {object} properties.metadata - metadata of the stream
|
||||
* @returns {void}
|
||||
*/
|
||||
addStream(muxedStream: MuxedStream, { protocol, metadata }: {
|
||||
protocol: string;
|
||||
metadata: object;
|
||||
}): void;
|
||||
/**
|
||||
* Remove stream registry after it is closed.
|
||||
*
|
||||
* @param {string} id - identifier of the stream
|
||||
*/
|
||||
removeStream(id: string): void;
|
||||
/**
|
||||
* Close the connection.
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
close(): Promise<void>;
|
||||
_closing: void | undefined;
|
||||
}
|
||||
declare namespace Connection {
|
||||
export { MuxedStream, ConectionStat, ConnectionOptions };
|
||||
}
|
||||
type MuxedStream = {
|
||||
close: () => void;
|
||||
abort: () => void;
|
||||
reset: () => void;
|
||||
sink: (source: Uint8Array) => Promise<Uint8Array>;
|
||||
source: () => AsyncIterable<Uint8Array>;
|
||||
timeline: import("../stream-muxer/types").MuxedTimeline;
|
||||
id: string;
|
||||
};
|
||||
type ConnectionOptions = {
|
||||
/**
|
||||
* - local multiaddr of the connection if known.
|
||||
*/
|
||||
localAddr?: import("multiaddr") | undefined;
|
||||
/**
|
||||
* - remote multiaddr of the connection.
|
||||
*/
|
||||
remoteAddr: import("multiaddr");
|
||||
/**
|
||||
* - local peer-id.
|
||||
*/
|
||||
localPeer: import("peer-id");
|
||||
/**
|
||||
* - remote peer-id.
|
||||
*/
|
||||
remotePeer: import("peer-id");
|
||||
/**
|
||||
* - new stream muxer function.
|
||||
*/
|
||||
newStream: (protocols: string | string[]) => Promise<{
|
||||
stream: MuxedStream;
|
||||
protocol: string;
|
||||
}>;
|
||||
/**
|
||||
* - close raw connection function.
|
||||
*/
|
||||
close: () => Promise<void>;
|
||||
/**
|
||||
* - get streams from muxer function.
|
||||
*/
|
||||
getStreams: () => MuxedStream[];
|
||||
/**
|
||||
* - metadata of the connection.
|
||||
*/
|
||||
stat: ConectionStat;
|
||||
};
|
||||
type ConectionStat = {
|
||||
/**
|
||||
* - connection establishment direction ("inbound" or "outbound").
|
||||
*/
|
||||
direction: string;
|
||||
/**
|
||||
* - connection relevant events timestamp.
|
||||
*/
|
||||
timeline: {
|
||||
open: number;
|
||||
upgraded: number | undefined;
|
||||
close: number | undefined;
|
||||
};
|
||||
/**
|
||||
* - connection multiplexing identifier.
|
||||
*/
|
||||
multiplexer?: string | undefined;
|
||||
/**
|
||||
* - connection encryption method identifier.
|
||||
*/
|
||||
encryption?: string | undefined;
|
||||
};
|
1
src/connection/index.d.ts
vendored
1
src/connection/index.d.ts
vendored
@ -1 +0,0 @@
|
||||
export var Connection: typeof import('./connection');
|
3
src/connection/status.d.ts
vendored
3
src/connection/status.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
export const OPEN: 'open';
|
||||
export const CLOSING: 'closing';
|
||||
export const CLOSED: 'closed';
|
15
src/crypto/errors.d.ts
vendored
15
src/crypto/errors.d.ts
vendored
@ -1,15 +0,0 @@
|
||||
export class UnexpectedPeerError extends Error {
|
||||
static get code(): string;
|
||||
constructor(message?: string);
|
||||
code: string;
|
||||
}
|
||||
export class InvalidCryptoExchangeError extends Error {
|
||||
static get code(): string;
|
||||
constructor(message?: string);
|
||||
code: string;
|
||||
}
|
||||
export class InvalidCryptoTransmissionError extends Error {
|
||||
static get code(): string;
|
||||
constructor(message?: string);
|
||||
code: string;
|
||||
}
|
0
src/index.d.ts
vendored
0
src/index.d.ts
vendored
11
src/pubsub/errors.d.ts
vendored
11
src/pubsub/errors.d.ts
vendored
@ -1,11 +0,0 @@
|
||||
export namespace codes {
|
||||
const ERR_INVALID_SIGNATURE_POLICY: string;
|
||||
const ERR_UNHANDLED_SIGNATURE_POLICY: string;
|
||||
const ERR_MISSING_SIGNATURE: string;
|
||||
const ERR_MISSING_SEQNO: string;
|
||||
const ERR_INVALID_SIGNATURE: string;
|
||||
const ERR_UNEXPECTED_FROM: string;
|
||||
const ERR_UNEXPECTED_SIGNATURE: string;
|
||||
const ERR_UNEXPECTED_KEY: string;
|
||||
const ERR_UNEXPECTED_SEQNO: string;
|
||||
}
|
332
src/pubsub/index.d.ts
vendored
332
src/pubsub/index.d.ts
vendored
@ -1,332 +0,0 @@
|
||||
export = PubsubBaseProtocol;
|
||||
/**
|
||||
* @typedef {Object} InMessage
|
||||
* @property {string} [from]
|
||||
* @property {string} receivedFrom
|
||||
* @property {string[]} topicIDs
|
||||
* @property {Uint8Array} [seqno]
|
||||
* @property {Uint8Array} data
|
||||
* @property {Uint8Array} [signature]
|
||||
* @property {Uint8Array} [key]
|
||||
*
|
||||
* @typedef PeerId
|
||||
* @type import('peer-id')
|
||||
*/
|
||||
/**
|
||||
* PubsubBaseProtocol handles the peers and connections logic for pubsub routers
|
||||
* and specifies the API that pubsub routers should have.
|
||||
*/
|
||||
declare class PubsubBaseProtocol {
|
||||
/**
|
||||
* @param {Object} props
|
||||
* @param {string} props.debugName - log namespace
|
||||
* @param {Array<string>|string} props.multicodecs - protocol identificers to connect
|
||||
* @param {Libp2p} props.libp2p
|
||||
* @param {SignaturePolicy} [props.globalSignaturePolicy = SignaturePolicy.StrictSign] - defines how signatures should be handled
|
||||
* @param {boolean} [props.canRelayMessage = false] - if can relay messages not subscribed
|
||||
* @param {boolean} [props.emitSelf = false] - if publish should emit to self, if subscribed
|
||||
* @abstract
|
||||
*/
|
||||
constructor({ debugName, multicodecs, libp2p, globalSignaturePolicy, canRelayMessage, emitSelf }: {
|
||||
debugName: string;
|
||||
multicodecs: Array<string> | string;
|
||||
libp2p: any;
|
||||
globalSignaturePolicy: any;
|
||||
canRelayMessage: boolean | undefined;
|
||||
emitSelf: boolean | undefined;
|
||||
});
|
||||
log: any;
|
||||
/**
|
||||
* @type {Array<string>}
|
||||
*/
|
||||
multicodecs: Array<string>;
|
||||
_libp2p: any;
|
||||
registrar: any;
|
||||
/**
|
||||
* @type {PeerId}
|
||||
*/
|
||||
peerId: PeerId;
|
||||
started: boolean;
|
||||
/**
|
||||
* Map of topics to which peers are subscribed to
|
||||
*
|
||||
* @type {Map<string, Set<string>>}
|
||||
*/
|
||||
topics: Map<string, Set<string>>;
|
||||
/**
|
||||
* List of our subscriptions
|
||||
*
|
||||
* @type {Set<string>}
|
||||
*/
|
||||
subscriptions: Set<string>;
|
||||
/**
|
||||
* Map of peer streams
|
||||
*
|
||||
* @type {Map<string, import('./peer-streams')>}
|
||||
*/
|
||||
peers: Map<string, import('./peer-streams')>;
|
||||
/**
|
||||
* The signature policy to follow by default
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
globalSignaturePolicy: string;
|
||||
/**
|
||||
* If router can relay received messages, even if not subscribed
|
||||
*
|
||||
* @type {boolean}
|
||||
*/
|
||||
canRelayMessage: boolean;
|
||||
/**
|
||||
* if publish should emit to self, if subscribed
|
||||
*
|
||||
* @type {boolean}
|
||||
*/
|
||||
emitSelf: boolean;
|
||||
/**
|
||||
* Topic validator function
|
||||
*
|
||||
* @typedef {function(string, InMessage): Promise<void>} validator
|
||||
*/
|
||||
/**
|
||||
* Topic validator map
|
||||
*
|
||||
* Keyed by topic
|
||||
* Topic validators are functions with the following input:
|
||||
*
|
||||
* @type {Map<string, validator>}
|
||||
*/
|
||||
topicValidators: Map<string, (arg0: string, arg1: InMessage) => Promise<void>>;
|
||||
_registrarId: any;
|
||||
/**
|
||||
* On an inbound stream opened.
|
||||
*
|
||||
* @private
|
||||
* @param {Object} props
|
||||
* @param {string} props.protocol
|
||||
* @param {DuplexIterableStream} props.stream
|
||||
* @param {Connection} props.connection - connection
|
||||
*/
|
||||
private _onIncomingStream;
|
||||
/**
|
||||
* Registrar notifies an established connection with pubsub protocol.
|
||||
*
|
||||
* @private
|
||||
* @param {PeerId} peerId - remote peer-id
|
||||
* @param {Connection} conn - connection to the peer
|
||||
*/
|
||||
private _onPeerConnected;
|
||||
/**
|
||||
* Registrar notifies a closing connection with pubsub protocol.
|
||||
*
|
||||
* @private
|
||||
* @param {PeerId} peerId - peerId
|
||||
* @param {Error} err - error for connection end
|
||||
*/
|
||||
private _onPeerDisconnected;
|
||||
/**
|
||||
* Register the pubsub protocol onto the libp2p node.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
start(): void;
|
||||
/**
|
||||
* Unregister the pubsub protocol and the streams with other peers will be closed.
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
stop(): void;
|
||||
/**
|
||||
* Notifies the router that a peer has been connected
|
||||
*
|
||||
* @private
|
||||
* @param {PeerId} peerId
|
||||
* @param {string} protocol
|
||||
* @returns {PeerStreams}
|
||||
*/
|
||||
private _addPeer;
|
||||
/**
|
||||
* Notifies the router that a peer has been disconnected.
|
||||
*
|
||||
* @private
|
||||
* @param {PeerId} peerId
|
||||
* @returns {PeerStreams | undefined}
|
||||
*/
|
||||
private _removePeer;
|
||||
/**
|
||||
* Responsible for processing each RPC message received by other peers.
|
||||
*
|
||||
* @param {string} idB58Str - peer id string in base58
|
||||
* @param {DuplexIterableStream} stream - inbound stream
|
||||
* @param {PeerStreams} peerStreams - PubSub peer
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
_processMessages(idB58Str: string, stream: any, peerStreams: import("./peer-streams")): Promise<void>;
|
||||
/**
|
||||
* Handles an rpc request from a peer
|
||||
*
|
||||
* @param {string} idB58Str
|
||||
* @param {PeerStreams} peerStreams
|
||||
* @param {RPC} rpc
|
||||
* @returns {boolean}
|
||||
*/
|
||||
_processRpc(idB58Str: string, peerStreams: import("./peer-streams"), rpc: any): boolean;
|
||||
/**
|
||||
* Handles a subscription change from a peer
|
||||
*
|
||||
* @param {string} id
|
||||
* @param {RPC.SubOpt} subOpt
|
||||
*/
|
||||
_processRpcSubOpt(id: string, subOpt: any): void;
|
||||
/**
|
||||
* Handles an message from a peer
|
||||
*
|
||||
* @param {InMessage} msg
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
_processRpcMessage(msg: InMessage): Promise<void>;
|
||||
/**
|
||||
* Emit a message from a peer
|
||||
*
|
||||
* @param {InMessage} message
|
||||
*/
|
||||
_emitMessage(message: InMessage): void;
|
||||
/**
|
||||
* The default msgID implementation
|
||||
* Child class can override this.
|
||||
*
|
||||
* @param {RPC.Message} msg - the message object
|
||||
* @returns {Uint8Array} message id as bytes
|
||||
*/
|
||||
getMsgId(msg: any): Uint8Array;
|
||||
/**
|
||||
* Whether to accept a message from a peer
|
||||
* Override to create a graylist
|
||||
*
|
||||
* @override
|
||||
* @param {string} id
|
||||
* @returns {boolean}
|
||||
*/
|
||||
_acceptFrom(id: string): boolean;
|
||||
/**
|
||||
* Decode Uint8Array into an RPC object.
|
||||
* This can be override to use a custom router protobuf.
|
||||
*
|
||||
* @param {Uint8Array} bytes
|
||||
* @returns {RPC}
|
||||
*/
|
||||
_decodeRpc(bytes: Uint8Array): any;
|
||||
/**
|
||||
* Encode RPC object into a Uint8Array.
|
||||
* This can be override to use a custom router protobuf.
|
||||
*
|
||||
* @param {RPC} rpc
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
_encodeRpc(rpc: any): Uint8Array;
|
||||
/**
|
||||
* Send an rpc object to a peer
|
||||
*
|
||||
* @param {string} id - peer id
|
||||
* @param {RPC} rpc
|
||||
* @returns {void}
|
||||
*/
|
||||
_sendRpc(id: string, rpc: any): void;
|
||||
/**
|
||||
* Send subscroptions to a peer
|
||||
*
|
||||
* @param {string} id - peer id
|
||||
* @param {string[]} topics
|
||||
* @param {boolean} subscribe - set to false for unsubscriptions
|
||||
* @returns {void}
|
||||
*/
|
||||
_sendSubscriptions(id: string, topics: string[], subscribe: boolean): void;
|
||||
/**
|
||||
* Validates the given message. The signature will be checked for authenticity.
|
||||
* Throws an error on invalid messages
|
||||
*
|
||||
* @param {InMessage} message
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
validate(message: InMessage): Promise<void>;
|
||||
/**
|
||||
* Normalizes the message and signs it, if signing is enabled.
|
||||
* Should be used by the routers to create the message to send.
|
||||
*
|
||||
* @private
|
||||
* @param {Message} message
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
private _buildMessage;
|
||||
/**
|
||||
* Get a list of the peer-ids that are subscribed to one topic.
|
||||
*
|
||||
* @param {string} topic
|
||||
* @returns {Array<string>}
|
||||
*/
|
||||
getSubscribers(topic: string): Array<string>;
|
||||
/**
|
||||
* Publishes messages to all subscribed peers
|
||||
*
|
||||
* @override
|
||||
* @param {string} topic
|
||||
* @param {Buffer} message
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
publish(topic: string, message: Buffer): Promise<void>;
|
||||
/**
|
||||
* Overriding the implementation of publish should handle the appropriate algorithms for the publish/subscriber implementation.
|
||||
* For example, a Floodsub implementation might simply publish each message to each topic for every peer
|
||||
*
|
||||
* @abstract
|
||||
* @param {InMessage} message
|
||||
* @returns {Promise<void>}
|
||||
*
|
||||
*/
|
||||
_publish(message: InMessage): Promise<void>;
|
||||
/**
|
||||
* Subscribes to a given topic.
|
||||
*
|
||||
* @abstract
|
||||
* @param {string} topic
|
||||
* @returns {void}
|
||||
*/
|
||||
subscribe(topic: string): void;
|
||||
/**
|
||||
* Unsubscribe from the given topic.
|
||||
*
|
||||
* @override
|
||||
* @param {string} topic
|
||||
* @returns {void}
|
||||
*/
|
||||
unsubscribe(topic: string): void;
|
||||
/**
|
||||
* Get the list of topics which the peer is subscribed to.
|
||||
*
|
||||
* @override
|
||||
* @returns {Array<string>}
|
||||
*/
|
||||
getTopics(): Array<string>;
|
||||
}
|
||||
declare namespace PubsubBaseProtocol {
|
||||
export { message, utils, SignaturePolicy, InMessage, PeerId };
|
||||
}
|
||||
type PeerId = import("peer-id");
|
||||
type InMessage = {
|
||||
from?: string | undefined;
|
||||
receivedFrom: string;
|
||||
topicIDs: string[];
|
||||
seqno?: Uint8Array | undefined;
|
||||
data: Uint8Array;
|
||||
signature?: Uint8Array | undefined;
|
||||
key?: Uint8Array | undefined;
|
||||
};
|
||||
/**
|
||||
* @type {typeof import('./message')}
|
||||
*/
|
||||
declare const message: typeof import('./message');
|
||||
declare const utils: typeof import("./utils");
|
||||
declare const SignaturePolicy: {
|
||||
StrictSign: "StrictSign";
|
||||
StrictNoSign: string;
|
||||
};
|
5
src/pubsub/message/index.d.ts
vendored
5
src/pubsub/message/index.d.ts
vendored
@ -1,5 +0,0 @@
|
||||
export var rpc: any;
|
||||
export var td: any;
|
||||
export var RPC: any;
|
||||
export var Message: any;
|
||||
export var SubOpts: any;
|
2
src/pubsub/message/rpc.proto.d.ts
vendored
2
src/pubsub/message/rpc.proto.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
declare const _exports: string;
|
||||
export = _exports;
|
24
src/pubsub/message/sign.d.ts
vendored
24
src/pubsub/message/sign.d.ts
vendored
@ -1,24 +0,0 @@
|
||||
/**
|
||||
* Returns the PublicKey associated with the given message.
|
||||
* If no, valid PublicKey can be retrieved an error will be returned.
|
||||
*
|
||||
* @param {InMessage} message
|
||||
* @returns {Promise<PublicKey>}
|
||||
*/
|
||||
export function messagePublicKey(message: any): Promise<any>;
|
||||
/**
|
||||
* Signs the provided message with the given `peerId`
|
||||
*
|
||||
* @param {PeerId} peerId
|
||||
* @param {Message} message
|
||||
* @returns {Promise<Message>}
|
||||
*/
|
||||
export function signMessage(peerId: import("peer-id"), message: any): Promise<any>;
|
||||
export const SignPrefix: any;
|
||||
/**
|
||||
* Verifies the signature of the given message
|
||||
*
|
||||
* @param {InMessage} message
|
||||
* @returns {Promise<boolean>}
|
||||
*/
|
||||
export function verifySignature(message: any): Promise<boolean>;
|
@ -1,2 +0,0 @@
|
||||
declare const _exports: string;
|
||||
export = _exports;
|
119
src/pubsub/peer-streams.d.ts
vendored
119
src/pubsub/peer-streams.d.ts
vendored
@ -1,119 +0,0 @@
|
||||
export = PeerStreams;
|
||||
/**
|
||||
* @callback Sink
|
||||
* @param {Uint8Array} source
|
||||
* @returns {Promise<Uint8Array>}
|
||||
*
|
||||
* @typedef {object} DuplexIterableStream
|
||||
* @property {Sink} sink
|
||||
* @property {() AsyncIterator<Uint8Array>} source
|
||||
*
|
||||
* @typedef PeerId
|
||||
* @type import('peer-id')
|
||||
*/
|
||||
/**
|
||||
* Thin wrapper around a peer's inbound / outbound pubsub streams
|
||||
*/
|
||||
declare class PeerStreams {
|
||||
/**
|
||||
* @param {object} properties - properties of the PeerStreams.
|
||||
* @param {PeerId} properties.id
|
||||
* @param {string} properties.protocol
|
||||
*/
|
||||
constructor({ id, protocol }: {
|
||||
id: PeerId;
|
||||
protocol: string;
|
||||
});
|
||||
/**
|
||||
* @type {import('peer-id')}
|
||||
*/
|
||||
id: import('peer-id');
|
||||
/**
|
||||
* Established protocol
|
||||
*
|
||||
* @type {string}
|
||||
*/
|
||||
protocol: string;
|
||||
/**
|
||||
* The raw outbound stream, as retrieved from conn.newStream
|
||||
*
|
||||
* @private
|
||||
* @type {DuplexIterableStream}
|
||||
*/
|
||||
private _rawOutboundStream;
|
||||
/**
|
||||
* The raw inbound stream, as retrieved from the callback from libp2p.handle
|
||||
*
|
||||
* @private
|
||||
* @type {DuplexIterableStream}
|
||||
*/
|
||||
private _rawInboundStream;
|
||||
/**
|
||||
* An AbortController for controlled shutdown of the inbound stream
|
||||
*
|
||||
* @private
|
||||
* @type {typeof AbortController}
|
||||
*/
|
||||
private _inboundAbortController;
|
||||
/**
|
||||
* Write stream -- its preferable to use the write method
|
||||
*
|
||||
* @type {import('it-pushable').Pushable<Uint8Array>>}
|
||||
*/
|
||||
outboundStream: import('it-pushable').Pushable<Uint8Array>;
|
||||
/**
|
||||
* Read stream
|
||||
*
|
||||
* @type {DuplexIterableStream}
|
||||
*/
|
||||
inboundStream: DuplexIterableStream;
|
||||
/**
|
||||
* Do we have a connection to read from?
|
||||
*
|
||||
* @type {boolean}
|
||||
*/
|
||||
get isReadable(): boolean;
|
||||
/**
|
||||
* Do we have a connection to write on?
|
||||
*
|
||||
* @type {boolean}
|
||||
*/
|
||||
get isWritable(): boolean;
|
||||
/**
|
||||
* Send a message to this peer.
|
||||
* Throws if there is no `stream` to write to available.
|
||||
*
|
||||
* @param {Uint8Array} data
|
||||
* @returns {void}
|
||||
*/
|
||||
write(data: Uint8Array): void;
|
||||
/**
|
||||
* Attach a raw inbound stream and setup a read stream
|
||||
*
|
||||
* @param {DuplexIterableStream} stream
|
||||
* @returns {void}
|
||||
*/
|
||||
attachInboundStream(stream: DuplexIterableStream): void;
|
||||
/**
|
||||
* Attach a raw outbound stream and setup a write stream
|
||||
*
|
||||
* @param {Stream} stream
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
attachOutboundStream(stream: any): Promise<void>;
|
||||
/**
|
||||
* Closes the open connection to peer
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
close(): void;
|
||||
}
|
||||
declare namespace PeerStreams {
|
||||
export { Sink, DuplexIterableStream, PeerId };
|
||||
}
|
||||
type DuplexIterableStream = {
|
||||
sink: Sink;
|
||||
source: () => AsyncIterator<Uint8Array>;
|
||||
};
|
||||
type PeerId = import("peer-id");
|
||||
type Sink = (source: Uint8Array) => Promise<Uint8Array>;
|
4
src/pubsub/signature-policy.d.ts
vendored
4
src/pubsub/signature-policy.d.ts
vendored
@ -1,4 +0,0 @@
|
||||
export namespace SignaturePolicy {
|
||||
const StrictSign: 'StrictSign';
|
||||
const StrictNoSign: string;
|
||||
}
|
13
src/pubsub/utils.d.ts
vendored
13
src/pubsub/utils.d.ts
vendored
@ -1,13 +0,0 @@
|
||||
export function randomSeqno(): Uint8Array;
|
||||
export function msgId(from: string, seqno: Uint8Array): Uint8Array;
|
||||
export function noSignMsgId(data: Uint8Array): Uint8Array;
|
||||
export function anyMatch(a: Set<any> | any[], b: Set<any> | any[]): boolean;
|
||||
export function ensureArray<T>(maybeArray: T | T[]): T[];
|
||||
export function normalizeInRpcMessage<T extends unknown>(message: T, peerId?: string | undefined): T & {
|
||||
from?: string | undefined;
|
||||
peerId?: string | undefined;
|
||||
};
|
||||
export function normalizeOutRpcMessage<T extends unknown>(message: T): T & {
|
||||
from?: Uint8Array | undefined;
|
||||
data?: Uint8Array | undefined;
|
||||
};
|
26
src/record/index.d.ts
vendored
26
src/record/index.d.ts
vendored
@ -1,26 +0,0 @@
|
||||
export = Record;
|
||||
/**
|
||||
* Record is the base implementation of a record that can be used as the payload of a libp2p envelope.
|
||||
*/
|
||||
declare class Record {
|
||||
/**
|
||||
* @class
|
||||
* @param {string} domain - signature domain
|
||||
* @param {Uint8Array} codec - identifier of the type of record
|
||||
*/
|
||||
constructor(domain: string, codec: Uint8Array);
|
||||
domain: string;
|
||||
codec: Uint8Array;
|
||||
/**
|
||||
* Marshal a record to be used in an envelope.
|
||||
* @returns {Uint8Array}
|
||||
*/
|
||||
marshal(): Uint8Array;
|
||||
/**
|
||||
* Verifies if the other provided Record is identical to this one.
|
||||
*
|
||||
* @param {Record} other
|
||||
* @returns {boolean}
|
||||
*/
|
||||
equals(other: Record): boolean;
|
||||
}
|
38
src/stream-muxer/types.d.ts
vendored
38
src/stream-muxer/types.d.ts
vendored
@ -1,38 +0,0 @@
|
||||
/**
|
||||
* A libp2p stream muxer
|
||||
*/
|
||||
export interface StreamMuxerInterface {
|
||||
readonly streams: Array<MuxedStream>;
|
||||
/**
|
||||
* Initiate a new stream with the given name. If no name is
|
||||
* provided, the id of th stream will be used.
|
||||
*
|
||||
* @param {string} [name] - If name is not a string it will be cast to one
|
||||
* @returns {Stream}
|
||||
*/
|
||||
newStream(name?: string): MuxedStream;
|
||||
onStream(stream: MuxedStream): void;
|
||||
onStreamEnd(stream: MuxedStream): void;
|
||||
}
|
||||
export declare class Muxer implements StreamMuxerInterface {
|
||||
multicodec: string;
|
||||
readonly streams: Array<MuxedStream>;
|
||||
newStream(name?: string): MuxedStream;
|
||||
onStream(stream: MuxedStream): void;
|
||||
onStreamEnd(stream: MuxedStream): void;
|
||||
}
|
||||
export declare type MuxedTimeline = {
|
||||
open: number;
|
||||
close?: number;
|
||||
};
|
||||
export declare type MuxedStream = {
|
||||
close: () => void;
|
||||
abort: () => void;
|
||||
reset: () => void;
|
||||
sink: Sink;
|
||||
source: () => AsyncIterable<Uint8Array>;
|
||||
timeline: MuxedTimeline;
|
||||
id: string;
|
||||
};
|
||||
declare type Sink = (source: Uint8Array) => Promise<Uint8Array>;
|
||||
export {};
|
74
src/topology/index.d.ts
vendored
74
src/topology/index.d.ts
vendored
@ -1,74 +0,0 @@
|
||||
export = Topology;
|
||||
/**
|
||||
* @typedef {import('peer-id')} PeerId
|
||||
*/
|
||||
/**
|
||||
* @typedef {Object} Options
|
||||
* @property {number} [min=0] - minimum needed connections.
|
||||
* @property {number} [max=Infinity] - maximum needed connections.
|
||||
* @property {Handlers} [handlers]
|
||||
*
|
||||
* @typedef {Object} Handlers
|
||||
* @property {(peerId: PeerId, conn: import('../connection')) => void} [onConnect] - protocol "onConnect" handler
|
||||
* @property {(peerId: PeerId) => void} [onDisconnect] - protocol "onDisconnect" handler
|
||||
*/
|
||||
declare class Topology {
|
||||
/**
|
||||
* Checks if the given value is a Topology instance.
|
||||
*
|
||||
* @param {any} other
|
||||
* @returns {other is Topology}
|
||||
*/
|
||||
static isTopology(other: any): other is Topology;
|
||||
/**
|
||||
* @param {Options} options
|
||||
*/
|
||||
constructor({ min, max, handlers }: Options);
|
||||
min: number;
|
||||
max: number;
|
||||
_onConnect: (peerId: PeerId, conn: import('../connection')) => void;
|
||||
_onDisconnect: (peerId: PeerId) => void;
|
||||
/**
|
||||
* Set of peers that support the protocol.
|
||||
*
|
||||
* @type {Set<string>}
|
||||
*/
|
||||
peers: Set<string>;
|
||||
get [Symbol.toStringTag](): string;
|
||||
set registrar(arg: any);
|
||||
_registrar: any;
|
||||
/**
|
||||
* Notify about peer disconnected event.
|
||||
*
|
||||
* @param {PeerId} peerId
|
||||
* @returns {void}
|
||||
*/
|
||||
disconnect(peerId: PeerId): void;
|
||||
get [topologySymbol](): boolean;
|
||||
}
|
||||
declare namespace Topology {
|
||||
export { PeerId, Options, Handlers };
|
||||
}
|
||||
type PeerId = import("peer-id");
|
||||
declare const topologySymbol: unique symbol;
|
||||
type Options = {
|
||||
/**
|
||||
* - minimum needed connections.
|
||||
*/
|
||||
min?: number | undefined;
|
||||
/**
|
||||
* - maximum needed connections.
|
||||
*/
|
||||
max?: number | undefined;
|
||||
handlers?: Handlers | undefined;
|
||||
};
|
||||
type Handlers = {
|
||||
/**
|
||||
* - protocol "onConnect" handler
|
||||
*/
|
||||
onConnect?: ((peerId: PeerId, conn: import('../connection')) => void) | undefined;
|
||||
/**
|
||||
* - protocol "onDisconnect" handler
|
||||
*/
|
||||
onDisconnect?: ((peerId: PeerId) => void) | undefined;
|
||||
};
|
81
src/topology/multicodec-topology.d.ts
vendored
81
src/topology/multicodec-topology.d.ts
vendored
@ -1,81 +0,0 @@
|
||||
export = MulticodecTopology;
|
||||
declare const MulticodecTopology_base: typeof import(".");
|
||||
declare class MulticodecTopology extends MulticodecTopology_base {
|
||||
/**
|
||||
* Checks if the given value is a `MulticodecTopology` instance.
|
||||
*
|
||||
* @param {any} other
|
||||
* @returns {other is MulticodecTopology}
|
||||
*/
|
||||
static isMulticodecTopology(other: any): other is MulticodecTopology;
|
||||
/**
|
||||
* @param {TopologyOptions & MulticodecOptions} props
|
||||
*/
|
||||
constructor({ min, max, multicodecs, handlers }: TopologyOptions & MulticodecOptions);
|
||||
multicodecs: string[];
|
||||
/**
|
||||
* Check if a new peer support the multicodecs for this topology.
|
||||
*
|
||||
* @param {Object} props
|
||||
* @param {PeerId} props.peerId
|
||||
* @param {Array<string>} props.protocols
|
||||
*/
|
||||
_onProtocolChange({ peerId, protocols }: {
|
||||
peerId: PeerId;
|
||||
protocols: Array<string>;
|
||||
}): void;
|
||||
/**
|
||||
* Verify if a new connected peer has a topology multicodec and call _onConnect.
|
||||
*
|
||||
* @param {Connection} connection
|
||||
* @returns {void}
|
||||
*/
|
||||
_onPeerConnect(connection: Connection): void;
|
||||
/**
|
||||
* Update topology.
|
||||
*
|
||||
* @param {Array<{id: PeerId, multiaddrs: Array<Multiaddr>, protocols: Array<string>}>} peerDataIterable
|
||||
* @returns {void}
|
||||
*/
|
||||
_updatePeers(peerDataIterable: Array<{
|
||||
id: PeerId;
|
||||
multiaddrs: Array<Multiaddr>;
|
||||
protocols: Array<string>;
|
||||
}>): void;
|
||||
get [multicodecTopologySymbol](): boolean;
|
||||
}
|
||||
declare namespace MulticodecTopology {
|
||||
export { PeerId, Multiaddr, Connection, TopologyOptions, MulticodecOptions, Handlers };
|
||||
}
|
||||
type PeerId = import("peer-id");
|
||||
type Connection = typeof import("../connection");
|
||||
type Multiaddr = import("multiaddr");
|
||||
declare const multicodecTopologySymbol: unique symbol;
|
||||
type TopologyOptions = {
|
||||
/**
|
||||
* - minimum needed connections.
|
||||
*/
|
||||
min?: number | undefined;
|
||||
/**
|
||||
* - maximum needed connections.
|
||||
*/
|
||||
max?: number | undefined;
|
||||
handlers?: import(".").Handlers | undefined;
|
||||
};
|
||||
type MulticodecOptions = {
|
||||
/**
|
||||
* - protocol multicodecs
|
||||
*/
|
||||
multicodecs: string[];
|
||||
handlers: Required<Handlers>;
|
||||
};
|
||||
type Handlers = {
|
||||
/**
|
||||
* - protocol "onConnect" handler
|
||||
*/
|
||||
onConnect?: ((peerId: import("peer-id"), conn: typeof import("../connection")) => void) | undefined;
|
||||
/**
|
||||
* - protocol "onDisconnect" handler
|
||||
*/
|
||||
onDisconnect?: ((peerId: import("peer-id")) => void) | undefined;
|
||||
};
|
6
src/transport/errors.d.ts
vendored
6
src/transport/errors.d.ts
vendored
@ -1,6 +0,0 @@
|
||||
export class AbortError extends Error {
|
||||
static get code(): string;
|
||||
static get type(): string;
|
||||
code: string;
|
||||
type: string;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user