@formant/data-sdk 0.0.85 → 0.0.86
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/data-sdk.es.js +239 -239
- package/dist/data-sdk.umd.js +33 -33
- package/package.json +2 -2
package/dist/data-sdk.es.js
CHANGED
|
@@ -78,34 +78,34 @@ var dist = { exports: {} };
|
|
|
78
78
|
return o(o.s = 226);
|
|
79
79
|
}([function(e, t, r) {
|
|
80
80
|
r.d(t, "a", function() {
|
|
81
|
-
return
|
|
81
|
+
return L;
|
|
82
82
|
});
|
|
83
83
|
const n = Math.pow(2, 20), o = n;
|
|
84
|
-
var i = r(54), s = r(
|
|
85
|
-
function
|
|
86
|
-
if (!
|
|
84
|
+
var i = r(54), s = r.n(i), a2 = r(15), l = r(53), u = typeof crypto != "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto != "undefined" && typeof msCrypto.getRandomValues == "function" && msCrypto.getRandomValues.bind(msCrypto), g = new Uint8Array(16);
|
|
85
|
+
function c() {
|
|
86
|
+
if (!u)
|
|
87
87
|
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
88
|
-
return
|
|
88
|
+
return u(g);
|
|
89
89
|
}
|
|
90
|
-
for (var
|
|
91
|
-
|
|
92
|
-
var
|
|
93
|
-
var r2 = t2 || 0, n2 =
|
|
90
|
+
for (var f = [], p = 0; p < 256; ++p)
|
|
91
|
+
f[p] = (p + 256).toString(16).substr(1);
|
|
92
|
+
var h = function(e2, t2) {
|
|
93
|
+
var r2 = t2 || 0, n2 = f;
|
|
94
94
|
return [n2[e2[r2++]], n2[e2[r2++]], n2[e2[r2++]], n2[e2[r2++]], "-", n2[e2[r2++]], n2[e2[r2++]], "-", n2[e2[r2++]], n2[e2[r2++]], "-", n2[e2[r2++]], n2[e2[r2++]], "-", n2[e2[r2++]], n2[e2[r2++]], n2[e2[r2++]], n2[e2[r2++]], n2[e2[r2++]], n2[e2[r2++]]].join("");
|
|
95
95
|
};
|
|
96
|
-
var
|
|
96
|
+
var d = function(e2, t2, r2) {
|
|
97
97
|
var n2 = t2 && r2 || 0;
|
|
98
98
|
typeof e2 == "string" && (t2 = e2 === "binary" ? new Array(16) : null, e2 = null);
|
|
99
|
-
var o2 = (e2 = e2 || {}).random || (e2.rng ||
|
|
99
|
+
var o2 = (e2 = e2 || {}).random || (e2.rng || c)();
|
|
100
100
|
if (o2[6] = 15 & o2[6] | 64, o2[8] = 63 & o2[8] | 128, t2)
|
|
101
101
|
for (var i2 = 0; i2 < 16; ++i2)
|
|
102
102
|
t2[n2 + i2] = o2[i2];
|
|
103
|
-
return t2 ||
|
|
104
|
-
},
|
|
105
|
-
function
|
|
106
|
-
return
|
|
103
|
+
return t2 || h(o2);
|
|
104
|
+
}, y = r(16), m = r(6), b = r(29), _ = r(35), v = r.n(_);
|
|
105
|
+
function S(e2) {
|
|
106
|
+
return v()(e2, { cycles: true });
|
|
107
107
|
}
|
|
108
|
-
var
|
|
108
|
+
var w = function(e2, t2) {
|
|
109
109
|
var r2 = {};
|
|
110
110
|
for (var n2 in e2)
|
|
111
111
|
Object.prototype.hasOwnProperty.call(e2, n2) && t2.indexOf(n2) < 0 && (r2[n2] = e2[n2]);
|
|
@@ -116,18 +116,18 @@ var dist = { exports: {} };
|
|
|
116
116
|
}
|
|
117
117
|
return r2;
|
|
118
118
|
};
|
|
119
|
-
function
|
|
120
|
-
const r2 = (e3) => t2.redacted !== false ? Object(
|
|
119
|
+
function E(e2, t2 = {}) {
|
|
120
|
+
const r2 = (e3) => t2.redacted !== false ? Object(b.a)(e3) : e3;
|
|
121
121
|
if (!e2.stack)
|
|
122
|
-
return { message:
|
|
123
|
-
const { name: n2, message: o2, stack: i2 } = e2, s2 =
|
|
124
|
-
return { name: n2, message: o2 !== void 0 ? o2 :
|
|
122
|
+
return { message: S(r2(e2)) };
|
|
123
|
+
const { name: n2, message: o2, stack: i2 } = e2, s2 = w(e2, ["name", "message", "stack"]);
|
|
124
|
+
return { name: n2, message: o2 !== void 0 ? o2 : S(r2(e2)), stack: i2, meta: s2 && Object.keys(s2).length === 0 ? void 0 : r2(s2) };
|
|
125
125
|
}
|
|
126
|
-
function
|
|
127
|
-
const { message: r2, stack: n2, meta: o2 } =
|
|
128
|
-
return `${n2 || r2 || ""}${o2 && Object.keys(o2).length > 0 ? ` -- ${
|
|
126
|
+
function T(e2, t2 = {}) {
|
|
127
|
+
const { message: r2, stack: n2, meta: o2 } = E(e2, t2);
|
|
128
|
+
return `${n2 || r2 || ""}${o2 && Object.keys(o2).length > 0 ? ` -- ${S(o2)}` : ""}`;
|
|
129
129
|
}
|
|
130
|
-
var
|
|
130
|
+
var R = r(99), A = r.n(R), O = function(e2, t2, r2, n2) {
|
|
131
131
|
return new (r2 || (r2 = Promise))(function(o2, i2) {
|
|
132
132
|
function s2(e3) {
|
|
133
133
|
try {
|
|
@@ -151,7 +151,7 @@ var dist = { exports: {} };
|
|
|
151
151
|
}
|
|
152
152
|
l2((n2 = n2.apply(e2, t2 || [])).next());
|
|
153
153
|
});
|
|
154
|
-
},
|
|
154
|
+
}, I = function(e2, t2) {
|
|
155
155
|
var r2 = {};
|
|
156
156
|
for (var n2 in e2)
|
|
157
157
|
Object.prototype.hasOwnProperty.call(e2, n2) && t2.indexOf(n2) < 0 && (r2[n2] = e2[n2]);
|
|
@@ -162,30 +162,30 @@ var dist = { exports: {} };
|
|
|
162
162
|
}
|
|
163
163
|
return r2;
|
|
164
164
|
};
|
|
165
|
-
class
|
|
165
|
+
class j extends A.a {
|
|
166
166
|
constructor(e2, t2) {
|
|
167
167
|
super(), this.endpoint = e2, this.meta = t2, this.logClient = this.getLogClient();
|
|
168
168
|
}
|
|
169
169
|
getLogClient() {
|
|
170
|
-
return
|
|
170
|
+
return O(this, void 0, void 0, function* () {
|
|
171
171
|
const { LogClient: e2 } = yield Promise.resolve().then(r.bind(null, 228));
|
|
172
172
|
return new e2(this.endpoint);
|
|
173
173
|
});
|
|
174
174
|
}
|
|
175
175
|
log(e2, t2) {
|
|
176
|
-
return
|
|
177
|
-
const { level: r2, message: n2, error: o2 } = e2, i2 =
|
|
176
|
+
return O(this, void 0, void 0, function* () {
|
|
177
|
+
const { level: r2, message: n2, error: o2 } = e2, i2 = I(e2, ["level", "message", "error"]);
|
|
178
178
|
this.emit("logged");
|
|
179
179
|
try {
|
|
180
|
-
yield (yield this.logClient).log([{ timestamp: new Date().toISOString(), level: r2, message: n2.substring(0, 1e3), error: o2 !== void 0 ?
|
|
180
|
+
yield (yield this.logClient).log([{ timestamp: new Date().toISOString(), level: r2, message: n2.substring(0, 1e3), error: o2 !== void 0 ? E(o2) : void 0, meta: Object.assign(Object.assign({}, i2), this.meta()) }]);
|
|
181
181
|
} catch (o3) {
|
|
182
|
-
console.error(`Failed to log to log-api: ${
|
|
182
|
+
console.error(`Failed to log to log-api: ${T(o3)}`);
|
|
183
183
|
}
|
|
184
184
|
t2();
|
|
185
185
|
});
|
|
186
186
|
}
|
|
187
187
|
}
|
|
188
|
-
var
|
|
188
|
+
var C = function(e2, t2) {
|
|
189
189
|
var r2 = {};
|
|
190
190
|
for (var n2 in e2)
|
|
191
191
|
Object.prototype.hasOwnProperty.call(e2, n2) && t2.indexOf(n2) < 0 && (r2[n2] = e2[n2]);
|
|
@@ -196,35 +196,35 @@ var dist = { exports: {} };
|
|
|
196
196
|
}
|
|
197
197
|
return r2;
|
|
198
198
|
};
|
|
199
|
-
const
|
|
200
|
-
let
|
|
201
|
-
const
|
|
202
|
-
var { timestamp: t2, level: r2, message: n2, error: o2 } = e2,
|
|
203
|
-
const a3 = Object.assign(Object.assign({ timestamp: t2 ? new Date(t2).getTime() : new Date().getTime(), level: r2.toUpperCase(), message: n2 }, o2 ? { error:
|
|
199
|
+
const M = { app: m.a, namespace: m.i, buildTag: m.b, instanceId: d() };
|
|
200
|
+
let P = {};
|
|
201
|
+
const N = m.e ? y.format.printf((e2) => {
|
|
202
|
+
var { timestamp: t2, level: r2, message: n2, error: o2 } = e2, i2 = C(e2, ["timestamp", "level", "message", "error"]);
|
|
203
|
+
const a3 = Object.assign(Object.assign({ timestamp: t2 ? new Date(t2).getTime() : new Date().getTime(), level: r2.toUpperCase(), message: n2 }, o2 ? { error: E(o2) } : {}), { meta: Object.assign(Object.assign(Object.assign({}, M), P), i2) });
|
|
204
204
|
try {
|
|
205
205
|
return JSON.stringify(a3);
|
|
206
206
|
} catch (o3) {
|
|
207
|
-
return
|
|
207
|
+
return s()(a3);
|
|
208
208
|
}
|
|
209
|
-
}) :
|
|
210
|
-
var { timestamp: t2, level: r2, message: n2, error: o2 } = e2,
|
|
209
|
+
}) : y.format.printf((e2) => {
|
|
210
|
+
var { timestamp: t2, level: r2, message: n2, error: o2 } = e2, i2 = C(e2, ["timestamp", "level", "message", "error"]);
|
|
211
211
|
let a3 = `${t2 || new Date().toISOString()} ${r2.toUpperCase()}: ${n2} `;
|
|
212
|
-
if (Object.keys(
|
|
212
|
+
if (Object.keys(i2).length > 0)
|
|
213
213
|
try {
|
|
214
|
-
a3 += JSON.stringify(
|
|
214
|
+
a3 += JSON.stringify(i2);
|
|
215
215
|
} catch (o3) {
|
|
216
|
-
a3 +=
|
|
216
|
+
a3 += s()(i2);
|
|
217
217
|
}
|
|
218
218
|
return o2 && (a3 += `
|
|
219
|
-
${
|
|
219
|
+
${T(o2)}`), a3;
|
|
220
220
|
});
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
if (
|
|
224
|
-
const e2 =
|
|
225
|
-
|
|
221
|
+
const L = Object(y.createLogger)({ level: m.f });
|
|
222
|
+
m.g && L.add(new y.transports.Console({ format: N, level: "debug" })), m.d && L.add(new j(m.d, () => Object.assign(Object.assign(Object.assign({}, M), P), { level: "debug" })));
|
|
223
|
+
if (m.h) {
|
|
224
|
+
const e2 = l.resolve(a2.tmpdir(), `silly-${m.a}.log`);
|
|
225
|
+
L.debug("Logging silly logs to file", { filename: e2 }), L.add(new y.transports.File({ filename: e2, maxsize: 1 * o, maxFiles: 10, format: y.format.combine((D = "silly", Object(y.format)((e3) => e3.level === D && e3)()), N), level: "silly" }));
|
|
226
226
|
}
|
|
227
|
-
var
|
|
227
|
+
var D;
|
|
228
228
|
}, function(e, t, r) {
|
|
229
229
|
r.d(t, "a", function() {
|
|
230
230
|
return n;
|
|
@@ -16875,9 +16875,9 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
16875
16875
|
}), r.d(t, "RtcSignalingClient", function() {
|
|
16876
16876
|
return a2;
|
|
16877
16877
|
}), r.d(t, "Credentials", function() {
|
|
16878
|
-
return
|
|
16878
|
+
return m;
|
|
16879
16879
|
}), r.d(t, "SignalingPromiseClient", function() {
|
|
16880
|
-
return
|
|
16880
|
+
return b.SignalingPromiseClient;
|
|
16881
16881
|
}), r.d(t, "IRtcClientConfiguration", function() {
|
|
16882
16882
|
}), r.d(t, "IRtcConnectConfiguration", function() {
|
|
16883
16883
|
}), r.d(t, "IRtcConnectionStatsInfo", function() {
|
|
@@ -16886,7 +16886,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
16886
16886
|
}), r.d(t, "IRtcStreamMessage", function() {
|
|
16887
16887
|
}), r.d(t, "IStreamControl", function() {
|
|
16888
16888
|
}), r.d(t, "RtcClient", function() {
|
|
16889
|
-
return
|
|
16889
|
+
return Q;
|
|
16890
16890
|
});
|
|
16891
16891
|
var n = r(25), o = function(e2, t2, r2, n2) {
|
|
16892
16892
|
return new (r2 || (r2 = Promise))(function(o2, i2) {
|
|
@@ -17057,8 +17057,8 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17057
17057
|
});
|
|
17058
17058
|
}
|
|
17059
17059
|
}
|
|
17060
|
-
var l = r(1), u = r(11), g = r(35), c = r(102);
|
|
17061
|
-
var
|
|
17060
|
+
var l = r(1), u = r(11), g = r(35), c = r.n(g), f = r(102), p = r.n(f);
|
|
17061
|
+
var h = function(e2, t2, r2, n2) {
|
|
17062
17062
|
return new (r2 || (r2 = Promise))(function(o2, i2) {
|
|
17063
17063
|
function s2(e3) {
|
|
17064
17064
|
try {
|
|
@@ -17083,9 +17083,9 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17083
17083
|
l2((n2 = n2.apply(e2, t2 || [])).next());
|
|
17084
17084
|
});
|
|
17085
17085
|
};
|
|
17086
|
-
class
|
|
17086
|
+
class d extends class {
|
|
17087
17087
|
constructor(e2) {
|
|
17088
|
-
this.cache = new
|
|
17088
|
+
this.cache = new p.a(Object.assign(Object.assign({}, e2.dispose || e2.disposeAfter ? { ttlAutopurge: true } : {}), e2)), this.stringify = e2.fastStringify ? JSON.stringify : c.a;
|
|
17089
17089
|
}
|
|
17090
17090
|
set(e2, t2, r2) {
|
|
17091
17091
|
const n2 = this.stringify(e2);
|
|
@@ -17116,12 +17116,12 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17116
17116
|
}
|
|
17117
17117
|
set(e2, t2, r2) {
|
|
17118
17118
|
const n2 = this.stringify(e2);
|
|
17119
|
-
this.cache.set(n2, t2, { ttl: r2 }), this.expireRejectedPromiseValues && Promise.resolve(t2).catch(() =>
|
|
17119
|
+
this.cache.set(n2, t2, { ttl: r2 }), this.expireRejectedPromiseValues && Promise.resolve(t2).catch(() => h(this, void 0, void 0, function* () {
|
|
17120
17120
|
yield Object(u.a)(this.rejectedPromiseValueTtl), this.cache.peek(n2) === t2 && this.cache.delete(n2);
|
|
17121
17121
|
}));
|
|
17122
17122
|
}
|
|
17123
17123
|
}
|
|
17124
|
-
var
|
|
17124
|
+
var y = function(e2, t2, r2, n2) {
|
|
17125
17125
|
return new (r2 || (r2 = Promise))(function(o2, i2) {
|
|
17126
17126
|
function s2(e3) {
|
|
17127
17127
|
try {
|
|
@@ -17146,14 +17146,14 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17146
17146
|
l2((n2 = n2.apply(e2, t2 || [])).next());
|
|
17147
17147
|
});
|
|
17148
17148
|
};
|
|
17149
|
-
class
|
|
17149
|
+
class m {
|
|
17150
17150
|
constructor(e2, t2, r2) {
|
|
17151
|
-
this.authClient = e2, this.email = t2, this.password = r2, this.tokenTtlMs = 1 * l.a.hour, this.tokenCache = new
|
|
17151
|
+
this.authClient = e2, this.email = t2, this.password = r2, this.tokenTtlMs = 1 * l.a.hour, this.tokenCache = new d({ max: 100, ttl: this.tokenTtlMs - 5 * l.a.minute, fastStringify: true });
|
|
17152
17152
|
}
|
|
17153
17153
|
getToken() {
|
|
17154
|
-
return
|
|
17154
|
+
return y(this, void 0, void 0, function* () {
|
|
17155
17155
|
let e2 = this.tokenCache.get(this.email);
|
|
17156
|
-
return e2 || (e2 = (() =>
|
|
17156
|
+
return e2 || (e2 = (() => y(this, void 0, void 0, function* () {
|
|
17157
17157
|
const { authentication: e3 } = yield this.authClient.login({ email: this.email, password: this.password, tokenExpirationSeconds: this.tokenTtlMs / l.a.second });
|
|
17158
17158
|
if (!e3)
|
|
17159
17159
|
throw new Error("User account not verified.");
|
|
@@ -17162,8 +17162,8 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17162
17162
|
});
|
|
17163
17163
|
}
|
|
17164
17164
|
}
|
|
17165
|
-
var
|
|
17166
|
-
var
|
|
17165
|
+
var b = r(93);
|
|
17166
|
+
var _ = function(e2, t2, r2, n2) {
|
|
17167
17167
|
return new (r2 || (r2 = Promise))(function(o2, i2) {
|
|
17168
17168
|
function s2(e3) {
|
|
17169
17169
|
try {
|
|
@@ -17188,17 +17188,17 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17188
17188
|
l2((n2 = n2.apply(e2, t2 || [])).next());
|
|
17189
17189
|
});
|
|
17190
17190
|
};
|
|
17191
|
-
function
|
|
17192
|
-
return
|
|
17191
|
+
function v(e2) {
|
|
17192
|
+
return _(this, void 0, void 0, function* () {
|
|
17193
17193
|
return (yield Promise.all(e2.map((e3) => e3.catch((e4) => e4)))).filter((e3) => e3 instanceof Error);
|
|
17194
17194
|
});
|
|
17195
17195
|
}
|
|
17196
|
-
function
|
|
17196
|
+
function S(e2) {
|
|
17197
17197
|
if (e2 !== void 0)
|
|
17198
17198
|
return e2;
|
|
17199
17199
|
throw new Error("Value is undefined");
|
|
17200
17200
|
}
|
|
17201
|
-
var
|
|
17201
|
+
var w = r(0), E = function(e2, t2, r2, n2) {
|
|
17202
17202
|
return new (r2 || (r2 = Promise))(function(o2, i2) {
|
|
17203
17203
|
function s2(e3) {
|
|
17204
17204
|
try {
|
|
@@ -17223,9 +17223,9 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17223
17223
|
l2((n2 = n2.apply(e2, t2 || [])).next());
|
|
17224
17224
|
});
|
|
17225
17225
|
};
|
|
17226
|
-
function
|
|
17226
|
+
function T({ func: e2, delay: t2, immediate: r2 }) {
|
|
17227
17227
|
let n2 = false, o2 = setTimeout(function r3() {
|
|
17228
|
-
return
|
|
17228
|
+
return E(this, void 0, void 0, function* () {
|
|
17229
17229
|
if (n2)
|
|
17230
17230
|
return;
|
|
17231
17231
|
const s2 = new Date().getTime();
|
|
@@ -17240,15 +17240,15 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17240
17240
|
});
|
|
17241
17241
|
}, r2 ? 0 : t2), i2 = Promise.resolve();
|
|
17242
17242
|
return { stop() {
|
|
17243
|
-
return
|
|
17243
|
+
return E(this, void 0, void 0, function* () {
|
|
17244
17244
|
n2 = true, clearTimeout(o2), yield i2;
|
|
17245
17245
|
});
|
|
17246
17246
|
} };
|
|
17247
17247
|
}
|
|
17248
|
-
function
|
|
17248
|
+
function R(e2, t2) {
|
|
17249
17249
|
return Object.keys(e2).reduce((r2, n2) => Object.assign(Object.assign({}, r2), { [n2]: t2(e2[n2]) }), {});
|
|
17250
17250
|
}
|
|
17251
|
-
var
|
|
17251
|
+
var A = function(e2, t2, r2, n2) {
|
|
17252
17252
|
return new (r2 || (r2 = Promise))(function(o2, i2) {
|
|
17253
17253
|
function s2(e3) {
|
|
17254
17254
|
try {
|
|
@@ -17273,20 +17273,20 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17273
17273
|
l2((n2 = n2.apply(e2, t2 || [])).next());
|
|
17274
17274
|
});
|
|
17275
17275
|
};
|
|
17276
|
-
class
|
|
17276
|
+
class O {
|
|
17277
17277
|
constructor(e2) {
|
|
17278
17278
|
this.message = e2;
|
|
17279
17279
|
}
|
|
17280
17280
|
send(e2) {
|
|
17281
|
-
return
|
|
17282
|
-
|
|
17281
|
+
return A(this, void 0, void 0, function* () {
|
|
17282
|
+
w.a.info(this.message, R(e2, (e3) => {
|
|
17283
17283
|
const { sum: t2, count: r2 } = e3, n2 = t2 / r2;
|
|
17284
17284
|
return Object.assign(Object.assign({}, e3), { average: n2 });
|
|
17285
17285
|
}));
|
|
17286
17286
|
});
|
|
17287
17287
|
}
|
|
17288
17288
|
}
|
|
17289
|
-
var
|
|
17289
|
+
var I = function(e2, t2, r2, n2) {
|
|
17290
17290
|
return new (r2 || (r2 = Promise))(function(o2, i2) {
|
|
17291
17291
|
function s2(e3) {
|
|
17292
17292
|
try {
|
|
@@ -17311,14 +17311,14 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17311
17311
|
l2((n2 = n2.apply(e2, t2 || [])).next());
|
|
17312
17312
|
});
|
|
17313
17313
|
};
|
|
17314
|
-
const
|
|
17315
|
-
var
|
|
17316
|
-
const
|
|
17314
|
+
const j = r(222);
|
|
17315
|
+
var C = r(6);
|
|
17316
|
+
const M = !!C.c, P = new class {
|
|
17317
17317
|
constructor(e2 = 60) {
|
|
17318
|
-
this.buffer = {}, this.metrics = {}, this.reporters = [], this.flushInterval =
|
|
17318
|
+
this.buffer = {}, this.metrics = {}, this.reporters = [], this.flushInterval = T({ func: () => this.flushStats(), delay: e2 * l.a.second });
|
|
17319
17319
|
}
|
|
17320
17320
|
shutdown() {
|
|
17321
|
-
return
|
|
17321
|
+
return I(this, void 0, void 0, function* () {
|
|
17322
17322
|
yield this.flushInterval.stop(), yield this.flushStats(), yield Object(u.a)(2 * l.a.second);
|
|
17323
17323
|
});
|
|
17324
17324
|
}
|
|
@@ -17333,8 +17333,8 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17333
17333
|
this.aggregate(e2, 1);
|
|
17334
17334
|
}
|
|
17335
17335
|
timer(e2, t2) {
|
|
17336
|
-
return
|
|
17337
|
-
const r2 =
|
|
17336
|
+
return I(this, void 0, void 0, function* () {
|
|
17337
|
+
const r2 = j(), n2 = yield t2(), o2 = j();
|
|
17338
17338
|
return this.aggregate(e2, o2 - r2), n2;
|
|
17339
17339
|
});
|
|
17340
17340
|
}
|
|
@@ -17345,17 +17345,17 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17345
17345
|
this.reporters.push(e2);
|
|
17346
17346
|
}
|
|
17347
17347
|
write(e2) {
|
|
17348
|
-
return
|
|
17348
|
+
return I(this, void 0, void 0, function* () {
|
|
17349
17349
|
if (Object.values(e2).length === 0)
|
|
17350
17350
|
return;
|
|
17351
|
-
const t2 = yield
|
|
17351
|
+
const t2 = yield v(this.reporters.map((t3) => t3.send(e2)));
|
|
17352
17352
|
for (const e3 of t2)
|
|
17353
|
-
|
|
17353
|
+
w.a.warn("Failed to write stats", { error: e3 });
|
|
17354
17354
|
});
|
|
17355
17355
|
}
|
|
17356
17356
|
flushStats() {
|
|
17357
|
-
return
|
|
17358
|
-
const e2 = Object.assign(Object.assign({}, this.buffer),
|
|
17357
|
+
return I(this, void 0, void 0, function* () {
|
|
17358
|
+
const e2 = Object.assign(Object.assign({}, this.buffer), R(this.metrics, (e3) => {
|
|
17359
17359
|
const t2 = e3();
|
|
17360
17360
|
return { min: t2, max: t2, sum: t2, count: 1 };
|
|
17361
17361
|
}));
|
|
@@ -17363,8 +17363,8 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17363
17363
|
});
|
|
17364
17364
|
}
|
|
17365
17365
|
}();
|
|
17366
|
-
|
|
17367
|
-
var
|
|
17366
|
+
M || ["local", "on-prem"].includes(C.i) || P.registerStatsReporter(new O("stats"));
|
|
17367
|
+
var N = r(8), L = r(21), D = r(103), x = r(36), U = function(e2, t2, r2, n2) {
|
|
17368
17368
|
return new (r2 || (r2 = Promise))(function(o2, i2) {
|
|
17369
17369
|
function s2(e3) {
|
|
17370
17370
|
try {
|
|
@@ -17389,22 +17389,22 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17389
17389
|
l2((n2 = n2.apply(e2, t2 || [])).next());
|
|
17390
17390
|
});
|
|
17391
17391
|
};
|
|
17392
|
-
class
|
|
17392
|
+
class B extends x.a {
|
|
17393
17393
|
constructor(e2) {
|
|
17394
17394
|
super(e2);
|
|
17395
17395
|
}
|
|
17396
17396
|
postLanRtcOffer(e2) {
|
|
17397
|
-
return
|
|
17397
|
+
return U(this, void 0, void 0, function* () {
|
|
17398
17398
|
return yield this.fetch("v1/lan-rtc-offer", { method: "POST", body: JSON.stringify(e2) });
|
|
17399
17399
|
});
|
|
17400
17400
|
}
|
|
17401
17401
|
}
|
|
17402
|
-
var
|
|
17403
|
-
const
|
|
17404
|
-
function
|
|
17402
|
+
var k = r(55);
|
|
17403
|
+
const F = { ordered: false, maxPacketLifeTime: 300 * l.a.millisecond }, W = { ordered: true }, V = { ordered: true }, H = { ordered: false, maxRetransmits: 0 }, z = { ordered: false, maxRetransmits: 0 };
|
|
17404
|
+
function G({ entityId: e2, streamName: t2, streamType: r2 }) {
|
|
17405
17405
|
return `${e2}.${t2}.${r2}`;
|
|
17406
17406
|
}
|
|
17407
|
-
var
|
|
17407
|
+
var q = function(e2, t2, r2, n2) {
|
|
17408
17408
|
return new (r2 || (r2 = Promise))(function(o2, i2) {
|
|
17409
17409
|
function s2(e3) {
|
|
17410
17410
|
try {
|
|
@@ -17429,7 +17429,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17429
17429
|
l2((n2 = n2.apply(e2, t2 || [])).next());
|
|
17430
17430
|
});
|
|
17431
17431
|
};
|
|
17432
|
-
class
|
|
17432
|
+
class Y {
|
|
17433
17433
|
constructor(e2, t2) {
|
|
17434
17434
|
this.sessionId = e2, this.connection = t2, this.counts = { localSent: /* @__PURE__ */ new Map(), localReceived: /* @__PURE__ */ new Map(), remoteSent: /* @__PURE__ */ new Map(), remoteReceived: /* @__PURE__ */ new Map() }, this.sessionId = e2, this.connection = t2;
|
|
17435
17435
|
}
|
|
@@ -17448,33 +17448,33 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17448
17448
|
}), timestamp: e2 };
|
|
17449
17449
|
}
|
|
17450
17450
|
incrementLocalSent(e2) {
|
|
17451
|
-
const { localSent: t2 } = this.counts, r2 =
|
|
17451
|
+
const { localSent: t2 } = this.counts, r2 = G(e2.header.stream);
|
|
17452
17452
|
t2.set(r2, (t2.get(r2) || 0) + 1);
|
|
17453
17453
|
}
|
|
17454
17454
|
incrementLocalReceived(e2) {
|
|
17455
|
-
const { localReceived: t2 } = this.counts, r2 =
|
|
17455
|
+
const { localReceived: t2 } = this.counts, r2 = G(e2.header.stream), n2 = t2.get(r2) || 0;
|
|
17456
17456
|
if (n2 === 0) {
|
|
17457
17457
|
const { streamName: t3, streamType: r3 } = e2.header.stream;
|
|
17458
|
-
|
|
17458
|
+
w.a.debug("RTC client received first message for stream", { streamName: t3, streamType: r3 });
|
|
17459
17459
|
}
|
|
17460
17460
|
t2.set(r2, n2 + 1);
|
|
17461
17461
|
}
|
|
17462
17462
|
uploadMetrics() {
|
|
17463
|
-
return
|
|
17463
|
+
return q(this, void 0, void 0, function* () {
|
|
17464
17464
|
const { sessionId: e2 } = this, t2 = yield this.connection.peerConnection.getStats(), r2 = {};
|
|
17465
|
-
t2.forEach((e3) => r2[e3.id] = e3),
|
|
17465
|
+
t2.forEach((e3) => r2[e3.id] = e3), w.a.debug("rtc-stats", Object.assign(Object.assign({}, r2), { sessionId: e2 }));
|
|
17466
17466
|
const { localSent: n2, localReceived: o2, remoteSent: i2, remoteReceived: s2 } = this.counts, a3 = [.../* @__PURE__ */ new Set([...n2.keys(), ...o2.keys()])].reduce((e3, t3) => {
|
|
17467
17467
|
const r3 = n2.get(t3), a4 = o2.get(t3), l2 = i2.get(t3), u2 = s2.get(t3);
|
|
17468
17468
|
return Object.assign(Object.assign({}, e3), { [`local-${t3}-sent`]: r3, [`local-${t3}-received`]: a4, [`remote-${t3}-sent`]: l2, [`remote-${t3}-received`]: u2 });
|
|
17469
17469
|
}, { sessionId: e2 });
|
|
17470
|
-
|
|
17470
|
+
w.a.debug("rtc-message-report", Object.assign({ deviceId: this.connection.getRemoteDeviceId() }, a3));
|
|
17471
17471
|
});
|
|
17472
17472
|
}
|
|
17473
17473
|
}
|
|
17474
|
-
function
|
|
17474
|
+
function Z(e2) {
|
|
17475
17475
|
return (/* @__PURE__ */ new Set(["disconnected", "failed", "closed"])).has(e2.iceConnectionState);
|
|
17476
17476
|
}
|
|
17477
|
-
var
|
|
17477
|
+
var $ = function(e2, t2, r2, n2) {
|
|
17478
17478
|
return new (r2 || (r2 = Promise))(function(o2, i2) {
|
|
17479
17479
|
function s2(e3) {
|
|
17480
17480
|
try {
|
|
@@ -17499,7 +17499,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17499
17499
|
l2((n2 = n2.apply(e2, t2 || [])).next());
|
|
17500
17500
|
});
|
|
17501
17501
|
};
|
|
17502
|
-
class
|
|
17502
|
+
class K {
|
|
17503
17503
|
constructor(e2, t2, r2) {
|
|
17504
17504
|
this.peerConnection = e2, this.config = t2, this.dataChannelNotifier = r2, this.connectTimeoutMs = 20 * l.a.second, this.iceGatheringTimeoutMs = 15 * l.a.second, this.pingUpdateTimeoutMs = 1 * l.a.second, this.streamsInfoUpdateTimeoutMs = 2 * l.a.second, this.reassemblyTimeoutMs = 500 * l.a.millisecond, this.reassemblyTableCleanupMs = 1 * l.a.second, this.heartbeatTimeoutMs = 20 * l.a.millisecond, this.streamLatestTimestamp = /* @__PURE__ */ new Map(), this.reassemblyTable = /* @__PURE__ */ new Map(), this.reassemblyTableLastTimestamp = /* @__PURE__ */ new Map(), this.closeCalled = false, this.gotOffer = false, this.hasIceCandidate = false;
|
|
17505
17505
|
const { isOffer: n2 } = t2.baseConfig;
|
|
@@ -17540,7 +17540,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17540
17540
|
}, this.heartbeatTimeoutMs);
|
|
17541
17541
|
}
|
|
17542
17542
|
handleSignal(e2) {
|
|
17543
|
-
return
|
|
17543
|
+
return $(this, void 0, void 0, function* () {
|
|
17544
17544
|
const { peerConnection: t2 } = this, { track: r2 } = this.config.baseConfig, n2 = (() => {
|
|
17545
17545
|
try {
|
|
17546
17546
|
return JSON.parse(e2.getPayload());
|
|
@@ -17549,19 +17549,19 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17549
17549
|
}
|
|
17550
17550
|
})();
|
|
17551
17551
|
if (!n2)
|
|
17552
|
-
return void
|
|
17553
|
-
|
|
17552
|
+
return void w.a.error("Received unparseable signal.");
|
|
17553
|
+
w.a.debug("Handling signal", { description: n2 });
|
|
17554
17554
|
const { sdp: o2, type: i2 } = n2;
|
|
17555
17555
|
if (!o2 || !i2)
|
|
17556
|
-
return void
|
|
17556
|
+
return void w.a.warn("Received non-SDP signal");
|
|
17557
17557
|
const { signalingState: s2, connectionState: a3 } = t2;
|
|
17558
17558
|
if (s2 !== "stable" || a3 !== "connected")
|
|
17559
17559
|
if (t2.remoteDescription)
|
|
17560
|
-
|
|
17560
|
+
w.a.warn(`Received SDP after remote description was set: ${o2}`);
|
|
17561
17561
|
else {
|
|
17562
17562
|
if (i2 === "offer") {
|
|
17563
17563
|
if (s2 !== "stable")
|
|
17564
|
-
return void
|
|
17564
|
+
return void w.a.warn("Received offer SDP when signaling is ongoing.");
|
|
17565
17565
|
yield t2.setRemoteDescription(n2);
|
|
17566
17566
|
const o3 = yield t2.createAnswer();
|
|
17567
17567
|
yield t2.setLocalDescription(o3);
|
|
@@ -17570,20 +17570,20 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17570
17570
|
}
|
|
17571
17571
|
if (i2 === "answer") {
|
|
17572
17572
|
if (s2 === "stable")
|
|
17573
|
-
return void
|
|
17573
|
+
return void w.a.warn("Received answer SDP when signaling hasn't started.");
|
|
17574
17574
|
yield t2.setRemoteDescription(n2);
|
|
17575
17575
|
}
|
|
17576
17576
|
}
|
|
17577
17577
|
else
|
|
17578
|
-
|
|
17578
|
+
w.a.warn(`Received SDP when already connected: ${o2}`);
|
|
17579
17579
|
});
|
|
17580
17580
|
}
|
|
17581
17581
|
send(e2, t2) {
|
|
17582
17582
|
const r2 = this.getChannelFromLabel(t2.channelLabel);
|
|
17583
|
-
r2 ? this.sendOnChannel(r2, e2) :
|
|
17583
|
+
r2 ? this.sendOnChannel(r2, e2) : w.a.warn("Send called with unexpected channel label", { channelLabel: t2.channelLabel });
|
|
17584
17584
|
}
|
|
17585
17585
|
controlRemoteStream(e2) {
|
|
17586
|
-
this.sendSystemMessage(
|
|
17586
|
+
this.sendSystemMessage(S(this.reliableStreamChannel), { type: "stream-control", streamControl: e2 });
|
|
17587
17587
|
}
|
|
17588
17588
|
isActive() {
|
|
17589
17589
|
return (/* @__PURE__ */ new Set(["new", "checking", "connected", "completed"])).has(this.peerConnection.iceConnectionState) || this.isReady();
|
|
@@ -17593,7 +17593,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17593
17593
|
return (e2 == null ? void 0 : e2.readyState) === "open" && (t2 == null ? void 0 : t2.readyState) === "open" && (r2 == null ? void 0 : r2.readyState) === "open" && (n2 == null ? void 0 : n2.readyState) === "open";
|
|
17594
17594
|
}
|
|
17595
17595
|
close() {
|
|
17596
|
-
return
|
|
17596
|
+
return $(this, void 0, void 0, function* () {
|
|
17597
17597
|
if (this.closeCalled)
|
|
17598
17598
|
return;
|
|
17599
17599
|
this.closeCalled = true, this.sessionMetrics && (yield this.sessionMetrics.uploadMetrics()), this.pingUpdateTimeout && clearInterval(this.pingUpdateTimeout), this.reassemblyTableCleanupTimeout && clearInterval(this.reassemblyTableCleanupTimeout), this.streamsInfoUpdateTimeout && clearInterval(this.streamsInfoUpdateTimeout), this.heartbeatTimeout && clearInterval(this.heartbeatTimeout);
|
|
@@ -17619,7 +17619,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17619
17619
|
return (e2 = this.config.remoteConfig) === null || e2 === void 0 ? void 0 : e2.sessionId;
|
|
17620
17620
|
}
|
|
17621
17621
|
setSessionId(e2) {
|
|
17622
|
-
this.config.remoteConfig && (this.config.remoteConfig.sessionId = e2, this.sessionMetrics = new
|
|
17622
|
+
this.config.remoteConfig && (this.config.remoteConfig.sessionId = e2, this.sessionMetrics = new Y(e2, this));
|
|
17623
17623
|
}
|
|
17624
17624
|
getRemotePeerId() {
|
|
17625
17625
|
return this.config.baseConfig.remotePeerId;
|
|
@@ -17636,7 +17636,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17636
17636
|
return (e2 = this.sessionMetrics) === null || e2 === void 0 ? void 0 : e2.counts;
|
|
17637
17637
|
}
|
|
17638
17638
|
getConnectionStatsInfo() {
|
|
17639
|
-
return
|
|
17639
|
+
return $(this, void 0, void 0, function* () {
|
|
17640
17640
|
const { peerConnection: e2 } = this;
|
|
17641
17641
|
if (!e2)
|
|
17642
17642
|
return;
|
|
@@ -17655,43 +17655,43 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17655
17655
|
});
|
|
17656
17656
|
}
|
|
17657
17657
|
initializeChannels(e2) {
|
|
17658
|
-
this.heartbeatChannel = e2.createDataChannel("heartbeat",
|
|
17658
|
+
this.heartbeatChannel = e2.createDataChannel("heartbeat", z), this.heartbeatChannel.binaryType = "arraybuffer", this.latestTtlStreamChannel = e2.createDataChannel("stream.latest-ttl", F), this.latestTtlStreamChannel.binaryType = "arraybuffer", this.reliableStreamChannel = e2.createDataChannel("stream.reliable", W), this.reliableStreamChannel.binaryType = "arraybuffer", this.latestReliableStreamChannel = e2.createDataChannel("stream.latest-reliable", V), this.latestReliableStreamChannel.binaryType = "arraybuffer", this.latestTryOnceStreamChannel = e2.createDataChannel("stream.latest-try-once", H), this.latestTryOnceStreamChannel.binaryType = "arraybuffer", this.setupChannel(this.latestTtlStreamChannel), this.setupChannel(this.reliableStreamChannel), this.setupChannel(this.latestReliableStreamChannel), this.setupChannel(this.latestTryOnceStreamChannel);
|
|
17659
17659
|
}
|
|
17660
17660
|
getOffer() {
|
|
17661
17661
|
var e2, t2, r2;
|
|
17662
|
-
return
|
|
17662
|
+
return $(this, void 0, void 0, function* () {
|
|
17663
17663
|
const { gotOffer: n2 } = this, { peerConnection: o2, config: i2 } = this;
|
|
17664
17664
|
if (this.config.baseConfig.isLan)
|
|
17665
17665
|
throw new Error('"getOffer" method can only be called with internet connections. LAN connections should call the "getLanOffer" method.');
|
|
17666
17666
|
const s2 = (e2 = this.config.remoteConfig) === null || e2 === void 0 ? void 0 : e2.sessionId;
|
|
17667
17667
|
if (n2)
|
|
17668
|
-
return void
|
|
17669
|
-
if (this.gotOffer = true,
|
|
17670
|
-
return void
|
|
17668
|
+
return void w.a.debug("Failed to generate offer because gotOffer was already called.");
|
|
17669
|
+
if (this.gotOffer = true, Z(this.peerConnection))
|
|
17670
|
+
return void w.a.debug("Failed to generate offer because the peer connection was inactive.");
|
|
17671
17671
|
const a3 = i2.baseConfig.track;
|
|
17672
17672
|
o2.onicecandidate = () => {
|
|
17673
17673
|
this.hasIceCandidate = true;
|
|
17674
|
-
}, o2.oniceconnectionstatechange = () =>
|
|
17674
|
+
}, o2.oniceconnectionstatechange = () => $(this, void 0, void 0, function* () {
|
|
17675
17675
|
const e3 = o2.iceConnectionState;
|
|
17676
17676
|
if (e3 === "connected" || e3 === "completed") {
|
|
17677
17677
|
const t3 = yield this.getConnectionStatsInfo(), r3 = t3 ? function(e4) {
|
|
17678
17678
|
const t4 = e4.localCandidate.candidateType, r4 = e4.remoteCandidate.candidateType;
|
|
17679
17679
|
return t4 === "host" && r4 === "host" ? "local" : t4 === "relay" || r4 === "relay" ? "TURN" : "STUN";
|
|
17680
17680
|
}(t3) : void 0;
|
|
17681
|
-
|
|
17681
|
+
w.a.info(`ICE connection state changed to ${e3}`, { sessionId: s2, connectionStatsInfo: t3, iceMode: r3 }), a3 == null || a3("ICE connection state change", { iceConnectionState: e3, sessionId: s2, connectionStatsInfo: t3, iceMode: r3 });
|
|
17682
17682
|
}
|
|
17683
17683
|
}), yield o2.setLocalDescription(yield o2.createOffer());
|
|
17684
17684
|
const g2 = new Date().getTime();
|
|
17685
17685
|
for (; ; ) {
|
|
17686
17686
|
const e3 = new Date().getTime() - g2;
|
|
17687
17687
|
if (e3 > this.connectTimeoutMs)
|
|
17688
|
-
return void
|
|
17688
|
+
return void w.a.debug("Failed to generate offer because ICE gathering timed out.");
|
|
17689
17689
|
if (e3 > this.iceGatheringTimeoutMs && this.hasIceCandidate) {
|
|
17690
|
-
|
|
17690
|
+
w.a.debug("ICE gathering partially completed; proceeding", { iceTransportPolicy: o2.getConfiguration().iceTransportPolicy, waitTime: e3 }), a3 == null || a3("ICE gathering partially completed", { sessionId: s2, iceTransportPolicy: o2.getConfiguration().iceTransportPolicy, waitTime: e3 });
|
|
17691
17691
|
break;
|
|
17692
17692
|
}
|
|
17693
17693
|
if (o2.iceGatheringState === "complete") {
|
|
17694
|
-
|
|
17694
|
+
w.a.debug("ICE gathering complete", { iceTransportPolicy: o2.getConfiguration().iceTransportPolicy, waitTime: e3 }), a3 == null || a3("ICE gathering completed", { sessionId: s2, iceTransportPolicy: o2.getConfiguration().iceTransportPolicy, waitTime: e3 });
|
|
17695
17695
|
break;
|
|
17696
17696
|
}
|
|
17697
17697
|
yield Object(u.a)(0.1 * l.a.second);
|
|
@@ -17699,36 +17699,36 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17699
17699
|
const c2 = (t2 = this.peerConnection.getConfiguration().iceServers) !== null && t2 !== void 0 ? t2 : [];
|
|
17700
17700
|
for (const e3 of c2)
|
|
17701
17701
|
e3.credentialType = void 0;
|
|
17702
|
-
const f2 = JSON.stringify(c2), p2 = new
|
|
17703
|
-
return p2.setPayload(JSON.stringify(o2.localDescription)), p2.setSenderId(this.config.baseConfig.localPeerId), p2.setReceiverId(this.config.baseConfig.remotePeerId), p2.setIceServers(f2), p2.setIceTransportPolicy((r2 = this.peerConnection.getConfiguration().iceTransportPolicy) !== null && r2 !== void 0 ? r2 : "all"), p2.setSessionType(
|
|
17702
|
+
const f2 = JSON.stringify(c2), p2 = new N.Signal();
|
|
17703
|
+
return p2.setPayload(JSON.stringify(o2.localDescription)), p2.setSenderId(this.config.baseConfig.localPeerId), p2.setReceiverId(this.config.baseConfig.remotePeerId), p2.setIceServers(f2), p2.setIceTransportPolicy((r2 = this.peerConnection.getConfiguration().iceTransportPolicy) !== null && r2 !== void 0 ? r2 : "all"), p2.setSessionType(this.config.baseConfig.sessionType || N.SessionType.TELEOP), w.a.debug("Sending offer signal with description", { description: p2.getPayload() }), p2;
|
|
17704
17704
|
});
|
|
17705
17705
|
}
|
|
17706
17706
|
getLanOffer() {
|
|
17707
|
-
return
|
|
17707
|
+
return $(this, void 0, void 0, function* () {
|
|
17708
17708
|
const { peerConnection: e2, gotOffer: t2 } = this;
|
|
17709
17709
|
if (!this.config.baseConfig.isLan)
|
|
17710
17710
|
throw new Error('"getLanOffer" method can only be used with LAN connections. Internet connections should call the "getOffer" method.');
|
|
17711
17711
|
if (t2)
|
|
17712
|
-
return void
|
|
17713
|
-
if (this.gotOffer = true,
|
|
17714
|
-
return void
|
|
17712
|
+
return void w.a.debug("Failed to generate offer because gotOffer was already called.");
|
|
17713
|
+
if (this.gotOffer = true, Z(this.peerConnection))
|
|
17714
|
+
return void w.a.debug("Failed to generate offer because the peer connection was inactive.");
|
|
17715
17715
|
yield e2.setLocalDescription(yield e2.createOffer());
|
|
17716
17716
|
const r2 = new Date().getTime();
|
|
17717
17717
|
for (; ; ) {
|
|
17718
17718
|
if (new Date().getTime() - r2 > this.iceGatheringTimeoutMs)
|
|
17719
|
-
return void
|
|
17719
|
+
return void w.a.debug("Failed to generate offer because ICE gathering timed out.");
|
|
17720
17720
|
if (e2.iceGatheringState === "complete")
|
|
17721
17721
|
break;
|
|
17722
17722
|
yield Object(u.a)(0.1 * l.a.second);
|
|
17723
17723
|
}
|
|
17724
17724
|
const n2 = e2.localDescription;
|
|
17725
17725
|
if (n2)
|
|
17726
|
-
return
|
|
17727
|
-
|
|
17726
|
+
return w.a.debug("Sending LAN offer signal with description", { description: n2 }), n2;
|
|
17727
|
+
w.a.error("Failed to generate LAN offer description");
|
|
17728
17728
|
});
|
|
17729
17729
|
}
|
|
17730
17730
|
handleLanAnswer(e2) {
|
|
17731
|
-
return
|
|
17731
|
+
return $(this, void 0, void 0, function* () {
|
|
17732
17732
|
const { peerConnection: t2 } = this;
|
|
17733
17733
|
if (!this.config.baseConfig.isLan)
|
|
17734
17734
|
throw new Error('"handleLanAnswer" method can only be used with LAN connections. Internet connections should call the "handleSignal" method.');
|
|
@@ -17750,14 +17750,14 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17750
17750
|
sendOnChannel(e2, t2) {
|
|
17751
17751
|
let r2;
|
|
17752
17752
|
try {
|
|
17753
|
-
r2 = Object(
|
|
17753
|
+
r2 = Object(k.encode)(JSON.stringify(t2));
|
|
17754
17754
|
} catch (e3) {
|
|
17755
|
-
return void
|
|
17755
|
+
return void w.a.warn("Failed to encode RTC message", { error: e3 });
|
|
17756
17756
|
}
|
|
17757
17757
|
try {
|
|
17758
17758
|
e2.send(r2), this.sessionMetrics && this.sessionMetrics.incrementLocalSent(t2);
|
|
17759
17759
|
} catch (t3) {
|
|
17760
|
-
|
|
17760
|
+
w.a.warn("Failed to send message to channel", { error: t3, channel: e2.label });
|
|
17761
17761
|
}
|
|
17762
17762
|
}
|
|
17763
17763
|
channelNotRecognized(e2) {
|
|
@@ -17766,21 +17766,21 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17766
17766
|
setupChannel(e2) {
|
|
17767
17767
|
e2.onmessage = (t2) => {
|
|
17768
17768
|
if (this.channelNotRecognized(e2))
|
|
17769
|
-
return void
|
|
17769
|
+
return void w.a.warn("Received message on unrecognized data channel.");
|
|
17770
17770
|
let r2;
|
|
17771
17771
|
try {
|
|
17772
|
-
r2 = JSON.parse(Object(
|
|
17772
|
+
r2 = JSON.parse(Object(k.decode)(t2.data));
|
|
17773
17773
|
} catch (t3) {
|
|
17774
|
-
return void
|
|
17774
|
+
return void w.a.warn("Received unparseable message on RTC stream data channel", { error: t3, channel: e2.label });
|
|
17775
17775
|
}
|
|
17776
17776
|
r2.communicationType === "message-chunk" ? this.receiveChannelMessageChunk(e2, r2) : this.receiveChannelMessage(e2, r2);
|
|
17777
17777
|
}, e2.onerror = (t2) => {
|
|
17778
|
-
|
|
17778
|
+
w.a.warn(`Channel error: ${t2.error}`, { error: t2.error, sessionId: this.getSessionId(), channelLabel: e2.label });
|
|
17779
17779
|
}, e2.onopen = () => {
|
|
17780
|
-
|
|
17780
|
+
w.a.debug("Channel opened", { sessionId: this.getSessionId(), channelLabel: e2.label });
|
|
17781
17781
|
}, e2.onclose = () => {
|
|
17782
17782
|
const t2 = { bufferedAmount: e2.bufferedAmount, sessionId: this.getSessionId(), channelLabel: e2.label };
|
|
17783
|
-
this.closeCalled === false ?
|
|
17783
|
+
this.closeCalled === false ? w.a.debug("Unexpected channel closed", t2) : w.a.debug("Channel closed", t2);
|
|
17784
17784
|
};
|
|
17785
17785
|
}
|
|
17786
17786
|
receiveChannelMessage(e2, t2) {
|
|
@@ -17829,7 +17829,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17829
17829
|
try {
|
|
17830
17830
|
return JSON.parse(t3);
|
|
17831
17831
|
} catch (e4) {
|
|
17832
|
-
return void
|
|
17832
|
+
return void w.a.warn("Could not reassemble RTC message chunks");
|
|
17833
17833
|
}
|
|
17834
17834
|
}(r2);
|
|
17835
17835
|
return n2 && this.receiveChannelMessage(e2, n2), void this.reassemblyTable.delete(t2.id);
|
|
@@ -17841,10 +17841,10 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17841
17841
|
const { config: o2 } = this, { baseConfig: i2 } = o2, { remotePeerId: s2 } = i2;
|
|
17842
17842
|
switch (t2.header.stream.streamType) {
|
|
17843
17843
|
case "ping":
|
|
17844
|
-
return this.sendSystemMessage(e2, { type: "pong", timestamp:
|
|
17844
|
+
return this.sendSystemMessage(e2, { type: "pong", timestamp: S(t2.payload.ping) }), true;
|
|
17845
17845
|
case "pong": {
|
|
17846
|
-
const e3 = new Date().getTime() -
|
|
17847
|
-
return this.pingTimeMs = e3,
|
|
17846
|
+
const e3 = new Date().getTime() - S(t2.payload.pong);
|
|
17847
|
+
return this.pingTimeMs = e3, P.aggregate("rtc-ping-time", e3), true;
|
|
17848
17848
|
}
|
|
17849
17849
|
case "streams-info": {
|
|
17850
17850
|
const { sessionMetrics: e3 } = this, o3 = (r2 = t2.payload.streamsInfo) === null || r2 === void 0 ? void 0 : r2.timestamp;
|
|
@@ -17881,15 +17881,15 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17881
17881
|
}(i2, s2));
|
|
17882
17882
|
}
|
|
17883
17883
|
isLatestMessage(e2) {
|
|
17884
|
-
const t2 =
|
|
17884
|
+
const t2 = G(e2.header.stream), r2 = (this.streamLatestTimestamp.get(t2) || 0) <= e2.header.created;
|
|
17885
17885
|
return r2 && this.streamLatestTimestamp.set(t2, e2.header.created), r2;
|
|
17886
17886
|
}
|
|
17887
17887
|
}
|
|
17888
|
-
function
|
|
17888
|
+
function X(e2) {
|
|
17889
17889
|
var t2, r2;
|
|
17890
17890
|
return { userId: (t2 = e2.getUserId()) === null || t2 === void 0 ? void 0 : t2.getValue(), deviceId: (r2 = e2.getDeviceId()) === null || r2 === void 0 ? void 0 : r2.getValue(), organizationId: e2.getOrganizationId(), id: e2.getPeerId(), capabilities: [], capabilitySet: {} };
|
|
17891
17891
|
}
|
|
17892
|
-
var
|
|
17892
|
+
var J = function(e2, t2, r2, n2) {
|
|
17893
17893
|
return new (r2 || (r2 = Promise))(function(o2, i2) {
|
|
17894
17894
|
function s2(e3) {
|
|
17895
17895
|
try {
|
|
@@ -17914,80 +17914,80 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
17914
17914
|
l2((n2 = n2.apply(e2, t2 || [])).next());
|
|
17915
17915
|
});
|
|
17916
17916
|
};
|
|
17917
|
-
class
|
|
17917
|
+
class Q {
|
|
17918
17918
|
constructor(e2) {
|
|
17919
17919
|
this.config = e2, this.grpcCallDeadline = 5 * l.a.second, this.refreshIntervalDelayMs = 2 * l.a.second, this.iceServersTtl = 30 * l.a.minute, this.connections = [], this.localConnections = [], this.isConnectionInitiator = /* @__PURE__ */ new Map(), this.isOutgoingConnection = /* @__PURE__ */ new Map(), this.peerDataChannelListeners = [];
|
|
17920
17920
|
const { refreshIntervalDelayMs: t2 } = this;
|
|
17921
|
-
this.refreshInterval =
|
|
17921
|
+
this.refreshInterval = T({ func: () => J(this, void 0, void 0, function* () {
|
|
17922
17922
|
try {
|
|
17923
17923
|
yield this.update();
|
|
17924
17924
|
} catch (e3) {
|
|
17925
|
-
|
|
17925
|
+
w.a.warn("RTC refresh failed", { error: e3 });
|
|
17926
17926
|
}
|
|
17927
17927
|
}), delay: t2, immediate: true });
|
|
17928
17928
|
}
|
|
17929
17929
|
send(e2, t2, r2) {
|
|
17930
17930
|
const n2 = this.getActiveConnection(e2);
|
|
17931
|
-
n2 ? n2.isReady() ? n2.send(t2, r2) :
|
|
17931
|
+
n2 ? n2.isReady() ? n2.send(t2, r2) : w.a.warn("Send called with unready connection.") : w.a.warn("Send called with no connection.");
|
|
17932
17932
|
}
|
|
17933
17933
|
controlRemoteStream(e2, t2) {
|
|
17934
17934
|
const r2 = this.getActiveConnection(e2);
|
|
17935
|
-
r2 ? r2.isReady() ? r2.controlRemoteStream(t2) :
|
|
17935
|
+
r2 ? r2.isReady() ? r2.controlRemoteStream(t2) : w.a.warn("controlRemoteStream called with unready connection.") : w.a.warn("controlRemoteStream called with no connection.");
|
|
17936
17936
|
}
|
|
17937
17937
|
getLocalPeer() {
|
|
17938
|
-
return
|
|
17938
|
+
return J(this, void 0, void 0, function* () {
|
|
17939
17939
|
for (; !this.localPeer; )
|
|
17940
17940
|
yield Object(u.a)(0.1 * l.a.second);
|
|
17941
|
-
return
|
|
17941
|
+
return X(this.localPeer);
|
|
17942
17942
|
});
|
|
17943
17943
|
}
|
|
17944
17944
|
connect(e2, t2) {
|
|
17945
17945
|
var r2, n2, o2;
|
|
17946
|
-
return
|
|
17946
|
+
return J(this, void 0, void 0, function* () {
|
|
17947
17947
|
if (this.config.lanOnlyMode === true)
|
|
17948
17948
|
throw new Error("connect method called in local only mode.");
|
|
17949
17949
|
const { track: i2, signalingClient: s2 } = this.config, { localPeer: a3, receiveSignalStream: l2, iceServers: u2 } = this;
|
|
17950
17950
|
if (!a3 || !l2 || !u2)
|
|
17951
|
-
return void
|
|
17951
|
+
return void w.a.warn("Connect called prior to local peer, receiveSignalStream, and ICE servers ready");
|
|
17952
17952
|
if (this.getActiveConnection(e2))
|
|
17953
|
-
return void
|
|
17953
|
+
return void w.a.warn("Connect called for peer with existing connection.");
|
|
17954
17954
|
if (this.isOutgoingConnection.get(e2))
|
|
17955
|
-
return void
|
|
17955
|
+
return void w.a.warn("Connect called for peer with an existing outgoing connection offer.");
|
|
17956
17956
|
this.isOutgoingConnection.set(e2, true);
|
|
17957
|
-
const g2 = new
|
|
17957
|
+
const g2 = new K(yield this.createRTCPeerConnection(u2, t2), { baseConfig: { isOffer: true, isLan: false, receive: (e3, t3) => this.config.receive(e3, t3), onStreamsInfoUpdate: this.config.onStreamsInfoUpdate ? (e3, t3) => {
|
|
17958
17958
|
var r3, n3;
|
|
17959
17959
|
return (n3 = (r3 = this.config).onStreamsInfoUpdate) === null || n3 === void 0 ? void 0 : n3.call(r3, e3, t3);
|
|
17960
|
-
} : void 0, track: this.config.lanOnlyMode ? void 0 : this.config.track, localUserId: (r2 = a3.getUserId()) === null || r2 === void 0 ? void 0 : r2.getValue(), localPeerId: a3.getPeerId(), remotePeerId: e2 }, remoteConfig: {} }, (t3) => this.onCustomDataChannel(e2, t3)), c2 = yield g2.getOffer();
|
|
17960
|
+
} : void 0, track: this.config.lanOnlyMode ? void 0 : this.config.track, localUserId: (r2 = a3.getUserId()) === null || r2 === void 0 ? void 0 : r2.getValue(), localPeerId: a3.getPeerId(), remotePeerId: e2, sessionType: t2 == null ? void 0 : t2.sessionType }, remoteConfig: {} }, (t3) => this.onCustomDataChannel(e2, t3)), c2 = yield g2.getOffer();
|
|
17961
17961
|
if (!c2)
|
|
17962
|
-
return
|
|
17963
|
-
|
|
17964
|
-
const f2 = new
|
|
17962
|
+
return w.a.error("Failed to generate offer."), void this.isOutgoingConnection.delete(e2);
|
|
17963
|
+
w.a.debug("Sending offer."), i2 == null || i2("Sending offer", c2);
|
|
17964
|
+
const f2 = new N.SendSignalRequest();
|
|
17965
17965
|
f2.setSignal(c2);
|
|
17966
|
-
const p2 = yield (() =>
|
|
17966
|
+
const p2 = yield (() => J(this, void 0, void 0, function* () {
|
|
17967
17967
|
try {
|
|
17968
17968
|
return yield s2.sendSignal(f2, yield this.getMetadata({}));
|
|
17969
17969
|
} catch (e3) {
|
|
17970
|
-
|
|
17970
|
+
w.a.warn("Error when sending signal", { error: e3 });
|
|
17971
17971
|
}
|
|
17972
17972
|
}))();
|
|
17973
17973
|
if (!this.isOutgoingConnection.get(e2))
|
|
17974
|
-
return void
|
|
17975
|
-
|
|
17974
|
+
return void w.a.debug("No offer set after receiving offer signal response.");
|
|
17975
|
+
w.a.debug("Offer sent.");
|
|
17976
17976
|
const h2 = (n2 = p2 == null ? void 0 : p2.getSessionId()) === null || n2 === void 0 ? void 0 : n2.getValue(), d2 = (o2 = p2 == null ? void 0 : p2.getSessionCreatedTimestamp()) === null || o2 === void 0 ? void 0 : o2.getValue();
|
|
17977
|
-
return h2 && d2 ? (g2.setSessionId(h2), g2.setSessionCreatedTimestamp(d2), this.isOutgoingConnection.delete(e2), this.connections.push(g2), this.isConnectionInitiator.set(g2, true), this.setupHandlers(g2), h2) : (
|
|
17977
|
+
return h2 && d2 ? (g2.setSessionId(h2), g2.setSessionCreatedTimestamp(d2), this.isOutgoingConnection.delete(e2), this.connections.push(g2), this.isConnectionInitiator.set(g2, true), this.setupHandlers(g2), h2) : (w.a.warn("No session ID or no session created timestamp on send signal response."), void this.isOutgoingConnection.delete(e2));
|
|
17978
17978
|
});
|
|
17979
17979
|
}
|
|
17980
17980
|
connectLan(e2) {
|
|
17981
17981
|
var t2, r2;
|
|
17982
|
-
return
|
|
17983
|
-
const n2 = new
|
|
17982
|
+
return J(this, void 0, void 0, function* () {
|
|
17983
|
+
const n2 = new B(e2), o2 = new K(yield this.createRTCPeerConnection([]), { baseConfig: { isOffer: true, isLan: true, receive: (e3, t3) => this.config.receive(e3, t3), onStreamsInfoUpdate: this.config.onStreamsInfoUpdate ? (e3, t3) => {
|
|
17984
17984
|
var r3, n3;
|
|
17985
17985
|
return (n3 = (r3 = this.config).onStreamsInfoUpdate) === null || n3 === void 0 ? void 0 : n3.call(r3, e3, t3);
|
|
17986
17986
|
} : void 0, track: this.config.lanOnlyMode ? void 0 : this.config.track, localUserId: (r2 = (t2 = this.localPeer) === null || t2 === void 0 ? void 0 : t2.getUserId()) === null || r2 === void 0 ? void 0 : r2.getValue(), localPeerId: "lan_client", remotePeerId: e2 } }, (t3) => this.onCustomDataChannel(e2, t3)), i2 = yield o2.getLanOffer();
|
|
17987
17987
|
if (!i2)
|
|
17988
|
-
return
|
|
17988
|
+
return w.a.warn("Could not generate LAN offer"), false;
|
|
17989
17989
|
const s2 = yield n2.postLanRtcOffer({ offer: JSON.stringify(i2) }), a3 = new RTCSessionDescription(JSON.parse(s2.answer));
|
|
17990
|
-
return yield o2.handleLanAnswer(a3), this.localConnections.push(o2), this.isConnectionInitiator.set(o2, true), Object(
|
|
17990
|
+
return yield o2.handleLanAnswer(a3), this.localConnections.push(o2), this.isConnectionInitiator.set(o2, true), Object(D.v4)();
|
|
17991
17991
|
});
|
|
17992
17992
|
}
|
|
17993
17993
|
getConnections() {
|
|
@@ -18017,27 +18017,27 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18017
18017
|
return t2 ? t2.isReady() ? "connected" : "connecting" : "disconnected";
|
|
18018
18018
|
}
|
|
18019
18019
|
getConnectionStatsInfo(e2) {
|
|
18020
|
-
return
|
|
18020
|
+
return J(this, void 0, void 0, function* () {
|
|
18021
18021
|
const t2 = this.getActiveConnection(e2);
|
|
18022
18022
|
if (t2)
|
|
18023
18023
|
return yield t2.getConnectionStatsInfo();
|
|
18024
18024
|
});
|
|
18025
18025
|
}
|
|
18026
18026
|
disconnect(e2) {
|
|
18027
|
-
return
|
|
18027
|
+
return J(this, void 0, void 0, function* () {
|
|
18028
18028
|
const t2 = this.getActiveConnection(e2);
|
|
18029
18029
|
t2 && (yield t2.close());
|
|
18030
18030
|
});
|
|
18031
18031
|
}
|
|
18032
18032
|
getPeers() {
|
|
18033
|
-
return
|
|
18033
|
+
return J(this, void 0, void 0, function* () {
|
|
18034
18034
|
if (this.config.lanOnlyMode)
|
|
18035
18035
|
throw new Error("getPeers method cannot be used in local-only mode.");
|
|
18036
|
-
const { signalingClient: e2 } = this.config, t2 = yield (() =>
|
|
18036
|
+
const { signalingClient: e2 } = this.config, t2 = yield (() => J(this, void 0, void 0, function* () {
|
|
18037
18037
|
try {
|
|
18038
|
-
return yield e2.getPeers(new
|
|
18038
|
+
return yield e2.getPeers(new N.GetPeersRequest(), yield this.getMetadata({}));
|
|
18039
18039
|
} catch (e3) {
|
|
18040
|
-
|
|
18040
|
+
w.a.warn("Error when getting peers", { error: e3 });
|
|
18041
18041
|
}
|
|
18042
18042
|
}))();
|
|
18043
18043
|
if (!t2)
|
|
@@ -18049,18 +18049,18 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18049
18049
|
var t3, r3;
|
|
18050
18050
|
return (r3 = (t3 = e3.getPeerCreatedTimestamp()) === null || t3 === void 0 ? void 0 : t3.getValue()) !== null && r3 !== void 0 ? r3 : 0;
|
|
18051
18051
|
};
|
|
18052
|
-
return r2.sort((e3, t3) => n2(t3) - n2(e3)).map((e3) =>
|
|
18052
|
+
return r2.sort((e3, t3) => n2(t3) - n2(e3)).map((e3) => X(e3));
|
|
18053
18053
|
});
|
|
18054
18054
|
}
|
|
18055
18055
|
getSessions() {
|
|
18056
|
-
return
|
|
18056
|
+
return J(this, void 0, void 0, function* () {
|
|
18057
18057
|
if (this.config.lanOnlyMode)
|
|
18058
18058
|
throw new Error("getPeers method cannot be used in local-only mode.");
|
|
18059
|
-
const { signalingClient: e2 } = this.config, t2 = yield (() =>
|
|
18059
|
+
const { signalingClient: e2 } = this.config, t2 = yield (() => J(this, void 0, void 0, function* () {
|
|
18060
18060
|
try {
|
|
18061
|
-
return yield e2.getPeers(new
|
|
18061
|
+
return yield e2.getPeers(new N.GetPeersRequest(), yield this.getMetadata({}));
|
|
18062
18062
|
} catch (e3) {
|
|
18063
|
-
|
|
18063
|
+
w.a.warn("Error when getting peers", { error: e3 });
|
|
18064
18064
|
}
|
|
18065
18065
|
}))();
|
|
18066
18066
|
if (!t2)
|
|
@@ -18075,19 +18075,19 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18075
18075
|
const t2 = this.getActiveConnection(e2);
|
|
18076
18076
|
if (t2)
|
|
18077
18077
|
return t2.getPing();
|
|
18078
|
-
|
|
18078
|
+
w.a.warn("Attempted to get ping time from inactive peer.");
|
|
18079
18079
|
}
|
|
18080
18080
|
getLastMessageTimestamp(e2) {
|
|
18081
18081
|
const t2 = this.getActiveConnection(e2);
|
|
18082
18082
|
if (t2)
|
|
18083
18083
|
return t2.getLastMessageTimestamp();
|
|
18084
|
-
|
|
18084
|
+
w.a.warn("Attempted to get last message time from inactive peer.");
|
|
18085
18085
|
}
|
|
18086
18086
|
getSessionMetricsMessageCounts(e2) {
|
|
18087
18087
|
const t2 = this.getActiveConnection(e2);
|
|
18088
18088
|
if (t2)
|
|
18089
18089
|
return t2.getSessionMetricsMessageCounts();
|
|
18090
|
-
|
|
18090
|
+
w.a.warn("Attempted to get session metrics counts from inactive peer.");
|
|
18091
18091
|
}
|
|
18092
18092
|
isReady() {
|
|
18093
18093
|
if (this.config.lanOnlyMode)
|
|
@@ -18096,8 +18096,8 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18096
18096
|
return !!(e2 && t2 && r2);
|
|
18097
18097
|
}
|
|
18098
18098
|
shutdown() {
|
|
18099
|
-
return
|
|
18100
|
-
|
|
18099
|
+
return J(this, void 0, void 0, function* () {
|
|
18100
|
+
w.a.info("Shutdown called on RTC client"), yield this.refreshInterval.stop(), this.receiveSignalStream && this.receiveSignalStream.cancel();
|
|
18101
18101
|
const e2 = this.connections;
|
|
18102
18102
|
this.connections = [], yield this.closeConnections(e2);
|
|
18103
18103
|
const { localPeer: t2 } = this;
|
|
@@ -18106,23 +18106,23 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18106
18106
|
if (this.config.lanOnlyMode)
|
|
18107
18107
|
return;
|
|
18108
18108
|
const { signalingClient: r2 } = this.config;
|
|
18109
|
-
yield (() =>
|
|
18109
|
+
yield (() => J(this, void 0, void 0, function* () {
|
|
18110
18110
|
try {
|
|
18111
|
-
const e3 = new
|
|
18111
|
+
const e3 = new N.DeletePeerRequest();
|
|
18112
18112
|
e3.setPeerId(t2.getPeerId()), yield r2.deletePeer(e3, yield this.getMetadata({}));
|
|
18113
18113
|
} catch (e3) {
|
|
18114
|
-
return void
|
|
18114
|
+
return void w.a.warn("Error deleting local peer", { error: e3 });
|
|
18115
18115
|
}
|
|
18116
18116
|
}))();
|
|
18117
18117
|
});
|
|
18118
18118
|
}
|
|
18119
18119
|
createPeer() {
|
|
18120
|
-
return
|
|
18120
|
+
return J(this, void 0, void 0, function* () {
|
|
18121
18121
|
if (this.config.lanOnlyMode)
|
|
18122
18122
|
throw new Error("createPeer method cannot be used in local-only mode.");
|
|
18123
|
-
const { signalingClient: e2 } = this.config, t2 = yield (() =>
|
|
18123
|
+
const { signalingClient: e2 } = this.config, t2 = yield (() => J(this, void 0, void 0, function* () {
|
|
18124
18124
|
try {
|
|
18125
|
-
return yield e2.createPeer(new
|
|
18125
|
+
return yield e2.createPeer(new N.CreatePeerRequest(), yield this.getMetadata({}));
|
|
18126
18126
|
} catch (e3) {
|
|
18127
18127
|
throw new Error(`Was not able to create peer: ${JSON.stringify(e3)}`);
|
|
18128
18128
|
}
|
|
@@ -18133,7 +18133,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18133
18133
|
});
|
|
18134
18134
|
}
|
|
18135
18135
|
createReceiveSignalStream() {
|
|
18136
|
-
return
|
|
18136
|
+
return J(this, void 0, void 0, function* () {
|
|
18137
18137
|
if (this.config.lanOnlyMode)
|
|
18138
18138
|
throw new Error("createReceiveSignalStream method cannot be used in local-only mode.");
|
|
18139
18139
|
const { signalingClient: e2 } = this.config, { localPeer: t2, iceServers: r2 } = this;
|
|
@@ -18141,9 +18141,9 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18141
18141
|
return;
|
|
18142
18142
|
const { receiveSignalStream: n2 } = this;
|
|
18143
18143
|
n2 && n2.cancel();
|
|
18144
|
-
const o2 = new
|
|
18144
|
+
const o2 = new N.ReceiveSignalStreamRequest();
|
|
18145
18145
|
o2.setPeerId(t2.getPeerId());
|
|
18146
|
-
const i2 = yield (() =>
|
|
18146
|
+
const i2 = yield (() => J(this, void 0, void 0, function* () {
|
|
18147
18147
|
try {
|
|
18148
18148
|
return e2.receiveSignalStream(o2, yield this.getMetadata({ hasDeadline: false }));
|
|
18149
18149
|
} catch (e3) {
|
|
@@ -18152,26 +18152,26 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18152
18152
|
}))();
|
|
18153
18153
|
if (!i2)
|
|
18154
18154
|
throw new Error("Response did not provide stream.");
|
|
18155
|
-
return i2.on("data", (e3) =>
|
|
18155
|
+
return i2.on("data", (e3) => J(this, void 0, void 0, function* () {
|
|
18156
18156
|
var n3, o3, i3, s2;
|
|
18157
18157
|
const a3 = e3.getSignal(), l2 = (n3 = a3 == null ? void 0 : a3.getSessionId()) === null || n3 === void 0 ? void 0 : n3.getValue(), u2 = a3 == null ? void 0 : a3.getSenderId(), g2 = a3 == null ? void 0 : a3.getReceiverId(), c2 = (o3 = a3 == null ? void 0 : a3.getSessionCreatedTimestamp()) === null || o3 === void 0 ? void 0 : o3.getValue();
|
|
18158
18158
|
if (!(a3 && l2 && u2 && g2 && c2))
|
|
18159
|
-
return void
|
|
18159
|
+
return void w.a.warn("Received signal with missing information.");
|
|
18160
18160
|
const f2 = this.getActiveConnection(u2);
|
|
18161
18161
|
if (f2)
|
|
18162
18162
|
if (f2.getSessionId() !== l2) {
|
|
18163
|
-
if (
|
|
18163
|
+
if (w.a.debug("Received signal: different session for a peer we're already connected to."), (f2.getSessionCreatedTimestamp() || 0) > c2)
|
|
18164
18164
|
return;
|
|
18165
|
-
const e4 = new
|
|
18165
|
+
const e4 = new K(yield this.createRTCPeerConnection(r2), { baseConfig: { isOffer: false, isLan: false, receive: (e5, t3) => this.config.receive(e5, t3), onStreamsInfoUpdate: this.config.onStreamsInfoUpdate ? (e5, t3) => {
|
|
18166
18166
|
var r3, n4;
|
|
18167
18167
|
return (n4 = (r3 = this.config).onStreamsInfoUpdate) === null || n4 === void 0 ? void 0 : n4.call(r3, e5, t3);
|
|
18168
18168
|
} : void 0, track: this.config.lanOnlyMode ? void 0 : this.config.track, localPeerId: t2.getPeerId(), localUserId: (s2 = t2.getUserId()) === null || s2 === void 0 ? void 0 : s2.getValue(), remotePeerId: u2 }, remoteConfig: { sessionId: l2, sessionCreatedTimestamp: c2 } }, (e5) => this.onCustomDataChannel(u2, e5));
|
|
18169
18169
|
yield e4.handleSignal(a3), this.connections.push(e4);
|
|
18170
18170
|
} else
|
|
18171
|
-
|
|
18171
|
+
w.a.debug("Received signal: for an existing connection."), yield f2.handleSignal(a3);
|
|
18172
18172
|
else {
|
|
18173
|
-
|
|
18174
|
-
const e4 = new
|
|
18173
|
+
w.a.debug("Received signal: new connection.");
|
|
18174
|
+
const e4 = new K(yield this.createRTCPeerConnection(r2), { baseConfig: { isOffer: false, isLan: false, receive: (e5, t3) => this.config.receive(e5, t3), onStreamsInfoUpdate: this.config.onStreamsInfoUpdate ? (e5, t3) => {
|
|
18175
18175
|
var r3, n4;
|
|
18176
18176
|
return (n4 = (r3 = this.config).onStreamsInfoUpdate) === null || n4 === void 0 ? void 0 : n4.call(r3, e5, t3);
|
|
18177
18177
|
} : void 0, track: this.config.lanOnlyMode ? void 0 : this.config.track, localPeerId: t2.getPeerId(), localUserId: (i3 = t2.getUserId()) === null || i3 === void 0 ? void 0 : i3.getValue(), remotePeerId: u2 }, remoteConfig: { sessionId: l2, sessionCreatedTimestamp: c2 } }, (e5) => this.onCustomDataChannel(u2, e5));
|
|
@@ -18181,16 +18181,16 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18181
18181
|
i2.cancel(), this.receiveSignalStream = void 0;
|
|
18182
18182
|
}), i2.on("error", (e3) => {
|
|
18183
18183
|
switch (e3.code) {
|
|
18184
|
-
case
|
|
18185
|
-
case
|
|
18186
|
-
case
|
|
18187
|
-
|
|
18184
|
+
case L.StatusCode.CANCELLED:
|
|
18185
|
+
case L.StatusCode.UNAVAILABLE:
|
|
18186
|
+
case L.StatusCode.UNKNOWN:
|
|
18187
|
+
w.a.debug("Receive signal stream error", { error: e3 });
|
|
18188
18188
|
break;
|
|
18189
|
-
case
|
|
18190
|
-
|
|
18189
|
+
case L.StatusCode.UNAUTHENTICATED:
|
|
18190
|
+
w.a.warn("Receive signal stream error", { error: e3 });
|
|
18191
18191
|
break;
|
|
18192
18192
|
default:
|
|
18193
|
-
|
|
18193
|
+
w.a.error("Receive signal stream error", { error: e3 });
|
|
18194
18194
|
}
|
|
18195
18195
|
i2.cancel(), this.receiveSignalStream = void 0;
|
|
18196
18196
|
}), this.receiveSignalStream = i2;
|
|
@@ -18198,7 +18198,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18198
18198
|
}
|
|
18199
18199
|
createRTCPeerConnection(e2, t2) {
|
|
18200
18200
|
var r2;
|
|
18201
|
-
return
|
|
18201
|
+
return J(this, void 0, void 0, function* () {
|
|
18202
18202
|
const n2 = t2 == null ? void 0 : t2.rtcIceTransportPolicies, o2 = (t2 == null ? void 0 : t2.rtcIceServerProtocol) ? [t2 == null ? void 0 : t2.rtcIceServerProtocol] : void 0, i2 = e2.map((e3) => Object.assign(Object.assign({}, e3), { urls: typeof e3.urls == "string" ? [e3.urls] : e3.urls })).map((e3) => Object.assign(Object.assign({}, e3), { urls: e3.urls.filter((e4) => {
|
|
18203
18203
|
const t3 = (n2 === void 0 || n2.some((t4) => ((e5, t5) => {
|
|
18204
18204
|
switch (t5) {
|
|
@@ -18208,7 +18208,7 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18208
18208
|
return /^turns?:/.test(e5);
|
|
18209
18209
|
}
|
|
18210
18210
|
})(e4, t4))) && (o2 === void 0 || o2.some((t4) => ((e5, t5) => e5.endsWith(`transport=${t5}`))(e4, t4)));
|
|
18211
|
-
return t3 ||
|
|
18211
|
+
return t3 || w.a.debug(`Ignoring ICE server: ${e4}`), t3;
|
|
18212
18212
|
}) })).filter(({ urls: e3 }) => e3.filter((e4) => e4).length > 0), s2 = (r2 = this.config.alternateRTCPeerConnection) !== null && r2 !== void 0 ? r2 : window.RTCPeerConnection;
|
|
18213
18213
|
if (!s2)
|
|
18214
18214
|
throw new Error("RTCPeerConnection class not found. WebRTC must be enabled.");
|
|
@@ -18216,12 +18216,12 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18216
18216
|
});
|
|
18217
18217
|
}
|
|
18218
18218
|
closeConnections(e2) {
|
|
18219
|
-
return
|
|
18220
|
-
const t2 = yield
|
|
18219
|
+
return J(this, void 0, void 0, function* () {
|
|
18220
|
+
const t2 = yield v(e2.map((e3) => J(this, void 0, void 0, function* () {
|
|
18221
18221
|
yield e3.close();
|
|
18222
18222
|
})));
|
|
18223
18223
|
for (const e3 of t2)
|
|
18224
|
-
|
|
18224
|
+
w.a.warn("Request to close session failed", { error: e3 });
|
|
18225
18225
|
});
|
|
18226
18226
|
}
|
|
18227
18227
|
getActiveConnection(e2) {
|
|
@@ -18229,21 +18229,21 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18229
18229
|
}
|
|
18230
18230
|
update() {
|
|
18231
18231
|
var e2;
|
|
18232
|
-
return
|
|
18232
|
+
return J(this, void 0, void 0, function* () {
|
|
18233
18233
|
if (this.localConnections = this.localConnections.filter((e3) => e3.isActive()), this.config.lanOnlyMode)
|
|
18234
18234
|
return;
|
|
18235
18235
|
const { signalingClient: t2 } = this.config;
|
|
18236
18236
|
if (!this.localPeer || !this.receiveSignalStream || !this.iceServers)
|
|
18237
18237
|
return this.localPeer || (yield this.createPeer()), this.iceServers || (yield this.updateIceServers()), void (this.receiveSignalStream || (yield this.createReceiveSignalStream()));
|
|
18238
18238
|
yield this.closeConnections(this.connections.filter((e3) => !e3.isActive())), this.connections = this.connections.filter((e3) => e3.isActive());
|
|
18239
|
-
const { localPeer: r2 } = this, n2 = this.connections.filter((e3) => e3.getSessionId).map((e3) =>
|
|
18239
|
+
const { localPeer: r2 } = this, n2 = this.connections.filter((e3) => e3.getSessionId).map((e3) => S(e3.getSessionId()));
|
|
18240
18240
|
r2.setSessionIdsList(n2);
|
|
18241
|
-
const o2 = new
|
|
18241
|
+
const o2 = new N.RefreshPeerRequest();
|
|
18242
18242
|
o2.setPeer(r2);
|
|
18243
18243
|
try {
|
|
18244
18244
|
yield t2.refreshPeer(o2, yield this.getMetadata({}));
|
|
18245
18245
|
} catch (e3) {
|
|
18246
|
-
e3.code ===
|
|
18246
|
+
e3.code === L.StatusCode.NOT_FOUND ? (w.a.warn("Peer expired, creating new peer", { peerId: r2.getPeerId() }), yield this.reset()) : w.a.warn("Error calling RefreshPeer", { error: e3 });
|
|
18247
18247
|
}
|
|
18248
18248
|
const i2 = yield this.getPeers();
|
|
18249
18249
|
for (const t3 of this.connections)
|
|
@@ -18251,40 +18251,40 @@ Found: ${e2.toString().split("\n")[0]}
|
|
|
18251
18251
|
});
|
|
18252
18252
|
}
|
|
18253
18253
|
reset() {
|
|
18254
|
-
return
|
|
18254
|
+
return J(this, void 0, void 0, function* () {
|
|
18255
18255
|
yield this.closeConnections(this.connections), this.connections = [], this.isOutgoingConnection = /* @__PURE__ */ new Map(), yield this.createPeer(), yield this.createReceiveSignalStream();
|
|
18256
18256
|
});
|
|
18257
18257
|
}
|
|
18258
18258
|
updateIceServers() {
|
|
18259
|
-
return
|
|
18259
|
+
return J(this, void 0, void 0, function* () {
|
|
18260
18260
|
if (this.config.lanOnlyMode)
|
|
18261
18261
|
return;
|
|
18262
18262
|
const { iceServersLastUpdate: e2, iceServersTtl: t2 } = this, r2 = new Date().getTime();
|
|
18263
18263
|
if (!e2 || r2 - e2 > t2)
|
|
18264
18264
|
try {
|
|
18265
|
-
const e3 = (yield this.config.signalingClient.getIceServers(new
|
|
18265
|
+
const e3 = (yield this.config.signalingClient.getIceServers(new N.GetIceServersRequest(), yield this.getMetadata({}))).getIceServers();
|
|
18266
18266
|
this.iceServers = JSON.parse(e3), this.iceServersLastUpdate = r2;
|
|
18267
18267
|
} catch (e3) {
|
|
18268
|
-
|
|
18268
|
+
w.a.warn("Error in updateIceServers", { error: e3 });
|
|
18269
18269
|
}
|
|
18270
18270
|
});
|
|
18271
18271
|
}
|
|
18272
18272
|
setupHandlers(e2) {
|
|
18273
18273
|
const { peerConnection: t2 } = e2, r2 = e2.getSessionCreatedTimestamp();
|
|
18274
|
-
t2.onconnectionstatechange = () =>
|
|
18274
|
+
t2.onconnectionstatechange = () => J(this, void 0, void 0, function* () {
|
|
18275
18275
|
const e3 = t2.connectionState;
|
|
18276
18276
|
if (r2)
|
|
18277
18277
|
switch (e3) {
|
|
18278
18278
|
case "connected":
|
|
18279
|
-
|
|
18279
|
+
P.aggregate("rtc-connect-time", new Date().getTime() - r2);
|
|
18280
18280
|
break;
|
|
18281
18281
|
case "failed":
|
|
18282
|
-
|
|
18282
|
+
P.increment("rtc-connect-failed");
|
|
18283
18283
|
}
|
|
18284
18284
|
});
|
|
18285
18285
|
}
|
|
18286
18286
|
getMetadata(e2) {
|
|
18287
|
-
return
|
|
18287
|
+
return J(this, void 0, void 0, function* () {
|
|
18288
18288
|
if (this.config.lanOnlyMode)
|
|
18289
18289
|
throw new Error("getMetadata method cannot be called in local-only mode");
|
|
18290
18290
|
const { getToken: t2 } = this.config, { grpcCallDeadline: r2 } = this, { hasDeadline: n2 } = e2, o2 = n2 === false ? void 0 : new Date().getTime() + r2;
|