Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@libp2p/interface

Package Overview
Dependencies
Maintainers
6
Versions
535
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@libp2p/interface - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1-34455b5f2

2

dist/index.min.js
(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 H=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.prototype.hasOwnProperty;var V=(t,r)=>{for(var e in r)n(t,e,{get:r[e],enumerable:!0})},W=(t,r,e,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of J(r))!Q.call(t,o)&&o!==e&&n(t,o,{get:()=>r[o],enumerable:!(s=H(r,o))||s.enumerable});return t};var X=t=>W(n({},"__esModule",{value:!0}),t);var lr={};V(lr,{AbortError:()=>c,AlreadyStartedError:()=>D,ConnectionClosedError:()=>E,ConnectionClosingError:()=>f,ConnectionFailedError:()=>h,DialError:()=>N,FaultTolerance:()=>i,InvalidCIDError:()=>L,InvalidCryptoExchangeError:()=>l,InvalidMessageError:()=>A,InvalidMultiaddrError:()=>g,InvalidMultihashError:()=>P,InvalidParametersError:()=>m,InvalidPeerIdError:()=>I,InvalidPrivateKeyError:()=>x,InvalidPublicKeyError:()=>u,KEEP_ALIVE:()=>er,LimitedConnectionError:()=>k,ListenError:()=>U,MuxerClosedError:()=>b,NotFoundError:()=>v,NotStartedError:()=>M,ProtocolError:()=>C,StreamResetError:()=>y,StreamStateError:()=>S,StrictNoSign:()=>sr,StrictSign:()=>or,TimeoutError:()=>T,TooManyInboundProtocolStreamsError:()=>_,TooManyOutboundProtocolStreamsError:()=>F,TopicValidatorResult:()=>a,TypedEventEmitter:()=>B,UnexpectedPeerError:()=>p,UnsupportedKeyTypeError:()=>K,UnsupportedOperationError:()=>d,UnsupportedProtocolError:()=>w,connectionSymbol:()=>j,contentRoutingSymbol:()=>Z,isConnection:()=>Y,isPeerId:()=>rr,isStartable:()=>R,isTransport:()=>nr,peerDiscoverySymbol:()=>$,peerIdSymbol:()=>q,peerRoutingSymbol:()=>tr,serviceCapabilities:()=>cr,serviceDependencies:()=>pr,setMaxListeners:()=>O,start:()=>ar,stop:()=>ir,transportSymbol:()=>z});var j=Symbol.for("@libp2p/connection");function Y(t){return t!=null&&!!t[j]}var Z=Symbol.for("@libp2p/content-routing");var $=Symbol.for("@libp2p/peer-discovery");var q=Symbol.for("@libp2p/peer-id");function rr(t){return!!t?.[q]}var tr=Symbol.for("@libp2p/peer-routing");var er="keep-alive";var or="StrictSign",sr="StrictNoSign",a;(function(t){t.Accept="accept",t.Ignore="ignore",t.Reject="reject"})(a||(a={}));var z=Symbol.for("@libp2p/transport");function nr(t){return t!=null&&!!t[z]}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"}},m=class extends Error{static name="InvalidParametersError";constructor(r="Invalid parameters"){super(r),this.name="InvalidParametersError"}},u=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"}},b=class extends Error{static name="MuxerClosedError";constructor(r="The muxer is closed"){super(r),this.name="MuxerClosedError"}},y=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"}},L=class extends Error{static name="InvalidCIDError";constructor(r="Invalid CID"){super(r),this.name="InvalidCIDError"}},P=class extends Error{static name="InvalidMultihashError";constructor(r="Invalid Multihash"){super(r),this.name="InvalidMultihashError"}},w=class extends Error{static name="UnsupportedProtocolError";constructor(r="Unsupported protocol error"){super(r),this.name="UnsupportedProtocolError"}},A=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"}},D=class extends Error{static name="AlreadyStartedError";constructor(r="Already started"){super(r),this.name="AlreadyStartedError"}},N=class extends Error{static name="DialError";constructor(r="Dial error"){super(r),this.name="DialError"}},U=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"}},_=class extends Error{static name="TooManyInboundProtocolStreamsError";constructor(r="Too many inbound protocol streams"){super(r),this.name="TooManyInboundProtocolStreamsError"}},F=class extends Error{static name="TooManyOutboundProtocolStreamsError";constructor(r="Too many outbound protocol streams"){super(r),this.name="TooManyOutboundProtocolStreamsError"}},K=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:G})=>G!==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 R(t){return t!=null&&typeof t.start=="function"&&typeof t.stop=="function"}async function ar(...t){let r=[];for(let e of t)R(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 ir(...t){let r=[];for(let e of t)R(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 cr=Symbol.for("@libp2p/service-capabilities"),pr=Symbol.for("@libp2p/service-dependencies");return X(lr);})();
"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);})();
return Libp2PInterface}));

@@ -53,2 +53,7 @@ import type { CID } from 'multiformats/cid';

/**
* Returns true if the passed argument has type overlap with the `PublicKey`
* interface. Can be used to disambiguate object types.
*/
export declare function isPublicKey(key?: any): key is PublicKey;
/**
* Generic private key interface

@@ -87,3 +92,8 @@ */

export type PrivateKey = RSAPrivateKey | Ed25519PrivateKey | Secp256k1PrivateKey;
/**
* Returns true if the passed argument has type overlap with the `PrivateKey`
* interface. Can be used to disambiguate object types.
*/
export declare function isPrivateKey(key?: any): key is PrivateKey;
export {};
//# sourceMappingURL=index.d.ts.map

@@ -1,2 +0,30 @@

export {};
/**
* Returns true if the passed argument has type overlap with the `PublicKey`
* interface. Can be used to disambiguate object types.
*/
export function isPublicKey(key) {
if (key == null) {
return false;
}
return (key.type === 'RSA' || key.type === 'Ed25519' || key.type === 'secp256k1') &&
key.raw instanceof Uint8Array &&
typeof key.equals === 'function' &&
typeof key.toMultihash === 'function' &&
typeof key.toCID === 'function' &&
typeof key.verify === 'function';
}
/**
* Returns true if the passed argument has type overlap with the `PrivateKey`
* interface. Can be used to disambiguate object types.
*/
export function isPrivateKey(key) {
if (key == null) {
return false;
}
return (key.type === 'RSA' || key.type === 'Ed25519' || key.type === 'secp256k1') &&
isPublicKey(key.publicKey) &&
key.raw instanceof Uint8Array &&
typeof key.equals === 'function' &&
typeof key.sign === 'function';
}
//# sourceMappingURL=index.js.map
{
"name": "@libp2p/interface",
"version": "2.0.0",
"version": "2.0.1-34455b5f2",
"description": "The interface implemented by a libp2p node",

@@ -5,0 +5,0 @@ "license": "Apache-2.0 OR MIT",

@@ -60,2 +60,19 @@ import type { CID } from 'multiformats/cid'

/**
* Returns true if the passed argument has type overlap with the `PublicKey`
* interface. Can be used to disambiguate object types.
*/
export function isPublicKey (key?: any): key is PublicKey {
if (key == null) {
return false
}
return (key.type === 'RSA' || key.type === 'Ed25519' || key.type === 'secp256k1') &&
key.raw instanceof Uint8Array &&
typeof key.equals === 'function' &&
typeof key.toMultihash === 'function' &&
typeof key.toCID === 'function' &&
typeof key.verify === 'function'
}
/**
* Generic private key interface

@@ -96,1 +113,17 @@ */

export type PrivateKey = RSAPrivateKey | Ed25519PrivateKey | Secp256k1PrivateKey
/**
* Returns true if the passed argument has type overlap with the `PrivateKey`
* interface. Can be used to disambiguate object types.
*/
export function isPrivateKey (key?: any): key is PrivateKey {
if (key == null) {
return false
}
return (key.type === 'RSA' || key.type === 'Ed25519' || key.type === 'secp256k1') &&
isPublicKey(key.publicKey) &&
key.raw instanceof Uint8Array &&
typeof key.equals === 'function' &&
typeof key.sign === 'function'
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc