@libp2p/webrtc 4.1.9 → 4.1.10-df330695a
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 +5 -6
- package/dist/src/error.d.ts +5 -25
- package/dist/src/error.d.ts.map +1 -1
- package/dist/src/error.js +18 -54
- package/dist/src/error.js.map +1 -1
- package/dist/src/pb/message.d.ts +2 -2
- package/dist/src/pb/message.d.ts.map +1 -1
- package/dist/src/pb/message.js +10 -7
- package/dist/src/pb/message.js.map +1 -1
- package/dist/src/private-to-private/initiate-connection.d.ts.map +1 -1
- package/dist/src/private-to-private/initiate-connection.js +8 -7
- package/dist/src/private-to-private/initiate-connection.js.map +1 -1
- package/dist/src/private-to-private/pb/message.d.ts +2 -2
- package/dist/src/private-to-private/pb/message.d.ts.map +1 -1
- package/dist/src/private-to-private/pb/message.js +10 -7
- package/dist/src/private-to-private/pb/message.js.map +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 +5 -5
- package/dist/src/private-to-private/signaling-stream-handler.js.map +1 -1
- package/dist/src/private-to-private/transport.d.ts.map +1 -1
- package/dist/src/private-to-private/transport.js +6 -7
- package/dist/src/private-to-private/transport.js.map +1 -1
- package/dist/src/private-to-private/util.js +3 -3
- package/dist/src/private-to-private/util.js.map +1 -1
- package/dist/src/private-to-public/sdp.d.ts.map +1 -1
- package/dist/src/private-to-public/sdp.js +7 -6
- package/dist/src/private-to-public/sdp.js.map +1 -1
- package/dist/src/private-to-public/transport.d.ts +2 -1
- package/dist/src/private-to-public/transport.d.ts.map +1 -1
- package/dist/src/private-to-public/transport.js +12 -10
- package/dist/src/private-to-public/transport.js.map +1 -1
- package/dist/src/stream.js +6 -6
- package/dist/src/stream.js.map +1 -1
- package/package.json +12 -12
- package/src/error.ts +18 -64
- package/src/pb/message.ts +10 -8
- package/src/private-to-private/initiate-connection.ts +8 -7
- package/src/private-to-private/pb/message.ts +10 -8
- package/src/private-to-private/signaling-stream-handler.ts +5 -5
- package/src/private-to-private/transport.ts +6 -7
- package/src/private-to-private/util.ts +3 -3
- package/src/private-to-public/sdp.ts +7 -6
- package/src/private-to-public/transport.ts +14 -12
- package/src/stream.ts +6 -6
- package/dist/typedoc-urls.json +0 -8
package/dist/src/error.d.ts
CHANGED
@@ -1,54 +1,34 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
ERR_CONNECTION_CLOSED = "ERR_CONNECTION_CLOSED",
|
7
|
-
ERR_HASH_NOT_SUPPORTED = "ERR_HASH_NOT_SUPPORTED",
|
8
|
-
ERR_INVALID_MULTIADDR = "ERR_INVALID_MULTIADDR",
|
9
|
-
ERR_INVALID_FINGERPRINT = "ERR_INVALID_FINGERPRINT",
|
10
|
-
ERR_INVALID_PARAMETERS = "ERR_INVALID_PARAMETERS",
|
11
|
-
ERR_NOT_IMPLEMENTED = "ERR_NOT_IMPLEMENTED",
|
12
|
-
ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS = "ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS",
|
13
|
-
ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS = "ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS"
|
14
|
-
}
|
15
|
-
export declare class WebRTCTransportError extends CodeError {
|
16
|
-
constructor(msg: string, code?: string);
|
1
|
+
export declare class WebRTCTransportError extends Error {
|
2
|
+
constructor(msg: string);
|
3
|
+
}
|
4
|
+
export declare class SDPHandshakeFailedError extends WebRTCTransportError {
|
5
|
+
constructor(message?: string);
|
17
6
|
}
|
18
7
|
export declare class ConnectionClosedError extends WebRTCTransportError {
|
19
8
|
constructor(state: RTCPeerConnectionState, msg: string);
|
20
9
|
}
|
21
|
-
export declare function connectionClosedError(state: RTCPeerConnectionState, msg: string): ConnectionClosedError;
|
22
10
|
export declare class DataChannelError extends WebRTCTransportError {
|
23
11
|
constructor(streamLabel: string, msg: string);
|
24
12
|
}
|
25
|
-
export declare function dataChannelError(streamLabel: string, msg: string): DataChannelError;
|
26
13
|
export declare class InappropriateMultiaddrError extends WebRTCTransportError {
|
27
14
|
constructor(msg: string);
|
28
15
|
}
|
29
|
-
export declare function inappropriateMultiaddr(msg: string): InappropriateMultiaddrError;
|
30
16
|
export declare class InvalidArgumentError extends WebRTCTransportError {
|
31
17
|
constructor(msg: string);
|
32
18
|
}
|
33
|
-
export declare function invalidArgument(msg: string): InvalidArgumentError;
|
34
19
|
export declare class InvalidFingerprintError extends WebRTCTransportError {
|
35
20
|
constructor(fingerprint: string, source: string);
|
36
21
|
}
|
37
|
-
export declare function invalidFingerprint(fingerprint: string, source: string): InvalidFingerprintError;
|
38
22
|
export declare class OperationAbortedError extends WebRTCTransportError {
|
39
23
|
constructor(context: string, abortReason: string);
|
40
24
|
}
|
41
|
-
export declare function operationAborted(context: string, reason: string): OperationAbortedError;
|
42
25
|
export declare class OverStreamLimitError extends WebRTCTransportError {
|
43
26
|
constructor(msg: string);
|
44
27
|
}
|
45
|
-
export declare function overStreamLimit(dir: Direction, proto: string): OverStreamLimitError;
|
46
28
|
export declare class UnimplementedError extends WebRTCTransportError {
|
47
29
|
constructor(methodName: string);
|
48
30
|
}
|
49
|
-
export declare function unimplemented(methodName: string): UnimplementedError;
|
50
31
|
export declare class UnsupportedHashAlgorithmError extends WebRTCTransportError {
|
51
32
|
constructor(algo: number);
|
52
33
|
}
|
53
|
-
export declare function unsupportedHashAlgorithmCode(code: number): UnsupportedHashAlgorithmError;
|
54
34
|
//# sourceMappingURL=error.d.ts.map
|
package/dist/src/error.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":"AAAA,
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":"AAAA,qBAAa,oBAAqB,SAAQ,KAAK;gBAChC,GAAG,EAAE,MAAM;CAIzB;AAED,qBAAa,uBAAwB,SAAQ,oBAAoB;gBAClD,OAAO,SAAyB;CAI9C;AAED,qBAAa,qBAAsB,SAAQ,oBAAoB;gBAChD,KAAK,EAAE,sBAAsB,EAAE,GAAG,EAAE,MAAM;CAIxD;AAED,qBAAa,gBAAiB,SAAQ,oBAAoB;gBAC3C,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;CAI9C;AAED,qBAAa,2BAA4B,SAAQ,oBAAoB;gBACtD,GAAG,EAAE,MAAM;CAIzB;AAED,qBAAa,oBAAqB,SAAQ,oBAAoB;gBAC/C,GAAG,EAAE,MAAM;CAIzB;AAED,qBAAa,uBAAwB,SAAQ,oBAAoB;gBAClD,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;CAIjD;AAED,qBAAa,qBAAsB,SAAQ,oBAAoB;gBAChD,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM;CAIlD;AAED,qBAAa,oBAAqB,SAAQ,oBAAoB;gBAC/C,GAAG,EAAE,MAAM;CAIzB;AAED,qBAAa,kBAAmB,SAAQ,oBAAoB;gBAC7C,UAAU,EAAE,MAAM;CAIhC;AAED,qBAAa,6BAA8B,SAAQ,oBAAoB;gBACxD,IAAI,EAAE,MAAM;CAI1B"}
|
package/dist/src/error.js
CHANGED
@@ -1,103 +1,67 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
(
|
4
|
-
codes["ERR_ALREADY_ABORTED"] = "ERR_ALREADY_ABORTED";
|
5
|
-
codes["ERR_DATA_CHANNEL"] = "ERR_DATA_CHANNEL";
|
6
|
-
codes["ERR_CONNECTION_CLOSED"] = "ERR_CONNECTION_CLOSED";
|
7
|
-
codes["ERR_HASH_NOT_SUPPORTED"] = "ERR_HASH_NOT_SUPPORTED";
|
8
|
-
codes["ERR_INVALID_MULTIADDR"] = "ERR_INVALID_MULTIADDR";
|
9
|
-
codes["ERR_INVALID_FINGERPRINT"] = "ERR_INVALID_FINGERPRINT";
|
10
|
-
codes["ERR_INVALID_PARAMETERS"] = "ERR_INVALID_PARAMETERS";
|
11
|
-
codes["ERR_NOT_IMPLEMENTED"] = "ERR_NOT_IMPLEMENTED";
|
12
|
-
codes["ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS"] = "ERR_TOO_MANY_INBOUND_PROTOCOL_STREAMS";
|
13
|
-
codes["ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS"] = "ERR_TOO_MANY_OUTBOUND_PROTOCOL_STREAMS";
|
14
|
-
})(codes || (codes = {}));
|
15
|
-
export class WebRTCTransportError extends CodeError {
|
16
|
-
constructor(msg, code) {
|
17
|
-
super(`WebRTC transport error: ${msg}`, code ?? '');
|
1
|
+
export class WebRTCTransportError extends Error {
|
2
|
+
constructor(msg) {
|
3
|
+
super(`WebRTC transport error: ${msg}`);
|
18
4
|
this.name = 'WebRTCTransportError';
|
19
5
|
}
|
20
6
|
}
|
7
|
+
export class SDPHandshakeFailedError extends WebRTCTransportError {
|
8
|
+
constructor(message = 'SDP handshake failed') {
|
9
|
+
super(message);
|
10
|
+
this.name = 'SDPHandshakeFailedError';
|
11
|
+
}
|
12
|
+
}
|
21
13
|
export class ConnectionClosedError extends WebRTCTransportError {
|
22
14
|
constructor(state, msg) {
|
23
|
-
super(`peerconnection moved to state: ${state}: ${msg}
|
15
|
+
super(`peerconnection moved to state: ${state}: ${msg}`);
|
24
16
|
this.name = 'WebRTC/ConnectionClosed';
|
25
17
|
}
|
26
18
|
}
|
27
|
-
export function connectionClosedError(state, msg) {
|
28
|
-
return new ConnectionClosedError(state, msg);
|
29
|
-
}
|
30
19
|
export class DataChannelError extends WebRTCTransportError {
|
31
20
|
constructor(streamLabel, msg) {
|
32
|
-
super(`[stream: ${streamLabel}] data channel error: ${msg}
|
21
|
+
super(`[stream: ${streamLabel}] data channel error: ${msg}`);
|
33
22
|
this.name = 'WebRTC/DataChannelError';
|
34
23
|
}
|
35
24
|
}
|
36
|
-
export function dataChannelError(streamLabel, msg) {
|
37
|
-
return new DataChannelError(streamLabel, msg);
|
38
|
-
}
|
39
25
|
export class InappropriateMultiaddrError extends WebRTCTransportError {
|
40
26
|
constructor(msg) {
|
41
|
-
super(`There was a problem with the Multiaddr which was passed in: ${msg}
|
27
|
+
super(`There was a problem with the Multiaddr which was passed in: ${msg}`);
|
42
28
|
this.name = 'WebRTC/InappropriateMultiaddrError';
|
43
29
|
}
|
44
30
|
}
|
45
|
-
export function inappropriateMultiaddr(msg) {
|
46
|
-
return new InappropriateMultiaddrError(msg);
|
47
|
-
}
|
48
31
|
export class InvalidArgumentError extends WebRTCTransportError {
|
49
32
|
constructor(msg) {
|
50
|
-
super(`There was a problem with a provided argument: ${msg}
|
33
|
+
super(`There was a problem with a provided argument: ${msg}`);
|
51
34
|
this.name = 'WebRTC/InvalidArgumentError';
|
52
35
|
}
|
53
36
|
}
|
54
|
-
export function invalidArgument(msg) {
|
55
|
-
return new InvalidArgumentError(msg);
|
56
|
-
}
|
57
37
|
export class InvalidFingerprintError extends WebRTCTransportError {
|
58
38
|
constructor(fingerprint, source) {
|
59
|
-
super(`Invalid fingerprint "${fingerprint}" within ${source}
|
39
|
+
super(`Invalid fingerprint "${fingerprint}" within ${source}`);
|
60
40
|
this.name = 'WebRTC/InvalidFingerprintError';
|
61
41
|
}
|
62
42
|
}
|
63
|
-
export function invalidFingerprint(fingerprint, source) {
|
64
|
-
return new InvalidFingerprintError(fingerprint, source);
|
65
|
-
}
|
66
43
|
export class OperationAbortedError extends WebRTCTransportError {
|
67
44
|
constructor(context, abortReason) {
|
68
|
-
super(`Signalled to abort because (${abortReason}}) ${context}
|
45
|
+
super(`Signalled to abort because (${abortReason}}) ${context}`);
|
69
46
|
this.name = 'WebRTC/OperationAbortedError';
|
70
47
|
}
|
71
48
|
}
|
72
|
-
export function operationAborted(context, reason) {
|
73
|
-
return new OperationAbortedError(context, reason);
|
74
|
-
}
|
75
49
|
export class OverStreamLimitError extends WebRTCTransportError {
|
76
50
|
constructor(msg) {
|
77
|
-
|
78
|
-
super(msg, code);
|
51
|
+
super(msg);
|
79
52
|
this.name = 'WebRTC/OverStreamLimitError';
|
80
53
|
}
|
81
54
|
}
|
82
|
-
export function overStreamLimit(dir, proto) {
|
83
|
-
return new OverStreamLimitError(`${dir} stream limit reached for protocol - ${proto}`);
|
84
|
-
}
|
85
55
|
export class UnimplementedError extends WebRTCTransportError {
|
86
56
|
constructor(methodName) {
|
87
|
-
super(`A method (${methodName}) was called though it has been intentionally left unimplemented
|
57
|
+
super(`A method (${methodName}) was called though it has been intentionally left unimplemented.`);
|
88
58
|
this.name = 'WebRTC/UnimplementedError';
|
89
59
|
}
|
90
60
|
}
|
91
|
-
export function unimplemented(methodName) {
|
92
|
-
return new UnimplementedError(methodName);
|
93
|
-
}
|
94
61
|
export class UnsupportedHashAlgorithmError extends WebRTCTransportError {
|
95
62
|
constructor(algo) {
|
96
|
-
super(`unsupported hash algorithm code: ${algo} please see the codes at https://github.com/multiformats/multicodec/blob/master/table.csv
|
63
|
+
super(`unsupported hash algorithm code: ${algo} please see the codes at https://github.com/multiformats/multicodec/blob/master/table.csv `);
|
97
64
|
this.name = 'WebRTC/UnsupportedHashAlgorithmError';
|
98
65
|
}
|
99
66
|
}
|
100
|
-
export function unsupportedHashAlgorithmCode(code) {
|
101
|
-
return new UnsupportedHashAlgorithmError(code);
|
102
|
-
}
|
103
67
|
//# sourceMappingURL=error.js.map
|
package/dist/src/error.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":"AAAA,
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/error.ts"],"names":[],"mappings":"AAAA,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAC7C,YAAa,GAAW;QACtB,KAAK,CAAC,2BAA2B,GAAG,EAAE,CAAC,CAAA;QACvC,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAA;I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WAAW,MAAM,OAAO,EAAE,CAAC,CAAA;QAChE,IAAI,CAAC,IAAI,GAAG,8BAA8B,CAAA;IAC5C,CAAC;CACF;AAED,MAAM,OAAO,oBAAqB,SAAQ,oBAAoB;IAC5D,YAAa,GAAW;QACtB,KAAK,CAAC,GAAG,CAAC,CAAA;QACV,IAAI,CAAC,IAAI,GAAG,6BAA6B,CAAA;IAC3C,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,oBAAoB;IAC1D,YAAa,UAAkB;QAC7B,KAAK,CAAC,aAAa,UAAU,mEAAmE,CAAC,CAAA;QACjG,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAA;IACzC,CAAC;CACF;AAED,MAAM,OAAO,6BAA8B,SAAQ,oBAAoB;IACrE,YAAa,IAAY;QACvB,KAAK,CAAC,oCAAoC,IAAI,4FAA4F,CAAC,CAAA;QAC3I,IAAI,CAAC,IAAI,GAAG,sCAAsC,CAAA;IACpD,CAAC;CACF"}
|
package/dist/src/pb/message.d.ts
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import type
|
1
|
+
import { type Codec, type DecodeOptions } from 'protons-runtime';
|
2
2
|
import type { Uint8ArrayList } from 'uint8arraylist';
|
3
3
|
export interface Message {
|
4
4
|
flag?: Message.Flag;
|
@@ -16,6 +16,6 @@ export declare namespace Message {
|
|
16
16
|
}
|
17
17
|
const codec: () => Codec<Message>;
|
18
18
|
const encode: (obj: Partial<Message>) => Uint8Array;
|
19
|
-
const decode: (buf: Uint8Array | Uint8ArrayList) => Message;
|
19
|
+
const decode: (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Message>) => Message;
|
20
20
|
}
|
21
21
|
//# sourceMappingURL=message.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/pb/message.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/pb/message.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,KAAK,EAAiB,KAAK,aAAa,EAAuC,MAAM,iBAAiB,CAAA;AACpH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAA;IACnB,OAAO,CAAC,EAAE,UAAU,CAAA;CACrB;AAED,yBAAiB,OAAO,CAAC;IACvB,KAAY,IAAI;QACd,GAAG,QAAQ;QACX,YAAY,iBAAiB;QAC7B,KAAK,UAAU;QACf,OAAO,YAAY;KACpB;IASD,UAAiB,IAAI,CAAC;QACb,MAAM,KAAK,QAAO,MAAM,IAAI,CAElC,CAAA;KACF;IAIM,MAAM,KAAK,QAAO,MAAM,OAAO,CAiDrC,CAAA;IAEM,MAAM,MAAM,QAAS,QAAQ,OAAO,CAAC,KAAG,UAE9C,CAAA;IAEM,MAAM,MAAM,QAAS,UAAU,GAAG,cAAc,SAAS,cAAc,OAAO,CAAC,KAAG,OAExF,CAAA;CACF"}
|
package/dist/src/pb/message.js
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-namespace */
|
4
4
|
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
|
5
5
|
/* eslint-disable @typescript-eslint/no-empty-interface */
|
6
|
-
import {
|
6
|
+
import { decodeMessage, encodeMessage, enumeration, message } from 'protons-runtime';
|
7
7
|
export var Message;
|
8
8
|
(function (Message) {
|
9
9
|
let Flag;
|
@@ -43,21 +43,24 @@ export var Message;
|
|
43
43
|
if (opts.lengthDelimited !== false) {
|
44
44
|
w.ldelim();
|
45
45
|
}
|
46
|
-
}, (reader, length) => {
|
46
|
+
}, (reader, length, opts = {}) => {
|
47
47
|
const obj = {};
|
48
48
|
const end = length == null ? reader.len : reader.pos + length;
|
49
49
|
while (reader.pos < end) {
|
50
50
|
const tag = reader.uint32();
|
51
51
|
switch (tag >>> 3) {
|
52
|
-
case 1:
|
52
|
+
case 1: {
|
53
53
|
obj.flag = Message.Flag.codec().decode(reader);
|
54
54
|
break;
|
55
|
-
|
55
|
+
}
|
56
|
+
case 2: {
|
56
57
|
obj.message = reader.bytes();
|
57
58
|
break;
|
58
|
-
|
59
|
+
}
|
60
|
+
default: {
|
59
61
|
reader.skipType(tag & 7);
|
60
62
|
break;
|
63
|
+
}
|
61
64
|
}
|
62
65
|
}
|
63
66
|
return obj;
|
@@ -68,8 +71,8 @@ export var Message;
|
|
68
71
|
Message.encode = (obj) => {
|
69
72
|
return encodeMessage(obj, Message.codec());
|
70
73
|
};
|
71
|
-
Message.decode = (buf) => {
|
72
|
-
return decodeMessage(buf, Message.codec());
|
74
|
+
Message.decode = (buf, opts) => {
|
75
|
+
return decodeMessage(buf, Message.codec(), opts);
|
73
76
|
};
|
74
77
|
})(Message || (Message = {}));
|
75
78
|
//# sourceMappingURL=message.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/pb/message.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,+BAA+B;AAC/B,oDAAoD;AACpD,8EAA8E;AAC9E,0DAA0D;AAE1D,OAAO,
|
1
|
+
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/pb/message.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,+BAA+B;AAC/B,oDAAoD;AACpD,8EAA8E;AAC9E,0DAA0D;AAE1D,OAAO,EAAc,aAAa,EAAsB,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AAQpH,MAAM,KAAW,OAAO,CAiFvB;AAjFD,WAAiB,OAAO;IACtB,IAAY,IAKX;IALD,WAAY,IAAI;QACd,mBAAW,CAAA;QACX,qCAA6B,CAAA;QAC7B,uBAAe,CAAA;QACf,2BAAmB,CAAA;IACrB,CAAC,EALW,IAAI,GAAJ,YAAI,KAAJ,YAAI,QAKf;IAED,IAAK,YAKJ;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ate-connection.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"initiate-connection.d.ts","sourceRoot":"","sources":["../../../src/private-to-private/initiate-connection.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAAE,iBAAiB,EAAyB,MAAM,oBAAoB,CAAA;AAE7E,OAAO,EAAiC,KAAK,gBAAgB,EAAE,KAAK,sBAAsB,EAAE,MAAM,gBAAgB,CAAA;AAElH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,KAAK,EAAE,aAAa,EAAc,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAA;AACzG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAA;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAEtD,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,kBAAkB,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAChD,MAAM,EAAE,WAAW,CAAA;CACpB;AAED,MAAM,WAAW,cAAe,SAAQ,aAAa,EAAE,eAAe,CAAC,gBAAgB,CAAC;IACtF,gBAAgB,CAAC,EAAE,gBAAgB,CAAA;IACnC,WAAW,CAAC,EAAE,kBAAkB,CAAA;IAChC,SAAS,EAAE,SAAS,CAAA;IACpB,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,kBAAkB,CAAC,EAAE,OAAO,CAAC,kBAAkB,CAAC,CAAA;IAChD,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,OAAO,CAAC,EAAE,sBAAsB,CAAA;IAChC,MAAM,EAAE,eAAe,CAAA;CACxB;AAED,wBAAsB,kBAAkB,CAAE,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,cAAc,GAAG,OAAO,CAAC;IAAE,aAAa,EAAE,SAAS,CAAC;IAAC,cAAc,EAAE,iBAAiB,CAAC;IAAC,YAAY,EAAE,uBAAuB,CAAA;CAAE,CAAC,CA8K1S"}
|
@@ -1,7 +1,8 @@
|
|
1
|
-
import {
|
1
|
+
import { InvalidParametersError } from '@libp2p/interface';
|
2
2
|
import { peerIdFromString } from '@libp2p/peer-id';
|
3
3
|
import { pbStream } from 'it-protobuf-stream';
|
4
4
|
import { CustomProgressEvent } from 'progress-events';
|
5
|
+
import { SDPHandshakeFailedError } from '../error.js';
|
5
6
|
import { DataChannelMuxerFactory } from '../muxer.js';
|
6
7
|
import { RTCPeerConnection, RTCSessionDescription } from '../webrtc/index.js';
|
7
8
|
import { Message } from './pb/message.js';
|
@@ -13,7 +14,7 @@ export async function initiateConnection({ rtcConfiguration, dataChannel, signal
|
|
13
14
|
log.trace('dialing base address: %a', baseAddr);
|
14
15
|
const relayPeer = baseAddr.getPeerId();
|
15
16
|
if (relayPeer == null) {
|
16
|
-
throw new
|
17
|
+
throw new InvalidParametersError('Relay peer was missing');
|
17
18
|
}
|
18
19
|
const connections = connectionManager.getConnections(peerIdFromString(relayPeer));
|
19
20
|
let connection;
|
@@ -39,7 +40,7 @@ export async function initiateConnection({ rtcConfiguration, dataChannel, signal
|
|
39
40
|
onProgress?.(new CustomProgressEvent('webrtc:open-signaling-stream'));
|
40
41
|
const stream = await connection.newStream(SIGNALING_PROTO_ID, {
|
41
42
|
signal,
|
42
|
-
|
43
|
+
runOnLimitedConnection: true
|
43
44
|
});
|
44
45
|
const messageStream = pbStream(stream).pb(Message);
|
45
46
|
const peerConnection = new RTCPeerConnection(rtcConfiguration);
|
@@ -78,7 +79,7 @@ export async function initiateConnection({ rtcConfiguration, dataChannel, signal
|
|
78
79
|
// create an offer
|
79
80
|
const offerSdp = await peerConnection.createOffer().catch(err => {
|
80
81
|
log.error('could not execute createOffer', err);
|
81
|
-
throw new
|
82
|
+
throw new SDPHandshakeFailedError('Failed to set createOffer');
|
82
83
|
});
|
83
84
|
log.trace('initiator send SDP offer %s', offerSdp.sdp);
|
84
85
|
onProgress?.(new CustomProgressEvent('webrtc:send-sdp-offer'));
|
@@ -89,7 +90,7 @@ export async function initiateConnection({ rtcConfiguration, dataChannel, signal
|
|
89
90
|
// set offer as local description
|
90
91
|
await peerConnection.setLocalDescription(offerSdp).catch(err => {
|
91
92
|
log.error('could not execute setLocalDescription', err);
|
92
|
-
throw new
|
93
|
+
throw new SDPHandshakeFailedError('Failed to set localDescription');
|
93
94
|
});
|
94
95
|
onProgress?.(new CustomProgressEvent('webrtc:read-sdp-answer'));
|
95
96
|
// read answer
|
@@ -97,13 +98,13 @@ export async function initiateConnection({ rtcConfiguration, dataChannel, signal
|
|
97
98
|
signal
|
98
99
|
});
|
99
100
|
if (answerMessage.type !== Message.Type.SDP_ANSWER) {
|
100
|
-
throw new
|
101
|
+
throw new SDPHandshakeFailedError('Remote should send an SDP answer');
|
101
102
|
}
|
102
103
|
log.trace('initiator receive SDP answer %s', answerMessage.data);
|
103
104
|
const answerSdp = new RTCSessionDescription({ type: 'answer', sdp: answerMessage.data });
|
104
105
|
await peerConnection.setRemoteDescription(answerSdp).catch(err => {
|
105
106
|
log.error('could not execute setRemoteDescription', err);
|
106
|
-
throw new
|
107
|
+
throw new SDPHandshakeFailedError('Failed to set remoteDescription');
|
107
108
|
});
|
108
109
|
log.trace('initiator read candidates until connected');
|
109
110
|
onProgress?.(new CustomProgressEvent('webrtc:read-ice-candidates'));
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"initiate-connection.js","sourceRoot":"","sources":["../../../src/private-to-private/initiate-connection.ts"],"names":[],"mappings":"AAAA,O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from 'protons-runtime';
|
2
2
|
import type { Uint8ArrayList } from 'uint8arraylist';
|
3
3
|
export interface Message {
|
4
4
|
type?: Message.Type;
|
@@ -15,6 +15,6 @@ export declare namespace Message {
|
|
15
15
|
}
|
16
16
|
const codec: () => Codec<Message>;
|
17
17
|
const encode: (obj: Partial<Message>) => Uint8Array;
|
18
|
-
const decode: (buf: Uint8Array | Uint8ArrayList) => Message;
|
18
|
+
const decode: (buf: Uint8Array | Uint8ArrayList, opts?: DecodeOptions<Message>) => Message;
|
19
19
|
}
|
20
20
|
//# sourceMappingURL=message.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../../src/private-to-private/pb/message.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../../src/private-to-private/pb/message.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,KAAK,EAAiB,KAAK,aAAa,EAAuC,MAAM,iBAAiB,CAAA;AACpH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAA;AAEpD,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,yBAAiB,OAAO,CAAC;IACvB,KAAY,IAAI;QACd,SAAS,cAAc;QACvB,UAAU,eAAe;QACzB,aAAa,kBAAkB;KAChC;IAQD,UAAiB,IAAI,CAAC;QACb,MAAM,KAAK,QAAO,MAAM,IAAI,CAElC,CAAA;KACF;IAIM,MAAM,KAAK,QAAO,MAAM,OAAO,CAiDrC,CAAA;IAEM,MAAM,MAAM,QAAS,QAAQ,OAAO,CAAC,KAAG,UAE9C,CAAA;IAEM,MAAM,MAAM,QAAS,UAAU,GAAG,cAAc,SAAS,cAAc,OAAO,CAAC,KAAG,OAExF,CAAA;CACF"}
|
@@ -3,7 +3,7 @@
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-namespace */
|
4
4
|
/* eslint-disable @typescript-eslint/no-unnecessary-boolean-literal-compare */
|
5
5
|
/* eslint-disable @typescript-eslint/no-empty-interface */
|
6
|
-
import {
|
6
|
+
import { decodeMessage, encodeMessage, enumeration, message } from 'protons-runtime';
|
7
7
|
export var Message;
|
8
8
|
(function (Message) {
|
9
9
|
let Type;
|
@@ -41,21 +41,24 @@ export var Message;
|
|
41
41
|
if (opts.lengthDelimited !== false) {
|
42
42
|
w.ldelim();
|
43
43
|
}
|
44
|
-
}, (reader, length) => {
|
44
|
+
}, (reader, length, opts = {}) => {
|
45
45
|
const obj = {};
|
46
46
|
const end = length == null ? reader.len : reader.pos + length;
|
47
47
|
while (reader.pos < end) {
|
48
48
|
const tag = reader.uint32();
|
49
49
|
switch (tag >>> 3) {
|
50
|
-
case 1:
|
50
|
+
case 1: {
|
51
51
|
obj.type = Message.Type.codec().decode(reader);
|
52
52
|
break;
|
53
|
-
|
53
|
+
}
|
54
|
+
case 2: {
|
54
55
|
obj.data = reader.string();
|
55
56
|
break;
|
56
|
-
|
57
|
+
}
|
58
|
+
default: {
|
57
59
|
reader.skipType(tag & 7);
|
58
60
|
break;
|
61
|
+
}
|
59
62
|
}
|
60
63
|
}
|
61
64
|
return obj;
|
@@ -66,8 +69,8 @@ export var Message;
|
|
66
69
|
Message.encode = (obj) => {
|
67
70
|
return encodeMessage(obj, Message.codec());
|
68
71
|
};
|
69
|
-
Message.decode = (buf) => {
|
70
|
-
return decodeMessage(buf, Message.codec());
|
72
|
+
Message.decode = (buf, opts) => {
|
73
|
+
return decodeMessage(buf, Message.codec(), opts);
|
71
74
|
};
|
72
75
|
})(Message || (Message = {}));
|
73
76
|
//# sourceMappingURL=message.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"message.js","sourceRoot":"","sources":["../../../../src/private-to-private/pb/message.ts"],"names":[],"mappings":"AAAA,kCAAkC;AAClC,+BAA+B;AAC/B,oDAAoD;AACpD,8EAA8E;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A;QACJ,CAAC;QAED,OAAO,MAAM,CAAA;IACf,CAAC,CAAA;IAEY,cAAM,GAAG,CAAC,GAAqB,EAAc,EAAE;QAC1D,OAAO,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAA;IAC5C,CAAC,CAAA;IAEY,cAAM,GAAG,CAAC,GAAgC,EAAE,IAA6B,EAAW,EAAE;QACjG,OAAO,aAAa,CAAC,GAAG,EAAE,OAAO,CAAC,KAAK,EAAE,EAAE,IAAI,CAAC,CAAA;IAClD,CAAC,CAAA;AACH,CAAC,EA/EgB,OAAO,KAAP,OAAO,QA+EvB"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"signaling-stream-handler.d.ts","sourceRoot":"","sources":["../../../src/private-to-private/signaling-stream-handler.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"signaling-stream-handler.d.ts","sourceRoot":"","sources":["../../../src/private-to-private/signaling-stream-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,yBAAyB,CAAA;AAGnE,OAAO,EAAE,KAAK,iBAAiB,EAAyB,MAAM,oBAAoB,CAAA;AAGlF,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAA;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAEpE,MAAM,WAAW,kBAAmB,SAAQ,kBAAkB;IAC5D,cAAc,EAAE,iBAAiB,CAAA;IACjC,MAAM,EAAE,WAAW,CAAA;IACnB,GAAG,EAAE,MAAM,CAAA;CACZ;AAED,wBAAsB,oBAAoB,CAAE,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC;IAAE,aAAa,EAAE,SAAS,CAAA;CAAE,CAAC,CA0F1J"}
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import { CodeError } from '@libp2p/interface';
|
2
1
|
import { multiaddr } from '@multiformats/multiaddr';
|
3
2
|
import { pbStream } from 'it-protobuf-stream';
|
3
|
+
import { SDPHandshakeFailedError } from '../error.js';
|
4
4
|
import { RTCSessionDescription } from '../webrtc/index.js';
|
5
5
|
import { Message } from './pb/message.js';
|
6
6
|
import { readCandidatesUntilConnected } from './util.js';
|
@@ -31,7 +31,7 @@ export async function handleIncomingStream({ peerConnection, stream, signal, con
|
|
31
31
|
signal
|
32
32
|
});
|
33
33
|
if (pbOffer.type !== Message.Type.SDP_OFFER) {
|
34
|
-
throw new
|
34
|
+
throw new SDPHandshakeFailedError(`expected message type SDP_OFFER, received: ${pbOffer.type ?? 'undefined'} `);
|
35
35
|
}
|
36
36
|
log.trace('recipient receive SDP offer %s', pbOffer.data);
|
37
37
|
const offer = new RTCSessionDescription({
|
@@ -40,12 +40,12 @@ export async function handleIncomingStream({ peerConnection, stream, signal, con
|
|
40
40
|
});
|
41
41
|
await peerConnection.setRemoteDescription(offer).catch(err => {
|
42
42
|
log.error('could not execute setRemoteDescription', err);
|
43
|
-
throw new
|
43
|
+
throw new SDPHandshakeFailedError('Failed to set remoteDescription');
|
44
44
|
});
|
45
45
|
// create and write an SDP answer
|
46
46
|
const answer = await peerConnection.createAnswer().catch(err => {
|
47
47
|
log.error('could not execute createAnswer', err);
|
48
|
-
throw new
|
48
|
+
throw new SDPHandshakeFailedError('Failed to create answer');
|
49
49
|
});
|
50
50
|
log.trace('recipient send SDP answer %s', answer.sdp);
|
51
51
|
// write the answer to the remote
|
@@ -54,7 +54,7 @@ export async function handleIncomingStream({ peerConnection, stream, signal, con
|
|
54
54
|
});
|
55
55
|
await peerConnection.setLocalDescription(answer).catch(err => {
|
56
56
|
log.error('could not execute setLocalDescription', err);
|
57
|
-
throw new
|
57
|
+
throw new SDPHandshakeFailedError('Failed to set localDescription');
|
58
58
|
});
|
59
59
|
log.trace('recipient read candidates until connected');
|
60
60
|
// wait until candidates are connected
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"signaling-stream-handler.js","sourceRoot":"","sources":["../../../src/private-to-private/signaling-stream-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,
|
1
|
+
{"version":3,"file":"signaling-stream-handler.js","sourceRoot":"","sources":["../../../src/private-to-private/signaling-stream-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkB,MAAM,yBAAyB,CAAA;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAA;AAC7C,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACrD,OAAO,EAA0B,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAClF,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,OAAO,EAAE,4BAA4B,EAAE,MAAM,WAAW,CAAA;AAUxD,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAE,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,EAAsB;IACjH,GAAG,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAA;IAEzC,MAAM,aAAa,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,CAAA;IAElD,IAAI,CAAC;QACH,sBAAsB;QACtB,cAAc,CAAC,cAAc,GAAG,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE;YAChD,sEAAsE;YACtE,qEAAqE;YACrE,8BAA8B;YAC9B,gEAAgE;YAChE,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,IAAI,CAAC,CAAA;YAExD,GAAG,CAAC,KAAK,CAAC,oCAAoC,EAAE,IAAI,CAAC,CAAA;YAErD,aAAa,CAAC,KAAK,CAAC;gBAClB,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,aAAa;gBAChC,IAAI;aACL,EAAE;gBACD,MAAM;aACP,CAAC;iBACC,KAAK,CAAC,GAAG,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AAU,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,EAAE,EAAE;YAC7E,MAAM;SACP,CAAC,CAAA;QAEF,MAAM,cAAc,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE;YAC3D,GAAG,CAAC,KAAK,CAAC,uCAAuC,EAAE,GAAG,CAAC,CAAA;YACvD,MAAM,IAAI,uBAAuB,CAAC,gCAAgC,CAAC,CAAA;QACrE,CAAC,CAAC,CAAA;QAEF,GAAG,CAAC,KAAK,CAAC,2CAA2C,CAAC,CAAA;QAEtD,sCAAsC;QACtC,MAAM,4BAA4B,CAAC,cAAc,EAAE,aAAa,EAAE;YAChE,SAAS,EAAE,WAAW;YACtB,MAAM;YACN,GAAG;SACJ,CAAC,CAAA;IACJ,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,IAAI,cAAc,CAAC,eAAe,KAAK,WAAW,EAAE,CAAC;YACnD,GAAG,CAAC,KAAK,CAAC,oDAAoD,EAAE,UAAU,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;YAE3F,cAAc,CAAC,KAAK,EAAE,CAAA;YACtB,MAAM,GAAG,CAAA;QACX,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,4GAA4G,EAAE,UAAU,CAAC,UAAU,EAAE,GAAG,CAAC,CAAA;QAC/I,CAAC;IACH,CAAC;IAED,MAAM,aAAa,GAAG,SAAS,CAAC,eAAe,UAAU,CAAC,UAAU,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;IAEnF,GAAG,CAAC,KAAK,CAAC,0CAA0C,EAAE,aAAa,CAAC,CAAA;IAEpE,OAAO,EAAE,aAAa,EAAE,CAAA;AAC1B,CAAC"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../../../src/private-to-private/transport.ts"],"names":[],"mappings":"AAAA,OAAO,
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../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AU,CAAE,UAAU,EAAE,SAAS,EAAE,GAAG,SAAS,EAAE;IAW3C,IAAI,CAAE,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE,oBAAoB,CAAC,gBAAgB,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IAoC1F,WAAW,CAAE,EAAE,UAAU,EAAE,MAAM,EAAE,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IA8C7E,OAAO,CAAC,gBAAgB;CAezB;AAED,wBAAgB,SAAS,CAAE,EAAE,EAAE,SAAS,GAAG;IAAE,QAAQ,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CA4BjF"}
|
@@ -1,8 +1,7 @@
|
|
1
|
-
import {
|
1
|
+
import { InvalidParametersError, serviceCapabilities, serviceDependencies, setMaxListeners, transportSymbol } from '@libp2p/interface';
|
2
2
|
import { peerIdFromString } from '@libp2p/peer-id';
|
3
3
|
import { multiaddr } from '@multiformats/multiaddr';
|
4
4
|
import { WebRTC } from '@multiformats/multiaddr-matcher';
|
5
|
-
import { codes } from '../error.js';
|
6
5
|
import { WebRTCMultiaddrConnection } from '../maconn.js';
|
7
6
|
import { DataChannelMuxerFactory } from '../muxer.js';
|
8
7
|
import { getRtcConfiguration } from '../util.js';
|
@@ -56,7 +55,7 @@ export class WebRTCTransport {
|
|
56
55
|
await this.components.registrar.handle(SIGNALING_PROTO_ID, (data) => {
|
57
56
|
this._onProtocol(data).catch(err => { this.log.error('failed to handle incoming connect from %p', data.connection.remotePeer, err); });
|
58
57
|
}, {
|
59
|
-
|
58
|
+
runOnLimitedConnection: true
|
60
59
|
});
|
61
60
|
this._started = true;
|
62
61
|
}
|
@@ -175,21 +174,21 @@ export class WebRTCTransport {
|
|
175
174
|
export function splitAddr(ma) {
|
176
175
|
const addrs = ma.toString().split(WEBRTC_TRANSPORT + '/');
|
177
176
|
if (addrs.length !== 2) {
|
178
|
-
throw new
|
177
|
+
throw new InvalidParametersError('webrtc protocol was not present in multiaddr');
|
179
178
|
}
|
180
179
|
if (!addrs[0].includes(CIRCUIT_RELAY_TRANSPORT)) {
|
181
|
-
throw new
|
180
|
+
throw new InvalidParametersError('p2p-circuit protocol was not present in multiaddr');
|
182
181
|
}
|
183
182
|
// look for remote peerId
|
184
183
|
let remoteAddr = multiaddr(addrs[0]);
|
185
184
|
const destination = multiaddr('/' + addrs[1]);
|
186
185
|
const destinationIdString = destination.getPeerId();
|
187
186
|
if (destinationIdString == null) {
|
188
|
-
throw new
|
187
|
+
throw new InvalidParametersError('destination peer id was missing');
|
189
188
|
}
|
190
189
|
const lastProtoInRemote = remoteAddr.protos().pop();
|
191
190
|
if (lastProtoInRemote === undefined) {
|
192
|
-
throw new
|
191
|
+
throw new InvalidParametersError('invalid multiaddr');
|
193
192
|
}
|
194
193
|
if (lastProtoInRemote.name !== 'p2p') {
|
195
194
|
remoteAddr = remoteAddr.encapsulate(`/p2p/${destinationIdString}`);
|