Skip to content
This repository has been archived by the owner on Jun 26, 2023. It is now read-only.

Commit

Permalink
tmp: add dist
Browse files Browse the repository at this point in the history
  • Loading branch information
vasco-santos committed Apr 29, 2021
1 parent 209065f commit a533ebc
Show file tree
Hide file tree
Showing 97 changed files with 2,240 additions and 41 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
.nyc_output

build
dist
docs

# Dependency directory
Expand Down
235 changes: 235 additions & 0 deletions dist/src/connection/connection.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,235 @@
export = Connection;
/**
* @typedef {import('../stream-muxer/types').MuxedStream} MuxedStream
* @typedef {import('./status').Status} Status
*/
/**
* @typedef {Object} Timeline
* @property {number} open - connection opening timestamp.
* @property {number} [upgraded] - connection upgraded timestamp.
* @property {number} [close]
*
* @typedef {Object} ConectionStat
* @property {'inbound' | 'outbound'} direction - connection establishment direction
* @property {Timeline} timeline - connection relevant events timestamp.
* @property {string} [multiplexer] - connection multiplexing identifier.
* @property {string} [encryption] - connection encryption method identifier.
*
* @typedef {(protocols: string|string[]) => Promise<{stream: MuxedStream, protocol: string}>} CreatedMuxedStream
*
* @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 {CreatedMuxedStream} 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.
*
* @typedef {Object} StreamData
* @property {string} protocol - the protocol used by the stream
* @property {Object} [metadata] - metadata of the stream
*/
/**
* 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: Multiaddr | undefined;
/**
* Observed multiaddr of the remote peer
*/
remoteAddr: Multiaddr;
/**
* Local peer id.
*/
localPeer: PeerId;
/**
* Remote peer id.
*/
remotePeer: PeerId;
/**
* Connection metadata.
*
* @type {ConectionStat & {status: Status}}
*/
_stat: ConectionStat & {
status: Status;
};
/**
* Reference to the new stream function of the multiplexer
*/
_newStream: CreatedMuxedStream;
/**
* 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(): ConectionStat & {
status: Status;
};
/**
* 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 {StreamData} data - the stream data to be registered
* @returns {void}
*/
addStream(muxedStream: MuxedStream, { protocol, metadata }: StreamData): 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, Status, Timeline, ConectionStat, CreatedMuxedStream, ConnectionOptions, StreamData };
}
import { Multiaddr } from "multiaddr";
import PeerId = require("peer-id");
type ConectionStat = {
/**
* - connection establishment direction
*/
direction: 'inbound' | 'outbound';
/**
* - connection relevant events timestamp.
*/
timeline: Timeline;
/**
* - connection multiplexing identifier.
*/
multiplexer?: string | undefined;
/**
* - connection encryption method identifier.
*/
encryption?: string | undefined;
};
type Status = import('./status').Status;
type CreatedMuxedStream = (protocols: string | string[]) => Promise<{
stream: MuxedStream;
protocol: string;
}>;
type MuxedStream = import('../stream-muxer/types').MuxedStream;
type StreamData = {
/**
* - the protocol used by the stream
*/
protocol: string;
/**
* - metadata of the stream
*/
metadata?: Object | undefined;
};
type ConnectionOptions = {
/**
* - local multiaddr of the connection if known.
*/
localAddr?: Multiaddr | undefined;
/**
* - remote multiaddr of the connection.
*/
remoteAddr: Multiaddr;
/**
* - local peer-id.
*/
localPeer: PeerId;
/**
* - remote peer-id.
*/
remotePeer: PeerId;
/**
* - new stream muxer function.
*/
newStream: CreatedMuxedStream;
/**
* - close raw connection function.
*/
close: () => Promise<void>;
/**
* - get streams from muxer function.
*/
getStreams: () => MuxedStream[];
/**
* - metadata of the connection.
*/
stat: ConectionStat;
};
type Timeline = {
/**
* - connection opening timestamp.
*/
open: number;
/**
* - connection upgraded timestamp.
*/
upgraded?: number | undefined;
close?: number | undefined;
};
//# sourceMappingURL=connection.d.ts.map
1 change: 1 addition & 0 deletions dist/src/connection/connection.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions dist/src/connection/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export var Connection: typeof import("./connection");
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions dist/src/connection/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions dist/src/connection/status.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export type Status = {
OPEN: "open";
CLOSING: "closing";
CLOSED: "closed";
}[keyof {
OPEN: "open";
CLOSING: "closing";
CLOSED: "closed";
}];
//# sourceMappingURL=status.d.ts.map
1 change: 1 addition & 0 deletions dist/src/connection/status.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/src/connection/tests/connection.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare function _exports(test: any): void;
export = _exports;
//# sourceMappingURL=connection.d.ts.map
1 change: 1 addition & 0 deletions dist/src/connection/tests/connection.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/src/connection/tests/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare function _exports(test: any): void;
export = _exports;
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions dist/src/connection/tests/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions dist/src/content-routing/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import PeerId from 'peer-id'
import { Multiaddr } from 'multiaddr'
import CID from 'cids'

export interface ContentRoutingFactory {
new (options?: any): ContentRouting;
}

export interface ContentRouting {
provide (cid: CID): Promise<void>;
findProviders (cid: CID, options: Object): AsyncIterable<{ id: PeerId, multiaddrs: Multiaddr[] }>;
}

export default ContentRouting;
13 changes: 13 additions & 0 deletions dist/src/crypto/errors.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export class UnexpectedPeerError extends Error {
static get code(): string;
code: string;
}
export class InvalidCryptoExchangeError extends Error {
static get code(): string;
code: string;
}
export class InvalidCryptoTransmissionError extends Error {
static get code(): string;
code: string;
}
//# sourceMappingURL=errors.d.ts.map
1 change: 1 addition & 0 deletions dist/src/crypto/errors.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/src/crypto/tests/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare function _exports(common: any): void;
export = _exports;
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions dist/src/crypto/tests/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 24 additions & 0 deletions dist/src/crypto/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import PeerId from 'peer-id'
import { MultiaddrConnection } from '../transport/types'

/**
* A libp2p crypto module must be compliant to this interface
* to ensure all exchanged data between two peers is encrypted.
*/
export interface Crypto {
protocol: string;
/**
* Encrypt outgoing data to the remote party.
*/
secureOutbound(localPeer: PeerId, connection: MultiaddrConnection, remotePeer: PeerId): Promise<SecureOutbound>;
/**
* Decrypt incoming data.
*/
secureInbound(localPeer: PeerId, connection: MultiaddrConnection, remotePeer?: PeerId): Promise<SecureOutbound>;
}

export type SecureOutbound = {
conn: MultiaddrConnection;
remoteEarlyData: Buffer;
remotePeer: PeerId;
}
1 change: 1 addition & 0 deletions dist/src/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions dist/src/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions dist/src/peer-discovery/tests/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
declare function _exports(common: any): void;
export = _exports;
//# sourceMappingURL=index.d.ts.map
1 change: 1 addition & 0 deletions dist/src/peer-discovery/tests/index.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions dist/src/peer-discovery/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { EventEmitter } from 'events';

export interface PeerDiscoveryFactory {
new (options?: any): PeerDiscovery;
tag: string;
}

export interface PeerDiscovery extends EventEmitter {
start(): void|Promise<void>;
stop(): void|Promise<void>;
}

export default PeerDiscovery;
13 changes: 13 additions & 0 deletions dist/src/peer-routing/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import PeerId from 'peer-id'
import { Multiaddr } from 'multiaddr'

export interface PeerRoutingFactory {
new (options?: any): PeerRouting;
}

export interface PeerRouting {
findPeer (peerId: PeerId, options?: Object): Promise<{ id: PeerId, multiaddrs: Multiaddr[] }>;
getClosestPeers(key: Uint8Array, options?: Object): AsyncIterable<{ id: PeerId, multiaddrs: Multiaddr[] }>;
}

export default PeerRouting;
Loading

0 comments on commit a533ebc

Please sign in to comment.