@libp2p/interface 0.1.6 → 1.0.0-273d8177c

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 (84) hide show
  1. package/README.md +1 -1
  2. package/dist/index.min.js +1 -1
  3. package/dist/src/connection/index.d.ts +15 -3
  4. package/dist/src/connection/index.d.ts.map +1 -1
  5. package/dist/src/connection/index.js +2 -2
  6. package/dist/src/connection/index.js.map +1 -1
  7. package/dist/src/connection-encrypter/index.d.ts +7 -5
  8. package/dist/src/connection-encrypter/index.d.ts.map +1 -1
  9. package/dist/src/content-routing/index.d.ts +3 -3
  10. package/dist/src/content-routing/index.d.ts.map +1 -1
  11. package/dist/src/content-routing/index.js +3 -3
  12. package/dist/src/content-routing/index.js.map +1 -1
  13. package/dist/src/errors.d.ts +4 -0
  14. package/dist/src/errors.d.ts.map +1 -1
  15. package/dist/src/errors.js +5 -0
  16. package/dist/src/errors.js.map +1 -1
  17. package/dist/src/events.d.ts +0 -1
  18. package/dist/src/events.d.ts.map +1 -1
  19. package/dist/src/events.js +0 -2
  20. package/dist/src/events.js.map +1 -1
  21. package/dist/src/index.d.ts +42 -14
  22. package/dist/src/index.d.ts.map +1 -1
  23. package/dist/src/index.js +21 -1
  24. package/dist/src/index.js.map +1 -1
  25. package/dist/src/keys/index.d.ts +5 -4
  26. package/dist/src/keys/index.d.ts.map +1 -1
  27. package/dist/src/keys/index.js.map +1 -1
  28. package/dist/src/peer-discovery/index.d.ts +1 -1
  29. package/dist/src/peer-discovery/index.d.ts.map +1 -1
  30. package/dist/src/peer-discovery/index.js +1 -1
  31. package/dist/src/peer-discovery/index.js.map +1 -1
  32. package/dist/src/peer-id/index.d.ts +1 -1
  33. package/dist/src/peer-id/index.d.ts.map +1 -1
  34. package/dist/src/peer-id/index.js +2 -2
  35. package/dist/src/peer-id/index.js.map +1 -1
  36. package/dist/src/peer-info/index.d.ts +12 -1
  37. package/dist/src/peer-info/index.d.ts.map +1 -1
  38. package/dist/src/peer-routing/index.d.ts +1 -1
  39. package/dist/src/peer-routing/index.d.ts.map +1 -1
  40. package/dist/src/peer-routing/index.js +1 -1
  41. package/dist/src/peer-routing/index.js.map +1 -1
  42. package/dist/src/startable.d.ts +0 -1
  43. package/dist/src/startable.d.ts.map +1 -1
  44. package/dist/src/startable.js.map +1 -1
  45. package/dist/src/stream-muxer/index.d.ts +2 -2
  46. package/dist/src/stream-muxer/index.d.ts.map +1 -1
  47. package/dist/src/topology/index.d.ts +0 -2
  48. package/dist/src/topology/index.d.ts.map +1 -1
  49. package/dist/src/transport/index.d.ts +2 -2
  50. package/dist/src/transport/index.d.ts.map +1 -1
  51. package/dist/src/transport/index.js +2 -2
  52. package/dist/src/transport/index.js.map +1 -1
  53. package/package.json +15 -119
  54. package/src/connection/index.ts +19 -4
  55. package/src/connection-encrypter/index.ts +7 -5
  56. package/src/content-routing/index.ts +3 -3
  57. package/src/errors.ts +7 -0
  58. package/src/events.ts +0 -3
  59. package/src/index.ts +47 -15
  60. package/src/keys/index.ts +6 -4
  61. package/src/peer-discovery/index.ts +1 -1
  62. package/src/peer-id/index.ts +2 -2
  63. package/src/peer-info/index.ts +13 -1
  64. package/src/peer-routing/index.ts +1 -1
  65. package/src/startable.ts +0 -2
  66. package/src/stream-muxer/index.ts +2 -2
  67. package/src/topology/index.ts +0 -3
  68. package/src/transport/index.ts +3 -3
  69. package/dist/src/keychain/index.d.ts +0 -154
  70. package/dist/src/keychain/index.d.ts.map +0 -1
  71. package/dist/src/keychain/index.js +0 -23
  72. package/dist/src/keychain/index.js.map +0 -1
  73. package/dist/src/metrics/tracked-map.d.ts +0 -17
  74. package/dist/src/metrics/tracked-map.d.ts.map +0 -1
  75. package/dist/src/metrics/tracked-map.js +0 -38
  76. package/dist/src/metrics/tracked-map.js.map +0 -1
  77. package/dist/src/stream-muxer/stream.d.ts +0 -150
  78. package/dist/src/stream-muxer/stream.d.ts.map +0 -1
  79. package/dist/src/stream-muxer/stream.js +0 -323
  80. package/dist/src/stream-muxer/stream.js.map +0 -1
  81. package/dist/typedoc-urls.json +0 -268
  82. package/src/keychain/index.ts +0 -167
  83. package/src/metrics/tracked-map.ts +0 -65
  84. package/src/stream-muxer/stream.ts +0 -496
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/peer-routing/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,MAAM,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/peer-routing/index.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAC,sBAAsB,CAAC,CAAA"}
@@ -2,7 +2,6 @@
2
2
  * Implemented by components that have a lifecycle
3
3
  */
4
4
  export interface Startable {
5
- isStarted(): boolean;
6
5
  /**
7
6
  * If implemented, this method will be invoked before the start method.
8
7
  *
@@ -1 +1 @@
1
- {"version":3,"file":"startable.d.ts","sourceRoot":"","sources":["../../src/startable.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB,SAAS,IAAI,OAAO,CAAA;IAEpB;;;;OAIG;IACH,WAAW,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEpC;;;;OAIG;IACH,KAAK,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE7B;;;;OAIG;IACH,UAAU,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEnC;;;;OAIG;IACH,UAAU,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEnC;;;;OAIG;IACH,IAAI,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5B;;;;OAIG;IACH,SAAS,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACnC;AAED,wBAAgB,WAAW,CAAE,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,SAAS,CAEvD;AAED,wBAAsB,KAAK,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8B1D;AAED,wBAAsB,IAAI,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BzD"}
1
+ {"version":3,"file":"startable.d.ts","sourceRoot":"","sources":["../../src/startable.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS;IACxB;;;;OAIG;IACH,WAAW,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEpC;;;;OAIG;IACH,KAAK,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE7B;;;;OAIG;IACH,UAAU,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEnC;;;;OAIG;IACH,UAAU,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAEnC;;;;OAIG;IACH,IAAI,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5B;;;;OAIG;IACH,SAAS,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACnC;AAED,wBAAgB,WAAW,CAAE,GAAG,EAAE,GAAG,GAAG,GAAG,IAAI,SAAS,CAEvD;AAED,wBAAsB,KAAK,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8B1D;AAED,wBAAsB,IAAI,CAAE,GAAG,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA8BzD"}
@@ -1 +1 @@
1
- {"version":3,"file":"startable.js","sourceRoot":"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E;QACvB,IAAI,CAAC,CAAC,SAAS,IAAI,IAAI,EAAE,CAAC;YACxB,MAAM,CAAC,CAAC,SAAS,EAAE,CAAA;QACrB,CAAC;IACH,CAAC,CAAC,CACH,CAAA;AACH,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import type { Direction, Stream } from '../connection/index.js';
2
2
  import type { AbortOptions } from '../index.js';
3
- import type { Duplex, Source } from 'it-stream-types';
3
+ import type { Duplex } from 'it-stream-types';
4
4
  import type { Uint8ArrayList } from 'uint8arraylist';
5
5
  export interface StreamMuxerFactory {
6
6
  /**
@@ -15,7 +15,7 @@ export interface StreamMuxerFactory {
15
15
  /**
16
16
  * A libp2p stream muxer
17
17
  */
18
- export interface StreamMuxer extends Duplex<AsyncGenerator<Uint8Array>, Source<Uint8ArrayList | Uint8Array>, Promise<void>> {
18
+ export interface StreamMuxer extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> {
19
19
  /**
20
20
  * The protocol used to select this muxer during connection opening
21
21
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stream-muxer/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACrD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAEhB;;OAEG;IACH,iBAAiB,CAAC,IAAI,CAAC,EAAE,eAAe,GAAG,WAAW,CAAA;CACvD;AAED;;GAEG;AACH,MAAM,WAAW,WAAY,SAAQ,MAAM,CAAC,cAAc,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,cAAc,GAAG,UAAU,CAAC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AE,MAAM,CAAA;IAEhB;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAA;IAC1B;;;OAGG;IACH,SAAS,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAElD;;OAEG;IACH,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAE5C;;OAEG;IACH,KAAK,CAAC,GAAG,EAAE,KAAK,GAAG,IAAI,CAAA;CACxB;AAED,MAAM,WAAW,eAAe;IAC9B;;OAEG;IACH,gBAAgB,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAEvC;;OAEG;IACH,WAAW,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IAElC;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB"}
@@ -1,8 +1,6 @@
1
1
  import type { Connection } from '../connection/index.js';
2
2
  import type { PeerId } from '../peer-id/index.js';
3
3
  export interface Topology {
4
- min?: number;
5
- max?: number;
6
4
  /**
7
5
  * If true, invoke `onConnect` for this topology on transient (e.g. short-lived
8
6
  * and/or data-limited) connections. (default: false)
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/topology/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAEjD,MAAM,WAAW,QAAQ;IACvB,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;IAEZ;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAE3B;;;OAGG;IACH,SAAS,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;IAElD;;;OAGG;IACH,YAAY,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CACpC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/topology/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAA;AAEjD,MAAM,WAAW,QAAQ;IACvB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAE3B;;;OAGG;IACH,SAAS,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;IAElD;;;OAGG;IACH,YAAY,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CACpC"}
@@ -25,7 +25,7 @@ export interface Listener extends TypedEventTarget<ListenerEvents> {
25
25
  */
26
26
  close(): Promise<void>;
27
27
  }
28
- export declare const symbol: unique symbol;
28
+ export declare const transportSymbol: unique symbol;
29
29
  export interface ConnectionHandler {
30
30
  (connection: Connection): void;
31
31
  }
@@ -50,7 +50,7 @@ export interface Transport {
50
50
  /**
51
51
  * Used by the isTransport function
52
52
  */
53
- [symbol]: true;
53
+ [transportSymbol]: true;
54
54
  /**
55
55
  * Dial a given multiaddr.
56
56
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/transport/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC7E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAExD,MAAM,W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A;IACxB,YAAY,CAAC,EAAE,kBAAkB,CAAA;IAEjC;;;OAGG;IACH,SAAS,CAAC,EAAE,OAAO,CAAA;CACpB;AAED,MAAM,WAAW,QAAQ;IACvB;;OAEG;IACH,eAAe,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;IAEzF;;OAEG;IACH,cAAc,CAAC,MAAM,EAAE,mBAAmB,EAAE,IAAI,CAAC,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;CACzF"}
@@ -1,6 +1,6 @@
1
- export const symbol = Symbol.for('@libp2p/transport');
1
+ export const transportSymbol = Symbol.for('@libp2p/transport');
2
2
  export function isTransport(other) {
3
- return other != null && Boolean(other[symbol]);
3
+ return other != null && Boolean(other[transportSymbol]);
4
4
  }
5
5
  /**
6
6
  * Enum Transport Manager Fault Tolerance values
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transport/index.ts"],"names":[],"mappings":"AA8BA,MAAM,CAAC,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;AA6CrD,MAAM,UAAU,WAAW,CAAE,KAAU;IACrC,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;AAChD,CAAC;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,cAUX;AAVD,WAAY,cAAc;IACxB;;OAEG;IACH,6DAAa,CAAA;IAEb;;OAEG;IACH,2DAAQ,CAAA;AACV,CAAC,EAVW,cAAc,KAAd,cAAc,QAUzB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/transport/index.ts"],"names":[],"mappings":"AA8BA,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,mBAAmB,CAAC,CAAA;AA6C9D,MAAM,UAAU,WAAW,CAAE,KAAU;IACrC,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC,CAAA;AACzD,CAAC;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,cAUX;AAVD,WAAY,cAAc;IACxB;;OAEG;IACH,6DAAa,CAAA;IAEb;;OAEG;IACH,2DAAQ,CAAA;AACV,CAAC,EAVW,cAAc,KAAd,cAAc,QAUzB"}
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@libp2p/interface",
3
- "version": "0.1.6",
3
+ "version": "1.0.0-273d8177c",
4
4
  "description": "The interface implemented by a libp2p node",
5
5
  "license": "Apache-2.0 OR MIT",
6
- "homepage": "https://github.com/libp2p/js-libp2p/tree/master/packages/interface#readme",
6
+ "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/interface#readme",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "git+https://github.com/libp2p/js-libp2p.git"
@@ -11,6 +11,10 @@
11
11
  "bugs": {
12
12
  "url": "https://github.com/libp2p/js-libp2p/issues"
13
13
  },
14
+ "publishConfig": {
15
+ "access": "public",
16
+ "provenance": true
17
+ },
14
18
  "keywords": [
15
19
  "interface",
16
20
  "libp2p"
@@ -39,105 +43,10 @@
39
43
  "!dist/test",
40
44
  "!**/*.tsbuildinfo"
41
45
  ],
42
- "browser": {
43
- "events": "./dist/src/events.browser.js"
44
- },
45
46
  "exports": {
46
47
  ".": {
47
48
  "types": "./dist/src/index.d.ts",
48
49
  "import": "./dist/src/index.js"
49
- },
50
- "./connection": {
51
- "types": "./dist/src/connection/index.d.ts",
52
- "import": "./dist/src/connection/index.js"
53
- },
54
- "./connection-encrypter": {
55
- "types": "./dist/src/connection-encrypter/index.d.ts",
56
- "import": "./dist/src/connection-encrypter/index.js"
57
- },
58
- "./connection-gater": {
59
- "types": "./dist/src/connection-gater/index.d.ts",
60
- "import": "./dist/src/connection-gater/index.js"
61
- },
62
- "./content-routing": {
63
- "types": "./dist/src/content-routing/index.d.ts",
64
- "import": "./dist/src/content-routing/index.js"
65
- },
66
- "./errors": {
67
- "types": "./dist/src/errors.d.ts",
68
- "import": "./dist/src/errors.js"
69
- },
70
- "./events": {
71
- "types": "./dist/src/events.d.ts",
72
- "import": "./dist/src/events.js"
73
- },
74
- "./keychain": {
75
- "types": "./dist/src/keychain/index.d.ts",
76
- "import": "./dist/src/keychain/index.js"
77
- },
78
- "./keys": {
79
- "types": "./dist/src/keys/index.d.ts",
80
- "import": "./dist/src/keys/index.js"
81
- },
82
- "./metrics": {
83
- "types": "./dist/src/metrics/index.d.ts",
84
- "import": "./dist/src/metrics/index.js"
85
- },
86
- "./metrics/tracked-map": {
87
- "types": "./dist/src/metrics/tracked-map.d.ts",
88
- "import": "./dist/src/metrics/tracked-map.js"
89
- },
90
- "./peer-discovery": {
91
- "types": "./dist/src/peer-discovery/index.d.ts",
92
- "import": "./dist/src/peer-discovery/index.js"
93
- },
94
- "./peer-id": {
95
- "types": "./dist/src/peer-id/index.d.ts",
96
- "import": "./dist/src/peer-id/index.js"
97
- },
98
- "./peer-info": {
99
- "types": "./dist/src/peer-info/index.d.ts",
100
- "import": "./dist/src/peer-info/index.js"
101
- },
102
- "./peer-routing": {
103
- "types": "./dist/src/peer-routing/index.d.ts",
104
- "import": "./dist/src/peer-routing/index.js"
105
- },
106
- "./peer-store": {
107
- "types": "./dist/src/peer-store/index.d.ts",
108
- "import": "./dist/src/peer-store/index.js"
109
- },
110
- "./peer-store/tags": {
111
- "types": "./dist/src/peer-store/tags.d.ts",
112
- "import": "./dist/src/peer-store/tags.js"
113
- },
114
- "./pubsub": {
115
- "types": "./dist/src/pubsub/index.d.ts",
116
- "import": "./dist/src/pubsub/index.js"
117
- },
118
- "./record": {
119
- "types": "./dist/src/record/index.d.ts",
120
- "import": "./dist/src/record/index.js"
121
- },
122
- "./startable": {
123
- "types": "./dist/src/startable.d.ts",
124
- "import": "./dist/src/startable.js"
125
- },
126
- "./stream-handler": {
127
- "types": "./dist/src/stream-handler/index.d.ts",
128
- "import": "./dist/src/stream-handler/index.js"
129
- },
130
- "./stream-muxer": {
131
- "types": "./dist/src/stream-muxer/index.d.ts",
132
- "import": "./dist/src/stream-muxer/index.js"
133
- },
134
- "./stream-muxer/stream": {
135
- "types": "./dist/src/stream-muxer/stream.d.ts",
136
- "import": "./dist/src/stream-muxer/stream.js"
137
- },
138
- "./transport": {
139
- "types": "./dist/src/transport/index.d.ts",
140
- "import": "./dist/src/transport/index.js"
141
50
  }
142
51
  },
143
52
  "eslintConfig": {
@@ -150,33 +59,20 @@
150
59
  "scripts": {
151
60
  "clean": "aegir clean",
152
61
  "lint": "aegir lint",
153
- "dep-check": "aegir dep-check",
154
- "build": "aegir build",
155
- "test": "aegir test",
156
- "test:chrome": "aegir test -t browser --cov",
157
- "test:chrome-webworker": "aegir test -t webworker",
158
- "test:firefox": "aegir test -t browser -- --browser firefox",
159
- "test:firefox-webworker": "aegir test -t webworker -- --browser firefox",
160
- "test:node": "aegir test -t node --cov",
161
- "test:electron-main": "aegir test -t electron-main"
62
+ "dep-check": "aegir dep-check -i @libp2p/utils",
63
+ "build": "aegir build"
162
64
  },
163
65
  "dependencies": {
164
- "@multiformats/multiaddr": "^12.1.5",
165
- "abortable-iterator": "^5.0.1",
166
- "it-pushable": "^3.2.0",
66
+ "@multiformats/multiaddr": "^12.1.10",
67
+ "it-pushable": "^3.2.1",
167
68
  "it-stream-types": "^2.0.1",
168
- "multiformats": "^12.0.1",
169
- "p-defer": "^4.0.0",
170
- "race-signal": "^1.0.0",
69
+ "multiformats": "^12.1.3",
171
70
  "uint8arraylist": "^2.4.3"
172
71
  },
173
72
  "devDependencies": {
174
- "@types/sinon": "^17.0.0",
175
- "aegir": "^41.0.2",
176
- "delay": "^6.0.0",
177
- "it-all": "^3.0.3",
178
- "it-drain": "^3.0.3",
179
- "sinon": "^17.0.0",
180
- "sinon-ts": "^2.0.0"
73
+ "aegir": "^41.0.2"
74
+ },
75
+ "browser": {
76
+ "events": "./dist/src/events.browser.js"
181
77
  }
182
78
  }
@@ -1,4 +1,4 @@
1
- import type { AbortOptions } from '../index.js'
1
+ import type { AbortOptions, Logger } from '../index.js'
2
2
  import type { PeerId } from '../peer-id/index.js'
3
3
  import type { Multiaddr } from '@multiformats/multiaddr'
4
4
  import type { Duplex, Source } from 'it-stream-types'
@@ -169,6 +169,11 @@ export interface Stream extends Duplex<AsyncGenerator<Uint8ArrayList>, Source<Ui
169
169
  * The current status of the writable end of the stream
170
170
  */
171
171
  writeStatus: WriteStatus
172
+
173
+ /**
174
+ * The stream logger
175
+ */
176
+ log: Logger
172
177
  }
173
178
 
174
179
  export interface NewStreamOptions extends AbortOptions {
@@ -268,12 +273,17 @@ export interface Connection {
268
273
  * Immediately close the connection, any queued data will be discarded
269
274
  */
270
275
  abort(err: Error): void
276
+
277
+ /**
278
+ * The connection logger
279
+ */
280
+ log: Logger
271
281
  }
272
282
 
273
- export const symbol = Symbol.for('@libp2p/connection')
283
+ export const connectionSymbol = Symbol.for('@libp2p/connection')
274
284
 
275
285
  export function isConnection (other: any): other is Connection {
276
- return other != null && Boolean(other[symbol])
286
+ return other != null && Boolean(other[connectionSymbol])
277
287
  }
278
288
 
279
289
  export interface ConnectionProtector {
@@ -308,7 +318,7 @@ export interface MultiaddrConnectionTimeline {
308
318
  * a peer. It is a low-level primitive and is the raw connection
309
319
  * without encryption or stream multiplexing.
310
320
  */
311
- export interface MultiaddrConnection extends Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>> {
321
+ export interface MultiaddrConnection extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> {
312
322
  /**
313
323
  * Gracefully close the connection. All queued data will be written to the
314
324
  * underlying transport.
@@ -329,4 +339,9 @@ export interface MultiaddrConnection extends Duplex<AsyncGenerator<Uint8Array>,
329
339
  * When connection lifecycle events occurred
330
340
  */
331
341
  timeline: MultiaddrConnectionTimeline
342
+
343
+ /**
344
+ * The multiaddr connection logger
345
+ */
346
+ log: Logger
332
347
  }
@@ -1,5 +1,7 @@
1
+ import type { MultiaddrConnection } from '../connection/index.js'
1
2
  import type { PeerId } from '../peer-id/index.js'
2
- import type { Duplex, Source } from 'it-stream-types'
3
+ import type { Duplex } from 'it-stream-types'
4
+ import type { Uint8ArrayList } from 'uint8arraylist'
3
5
 
4
6
  /**
5
7
  * A libp2p connection encrypter module must be compliant to this interface
@@ -13,18 +15,18 @@ export interface ConnectionEncrypter<Extension = unknown> {
13
15
  * pass it for extra verification, otherwise it will be determined during
14
16
  * the handshake.
15
17
  */
16
- secureOutbound(localPeer: PeerId, connection: Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>>, remotePeer?: PeerId): Promise<SecuredConnection<Extension>>
18
+ secureOutbound <Stream extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> = MultiaddrConnection> (localPeer: PeerId, connection: Stream, remotePeer?: PeerId): Promise<SecuredConnection<Stream, Extension>>
17
19
 
18
20
  /**
19
21
  * Decrypt incoming data. If the remote PeerId is known,
20
22
  * pass it for extra verification, otherwise it will be determined during
21
23
  * the handshake
22
24
  */
23
- secureInbound(localPeer: PeerId, connection: Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>>, remotePeer?: PeerId): Promise<SecuredConnection<Extension>>
25
+ secureInbound <Stream extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> = MultiaddrConnection> (localPeer: PeerId, connection: Stream, remotePeer?: PeerId): Promise<SecuredConnection<Stream, Extension>>
24
26
  }
25
27
 
26
- export interface SecuredConnection<Extension = unknown> {
27
- conn: Duplex<AsyncGenerator<Uint8Array>, Source<Uint8Array>, Promise<void>>
28
+ export interface SecuredConnection<Stream = any, Extension = unknown> {
29
+ conn: Stream
28
30
  remoteExtensions?: Extension
29
31
  remotePeer: PeerId
30
32
  }
@@ -10,10 +10,10 @@ import type { CID } from 'multiformats/cid'
10
10
  * @example
11
11
  *
12
12
  * ```js
13
- * import { contentRouting, ContentRouting } from '@libp2p/content-routing'
13
+ * import { contentRoutingSymbol, ContentRouting } from '@libp2p/content-routing'
14
14
  *
15
15
  * class MyContentRouter implements ContentRouting {
16
- * get [contentRouting] () {
16
+ * get [contentRoutingSymbol] () {
17
17
  * return this
18
18
  * }
19
19
  *
@@ -21,7 +21,7 @@ import type { CID } from 'multiformats/cid'
21
21
  * }
22
22
  * ```
23
23
  */
24
- export const contentRouting = Symbol.for('@libp2p/content-routing')
24
+ export const contentRoutingSymbol = Symbol.for('@libp2p/content-routing')
25
25
 
26
26
  export interface ContentRouting {
27
27
  /**
package/src/errors.ts CHANGED
@@ -65,3 +65,10 @@ export class InvalidCryptoTransmissionError extends Error {
65
65
 
66
66
  static readonly code = 'ERR_INVALID_CRYPTO_TRANSMISSION'
67
67
  }
68
+
69
+ // Error codes
70
+
71
+ export const ERR_TIMEOUT = 'ERR_TIMEOUT'
72
+ export const ERR_INVALID_PARAMETERS = 'ERR_INVALID_PARAMETERS'
73
+ export const ERR_NOT_FOUND = 'ERR_NOT_FOUND'
74
+ export const ERR_INVALID_MESSAGE = 'ERR_INVALID_MESSAGE'
package/src/events.ts CHANGED
@@ -117,9 +117,6 @@ class CustomEventPolyfill<T = any> extends Event {
117
117
 
118
118
  export const CustomEvent = globalThis.CustomEvent ?? CustomEventPolyfill
119
119
 
120
- // TODO: remove this in v1
121
- export { TypedEventEmitter as EventEmitter }
122
-
123
120
  // create a setMaxListeners that doesn't break browser usage
124
121
  export const setMaxListeners: typeof nodeSetMaxListeners = (n, ...eventTargets) => {
125
122
  try {
package/src/index.ts CHANGED
@@ -17,7 +17,6 @@
17
17
  import type { Connection, NewStreamOptions, Stream } from './connection/index.js'
18
18
  import type { ContentRouting } from './content-routing/index.js'
19
19
  import type { TypedEventTarget } from './events.js'
20
- import type { KeyChain } from './keychain/index.js'
21
20
  import type { Metrics } from './metrics/index.js'
22
21
  import type { PeerId } from './peer-id/index.js'
23
22
  import type { PeerInfo } from './peer-info/index.js'
@@ -322,6 +321,8 @@ export interface PendingDial {
322
321
  multiaddrs: Multiaddr[]
323
322
  }
324
323
 
324
+ export type Libp2pStatus = 'starting' | 'started' | 'stopping' | 'stopped'
325
+
325
326
  /**
326
327
  * Libp2p nodes implement this interface.
327
328
  */
@@ -394,20 +395,6 @@ export interface Libp2p<T extends ServiceMap = ServiceMap> extends Startable, Ty
394
395
  */
395
396
  contentRouting: ContentRouting
396
397
 
397
- /**
398
- * The keychain contains the keys used by the current node, and can create new
399
- * keys, export them, import them, etc.
400
- *
401
- * @example
402
- *
403
- * ```js
404
- * const keyInfo = await libp2p.keychain.createKey('new key')
405
- * console.info(keyInfo)
406
- * // { id: '...', name: 'new key' }
407
- * ```
408
- */
409
- keychain: KeyChain
410
-
411
398
  /**
412
399
  * The metrics subsystem allows recording values to assess the health/performance
413
400
  * of the running node.
@@ -425,8 +412,16 @@ export interface Libp2p<T extends ServiceMap = ServiceMap> extends Startable, Ty
425
412
  */
426
413
  metrics?: Metrics
427
414
 
415
+ /**
416
+ * The logger used by this libp2p node
417
+ */
428
418
  logger: ComponentLogger
429
419
 
420
+ /**
421
+ * The current status of the libp2p node
422
+ */
423
+ status: Libp2pStatus
424
+
430
425
  /**
431
426
  * Get a deduplicated list of peer advertising multiaddrs by concatenating
432
427
  * the listen addresses used by transports with any configured
@@ -624,6 +619,21 @@ export interface Libp2p<T extends ServiceMap = ServiceMap> extends Startable, Ty
624
619
  services: T
625
620
  }
626
621
 
622
+ /**
623
+ * Metadata about the current node
624
+ */
625
+ export interface NodeInfo {
626
+ /**
627
+ * The implementation name
628
+ */
629
+ name: string
630
+
631
+ /**
632
+ * The implementation version
633
+ */
634
+ version: string
635
+ }
636
+
627
637
  /**
628
638
  * An object that contains an AbortSignal as
629
639
  * the optional `signal` property.
@@ -660,3 +670,25 @@ export interface LoggerOptions {
660
670
  export type RecursivePartial<T> = {
661
671
  [P in keyof T]?: T[P] extends Array<infer I> ? Array<RecursivePartial<I>> : T[P] extends (...args: any[]) => any ? T[P] : RecursivePartial<T[P]>
662
672
  }
673
+
674
+ export * from './connection/index.js'
675
+ export * from './connection-encrypter/index.js'
676
+ export * from './connection-gater/index.js'
677
+ export * from './content-routing/index.js'
678
+ export * from './keys/index.js'
679
+ export * from './metrics/index.js'
680
+ export * from './peer-discovery/index.js'
681
+ export * from './peer-id/index.js'
682
+ export * from './peer-info/index.js'
683
+ export * from './peer-routing/index.js'
684
+ export * from './peer-store/index.js'
685
+ export * from './peer-store/tags.js'
686
+ export * from './pubsub/index.js'
687
+ export * from './record/index.js'
688
+ export * from './stream-handler/index.js'
689
+ export * from './stream-muxer/index.js'
690
+ export * from './topology/index.js'
691
+ export * from './transport/index.js'
692
+ export * from './errors.js'
693
+ export * from './events.js'
694
+ export * from './startable.js'
package/src/keys/index.ts CHANGED
@@ -1,9 +1,11 @@
1
+ import type { Uint8ArrayList } from 'uint8arraylist'
2
+
1
3
  export interface PublicKey {
2
4
  readonly bytes: Uint8Array
3
- verify(data: Uint8Array, sig: Uint8Array): Promise<boolean>
5
+ verify(data: Uint8Array | Uint8ArrayList, sig: Uint8Array): boolean | Promise<boolean>
4
6
  marshal(): Uint8Array
5
7
  equals(key: PublicKey): boolean
6
- hash(): Promise<Uint8Array>
8
+ hash(): Uint8Array | Promise<Uint8Array>
7
9
  }
8
10
 
9
11
  /**
@@ -12,10 +14,10 @@ export interface PublicKey {
12
14
  export interface PrivateKey {
13
15
  readonly public: PublicKey
14
16
  readonly bytes: Uint8Array
15
- sign(data: Uint8Array): Promise<Uint8Array>
17
+ sign(data: Uint8Array | Uint8ArrayList): Uint8Array | Promise<Uint8Array>
16
18
  marshal(): Uint8Array
17
19
  equals(key: PrivateKey): boolean
18
- hash(): Promise<Uint8Array>
20
+ hash(): Uint8Array | Promise<Uint8Array>
19
21
  /**
20
22
  * Gets the ID of the key.
21
23
  *
@@ -20,7 +20,7 @@ import type { PeerInfo } from '../peer-info/index.js'
20
20
  * }
21
21
  * ```
22
22
  */
23
- export const peerDiscovery = Symbol.for('@libp2p/peer-discovery')
23
+ export const peerDiscoverySymbol = Symbol.for('@libp2p/peer-discovery')
24
24
 
25
25
  export interface PeerDiscoveryEvents {
26
26
  'peer': CustomEvent<PeerInfo>
@@ -32,8 +32,8 @@ export interface Secp256k1PeerId extends BasePeerId {
32
32
 
33
33
  export type PeerId = RSAPeerId | Ed25519PeerId | Secp256k1PeerId
34
34
 
35
- export const symbol = Symbol.for('@libp2p/peer-id')
35
+ export const peerIdSymbol = Symbol.for('@libp2p/peer-id')
36
36
 
37
37
  export function isPeerId (other: any): other is PeerId {
38
- return other != null && Boolean(other[symbol])
38
+ return other != null && Boolean(other[peerIdSymbol])
39
39
  }
@@ -1,8 +1,20 @@
1
1
  import type { PeerId } from '../peer-id/index.js'
2
2
  import type { Multiaddr } from '@multiformats/multiaddr'
3
3
 
4
+ /**
5
+ * A `PeerInfo` is a lightweight object that represents a remote peer, it can be
6
+ * obtained from peer discovery mechanisms, HTTP RPC endpoints, etc.
7
+ *
8
+ * @see https://docs.libp2p.io/concepts/fundamentals/peers/#peer-info
9
+ */
4
10
  export interface PeerInfo {
11
+ /**
12
+ * The identifier of the remote peer
13
+ */
5
14
  id: PeerId
15
+
16
+ /**
17
+ * The multiaddrs a peer is listening on
18
+ */
6
19
  multiaddrs: Multiaddr[]
7
- protocols: string[]
8
20
  }
@@ -21,7 +21,7 @@ import type { PeerInfo } from '../peer-info/index.js'
21
21
  * }
22
22
  * ```
23
23
  */
24
- export const peerRouting = Symbol.for('@libp2p/peer-routing')
24
+ export const peerRoutingSymbol = Symbol.for('@libp2p/peer-routing')
25
25
 
26
26
  export interface PeerRouting {
27
27
  /**
package/src/startable.ts CHANGED
@@ -2,8 +2,6 @@
2
2
  * Implemented by components that have a lifecycle
3
3
  */
4
4
  export interface Startable {
5
- isStarted(): boolean
6
-
7
5
  /**
8
6
  * If implemented, this method will be invoked before the start method.
9
7
  *
@@ -1,6 +1,6 @@
1
1
  import type { Direction, Stream } from '../connection/index.js'
2
2
  import type { AbortOptions } from '../index.js'
3
- import type { Duplex, Source } from 'it-stream-types'
3
+ import type { Duplex } from 'it-stream-types'
4
4
  import type { Uint8ArrayList } from 'uint8arraylist'
5
5
 
6
6
  export interface StreamMuxerFactory {
@@ -18,7 +18,7 @@ export interface StreamMuxerFactory {
18
18
  /**
19
19
  * A libp2p stream muxer
20
20
  */
21
- export interface StreamMuxer extends Duplex<AsyncGenerator<Uint8Array>, Source<Uint8ArrayList | Uint8Array>, Promise<void>> {
21
+ export interface StreamMuxer extends Duplex<AsyncGenerator<Uint8Array | Uint8ArrayList>> {
22
22
  /**
23
23
  * The protocol used to select this muxer during connection opening
24
24
  */
@@ -2,9 +2,6 @@ import type { Connection } from '../connection/index.js'
2
2
  import type { PeerId } from '../peer-id/index.js'
3
3
 
4
4
  export interface Topology {
5
- min?: number
6
- max?: number
7
-
8
5
  /**
9
6
  * If true, invoke `onConnect` for this topology on transient (e.g. short-lived
10
7
  * and/or data-limited) connections. (default: false)