@libp2p/webrtc 4.0.0 → 4.0.1-6c1f0ee81
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 +21 -21
- package/dist/src/index.d.ts +3 -28
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/private-to-private/transport.d.ts +21 -4
- package/dist/src/private-to-private/transport.d.ts.map +1 -1
- package/dist/src/private-to-private/transport.js +2 -1
- package/dist/src/private-to-private/transport.js.map +1 -1
- package/dist/src/private-to-public/transport.d.ts +13 -3
- package/dist/src/private-to-public/transport.d.ts.map +1 -1
- package/dist/src/private-to-public/transport.js +4 -4
- package/dist/src/private-to-public/transport.js.map +1 -1
- package/package.json +13 -13
- package/src/index.ts +3 -34
- package/src/private-to-private/transport.ts +25 -4
- package/src/private-to-public/transport.ts +19 -7
- package/dist/typedoc-urls.json +0 -16
package/dist/src/index.d.ts
CHANGED
|
@@ -28,8 +28,9 @@
|
|
|
28
28
|
* const responseDecoded = toString(response.slice(0, response.length))
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
|
-
import
|
|
32
|
-
import type {
|
|
31
|
+
import { type WebRTCTransportDirectInit, type WebRTCDirectTransportComponents } from './private-to-public/transport.js';
|
|
32
|
+
import type { WebRTCTransportComponents, WebRTCTransportInit } from './private-to-private/transport.js';
|
|
33
|
+
import type { Transport } from '@libp2p/interface';
|
|
33
34
|
export interface DataChannelOptions {
|
|
34
35
|
/**
|
|
35
36
|
* The maximum message size sendable over the channel in bytes (default 16KB)
|
|
@@ -64,14 +65,6 @@ export interface DataChannelOptions {
|
|
|
64
65
|
*/
|
|
65
66
|
openTimeout?: number;
|
|
66
67
|
}
|
|
67
|
-
export interface WebRTCDirectTransportComponents {
|
|
68
|
-
peerId: PeerId;
|
|
69
|
-
metrics?: Metrics;
|
|
70
|
-
logger: ComponentLogger;
|
|
71
|
-
}
|
|
72
|
-
export interface WebRTCTransportDirectInit {
|
|
73
|
-
dataChannel?: DataChannelOptions;
|
|
74
|
-
}
|
|
75
68
|
/**
|
|
76
69
|
* @param {WebRTCTransportDirectInit} init - WebRTC direct transport configuration
|
|
77
70
|
* @param init.dataChannel - DataChannel configurations
|
|
@@ -81,24 +74,6 @@ export interface WebRTCTransportDirectInit {
|
|
|
81
74
|
* @returns
|
|
82
75
|
*/
|
|
83
76
|
declare function webRTCDirect(init?: WebRTCTransportDirectInit): (components: WebRTCDirectTransportComponents) => Transport;
|
|
84
|
-
export interface WebRTCTransportInit {
|
|
85
|
-
rtcConfiguration?: RTCConfiguration;
|
|
86
|
-
dataChannel?: DataChannelOptions;
|
|
87
|
-
/**
|
|
88
|
-
* Inbound connections must complete the upgrade within this many ms
|
|
89
|
-
* (default: 30s)
|
|
90
|
-
*/
|
|
91
|
-
inboundConnectionTimeout?: number;
|
|
92
|
-
}
|
|
93
|
-
export interface WebRTCTransportComponents {
|
|
94
|
-
peerId: PeerId;
|
|
95
|
-
registrar: Registrar;
|
|
96
|
-
upgrader: Upgrader;
|
|
97
|
-
transportManager: TransportManager;
|
|
98
|
-
connectionManager: ConnectionManager;
|
|
99
|
-
metrics?: Metrics;
|
|
100
|
-
logger: ComponentLogger;
|
|
101
|
-
}
|
|
102
77
|
/**
|
|
103
78
|
* @param {WebRTCTransportInit} init - WebRTC transport configuration
|
|
104
79
|
* @param {RTCConfiguration} init.rtcConfiguration - RTCConfiguration
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAGH,OAAO,EAAyB,KAAK,yBAAyB,EAAE,KAAK,+BAA+B,EAAE,MAAM,kCAAkC,CAAA;AAC9I,OAAO,KAAK,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAA;AACvG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAElD,MAAM,WAAW,kBAAkB;IACjC;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAA;IAEvB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAA;IAE1B;;;;OAIG;IACH,6BAA6B,CAAC,EAAE,MAAM,CAAA;IAEtC;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAA;IAErB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAED;;;;;;;GAOG;AACH,iBAAS,YAAY,CAAE,IAAI,CAAC,EAAE,yBAAyB,GAAG,CAAC,UAAU,EAAE,+BAA+B,KAAK,SAAS,CAEnH;AAED;;;;;;;;GAQG;AACH,iBAAS,MAAM,CAAE,IAAI,CAAC,EAAE,mBAAmB,GAAG,CAAC,UAAU,EAAE,yBAAyB,KAAK,SAAS,CAEjG;AAED,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAA"}
|
package/dist/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,qBAAqB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAA;AACnE,OAAO,EAAE,qBAAqB,EAAwE,MAAM,kCAAkC,CAAA;AA4C9I;;;;;;;GAOG;AACH,SAAS,YAAY,CAAE,IAAgC;IACrD,OAAO,CAAC,UAA2C,EAAE,EAAE,CAAC,IAAI,qBAAqB,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACrG,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,MAAM,CAAE,IAA0B;IACzC,OAAO,CAAC,UAAqC,EAAE,EAAE,CAAC,IAAI,eAAe,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;AACzF,CAAC;AAED,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,CAAA"}
|
|
@@ -1,9 +1,26 @@
|
|
|
1
|
-
import { transportSymbol } from '@libp2p/interface';
|
|
1
|
+
import { type CreateListenerOptions, type DialOptions, transportSymbol, type Transport, type Listener, type Upgrader, type ComponentLogger, type Connection, type PeerId, type CounterGroup, type Metrics, type Startable } from '@libp2p/interface';
|
|
2
2
|
import { type Multiaddr } from '@multiformats/multiaddr';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { IncomingStreamData } from '@libp2p/interface-internal';
|
|
3
|
+
import type { DataChannelOptions } from '../index.js';
|
|
4
|
+
import type { IncomingStreamData, Registrar, ConnectionManager, TransportManager } from '@libp2p/interface-internal';
|
|
6
5
|
export declare const SIGNALING_PROTO_ID = "/webrtc-signaling/0.0.1";
|
|
6
|
+
export interface WebRTCTransportInit {
|
|
7
|
+
rtcConfiguration?: RTCConfiguration;
|
|
8
|
+
dataChannel?: DataChannelOptions;
|
|
9
|
+
/**
|
|
10
|
+
* Inbound connections must complete the upgrade within this many ms
|
|
11
|
+
* (default: 30s)
|
|
12
|
+
*/
|
|
13
|
+
inboundConnectionTimeout?: number;
|
|
14
|
+
}
|
|
15
|
+
export interface WebRTCTransportComponents {
|
|
16
|
+
peerId: PeerId;
|
|
17
|
+
registrar: Registrar;
|
|
18
|
+
upgrader: Upgrader;
|
|
19
|
+
transportManager: TransportManager;
|
|
20
|
+
connectionManager: ConnectionManager;
|
|
21
|
+
metrics?: Metrics;
|
|
22
|
+
logger: ComponentLogger;
|
|
23
|
+
}
|
|
7
24
|
export interface WebRTCTransportMetrics {
|
|
8
25
|
dialerEvents: CounterGroup;
|
|
9
26
|
listenerEvents: CounterGroup;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/private-to-private/transport.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/private-to-private/transport.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,WAAW,EAAE,eAAe,EAAE,KAAK,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,KAAK,eAAe,EAAe,KAAK,UAAU,EAAE,KAAK,MAAM,EAAE,KAAK,YAAY,EAAE,KAAK,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAEjQ,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,yBAAyB,CAAA;AASnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AAIpH,eAAO,MAAM,kBAAkB,4BAA4B,CAAA;AAG3D,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,WAAW,CAAC,EAAE,kBAAkB,CAAA;IAEhC;;;OAGG;IACH,wBAAwB,CAAC,EAAE,MAAM,CAAA;CAClC;AAED,MAAM,WAAW,yBAAyB;IACxC,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,SAAS,CAAA;IACpB,QAAQ,EAAE,QAAQ,CAAA;IAClB,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,iBAAiB,EAAE,iBAAiB,CAAA;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-
import { CodeError
|
|
1
|
+
import { CodeError } from '@libp2p/interface';
|
|
2
|
+
import { transportSymbol } from '@libp2p/interface';
|
|
2
3
|
import { peerIdFromString } from '@libp2p/peer-id';
|
|
3
4
|
import { multiaddr } from '@multiformats/multiaddr';
|
|
4
5
|
import { WebRTC } from '@multiformats/multiaddr-matcher';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../src/private-to-private/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../../src/private-to-private/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAgD,eAAe,EAAkK,MAAM,mBAAmB,CAAA;AACjQ,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAkB,MAAM,yBAAyB,CAAA;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,iCAAiC,CAAA;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAA;AACnC,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAA;AAC7D,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAA;AAIpE,MAAM,gBAAgB,GAAG,SAAS,CAAA;AAClC,MAAM,uBAAuB,GAAG,cAAc,CAAA;AAC9C,MAAM,CAAC,MAAM,kBAAkB,GAAG,yBAAyB,CAAA;AAC3D,MAAM,0BAA0B,GAAG,EAAE,GAA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CAAC,EAAE,CAAA;AAChF,CAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { transportSymbol } from '@libp2p/interface';
|
|
1
|
+
import { type CreateListenerOptions, transportSymbol, type Transport, type Listener, type ComponentLogger, type Connection, type CounterGroup, type Metrics, type PeerId } from '@libp2p/interface';
|
|
2
2
|
import type { WebRTCDialOptions } from './options.js';
|
|
3
|
-
import type {
|
|
4
|
-
import type { Connection, CounterGroup, CreateListenerOptions, Transport, Listener } from '@libp2p/interface';
|
|
3
|
+
import type { DataChannelOptions } from '../index.js';
|
|
5
4
|
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
6
5
|
/**
|
|
7
6
|
* Created by converting the hexadecimal protocol code to an integer.
|
|
@@ -15,9 +14,20 @@ export declare const WEBRTC_CODE: number;
|
|
|
15
14
|
* {@link https://github.com/multiformats/multiaddr/blob/master/protocols.csv}
|
|
16
15
|
*/
|
|
17
16
|
export declare const CERTHASH_CODE: number;
|
|
17
|
+
/**
|
|
18
|
+
* The peer for this transport
|
|
19
|
+
*/
|
|
20
|
+
export interface WebRTCDirectTransportComponents {
|
|
21
|
+
peerId: PeerId;
|
|
22
|
+
metrics?: Metrics;
|
|
23
|
+
logger: ComponentLogger;
|
|
24
|
+
}
|
|
18
25
|
export interface WebRTCMetrics {
|
|
19
26
|
dialerEvents: CounterGroup;
|
|
20
27
|
}
|
|
28
|
+
export interface WebRTCTransportDirectInit {
|
|
29
|
+
dataChannel?: DataChannelOptions;
|
|
30
|
+
}
|
|
21
31
|
export declare class WebRTCDirectTransport implements Transport {
|
|
22
32
|
private readonly log;
|
|
23
33
|
private readonly metrics?;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/private-to-public/transport.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/private-to-public/transport.ts"],"names":[],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CAAE,UAAU,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE;IAI7C;;OAEG;IACH,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,2BAA0B;IAEvD;;OAEG;IACH,QAAQ,CAAC,CAAC,eAAe,CAAC,QAAO;IAEjC;;OAEG;IACG,QAAQ,CAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC;IAsJ/E;;;OAGG;IACH,OAAO,CAAC,qBAAqB;CAoB9B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { noise } from '@chainsafe/libp2p-noise';
|
|
2
2
|
import { transportSymbol } from '@libp2p/interface';
|
|
3
|
-
import
|
|
3
|
+
import * as p 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';
|
|
@@ -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 = peerIdFromString(remotePeerString);
|
|
89
|
+
const theirPeerId = p.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 connectionEncrypter = noise({ prologueBytes: fingerprintsPrologue })(this.components);
|
|
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 connectionEncrypter.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,EAAE,MAAM,yBAAyB,CAAA;AAC/C,OAAO,
|
|
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,EAA8B,eAAe,EAAmI,MAAM,mBAAmB,CAAA;AAChN,OAAO,KAAK,CAAC,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAC9D,OAAO,KAAK,WAAW,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAC3C,OAAO,EAAE,UAAU,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAC5E,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AACtG,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AACxD,OAAO,EAAE,uBAAuB,EAA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AgB,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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/webrtc",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1-6c1f0ee81",
|
|
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",
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
"dep-check": "aegir dep-check"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@chainsafe/libp2p-noise": "^
|
|
53
|
-
"@libp2p/interface": "
|
|
54
|
-
"@libp2p/interface-internal": "
|
|
55
|
-
"@libp2p/logger": "
|
|
56
|
-
"@libp2p/peer-id": "
|
|
57
|
-
"@libp2p/utils": "
|
|
52
|
+
"@chainsafe/libp2p-noise": "^14.0.0",
|
|
53
|
+
"@libp2p/interface": "1.0.1-6c1f0ee81",
|
|
54
|
+
"@libp2p/interface-internal": "0.1.11-6c1f0ee81",
|
|
55
|
+
"@libp2p/logger": "4.0.1-6c1f0ee81",
|
|
56
|
+
"@libp2p/peer-id": "4.0.1-6c1f0ee81",
|
|
57
|
+
"@libp2p/utils": "5.0.1-6c1f0ee81",
|
|
58
58
|
"@multiformats/mafmt": "^12.1.6",
|
|
59
59
|
"@multiformats/multiaddr": "^12.1.10",
|
|
60
60
|
"@multiformats/multiaddr-matcher": "^1.1.0",
|
|
@@ -78,11 +78,11 @@
|
|
|
78
78
|
"uint8arrays": "^4.0.6"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@chainsafe/libp2p-yamux": "^
|
|
82
|
-
"@libp2p/circuit-relay-v2": "
|
|
83
|
-
"@libp2p/interface-compliance-tests": "
|
|
84
|
-
"@libp2p/peer-id-factory": "
|
|
85
|
-
"@libp2p/websockets": "
|
|
81
|
+
"@chainsafe/libp2p-yamux": "^6.0.1",
|
|
82
|
+
"@libp2p/circuit-relay-v2": "1.0.1-6c1f0ee81",
|
|
83
|
+
"@libp2p/interface-compliance-tests": "5.0.1-6c1f0ee81",
|
|
84
|
+
"@libp2p/peer-id-factory": "3.0.10-6c1f0ee81",
|
|
85
|
+
"@libp2p/websockets": "8.0.1-6c1f0ee81",
|
|
86
86
|
"@types/sinon": "^17.0.0",
|
|
87
87
|
"aegir": "^41.0.2",
|
|
88
88
|
"delay": "^6.0.0",
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
"it-length": "^3.0.2",
|
|
91
91
|
"it-map": "^3.0.3",
|
|
92
92
|
"it-pair": "^2.0.6",
|
|
93
|
-
"libp2p": "
|
|
93
|
+
"libp2p": "1.0.1-6c1f0ee81",
|
|
94
94
|
"p-retry": "^6.1.0",
|
|
95
95
|
"protons": "^7.3.0",
|
|
96
96
|
"sinon": "^17.0.0",
|
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 } from './private-to-public/transport.js'
|
|
34
|
-
import type {
|
|
35
|
-
import type {
|
|
33
|
+
import { WebRTCDirectTransport, type WebRTCTransportDirectInit, type WebRTCDirectTransportComponents } from './private-to-public/transport.js'
|
|
34
|
+
import type { WebRTCTransportComponents, WebRTCTransportInit } from './private-to-private/transport.js'
|
|
35
|
+
import type { Transport } from '@libp2p/interface'
|
|
36
36
|
|
|
37
37
|
export interface DataChannelOptions {
|
|
38
38
|
/**
|
|
@@ -74,16 +74,6 @@ 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
|
-
|
|
87
77
|
/**
|
|
88
78
|
* @param {WebRTCTransportDirectInit} init - WebRTC direct transport configuration
|
|
89
79
|
* @param init.dataChannel - DataChannel configurations
|
|
@@ -96,27 +86,6 @@ function webRTCDirect (init?: WebRTCTransportDirectInit): (components: WebRTCDir
|
|
|
96
86
|
return (components: WebRTCDirectTransportComponents) => new WebRTCDirectTransport(components, init)
|
|
97
87
|
}
|
|
98
88
|
|
|
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
|
-
|
|
120
89
|
/**
|
|
121
90
|
* @param {WebRTCTransportInit} init - WebRTC transport configuration
|
|
122
91
|
* @param {RTCConfiguration} init.rtcConfiguration - RTCConfiguration
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CodeError
|
|
1
|
+
import { CodeError } from '@libp2p/interface'
|
|
2
|
+
import { type CreateListenerOptions, type DialOptions, transportSymbol, type Transport, type Listener, type Upgrader, type ComponentLogger, type Logger, type Connection, type PeerId, type CounterGroup, type Metrics, type Startable } from '@libp2p/interface'
|
|
2
3
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
3
4
|
import { multiaddr, type Multiaddr } from '@multiformats/multiaddr'
|
|
4
5
|
import { WebRTC } from '@multiformats/multiaddr-matcher'
|
|
@@ -9,15 +10,35 @@ import { cleanup, RTCPeerConnection } from '../webrtc/index.js'
|
|
|
9
10
|
import { initiateConnection } from './initiate-connection.js'
|
|
10
11
|
import { WebRTCPeerListener } from './listener.js'
|
|
11
12
|
import { handleIncomingStream } from './signaling-stream-handler.js'
|
|
12
|
-
import type {
|
|
13
|
-
import type {
|
|
14
|
-
import type { IncomingStreamData } from '@libp2p/interface-internal'
|
|
13
|
+
import type { DataChannelOptions } from '../index.js'
|
|
14
|
+
import type { IncomingStreamData, Registrar, ConnectionManager, TransportManager } from '@libp2p/interface-internal'
|
|
15
15
|
|
|
16
16
|
const WEBRTC_TRANSPORT = '/webrtc'
|
|
17
17
|
const CIRCUIT_RELAY_TRANSPORT = '/p2p-circuit'
|
|
18
18
|
export const SIGNALING_PROTO_ID = '/webrtc-signaling/0.0.1'
|
|
19
19
|
const INBOUND_CONNECTION_TIMEOUT = 30 * 1000
|
|
20
20
|
|
|
21
|
+
export interface WebRTCTransportInit {
|
|
22
|
+
rtcConfiguration?: RTCConfiguration
|
|
23
|
+
dataChannel?: DataChannelOptions
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Inbound connections must complete the upgrade within this many ms
|
|
27
|
+
* (default: 30s)
|
|
28
|
+
*/
|
|
29
|
+
inboundConnectionTimeout?: number
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface WebRTCTransportComponents {
|
|
33
|
+
peerId: PeerId
|
|
34
|
+
registrar: Registrar
|
|
35
|
+
upgrader: Upgrader
|
|
36
|
+
transportManager: TransportManager
|
|
37
|
+
connectionManager: ConnectionManager
|
|
38
|
+
metrics?: Metrics
|
|
39
|
+
logger: ComponentLogger
|
|
40
|
+
}
|
|
41
|
+
|
|
21
42
|
export interface WebRTCTransportMetrics {
|
|
22
43
|
dialerEvents: CounterGroup
|
|
23
44
|
listenerEvents: CounterGroup
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { noise } from '@chainsafe/libp2p-noise'
|
|
2
|
-
import { transportSymbol } from '@libp2p/interface'
|
|
3
|
-
import
|
|
2
|
+
import { type CreateListenerOptions, transportSymbol, type Transport, type Listener, type ComponentLogger, type Logger, type Connection, type CounterGroup, type Metrics, type PeerId } from '@libp2p/interface'
|
|
3
|
+
import * as p 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,8 +15,7 @@ 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 { Logger, Connection, CounterGroup, CreateListenerOptions, Transport, Listener } from '@libp2p/interface'
|
|
18
|
+
import type { DataChannelOptions } from '../index.js'
|
|
20
19
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
21
20
|
|
|
22
21
|
/**
|
|
@@ -38,10 +37,23 @@ export const WEBRTC_CODE: number = protocols('webrtc-direct').code
|
|
|
38
37
|
*/
|
|
39
38
|
export const CERTHASH_CODE: number = protocols('certhash').code
|
|
40
39
|
|
|
40
|
+
/**
|
|
41
|
+
* The peer for this transport
|
|
42
|
+
*/
|
|
43
|
+
export interface WebRTCDirectTransportComponents {
|
|
44
|
+
peerId: PeerId
|
|
45
|
+
metrics?: Metrics
|
|
46
|
+
logger: ComponentLogger
|
|
47
|
+
}
|
|
48
|
+
|
|
41
49
|
export interface WebRTCMetrics {
|
|
42
50
|
dialerEvents: CounterGroup
|
|
43
51
|
}
|
|
44
52
|
|
|
53
|
+
export interface WebRTCTransportDirectInit {
|
|
54
|
+
dataChannel?: DataChannelOptions
|
|
55
|
+
}
|
|
56
|
+
|
|
45
57
|
export class WebRTCDirectTransport implements Transport {
|
|
46
58
|
private readonly log: Logger
|
|
47
59
|
private readonly metrics?: WebRTCMetrics
|
|
@@ -105,7 +117,7 @@ export class WebRTCDirectTransport implements Transport {
|
|
|
105
117
|
if (remotePeerString === null) {
|
|
106
118
|
throw inappropriateMultiaddr("we need to have the remote's PeerId")
|
|
107
119
|
}
|
|
108
|
-
const theirPeerId = peerIdFromString(remotePeerString)
|
|
120
|
+
const theirPeerId = p.peerIdFromString(remotePeerString)
|
|
109
121
|
|
|
110
122
|
const remoteCerthash = sdp.decodeCerthash(sdp.certhash(ma))
|
|
111
123
|
|
|
@@ -177,7 +189,7 @@ export class WebRTCDirectTransport implements Transport {
|
|
|
177
189
|
|
|
178
190
|
// Since we use the default crypto interface and do not use a static key or early data,
|
|
179
191
|
// we pass in undefined for these parameters.
|
|
180
|
-
const
|
|
192
|
+
const connectionEncrypter = noise({ prologueBytes: fingerprintsPrologue })(this.components)
|
|
181
193
|
|
|
182
194
|
const wrappedChannel = createStream({
|
|
183
195
|
channel: handshakeDataChannel,
|
|
@@ -238,7 +250,7 @@ export class WebRTCDirectTransport implements Transport {
|
|
|
238
250
|
|
|
239
251
|
// For outbound connections, the remote is expected to start the noise handshake.
|
|
240
252
|
// Therefore, we need to secure an inbound noise connection from the remote.
|
|
241
|
-
await
|
|
253
|
+
await connectionEncrypter.secureInbound(myPeerId, wrappedDuplex, theirPeerId)
|
|
242
254
|
|
|
243
255
|
return await options.upgrader.upgradeOutbound(maConn, { skipProtection: true, skipEncryption: true, muxerFactory })
|
|
244
256
|
} catch (err) {
|
package/dist/typedoc-urls.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
}
|