@libp2p/webrtc 1.1.10 → 1.1.11
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 +15 -15
- package/dist/src/index.d.ts +2 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/maconn.d.ts +2 -2
- package/dist/src/maconn.d.ts.map +1 -1
- package/dist/src/maconn.js +20 -8
- package/dist/src/maconn.js.map +1 -1
- package/dist/src/muxer.d.ts +3 -2
- package/dist/src/muxer.d.ts.map +1 -1
- package/dist/src/muxer.js +31 -17
- package/dist/src/muxer.js.map +1 -1
- package/dist/src/peer_transport/handler.d.ts +1 -1
- package/dist/src/peer_transport/handler.d.ts.map +1 -1
- package/dist/src/peer_transport/handler.js +6 -8
- package/dist/src/peer_transport/handler.js.map +1 -1
- package/dist/src/peer_transport/listener.d.ts +2 -2
- package/dist/src/peer_transport/listener.d.ts.map +1 -1
- package/dist/src/peer_transport/listener.js +2 -1
- package/dist/src/peer_transport/listener.js.map +1 -1
- package/dist/src/peer_transport/pb/index.d.ts +1 -1
- package/dist/src/peer_transport/pb/index.d.ts.map +1 -1
- package/dist/src/peer_transport/transport.d.ts +6 -7
- package/dist/src/peer_transport/transport.d.ts.map +1 -1
- package/dist/src/peer_transport/transport.js +10 -12
- package/dist/src/peer_transport/transport.js.map +1 -1
- package/dist/src/peer_transport/util.d.ts +1 -1
- package/dist/src/peer_transport/util.d.ts.map +1 -1
- package/dist/src/peer_transport/util.js +1 -1
- package/dist/src/peer_transport/util.js.map +1 -1
- package/dist/src/sdp.d.ts +1 -1
- package/dist/src/sdp.d.ts.map +1 -1
- package/dist/src/sdp.js.map +1 -1
- package/dist/src/stream.d.ts +5 -5
- package/dist/src/stream.d.ts.map +1 -1
- package/dist/src/stream.js +48 -25
- package/dist/src/stream.js.map +1 -1
- package/dist/src/transport.d.ts +4 -4
- package/dist/src/transport.d.ts.map +1 -1
- package/dist/src/transport.js +10 -10
- package/dist/src/transport.js.map +1 -1
- package/dist/src/util.d.ts +1 -3
- package/dist/src/util.d.ts.map +1 -1
- package/dist/src/util.js +1 -3
- package/dist/src/util.js.map +1 -1
- package/package.json +27 -29
- package/src/index.ts +3 -3
- package/src/maconn.ts +4 -5
- package/src/muxer.ts +5 -5
- package/src/peer_transport/handler.ts +7 -9
- package/src/peer_transport/listener.ts +3 -3
- package/src/peer_transport/pb/index.ts +1 -1
- package/src/peer_transport/transport.ts +13 -18
- package/src/peer_transport/util.ts +2 -2
- package/src/sdp.ts +2 -3
- package/src/stream.ts +6 -7
- package/src/transport.ts +11 -15
- package/src/util.ts +1 -3
package/dist/src/stream.js
CHANGED
|
@@ -32,9 +32,7 @@ function unreachableBranch(x) {
|
|
|
32
32
|
throw new Error('Case not handled in switch');
|
|
33
33
|
}
|
|
34
34
|
class StreamState {
|
|
35
|
-
|
|
36
|
-
this.state = StreamStates.OPEN;
|
|
37
|
-
}
|
|
35
|
+
state = StreamStates.OPEN;
|
|
38
36
|
isWriteClosed() {
|
|
39
37
|
return (this.state === StreamStates.CLOSED || this.state === StreamStates.WRITE_CLOSED);
|
|
40
38
|
}
|
|
@@ -98,29 +96,54 @@ class StreamState {
|
|
|
98
96
|
}
|
|
99
97
|
}
|
|
100
98
|
export class WebRTCStream {
|
|
99
|
+
/**
|
|
100
|
+
* Unique identifier for a stream
|
|
101
|
+
*/
|
|
102
|
+
id;
|
|
103
|
+
/**
|
|
104
|
+
* Stats about this stream
|
|
105
|
+
*/
|
|
106
|
+
stat;
|
|
107
|
+
/**
|
|
108
|
+
* User defined stream metadata
|
|
109
|
+
*/
|
|
110
|
+
metadata;
|
|
111
|
+
/**
|
|
112
|
+
* The data channel used to send and receive data
|
|
113
|
+
*/
|
|
114
|
+
channel;
|
|
115
|
+
/**
|
|
116
|
+
* The current state of the stream
|
|
117
|
+
*/
|
|
118
|
+
streamState = new StreamState();
|
|
119
|
+
/**
|
|
120
|
+
* Read unwrapped protobuf data from the underlying datachannel.
|
|
121
|
+
* _src is exposed to the user via the `source` getter to .
|
|
122
|
+
*/
|
|
123
|
+
_src;
|
|
124
|
+
/**
|
|
125
|
+
* push data from the underlying datachannel to the length prefix decoder
|
|
126
|
+
* and then the protobuf decoder.
|
|
127
|
+
*/
|
|
128
|
+
_innersrc = pushable();
|
|
129
|
+
/**
|
|
130
|
+
* Deferred promise that resolves when the underlying datachannel is in the
|
|
131
|
+
* open state.
|
|
132
|
+
*/
|
|
133
|
+
opened = defer();
|
|
134
|
+
/**
|
|
135
|
+
* sinkCreated is set to true once the sinkFunction is invoked
|
|
136
|
+
*/
|
|
137
|
+
_sinkCalled = false;
|
|
138
|
+
/**
|
|
139
|
+
* Triggers a generator which can be used to close the sink.
|
|
140
|
+
*/
|
|
141
|
+
closeWritePromise = defer();
|
|
142
|
+
/**
|
|
143
|
+
* Callback to invoke when the stream is closed.
|
|
144
|
+
*/
|
|
145
|
+
closeCb;
|
|
101
146
|
constructor(opts) {
|
|
102
|
-
/**
|
|
103
|
-
* The current state of the stream
|
|
104
|
-
*/
|
|
105
|
-
this.streamState = new StreamState();
|
|
106
|
-
/**
|
|
107
|
-
* push data from the underlying datachannel to the length prefix decoder
|
|
108
|
-
* and then the protobuf decoder.
|
|
109
|
-
*/
|
|
110
|
-
this._innersrc = pushable();
|
|
111
|
-
/**
|
|
112
|
-
* Deferred promise that resolves when the underlying datachannel is in the
|
|
113
|
-
* open state.
|
|
114
|
-
*/
|
|
115
|
-
this.opened = defer();
|
|
116
|
-
/**
|
|
117
|
-
* sinkCreated is set to true once the sinkFunction is invoked
|
|
118
|
-
*/
|
|
119
|
-
this._sinkCalled = false;
|
|
120
|
-
/**
|
|
121
|
-
* Triggers a generator which can be used to close the sink.
|
|
122
|
-
*/
|
|
123
|
-
this.closeWritePromise = defer();
|
|
124
147
|
this.channel = opts.channel;
|
|
125
148
|
this.channel.binaryType = 'arraybuffer';
|
|
126
149
|
this.id = this.channel.label;
|
package/dist/src/stream.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../src/stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,KAAK,cAAc,MAAM,oBAAoB,CAAA;AACpD,OAAO,KAAK,MAAM,UAAU,CAAA;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC9B,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,KAA+B,MAAM,SAAS,CAAA;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAC/C,OAAO,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAI5C,MAAM,GAAG,GAAG,MAAM,CAAC,sBAAsB,CAAC,CAAA;AAE1C;;GAEG;AACH,MAAM,UAAU,WAAW,CAAE,GAAc;IACzC,OAAO;QACL,SAAS,EAAE,GAAG;QACd,QAAQ,EAAE;YACR,IAAI,EAAE,CAAC;YACP,KAAK,EAAE,SAAS;SACjB;KACF,CAAA;AACH,CAAC;AA+CD,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,+CAAI,CAAA;IACJ,6DAAW,CAAA;IACX,+DAAY,CAAA;IACZ,mDAAM,CAAA;AACR,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAED,4EAA4E;AAC5E,+BAA+B;AAC/B,SAAS,iBAAiB,CAAE,CAAQ;IAClC,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAA;AAC/C,CAAC;AAED,MAAM,WAAW;IACf,KAAK,GAAiB,YAAY,CAAC,IAAI,CAAA;IAEvC,aAAa;QACX,OAAO,CAAC,IAAI,CAAC,KAAK,KAAK,YAAY,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,KAAK,YAAY,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,SAAS,EAAE;YAC9B,mBAAmB;YACnB,OAAM;SACP;QAED,IAAI,CAAC,SAAS,CAAC,EAAE,CAAC,YAAY,CAAC,KAAK,CAAC,CAAA;QACrC,IAAI,CAAC,KAAK,EAAE,CAAA;IACd,CAAC;IAEO,SAAS,CAAE,IAAqB;QACtC,IAAI;YACF,GAAG,CAAC,KAAK,CAAC,kBAAkB,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;YAC9C,MAAM,MAAM,GAAG,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,IAAI,EAAE,CAAC,CAAA;YAC5C,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAA;SACnE;QAAC,OAAO,GAAG,EAAE;YACZ,IAAI,GAAG,YAAY,KAAK,EAAE;gBACxB,GAAG,CAAC,KAAK,CAAC,gCAAgC,IAAI,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;aAClE;SACF;IACH,CAAC;IAEO,mBAAmB;QACzB,MAAM,IAAI,GAAG,IAAI,CAAA;QACjB,OAAO;YACL,KAAK,CAAC,CAAE,CAAC,MAAM,CAAC,aAAa,CAAC;gBAC5B,MAAM,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAAA;gBACpC,MAAM,IAAI,UAAU,CAAC,CAAC,CAAC,CAAA;YACzB,CAAC;SACF,CAAA;IACH,CAAC;IAED,EAAE,CAAE,MAAc;QAChB,IAAI,MAAM,YAAY,YAAY,EAAE;YAClC,OAAO,MAAM,CAAC,OAAO,CAAC,EAAE,KAAK,IAAI,CAAC,OAAO,CAAC,EAAE,CAAA;SAC7C;QACD,OAAO,KAAK,CAAA;IACd,CAAC;CACF"}
|
package/dist/src/transport.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { type CreateListenerOptions, type Listener, symbol, type Transport } from '@libp2p/interface-transport';
|
|
2
|
+
import type { WebRTCDialOptions } from './options.js';
|
|
1
3
|
import type { Connection } from '@libp2p/interface-connection';
|
|
2
4
|
import type { PeerId } from '@libp2p/interface-peer-id';
|
|
3
|
-
import { CreateListenerOptions, Listener, symbol, Transport } from '@libp2p/interface-transport';
|
|
4
5
|
import type { Multiaddr } from '@multiformats/multiaddr';
|
|
5
|
-
import type { WebRTCDialOptions } from './options.js';
|
|
6
6
|
/**
|
|
7
7
|
* Created by converting the hexadecimal protocol code to an integer.
|
|
8
8
|
*
|
|
@@ -42,11 +42,11 @@ export declare class WebRTCDirectTransport implements Transport {
|
|
|
42
42
|
/**
|
|
43
43
|
* Implement toString() for WebRTCTransport
|
|
44
44
|
*/
|
|
45
|
-
|
|
45
|
+
readonly [Symbol.toStringTag] = "@libp2p/webrtc-direct";
|
|
46
46
|
/**
|
|
47
47
|
* Symbol.for('@libp2p/transport')
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
readonly [symbol] = true;
|
|
50
50
|
/**
|
|
51
51
|
* Connect to a peer using a multiaddr
|
|
52
52
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/transport.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../src/transport.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,qBAAqB,EAAE,KAAK,QAAQ,EAAE,MAAM,EAAE,KAAK,SAAS,EAAE,MAAM,6BAA6B,CAAA;AAc/G,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAA;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,2BAA2B,CAAA;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AASxD;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,MAAwC,CAAA;AAElE;;;;GAIG;AACH,eAAO,MAAM,aAAa,EAAE,MAAmC,CAAA;AAE/D;;GAEG;AAEH,MAAM,WAAW,+BAA+B;IAC9C,MAAM,EAAE,MAAM,CAAA;CACf;AAED,qBAAa,qBAAsB,YAAW,SAAS;IACrD;;OAEG;IACH,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAiC;gBAE/C,UAAU,EAAE,+BAA+B;IAIxD;;OAEG;IACG,IAAI,CAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC;IAM3E;;OAEG;IACH,cAAc,CAAE,OAAO,EAAE,qBAAqB,GAAG,QAAQ;IAIzD;;OAEG;IACH,MAAM,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,MAAM,CAAC,QAAO;IAExB;;OAEG;IACG,QAAQ,CAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC;IAmI/E;;;OAGG;IACH,OAAO,CAAC,qBAAqB;CAkB9B"}
|
package/dist/src/transport.js
CHANGED
|
@@ -2,17 +2,17 @@ import { noise as Noise } from '@chainsafe/libp2p-noise';
|
|
|
2
2
|
import { symbol } from '@libp2p/interface-transport';
|
|
3
3
|
import { logger } from '@libp2p/logger';
|
|
4
4
|
import * as p from '@libp2p/peer-id';
|
|
5
|
+
import { protocols } from '@multiformats/multiaddr';
|
|
5
6
|
import * as multihashes from 'multihashes';
|
|
6
|
-
import { fromString as uint8arrayFromString } from 'uint8arrays/from-string';
|
|
7
7
|
import { concat } from 'uint8arrays/concat';
|
|
8
|
+
import { fromString as uint8arrayFromString } from 'uint8arrays/from-string';
|
|
8
9
|
import { dataChannelError, inappropriateMultiaddr, unimplemented, invalidArgument } from './error.js';
|
|
9
10
|
import { WebRTCMultiaddrConnection } from './maconn.js';
|
|
10
11
|
import { DataChannelMuxerFactory } from './muxer.js';
|
|
12
|
+
import { isFirefox } from './peer_transport/util.js';
|
|
11
13
|
import * as sdp from './sdp.js';
|
|
12
14
|
import { WebRTCStream } from './stream.js';
|
|
13
15
|
import { genUfrag } from './util.js';
|
|
14
|
-
import { protocols } from '@multiformats/multiaddr';
|
|
15
|
-
import { isFirefox } from './peer_transport/util.js';
|
|
16
16
|
const log = logger('libp2p:webrtc:transport');
|
|
17
17
|
/**
|
|
18
18
|
* The time to wait, in milliseconds, for the data channel handshake to complete
|
|
@@ -31,6 +31,10 @@ export const WEBRTC_CODE = protocols('webrtc-direct').code;
|
|
|
31
31
|
*/
|
|
32
32
|
export const CERTHASH_CODE = protocols('certhash').code;
|
|
33
33
|
export class WebRTCDirectTransport {
|
|
34
|
+
/**
|
|
35
|
+
* The peer for this transport
|
|
36
|
+
*/
|
|
37
|
+
components;
|
|
34
38
|
constructor(components) {
|
|
35
39
|
this.components = components;
|
|
36
40
|
}
|
|
@@ -57,15 +61,11 @@ export class WebRTCDirectTransport {
|
|
|
57
61
|
/**
|
|
58
62
|
* Implement toString() for WebRTCTransport
|
|
59
63
|
*/
|
|
60
|
-
|
|
61
|
-
return '@libp2p/webrtc-direct';
|
|
62
|
-
}
|
|
64
|
+
[Symbol.toStringTag] = '@libp2p/webrtc-direct';
|
|
63
65
|
/**
|
|
64
66
|
* Symbol.for('@libp2p/transport')
|
|
65
67
|
*/
|
|
66
|
-
|
|
67
|
-
return true;
|
|
68
|
-
}
|
|
68
|
+
[symbol] = true;
|
|
69
69
|
/**
|
|
70
70
|
* Connect to a peer using a multiaddr
|
|
71
71
|
*/
|
|
@@ -176,7 +176,7 @@ export class WebRTCDirectTransport {
|
|
|
176
176
|
// For outbound connections, the remote is expected to start the noise handshake.
|
|
177
177
|
// Therefore, we need to secure an inbound noise connection from the remote.
|
|
178
178
|
await noise.secureInbound(myPeerId, wrappedDuplex, theirPeerId);
|
|
179
|
-
return
|
|
179
|
+
return options.upgrader.upgradeOutbound(maConn, { skipProtection: true, skipEncryption: true, muxerFactory });
|
|
180
180
|
}
|
|
181
181
|
/**
|
|
182
182
|
* Generate a noise prologue from the peer connection's certificate.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,KAAK,EAAE,MAAM,yBAAyB,CAAA;
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,IAAI,KAAK,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,EAA6C,MAAM,EAAkB,MAAM,6BAA6B,CAAA;AAC/G,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AACvC,OAAO,KAAK,CAAC,MAAM,iBAAiB,CAAA;AACpC,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACnD,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,YAAY,CAAA;AACrG,OAAO,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AACvD,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,KAAK,GAAG,MAAM,UAAU,CAAA;AAC/B,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAMp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G,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;AAED;;;GAGG;AACH,SAAS,OAAO,CAAE,EAAa;IAC7B,MAAM,KAAK,GAAG,EAAE,CAAC,UAAU,EAAE,CAAA;IAC7B,OAAO,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,aAAa,CAAC,IAAI,EAAE,CAAC,SAAS,EAAE,IAAI,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,CAAA;AACjJ,CAAC"}
|
package/dist/src/util.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export declare const nopSource:
|
|
2
|
-
[Symbol.asyncIterator](): AsyncGenerator<never, void, unknown>;
|
|
3
|
-
};
|
|
1
|
+
export declare const nopSource: () => AsyncGenerator<Uint8Array, any, unknown>;
|
|
4
2
|
export declare const nopSink: (_: any) => Promise<void>;
|
|
5
3
|
export declare const genUfrag: (len: number) => string;
|
|
6
4
|
//# sourceMappingURL=util.d.ts.map
|
package/dist/src/util.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS
|
|
1
|
+
{"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS,QAA4B,eAAe,UAAU,EAAE,GAAG,EAAE,OAAO,CAAI,CAAA;AAE7F,eAAO,MAAM,OAAO,MAAa,GAAG,KAAG,QAAQ,IAAI,CAAO,CAAA;AAG1D,eAAO,MAAM,QAAQ,QAAS,MAAM,KAAG,MAAoG,CAAA"}
|
package/dist/src/util.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export const nopSource = {
|
|
2
|
-
async *[Symbol.asyncIterator]() { }
|
|
3
|
-
};
|
|
1
|
+
export const nopSource = async function* nop() { };
|
|
4
2
|
export const nopSink = async (_) => { };
|
|
5
3
|
const charset = Array.from('ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/');
|
|
6
4
|
export const genUfrag = (len) => [...Array(len)].map(() => charset.at(Math.floor(Math.random() * charset.length))).join('');
|
package/dist/src/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/util.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,KAAK,SAAU,CAAC,CAAC,GAAG,KAA+C,CAAC,CAAA;AAE7F,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAAE,CAAM,EAAiB,EAAE,GAAE,CAAC,CAAA;AAE1D,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,kEAAkE,CAAC,CAAA;AAC9F,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAU,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@libp2p/webrtc",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"description": "A libp2p transport using WebRTC connections",
|
|
5
5
|
"author": "",
|
|
6
6
|
"license": "Apache-2.0 OR MIT",
|
|
@@ -137,44 +137,42 @@
|
|
|
137
137
|
"release": "aegir release"
|
|
138
138
|
},
|
|
139
139
|
"dependencies": {
|
|
140
|
-
"@chainsafe/libp2p-noise": "^11.0.
|
|
141
|
-
"@libp2p/interface-connection": "^
|
|
142
|
-
"@libp2p/interface-peer-id": "^2.0.
|
|
143
|
-
"@libp2p/interface-peer-store": "^2.0.
|
|
144
|
-
"@libp2p/interface-registrar": "^2.0.
|
|
145
|
-
"@libp2p/interface-stream-muxer": "^
|
|
146
|
-
"@libp2p/interface-transport": "^
|
|
147
|
-
"@libp2p/interfaces": "^3.2
|
|
148
|
-
"@libp2p/logger": "^2.0.
|
|
149
|
-
"@libp2p/peer-id": "^2.0.
|
|
150
|
-
"@multiformats/multiaddr": "^12.1.
|
|
151
|
-
"@protobuf-ts/runtime": "^2.
|
|
140
|
+
"@chainsafe/libp2p-noise": "^11.0.4",
|
|
141
|
+
"@libp2p/interface-connection": "^5.0.2",
|
|
142
|
+
"@libp2p/interface-peer-id": "^2.0.2",
|
|
143
|
+
"@libp2p/interface-peer-store": "^2.0.2",
|
|
144
|
+
"@libp2p/interface-registrar": "^2.0.12",
|
|
145
|
+
"@libp2p/interface-stream-muxer": "^4.0.1",
|
|
146
|
+
"@libp2p/interface-transport": "^4.0.2",
|
|
147
|
+
"@libp2p/interfaces": "^3.3.2",
|
|
148
|
+
"@libp2p/logger": "^2.0.7",
|
|
149
|
+
"@libp2p/peer-id": "^2.0.3",
|
|
150
|
+
"@multiformats/multiaddr": "^12.1.2",
|
|
151
|
+
"@protobuf-ts/runtime": "^2.9.0",
|
|
152
152
|
"abortable-iterator": "^4.0.2",
|
|
153
|
-
"
|
|
153
|
+
"detect-browser": "^5.3.0",
|
|
154
154
|
"it-length-prefixed": "^8.0.3",
|
|
155
|
-
"it-merge": "^
|
|
156
|
-
"it-pb-stream": "^
|
|
155
|
+
"it-merge": "^3.0.0",
|
|
156
|
+
"it-pb-stream": "^4.0.1",
|
|
157
157
|
"it-pipe": "^3.0.1",
|
|
158
|
-
"it-pushable": "^3.1.
|
|
159
|
-
"it-stream-types": "^
|
|
158
|
+
"it-pushable": "^3.1.3",
|
|
159
|
+
"it-stream-types": "^2.0.1",
|
|
160
160
|
"multiformats": "^11.0.2",
|
|
161
161
|
"multihashes": "^4.0.3",
|
|
162
162
|
"p-defer": "^4.0.0",
|
|
163
163
|
"protons-runtime": "^5.0.0",
|
|
164
|
-
"
|
|
165
|
-
"
|
|
166
|
-
"uint8arrays": "^4.0.2",
|
|
167
|
-
"detect-browser": "^5.3.0"
|
|
164
|
+
"uint8arraylist": "^2.4.3",
|
|
165
|
+
"uint8arrays": "^4.0.3"
|
|
168
166
|
},
|
|
169
167
|
"devDependencies": {
|
|
170
|
-
"@libp2p/interface-mocks": "^
|
|
171
|
-
"@libp2p/peer-id-factory": "^2.0.
|
|
172
|
-
"@protobuf-ts/
|
|
173
|
-
"@
|
|
174
|
-
"aegir": "^
|
|
168
|
+
"@libp2p/interface-mocks": "^11.0.2",
|
|
169
|
+
"@libp2p/peer-id-factory": "^2.0.3",
|
|
170
|
+
"@protobuf-ts/protoc": "^2.9.0",
|
|
171
|
+
"@types/sinon": "^10.0.14",
|
|
172
|
+
"aegir": "^39.0.5",
|
|
175
173
|
"eslint-plugin-etc": "^2.0.2",
|
|
176
|
-
"it-pair": "^2.0.
|
|
174
|
+
"it-pair": "^2.0.6",
|
|
177
175
|
"protons": "^7.0.2",
|
|
178
|
-
"sinon": "^15.0.
|
|
176
|
+
"sinon": "^15.0.4"
|
|
179
177
|
}
|
|
180
178
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { Transport } from '@libp2p/interface-transport'
|
|
2
|
-
import type { WebRTCTransportComponents, WebRTCTransportInit } from './peer_transport/transport.js'
|
|
3
1
|
import { WebRTCTransport } from './peer_transport/transport.js'
|
|
4
|
-
import { WebRTCDirectTransport, WebRTCDirectTransportComponents } from './transport.js'
|
|
2
|
+
import { WebRTCDirectTransport, type WebRTCDirectTransportComponents } from './transport.js'
|
|
3
|
+
import type { WebRTCTransportComponents, WebRTCTransportInit } from './peer_transport/transport.js'
|
|
4
|
+
import type { Transport } from '@libp2p/interface-transport'
|
|
5
5
|
|
|
6
6
|
function webRTCDirect (): (components: WebRTCDirectTransportComponents) => Transport {
|
|
7
7
|
return (components: WebRTCDirectTransportComponents) => new WebRTCDirectTransport(components)
|
package/src/maconn.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type { MultiaddrConnection, MultiaddrConnectionTimeline } from '@libp2p/interface-connection'
|
|
2
1
|
import { logger } from '@libp2p/logger'
|
|
2
|
+
import { nopSink, nopSource } from './util.js'
|
|
3
|
+
import type { MultiaddrConnection, MultiaddrConnectionTimeline } from '@libp2p/interface-connection'
|
|
3
4
|
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
4
5
|
import type { Source, Sink } from 'it-stream-types'
|
|
5
6
|
|
|
6
|
-
import { nopSink, nopSource } from './util.js'
|
|
7
|
-
|
|
8
7
|
const log = logger('libp2p:webrtc:connection')
|
|
9
8
|
|
|
10
9
|
interface WebRTCMultiaddrConnectionInit {
|
|
@@ -43,12 +42,12 @@ export class WebRTCMultiaddrConnection implements MultiaddrConnection {
|
|
|
43
42
|
/**
|
|
44
43
|
* The stream source, a no-op as the transport natively supports multiplexing
|
|
45
44
|
*/
|
|
46
|
-
source:
|
|
45
|
+
source: AsyncGenerator<Uint8Array, any, unknown> = nopSource()
|
|
47
46
|
|
|
48
47
|
/**
|
|
49
48
|
* The stream destination, a no-op as the transport natively supports multiplexing
|
|
50
49
|
*/
|
|
51
|
-
sink: Sink<Uint8Array
|
|
50
|
+
sink: Sink<Source<Uint8Array>, Promise<void>> = nopSink
|
|
52
51
|
|
|
53
52
|
constructor (init: WebRTCMultiaddrConnectionInit) {
|
|
54
53
|
this.remoteAddr = init.remoteAddr
|
package/src/muxer.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { WebRTCStream } from './stream.js'
|
|
2
|
+
import { nopSink, nopSource } from './util.js'
|
|
1
3
|
import type { Stream } from '@libp2p/interface-connection'
|
|
2
4
|
import type { StreamMuxer, StreamMuxerFactory, StreamMuxerInit } from '@libp2p/interface-stream-muxer'
|
|
3
5
|
import type { Source, Sink } from 'it-stream-types'
|
|
4
|
-
|
|
5
|
-
import { WebRTCStream } from './stream.js'
|
|
6
|
-
import { nopSink, nopSource } from './util.js'
|
|
6
|
+
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
7
7
|
|
|
8
8
|
export class DataChannelMuxerFactory implements StreamMuxerFactory {
|
|
9
9
|
/**
|
|
@@ -62,12 +62,12 @@ export class DataChannelMuxer implements StreamMuxer {
|
|
|
62
62
|
/**
|
|
63
63
|
* The stream source, a no-op as the transport natively supports multiplexing
|
|
64
64
|
*/
|
|
65
|
-
source:
|
|
65
|
+
source: AsyncGenerator<Uint8Array, any, unknown> = nopSource()
|
|
66
66
|
|
|
67
67
|
/**
|
|
68
68
|
* The stream destination, a no-op as the transport natively supports multiplexing
|
|
69
69
|
*/
|
|
70
|
-
sink: Sink<Uint8Array
|
|
70
|
+
sink: Sink<Source<Uint8Array | Uint8ArrayList>, Promise<void>> = nopSink
|
|
71
71
|
|
|
72
72
|
constructor (peerConnection: RTCPeerConnection, streams: Stream[], readonly protocol = '/webrtc', init?: StreamMuxerInit) {
|
|
73
73
|
/**
|
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { logger } from '@libp2p/logger'
|
|
2
|
+
import { abortableDuplex } from 'abortable-iterator'
|
|
2
3
|
import { pbStream } from 'it-pb-stream'
|
|
3
4
|
import pDefer, { type DeferredPromise } from 'p-defer'
|
|
4
|
-
import {
|
|
5
|
-
import { readCandidatesUntilConnected, resolveOnConnected } from './util.js'
|
|
5
|
+
import { DataChannelMuxerFactory } from '../muxer.js'
|
|
6
6
|
import * as pb from './pb/index.js'
|
|
7
|
-
import {
|
|
8
|
-
import { logger } from '@libp2p/logger'
|
|
7
|
+
import { readCandidatesUntilConnected, resolveOnConnected } from './util.js'
|
|
9
8
|
import type { Stream } from '@libp2p/interface-connection'
|
|
9
|
+
import type { IncomingStreamData } from '@libp2p/interface-registrar'
|
|
10
10
|
import type { StreamMuxerFactory } from '@libp2p/interface-stream-muxer'
|
|
11
|
-
import { DataChannelMuxerFactory } from '../muxer.js'
|
|
12
11
|
|
|
13
12
|
const DEFAULT_TIMEOUT = 30 * 1000
|
|
14
13
|
|
|
@@ -17,9 +16,8 @@ const log = logger('libp2p:webrtc:peer')
|
|
|
17
16
|
export type IncomingStreamOpts = { rtcConfiguration?: RTCConfiguration } & IncomingStreamData
|
|
18
17
|
|
|
19
18
|
export async function handleIncomingStream ({ rtcConfiguration, stream: rawStream }: IncomingStreamOpts): Promise<[RTCPeerConnection, StreamMuxerFactory]> {
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const stream = pbStream(abortableDuplex(rawStream, timeoutController.signal)).pb(pb.Message)
|
|
19
|
+
const signal = AbortSignal.timeout(DEFAULT_TIMEOUT)
|
|
20
|
+
const stream = pbStream(abortableDuplex(rawStream, signal)).pb(pb.Message)
|
|
23
21
|
const pc = new RTCPeerConnection(rtcConfiguration)
|
|
24
22
|
const muxerFactory = new DataChannelMuxerFactory(pc)
|
|
25
23
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
2
|
-
import type { ListenerEvents, TransportManager, Upgrader, Listener } from '@libp2p/interface-transport'
|
|
3
1
|
import { EventEmitter } from '@libp2p/interfaces/events'
|
|
4
|
-
import { multiaddr, Multiaddr } from '@multiformats/multiaddr'
|
|
2
|
+
import { multiaddr, type Multiaddr } from '@multiformats/multiaddr'
|
|
5
3
|
import { inappropriateMultiaddr } from '../error.js'
|
|
6
4
|
import { TRANSPORT } from './transport.js'
|
|
5
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
6
|
+
import type { ListenerEvents, TransportManager, Upgrader, Listener } from '@libp2p/interface-transport'
|
|
7
7
|
|
|
8
8
|
export interface ListenerOptions {
|
|
9
9
|
peerId: PeerId
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
/* eslint-disable @typescript-eslint/no-empty-interface */
|
|
6
6
|
|
|
7
7
|
import { enumeration, encodeMessage, decodeMessage, message } from 'protons-runtime'
|
|
8
|
-
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
9
8
|
import type { Codec } from 'protons-runtime'
|
|
9
|
+
import type { Uint8ArrayList } from 'uint8arraylist'
|
|
10
10
|
|
|
11
11
|
export interface Message {
|
|
12
12
|
type?: Message.Type
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import { multiaddr, Multiaddr, protocols } from '@multiformats/multiaddr'
|
|
5
|
-
import type { IncomingStreamData, Registrar } from '@libp2p/interface-registrar'
|
|
6
|
-
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
1
|
+
import { type CreateListenerOptions, type DialOptions, type Listener, symbol, type Transport, type TransportManager, type Upgrader } from '@libp2p/interface-transport'
|
|
2
|
+
import { CodeError } from '@libp2p/interfaces/errors'
|
|
3
|
+
import { logger } from '@libp2p/logger'
|
|
7
4
|
import { peerIdFromString } from '@libp2p/peer-id'
|
|
5
|
+
import { multiaddr, type Multiaddr, protocols } from '@multiformats/multiaddr'
|
|
6
|
+
import { codes } from '../error.js'
|
|
8
7
|
import { WebRTCMultiaddrConnection } from '../maconn.js'
|
|
9
|
-
import
|
|
8
|
+
import { initiateConnection, handleIncomingStream } from './handler.js'
|
|
10
9
|
import { WebRTCPeerListener } from './listener.js'
|
|
10
|
+
import type { Connection } from '@libp2p/interface-connection'
|
|
11
|
+
import type { PeerId } from '@libp2p/interface-peer-id'
|
|
11
12
|
import type { PeerStore } from '@libp2p/interface-peer-store'
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { CodeError } from '@libp2p/interfaces/errors'
|
|
15
|
-
import { codes } from '../error.js'
|
|
13
|
+
import type { IncomingStreamData, Registrar } from '@libp2p/interface-registrar'
|
|
14
|
+
import type { Startable } from '@libp2p/interfaces/startable'
|
|
16
15
|
|
|
17
16
|
const log = logger('libp2p:webrtc:peer')
|
|
18
17
|
|
|
@@ -46,7 +45,7 @@ export class WebRTCTransport implements Transport, Startable {
|
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
async start (): Promise<void> {
|
|
49
|
-
await this.components.registrar.handle(SIGNALING_PROTO_ID, (data) => {
|
|
48
|
+
await this.components.registrar.handle(SIGNALING_PROTO_ID, (data: IncomingStreamData) => {
|
|
50
49
|
this._onProtocol(data).catch(err => { log.error('failed to handle incoming connect from %p', data.connection.remotePeer, err) })
|
|
51
50
|
})
|
|
52
51
|
this._started = true
|
|
@@ -61,13 +60,9 @@ export class WebRTCTransport implements Transport, Startable {
|
|
|
61
60
|
return new WebRTCPeerListener(this.components)
|
|
62
61
|
}
|
|
63
62
|
|
|
64
|
-
|
|
65
|
-
return '@libp2p/webrtc'
|
|
66
|
-
}
|
|
63
|
+
readonly [Symbol.toStringTag] = '@libp2p/webrtc'
|
|
67
64
|
|
|
68
|
-
|
|
69
|
-
return true
|
|
70
|
-
}
|
|
65
|
+
readonly [symbol] = true
|
|
71
66
|
|
|
72
67
|
filter (multiaddrs: Multiaddr[]): Multiaddr[] {
|
|
73
68
|
return multiaddrs.filter((ma) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { logger } from '@libp2p/logger'
|
|
2
|
-
import type { DeferredPromise } from 'p-defer'
|
|
3
|
-
import * as pb from './pb/index.js'
|
|
4
2
|
import { detect } from 'detect-browser'
|
|
3
|
+
import * as pb from './pb/index.js'
|
|
4
|
+
import type { DeferredPromise } from 'p-defer'
|
|
5
5
|
|
|
6
6
|
const browser = detect()
|
|
7
7
|
export const isFirefox = ((browser != null) && browser.name === 'firefox')
|
package/src/sdp.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { logger } from '@libp2p/logger'
|
|
2
|
-
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
3
2
|
import { bases } from 'multiformats/basics'
|
|
4
3
|
import * as multihashes from 'multihashes'
|
|
5
|
-
import type { HashCode, HashName } from 'multihashes'
|
|
6
|
-
|
|
7
4
|
import { inappropriateMultiaddr, invalidArgument, invalidFingerprint, unsupportedHashAlgorithm } from './error.js'
|
|
8
5
|
import { CERTHASH_CODE } from './transport.js'
|
|
6
|
+
import type { Multiaddr } from '@multiformats/multiaddr'
|
|
7
|
+
import type { HashCode, HashName } from 'multihashes'
|
|
9
8
|
|
|
10
9
|
const log = logger('libp2p:webrtc:sdp')
|
|
11
10
|
|
package/src/stream.ts
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
|
-
import type { Stream, StreamStat, Direction } from '@libp2p/interface-connection'
|
|
2
1
|
import { logger } from '@libp2p/logger'
|
|
3
2
|
import * as lengthPrefixed from 'it-length-prefixed'
|
|
4
3
|
import merge from 'it-merge'
|
|
5
4
|
import { pipe } from 'it-pipe'
|
|
6
5
|
import { pushable } from 'it-pushable'
|
|
7
|
-
import defer, { DeferredPromise } from 'p-defer'
|
|
8
|
-
import type { Source } from 'it-stream-types'
|
|
6
|
+
import defer, { type DeferredPromise } from 'p-defer'
|
|
9
7
|
import { Uint8ArrayList } from 'uint8arraylist'
|
|
10
|
-
|
|
11
8
|
import * as pb from '../proto_ts/message.js'
|
|
9
|
+
import type { Stream, StreamStat, Direction } from '@libp2p/interface-connection'
|
|
10
|
+
import type { Source } from 'it-stream-types'
|
|
12
11
|
|
|
13
12
|
const log = logger('libp2p:webrtc:stream')
|
|
14
13
|
|
|
@@ -182,7 +181,7 @@ export class WebRTCStream implements Stream {
|
|
|
182
181
|
* Read unwrapped protobuf data from the underlying datachannel.
|
|
183
182
|
* _src is exposed to the user via the `source` getter to .
|
|
184
183
|
*/
|
|
185
|
-
private readonly _src:
|
|
184
|
+
private readonly _src: AsyncGenerator<Uint8ArrayList, any, unknown>
|
|
186
185
|
|
|
187
186
|
/**
|
|
188
187
|
* push data from the underlying datachannel to the length prefix decoder
|
|
@@ -282,9 +281,9 @@ export class WebRTCStream implements Stream {
|
|
|
282
281
|
}
|
|
283
282
|
|
|
284
283
|
// If user attempts to set a new source this should be a noop
|
|
285
|
-
set source (_src:
|
|
284
|
+
set source (_src: AsyncGenerator<Uint8ArrayList, any, unknown>) { }
|
|
286
285
|
|
|
287
|
-
get source ():
|
|
286
|
+
get source (): AsyncGenerator<Uint8ArrayList, any, unknown> {
|
|
288
287
|
return this._src
|
|
289
288
|
}
|
|
290
289
|
|