mirror of
https://github.com/fluencelabs/js-libp2p-interfaces
synced 2025-07-07 00:41:53 +00:00
Compare commits
1 Commits
feat/add-t
...
fix/types-
Author | SHA1 | Date | |
---|---|---|---|
46c98e9cf6 |
53
.github/workflows/main.yml
vendored
53
.github/workflows/main.yml
vendored
@ -1,53 +0,0 @@
|
||||
name: ci
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
check:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: yarn
|
||||
- run: yarn lint
|
||||
- uses: gozala/typescript-error-reporter-action@v1.0.4
|
||||
- run: yarn build
|
||||
- run: yarn aegir dep-check
|
||||
- uses: ipfs/aegir/actions/bundle-size@master
|
||||
name: size
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
test-node:
|
||||
needs: check
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [windows-latest, ubuntu-latest, macos-latest]
|
||||
node: [12, 14]
|
||||
fail-fast: true
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node }}
|
||||
- run: yarn
|
||||
- run: npx nyc --reporter=lcov aegir test -t node -- --bail
|
||||
- uses: codecov/codecov-action@v1
|
||||
test-chrome:
|
||||
needs: check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: yarn
|
||||
- run: npx aegir test -t browser -t webworker --bail
|
||||
test-firefox:
|
||||
needs: check
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- run: yarn
|
||||
- run: npx aegir test -t browser -t webworker --bail -- --browsers FirefoxHeadless
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -5,6 +5,7 @@
|
||||
.nyc_output
|
||||
|
||||
build
|
||||
dist
|
||||
docs
|
||||
|
||||
# Dependency directory
|
||||
|
40
.travis.yml
Normal file
40
.travis.yml
Normal file
@ -0,0 +1,40 @@
|
||||
language: node_js
|
||||
cache: npm
|
||||
stages:
|
||||
- check
|
||||
- test
|
||||
- cov
|
||||
|
||||
node_js:
|
||||
- '10'
|
||||
- '12'
|
||||
|
||||
os:
|
||||
- linux
|
||||
- osx
|
||||
- windows
|
||||
|
||||
script: npx nyc -s npm run test:node -- --bail
|
||||
after_success: npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov
|
||||
|
||||
jobs:
|
||||
include:
|
||||
- stage: check
|
||||
script:
|
||||
- npx aegir dep-check
|
||||
- npm run lint
|
||||
|
||||
- stage: test
|
||||
name: chrome
|
||||
addons:
|
||||
chrome: stable
|
||||
script: npx aegir test -t browser -t webworker
|
||||
|
||||
- stage: test
|
||||
name: firefox
|
||||
addons:
|
||||
firefox: latest
|
||||
script: npx aegir test -t browser -t webworker -- --browsers FirefoxHeadless
|
||||
|
||||
notifications:
|
||||
email: false
|
1
dist/index.min.js
vendored
1
dist/index.min.js
vendored
@ -1 +0,0 @@
|
||||
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Libp2pInterfaces=t():e.Libp2pInterfaces=t()}(self,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){e.exports=n(1)},function(e,t,n){}])}));
|
233
dist/src/connection/connection.d.ts
vendored
233
dist/src/connection/connection.d.ts
vendored
@ -1,233 +0,0 @@
|
||||
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 {string} direction - connection establishment direction ("inbound" or "outbound").
|
||||
* @property {Timeline} timeline - connection relevant events 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.
|
||||
*
|
||||
* @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: 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.
|
||||
*
|
||||
* @type {ConectionStat & {status: Status}}
|
||||
*/
|
||||
_stat: ConectionStat & {
|
||||
status: Status;
|
||||
};
|
||||
/**
|
||||
* 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(): 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, ConnectionOptions, StreamData };
|
||||
}
|
||||
type ConectionStat = {
|
||||
/**
|
||||
* - connection establishment direction ("inbound" or "outbound").
|
||||
*/
|
||||
direction: string;
|
||||
/**
|
||||
* - connection relevant events timestamp.
|
||||
*/
|
||||
timeline: Timeline;
|
||||
/**
|
||||
* - connection multiplexing identifier.
|
||||
*/
|
||||
multiplexer?: string | undefined;
|
||||
/**
|
||||
* - connection encryption method identifier.
|
||||
*/
|
||||
encryption?: string | undefined;
|
||||
};
|
||||
type Status = "open" | "closing" | "closed";
|
||||
type MuxedStream = import("../stream-muxer/types").MuxedStream;
|
||||
type StreamData = {
|
||||
/**
|
||||
* - the protocol used by the stream
|
||||
*/
|
||||
protocol: string;
|
||||
/**
|
||||
* - metadata of the stream
|
||||
*/
|
||||
metadata?: any;
|
||||
};
|
||||
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 Timeline = {
|
||||
/**
|
||||
* - connection opening timestamp.
|
||||
*/
|
||||
open: number;
|
||||
/**
|
||||
* - connection upgraded timestamp.
|
||||
*/
|
||||
upgraded?: number | undefined;
|
||||
close?: number | undefined;
|
||||
};
|
||||
//# sourceMappingURL=connection.d.ts.map
|
1
dist/src/connection/connection.d.ts.map
vendored
1
dist/src/connection/connection.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../src/connection/connection.js"],"names":[],"mappings":";AASA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;GAGG;AACH;IAkFE;;;;;OAKG;IACH,2BAHW,GAAG,uBAKb;IAzFD;;;;;;OAMG;IACH,kGAFW,iBAAiB,EAkE3B;IA7DC;;OAEG;IACH,WAA2E;IAE3E;;OAEG;IACH,2CAA0B;IAE1B;;OAEG;IACH,gCAA4B;IAE5B;;OAEG;IACH,6BAA0B;IAE1B;;OAEG;IACH,8BAA4B;IAE5B;;;;OAIG;IACH,OAFU,aAAa,GAAG;QAAC,QAAQ,MAAM,CAAA;KAAC,CAKzC;IAED;;OAEG;IACH,wBA/DsB,MAAM,GAAC,MAAM,EAAE,KAAK,QAAQ;QAAC,MAAM,EAAE,WAAW,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,CAAC,CA+D/D;IAE3B;;OAEG;IACH,cAnEgB,QAAQ,IAAI,CAAC,CAmEV;IAEnB;;OAEG;IACH,mBAvEgB,WAAW,EAAE,CAuEA;IAE7B;;OAEG;IACH,wBAAyB;IAEzB;;;;OAIG;IACH,MAFU,MAAM,EAAE,CAEJ;IAGhB,mCAEC;IAgBD;;;;OAIG;IACH;gBA1DqC,MAAM;MA4D1C;IAED;;;;OAIG;IACH,6DAEC;IAED;;;;;OAKG;IACH,qBAHW,MAAM,GAAC,MAAM,EAAE;gBACI,WAAW;kBAAY,MAAM;OAqB1D;IAED;;;;;;OAMG;IACH,uBAJW,WAAW,0BACX,UAAU,GACR,IAAI,CAQhB;IAED;;;;OAIG;IACH,iBAFW,MAAM,QAIhB;IAED;;;;OAIG;IACH,SAFa,QAAQ,IAAI,CAAC,CAkBzB;IAJC,2BAAmC;CAKtC;;;;;;;;eA/Ma,MAAM;;;;cACN,QAAQ;;;;;;;;;;;;;;;;cAeR,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;2BANM,MAAM,GAAC,MAAM,EAAE,KAAK,QAAQ;QAAC,MAAM,EAAE,WAAW,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAC,CAAC;;;;WAChF,MAAM,QAAQ,IAAI,CAAC;;;;gBACnB,MAAM,WAAW,EAAE;;;;UACnB,aAAa;;;;;;UAlBb,MAAM"}
|
2
dist/src/connection/index.d.ts
vendored
2
dist/src/connection/index.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
export var Connection: typeof import("./connection");
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/connection/index.d.ts.map
vendored
1
dist/src/connection/index.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection/index.js"],"names":[],"mappings":""}
|
2
dist/src/connection/status.d.ts
vendored
2
dist/src/connection/status.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
export type Status = "open" | "closing" | "closed";
|
||||
//# sourceMappingURL=status.d.ts.map
|
1
dist/src/connection/status.d.ts.map
vendored
1
dist/src/connection/status.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"status.d.ts","sourceRoot":"","sources":["../../../src/connection/status.js"],"names":[],"mappings":""}
|
3
dist/src/connection/tests/connection.d.ts
vendored
3
dist/src/connection/tests/connection.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(test: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=connection.d.ts.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"connection.d.ts","sourceRoot":"","sources":["../../../../src/connection/tests/connection.js"],"names":[],"mappings":"AAUiB,2CA4KhB"}
|
3
dist/src/connection/tests/index.d.ts
vendored
3
dist/src/connection/tests/index.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(test: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/connection/tests/index.d.ts.map
vendored
1
dist/src/connection/tests/index.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/connection/tests/index.js"],"names":[],"mappings":"AAMiB,2CAEhB"}
|
1
dist/src/content-routing/types.d.ts
vendored
1
dist/src/content-routing/types.d.ts
vendored
@ -1 +0,0 @@
|
||||
//# sourceMappingURL=types.d.ts.map
|
1
dist/src/content-routing/types.d.ts.map
vendored
1
dist/src/content-routing/types.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/content-routing/types.ts"],"names":[],"mappings":""}
|
1
dist/src/crypto/errors.d.ts.map
vendored
1
dist/src/crypto/errors.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/crypto/errors.js"],"names":[],"mappings":"AAEA;IAME,0BAEC;IAPD,8BAGC;IADC,aAAoC;CAMvC;AAED;IAME,0BAEC;IAPD,8BAGC;IADC,aAA2C;CAM9C;AAED;IAME,0BAEC;IAPD,8BAGC;IADC,aAA+C;CAMlD"}
|
3
dist/src/crypto/tests/index.d.ts
vendored
3
dist/src/crypto/tests/index.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(common: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/crypto/tests/index.d.ts.map
vendored
1
dist/src/crypto/tests/index.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/crypto/tests/index.js"],"names":[],"mappings":"AAgBiB,6CAwFhB"}
|
24
dist/src/crypto/types.d.ts
vendored
24
dist/src/crypto/types.d.ts
vendored
@ -1,24 +0,0 @@
|
||||
/// <reference types="node" />
|
||||
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 declare type SecureOutbound = {
|
||||
conn: MultiaddrConnection;
|
||||
remoteEarlyData: Buffer;
|
||||
remotePeer: PeerId;
|
||||
};
|
||||
//# sourceMappingURL=types.d.ts.map
|
1
dist/src/crypto/types.d.ts.map
vendored
1
dist/src/crypto/types.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/crypto/types.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAA;AAExD;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB;;OAEG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IAChH;;OAEG;IACH,aAAa,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,mBAAmB,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACjH;AAED,oBAAY,cAAc,GAAG;IAC3B,IAAI,EAAE,mBAAmB,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAA"}
|
1
dist/src/index.d.ts
vendored
1
dist/src/index.d.ts
vendored
@ -1 +0,0 @@
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/index.d.ts.map
vendored
1
dist/src/index.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.js"],"names":[],"mappings":""}
|
3
dist/src/peer-discovery/tests/index.d.ts
vendored
3
dist/src/peer-discovery/tests/index.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(common: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/peer-discovery/tests/index.d.ts.map
vendored
1
dist/src/peer-discovery/tests/index.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/peer-discovery/tests/index.js"],"names":[],"mappings":"AAaiB,6CA8EhB"}
|
1
dist/src/pubsub/errors.d.ts.map
vendored
1
dist/src/pubsub/errors.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/pubsub/errors.js"],"names":[],"mappings":""}
|
1
dist/src/pubsub/index.d.ts.map
vendored
1
dist/src/pubsub/index.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pubsub/index.js"],"names":[],"mappings":";;;AAuBA;;;;;;;;;;GAUG;AAEH;;;;;;;;;GASG;AAEH;;;GAGG;AACH;IACE;;;;;;;;;OASG;IACH;QARyB,SAAS,EAAvB,MAAM;QACsB,WAAW,EAAvC,MAAM,MAAM,CAAC,GAAC,MAAM;QACN,MAAM,EAApB,MAAM;QACsB,qBAAqB;QACjC,eAAe;QACf,QAAQ;OA2GlC;IAlFC,SAA2B;IAG3B;;OAEG;IACH,aAFU,MAAM,MAAM,CAAC,CAE0B;IACjD,aAAqB;IACrB,eAAiC;IACjC;;OAEG;IACH,QAFU,MAAM,CAEW;IAE3B,iBAAoB;IAEpB;;;;OAIG;IACH,QAFU,IAAI,MAAM,EAAE,IAAI,MAAM,CAAC,CAAC,CAEX;IAEvB;;;;OAIG;IACH,eAFU,IAAI,MAAM,CAAC,CAES;IAE9B;;;;OAIG;IACH,OAFU,IAAI,MAAM,EAAE,OAAO,gBAAgB,CAAC,CAAC,CAEzB;IAOtB;;;;OAIG;IACH,uBAFU,MAAM,CAEkC;IAElD;;;;OAIG;IACH,iBAFU,OAAO,CAEqB;IAEtC;;;;OAIG;IACH,UAFU,OAAO,CAEO;IAExB;;;;OAIG;IACH;;;;;;;OAOG;IACH,oCAVsB,MAAM,sBAAc,QAAQ,IAAI,CAAC,EAUvB;IAEhC,kBAA6B;IA4D/B;;;;;;;;OAQG;IACH;kBAJW,MAAM;gBACN,WAAW;oBACX,UAAU;aASpB;IAED;;;;;;OAMG;IACH,mCAHW,MAAM,QACN,UAAU,iBAgBpB;IAED;;;;;;OAMG;IACH,sCAHW,MAAM,iCAQhB;IAzGD;;;;OAIG;IACH,SAFa,IAAI,CAyBhB;IAED;;;;OAIG;IACH,QAFa,IAAI,CAiBhB;IAyDD;;;;;;;OAOG;IACH,2BAJW,MAAM,YACN,MAAM,4BAwBhB;IAED;;;;;;OAMG;IACH,8BAHW,MAAM,GACJ,2BAAc,SAAS,CAsBnC;IAID;;;;;;;OAOG;IACH,2BALW,MAAM,UACN,cAAc,UAAU,GAAC,UAAU,CAAC,0CAElC,QAAQ,IAAI,CAAC,CAkBzB;IAED;;;;;;;OAOG;IACH,sBALW,MAAM,8CAEN,GAAG,GACD,OAAO,CA6BnB;IAED;;;;;OAKG;IACH,sBAHW,MAAM,UACN,UAAU,QAkBpB;IAED;;;;;OAKG;IACH,wBAHW,SAAS,GACP,QAAQ,IAAI,CAAC,CAmBzB;IAED;;;;OAIG;IACH,uCAMC;IAED;;;;;;OAMG;IACH,cAHW,UAAU,GACR,UAAU,CAYtB;IAED;;;;;;;OAOG;IACH,gBAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;;;;OAMG;IACH,kBAHW,UAAU,GACR,GAAG,CAIf;IAED;;;;;;OAMG;IACH,gBAHW,GAAG,GACD,UAAU,CAItB;IAED;;;;;;OAMG;IACH,aAJW,MAAM,OACN,GAAG,GACD,IAAI,CAWhB;IAED;;;;;;;OAOG;IACH,uBALW,MAAM,UACN,MAAM,EAAE,aACR,OAAO,GACL,IAAI,CAMhB;IAED;;;;;;OAMG;IACH,kBAHW,SAAS,GACP,QAAQ,IAAI,CAAC,CAwCzB;IAED;;;;;;;OAOG;IACH,iCAHW,UAAU,GACR,QAAQ,UAAU,CAAC,CAc/B;IAID;;;;;OAKG;IACH,sBAHW,MAAM,GACJ,MAAM,MAAM,CAAC,CAgBzB;IAED;;;;;;;OAOG;IACH,eAJW,MAAM,WACN,MAAM,GACJ,QAAQ,IAAI,CAAC,CAyBzB;IAED;;;;;;;;OAQG;IACH,kBAJW,SAAS,GACP,QAAQ,IAAI,CAAC,CAKzB;IAED;;;;;;OAMG;IACH,iBAHW,MAAM,GACJ,IAAI,CAWhB;IAED;;;;;;OAMG;IACH,mBAHW,MAAM,GACJ,IAAI,CAWhB;IAED;;;;;OAKG;IACH,aAFa,MAAM,MAAM,CAAC,CAQzB;CACF;;;;;;;kBA1rBa,MAAM;cACN,MAAM,EAAE;;UAER,UAAU;;;;;;;;;;;AA/BxB;;GAEG;AACH,uBAFU,cAAc,WAAW,CAAC,CAEA;AAGpC,8CAAgC"}
|
6
dist/src/pubsub/message/index.d.ts
vendored
6
dist/src/pubsub/message/index.d.ts
vendored
@ -1,6 +0,0 @@
|
||||
export var rpc: any;
|
||||
export var td: any;
|
||||
export var RPC: any;
|
||||
export var Message: any;
|
||||
export var SubOpts: any;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/pubsub/message/index.d.ts.map
vendored
1
dist/src/pubsub/message/index.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/pubsub/message/index.js"],"names":[],"mappings":""}
|
1
dist/src/pubsub/message/rpc.proto.d.ts.map
vendored
1
dist/src/pubsub/message/rpc.proto.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"rpc.proto.d.ts","sourceRoot":"","sources":["../../../../src/pubsub/message/rpc.proto.js"],"names":[],"mappings":""}
|
35
dist/src/pubsub/message/sign.d.ts
vendored
35
dist/src/pubsub/message/sign.d.ts
vendored
@ -1,35 +0,0 @@
|
||||
export type InMessage = {
|
||||
from?: string | undefined;
|
||||
receivedFrom: string;
|
||||
topicIDs: string[];
|
||||
seqno?: Uint8Array | undefined;
|
||||
data: Uint8Array;
|
||||
signature?: Uint8Array | undefined;
|
||||
key?: Uint8Array | undefined;
|
||||
};
|
||||
export type PublicKey = import("libp2p-crypto").PublicKey;
|
||||
/**
|
||||
* 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: InMessage): Promise<PublicKey>;
|
||||
/**
|
||||
* 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: InMessage): Promise<boolean>;
|
||||
//# sourceMappingURL=sign.d.ts.map
|
1
dist/src/pubsub/message/sign.d.ts.map
vendored
1
dist/src/pubsub/message/sign.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"sign.d.ts","sourceRoot":"","sources":["../../../../src/pubsub/message/sign.js"],"names":[],"mappings":";;;;;;;;;;AA4DA;;;;;;GAMG;AACH,0CAHW,SAAS,GACP,QAAQ,SAAS,CAAC,CAsB9B;AA/ED;;;;;;GAMG;AACH,sEAFa,YAAgB,CAgB5B;AAvBD,6BAAyD;AAyBzD;;;;;GAKG;AACH,yCAHW,SAAS,GACP,QAAQ,OAAO,CAAC,CAuB5B"}
|
@ -1,3 +0,0 @@
|
||||
declare const _exports: string;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=topic-descriptor.proto.d.ts.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"topic-descriptor.proto.d.ts","sourceRoot":"","sources":["../../../../src/pubsub/message/topic-descriptor.proto.js"],"names":[],"mappings":""}
|
1
dist/src/pubsub/peer-streams.d.ts.map
vendored
1
dist/src/pubsub/peer-streams.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"peer-streams.d.ts","sourceRoot":"","sources":["../../../src/pubsub/peer-streams.js"],"names":[],"mappings":";;;AAiBA;;;;GAIG;AAEH;;GAEG;AACH;IACE;;;;OAIG;IACH;QAH8B,EAAE,EAArB,MAAM;QACa,QAAQ,EAA3B,MAAM;OAgDhB;IA3CC;;OAEG;IACH,IAFU,OAAO,SAAS,CAAC,CAEf;IACZ;;;;OAIG;IACH,UAFU,MAAM,CAEQ;IACxB;;;;;OAKG;IACH,2BAA8B;IAC9B;;;;;OAKG;IACH,0BAA6B;IAC7B;;;;;OAKG;IACH,gCAAoD;IACpD;;;;OAIG;IACH,gBAFU,IAAI,6CAAe,CAEH;IAC1B;;;;OAIG;IACH,eAFU,IAAI,GAAE,cAAc,UAAU,CAAC,CAEhB;IAG3B;;;;OAIG;IACH,0BAEC;IAED;;;;OAIG;IACH,0BAEC;IAED;;;;;;OAMG;IACH,YAHW,UAAU,GACR,IAAI,CAShB;IAED;;;;;OAKG;IACH,4BAHW,WAAW,GACT,cAAc,UAAU,CAAC,CAmBrC;IAED;;;;;OAKG;IACH,6BAHW,WAAW,GACT,QAAQ,IAAI,CAAC,CAmCzB;IAED;;;;OAIG;IACH,SAFa,IAAI,CAiBhB;CACF"}
|
1
dist/src/pubsub/signature-policy.d.ts.map
vendored
1
dist/src/pubsub/signature-policy.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"signature-policy.d.ts","sourceRoot":"","sources":["../../../src/pubsub/signature-policy.js"],"names":[],"mappings":";sBAeyB,YAAY;wBAWV,cAAc"}
|
3
dist/src/pubsub/tests/api.d.ts
vendored
3
dist/src/pubsub/tests/api.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(common: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=api.d.ts.map
|
1
dist/src/pubsub/tests/api.d.ts.map
vendored
1
dist/src/pubsub/tests/api.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../../src/pubsub/tests/api.js"],"names":[],"mappings":"AAciB,6CA8EhB"}
|
3
dist/src/pubsub/tests/emit-self.d.ts
vendored
3
dist/src/pubsub/tests/emit-self.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(common: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=emit-self.d.ts.map
|
1
dist/src/pubsub/tests/emit-self.d.ts.map
vendored
1
dist/src/pubsub/tests/emit-self.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"emit-self.d.ts","sourceRoot":"","sources":["../../../../src/pubsub/tests/emit-self.js"],"names":[],"mappings":"AAaiB,6CAuDhB"}
|
3
dist/src/pubsub/tests/index.d.ts
vendored
3
dist/src/pubsub/tests/index.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(common: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/pubsub/tests/index.d.ts.map
vendored
1
dist/src/pubsub/tests/index.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/pubsub/tests/index.js"],"names":[],"mappings":"AASiB,6CAQhB"}
|
3
dist/src/pubsub/tests/messages.d.ts
vendored
3
dist/src/pubsub/tests/messages.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(common: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=messages.d.ts.map
|
1
dist/src/pubsub/tests/messages.d.ts.map
vendored
1
dist/src/pubsub/tests/messages.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../../src/pubsub/tests/messages.js"],"names":[],"mappings":"AAiBiB,6CAiGhB"}
|
3
dist/src/pubsub/tests/multiple-nodes.d.ts
vendored
3
dist/src/pubsub/tests/multiple-nodes.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(common: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=multiple-nodes.d.ts.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"multiple-nodes.d.ts","sourceRoot":"","sources":["../../../../src/pubsub/tests/multiple-nodes.js"],"names":[],"mappings":"AAgBiB,6CAmUhB"}
|
3
dist/src/pubsub/tests/two-nodes.d.ts
vendored
3
dist/src/pubsub/tests/two-nodes.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(common: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=two-nodes.d.ts.map
|
1
dist/src/pubsub/tests/two-nodes.d.ts.map
vendored
1
dist/src/pubsub/tests/two-nodes.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"two-nodes.d.ts","sourceRoot":"","sources":["../../../../src/pubsub/tests/two-nodes.js"],"names":[],"mappings":"AAwBiB,6CA2MhB"}
|
3
dist/src/pubsub/tests/utils.d.ts
vendored
3
dist/src/pubsub/tests/utils.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
export function first(map: any): any;
|
||||
export function expectSet(set: any, subs: any): void;
|
||||
//# sourceMappingURL=utils.d.ts.map
|
1
dist/src/pubsub/tests/utils.d.ts.map
vendored
1
dist/src/pubsub/tests/utils.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../../src/pubsub/tests/utils.js"],"names":[],"mappings":"AAIgB,qCAAkC;AAE9B,qDAEnB"}
|
1
dist/src/pubsub/utils.d.ts.map
vendored
1
dist/src/pubsub/utils.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/pubsub/utils.js"],"names":[],"mappings":"AAesB,+BAHT,UAAU,CAKtB;AAUe,4BALL,MAAM,SACN,UAAU,GACR,UAAU,CAStB;AASqB,kCAJX,UAAU,GACR,UAAU,CAG2C;AAW/C,4BALR,gBAAS,KACT,gBAAS,GACP,OAAO,CAkBnB;AAUqB,yDAMrB;AAU+B;WALX,GAAG;;;kBACmB,MAAM;;;;EAahD;AAQgC;WALZ,GAAG;WAAQ,GAAG;;;;EAclC"}
|
3
dist/src/record/tests/index.d.ts
vendored
3
dist/src/record/tests/index.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(test: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/record/tests/index.d.ts.map
vendored
1
dist/src/record/tests/index.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/record/tests/index.js"],"names":[],"mappings":"AAQiB,2CA0BhB"}
|
1
dist/src/record/types.d.ts.map
vendored
1
dist/src/record/types.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/record/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;OAEG;IACH,KAAK,EAAE,UAAU,CAAC;IAClB;;OAEG;IACH,OAAO,IAAI,UAAU,CAAC;IACtB;;OAEG;IACH,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAA;CAChC"}
|
3
dist/src/stream-muxer/tests/base-test.d.ts
vendored
3
dist/src/stream-muxer/tests/base-test.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(common: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=base-test.d.ts.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"base-test.d.ts","sourceRoot":"","sources":["../../../../src/stream-muxer/tests/base-test.js"],"names":[],"mappings":"AAiCiB,6CAwHhB"}
|
3
dist/src/stream-muxer/tests/close-test.d.ts
vendored
3
dist/src/stream-muxer/tests/close-test.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(common: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=close-test.d.ts.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"close-test.d.ts","sourceRoot":"","sources":["../../../../src/stream-muxer/tests/close-test.js"],"names":[],"mappings":"AAgCiB,6CAsFhB"}
|
3
dist/src/stream-muxer/tests/index.d.ts
vendored
3
dist/src/stream-muxer/tests/index.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(common: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/stream-muxer/tests/index.d.ts.map
vendored
1
dist/src/stream-muxer/tests/index.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/stream-muxer/tests/index.js"],"names":[],"mappings":"AAQiB,6CAUhB"}
|
@ -1,3 +0,0 @@
|
||||
declare function _exports(common: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=mega-stress-test.d.ts.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"mega-stress-test.d.ts","sourceRoot":"","sources":["../../../../src/stream-muxer/tests/mega-stress-test.js"],"names":[],"mappings":"AAKiB,6CAWhB"}
|
3
dist/src/stream-muxer/tests/spawner.d.ts
vendored
3
dist/src/stream-muxer/tests/spawner.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(Muxer: any, nStreams: any, nMsg: any, limit: any): Promise<void>;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=spawner.d.ts.map
|
1
dist/src/stream-muxer/tests/spawner.d.ts.map
vendored
1
dist/src/stream-muxer/tests/spawner.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"spawner.d.ts","sourceRoot":"","sources":["../../../../src/stream-muxer/tests/spawner.js"],"names":[],"mappings":"AASiB,2FAoDhB"}
|
3
dist/src/stream-muxer/tests/stress-test.d.ts
vendored
3
dist/src/stream-muxer/tests/stress-test.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(common: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=stress-test.d.ts.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"stress-test.d.ts","sourceRoot":"","sources":["../../../../src/stream-muxer/tests/stress-test.js"],"names":[],"mappings":"AAKiB,6CAwBhB"}
|
44
dist/src/stream-muxer/types.d.ts
vendored
44
dist/src/stream-muxer/types.d.ts
vendored
@ -1,44 +0,0 @@
|
||||
import BufferList from 'bl';
|
||||
export interface MuxerFactory {
|
||||
new (options: MuxerOptions): Muxer;
|
||||
multicodec: string;
|
||||
}
|
||||
/**
|
||||
* A libp2p stream muxer
|
||||
*/
|
||||
export interface Muxer {
|
||||
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.
|
||||
*/
|
||||
newStream(name?: string): MuxedStream;
|
||||
/**
|
||||
* A function called when receiving a new stream from the remote.
|
||||
*/
|
||||
onStream(stream: MuxedStream): void;
|
||||
/**
|
||||
* A function called when a stream ends.
|
||||
*/
|
||||
onStreamEnd(stream: MuxedStream): void;
|
||||
}
|
||||
export declare type MuxerOptions = {
|
||||
onStream: (stream: MuxedStream) => void;
|
||||
onStreamEnd: (stream: MuxedStream) => void;
|
||||
maxMsgSize?: number;
|
||||
};
|
||||
export declare type MuxedTimeline = {
|
||||
open: number;
|
||||
close?: number;
|
||||
};
|
||||
export interface MuxedStream extends AsyncIterable<Uint8Array | BufferList> {
|
||||
close: () => void;
|
||||
abort: () => void;
|
||||
reset: () => void;
|
||||
sink: Sink;
|
||||
source: () => AsyncIterable<Uint8Array | BufferList>;
|
||||
timeline: MuxedTimeline;
|
||||
id: string;
|
||||
}
|
||||
export declare type Sink = (source: Uint8Array) => Promise<Uint8Array>;
|
||||
//# sourceMappingURL=types.d.ts.map
|
1
dist/src/stream-muxer/types.d.ts.map
vendored
1
dist/src/stream-muxer/types.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/stream-muxer/types.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,IAAI,CAAA;AAE3B,MAAM,WAAW,YAAY;IAC3B,KAAK,OAAO,EAAE,YAAY,GAAG,KAAK,CAAC;IACnC,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IACrC;;;OAGG;IACH,SAAS,CAAE,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,CAAC;IAEvC;;OAEG;IACH,QAAQ,CAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;IAErC;;OAEG;IACH,WAAW,CAAE,MAAM,EAAE,WAAW,GAAG,IAAI,CAAC;CACzC;AAED,oBAAY,YAAY,GAAG;IACzB,QAAQ,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IACxC,WAAW,EAAE,CAAC,MAAM,EAAE,WAAW,KAAK,IAAI,CAAC;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAA;AAED,oBAAY,aAAa,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAA;AAED,MAAM,WAAW,WAAY,SAAQ,aAAa,CAAC,UAAU,GAAG,UAAU,CAAC;IACzE,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,MAAM,aAAa,CAAC,UAAU,GAAG,UAAU,CAAC,CAAC;IACrD,QAAQ,EAAE,aAAa,CAAC;IACxB,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,oBAAY,IAAI,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC"}
|
1
dist/src/topology/index.d.ts.map
vendored
1
dist/src/topology/index.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/topology/index.js"],"names":[],"mappings":";AAKA;;GAEG;AAEH;;;;;;;;;;;GAWG;AAEH;IAgCE;;;;;OAKG;IACH,yBAHW,GAAG,qBAKb;IAvCD;;OAEG;IACH,oCAFW,OAAO,EAoBjB;IAbC,YAAc;IACd,YAAc;IAGd,qBAnBmB,MAAM,QAAQ,UAAU,KAAK,IAAI,CAmBR;IAC5C,wBAnBmB,MAAM,gCAAmB,IAAI,CAmBE;IAElD;;;;OAIG;IACH,OAFU,IAAI,MAAM,CAAC,CAEC;IAGxB,mCAEC;IAgBD,wBAEC;IADC,gBAA2B;IAG7B;;;;;OAKG;IACH,mBAHW,MAAM,GACJ,IAAI,CAIhB;CACF;;;;;;;;;;;;;;;;;;;;;0BA7DsB,MAAM,QAAQ,UAAU,KAAK,IAAI;;;;6BACjC,MAAM,gCAAmB,IAAI"}
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"multicodec-topology.d.ts","sourceRoot":"","sources":["../../../src/topology/multicodec-topology.js"],"names":[],"mappings":";;AAKA;IA2CE;;;;;OAKG;IACH,mCAHW,GAAG,+BAKb;IAlDD;;OAEG;IACH,iDAFW,eAAe,GAAG,iBAAiB,EA+B7C;IALC,sBAA2E;IAuD7E;;;;;;OAMG;IACH;QAHyB,MAAM,EAApB,MAAM;QACe,SAAS,EAA9B,MAAM,MAAM,CAAC;aAmBvB;IAED;;;;;OAKG;IACH,2BAHW,UAAU,GACR,IAAI,CAehB;IAlED;;;;;OAKG;IACH,+BAHW,MAAM;QAAC,EAAE,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,SAAS,CAAC,CAAC;QAAC,SAAS,EAAE,MAAM,MAAM,CAAC,CAAA;KAAC,CAAC,GACzE,IAAI,CAehB;CAgDF;;;;;;;;;;;;;;;;;;;;;;iBAQa,MAAM,EAAE;cACR,SAAS,QAAQ,CAAC"}
|
@ -1,3 +0,0 @@
|
||||
declare function _exports(test: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=multicodec-topology.d.ts.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"multicodec-topology.d.ts","sourceRoot":"","sources":["../../../../src/topology/tests/multicodec-topology.js"],"names":[],"mappings":"AAaiB,2CAuHhB"}
|
3
dist/src/topology/tests/topology.d.ts
vendored
3
dist/src/topology/tests/topology.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(test: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=topology.d.ts.map
|
1
dist/src/topology/tests/topology.d.ts.map
vendored
1
dist/src/topology/tests/topology.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"topology.d.ts","sourceRoot":"","sources":["../../../../src/topology/tests/topology.js"],"names":[],"mappings":"AAYiB,2CA+BhB"}
|
1
dist/src/transport/errors.d.ts.map
vendored
1
dist/src/transport/errors.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/transport/errors.js"],"names":[],"mappings":"AAEA;IAOE,0BAEC;IAED,0BAEC;IAVC,aAA2B;IAC3B,aAA2B;CAU9B"}
|
3
dist/src/transport/tests/dial-test.d.ts
vendored
3
dist/src/transport/tests/dial-test.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(common: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=dial-test.d.ts.map
|
1
dist/src/transport/tests/dial-test.d.ts.map
vendored
1
dist/src/transport/tests/dial-test.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"dial-test.d.ts","sourceRoot":"","sources":["../../../../src/transport/tests/dial-test.js"],"names":[],"mappings":"AAgBiB,6CA0LhB"}
|
3
dist/src/transport/tests/filter-test.d.ts
vendored
3
dist/src/transport/tests/filter-test.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(common: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=filter-test.d.ts.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"filter-test.d.ts","sourceRoot":"","sources":["../../../../src/transport/tests/filter-test.js"],"names":[],"mappings":"AAQiB,6CA4BhB"}
|
3
dist/src/transport/tests/index.d.ts
vendored
3
dist/src/transport/tests/index.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(common: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=index.d.ts.map
|
1
dist/src/transport/tests/index.d.ts.map
vendored
1
dist/src/transport/tests/index.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/transport/tests/index.js"],"names":[],"mappings":"AAOiB,6CAMhB"}
|
3
dist/src/transport/tests/listen-test.d.ts
vendored
3
dist/src/transport/tests/listen-test.d.ts
vendored
@ -1,3 +0,0 @@
|
||||
declare function _exports(common: any): void;
|
||||
export = _exports;
|
||||
//# sourceMappingURL=listen-test.d.ts.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"listen-test.d.ts","sourceRoot":"","sources":["../../../../src/transport/tests/listen-test.js"],"names":[],"mappings":"AAeiB,6CAmJhB"}
|
2
dist/src/transport/tests/utils/index.d.ts
vendored
2
dist/src/transport/tests/utils/index.d.ts
vendored
@ -1,2 +0,0 @@
|
||||
export function isValidTick(date: number, ms?: number): boolean;
|
||||
//# sourceMappingURL=index.d.ts.map
|
@ -1 +0,0 @@
|
||||
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/transport/tests/utils/index.js"],"names":[],"mappings":"AAWe,gEAIZ"}
|
70
dist/src/transport/types.d.ts
vendored
70
dist/src/transport/types.d.ts
vendored
@ -1,70 +0,0 @@
|
||||
/// <reference types="node" />
|
||||
import events from 'events';
|
||||
import Multiaddr from 'multiaddr';
|
||||
import Connection from '../connection/connection';
|
||||
import { Sink } from '../stream-muxer/types';
|
||||
export interface TransportFactory<DialOptions extends {
|
||||
signal?: AbortSignal;
|
||||
}, ListenerOptions> {
|
||||
new (upgrader: Upgrader): Transport<DialOptions, ListenerOptions>;
|
||||
}
|
||||
/**
|
||||
* A libp2p transport is understood as something that offers a dial and listen interface to establish connections.
|
||||
*/
|
||||
export interface Transport<DialOptions extends {
|
||||
signal?: AbortSignal;
|
||||
}, ListenerOptions> {
|
||||
/**
|
||||
* Dial a given multiaddr.
|
||||
*/
|
||||
dial(ma: Multiaddr, options?: DialOptions): Promise<Connection>;
|
||||
/**
|
||||
* Create transport listeners.
|
||||
*/
|
||||
createListener(options: ListenerOptions, handler?: (connection: Connection) => void): Listener;
|
||||
/**
|
||||
* Takes a list of `Multiaddr`s and returns only valid addresses for the transport
|
||||
*/
|
||||
filter(multiaddrs: Multiaddr[]): Multiaddr[];
|
||||
}
|
||||
export interface Listener extends events.EventEmitter {
|
||||
/**
|
||||
* Start a listener
|
||||
*/
|
||||
listen(multiaddr: Multiaddr): Promise<void>;
|
||||
/**
|
||||
* Get listen addresses
|
||||
*/
|
||||
getAddrs(): Multiaddr[];
|
||||
/**
|
||||
* Close listener
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
close(): Promise<void>;
|
||||
}
|
||||
export interface Upgrader {
|
||||
/**
|
||||
* Upgrades an outbound connection on `transport.dial`.
|
||||
*/
|
||||
upgradeOutbound(maConn: MultiaddrConnection): Promise<Connection>;
|
||||
/**
|
||||
* Upgrades an inbound connection on transport listener.
|
||||
*/
|
||||
upgradeInbound(maConn: MultiaddrConnection): Promise<Connection>;
|
||||
}
|
||||
export declare type MultiaddrConnectionTimeline = {
|
||||
open: number;
|
||||
upgraded?: number;
|
||||
close?: number;
|
||||
};
|
||||
export declare type MultiaddrConnection = {
|
||||
sink: Sink;
|
||||
source: () => AsyncIterable<Uint8Array>;
|
||||
close: (err?: Error) => Promise<void>;
|
||||
conn: unknown;
|
||||
remoteAddr: Multiaddr;
|
||||
localAddr?: Multiaddr;
|
||||
timeline: MultiaddrConnectionTimeline;
|
||||
};
|
||||
//# sourceMappingURL=types.d.ts.map
|
1
dist/src/transport/types.d.ts.map
vendored
1
dist/src/transport/types.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/transport/types.ts"],"names":[],"mappings":";AAAA,OAAO,MAAM,MAAM,QAAQ,CAAA;AAC3B,OAAO,SAAS,MAAM,WAAW,CAAA;AACjC,OAAO,UAAU,MAAM,0BAA0B,CAAA;AACjD,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAA;AAE5C,MAAM,WAAW,gBAAgB,CAAC,WAAW,SAAS;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,EAAE,eAAe;IAC7F,KAAI,QAAQ,EAAE,QAAQ,GAAG,SAAS,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;CAClE;AAED;;GAEG;AACH,MAAM,WAAW,SAAS,CAAE,WAAW,SAAS;IAAE,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,EAAE,eAAe;IACvF;;OAEG;IACH,IAAI,CAAC,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAChE;;OAEG;IACH,cAAc,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,GAAG,QAAQ,CAAC;IAC/F;;OAEG;IACH,MAAM,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE,CAAC;CAC9C;AAED,MAAM,WAAW,QAAS,SAAQ,MAAM,CAAC,YAAY;IACnD;;OAEG;IACH,MAAM,CAAC,SAAS,EAAE,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C;;OAEG;IACH,QAAQ,IAAI,SAAS,EAAE,CAAC;IACxB;;;;OAIG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAED,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,eAAe,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAElE;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAClE;AAED,oBAAY,2BAA2B,GAAG;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAA;AAED,oBAAY,mBAAmB,GAAG;IAChC,IAAI,EAAE,IAAI,CAAC;IACX,MAAM,EAAE,MAAM,aAAa,CAAC,UAAU,CAAC,CAAC;IACxC,KAAK,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACtC,IAAI,EAAE,OAAO,CAAC;IACd,UAAU,EAAE,SAAS,CAAC;IACtB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,QAAQ,EAAE,2BAA2B,CAAC;CACvC,CAAA"}
|
376
dist/src/utils/peers.d.ts
vendored
376
dist/src/utils/peers.d.ts
vendored
@ -1,376 +0,0 @@
|
||||
declare const _exports: {
|
||||
[n: number]: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
};
|
||||
length: number;
|
||||
toString(): string;
|
||||
toLocaleString(): string;
|
||||
pop(): {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
} | undefined;
|
||||
push(...items: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]): number;
|
||||
concat(...items: ConcatArray<{
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}>[]): {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[];
|
||||
concat(...items: ({
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
} | ConcatArray<{
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}>)[]): {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[];
|
||||
join(separator?: string | undefined): string;
|
||||
reverse(): {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[];
|
||||
shift(): {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
} | undefined;
|
||||
slice(start?: number | undefined, end?: number | undefined): {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[];
|
||||
sort(compareFn?: ((a: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, b: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}) => number) | undefined): {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[];
|
||||
splice(start: number, deleteCount?: number | undefined): {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[];
|
||||
splice(start: number, deleteCount: number, ...items: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]): {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[];
|
||||
unshift(...items: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]): number;
|
||||
indexOf(searchElement: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, fromIndex?: number | undefined): number;
|
||||
lastIndexOf(searchElement: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, fromIndex?: number | undefined): number;
|
||||
every<S extends {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}>(predicate: (value: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, index: number, array: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]) => value is S, thisArg?: any): this is S[];
|
||||
every(predicate: (value: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, index: number, array: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]) => unknown, thisArg?: any): boolean;
|
||||
some(predicate: (value: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, index: number, array: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]) => unknown, thisArg?: any): boolean;
|
||||
forEach(callbackfn: (value: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, index: number, array: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]) => void, thisArg?: any): void;
|
||||
map<U>(callbackfn: (value: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, index: number, array: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]) => U, thisArg?: any): U[];
|
||||
filter<S_1 extends {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}>(predicate: (value: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, index: number, array: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]) => value is S_1, thisArg?: any): S_1[];
|
||||
filter(predicate: (value: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, index: number, array: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]) => unknown, thisArg?: any): {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[];
|
||||
reduce(callbackfn: (previousValue: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, currentValue: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, currentIndex: number, array: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]) => {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}): {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
};
|
||||
reduce(callbackfn: (previousValue: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, currentValue: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, currentIndex: number, array: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]) => {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, initialValue: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}): {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
};
|
||||
reduce<U_1>(callbackfn: (previousValue: U_1, currentValue: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, currentIndex: number, array: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]) => U_1, initialValue: U_1): U_1;
|
||||
reduceRight(callbackfn: (previousValue: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, currentValue: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, currentIndex: number, array: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]) => {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}): {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
};
|
||||
reduceRight(callbackfn: (previousValue: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, currentValue: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, currentIndex: number, array: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]) => {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, initialValue: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}): {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
};
|
||||
reduceRight<U_2>(callbackfn: (previousValue: U_2, currentValue: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, currentIndex: number, array: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]) => U_2, initialValue: U_2): U_2;
|
||||
find<S_2 extends {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}>(predicate: (this: void, value: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, index: number, obj: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]) => value is S_2, thisArg?: any): S_2 | undefined;
|
||||
find(predicate: (value: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, index: number, obj: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]) => unknown, thisArg?: any): {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
} | undefined;
|
||||
findIndex(predicate: (value: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, index: number, obj: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]) => unknown, thisArg?: any): number;
|
||||
fill(value: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, start?: number | undefined, end?: number | undefined): {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[];
|
||||
copyWithin(target: number, start: number, end?: number | undefined): {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[];
|
||||
[Symbol.iterator](): IterableIterator<{
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}>;
|
||||
entries(): IterableIterator<[number, {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}]>;
|
||||
keys(): IterableIterator<number>;
|
||||
values(): IterableIterator<{
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}>;
|
||||
[Symbol.unscopables](): {
|
||||
copyWithin: boolean;
|
||||
entries: boolean;
|
||||
fill: boolean;
|
||||
find: boolean;
|
||||
findIndex: boolean;
|
||||
keys: boolean;
|
||||
values: boolean;
|
||||
};
|
||||
includes(searchElement: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, fromIndex?: number | undefined): boolean;
|
||||
flatMap<U_3, This = undefined>(callback: (this: This, value: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}, index: number, array: {
|
||||
id: string;
|
||||
privKey: string;
|
||||
pubKey: string;
|
||||
}[]) => U_3 | readonly U_3[], thisArg?: This | undefined): U_3[];
|
||||
flat<A, D extends number = 1>(this: A, depth?: D | undefined): FlatArray<A, D>[];
|
||||
};
|
||||
export = _exports;
|
||||
//# sourceMappingURL=peers.d.ts.map
|
1
dist/src/utils/peers.d.ts.map
vendored
1
dist/src/utils/peers.d.ts.map
vendored
@ -1 +0,0 @@
|
||||
{"version":3,"file":"peers.d.ts","sourceRoot":"","sources":["../../../src/utils/peers.js"],"names":[],"mappings":""}
|
21
package.json
21
package.json
@ -9,22 +9,11 @@
|
||||
"types",
|
||||
"dist"
|
||||
],
|
||||
"types": "dist/src/index.d.ts",
|
||||
"typesVersions": {
|
||||
"*": {
|
||||
"src/*": [
|
||||
"dist/src/*",
|
||||
"dist/src/*/index"
|
||||
]
|
||||
}
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": "ipfs"
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "aegir build",
|
||||
"lint": "aegir lint",
|
||||
"build": "aegir build",
|
||||
"pregenerate:types": "rimraf './src/**/*.d.ts'",
|
||||
"generate:types": "tsc --build",
|
||||
"test": "aegir test",
|
||||
"test:node": "aegir test --target node",
|
||||
"test:browser": "aegir test --target browser",
|
||||
@ -48,7 +37,6 @@
|
||||
},
|
||||
"homepage": "https://github.com/libp2p/js-interfaces#readme",
|
||||
"dependencies": {
|
||||
"@types/bl": "^2.1.0",
|
||||
"abort-controller": "^3.0.0",
|
||||
"abortable-iterator": "^3.0.0",
|
||||
"chai": "^4.2.0",
|
||||
@ -78,9 +66,10 @@
|
||||
"uint8arrays": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"aegir": "^29.2.0",
|
||||
"aegir": "^25.0.0",
|
||||
"it-handshake": "^1.0.1",
|
||||
"rimraf": "^3.0.2"
|
||||
"rimraf": "^3.0.2",
|
||||
"typescript": "^4.0.5"
|
||||
},
|
||||
"contributors": [
|
||||
"Alan Shaw <alan.shaw@protocol.ai>",
|
||||
|
160
src/connection/connection.d.ts
vendored
Normal file
160
src/connection/connection.d.ts
vendored
Normal file
@ -0,0 +1,160 @@
|
||||
export = 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;
|
||||
/**
|
||||
* Creates an instance of Connection.
|
||||
* @param {object} properties properties of the connection.
|
||||
* @param {multiaddr} [properties.localAddr] local multiaddr of the connection if known.
|
||||
* @param {multiaddr} [properties.remoteAddr] remote multiaddr of the connection.
|
||||
* @param {PeerId} properties.localPeer local peer-id.
|
||||
* @param {PeerId} properties.remotePeer remote peer-id.
|
||||
* @param {function} properties.newStream new stream muxer function.
|
||||
* @param {function} properties.close close raw connection function.
|
||||
* @param {function(): Stream[]} properties.getStreams get streams from muxer function.
|
||||
* @param {object} properties.stat metadata of the connection.
|
||||
* @param {string} properties.stat.direction connection establishment direction ("inbound" or "outbound").
|
||||
* @param {object} properties.stat.timeline connection relevant events timestamp.
|
||||
* @param {string} properties.stat.timeline.open connection opening timestamp.
|
||||
* @param {string} properties.stat.timeline.upgraded connection upgraded timestamp.
|
||||
* @param {string} [properties.stat.multiplexer] connection multiplexing identifier.
|
||||
* @param {string} [properties.stat.encryption] connection encryption method identifier.
|
||||
*/
|
||||
constructor({ localAddr, remoteAddr, localPeer, remotePeer, newStream, close, getStreams, stat }: {
|
||||
localAddr: multiaddr | undefined;
|
||||
remoteAddr: multiaddr | undefined;
|
||||
localPeer: PeerId;
|
||||
remotePeer: PeerId;
|
||||
newStream: Function;
|
||||
close: Function;
|
||||
getStreams: () => any[];
|
||||
stat: {
|
||||
direction: string;
|
||||
timeline: {
|
||||
open: string;
|
||||
upgraded: string;
|
||||
};
|
||||
multiplexer: string | undefined;
|
||||
encryption: string | undefined;
|
||||
};
|
||||
});
|
||||
/**
|
||||
* Connection identifier.
|
||||
*/
|
||||
id: string;
|
||||
/**
|
||||
* Observed multiaddr of the local peer
|
||||
*/
|
||||
localAddr: multiaddr | undefined;
|
||||
/**
|
||||
* Observed multiaddr of the remote peer
|
||||
*/
|
||||
remoteAddr: multiaddr | undefined;
|
||||
/**
|
||||
* Local peer id.
|
||||
*/
|
||||
localPeer: PeerId;
|
||||
/**
|
||||
* Remote peer id.
|
||||
*/
|
||||
remotePeer: PeerId;
|
||||
/**
|
||||
* Connection metadata.
|
||||
*/
|
||||
_stat: {
|
||||
status: "open";
|
||||
direction: string;
|
||||
timeline: {
|
||||
open: string;
|
||||
upgraded: string;
|
||||
};
|
||||
multiplexer?: string | undefined;
|
||||
encryption?: string | undefined;
|
||||
};
|
||||
/**
|
||||
* Reference to the new stream function of the multiplexer
|
||||
*/
|
||||
_newStream: Function;
|
||||
/**
|
||||
* Reference to the close function of the raw connection
|
||||
*/
|
||||
_close: Function;
|
||||
/**
|
||||
* Reference to the getStreams function of the muxer
|
||||
*/
|
||||
_getStreams: () => any[];
|
||||
/**
|
||||
* 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";
|
||||
direction: string;
|
||||
timeline: {
|
||||
open: string;
|
||||
upgraded: string;
|
||||
};
|
||||
multiplexer?: string | undefined;
|
||||
encryption?: string | undefined;
|
||||
};
|
||||
/**
|
||||
* Get all the streams of the muxer.
|
||||
* @this {Connection}
|
||||
*/
|
||||
get streams(): any[];
|
||||
/**
|
||||
* Create a new stream from this connection
|
||||
* @param {string[]} protocols intended protocol for the stream
|
||||
* @return {Promise<{stream: Stream, protocol: string}>} with muxed+multistream-selected stream and selected protocol
|
||||
*/
|
||||
newStream(protocols: string[]): Promise<{
|
||||
stream: any;
|
||||
protocol: string;
|
||||
}>;
|
||||
/**
|
||||
* Add a stream when it is opened to the registry.
|
||||
* @param {*} 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
|
||||
* @return {void}
|
||||
*/
|
||||
addStream(muxedStream: any, { 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.
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
close(): Promise<void>;
|
||||
_closing: any;
|
||||
get [connectionSymbol](): boolean;
|
||||
}
|
||||
import multiaddr = require("multiaddr");
|
||||
import PeerId = require("peer-id");
|
||||
declare const connectionSymbol: unique symbol;
|
@ -1,235 +1,13 @@
|
||||
'use strict'
|
||||
/* eslint-disable valid-jsdoc */
|
||||
|
||||
const PeerId = require('peer-id')
|
||||
const multiaddr = require('multiaddr')
|
||||
const errCode = require('err-code')
|
||||
const { OPEN, CLOSING, CLOSED } = require('./status')
|
||||
const Status = require('./status')
|
||||
|
||||
const connectionSymbol = Symbol.for('@libp2p/interface-connection/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 {string} direction - connection establishment direction ("inbound" or "outbound").
|
||||
* @property {Timeline} timeline - connection relevant events 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.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
class 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 }) {
|
||||
validateArgs(localAddr, localPeer, remotePeer, newStream, close, getStreams, stat)
|
||||
|
||||
/**
|
||||
* Connection identifier.
|
||||
*/
|
||||
this.id = (parseInt(String(Math.random() * 1e9))).toString(36) + Date.now()
|
||||
|
||||
/**
|
||||
* Observed multiaddr of the local peer
|
||||
*/
|
||||
this.localAddr = localAddr
|
||||
|
||||
/**
|
||||
* Observed multiaddr of the remote peer
|
||||
*/
|
||||
this.remoteAddr = remoteAddr
|
||||
|
||||
/**
|
||||
* Local peer id.
|
||||
*/
|
||||
this.localPeer = localPeer
|
||||
|
||||
/**
|
||||
* Remote peer id.
|
||||
*/
|
||||
this.remotePeer = remotePeer
|
||||
|
||||
/**
|
||||
* Connection metadata.
|
||||
*
|
||||
* @type {ConectionStat & {status: Status}}
|
||||
*/
|
||||
this._stat = {
|
||||
...stat,
|
||||
status: OPEN
|
||||
}
|
||||
|
||||
/**
|
||||
* Reference to the new stream function of the multiplexer
|
||||
*/
|
||||
this._newStream = newStream
|
||||
|
||||
/**
|
||||
* Reference to the close function of the raw connection
|
||||
*/
|
||||
this._close = close
|
||||
|
||||
/**
|
||||
* Reference to the getStreams function of the muxer
|
||||
*/
|
||||
this._getStreams = getStreams
|
||||
|
||||
/**
|
||||
* Connection streams registry
|
||||
*/
|
||||
this.registry = new Map()
|
||||
|
||||
/**
|
||||
* User provided tags
|
||||
*
|
||||
* @type {string[]}
|
||||
*/
|
||||
this.tags = []
|
||||
}
|
||||
|
||||
get [Symbol.toStringTag] () {
|
||||
return 'Connection'
|
||||
}
|
||||
|
||||
get [connectionSymbol] () {
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given value is a `Connection` instance.
|
||||
*
|
||||
* @param {any} other
|
||||
* @returns {other is Connection}
|
||||
*/
|
||||
static isConnection (other) {
|
||||
return Boolean(other && other[connectionSymbol])
|
||||
}
|
||||
|
||||
/**
|
||||
* Get connection metadata
|
||||
*
|
||||
* @this {Connection}
|
||||
*/
|
||||
get stat () {
|
||||
return this._stat
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the streams of the muxer.
|
||||
*
|
||||
* @this {Connection}
|
||||
*/
|
||||
get streams () {
|
||||
return this._getStreams()
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
async newStream (protocols) {
|
||||
if (this.stat.status === CLOSING) {
|
||||
throw errCode(new Error('the connection is being closed'), 'ERR_CONNECTION_BEING_CLOSED')
|
||||
}
|
||||
|
||||
if (this.stat.status === CLOSED) {
|
||||
throw errCode(new Error('the connection is closed'), 'ERR_CONNECTION_CLOSED')
|
||||
}
|
||||
|
||||
if (!Array.isArray(protocols)) protocols = [protocols]
|
||||
|
||||
const { stream, protocol } = await this._newStream(protocols)
|
||||
|
||||
this.addStream(stream, { protocol })
|
||||
|
||||
return {
|
||||
stream,
|
||||
protocol
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, { protocol, metadata = {} }) {
|
||||
// Add metadata for the stream
|
||||
this.registry.set(muxedStream.id, {
|
||||
protocol,
|
||||
...metadata
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove stream registry after it is closed.
|
||||
*
|
||||
* @param {string} id - identifier of the stream
|
||||
*/
|
||||
removeStream (id) {
|
||||
this.registry.delete(id)
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the connection.
|
||||
*
|
||||
* @returns {Promise<void>}
|
||||
*/
|
||||
async close () {
|
||||
if (this.stat.status === CLOSED) {
|
||||
return
|
||||
}
|
||||
|
||||
if (this._closing) {
|
||||
return this._closing
|
||||
}
|
||||
|
||||
this.stat.status = CLOSING
|
||||
|
||||
// Close raw connection
|
||||
this._closing = await this._close()
|
||||
|
||||
this._stat.timeline.close = Date.now()
|
||||
this.stat.status = CLOSED
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Connection
|
||||
|
||||
function validateArgs (localAddr, localPeer, remotePeer, newStream, close, getStreams, stat) {
|
||||
if (localAddr && !multiaddr.isMultiaddr(localAddr)) {
|
||||
throw errCode(new Error('localAddr must be an instance of multiaddr'), 'ERR_INVALID_PARAMETERS')
|
||||
@ -275,3 +53,198 @@ function validateArgs (localAddr, localPeer, remotePeer, newStream, close, getSt
|
||||
throw errCode(new Error('connection upgraded timestamp must be provided'), 'ERR_INVALID_PARAMETERS')
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* An implementation of the js-libp2p connection.
|
||||
* Any libp2p transport should use an upgrader to return this connection.
|
||||
*/
|
||||
class Connection {
|
||||
/**
|
||||
* Creates an instance of Connection.
|
||||
* @param {object} properties properties of the connection.
|
||||
* @param {multiaddr} [properties.localAddr] local multiaddr of the connection if known.
|
||||
* @param {multiaddr} [properties.remoteAddr] remote multiaddr of the connection.
|
||||
* @param {PeerId} properties.localPeer local peer-id.
|
||||
* @param {PeerId} properties.remotePeer remote peer-id.
|
||||
* @param {function} properties.newStream new stream muxer function.
|
||||
* @param {function} properties.close close raw connection function.
|
||||
* @param {function(): Stream[]} properties.getStreams get streams from muxer function.
|
||||
* @param {object} properties.stat metadata of the connection.
|
||||
* @param {string} properties.stat.direction connection establishment direction ("inbound" or "outbound").
|
||||
* @param {object} properties.stat.timeline connection relevant events timestamp.
|
||||
* @param {string} properties.stat.timeline.open connection opening timestamp.
|
||||
* @param {string} properties.stat.timeline.upgraded connection upgraded timestamp.
|
||||
* @param {string} [properties.stat.multiplexer] connection multiplexing identifier.
|
||||
* @param {string} [properties.stat.encryption] connection encryption method identifier.
|
||||
*/
|
||||
constructor ({ localAddr, remoteAddr, localPeer, remotePeer, newStream, close, getStreams, stat }) {
|
||||
validateArgs(localAddr, localPeer, remotePeer, newStream, close, getStreams, stat)
|
||||
|
||||
/**
|
||||
* Connection identifier.
|
||||
*/
|
||||
this.id = (parseInt(Math.random() * 1e9)).toString(36) + Date.now()
|
||||
|
||||
/**
|
||||
* Observed multiaddr of the local peer
|
||||
*/
|
||||
this.localAddr = localAddr
|
||||
|
||||
/**
|
||||
* Observed multiaddr of the remote peer
|
||||
*/
|
||||
this.remoteAddr = remoteAddr
|
||||
|
||||
/**
|
||||
* Local peer id.
|
||||
*/
|
||||
this.localPeer = localPeer
|
||||
|
||||
/**
|
||||
* Remote peer id.
|
||||
*/
|
||||
this.remotePeer = remotePeer
|
||||
|
||||
/**
|
||||
* Connection metadata.
|
||||
*/
|
||||
this._stat = {
|
||||
...stat,
|
||||
status: Status.OPEN
|
||||
}
|
||||
|
||||
/**
|
||||
* Reference to the new stream function of the multiplexer
|
||||
*/
|
||||
this._newStream = newStream
|
||||
|
||||
/**
|
||||
* Reference to the close function of the raw connection
|
||||
*/
|
||||
this._close = close
|
||||
|
||||
/**
|
||||
* Reference to the getStreams function of the muxer
|
||||
*/
|
||||
this._getStreams = getStreams
|
||||
|
||||
/**
|
||||
* Connection streams registry
|
||||
*/
|
||||
this.registry = new Map()
|
||||
|
||||
/**
|
||||
* User provided tags
|
||||
* @type {string[]}
|
||||
*/
|
||||
this.tags = []
|
||||
}
|
||||
|
||||
get [Symbol.toStringTag] () {
|
||||
return 'Connection'
|
||||
}
|
||||
|
||||
get [connectionSymbol] () {
|
||||
return true
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the given value is a `Connection` instance.
|
||||
*
|
||||
* @param {any} other
|
||||
* @returns {other is Connection}
|
||||
*/
|
||||
static isConnection (other) {
|
||||
return Boolean(other && other[connectionSymbol])
|
||||
}
|
||||
|
||||
/**
|
||||
* Get connection metadata
|
||||
* @this {Connection}
|
||||
*/
|
||||
get stat () {
|
||||
return this._stat
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all the streams of the muxer.
|
||||
* @this {Connection}
|
||||
*/
|
||||
get streams () {
|
||||
return this._getStreams()
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new stream from this connection
|
||||
* @param {string[]} protocols intended protocol for the stream
|
||||
* @return {Promise<{stream: Stream, protocol: string}>} with muxed+multistream-selected stream and selected protocol
|
||||
*/
|
||||
async newStream (protocols) {
|
||||
if (this.stat.status === Status.CLOSING) {
|
||||
throw errCode(new Error('the connection is being closed'), 'ERR_CONNECTION_BEING_CLOSED')
|
||||
}
|
||||
|
||||
if (this.stat.status === Status.CLOSED) {
|
||||
throw errCode(new Error('the connection is closed'), 'ERR_CONNECTION_CLOSED')
|
||||
}
|
||||
|
||||
if (!Array.isArray(protocols)) protocols = [protocols]
|
||||
|
||||
const { stream, protocol } = await this._newStream(protocols)
|
||||
|
||||
this.addStream(stream, { protocol })
|
||||
|
||||
return {
|
||||
stream,
|
||||
protocol
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a stream when it is opened to the registry.
|
||||
* @param {*} 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
|
||||
* @return {void}
|
||||
*/
|
||||
addStream (muxedStream, { protocol, metadata = {} }) {
|
||||
// Add metadata for the stream
|
||||
this.registry.set(muxedStream.id, {
|
||||
protocol,
|
||||
...metadata
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove stream registry after it is closed.
|
||||
* @param {string} id identifier of the stream
|
||||
*/
|
||||
removeStream (id) {
|
||||
this.registry.delete(id)
|
||||
}
|
||||
|
||||
/**
|
||||
* Close the connection.
|
||||
* @return {Promise<void>}
|
||||
*/
|
||||
async close () {
|
||||
if (this.stat.status === Status.CLOSED) {
|
||||
return
|
||||
}
|
||||
|
||||
if (this._closing) {
|
||||
return this._closing
|
||||
}
|
||||
|
||||
this.stat.status = Status.CLOSING
|
||||
|
||||
// Close raw connection
|
||||
this._closing = await this._close()
|
||||
|
||||
this._stat.timeline.close = Date.now()
|
||||
this.stat.status = Status.CLOSED
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = Connection
|
||||
|
1
src/connection/index.d.ts
vendored
Normal file
1
src/connection/index.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
export var Connection: typeof import('./connection');
|
@ -1,3 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
/**
|
||||
* @module connection/index
|
||||
* @type {typeof import('./connection')}
|
||||
*/
|
||||
exports.Connection = require('./connection')
|
||||
|
3
src/connection/status.d.ts
vendored
Normal file
3
src/connection/status.d.ts
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export const OPEN: 'open';
|
||||
export const CLOSING: 'closing';
|
||||
export const CLOSED: 'closed';
|
@ -1,12 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
const STATUS = {
|
||||
module.exports = {
|
||||
OPEN: /** @type {'open'} */('open'),
|
||||
CLOSING: /** @type {'closing'} */('closing'),
|
||||
CLOSED: /** @type {'closed'} */('closed')
|
||||
}
|
||||
module.exports = STATUS
|
||||
|
||||
/**
|
||||
* @typedef {STATUS[keyof STATUS]} Status
|
||||
*/
|
||||
|
@ -74,7 +74,6 @@ module.exports = (test) => {
|
||||
let timelineProxy
|
||||
const proxyHandler = {
|
||||
set () {
|
||||
// @ts-ignore - TS fails to infer here
|
||||
return Reflect.set(...arguments)
|
||||
}
|
||||
}
|
||||
@ -139,9 +138,7 @@ module.exports = (test) => {
|
||||
expect(connection.stat.timeline.close).to.not.exist()
|
||||
|
||||
await connection.close()
|
||||
// @ts-ignore - fails to infer callCount
|
||||
expect(proxyHandler.set.callCount).to.equal(1)
|
||||
// @ts-ignore - fails to infer getCall
|
||||
const [obj, key, value] = proxyHandler.set.getCall(0).args
|
||||
expect(obj).to.eql(connection.stat.timeline)
|
||||
expect(key).to.equal('close')
|
||||
|
@ -13,4 +13,3 @@ export class InvalidCryptoTransmissionError extends Error {
|
||||
constructor(message?: string);
|
||||
code: string;
|
||||
}
|
||||
//# sourceMappingURL=errors.d.ts.map
|
@ -6,7 +6,7 @@ const expect = chai.expect
|
||||
chai.use(require('dirty-chai'))
|
||||
|
||||
const duplexPair = require('it-pair/duplex')
|
||||
const { pipe } = require('it-pipe')
|
||||
const pipe = require('it-pipe')
|
||||
const PeerId = require('peer-id')
|
||||
const { collect } = require('streaming-iterables')
|
||||
const uint8arrayFromString = require('uint8arrays/from-string')
|
||||
|
@ -1,24 +0,0 @@
|
||||
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;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user