@libp2p/interface 1.7.0 → 2.0.0-18dd3cb26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/index.min.js +1 -1
  2. package/dist/src/connection/index.d.ts +32 -8
  3. package/dist/src/connection/index.d.ts.map +1 -1
  4. package/dist/src/connection/index.js.map +1 -1
  5. package/dist/src/connection-encrypter/index.d.ts +11 -2
  6. package/dist/src/connection-encrypter/index.d.ts.map +1 -1
  7. package/dist/src/errors.d.ts +200 -25
  8. package/dist/src/errors.d.ts.map +1 -1
  9. package/dist/src/errors.js +280 -43
  10. package/dist/src/errors.js.map +1 -1
  11. package/dist/src/event-target.d.ts +0 -4
  12. package/dist/src/event-target.d.ts.map +1 -1
  13. package/dist/src/event-target.js +0 -1
  14. package/dist/src/event-target.js.map +1 -1
  15. package/dist/src/index.d.ts +12 -3
  16. package/dist/src/index.d.ts.map +1 -1
  17. package/dist/src/index.js.map +1 -1
  18. package/dist/src/keys/index.d.ts +85 -24
  19. package/dist/src/keys/index.d.ts.map +1 -1
  20. package/dist/src/keys/index.js +29 -3
  21. package/dist/src/keys/index.js.map +1 -1
  22. package/dist/src/metrics/index.d.ts +8 -8
  23. package/dist/src/metrics/index.d.ts.map +1 -1
  24. package/dist/src/peer-id/index.d.ts +120 -18
  25. package/dist/src/peer-id/index.d.ts.map +1 -1
  26. package/dist/src/peer-id/index.js +8 -1
  27. package/dist/src/peer-id/index.js.map +1 -1
  28. package/dist/src/peer-store/index.d.ts +5 -2
  29. package/dist/src/peer-store/index.d.ts.map +1 -1
  30. package/dist/src/pubsub/index.d.ts +2 -1
  31. package/dist/src/pubsub/index.d.ts.map +1 -1
  32. package/dist/src/pubsub/index.js.map +1 -1
  33. package/dist/src/record/index.d.ts +2 -2
  34. package/dist/src/record/index.d.ts.map +1 -1
  35. package/dist/src/stream-handler/index.d.ts +3 -3
  36. package/dist/src/stream-handler/index.d.ts.map +1 -1
  37. package/dist/src/topology/index.d.ts +4 -3
  38. package/dist/src/topology/index.d.ts.map +1 -1
  39. package/dist/src/transport/index.d.ts +3 -7
  40. package/dist/src/transport/index.d.ts.map +1 -1
  41. package/package.json +1 -1
  42. package/src/connection/index.ts +34 -8
  43. package/src/connection-encrypter/index.ts +12 -2
  44. package/src/errors.ts +320 -49
  45. package/src/event-target.ts +0 -2
  46. package/src/index.ts +12 -4
  47. package/src/keys/index.ts +112 -24
  48. package/src/metrics/index.ts +8 -8
  49. package/src/peer-id/index.ts +140 -19
  50. package/src/peer-store/index.ts +5 -2
  51. package/src/pubsub/index.ts +2 -1
  52. package/src/record/index.ts +2 -2
  53. package/src/stream-handler/index.ts +3 -3
  54. package/src/topology/index.ts +4 -3
  55. package/src/transport/index.ts +3 -8
  56. package/dist/typedoc-urls.json +0 -175
package/dist/index.min.js CHANGED
@@ -1,3 +1,3 @@
1
1
  (function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PInterface = factory()}(typeof self !== 'undefined' ? self : this, function () {
2
- "use strict";var Libp2PInterface=(()=>{var n=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var L=Object.prototype.hasOwnProperty;var _=(e,t)=>{for(var o in t)n(e,o,{get:t[o],enumerable:!0})},g=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of I(t))!L.call(e,r)&&r!==o&&n(e,r,{get:()=>t[r],enumerable:!(s=A(t,r))||s.enumerable});return e};var v=e=>g(n({},"__esModule",{value:!0}),e);var z={};_(z,{AbortError:()=>c,AggregateCodeError:()=>l,CodeError:()=>a,CustomEvent:()=>h,ERR_INVALID_MESSAGE:()=>X,ERR_INVALID_PARAMETERS:()=>G,ERR_NOT_FOUND:()=>j,ERR_TIMEOUT:()=>F,Ed25519:()=>w,FaultTolerance:()=>p,InvalidCryptoExchangeError:()=>x,InvalidCryptoTransmissionError:()=>m,KEEP_ALIVE:()=>U,RSA:()=>P,StrictNoSign:()=>k,StrictSign:()=>V,TopicValidatorResult:()=>i,TypedEventEmitter:()=>E,UnexpectedPeerError:()=>f,connectionSymbol:()=>S,contentRoutingSymbol:()=>T,isConnection:()=>N,isPeerId:()=>O,isStartable:()=>d,isTransport:()=>B,peerDiscoverySymbol:()=>M,peerIdSymbol:()=>R,peerRoutingSymbol:()=>C,secp256k1:()=>D,serviceCapabilities:()=>K,serviceDependencies:()=>q,setMaxListeners:()=>u,start:()=>Y,stop:()=>H,transportSymbol:()=>b});var S=Symbol.for("@libp2p/connection");function N(e){return e!=null&&!!e[S]}var T=Symbol.for("@libp2p/content-routing");var w="Ed25519",P="RSA",D="secp256k1";var M=Symbol.for("@libp2p/peer-discovery");var R=Symbol.for("@libp2p/peer-id");function O(e){return e!=null&&!!e[R]}var C=Symbol.for("@libp2p/peer-routing");var U="keep-alive";var V="StrictSign",k="StrictNoSign",i;(function(e){e.Accept="accept",e.Ignore="ignore",e.Reject="reject"})(i||(i={}));var b=Symbol.for("@libp2p/transport");function B(e){return e!=null&&!!e[b]}var p;(function(e){e[e.FATAL_ALL=0]="FATAL_ALL",e[e.NO_FATAL=1]="NO_FATAL"})(p||(p={}));var c=class e extends Error{code;type;constructor(t="The operation was aborted"){super(t),this.name="AbortError",this.code=e.code,this.type=e.type}static code="ABORT_ERR";static type="aborted"},a=class extends Error{code;props;constructor(t,o,s){super(t),this.code=o,this.name=s?.name??"CodeError",this.props=s??{}}},l=class extends AggregateError{code;props;constructor(t,o,s,r){super(t,o),this.code=s,this.name=r?.name??"AggregateCodeError",this.props=r??{}}},f=class e extends Error{code;constructor(t="Unexpected Peer"){super(t),this.name="UnexpectedPeerError",this.code=e.code}static code="ERR_UNEXPECTED_PEER"},x=class e extends Error{code;constructor(t="Invalid crypto exchange"){super(t),this.name="InvalidCryptoExchangeError",this.code=e.code}static code="ERR_INVALID_CRYPTO_EXCHANGE"},m=class e extends Error{code;constructor(t="Invalid crypto transmission"){super(t),this.name="InvalidCryptoTransmissionError",this.code=e.code}static code="ERR_INVALID_CRYPTO_TRANSMISSION"},F="ERR_TIMEOUT",G="ERR_INVALID_PARAMETERS",j="ERR_NOT_FOUND",X="ERR_INVALID_MESSAGE";var u=(e,...t)=>{try{[...t]}catch{}};var E=class extends EventTarget{#t=new Map;constructor(){super(),u(1/0,this)}listenerCount(t){let o=this.#t.get(t);return o==null?0:o.length}addEventListener(t,o,s){super.addEventListener(t,o,s);let r=this.#t.get(t);r==null&&(r=[],this.#t.set(t,r)),r.push({callback:o,once:(s!==!0&&s!==!1&&s?.once)??!1})}removeEventListener(t,o,s){super.removeEventListener(t.toString(),o??null,s);let r=this.#t.get(t);r!=null&&(r=r.filter(({callback:y})=>y!==o),this.#t.set(t,r))}dispatchEvent(t){let o=super.dispatchEvent(t),s=this.#t.get(t.type);return s==null||(s=s.filter(({once:r})=>!r),this.#t.set(t.type,s)),o}safeDispatchEvent(t,o={}){return this.dispatchEvent(new h(t,o))}},h=globalThis.CustomEvent;function d(e){return e!=null&&typeof e.start=="function"&&typeof e.stop=="function"}async function Y(...e){let t=[];for(let o of e)d(o)&&t.push(o);await Promise.all(t.map(async o=>{o.beforeStart!=null&&await o.beforeStart()})),await Promise.all(t.map(async o=>{await o.start()})),await Promise.all(t.map(async o=>{o.afterStart!=null&&await o.afterStart()}))}async function H(...e){let t=[];for(let o of e)d(o)&&t.push(o);await Promise.all(t.map(async o=>{o.beforeStop!=null&&await o.beforeStop()})),await Promise.all(t.map(async o=>{await o.stop()})),await Promise.all(t.map(async o=>{o.afterStop!=null&&await o.afterStop()}))}var K=Symbol.for("@libp2p/service-capabilities"),q=Symbol.for("@libp2p/service-dependencies");return v(z);})();
2
+ "use strict";var Libp2PInterface=(()=>{var n=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var W=Object.prototype.hasOwnProperty;var X=(t,r)=>{for(var e in r)n(t,e,{get:r[e],enumerable:!0})},Y=(t,r,e,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of V(r))!W.call(t,o)&&o!==e&&n(t,o,{get:()=>r[o],enumerable:!(s=Q(r,o))||s.enumerable});return t};var Z=t=>Y(n({},"__esModule",{value:!0}),t);var mr={};X(mr,{AbortError:()=>c,AlreadyStartedError:()=>U,ConnectionClosedError:()=>E,ConnectionClosingError:()=>f,ConnectionFailedError:()=>h,DialError:()=>D,FaultTolerance:()=>i,InvalidCIDError:()=>P,InvalidCryptoExchangeError:()=>l,InvalidMessageError:()=>w,InvalidMultiaddrError:()=>g,InvalidMultihashError:()=>L,InvalidParametersError:()=>u,InvalidPeerIdError:()=>I,InvalidPrivateKeyError:()=>x,InvalidPublicKeyError:()=>m,KEEP_ALIVE:()=>sr,LimitedConnectionError:()=>K,ListenError:()=>N,MuxerClosedError:()=>y,NotFoundError:()=>v,NotStartedError:()=>M,ProtocolError:()=>C,StreamResetError:()=>b,StreamStateError:()=>S,StrictNoSign:()=>ar,StrictSign:()=>nr,TimeoutError:()=>T,TooManyInboundProtocolStreamsError:()=>R,TooManyOutboundProtocolStreamsError:()=>_,TopicValidatorResult:()=>a,TypedEventEmitter:()=>B,UnexpectedPeerError:()=>p,UnsupportedKeyTypeError:()=>F,UnsupportedOperationError:()=>d,UnsupportedProtocolError:()=>A,connectionSymbol:()=>q,contentRoutingSymbol:()=>k,isConnection:()=>$,isPeerId:()=>er,isPrivateKey:()=>rr,isPublicKey:()=>z,isStartable:()=>j,isTransport:()=>ir,peerDiscoverySymbol:()=>tr,peerIdSymbol:()=>G,peerRoutingSymbol:()=>or,serviceCapabilities:()=>lr,serviceDependencies:()=>ur,setMaxListeners:()=>O,start:()=>cr,stop:()=>pr,transportSymbol:()=>H});var q=Symbol.for("@libp2p/connection");function $(t){return t!=null&&!!t[q]}var k=Symbol.for("@libp2p/content-routing");function z(t){return t==null?!1:(t.type==="RSA"||t.type==="Ed25519"||t.type==="secp256k1")&&t.raw instanceof Uint8Array&&typeof t.equals=="function"&&typeof t.toMultihash=="function"&&typeof t.toCID=="function"&&typeof t.verify=="function"}function rr(t){return t==null?!1:(t.type==="RSA"||t.type==="Ed25519"||t.type==="secp256k1")&&z(t.publicKey)&&t.raw instanceof Uint8Array&&typeof t.equals=="function"&&typeof t.sign=="function"}var tr=Symbol.for("@libp2p/peer-discovery");var G=Symbol.for("@libp2p/peer-id");function er(t){return!!t?.[G]}var or=Symbol.for("@libp2p/peer-routing");var sr="keep-alive";var nr="StrictSign",ar="StrictNoSign",a;(function(t){t.Accept="accept",t.Ignore="ignore",t.Reject="reject"})(a||(a={}));var H=Symbol.for("@libp2p/transport");function ir(t){return t!=null&&!!t[H]}var i;(function(t){t[t.FATAL_ALL=0]="FATAL_ALL",t[t.NO_FATAL=1]="NO_FATAL"})(i||(i={}));var c=class extends Error{static name="AbortError";constructor(r="The operation was aborted"){super(r),this.name="AbortError"}},p=class extends Error{static name="UnexpectedPeerError";constructor(r="Unexpected Peer"){super(r),this.name="UnexpectedPeerError"}},l=class extends Error{static name="InvalidCryptoExchangeError";constructor(r="Invalid crypto exchange"){super(r),this.name="InvalidCryptoExchangeError"}},u=class extends Error{static name="InvalidParametersError";constructor(r="Invalid parameters"){super(r),this.name="InvalidParametersError"}},m=class extends Error{static name="InvalidPublicKeyError";constructor(r="Invalid public key"){super(r),this.name="InvalidPublicKeyError"}},x=class extends Error{static name="InvalidPrivateKeyError";constructor(r="Invalid private key"){super(r),this.name="InvalidPrivateKeyError"}},d=class extends Error{static name="UnsupportedOperationError";constructor(r="Unsupported operation"){super(r),this.name="UnsupportedOperationError"}},f=class extends Error{static name="ConnectionClosingError";constructor(r="The connection is closing"){super(r),this.name="ConnectionClosingError"}},E=class extends Error{static name="ConnectionClosedError";constructor(r="The connection is closed"){super(r),this.name="ConnectionClosedError"}},h=class extends Error{static name="ConnectionFailedError";constructor(r="Connection failed"){super(r),this.name="ConnectionFailedError"}},y=class extends Error{static name="MuxerClosedError";constructor(r="The muxer is closed"){super(r),this.name="MuxerClosedError"}},b=class extends Error{static name="StreamResetError";constructor(r="The stream has been reset"){super(r),this.name="StreamResetError"}},S=class extends Error{static name="StreamStateError";constructor(r="The stream is in an invalid state"){super(r),this.name="StreamStateError"}},v=class extends Error{static name="NotFoundError";constructor(r="Not found"){super(r),this.name="NotFoundError"}},I=class extends Error{static name="InvalidPeerIdError";constructor(r="Invalid PeerID"){super(r),this.name="InvalidPeerIdError"}},g=class extends Error{static name="InvalidMultiaddrError";constructor(r="Invalid multiaddr"){super(r),this.name="InvalidMultiaddrError"}},P=class extends Error{static name="InvalidCIDError";constructor(r="Invalid CID"){super(r),this.name="InvalidCIDError"}},L=class extends Error{static name="InvalidMultihashError";constructor(r="Invalid Multihash"){super(r),this.name="InvalidMultihashError"}},A=class extends Error{static name="UnsupportedProtocolError";constructor(r="Unsupported protocol error"){super(r),this.name="UnsupportedProtocolError"}},w=class extends Error{static name="InvalidMessageError";constructor(r="Invalid message"){super(r),this.name="InvalidMessageError"}},C=class extends Error{static name="ProtocolError";constructor(r="Protocol error"){super(r),this.name="ProtocolError"}},T=class extends Error{static name="TimeoutError";constructor(r="Timed out"){super(r),this.name="TimeoutError"}},M=class extends Error{static name="NotStartedError";constructor(r="Not started"){super(r),this.name="NotStartedError"}},U=class extends Error{static name="AlreadyStartedError";constructor(r="Already started"){super(r),this.name="AlreadyStartedError"}},D=class extends Error{static name="DialError";constructor(r="Dial error"){super(r),this.name="DialError"}},N=class extends Error{static name="ListenError";constructor(r="Listen error"){super(r),this.name="ListenError"}},K=class extends Error{static name="LimitedConnectionError";constructor(r="Limited connection"){super(r),this.name="LimitedConnectionError"}},R=class extends Error{static name="TooManyInboundProtocolStreamsError";constructor(r="Too many inbound protocol streams"){super(r),this.name="TooManyInboundProtocolStreamsError"}},_=class extends Error{static name="TooManyOutboundProtocolStreamsError";constructor(r="Too many outbound protocol streams"){super(r),this.name="TooManyOutboundProtocolStreamsError"}},F=class extends Error{static name="UnsupportedKeyTypeError";constructor(r="Unsupported key type"){super(r),this.name="UnsupportedKeyTypeError"}};var O=(t,...r)=>{try{[...r]}catch{}};var B=class extends EventTarget{#r=new Map;constructor(){super(),O(1/0,this)}listenerCount(r){let e=this.#r.get(r);return e==null?0:e.length}addEventListener(r,e,s){super.addEventListener(r,e,s);let o=this.#r.get(r);o==null&&(o=[],this.#r.set(r,o)),o.push({callback:e,once:(s!==!0&&s!==!1&&s?.once)??!1})}removeEventListener(r,e,s){super.removeEventListener(r.toString(),e??null,s);let o=this.#r.get(r);o!=null&&(o=o.filter(({callback:J})=>J!==e),this.#r.set(r,o))}dispatchEvent(r){let e=super.dispatchEvent(r),s=this.#r.get(r.type);return s==null||(s=s.filter(({once:o})=>!o),this.#r.set(r.type,s)),e}safeDispatchEvent(r,e={}){return this.dispatchEvent(new CustomEvent(r,e))}};function j(t){return t!=null&&typeof t.start=="function"&&typeof t.stop=="function"}async function cr(...t){let r=[];for(let e of t)j(e)&&r.push(e);await Promise.all(r.map(async e=>{e.beforeStart!=null&&await e.beforeStart()})),await Promise.all(r.map(async e=>{await e.start()})),await Promise.all(r.map(async e=>{e.afterStart!=null&&await e.afterStart()}))}async function pr(...t){let r=[];for(let e of t)j(e)&&r.push(e);await Promise.all(r.map(async e=>{e.beforeStop!=null&&await e.beforeStop()})),await Promise.all(r.map(async e=>{await e.stop()})),await Promise.all(r.map(async e=>{e.afterStop!=null&&await e.afterStop()}))}var lr=Symbol.for("@libp2p/service-capabilities"),ur=Symbol.for("@libp2p/service-dependencies");return Z(mr);})();
3
3
  return Libp2PInterface}));
@@ -157,12 +157,16 @@ export interface NewStreamOptions extends AbortOptions {
157
157
  */
158
158
  maxOutboundStreams?: number;
159
159
  /**
160
- * Opt-in to running over a transient connection - one that has time/data limits
161
- * placed on it.
160
+ * Opt-in to running over a limited connection - one that has restrictions
161
+ * on the amount of data that may be transferred or how long it may be open for.
162
+ *
163
+ * These limits are typically enforced by a relay server, if the protocol
164
+ * will be transferring a lot of data or the stream will be open for a long time
165
+ * consider upgrading to a direct connection before opening the stream.
162
166
  *
163
167
  * @default false
164
168
  */
165
- runOnTransientConnection?: boolean;
169
+ runOnLimitedConnection?: boolean;
166
170
  /**
167
171
  * By default when negotiating a protocol the dialer writes then protocol name
168
172
  * then reads the response.
@@ -191,6 +195,27 @@ export interface NewStreamOptions extends AbortOptions {
191
195
  negotiateFully?: boolean;
192
196
  }
193
197
  export type ConnectionStatus = 'open' | 'closing' | 'closed';
198
+ /**
199
+ * Connection limits are present on connections that are only allowed to
200
+ * transfer a certain amount of bytes or be open for a certain number
201
+ * of seconds.
202
+ *
203
+ * These limits are applied by Circuit Relay v2 servers, for example and
204
+ * the connection will normally be closed abruptly if the limits are
205
+ * exceeded.
206
+ */
207
+ export interface ConnectionLimits {
208
+ /**
209
+ * If present this is the number of bytes remaining that may be
210
+ * transferred over this connection
211
+ */
212
+ bytes?: bigint;
213
+ /**
214
+ * If present this is the number of seconds that this connection will
215
+ * remain open for
216
+ */
217
+ seconds?: number;
218
+ }
194
219
  /**
195
220
  * A Connection is a high-level representation of a connection
196
221
  * to a remote peer that may have been secured by encryption and
@@ -239,12 +264,11 @@ export interface Connection {
239
264
  */
240
265
  status: ConnectionStatus;
241
266
  /**
242
- * A transient connection is one that is not expected to be open for very long
243
- * or one that cannot transfer very much data, such as one being used as a
244
- * circuit relay connection. Protocols need to explicitly opt-in to being run
245
- * over transient connections.
267
+ * If present, this connection has limits applied to it, perhaps by an
268
+ * intermediate relay. Once the limits have been reached the connection will
269
+ * be closed by the relay.
246
270
  */
247
- transient: boolean;
271
+ limits?: ConnectionLimits;
248
272
  /**
249
273
  * The time in milliseconds it takes to make a round trip to the remote peer.
250
274
  *
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAA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KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAA;AAC1D,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/connection/index.ts"],"names":[],"mappings":"AAwVA,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC,CAAA;AAEhE,MAAM,UAAU,YAAY,CAAE,KAAU;IACtC,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC,CAAA;AAC1D,CAAC"}
@@ -1,7 +1,16 @@
1
1
  import type { MultiaddrConnection } from '../connection/index.js';
2
+ import type { AbortOptions } from '../index.js';
2
3
  import type { PeerId } from '../peer-id/index.js';
3
4
  import type { Duplex } from 'it-stream-types';
4
5
  import type { Uint8ArrayList } from 'uint8arraylist';
6
+ /**
7
+ * If the remote PeerId is known and passed as an option, the securing operation
8
+ * will throw if the remote peer cannot prove it has the private key that
9
+ * corresponds to the public key the remote PeerId is derived from.
10
+ */
11
+ export interface SecureConnectionOptions extends AbortOptions {
12
+ remotePeer?: PeerId;
13
+ }
5
14
  /**
6
15
  * A libp2p connection encrypter module must be compliant to this interface
7
16
  * to ensure all exchanged data between two peers is encrypted.
@@ -13,13 +22,13 @@ export interface ConnectionEncrypter<Extension = unknown> {
13
22
  * pass it for extra verification, otherwise it will be determined during
14
23
  * the handshake.
15
24
  */
16
- secureOutbound<Stream extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> = MultiaddrConnection>(localPeer: PeerId, connection: Stream, remotePeer?: PeerId): Promise<SecuredConnection<Stream, Extension>>;
25
+ secureOutbound<Stream extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> = MultiaddrConnection>(connection: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream, Extension>>;
17
26
  /**
18
27
  * Decrypt incoming data. If the remote PeerId is known,
19
28
  * pass it for extra verification, otherwise it will be determined during
20
29
  * the handshake
21
30
  */
22
- secureInbound<Stream extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> = MultiaddrConnection>(localPeer: PeerId, connection: Stream, remotePeer?: PeerId): Promise<SecuredConnection<Stream, Extension>>;
31
+ secureInbound<Stream extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> = MultiaddrConnection>(connection: Stream, options?: SecureConnectionOptions): Promise<SecuredConnection<Stream, Extension>>;
23
32
  }
24
33
  export interface SecuredConnection<Stream = any, Extension = unknown> {
25
34
  conn: Stream;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/connection-encrypter/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAC7C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD;;;GAGG;AACH,MAAM,WAAW,mBAAmB,CAAC,SAAS,GAAG,OAAO;IACtD,QAAQ,EAAE,MAAM,CAAA;IAEhB;;;;OAIG;IACH,cAAc,CAAE,MAAM,SAAS,MAAM,CAAC,cAAc,CAAC,UAAU,GAAG,cAAc,CAAC,CAAC,GAAG,mBAAmB,EAAG,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAA;IAErN;;;;OAIG;IACH,aAAa,CAAE,MAAM,SAAS,MAAM,CAAC,cAAc,CAAC,UAAU,GAAG,cAAc,CAAC,CAAC,GAAG,mBAAmB,EAAG,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,C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B,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAA;CAChN;AAED,MAAM,WAAW,iBAAiB,CAAC,MAAM,GAAG,GAAG,EAAE,SAAS,GAAG,OAAO;IAClE,IAAI,EAAE,MAAM,CAAA;IACZ,gBAAgB,CAAC,EAAE,SAAS,CAAA;IAC5B,UAAU,EAAE,MAAM,CAAA;CACnB"}
@@ -4,39 +4,214 @@
4
4
  * AbortSignal.
5
5
  */
6
6
  export declare class AbortError extends Error {
7
- readonly code: string;
8
- readonly type: string;
7
+ static name: string;
9
8
  constructor(message?: string);
10
- static readonly code = "ABORT_ERR";
11
- static readonly type = "aborted";
12
- }
13
- export declare class CodeError<T extends Record<string, any> = Record<string, never>> extends Error {
14
- readonly code: string;
15
- readonly props: T;
16
- constructor(message: string, code: string, props?: T);
17
- }
18
- export declare class AggregateCodeError<T extends Record<string, any> = Record<string, never>> extends AggregateError {
19
- readonly code: string;
20
- readonly props: T;
21
- constructor(errors: Error[], message: string, code: string, props?: T);
22
9
  }
10
+ /**
11
+ * Thrown when a remote Peer ID does not match the expected one
12
+ */
23
13
  export declare class UnexpectedPeerError extends Error {
24
- code: string;
14
+ static name: string;
25
15
  constructor(message?: string);
26
- static readonly code = "ERR_UNEXPECTED_PEER";
27
16
  }
17
+ /**
18
+ * Thrown when a crypto exchange fails
19
+ */
28
20
  export declare class InvalidCryptoExchangeError extends Error {
29
- code: string;
21
+ static name: string;
22
+ constructor(message?: string);
23
+ }
24
+ /**
25
+ * Thrown when invalid parameters are passed to a function or method call
26
+ */
27
+ export declare class InvalidParametersError extends Error {
28
+ static name: string;
29
+ constructor(message?: string);
30
+ }
31
+ /**
32
+ * Thrown when a public key is invalid
33
+ */
34
+ export declare class InvalidPublicKeyError extends Error {
35
+ static name: string;
36
+ constructor(message?: string);
37
+ }
38
+ /**
39
+ * Thrown when a private key is invalid
40
+ */
41
+ export declare class InvalidPrivateKeyError extends Error {
42
+ static name: string;
43
+ constructor(message?: string);
44
+ }
45
+ /**
46
+ * Thrown when a operation is unsupported
47
+ */
48
+ export declare class UnsupportedOperationError extends Error {
49
+ static name: string;
50
+ constructor(message?: string);
51
+ }
52
+ /**
53
+ * Thrown when a connection is closing
54
+ */
55
+ export declare class ConnectionClosingError extends Error {
56
+ static name: string;
57
+ constructor(message?: string);
58
+ }
59
+ /**
60
+ * Thrown when a connection is closed
61
+ */
62
+ export declare class ConnectionClosedError extends Error {
63
+ static name: string;
64
+ constructor(message?: string);
65
+ }
66
+ /**
67
+ * Thrown when a connection fails
68
+ */
69
+ export declare class ConnectionFailedError extends Error {
70
+ static name: string;
71
+ constructor(message?: string);
72
+ }
73
+ /**
74
+ * Thrown when the muxer is closed and an attempt to open a stream occurs
75
+ */
76
+ export declare class MuxerClosedError extends Error {
77
+ static name: string;
78
+ constructor(message?: string);
79
+ }
80
+ /**
81
+ * Thrown when a protocol stream is reset by the remote muxer
82
+ */
83
+ export declare class StreamResetError extends Error {
84
+ static name: string;
85
+ constructor(message?: string);
86
+ }
87
+ /**
88
+ * Thrown when a stream is in an invalid state
89
+ */
90
+ export declare class StreamStateError extends Error {
91
+ static name: string;
92
+ constructor(message?: string);
93
+ }
94
+ /**
95
+ * Thrown when a value could not be found
96
+ */
97
+ export declare class NotFoundError extends Error {
98
+ static name: string;
99
+ constructor(message?: string);
100
+ }
101
+ /**
102
+ * Thrown when an invalid peer ID is encountered
103
+ */
104
+ export declare class InvalidPeerIdError extends Error {
105
+ static name: string;
106
+ constructor(message?: string);
107
+ }
108
+ /**
109
+ * Thrown when an invalid multiaddr is encountered
110
+ */
111
+ export declare class InvalidMultiaddrError extends Error {
112
+ static name: string;
113
+ constructor(message?: string);
114
+ }
115
+ /**
116
+ * Thrown when an invalid CID is encountered
117
+ */
118
+ export declare class InvalidCIDError extends Error {
119
+ static name: string;
120
+ constructor(message?: string);
121
+ }
122
+ /**
123
+ * Thrown when an invalid multihash is encountered
124
+ */
125
+ export declare class InvalidMultihashError extends Error {
126
+ static name: string;
127
+ constructor(message?: string);
128
+ }
129
+ /**
130
+ * Thrown when a protocol is not supported
131
+ */
132
+ export declare class UnsupportedProtocolError extends Error {
133
+ static name: string;
134
+ constructor(message?: string);
135
+ }
136
+ /**
137
+ * An invalid or malformed message was encountered during a protocol exchange
138
+ */
139
+ export declare class InvalidMessageError extends Error {
140
+ static name: string;
141
+ constructor(message?: string);
142
+ }
143
+ /**
144
+ * Thrown when a remote peer sends a structurally valid message that does not
145
+ * comply with the protocol
146
+ */
147
+ export declare class ProtocolError extends Error {
148
+ static name: string;
149
+ constructor(message?: string);
150
+ }
151
+ /**
152
+ * Throw when an operation times out
153
+ */
154
+ export declare class TimeoutError extends Error {
155
+ static name: string;
156
+ constructor(message?: string);
157
+ }
158
+ /**
159
+ * Thrown when a startable component is interacted with but it has not been
160
+ * started yet
161
+ */
162
+ export declare class NotStartedError extends Error {
163
+ static name: string;
164
+ constructor(message?: string);
165
+ }
166
+ /**
167
+ * Thrown when a component is started that has already been started
168
+ */
169
+ export declare class AlreadyStartedError extends Error {
170
+ static name: string;
171
+ constructor(message?: string);
172
+ }
173
+ /**
174
+ * Thrown when dialing an address failed
175
+ */
176
+ export declare class DialError extends Error {
177
+ static name: string;
178
+ constructor(message?: string);
179
+ }
180
+ /**
181
+ * Thrown when listening on an address failed
182
+ */
183
+ export declare class ListenError extends Error {
184
+ static name: string;
30
185
  constructor(message?: string);
31
- static readonly code = "ERR_INVALID_CRYPTO_EXCHANGE";
32
186
  }
33
- export declare class InvalidCryptoTransmissionError extends Error {
34
- code: string;
187
+ /**
188
+ * This error is thrown when a limited connection is encountered, i.e. if the
189
+ * user tried to open a stream on a connection for a protocol that is not
190
+ * configured to run over limited connections.
191
+ */
192
+ export declare class LimitedConnectionError extends Error {
193
+ static name: string;
194
+ constructor(message?: string);
195
+ }
196
+ /**
197
+ * This error is thrown where there are too many inbound protocols streams open
198
+ */
199
+ export declare class TooManyInboundProtocolStreamsError extends Error {
200
+ static name: string;
201
+ constructor(message?: string);
202
+ }
203
+ /**
204
+ * This error is thrown where there are too many outbound protocols streams open
205
+ */
206
+ export declare class TooManyOutboundProtocolStreamsError extends Error {
207
+ static name: string;
208
+ constructor(message?: string);
209
+ }
210
+ /**
211
+ * Thrown when and attempt to operate on an unsupported key was made
212
+ */
213
+ export declare class UnsupportedKeyTypeError extends Error {
214
+ static name: string;
35
215
  constructor(message?: string);
36
- static readonly code = "ERR_INVALID_CRYPTO_TRANSMISSION";
37
216
  }
38
- export declare const ERR_TIMEOUT = "ERR_TIMEOUT";
39
- export declare const ERR_INVALID_PARAMETERS = "ERR_INVALID_PARAMETERS";
40
- export declare const ERR_NOT_FOUND = "ERR_NOT_FOUND";
41
- export declare const ERR_INVALID_MESSAGE = "ERR_INVALID_MESSAGE";
42
217
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,SAAgB,IAAI,EAAE,MAAM,CAAA;IAC5B,SAAgB,IAAI,EAAE,MAAM,CAAA;gBAEf,OAAO,GAAE,MAAoC;IAO1D,MAAM,CAAC,QAAQ,CAAC,IAAI,eAAc;IAElC,MAAM,CAAC,QAAQ,CAAC,IAAI,aAAY;CACjC;AAED,qBAAa,SAAS,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAE,SAAQ,KAAK;aAKvE,IAAI,EAAE,MAAM;IAJ9B,SAAgB,KAAK,EAAE,CAAC,CAAA;gBAGtB,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EAC5B,KAAK,CAAC,EAAE,CAAC;CAOZ;AAED,qBAAa,kBAAkB,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAE,SAAQ,c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