@libp2p/interface 2.7.0 → 2.8.0

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.
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 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 dr={};X(dr,{AbortError:()=>c,AlreadyStartedError:()=>U,ConnectionClosedError:()=>E,ConnectionClosingError:()=>f,ConnectionFailedError:()=>h,DialError:()=>D,FaultTolerance:()=>i,InvalidCIDError:()=>P,InvalidCryptoExchangeError:()=>l,InvalidMessageError:()=>w,InvalidMultiaddrError:()=>g,InvalidMultihashError:()=>A,InvalidParametersError:()=>u,InvalidPeerIdError:()=>I,InvalidPrivateKeyError:()=>x,InvalidPublicKeyError:()=>m,KEEP_ALIVE:()=>sr,LimitedConnectionError:()=>K,ListenError:()=>N,MuxerClosedError:()=>b,NotFoundError:()=>v,NotStartedError:()=>M,ProtocolError:()=>C,StreamResetError:()=>y,StreamStateError:()=>S,StrictNoSign:()=>ar,StrictSign:()=>nr,TimeoutError:()=>T,TooManyInboundProtocolStreamsError:()=>R,TooManyOutboundProtocolStreamsError:()=>_,TopicValidatorResult:()=>a,TypedEventEmitter:()=>F,UnexpectedPeerError:()=>p,UnsupportedKeyTypeError:()=>B,UnsupportedOperationError:()=>d,UnsupportedProtocolError:()=>L,connectionSymbol:()=>j,contentRoutingSymbol:()=>k,isConnection:()=>$,isPeerId:()=>er,isPrivateKey:()=>rr,isPubSub:()=>ir,isPublicKey:()=>q,isStartable:()=>O,isTransport:()=>cr,peerDiscoverySymbol:()=>tr,peerIdSymbol:()=>z,peerRoutingSymbol:()=>or,pubSubSymbol:()=>G,serviceCapabilities:()=>mr,serviceDependencies:()=>xr,setMaxListeners:()=>pr,start:()=>lr,stop:()=>ur,transportSymbol:()=>H});var j=Symbol.for("@libp2p/connection");function $(t){return t!=null&&!!t[j]}var k=Symbol.for("@libp2p/content-routing");function q(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")&&q(t.publicKey)&&t.raw instanceof Uint8Array&&typeof t.equals=="function"&&typeof t.sign=="function"}var tr=Symbol.for("@libp2p/peer-discovery");var z=Symbol.for("@libp2p/peer-id");function er(t){return!!t?.[z]}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 G=Symbol.for("@libp2p/pubsub");function ir(t){return!!t?.[G]}var H=Symbol.for("@libp2p/transport");function cr(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"}},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"}},P=class extends Error{static name="InvalidCIDError";constructor(r="Invalid CID"){super(r),this.name="InvalidCIDError"}},A=class extends Error{static name="InvalidMultihashError";constructor(r="Invalid Multihash"){super(r),this.name="InvalidMultihashError"}},L=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"}},B=class extends Error{static name="UnsupportedKeyTypeError";constructor(r="Unsupported key type"){super(r),this.name="UnsupportedKeyTypeError"}};function pr(){}var F=class extends EventTarget{#r=new Map;constructor(){super()}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 O(t){return t!=null&&typeof t.start=="function"&&typeof t.stop=="function"}async function lr(...t){let r=[];for(let e of t)O(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 ur(...t){let r=[];for(let e of t)O(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 mr=Symbol.for("@libp2p/service-capabilities"),xr=Symbol.for("@libp2p/service-dependencies");return Z(dr);})();
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 dr={};X(dr,{AbortError:()=>c,AlreadyStartedError:()=>M,ConnectionClosedError:()=>E,ConnectionClosingError:()=>f,ConnectionFailedError:()=>h,DialError:()=>U,FaultTolerance:()=>i,InvalidCIDError:()=>P,InvalidCryptoExchangeError:()=>l,InvalidMessageError:()=>C,InvalidMultiaddrError:()=>g,InvalidMultihashError:()=>A,InvalidParametersError:()=>u,InvalidPeerIdError:()=>I,InvalidPrivateKeyError:()=>x,InvalidPublicKeyError:()=>m,KEEP_ALIVE:()=>sr,LimitedConnectionError:()=>K,ListenError:()=>N,MuxerClosedError:()=>b,NotFoundError:()=>v,NotStartedError:()=>D,ProtocolError:()=>w,StreamResetError:()=>S,StreamStateError:()=>y,StrictNoSign:()=>ar,StrictSign:()=>nr,TimeoutError:()=>T,TooManyInboundProtocolStreamsError:()=>R,TooManyOutboundProtocolStreamsError:()=>_,TopicValidatorResult:()=>a,TypedEventEmitter:()=>F,UnexpectedPeerError:()=>p,UnsupportedKeyTypeError:()=>B,UnsupportedOperationError:()=>d,UnsupportedProtocolError:()=>L,connectionSymbol:()=>j,contentRoutingSymbol:()=>k,isConnection:()=>$,isPeerId:()=>er,isPrivateKey:()=>rr,isPubSub:()=>ir,isPublicKey:()=>q,isStartable:()=>O,isTransport:()=>cr,peerDiscoverySymbol:()=>tr,peerIdSymbol:()=>z,peerRoutingSymbol:()=>or,pubSubSymbol:()=>G,serviceCapabilities:()=>mr,serviceDependencies:()=>xr,setMaxListeners:()=>pr,start:()=>lr,stop:()=>ur,transportSymbol:()=>H});var j=Symbol.for("@libp2p/connection");function $(t){return t!=null&&!!t[j]}var k=Symbol.for("@libp2p/content-routing");function q(t){return t==null?!1:(t.type==="RSA"||t.type==="Ed25519"||t.type==="secp256k1"||t.type==="ECDSA")&&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"||t.type==="ECDSA")&&q(t.publicKey)&&t.raw instanceof Uint8Array&&typeof t.equals=="function"&&typeof t.sign=="function"}var tr=Symbol.for("@libp2p/peer-discovery");var z=Symbol.for("@libp2p/peer-id");function er(t){return!!t?.[z]}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 G=Symbol.for("@libp2p/pubsub");function ir(t){return!!t?.[G]}var H=Symbol.for("@libp2p/transport");function cr(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"}},b=class extends Error{static name="MuxerClosedError";constructor(r="The muxer is closed"){super(r),this.name="MuxerClosedError"}},S=class extends Error{static name="StreamResetError";constructor(r="The stream has been reset"){super(r),this.name="StreamResetError"}},y=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"}},A=class extends Error{static name="InvalidMultihashError";constructor(r="Invalid Multihash"){super(r),this.name="InvalidMultihashError"}},L=class extends Error{static name="UnsupportedProtocolError";constructor(r="Unsupported protocol error"){super(r),this.name="UnsupportedProtocolError"}},C=class extends Error{static name="InvalidMessageError";constructor(r="Invalid message"){super(r),this.name="InvalidMessageError"}},w=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"}},D=class extends Error{static name="NotStartedError";constructor(r="Not started"){super(r),this.name="NotStartedError"}},M=class extends Error{static name="AlreadyStartedError";constructor(r="Already started"){super(r),this.name="AlreadyStartedError"}},U=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"}},B=class extends Error{static name="UnsupportedKeyTypeError";constructor(r="Unsupported key type"){super(r),this.name="UnsupportedKeyTypeError"}};function pr(){}var F=class extends EventTarget{#r=new Map;constructor(){super()}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 O(t){return t!=null&&typeof t.start=="function"&&typeof t.stop=="function"}async function lr(...t){let r=[];for(let e of t)O(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 ur(...t){let r=[];for(let e of t)O(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 mr=Symbol.for("@libp2p/service-capabilities"),xr=Symbol.for("@libp2p/service-dependencies");return Z(dr);})();
3
3
  return Libp2PInterface}));
@@ -1,7 +1,7 @@
1
1
  import type { CID } from 'multiformats/cid';
2
2
  import type { MultihashDigest } from 'multiformats/hashes/interface';
3
3
  import type { Uint8ArrayList } from 'uint8arraylist';
4
- export type KeyType = 'RSA' | 'Ed25519' | 'secp256k1';
4
+ export type KeyType = 'RSA' | 'Ed25519' | 'secp256k1' | 'ECDSA';
5
5
  export interface RSAPublicKey {
6
6
  /**
7
7
  * The type of this key
@@ -11,6 +11,10 @@ export interface RSAPublicKey {
11
11
  * PKIX in ASN1 DER format
12
12
  */
13
13
  readonly raw: Uint8Array;
14
+ /**
15
+ * The public key as a JSON web key
16
+ */
17
+ readonly jwk: JsonWebKey;
14
18
  /**
15
19
  * Returns `true` if the passed object matches this key
16
20
  */
@@ -108,7 +112,46 @@ export interface Secp256k1PublicKey {
108
112
  */
109
113
  toString(): string;
110
114
  }
111
- export type PublicKey = RSAPublicKey | Ed25519PublicKey | Secp256k1PublicKey;
115
+ export interface ECDSAPublicKey {
116
+ /**
117
+ * The type of this key
118
+ */
119
+ readonly type: 'ECDSA';
120
+ /**
121
+ * The public key as a DER-encoded PKIMessage
122
+ */
123
+ readonly raw: Uint8Array;
124
+ /**
125
+ * The public key as a JSON web key
126
+ */
127
+ readonly jwk: JsonWebKey;
128
+ /**
129
+ * Returns `true` if the passed object matches this key
130
+ */
131
+ equals(key?: any): boolean;
132
+ /**
133
+ * Returns this public key as an identity hash containing the protobuf wrapped
134
+ * public key
135
+ */
136
+ toMultihash(): MultihashDigest<0x0>;
137
+ /**
138
+ * Return this public key as a CID encoded with the `libp2p-key` codec
139
+ *
140
+ * The digest contains an identity hash containing the protobuf wrapped
141
+ * version of the public key.
142
+ */
143
+ toCID(): CID<unknown, 0x72, 0x0, 1>;
144
+ /**
145
+ * Verify the passed data was signed by the private key corresponding to this
146
+ * public key
147
+ */
148
+ verify(data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean | Promise<boolean>;
149
+ /**
150
+ * Returns this key as a multihash with base58btc encoding
151
+ */
152
+ toString(): string;
153
+ }
154
+ export type PublicKey = RSAPublicKey | Ed25519PublicKey | Secp256k1PublicKey | ECDSAPublicKey;
112
155
  /**
113
156
  * Returns true if the passed argument has type overlap with the `PublicKey`
114
157
  * interface. Can be used to disambiguate object types.
@@ -130,6 +173,10 @@ export interface RSAPrivateKey {
130
173
  * PKIX in ASN1 DER format
131
174
  */
132
175
  readonly raw: Uint8Array;
176
+ /**
177
+ * The private key as a JSON web key
178
+ */
179
+ readonly jwk: JsonWebKey;
133
180
  /**
134
181
  * Returns `true` if the passed object matches this key
135
182
  */
@@ -186,7 +233,34 @@ export interface Secp256k1PrivateKey {
186
233
  */
187
234
  sign(data: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array>;
188
235
  }
189
- export type PrivateKey = RSAPrivateKey | Ed25519PrivateKey | Secp256k1PrivateKey;
236
+ export interface ECDSAPrivateKey {
237
+ /**
238
+ * The type of this key
239
+ */
240
+ readonly type: 'ECDSA';
241
+ /**
242
+ * The public key that corresponds to this private key
243
+ */
244
+ readonly publicKey: ECDSAPublicKey;
245
+ /**
246
+ * The private key as a DER-encoded PKIMessage
247
+ */
248
+ readonly raw: Uint8Array;
249
+ /**
250
+ * The private key as a JSON web key
251
+ */
252
+ readonly jwk: JsonWebKey;
253
+ /**
254
+ * Returns `true` if the passed object matches this key
255
+ */
256
+ equals(key?: any): boolean;
257
+ /**
258
+ * Sign the passed data with this private key and return the signature for
259
+ * later verification
260
+ */
261
+ sign(data: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array>;
262
+ }
263
+ export type PrivateKey = RSAPrivateKey | Ed25519PrivateKey | Secp256k1PrivateKey | ECDSAPrivateKey;
190
264
  /**
191
265
  * Returns true if the passed argument has type overlap with the `PrivateKey`
192
266
  * interface. Can be used to disambiguate object types.
@@ -1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,GAAG,CAAC,EAAE,GAAG,GAAG,OAAO,CAAA;IAE1B;;;OAGG;IACH,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,cAAc,GAAG,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CAC1E;AAED,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAA;IAEtB;;OAEG;IACH,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAA;IAElC;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAA;IAExB;;OAEG;IACH,QAAQ,CAAC,GAAG,EAAE,UAAU,CAAA;IAExB;;OAEG;IACH,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,OAAO,CAAA;IAE1B;;;OAGG;IACH,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,cAAc,GAAG,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CAC1E;AAED,MAAM,MAAM,UAAU,GAAG,aAAa,GAAG,iBAAiB,GAAG,mBAAmB,GAAG,eAAe,CAAA;AAElG;;;GAGG;AACH,wBAAgB,YAAY,CAAE,GAAG,CAAC,EAAE,GAAG,GAAG,GAAG,IAAI,UAAU,CAU1D"}
package/dist/src/keys.js CHANGED
@@ -6,7 +6,7 @@ export function isPublicKey(key) {
6
6
  if (key == null) {
7
7
  return false;
8
8
  }
9
- return (key.type === 'RSA' || key.type === 'Ed25519' || key.type === 'secp256k1') &&
9
+ return (key.type === 'RSA' || key.type === 'Ed25519' || key.type === 'secp256k1' || key.type === 'ECDSA') &&
10
10
  key.raw instanceof Uint8Array &&
11
11
  typeof key.equals === 'function' &&
12
12
  typeof key.toMultihash === 'function' &&
@@ -21,7 +21,7 @@ export function isPrivateKey(key) {
21
21
  if (key == null) {
22
22
  return false;
23
23
  }
24
- return (key.type === 'RSA' || key.type === 'Ed25519' || key.type === 'secp256k1') &&
24
+ return (key.type === 'RSA' || key.type === 'Ed25519' || key.type === 'secp256k1' || key.type === 'ECDSA') &&
25
25
  isPublicKey(key.publicKey) &&
26
26
  key.raw instanceof Uint8Array &&
27
27
  typeof key.equals === 'function' &&
@@ -1 +1 @@
1
- {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/keys.ts"],"names":[],"mappings":"AAuIA;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAE,GAAS;IACpC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,CAAC;QAC/E,GAAG,CAAC,GAAG,YAAY,UAAU;QAC7B,OAAO,GAAG,CAAC,MAAM,KAAK,UAAU;QAChC,OAAO,GAAG,CAAC,WAAW,KAAK,UAAU;QACrC,OAAO,GAAG,CAAC,KAAK,KAAK,UAAU;QAC/B,OAAO,GAAG,CAAC,MAAM,KAAK,UAAU,CAAA;AACpC,CAAC;AA2FD;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAE,GAAS;IACrC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,CAAC;QAC/E,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC;QAC1B,GAAG,CAAC,GAAG,YAAY,UAAU;QAC7B,OAAO,GAAG,CAAC,MAAM,KAAK,UAAU;QAChC,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,CAAA;AAClC,CAAC"}
1
+ {"version":3,"file":"keys.js","sourceRoot":"","sources":["../../src/keys.ts"],"names":[],"mappings":"AA2LA;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAE,GAAS;IACpC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,CAAC;QACvG,GAAG,CAAC,GAAG,YAAY,UAAU;QAC7B,OAAO,GAAG,CAAC,MAAM,KAAK,UAAU;QAChC,OAAO,GAAG,CAAC,WAAW,KAAK,UAAU;QACrC,OAAO,GAAG,CAAC,KAAK,KAAK,UAAU;QAC/B,OAAO,GAAG,CAAC,MAAM,KAAK,UAAU,CAAA;AACpC,CAAC;AAiID;;;GAGG;AACH,MAAM,UAAU,YAAY,CAAE,GAAS;IACrC,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,OAAO,KAAK,CAAA;IACd,CAAC;IAED,OAAO,CAAC,GAAG,CAAC,IAAI,KAAK,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,IAAI,GAAG,CAAC,IAAI,KAAK,OAAO,CAAC;QACvG,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC;QAC1B,GAAG,CAAC,GAAG,YAAY,UAAU;QAC7B,OAAO,GAAG,CAAC,MAAM,KAAK,UAAU;QAChC,OAAO,GAAG,CAAC,IAAI,KAAK,UAAU,CAAA;AAClC,CAAC"}
@@ -60,6 +60,8 @@
60
60
  "DialProtocolOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.DialProtocolOptions.html",
61
61
  ".:DialProtocolOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.DialProtocolOptions.html",
62
62
  "DialTransportOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.DialTransportOptions.html",
63
+ "ECDSAPrivateKey": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.ECDSAPrivateKey.html",
64
+ "ECDSAPublicKey": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.ECDSAPublicKey.html",
63
65
  "Ed25519PeerId": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.Ed25519PeerId.html",
64
66
  "Ed25519PrivateKey": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.Ed25519PrivateKey.html",
65
67
  "Ed25519PublicKey": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_interface.Ed25519PublicKey.html",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@libp2p/interface",
3
- "version": "2.7.0",
3
+ "version": "2.8.0",
4
4
  "description": "The interface implemented by a libp2p node",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/interface#readme",
package/src/keys.ts CHANGED
@@ -2,7 +2,7 @@ import type { CID } from 'multiformats/cid'
2
2
  import type { MultihashDigest } from 'multiformats/hashes/interface'
3
3
  import type { Uint8ArrayList } from 'uint8arraylist'
4
4
 
5
- export type KeyType = 'RSA' | 'Ed25519' | 'secp256k1'
5
+ export type KeyType = 'RSA' | 'Ed25519' | 'secp256k1' | 'ECDSA'
6
6
 
7
7
  export interface RSAPublicKey {
8
8
  /**
@@ -15,6 +15,11 @@ export interface RSAPublicKey {
15
15
  */
16
16
  readonly raw: Uint8Array
17
17
 
18
+ /**
19
+ * The public key as a JSON web key
20
+ */
21
+ readonly jwk: JsonWebKey
22
+
18
23
  /**
19
24
  * Returns `true` if the passed object matches this key
20
25
  */
@@ -131,7 +136,54 @@ export interface Secp256k1PublicKey {
131
136
  toString(): string
132
137
  }
133
138
 
134
- export type PublicKey = RSAPublicKey | Ed25519PublicKey | Secp256k1PublicKey
139
+ export interface ECDSAPublicKey {
140
+ /**
141
+ * The type of this key
142
+ */
143
+ readonly type: 'ECDSA'
144
+
145
+ /**
146
+ * The public key as a DER-encoded PKIMessage
147
+ */
148
+ readonly raw: Uint8Array
149
+
150
+ /**
151
+ * The public key as a JSON web key
152
+ */
153
+ readonly jwk: JsonWebKey
154
+
155
+ /**
156
+ * Returns `true` if the passed object matches this key
157
+ */
158
+ equals(key?: any): boolean
159
+
160
+ /**
161
+ * Returns this public key as an identity hash containing the protobuf wrapped
162
+ * public key
163
+ */
164
+ toMultihash(): MultihashDigest<0x0>
165
+
166
+ /**
167
+ * Return this public key as a CID encoded with the `libp2p-key` codec
168
+ *
169
+ * The digest contains an identity hash containing the protobuf wrapped
170
+ * version of the public key.
171
+ */
172
+ toCID(): CID<unknown, 0x72, 0x0, 1>
173
+
174
+ /**
175
+ * Verify the passed data was signed by the private key corresponding to this
176
+ * public key
177
+ */
178
+ verify(data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean | Promise<boolean>
179
+
180
+ /**
181
+ * Returns this key as a multihash with base58btc encoding
182
+ */
183
+ toString(): string
184
+ }
185
+
186
+ export type PublicKey = RSAPublicKey | Ed25519PublicKey | Secp256k1PublicKey | ECDSAPublicKey
135
187
 
136
188
  /**
137
189
  * Returns true if the passed argument has type overlap with the `PublicKey`
@@ -142,7 +194,7 @@ export function isPublicKey (key?: any): key is PublicKey {
142
194
  return false
143
195
  }
144
196
 
145
- return (key.type === 'RSA' || key.type === 'Ed25519' || key.type === 'secp256k1') &&
197
+ return (key.type === 'RSA' || key.type === 'Ed25519' || key.type === 'secp256k1' || key.type === 'ECDSA') &&
146
198
  key.raw instanceof Uint8Array &&
147
199
  typeof key.equals === 'function' &&
148
200
  typeof key.toMultihash === 'function' &&
@@ -169,6 +221,11 @@ export interface RSAPrivateKey {
169
221
  */
170
222
  readonly raw: Uint8Array
171
223
 
224
+ /**
225
+ * The private key as a JSON web key
226
+ */
227
+ readonly jwk: JsonWebKey
228
+
172
229
  /**
173
230
  * Returns `true` if the passed object matches this key
174
231
  */
@@ -237,7 +294,40 @@ export interface Secp256k1PrivateKey {
237
294
  sign(data: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array>
238
295
  }
239
296
 
240
- export type PrivateKey = RSAPrivateKey | Ed25519PrivateKey | Secp256k1PrivateKey
297
+ export interface ECDSAPrivateKey {
298
+ /**
299
+ * The type of this key
300
+ */
301
+ readonly type: 'ECDSA'
302
+
303
+ /**
304
+ * The public key that corresponds to this private key
305
+ */
306
+ readonly publicKey: ECDSAPublicKey
307
+
308
+ /**
309
+ * The private key as a DER-encoded PKIMessage
310
+ */
311
+ readonly raw: Uint8Array
312
+
313
+ /**
314
+ * The private key as a JSON web key
315
+ */
316
+ readonly jwk: JsonWebKey
317
+
318
+ /**
319
+ * Returns `true` if the passed object matches this key
320
+ */
321
+ equals(key?: any): boolean
322
+
323
+ /**
324
+ * Sign the passed data with this private key and return the signature for
325
+ * later verification
326
+ */
327
+ sign(data: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array>
328
+ }
329
+
330
+ export type PrivateKey = RSAPrivateKey | Ed25519PrivateKey | Secp256k1PrivateKey | ECDSAPrivateKey
241
331
 
242
332
  /**
243
333
  * Returns true if the passed argument has type overlap with the `PrivateKey`
@@ -248,7 +338,7 @@ export function isPrivateKey (key?: any): key is PrivateKey {
248
338
  return false
249
339
  }
250
340
 
251
- return (key.type === 'RSA' || key.type === 'Ed25519' || key.type === 'secp256k1') &&
341
+ return (key.type === 'RSA' || key.type === 'Ed25519' || key.type === 'secp256k1' || key.type === 'ECDSA') &&
252
342
  isPublicKey(key.publicKey) &&
253
343
  key.raw instanceof Uint8Array &&
254
344
  typeof key.equals === 'function' &&