@libp2p/webrtc 3.2.11-e2267d437 → 4.0.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 +12 -12
- package/dist/src/error.d.ts +2 -2
- package/dist/src/error.d.ts.map +1 -1
- package/dist/src/error.js +1 -1
- package/dist/src/error.js.map +1 -1
- package/dist/src/index.d.ts +28 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/maconn.d.ts +1 -3
- package/dist/src/maconn.d.ts.map +1 -1
- package/dist/src/maconn.js.map +1 -1
- package/dist/src/muxer.d.ts +1 -4
- package/dist/src/muxer.d.ts.map +1 -1
- package/dist/src/muxer.js.map +1 -1
- package/dist/src/private-to-private/initiate-connection.d.ts +1 -3
- package/dist/src/private-to-private/initiate-connection.d.ts.map +1 -1
- package/dist/src/private-to-private/initiate-connection.js +1 -1
- package/dist/src/private-to-private/initiate-connection.js.map +1 -1
- package/dist/src/private-to-private/listener.d.ts +3 -4
- package/dist/src/private-to-private/listener.d.ts.map +1 -1
- package/dist/src/private-to-private/listener.js +1 -1
- package/dist/src/private-to-private/listener.js.map +1 -1
- package/dist/src/private-to-private/signaling-stream-handler.d.ts +1 -1
- package/dist/src/private-to-private/signaling-stream-handler.d.ts.map +1 -1
- package/dist/src/private-to-private/signaling-stream-handler.js +1 -1
- package/dist/src/private-to-private/signaling-stream-handler.js.map +1 -1
- package/dist/src/private-to-private/transport.d.ts +5 -29
- package/dist/src/private-to-private/transport.d.ts.map +1 -1
- package/dist/src/private-to-private/transport.js +2 -3
- package/dist/src/private-to-private/transport.js.map +1 -1
- package/dist/src/private-to-private/util.d.ts +1 -2
- package/dist/src/private-to-private/util.d.ts.map +1 -1
- package/dist/src/private-to-private/util.js +1 -1
- package/dist/src/private-to-private/util.js.map +1 -1
- package/dist/src/private-to-public/options.d.ts +1 -1
- package/dist/src/private-to-public/options.d.ts.map +1 -1
- package/dist/src/private-to-public/transport.d.ts +4 -18
- package/dist/src/private-to-public/transport.d.ts.map +1 -1
- package/dist/src/private-to-public/transport.js +7 -7
- package/dist/src/private-to-public/transport.js.map +1 -1
- package/dist/src/stream.d.ts +1 -2
- package/dist/src/stream.d.ts.map +1 -1
- package/dist/src/stream.js +1 -1
- package/dist/src/stream.js.map +1 -1
- package/dist/typedoc-urls.json +16 -0
- package/package.json +15 -11
- package/src/error.ts +2 -2
- package/src/index.ts +34 -3
- package/src/maconn.ts +1 -3
- package/src/muxer.ts +1 -4
- package/src/private-to-private/initiate-connection.ts +3 -6
- package/src/private-to-private/listener.ts +3 -4
- package/src/private-to-private/signaling-stream-handler.ts +2 -2
- package/src/private-to-private/transport.ts +5 -33
- package/src/private-to-private/util.ts +2 -3
- package/src/private-to-public/options.ts +1 -1
- package/src/private-to-public/transport.ts +9 -25
- package/src/stream.ts +2 -3
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { noise
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { noise } from '@chainsafe/libp2p-noise';
|
|
2
|
+
import { transportSymbol } from '@libp2p/interface';
|
|
3
|
+
import { peerIdFromString } from '@libp2p/peer-id';
|
|
4
4
|
import { protocols } from '@multiformats/multiaddr';
|
|
5
5
|
import { WebRTCDirect } from '@multiformats/multiaddr-matcher';
|
|
6
6
|
import * as multihashes from 'multihashes';
|
|
@@ -75,7 +75,7 @@ export class WebRTCDirectTransport {
|
|
|
75
75
|
/**
|
|
76
76
|
* Symbol.for('@libp2p/transport')
|
|
77
77
|
*/
|
|
78
|
-
[
|
|
78
|
+
[transportSymbol] = true;
|
|
79
79
|
/**
|
|
80
80
|
* Connect to a peer using a multiaddr
|
|
81
81
|
*/
|
|
@@ -86,7 +86,7 @@ export class WebRTCDirectTransport {
|
|
|
86
86
|
if (remotePeerString === null) {
|
|
87
87
|
throw inappropriateMultiaddr("we need to have the remote's PeerId");
|
|
88
88
|
}
|
|
89
|
-
const theirPeerId =
|
|
89
|
+
const theirPeerId = peerIdFromString(remotePeerString);
|
|
90
90
|
const remoteCerthash = sdp.decodeCerthash(sdp.certhash(ma));
|
|
91
91
|
// ECDSA is preferred over RSA here. From our testing we find that P-256 elliptic
|
|
92
92
|
// curve is supported by Pion, webrtc-rs, as well as Chromium (P-228 and P-384
|
|
@@ -145,7 +145,7 @@ export class WebRTCDirectTransport {
|
|
|
145
145
|
const fingerprintsPrologue = this.generateNoisePrologue(peerConnection, remoteCerthash.code, ma);
|
|
146
146
|
// Since we use the default crypto interface and do not use a static key or early data,
|
|
147
147
|
// we pass in undefined for these parameters.
|
|
148
|
-
const
|
|
148
|
+
const encrypter = noise({ prologueBytes: fingerprintsPrologue })();
|
|
149
149
|
const wrappedChannel = createStream({
|
|
150
150
|
channel: handshakeDataChannel,
|
|
151
151
|
direction: 'inbound',
|
|
@@ -199,7 +199,7 @@ export class WebRTCDirectTransport {
|
|
|
199
199
|
});
|
|
200
200
|
// For outbound connections, the remote is expected to start the noise handshake.
|
|
201
201
|
// Therefore, we need to secure an inbound noise connection from the remote.
|
|
202
|
-
await
|
|
202
|
+
await encrypter.secureInbound(myPeerId, wrappedDuplex, theirPeerId);
|
|
203
203
|
return await options.upgrader.upgradeOutbound(maConn, { skipProtection: true, skipEncryption: true, muxerFactory });
|
|
204
204
|
}
|
|
205
205
|
catch (err) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../src/private-to-public/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../src/private-to-public/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAC/C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAA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CAAC,YAAY,EAAE,MAAM,KAAK,CAAC,EAAE,CAAC;YACrD,MAAM,eAAe,CAAC,sBAAsB,CAAC,CAAA;QAC/C,CAAC;QAED,MAAM,gBAAgB,GAAG,GAAG,CAAC,mBAAmB,CAAC,EAAE,EAAE;YACnD,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAC,CAAA;QACF,IAAI,gBAAgB,IAAI,IAAI,EAAE,CAAC;YAC7B,MAAM,eAAe,CAAC,4BAA4B,CAAC,CAAA;QACrD,CAAC;QAED,MAAM,aAAa,GAAG,gBAAgB,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAA;QAC/E,MAAM,YAAY,GAAG,oBAAoB,CAAC,aAAa,EAAE,KAAK,CAAC,CAAA;QAC/D,MAAM,KAAK,GAAG,WAAW,CAAC,MAAM,CAAC,YAAY,EAAE,QAAQ,CAAC,CAAA;QACxD,MAAM,MAAM,GAAe,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAA;QACjE,MAAM,MAAM,GAAG,oBAAoB,CAAC,sBAAsB,CAAC,CAAA;QAE3D,OAAO,MAAM,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,CAAA;IACxC,CAAC;CACF"}
|
package/dist/src/stream.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { AbstractStream, type AbstractStreamInit } from '@libp2p/utils/abstract-stream';
|
|
2
2
|
import { Uint8ArrayList } from 'uint8arraylist';
|
|
3
3
|
import type { DataChannelOptions } from './index.js';
|
|
4
|
-
import type { AbortOptions, ComponentLogger } from '@libp2p/interface';
|
|
5
|
-
import type { Direction } from '@libp2p/interface/connection';
|
|
4
|
+
import type { AbortOptions, ComponentLogger, Direction } from '@libp2p/interface';
|
|
6
5
|
export interface WebRTCStreamInit extends AbstractStreamInit, DataChannelOptions {
|
|
7
6
|
/**
|
|
8
7
|
* The network channel used for bidirectional peer-to-peer transfers of
|
package/dist/src/stream.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAOvF,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,KAAK,kBAAkB,EAAE,MAAM,+BAA+B,CAAA;AAOvF,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAE/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAGjF,MAAM,WAAW,gBAAiB,SAAQ,kBAAkB,EAAE,kBAAkB;IAC9E;;;;;OAKG;IACH,OAAO,EAAE,cAAc,CAAA;IAEvB,MAAM,EAAE,eAAe,CAAA;CACxB;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,QAAmB,CAAA;AAEnD;;GAEG;AACH,eAAO,MAAM,2BAA2B,QAAY,CAAA;AAEpD;;GAEG;AACH,eAAO,MAAM,iBAAiB,IAAI,CAAA;AAElC;;GAEG;AACH,eAAO,MAAM,aAAa,IAAI,CAAA;AAE9B;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAY,CAAA;AAEzC;;;;GAIG;AACH,eAAO,MAAM,eAAe,OAAO,CAAA;AAEnC;;;GAGG;AACH,eAAO,MAAM,Y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/dist/src/stream.js
CHANGED
package/dist/src/stream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAA2B,MAAM,+BAA+B,CAAA;AACvF,OAAO,KAAK,cAAc,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAiB,QAAQ,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,MAAM,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,QAAQ,MAAM,WAAW,CAAA;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAiBzC;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAA;AAEnD;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,GAAG,IAAI,CAAA;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAA;AAElC;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAA;AAE9B;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,CAAA;AAEzC;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,CAAA;AAEnC;;;GAGG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,IAAI,CAAA;AAEhC,MAA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16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"DataChannelOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.DataChannelOptions.html",
|
|
3
|
+
".:DataChannelOptions": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.DataChannelOptions.html",
|
|
4
|
+
"WebRTCDirectTransportComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.WebRTCDirectTransportComponents.html",
|
|
5
|
+
".:WebRTCDirectTransportComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.WebRTCDirectTransportComponents.html",
|
|
6
|
+
"WebRTCTransportComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.WebRTCTransportComponents.html",
|
|
7
|
+
".:WebRTCTransportComponents": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.WebRTCTransportComponents.html",
|
|
8
|
+
"WebRTCTransportDirectInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.WebRTCTransportDirectInit.html",
|
|
9
|
+
".:WebRTCTransportDirectInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.WebRTCTransportDirectInit.html",
|
|
10
|
+
"WebRTCTransportInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.WebRTCTransportInit.html",
|
|
11
|
+
".:WebRTCTransportInit": "https://libp2p.github.io/js-libp2p/interfaces/_libp2p_webrtc.WebRTCTransportInit.html",
|
|
12
|
+
"webRTC": "https://libp2p.github.io/js-libp2p/functions/_libp2p_webrtc.webRTC.html",
|
|
13
|
+
".:webRTC": "https://libp2p.github.io/js-libp2p/functions/_libp2p_webrtc.webRTC.html",
|
|
14
|
+
"webRTCDirect": "https://libp2p.github.io/js-libp2p/functions/_libp2p_webrtc.webRTCDirect.html",
|
|
15
|
+
".:webRTCDirect": "https://libp2p.github.io/js-libp2p/functions/_libp2p_webrtc.webRTCDirect.html"
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/webrtc",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "A libp2p transport using WebRTC connections",
|
|
5
5
|
"license": "Apache-2.0 OR MIT",
|
|
6
6
|
"homepage": "https://github.com/libp2p/js-libp2p/tree/main/packages/transport-webrtc#readme",
|
|
@@ -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
|
"type": "module",
|
|
15
19
|
"types": "./dist/src/index.d.ts",
|
|
16
20
|
"files": [
|
|
@@ -46,11 +50,11 @@
|
|
|
46
50
|
},
|
|
47
51
|
"dependencies": {
|
|
48
52
|
"@chainsafe/libp2p-noise": "^13.0.0",
|
|
49
|
-
"@libp2p/interface": "0.
|
|
50
|
-
"@libp2p/interface-internal": "0.1.
|
|
51
|
-
"@libp2p/logger": "
|
|
52
|
-
"@libp2p/peer-id": "
|
|
53
|
-
"@libp2p/utils": "
|
|
53
|
+
"@libp2p/interface": "^1.0.0",
|
|
54
|
+
"@libp2p/interface-internal": "^0.1.10",
|
|
55
|
+
"@libp2p/logger": "^4.0.0",
|
|
56
|
+
"@libp2p/peer-id": "^4.0.0",
|
|
57
|
+
"@libp2p/utils": "^5.0.0",
|
|
54
58
|
"@multiformats/mafmt": "^12.1.6",
|
|
55
59
|
"@multiformats/multiaddr": "^12.1.10",
|
|
56
60
|
"@multiformats/multiaddr-matcher": "^1.1.0",
|
|
@@ -75,10 +79,10 @@
|
|
|
75
79
|
},
|
|
76
80
|
"devDependencies": {
|
|
77
81
|
"@chainsafe/libp2p-yamux": "^5.0.0",
|
|
78
|
-
"@libp2p/circuit-relay-v2": "
|
|
79
|
-
"@libp2p/interface-compliance-tests": "
|
|
80
|
-
"@libp2p/peer-id-factory": "3.0.
|
|
81
|
-
"@libp2p/websockets": "
|
|
82
|
+
"@libp2p/circuit-relay-v2": "^1.0.0",
|
|
83
|
+
"@libp2p/interface-compliance-tests": "^5.0.0",
|
|
84
|
+
"@libp2p/peer-id-factory": "^3.0.9",
|
|
85
|
+
"@libp2p/websockets": "^8.0.0",
|
|
82
86
|
"@types/sinon": "^17.0.0",
|
|
83
87
|
"aegir": "^41.0.2",
|
|
84
88
|
"delay": "^6.0.0",
|
|
@@ -86,7 +90,7 @@
|
|
|
86
90
|
"it-length": "^3.0.2",
|
|
87
91
|
"it-map": "^3.0.3",
|
|
88
92
|
"it-pair": "^2.0.6",
|
|
89
|
-
"libp2p": "0.
|
|
93
|
+
"libp2p": "^1.0.0",
|
|
90
94
|
"p-retry": "^6.1.0",
|
|
91
95
|
"protons": "^7.3.0",
|
|
92
96
|
"sinon": "^17.0.0",
|
package/src/error.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/interface
|
|
2
|
-
import type { Direction } from '@libp2p/interface
|
|
1
|
+
import { CodeError } from '@libp2p/interface'
|
|
2
|
+
import type { Direction } from '@libp2p/interface'
|
|
3
3
|
|
|
4
4
|
export enum codes {
|
|
5
5
|
ERR_ALREADY_ABORTED = 'ERR_ALREADY_ABORTED',
|
package/src/index.ts
CHANGED
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
*/
|
|
31
31
|
|
|
32
32
|
import { WebRTCTransport } from './private-to-private/transport.js'
|
|
33
|
-
import { WebRTCDirectTransport
|
|
34
|
-
import type {
|
|
35
|
-
import type {
|
|
33
|
+
import { WebRTCDirectTransport } from './private-to-public/transport.js'
|
|
34
|
+
import type { ComponentLogger, Metrics, PeerId, Transport, Upgrader } from '@libp2p/interface'
|
|
35
|
+
import type { ConnectionManager, Registrar, TransportManager } from '@libp2p/interface-internal'
|
|
36
36
|
|
|
37
37
|
export interface DataChannelOptions {
|
|
38
38
|
/**
|
|
@@ -74,6 +74,16 @@ export interface DataChannelOptions {
|
|
|
74
74
|
openTimeout?: number
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
export interface WebRTCDirectTransportComponents {
|
|
78
|
+
peerId: PeerId
|
|
79
|
+
metrics?: Metrics
|
|
80
|
+
logger: ComponentLogger
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export interface WebRTCTransportDirectInit {
|
|
84
|
+
dataChannel?: DataChannelOptions
|
|
85
|
+
}
|
|
86
|
+
|
|
77
87
|
/**
|
|
78
88
|
* @param {WebRTCTransportDirectInit} init - WebRTC direct transport configuration
|
|
79
89
|
* @param init.dataChannel - DataChannel configurations
|
|
@@ -86,6 +96,27 @@ function webRTCDirect (init?: WebRTCTransportDirectInit): (components: WebRTCDir
|
|
|
86
96
|
return (components: WebRTCDirectTransportComponents) => new WebRTCDirectTransport(components, init)
|
|
87
97
|
}
|
|
88
98
|
|
|
99
|
+
export interface WebRTCTransportInit {
|
|
100
|
+
rtcConfiguration?: RTCConfiguration
|
|
101
|
+
dataChannel?: DataChannelOptions
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Inbound connections must complete the upgrade within this many ms
|
|
105
|
+
* (default: 30s)
|
|
106
|
+
*/
|
|
107
|
+
inboundConnectionTimeout?: number
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface WebRTCTransportComponents {
|
|
111
|
+
peerId: PeerId
|
|
112
|
+
registrar: Registrar
|
|
113
|
+
upgrader: Upgrader
|
|
114
|
+
transportManager: TransportManager
|
|
115
|
+
connectionManager: ConnectionManager
|
|
116
|
+
metrics?: Metrics
|
|
117
|
+
logger: ComponentLogger
|
|
118
|
+
}
|
|
119
|
+
|
|
89
120
|
/**
|
|
90
121
|
* @param {WebRTCTransportInit} init - WebRTC transport configuration
|
|
91
122
|
* @param {RTCConfiguration} init.rtcConfiguration - RTCConfiguration
|
package/src/maconn.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { nopSink, nopSource } from './util.js'
|
|
2
|
-
import type { ComponentLogger, Logger } from '@libp2p/interface'
|
|
3
|
-
import type { MultiaddrConnection, MultiaddrConnectionTimeline } from '@libp2p/interface/connection'
|
|
4
|
-
import type { CounterGroup } from '@libp2p/interface/metrics'
|
|
2
|
+
import type { ComponentLogger, Logger, MultiaddrConnection, MultiaddrConnectionTimeline, CounterGroup } from '@libp2p/interface'
|
|
5
3
|
import type { AbortOptions, Multiaddr } from '@multiformats/multiaddr'
|
|
6
4
|
import type { Source, Sink } from 'it-stream-types'
|
|
7
5
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
package/src/muxer.ts
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import { createStream } from './stream.js'
|
|
2
2
|
import { drainAndClose, nopSink, nopSource } from './util.js'
|
|
3
3
|
import type { DataChannelOptions } from './index.js'
|
|
4
|
-
import type { ComponentLogger, Logger } from '@libp2p/interface'
|
|
5
|
-
import type { Stream } from '@libp2p/interface/connection'
|
|
6
|
-
import type { CounterGroup } from '@libp2p/interface/metrics'
|
|
7
|
-
import type { StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface/stream-muxer'
|
|
4
|
+
import type { ComponentLogger, Logger, Stream, CounterGroup, StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface'
|
|
8
5
|
import type { AbortOptions } from '@multiformats/multiaddr'
|
|
9
6
|
import type { Source, Sink } from 'it-stream-types'
|
|
10
7
|
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/interface
|
|
1
|
+
import { CodeError } from '@libp2p/interface'
|
|
2
2
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
3
3
|
import { pbStream } from 'it-protobuf-stream'
|
|
4
4
|
import pDefer, { type DeferredPromise } from 'p-defer'
|
|
@@ -7,11 +7,8 @@ import { Message } from './pb/message.js'
|
|
|
7
7
|
import { SIGNALING_PROTO_ID, splitAddr, type WebRTCTransportMetrics } from './transport.js'
|
|
8
8
|
import { readCandidatesUntilConnected, resolveOnConnected } from './util.js'
|
|
9
9
|
import type { DataChannelOptions } from '../index.js'
|
|
10
|
-
import type { LoggerOptions } from '@libp2p/interface'
|
|
11
|
-
import type {
|
|
12
|
-
import type { ConnectionManager } from '@libp2p/interface-internal/connection-manager'
|
|
13
|
-
import type { IncomingStreamData } from '@libp2p/interface-internal/registrar'
|
|
14
|
-
import type { TransportManager } from '@libp2p/interface-internal/transport-manager'
|
|
10
|
+
import type { LoggerOptions, Connection } from '@libp2p/interface'
|
|
11
|
+
import type { ConnectionManager, IncomingStreamData, TransportManager } from '@libp2p/interface-internal'
|
|
15
12
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
16
13
|
|
|
17
14
|
export interface IncomingStreamOpts extends IncomingStreamData {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import { TypedEventEmitter } from '@libp2p/interface
|
|
1
|
+
import { TypedEventEmitter } from '@libp2p/interface'
|
|
2
2
|
import { Circuit } from '@multiformats/mafmt'
|
|
3
|
-
import type { PeerId } from '@libp2p/interface
|
|
4
|
-
import type {
|
|
5
|
-
import type { TransportManager } from '@libp2p/interface-internal/transport-manager'
|
|
3
|
+
import type { PeerId, ListenerEvents, Listener } from '@libp2p/interface'
|
|
4
|
+
import type { TransportManager } from '@libp2p/interface-internal'
|
|
6
5
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
7
6
|
|
|
8
7
|
export interface WebRTCPeerListenerComponents {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/interface
|
|
1
|
+
import { CodeError } from '@libp2p/interface'
|
|
2
2
|
import { multiaddr, type Multiaddr } from '@multiformats/multiaddr'
|
|
3
3
|
import { pbStream } from 'it-protobuf-stream'
|
|
4
4
|
import pDefer, { type DeferredPromise } from 'p-defer'
|
|
@@ -6,7 +6,7 @@ import { type RTCPeerConnection, RTCSessionDescription } from '../webrtc/index.j
|
|
|
6
6
|
import { Message } from './pb/message.js'
|
|
7
7
|
import { readCandidatesUntilConnected, resolveOnConnected } from './util.js'
|
|
8
8
|
import type { Logger } from '@libp2p/interface'
|
|
9
|
-
import type { IncomingStreamData } from '@libp2p/interface-internal
|
|
9
|
+
import type { IncomingStreamData } from '@libp2p/interface-internal'
|
|
10
10
|
|
|
11
11
|
export interface IncomingStreamOpts extends IncomingStreamData {
|
|
12
12
|
peerConnection: RTCPeerConnection
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/interface
|
|
2
|
-
import { type CreateListenerOptions, type DialOptions, symbol, type Transport, type Listener, type Upgrader } from '@libp2p/interface/transport'
|
|
1
|
+
import { CodeError, transportSymbol } from '@libp2p/interface'
|
|
3
2
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
4
3
|
import { multiaddr, type Multiaddr } from '@multiformats/multiaddr'
|
|
5
4
|
import { WebRTC } from '@multiformats/multiaddr-matcher'
|
|
@@ -10,42 +9,15 @@ import { cleanup, RTCPeerConnection } from '../webrtc/index.js'
|
|
|
10
9
|
import { initiateConnection } from './initiate-connection.js'
|
|
11
10
|
import { WebRTCPeerListener } from './listener.js'
|
|
12
11
|
import { handleIncomingStream } from './signaling-stream-handler.js'
|
|
13
|
-
import type {
|
|
14
|
-
import type {
|
|
15
|
-
import type {
|
|
16
|
-
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
17
|
-
import type { CounterGroup, Metrics } from '@libp2p/interface/src/metrics/index.js'
|
|
18
|
-
import type { Startable } from '@libp2p/interface/startable'
|
|
19
|
-
import type { IncomingStreamData, Registrar } from '@libp2p/interface-internal/registrar'
|
|
20
|
-
import type { ConnectionManager } from '@libp2p/interface-internal/src/connection-manager/index.js'
|
|
21
|
-
import type { TransportManager } from '@libp2p/interface-internal/transport-manager'
|
|
12
|
+
import type { WebRTCTransportComponents, WebRTCTransportInit } from '../index.js'
|
|
13
|
+
import type { Logger, Connection, CounterGroup, PeerId, Startable, CreateListenerOptions, DialOptions, Transport, Listener } from '@libp2p/interface'
|
|
14
|
+
import type { IncomingStreamData } from '@libp2p/interface-internal'
|
|
22
15
|
|
|
23
16
|
const WEBRTC_TRANSPORT = '/webrtc'
|
|
24
17
|
const CIRCUIT_RELAY_TRANSPORT = '/p2p-circuit'
|
|
25
18
|
export const SIGNALING_PROTO_ID = '/webrtc-signaling/0.0.1'
|
|
26
19
|
const INBOUND_CONNECTION_TIMEOUT = 30 * 1000
|
|
27
20
|
|
|
28
|
-
export interface WebRTCTransportInit {
|
|
29
|
-
rtcConfiguration?: RTCConfiguration
|
|
30
|
-
dataChannel?: DataChannelOptions
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Inbound connections must complete the upgrade within this many ms
|
|
34
|
-
* (default: 30s)
|
|
35
|
-
*/
|
|
36
|
-
inboundConnectionTimeout?: number
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export interface WebRTCTransportComponents {
|
|
40
|
-
peerId: PeerId
|
|
41
|
-
registrar: Registrar
|
|
42
|
-
upgrader: Upgrader
|
|
43
|
-
transportManager: TransportManager
|
|
44
|
-
connectionManager: ConnectionManager
|
|
45
|
-
metrics?: Metrics
|
|
46
|
-
logger: ComponentLogger
|
|
47
|
-
}
|
|
48
|
-
|
|
49
21
|
export interface WebRTCTransportMetrics {
|
|
50
22
|
dialerEvents: CounterGroup
|
|
51
23
|
listenerEvents: CounterGroup
|
|
@@ -105,7 +77,7 @@ export class WebRTCTransport implements Transport, Startable {
|
|
|
105
77
|
|
|
106
78
|
readonly [Symbol.toStringTag] = '@libp2p/webrtc'
|
|
107
79
|
|
|
108
|
-
readonly [
|
|
80
|
+
readonly [transportSymbol] = true
|
|
109
81
|
|
|
110
82
|
filter (multiaddrs: Multiaddr[]): Multiaddr[] {
|
|
111
83
|
return multiaddrs.filter(WebRTC.exactMatch)
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/interface
|
|
1
|
+
import { CodeError } from '@libp2p/interface'
|
|
2
2
|
import { closeSource } from '@libp2p/utils/close-source'
|
|
3
3
|
import { anySignal } from 'any-signal'
|
|
4
4
|
import { isFirefox } from '../util.js'
|
|
5
5
|
import { RTCIceCandidate } from '../webrtc/index.js'
|
|
6
6
|
import { Message } from './pb/message.js'
|
|
7
|
-
import type { LoggerOptions } from '@libp2p/interface'
|
|
8
|
-
import type { Stream } from '@libp2p/interface/connection'
|
|
7
|
+
import type { LoggerOptions, Stream } from '@libp2p/interface'
|
|
9
8
|
import type { AbortOptions, MessageStream } from 'it-protobuf-stream'
|
|
10
9
|
import type { DeferredPromise } from 'p-defer'
|
|
11
10
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { CreateListenerOptions, DialOptions } from '@libp2p/interface
|
|
1
|
+
import type { CreateListenerOptions, DialOptions } from '@libp2p/interface'
|
|
2
2
|
|
|
3
3
|
export interface WebRTCListenerOptions extends CreateListenerOptions {}
|
|
4
4
|
export interface WebRTCDialOptions extends DialOptions {}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { noise
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
1
|
+
import { noise } from '@chainsafe/libp2p-noise'
|
|
2
|
+
import { transportSymbol } from '@libp2p/interface'
|
|
3
|
+
import { peerIdFromString } from '@libp2p/peer-id'
|
|
4
4
|
import { protocols } from '@multiformats/multiaddr'
|
|
5
5
|
import { WebRTCDirect } from '@multiformats/multiaddr-matcher'
|
|
6
6
|
import * as multihashes from 'multihashes'
|
|
@@ -15,11 +15,8 @@ import { RTCPeerConnection } from '../webrtc/index.js'
|
|
|
15
15
|
import * as sdp from './sdp.js'
|
|
16
16
|
import { genUfrag } from './util.js'
|
|
17
17
|
import type { WebRTCDialOptions } from './options.js'
|
|
18
|
-
import type {
|
|
19
|
-
import type {
|
|
20
|
-
import type { Connection } from '@libp2p/interface/connection'
|
|
21
|
-
import type { CounterGroup, Metrics } from '@libp2p/interface/metrics'
|
|
22
|
-
import type { PeerId } from '@libp2p/interface/peer-id'
|
|
18
|
+
import type { WebRTCDirectTransportComponents, WebRTCTransportDirectInit } from '../index.js'
|
|
19
|
+
import type { Logger, Connection, CounterGroup, CreateListenerOptions, Transport, Listener } from '@libp2p/interface'
|
|
23
20
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
24
21
|
|
|
25
22
|
/**
|
|
@@ -41,23 +38,10 @@ export const WEBRTC_CODE: number = protocols('webrtc-direct').code
|
|
|
41
38
|
*/
|
|
42
39
|
export const CERTHASH_CODE: number = protocols('certhash').code
|
|
43
40
|
|
|
44
|
-
/**
|
|
45
|
-
* The peer for this transport
|
|
46
|
-
*/
|
|
47
|
-
export interface WebRTCDirectTransportComponents {
|
|
48
|
-
peerId: PeerId
|
|
49
|
-
metrics?: Metrics
|
|
50
|
-
logger: ComponentLogger
|
|
51
|
-
}
|
|
52
|
-
|
|
53
41
|
export interface WebRTCMetrics {
|
|
54
42
|
dialerEvents: CounterGroup
|
|
55
43
|
}
|
|
56
44
|
|
|
57
|
-
export interface WebRTCTransportDirectInit {
|
|
58
|
-
dataChannel?: DataChannelOptions
|
|
59
|
-
}
|
|
60
|
-
|
|
61
45
|
export class WebRTCDirectTransport implements Transport {
|
|
62
46
|
private readonly log: Logger
|
|
63
47
|
private readonly metrics?: WebRTCMetrics
|
|
@@ -108,7 +92,7 @@ export class WebRTCDirectTransport implements Transport {
|
|
|
108
92
|
/**
|
|
109
93
|
* Symbol.for('@libp2p/transport')
|
|
110
94
|
*/
|
|
111
|
-
readonly [
|
|
95
|
+
readonly [transportSymbol] = true
|
|
112
96
|
|
|
113
97
|
/**
|
|
114
98
|
* Connect to a peer using a multiaddr
|
|
@@ -121,7 +105,7 @@ export class WebRTCDirectTransport implements Transport {
|
|
|
121
105
|
if (remotePeerString === null) {
|
|
122
106
|
throw inappropriateMultiaddr("we need to have the remote's PeerId")
|
|
123
107
|
}
|
|
124
|
-
const theirPeerId =
|
|
108
|
+
const theirPeerId = peerIdFromString(remotePeerString)
|
|
125
109
|
|
|
126
110
|
const remoteCerthash = sdp.decodeCerthash(sdp.certhash(ma))
|
|
127
111
|
|
|
@@ -193,7 +177,7 @@ export class WebRTCDirectTransport implements Transport {
|
|
|
193
177
|
|
|
194
178
|
// Since we use the default crypto interface and do not use a static key or early data,
|
|
195
179
|
// we pass in undefined for these parameters.
|
|
196
|
-
const
|
|
180
|
+
const encrypter = noise({ prologueBytes: fingerprintsPrologue })()
|
|
197
181
|
|
|
198
182
|
const wrappedChannel = createStream({
|
|
199
183
|
channel: handshakeDataChannel,
|
|
@@ -254,7 +238,7 @@ export class WebRTCDirectTransport implements Transport {
|
|
|
254
238
|
|
|
255
239
|
// For outbound connections, the remote is expected to start the noise handshake.
|
|
256
240
|
// Therefore, we need to secure an inbound noise connection from the remote.
|
|
257
|
-
await
|
|
241
|
+
await encrypter.secureInbound(myPeerId, wrappedDuplex, theirPeerId)
|
|
258
242
|
|
|
259
243
|
return await options.upgrader.upgradeOutbound(maConn, { skipProtection: true, skipEncryption: true, muxerFactory })
|
|
260
244
|
} catch (err) {
|
package/src/stream.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CodeError } from '@libp2p/interface
|
|
1
|
+
import { CodeError } from '@libp2p/interface'
|
|
2
2
|
import { AbstractStream, type AbstractStreamInit } from '@libp2p/utils/abstract-stream'
|
|
3
3
|
import * as lengthPrefixed from 'it-length-prefixed'
|
|
4
4
|
import { type Pushable, pushable } from 'it-pushable'
|
|
@@ -9,8 +9,7 @@ import { raceSignal } from 'race-signal'
|
|
|
9
9
|
import { Uint8ArrayList } from 'uint8arraylist'
|
|
10
10
|
import { Message } from './pb/message.js'
|
|
11
11
|
import type { DataChannelOptions } from './index.js'
|
|
12
|
-
import type { AbortOptions, ComponentLogger } from '@libp2p/interface'
|
|
13
|
-
import type { Direction } from '@libp2p/interface/connection'
|
|
12
|
+
import type { AbortOptions, ComponentLogger, Direction } from '@libp2p/interface'
|
|
14
13
|
import type { DeferredPromise } from 'p-defer'
|
|
15
14
|
|
|
16
15
|
export interface WebRTCStreamInit extends AbstractStreamInit, DataChannelOptions {
|