libp2p 1.9.1 → 1.9.2-7655e5200

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.
@@ -29,6 +29,12 @@ export interface ConnectionMonitorInit {
29
29
  * @default true
30
30
  */
31
31
  abortConnectionOnPingFailure?: boolean;
32
+ /**
33
+ * Override the ping protocol prefix
34
+ *
35
+ * @default 'ipfs'
36
+ */
37
+ protocolPrefix?: string;
32
38
  }
33
39
  export interface ConnectionMonitorComponents {
34
40
  logger: ComponentLogger;
@@ -36,6 +42,7 @@ export interface ConnectionMonitorComponents {
36
42
  metrics?: Metrics;
37
43
  }
38
44
  export declare class ConnectionMonitor implements Startable {
45
+ private readonly protocol;
39
46
  private readonly components;
40
47
  private readonly log;
41
48
  private heartbeatInterval?;
@@ -1 +1 @@
1
- {"version":3,"file":"connection-monitor.d.ts","sourceRoot":"","sources":["../../src/connection-monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AAGvD,OAAO,KAAK,EAAE,eAAe,EAAU,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AACpF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AACnE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAA;AAIzE,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,CAAA;IAEjB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,IAAI,CAAC,mBAAmB,EAAE,aAAa,GAAG,SAAS,CAAC,CAAA;IAElE;;;;OAIG;IACH,4BAA4B,CAAC,EAAE,OAAO,CAAA;CACvC;AAED,MAAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,eAAe,CAAA;IACvB,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,OAA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AAM,WAAW,2BAA2B;IAC1C,MAAM,EAAE,eAAe,CAAA;IACvB,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,OAAO,CAAC,EAAE,OAAO,CAAA;CAClB;AAED,qBAAa,iBAAkB,YAAW,SAAS;IACjD,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAQ;IACjC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA6B;IACxD,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAQ;IAC5B,OAAO,CAAC,iBAAiB,CAAC,CAAgC;IAC1D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAQ;IACvC,OAAO,CAAC,eAAe,CAAC,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;gBAE5B,UAAU,EAAE,2BAA2B,EAAE,IAAI,GAAE,qBAA0B;IActF,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,gCAA+B;IAE5D,QAAQ,CAAC,CAAC,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAEvC;IAED,KAAK,IAAK,IAAI;IAoDd,IAAI,IAAK,IAAI;CAOd"}
@@ -1,8 +1,14 @@
1
+ import { randomBytes } from '@libp2p/crypto';
1
2
  import { serviceCapabilities } from '@libp2p/interface';
2
3
  import { AdaptiveTimeout } from '@libp2p/utils/adaptive-timeout';
3
4
  import { byteStream } from 'it-byte-stream';
4
5
  const DEFAULT_PING_INTERVAL_MS = 10000;
6
+ const PROTOCOL_VERSION = '1.0.0';
7
+ const PROTOCOL_NAME = 'ping';
8
+ const PROTOCOL_PREFIX = 'ipfs';
9
+ const PING_LENGTH = 32;
5
10
  export class ConnectionMonitor {
11
+ protocol;
6
12
  components;
7
13
  log;
8
14
  heartbeatInterval;
@@ -11,6 +17,7 @@ export class ConnectionMonitor {
11
17
  timeout;
12
18
  constructor(components, init = {}) {
13
19
  this.components = components;
20
+ this.protocol = `/${init.protocolPrefix ?? PROTOCOL_PREFIX}/${PROTOCOL_NAME}/${PROTOCOL_VERSION}`;
14
21
  this.log = components.logger.forComponent('libp2p:connection-monitor');
15
22
  this.pingIntervalMs = init.pingInterval ?? DEFAULT_PING_INTERVAL_MS;
16
23
  this.timeout = new AdaptiveTimeout({
@@ -33,17 +40,17 @@ export class ConnectionMonitor {
33
40
  const signal = this.timeout.getTimeoutSignal({
34
41
  signal: this.abortController?.signal
35
42
  });
36
- const stream = await conn.newStream('/ipfs/ping/1.0.0', {
43
+ const stream = await conn.newStream(this.protocol, {
37
44
  signal,
38
45
  runOnTransientConnection: true
39
46
  });
40
47
  const bs = byteStream(stream);
41
48
  start = Date.now();
42
49
  await Promise.all([
43
- bs.write(new Uint8Array(1), {
50
+ bs.write(randomBytes(PING_LENGTH), {
44
51
  signal
45
52
  }),
46
- bs.read(1, {
53
+ bs.read(PING_LENGTH, {
47
54
  signal
48
55
  })
49
56
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"connection-monitor.js","sourceRoot":"","sources":["../../src/connection-monitor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvD,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAA;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAK3C,MAAM,wBAAwB,GAAG,KAAK,CAAA;AAwCtC,MAAM,OAAO,iBAAiB;IACX,UAAU,CAA6B;IACvC,GAAG,CAAQ;IACpB,iBAAiB,CAAiC;IACzC,cAAc,CAAQ;IAC/B,eAAe,CAAkB;IACxB,OAAO,CAAiB;IAEzC,YAAa,UAAuC,EAAE,OAA8B,EAAE;QACpF,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAE5B,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,MAAM,CAAC,YAAY,CAAC,2BAA2B,CAAC,CAAA;QACtE,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,YAAY,IAAI,wBAAwB,CAAA;QAEnE,IAAI,CAAC,OAAO,GAAG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KAAK,CAAC,GAAG,CAAC,EAAE;oBACX,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,6CAA6C,EAAE,GAAG,CAAC,CAAA;oBAClE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;gBACjB,CAAC,CAAC,CAAA;YACN,CAAC,CAAC,CAAA;QACJ,CAAC,EAAE,IAAI,CAAC,cAAc,CAAC,CAAA;IACzB,CAAC;IAED,IAAI;QACF,IAAI,CAAC,eAAe,EAAE,KAAK,EAAE,CAAA;QAE7B,IAAI,IAAI,CAAC,iBAAiB,IAAI,IAAI,EAAE,CAAC;YACnC,aAAa,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;QACvC,CAAC;IACH,CAAC;CACF"}
@@ -1,3 +1,3 @@
1
- export declare const version = "1.9.1";
1
+ export declare const version = "1.9.2-7655e5200";
2
2
  export declare const name = "libp2p";
3
3
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,UAAU,CAAA;AAC9B,eAAO,MAAM,IAAI,WAAW,CAAA"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,OAAO,oBAAoB,CAAA;AACxC,eAAO,MAAM,IAAI,WAAW,CAAA"}
@@ -1,3 +1,3 @@
1
- export const version = '1.9.1';
1
+ export const version = '1.9.2-7655e5200';
2
2
  export const name = 'libp2p';
3
3
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,OAAO,CAAA;AAC9B,MAAM,CAAC,MAAM,IAAI,GAAG,QAAQ,CAAA"}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,OAAO,GAAG,iBAAiB,CAAA;AACxC,MAAM,CAAC,MAAM,IAAI,GAAG,QAAQ,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libp2p",
3
- "version": "1.9.1",
3
+ "version": "1.9.2-7655e5200",
4
4
  "description": "JavaScript implementation of libp2p, a modular peer to peer network stack",
5
5
  "license": "Apache-2.0 OR MIT",
6
6
  "homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/libp2p#readme",
@@ -85,16 +85,16 @@
85
85
  "test:webkit": "aegir test -t browser -f \"./dist/test/**/*.spec.js\" -- --browser webkit"
86
86
  },
87
87
  "dependencies": {
88
- "@libp2p/crypto": "^4.1.9",
89
- "@libp2p/interface": "^1.7.0",
90
- "@libp2p/interface-internal": "^1.3.4",
91
- "@libp2p/logger": "^4.0.20",
92
- "@libp2p/multistream-select": "^5.1.17",
93
- "@libp2p/peer-collections": "^5.2.9",
94
- "@libp2p/peer-id": "^4.2.4",
95
- "@libp2p/peer-id-factory": "^4.2.4",
96
- "@libp2p/peer-store": "^10.1.5",
97
- "@libp2p/utils": "^5.4.9",
88
+ "@libp2p/crypto": "4.1.9-7655e5200",
89
+ "@libp2p/interface": "1.7.0-7655e5200",
90
+ "@libp2p/interface-internal": "1.3.4-7655e5200",
91
+ "@libp2p/logger": "4.0.20-7655e5200",
92
+ "@libp2p/multistream-select": "5.1.17-7655e5200",
93
+ "@libp2p/peer-collections": "5.2.9-7655e5200",
94
+ "@libp2p/peer-id": "4.2.4-7655e5200",
95
+ "@libp2p/peer-id-factory": "4.2.4-7655e5200",
96
+ "@libp2p/peer-store": "10.1.5-7655e5200",
97
+ "@libp2p/utils": "5.4.9-7655e5200",
98
98
  "@multiformats/dns": "^1.0.6",
99
99
  "@multiformats/multiaddr": "^12.2.3",
100
100
  "@multiformats/multiaddr-matcher": "^1.2.1",
@@ -114,13 +114,13 @@
114
114
  },
115
115
  "devDependencies": {
116
116
  "@chainsafe/libp2p-yamux": "^6.0.2",
117
- "@libp2p/circuit-relay-v2": "^1.1.5",
118
- "@libp2p/identify": "^2.1.5",
119
- "@libp2p/interface-compliance-tests": "^5.4.12",
120
- "@libp2p/mplex": "^10.1.5",
121
- "@libp2p/plaintext": "^1.1.6",
122
- "@libp2p/tcp": "^9.1.5",
123
- "@libp2p/websockets": "^8.2.0",
117
+ "@libp2p/circuit-relay-v2": "1.1.5-7655e5200",
118
+ "@libp2p/identify": "2.1.5-7655e5200",
119
+ "@libp2p/interface-compliance-tests": "5.4.12-7655e5200",
120
+ "@libp2p/mplex": "10.1.5-7655e5200",
121
+ "@libp2p/plaintext": "1.1.6-7655e5200",
122
+ "@libp2p/tcp": "9.1.5-7655e5200",
123
+ "@libp2p/websockets": "8.2.0-7655e5200",
124
124
  "@multiformats/mafmt": "^12.1.6",
125
125
  "aegir": "^44.0.1",
126
126
  "delay": "^6.0.0",
@@ -1,3 +1,4 @@
1
+ import { randomBytes } from '@libp2p/crypto'
1
2
  import { serviceCapabilities } from '@libp2p/interface'
2
3
  import { AdaptiveTimeout } from '@libp2p/utils/adaptive-timeout'
3
4
  import { byteStream } from 'it-byte-stream'
@@ -6,6 +7,10 @@ import type { ConnectionManager } from '@libp2p/interface-internal'
6
7
  import type { AdaptiveTimeoutInit } from '@libp2p/utils/adaptive-timeout'
7
8
 
8
9
  const DEFAULT_PING_INTERVAL_MS = 10000
10
+ const PROTOCOL_VERSION = '1.0.0'
11
+ const PROTOCOL_NAME = 'ping'
12
+ const PROTOCOL_PREFIX = 'ipfs'
13
+ const PING_LENGTH = 32
9
14
 
10
15
  export interface ConnectionMonitorInit {
11
16
  /**
@@ -37,6 +42,13 @@ export interface ConnectionMonitorInit {
37
42
  * @default true
38
43
  */
39
44
  abortConnectionOnPingFailure?: boolean
45
+
46
+ /**
47
+ * Override the ping protocol prefix
48
+ *
49
+ * @default 'ipfs'
50
+ */
51
+ protocolPrefix?: string
40
52
  }
41
53
 
42
54
  export interface ConnectionMonitorComponents {
@@ -46,6 +58,7 @@ export interface ConnectionMonitorComponents {
46
58
  }
47
59
 
48
60
  export class ConnectionMonitor implements Startable {
61
+ private readonly protocol: string
49
62
  private readonly components: ConnectionMonitorComponents
50
63
  private readonly log: Logger
51
64
  private heartbeatInterval?: ReturnType<typeof setInterval>
@@ -55,6 +68,7 @@ export class ConnectionMonitor implements Startable {
55
68
 
56
69
  constructor (components: ConnectionMonitorComponents, init: ConnectionMonitorInit = {}) {
57
70
  this.components = components
71
+ this.protocol = `/${init.protocolPrefix ?? PROTOCOL_PREFIX}/${PROTOCOL_NAME}/${PROTOCOL_VERSION}`
58
72
 
59
73
  this.log = components.logger.forComponent('libp2p:connection-monitor')
60
74
  this.pingIntervalMs = init.pingInterval ?? DEFAULT_PING_INTERVAL_MS
@@ -83,7 +97,7 @@ export class ConnectionMonitor implements Startable {
83
97
  const signal = this.timeout.getTimeoutSignal({
84
98
  signal: this.abortController?.signal
85
99
  })
86
- const stream = await conn.newStream('/ipfs/ping/1.0.0', {
100
+ const stream = await conn.newStream(this.protocol, {
87
101
  signal,
88
102
  runOnTransientConnection: true
89
103
  })
@@ -91,10 +105,10 @@ export class ConnectionMonitor implements Startable {
91
105
  start = Date.now()
92
106
 
93
107
  await Promise.all([
94
- bs.write(new Uint8Array(1), {
108
+ bs.write(randomBytes(PING_LENGTH), {
95
109
  signal
96
110
  }),
97
- bs.read(1, {
111
+ bs.read(PING_LENGTH, {
98
112
  signal
99
113
  })
100
114
  ])
package/src/version.ts CHANGED
@@ -1,2 +1,2 @@
1
- export const version = '1.9.1'
1
+ export const version = '1.9.2-7655e5200'
2
2
  export const name = 'libp2p'
@@ -1,14 +0,0 @@
1
- {
2
- "Libp2pInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.Libp2pInit.html",
3
- ".:Libp2pInit": "https://libp2p.github.io/js-libp2p/interfaces/libp2p.index.Libp2pInit.html",
4
- "Libp2pOptions": "https://libp2p.github.io/js-libp2p/types/libp2p.index.Libp2pOptions.html",
5
- ".:Libp2pOptions": "https://libp2p.github.io/js-libp2p/types/libp2p.index.Libp2pOptions.html",
6
- "ServiceFactoryMap": "https://libp2p.github.io/js-libp2p/types/libp2p.index.ServiceFactoryMap.html",
7
- ".:ServiceFactoryMap": "https://libp2p.github.io/js-libp2p/types/libp2p.index.ServiceFactoryMap.html",
8
- "createLibp2p": "https://libp2p.github.io/js-libp2p/functions/libp2p.index.createLibp2p.html",
9
- ".:createLibp2p": "https://libp2p.github.io/js-libp2p/functions/libp2p.index.createLibp2p.html",
10
- "name": "https://libp2p.github.io/js-libp2p/variables/libp2p.version.name.html",
11
- "./version:name": "https://libp2p.github.io/js-libp2p/variables/libp2p.version.name.html",
12
- "version": "https://libp2p.github.io/js-libp2p/variables/libp2p.version.version.html",
13
- "./version:version": "https://libp2p.github.io/js-libp2p/variables/libp2p.version.version.html"
14
- }