@libp2p/interface
Advanced tools
Comparing version 1.4.1-863b3de03 to 1.4.1-8e4fdcde9
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.Libp2PInterface = factory()}(typeof self !== 'undefined' ? self : this, function () { | ||
"use strict";var Libp2PInterface=(()=>{var n=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var o in t)n(e,o,{get:t[o],enumerable:!0})},N=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of L(t))!_.call(e,r)&&r!==o&&n(e,r,{get:()=>t[r],enumerable:!(s=I(t,r))||s.enumerable});return e};var v=e=>N(n({},"__esModule",{value:!0}),e);var q={};g(q,{AbortError:()=>p,AggregateCodeError:()=>l,CodeError:()=>a,CustomEvent:()=>b,ERR_INVALID_MESSAGE:()=>Y,ERR_INVALID_PARAMETERS:()=>j,ERR_NOT_FOUND:()=>X,ERR_TIMEOUT:()=>G,Ed25519:()=>P,FaultTolerance:()=>i,InvalidCryptoExchangeError:()=>x,InvalidCryptoTransmissionError:()=>m,KEEP_ALIVE:()=>V,RSA:()=>M,StrictNoSign:()=>B,StrictSign:()=>k,TopicValidatorResult:()=>c,TypedEventEmitter:()=>E,UnexpectedPeerError:()=>f,connectionSymbol:()=>R,contentRoutingSymbol:()=>w,isConnection:()=>T,isPeerId:()=>C,isStartable:()=>S,isTransport:()=>F,peerDiscoverySymbol:()=>D,peerIdSymbol:()=>h,peerRoutingSymbol:()=>U,secp256k1:()=>O,setMaxListeners:()=>u,start:()=>H,stop:()=>K,transportSymbol:()=>A});var R=Symbol.for("@libp2p/connection");function T(e){return e!=null&&!!e[R]}var w=Symbol.for("@libp2p/content-routing");var P="Ed25519",M="RSA",O="secp256k1";var D=Symbol.for("@libp2p/peer-discovery");var h=Symbol.for("@libp2p/peer-id");function C(e){return e!=null&&!!e[h]}var U=Symbol.for("@libp2p/peer-routing");var V="keep-alive";var k="StrictSign",B="StrictNoSign",c;(function(e){e.Accept="accept",e.Ignore="ignore",e.Reject="reject"})(c||(c={}));var A=Symbol.for("@libp2p/transport");function F(e){return e!=null&&!!e[A]}var i;(function(e){e[e.FATAL_ALL=0]="FATAL_ALL",e[e.NO_FATAL=1]="NO_FATAL"})(i||(i={}));var p=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"},G="ERR_TIMEOUT",j="ERR_INVALID_PARAMETERS",X="ERR_NOT_FOUND",Y="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 b(t,o))}},d=class extends Event{detail;constructor(t,o){super(t,o),this.detail=o?.detail}},b=globalThis.CustomEvent??d;function S(e){return e!=null&&typeof e.start=="function"&&typeof e.stop=="function"}async function H(...e){let t=[];for(let o of e)S(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 K(...e){let t=[];for(let o of e)S(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()}))}return v(q);})(); | ||
"use strict";var Libp2PInterface=(()=>{var n=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var g=(e,t)=>{for(var o in t)n(e,o,{get:t[o],enumerable:!0})},v=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of L(t))!_.call(e,r)&&r!==o&&n(e,r,{get:()=>t[r],enumerable:!(s=I(t,r))||s.enumerable});return e};var N=e=>v(n({},"__esModule",{value:!0}),e);var J={};g(J,{AbortError:()=>p,AggregateCodeError:()=>l,CodeError:()=>a,CustomEvent:()=>y,ERR_INVALID_MESSAGE:()=>Y,ERR_INVALID_PARAMETERS:()=>j,ERR_NOT_FOUND:()=>X,ERR_TIMEOUT:()=>G,Ed25519:()=>P,FaultTolerance:()=>c,InvalidCryptoExchangeError:()=>x,InvalidCryptoTransmissionError:()=>m,KEEP_ALIVE:()=>V,RSA:()=>D,StrictNoSign:()=>B,StrictSign:()=>k,TopicValidatorResult:()=>i,TypedEventEmitter:()=>d,UnexpectedPeerError:()=>f,connectionSymbol:()=>R,contentRoutingSymbol:()=>w,isConnection:()=>T,isPeerId:()=>C,isStartable:()=>S,isTransport:()=>F,peerDiscoverySymbol:()=>O,peerIdSymbol:()=>b,peerRoutingSymbol:()=>U,secp256k1:()=>M,serviceCapabilities:()=>q,serviceDependencies:()=>z,setMaxListeners:()=>u,start:()=>H,stop:()=>K,transportSymbol:()=>h});var R=Symbol.for("@libp2p/connection");function T(e){return e!=null&&!!e[R]}var w=Symbol.for("@libp2p/content-routing");var P="Ed25519",D="RSA",M="secp256k1";var O=Symbol.for("@libp2p/peer-discovery");var b=Symbol.for("@libp2p/peer-id");function C(e){return e!=null&&!!e[b]}var U=Symbol.for("@libp2p/peer-routing");var V="keep-alive";var k="StrictSign",B="StrictNoSign",i;(function(e){e.Accept="accept",e.Ignore="ignore",e.Reject="reject"})(i||(i={}));var h=Symbol.for("@libp2p/transport");function F(e){return e!=null&&!!e[h]}var c;(function(e){e[e.FATAL_ALL=0]="FATAL_ALL",e[e.NO_FATAL=1]="NO_FATAL"})(c||(c={}));var p=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"},G="ERR_TIMEOUT",j="ERR_INVALID_PARAMETERS",X="ERR_NOT_FOUND",Y="ERR_INVALID_MESSAGE";var u=(e,...t)=>{try{[...t]}catch{}};var d=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:A})=>A!==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 y(t,o))}},E=class extends Event{detail;constructor(t,o){super(t,o),this.detail=o?.detail}},y=globalThis.CustomEvent??E;function S(e){return e!=null&&typeof e.start=="function"&&typeof e.stop=="function"}async function H(...e){let t=[];for(let o of e)S(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 K(...e){let t=[];for(let o of e)S(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 q=Symbol.for("@libp2p/service-capabilities"),z=Symbol.for("@libp2p/service-dependencies");return N(J);})(); | ||
return Libp2PInterface})); |
@@ -14,3 +14,3 @@ import type { MultiaddrConnection } from '../connection/index.js'; | ||
*/ | ||
denyDialPeer?(peerId: PeerId): Promise<boolean>; | ||
denyDialPeer?(peerId: PeerId): Promise<boolean> | boolean; | ||
/** | ||
@@ -25,3 +25,3 @@ * denyDialMultiaddr tests whether we're permitted to dial the specified | ||
*/ | ||
denyDialMultiaddr?(multiaddr: Multiaddr): Promise<boolean>; | ||
denyDialMultiaddr?(multiaddr: Multiaddr): Promise<boolean> | boolean; | ||
/** | ||
@@ -35,3 +35,3 @@ * denyInboundConnection tests whether an incipient inbound connection is allowed. | ||
*/ | ||
denyInboundConnection?(maConn: MultiaddrConnection): Promise<boolean>; | ||
denyInboundConnection?(maConn: MultiaddrConnection): Promise<boolean> | boolean; | ||
/** | ||
@@ -45,3 +45,3 @@ * denyOutboundConnection tests whether an incipient outbound connection is allowed. | ||
*/ | ||
denyOutboundConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean>; | ||
denyOutboundConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean> | boolean; | ||
/** | ||
@@ -57,3 +57,3 @@ * denyInboundEncryptedConnection tests whether a given connection, now encrypted, | ||
*/ | ||
denyInboundEncryptedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean>; | ||
denyInboundEncryptedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean> | boolean; | ||
/** | ||
@@ -69,3 +69,3 @@ * denyOutboundEncryptedConnection tests whether a given connection, now encrypted, | ||
*/ | ||
denyOutboundEncryptedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean>; | ||
denyOutboundEncryptedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean> | boolean; | ||
/** | ||
@@ -79,3 +79,3 @@ * denyInboundUpgradedConnection tests whether a fully capable connection is allowed. | ||
*/ | ||
denyInboundUpgradedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean>; | ||
denyInboundUpgradedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean> | boolean; | ||
/** | ||
@@ -89,3 +89,3 @@ * denyOutboundUpgradedConnection tests whether a fully capable connection is allowed. | ||
*/ | ||
denyOutboundUpgradedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean>; | ||
denyOutboundUpgradedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean> | boolean; | ||
/** | ||
@@ -97,3 +97,3 @@ * denyInboundRelayReservation tests whether a remote peer is allowed make a | ||
*/ | ||
denyInboundRelayReservation?(source: PeerId): Promise<boolean>; | ||
denyInboundRelayReservation?(source: PeerId): Promise<boolean> | boolean; | ||
/** | ||
@@ -108,3 +108,3 @@ * denyOutboundRelayedConnection tests whether a remote peer is allowed to open a relayed | ||
*/ | ||
denyOutboundRelayedConnection?(source: PeerId, destination: PeerId): Promise<boolean>; | ||
denyOutboundRelayedConnection?(source: PeerId, destination: PeerId): Promise<boolean> | boolean; | ||
/** | ||
@@ -119,3 +119,3 @@ * denyInboundRelayedConnection tests whether a remote peer is allowed to open a relayed | ||
*/ | ||
denyInboundRelayedConnection?(relay: PeerId, remotePeer: PeerId): Promise<boolean>; | ||
denyInboundRelayedConnection?(relay: PeerId, remotePeer: PeerId): Promise<boolean> | boolean; | ||
/** | ||
@@ -126,4 +126,4 @@ * Used by the address book to filter passed addresses. | ||
*/ | ||
filterMultiaddrForPeer?(peer: PeerId, multiaddr: Multiaddr): Promise<boolean>; | ||
filterMultiaddrForPeer?(peer: PeerId, multiaddr: Multiaddr): Promise<boolean> | boolean; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
@@ -625,10 +625,2 @@ /** | ||
/** | ||
* Returns a new type with all fields marked optional. | ||
* | ||
* Borrowed from the tsdef module. | ||
*/ | ||
export type RecursivePartial<T> = { | ||
[P in keyof T]?: T[P] extends Array<infer I> ? Array<RecursivePartial<I>> : T[P] extends (...args: any[]) => any ? T[P] : RecursivePartial<T[P]>; | ||
}; | ||
/** | ||
* When a routing operation involves reading values, these options allow | ||
@@ -653,2 +645,18 @@ * controlling where the values are read from. By default libp2p will check | ||
} | ||
/** | ||
* This symbol is used by libp2p services to define the capabilities they can | ||
* provide to other libp2p services. | ||
* | ||
* The service should define a property with this symbol as the key and the | ||
* value should be a string array of provided capabilities. | ||
*/ | ||
export declare const serviceCapabilities: unique symbol; | ||
/** | ||
* This symbol is used by libp2p services to define the capabilities they | ||
* require from other libp2p services. | ||
* | ||
* The service should define a property with this symbol as the key and the | ||
* value should be a string array of required capabilities. | ||
*/ | ||
export declare const serviceDependencies: unique symbol; | ||
export * from './connection/index.js'; | ||
@@ -655,0 +663,0 @@ export * from './connection-encrypter/index.js'; |
@@ -16,2 +16,18 @@ /** | ||
*/ | ||
/** | ||
* This symbol is used by libp2p services to define the capabilities they can | ||
* provide to other libp2p services. | ||
* | ||
* The service should define a property with this symbol as the key and the | ||
* value should be a string array of provided capabilities. | ||
*/ | ||
export const serviceCapabilities = Symbol.for('@libp2p/service-capabilities'); | ||
/** | ||
* This symbol is used by libp2p services to define the capabilities they | ||
* require from other libp2p services. | ||
* | ||
* The service should define a property with this symbol as the key and the | ||
* value should be a string array of required capabilities. | ||
*/ | ||
export const serviceDependencies = Symbol.for('@libp2p/service-dependencies'); | ||
export * from './connection/index.js'; | ||
@@ -18,0 +34,0 @@ export * from './connection-encrypter/index.js'; |
{ | ||
"name": "@libp2p/interface", | ||
"version": "1.4.1-863b3de03", | ||
"version": "1.4.1-8e4fdcde9", | ||
"description": "The interface implemented by a libp2p node", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0 OR MIT", |
@@ -15,3 +15,3 @@ import type { MultiaddrConnection } from '../connection/index.js' | ||
*/ | ||
denyDialPeer?(peerId: PeerId): Promise<boolean> | ||
denyDialPeer?(peerId: PeerId): Promise<boolean> | boolean | ||
@@ -27,3 +27,3 @@ /** | ||
*/ | ||
denyDialMultiaddr?(multiaddr: Multiaddr): Promise<boolean> | ||
denyDialMultiaddr?(multiaddr: Multiaddr): Promise<boolean> | boolean | ||
@@ -38,3 +38,3 @@ /** | ||
*/ | ||
denyInboundConnection?(maConn: MultiaddrConnection): Promise<boolean> | ||
denyInboundConnection?(maConn: MultiaddrConnection): Promise<boolean> | boolean | ||
@@ -49,3 +49,3 @@ /** | ||
*/ | ||
denyOutboundConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean> | ||
denyOutboundConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean> | boolean | ||
@@ -62,3 +62,3 @@ /** | ||
*/ | ||
denyInboundEncryptedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean> | ||
denyInboundEncryptedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean> | boolean | ||
@@ -75,3 +75,3 @@ /** | ||
*/ | ||
denyOutboundEncryptedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean> | ||
denyOutboundEncryptedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean> | boolean | ||
@@ -86,3 +86,3 @@ /** | ||
*/ | ||
denyInboundUpgradedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean> | ||
denyInboundUpgradedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean> | boolean | ||
@@ -97,3 +97,3 @@ /** | ||
*/ | ||
denyOutboundUpgradedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean> | ||
denyOutboundUpgradedConnection?(peerId: PeerId, maConn: MultiaddrConnection): Promise<boolean> | boolean | ||
@@ -106,3 +106,3 @@ /** | ||
*/ | ||
denyInboundRelayReservation?(source: PeerId): Promise<boolean> | ||
denyInboundRelayReservation?(source: PeerId): Promise<boolean> | boolean | ||
@@ -118,3 +118,3 @@ /** | ||
*/ | ||
denyOutboundRelayedConnection?(source: PeerId, destination: PeerId): Promise<boolean> | ||
denyOutboundRelayedConnection?(source: PeerId, destination: PeerId): Promise<boolean> | boolean | ||
@@ -130,3 +130,3 @@ /** | ||
*/ | ||
denyInboundRelayedConnection?(relay: PeerId, remotePeer: PeerId): Promise<boolean> | ||
denyInboundRelayedConnection?(relay: PeerId, remotePeer: PeerId): Promise<boolean> | boolean | ||
@@ -138,3 +138,3 @@ /** | ||
*/ | ||
filterMultiaddrForPeer?(peer: PeerId, multiaddr: Multiaddr): Promise<boolean> | ||
filterMultiaddrForPeer?(peer: PeerId, multiaddr: Multiaddr): Promise<boolean> | boolean | ||
} |
@@ -688,11 +688,2 @@ /** | ||
/** | ||
* Returns a new type with all fields marked optional. | ||
* | ||
* Borrowed from the tsdef module. | ||
*/ | ||
export type RecursivePartial<T> = { | ||
[P in keyof T]?: T[P] extends Array<infer I> ? Array<RecursivePartial<I>> : T[P] extends (...args: any[]) => any ? T[P] : RecursivePartial<T[P]> | ||
} | ||
/** | ||
* When a routing operation involves reading values, these options allow | ||
@@ -719,2 +710,20 @@ * controlling where the values are read from. By default libp2p will check | ||
/** | ||
* This symbol is used by libp2p services to define the capabilities they can | ||
* provide to other libp2p services. | ||
* | ||
* The service should define a property with this symbol as the key and the | ||
* value should be a string array of provided capabilities. | ||
*/ | ||
export const serviceCapabilities = Symbol.for('@libp2p/service-capabilities') | ||
/** | ||
* This symbol is used by libp2p services to define the capabilities they | ||
* require from other libp2p services. | ||
* | ||
* The service should define a property with this symbol as the key and the | ||
* value should be a string array of required capabilities. | ||
*/ | ||
export const serviceDependencies = Symbol.for('@libp2p/service-dependencies') | ||
export * from './connection/index.js' | ||
@@ -721,0 +730,0 @@ export * from './connection-encrypter/index.js' |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
232047
5700