livekit-client 2.19.0 → 2.19.2
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/livekit-client.e2ee.worker.js +1 -1
- package/dist/livekit-client.e2ee.worker.js.map +1 -1
- package/dist/livekit-client.e2ee.worker.mjs +181 -122
- package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
- package/dist/livekit-client.esm.mjs +517 -426
- package/dist/livekit-client.esm.mjs.map +1 -1
- package/dist/livekit-client.pt.worker.js +1 -1
- package/dist/livekit-client.pt.worker.js.map +1 -1
- package/dist/livekit-client.pt.worker.mjs +129 -95
- package/dist/livekit-client.pt.worker.mjs.map +1 -1
- package/dist/livekit-client.umd.js +1 -1
- package/dist/livekit-client.umd.js.map +1 -1
- package/dist/src/e2ee/worker/FrameCryptor.d.ts +12 -2
- package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts +8 -0
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/rpc/client/RpcClientManager.d.ts.map +1 -1
- package/dist/src/room/utils.d.ts +1 -0
- package/dist/src/room/utils.d.ts.map +1 -1
- package/dist/ts4.2/e2ee/worker/FrameCryptor.d.ts +11 -1
- package/dist/ts4.2/room/RTCEngine.d.ts +8 -0
- package/dist/ts4.2/room/utils.d.ts +1 -0
- package/package.json +10 -8
- package/src/api/SignalClient.ts +1 -0
- package/src/e2ee/worker/FrameCryptor.ts +42 -7
- package/src/room/RTCEngine.ts +48 -20
- package/src/room/Room.test.ts +99 -1
- package/src/room/Room.ts +24 -7
- package/src/room/rpc/client/RpcClientManager.ts +5 -2
- package/src/room/utils.ts +5 -0
|
@@ -1000,16 +1000,15 @@ function int64ToString(lo, hi) {
|
|
|
1000
1000
|
* See https://github.com/protocolbuffers/protobuf-javascript/blob/a428c58273abad07c66071d9753bc4d1289de426/experimental/runtime/int64.js#L10
|
|
1001
1001
|
*/
|
|
1002
1002
|
function uInt64ToString(lo, hi) {
|
|
1003
|
-
({
|
|
1004
|
-
lo,
|
|
1005
|
-
hi
|
|
1006
|
-
} = toUnsigned(lo, hi));
|
|
1007
1003
|
// Skip the expensive conversion if the number is small enough to use the
|
|
1008
1004
|
// built-in conversions.
|
|
1009
1005
|
// Number.MAX_SAFE_INTEGER = 0x001FFFFF FFFFFFFF, thus any number with
|
|
1010
1006
|
// highBits <= 0x1FFFFF can be safely expressed with a double and retain
|
|
1011
1007
|
// integer precision.
|
|
1012
1008
|
// Proven by: Number.isSafeInteger(0x1FFFFF * 2**32 + 0xFFFFFFFF) == true.
|
|
1009
|
+
var _toUnsigned = toUnsigned(lo, hi);
|
|
1010
|
+
lo = _toUnsigned.lo;
|
|
1011
|
+
hi = _toUnsigned.hi;
|
|
1013
1012
|
if (hi <= 0x1FFFFF) {
|
|
1014
1013
|
return String(TWO_PWR_32_DBL * hi + lo);
|
|
1015
1014
|
}
|
|
@@ -1430,19 +1429,55 @@ function isScalarZeroValue(type, value) {
|
|
|
1430
1429
|
}
|
|
1431
1430
|
}
|
|
1432
1431
|
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1432
|
+
function _arrayLikeToArray(r, a) {
|
|
1433
|
+
(null == a || a > r.length) && (a = r.length);
|
|
1434
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
1435
|
+
return n;
|
|
1436
|
+
}
|
|
1437
|
+
function _arrayWithHoles(r) {
|
|
1438
|
+
if (Array.isArray(r)) return r;
|
|
1439
|
+
}
|
|
1440
|
+
function _iterableToArrayLimit(r, l) {
|
|
1441
|
+
var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
|
|
1442
|
+
if (null != t) {
|
|
1443
|
+
var e,
|
|
1444
|
+
n,
|
|
1445
|
+
i,
|
|
1446
|
+
u,
|
|
1447
|
+
a = [],
|
|
1448
|
+
f = true,
|
|
1449
|
+
o = false;
|
|
1450
|
+
try {
|
|
1451
|
+
if (i = (t = t.call(r)).next, 0 === l) {
|
|
1452
|
+
if (Object(t) !== t) return;
|
|
1453
|
+
f = !1;
|
|
1454
|
+
} else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
|
|
1455
|
+
} catch (r) {
|
|
1456
|
+
o = true, n = r;
|
|
1457
|
+
} finally {
|
|
1458
|
+
try {
|
|
1459
|
+
if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
|
|
1460
|
+
} finally {
|
|
1461
|
+
if (o) throw n;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
return a;
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1467
|
+
function _nonIterableRest() {
|
|
1468
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
1469
|
+
}
|
|
1470
|
+
function _slicedToArray(r, e) {
|
|
1471
|
+
return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
|
|
1472
|
+
}
|
|
1473
|
+
function _unsupportedIterableToArray(r, a) {
|
|
1474
|
+
if (r) {
|
|
1475
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
1476
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
1477
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
|
|
1446
1481
|
/* eslint-disable prefer-const,no-case-declarations,@typescript-eslint/restrict-plus-operands */
|
|
1447
1482
|
/**
|
|
1448
1483
|
* Protobuf binary format wire types.
|
|
@@ -1755,7 +1790,10 @@ class BinaryReader {
|
|
|
1755
1790
|
break;
|
|
1756
1791
|
case WireType.StartGroup:
|
|
1757
1792
|
for (;;) {
|
|
1758
|
-
const
|
|
1793
|
+
const _this$tag = this.tag(),
|
|
1794
|
+
_this$tag2 = _slicedToArray(_this$tag, 2),
|
|
1795
|
+
fn = _this$tag2[0],
|
|
1796
|
+
wt = _this$tag2[1];
|
|
1759
1797
|
if (wt === WireType.EndGroup) {
|
|
1760
1798
|
if (fieldNo !== undefined && fn !== fieldNo) {
|
|
1761
1799
|
throw new Error("invalid end group tag");
|
|
@@ -1807,7 +1845,10 @@ class BinaryReader {
|
|
|
1807
1845
|
* Read a `sint64` field, a signed, zig-zag-encoded 64-bit varint.
|
|
1808
1846
|
*/
|
|
1809
1847
|
sint64() {
|
|
1810
|
-
let
|
|
1848
|
+
let _this$varint = this.varint64(),
|
|
1849
|
+
_this$varint2 = _slicedToArray(_this$varint, 2),
|
|
1850
|
+
lo = _this$varint2[0],
|
|
1851
|
+
hi = _this$varint2[1];
|
|
1811
1852
|
// decode zig zag
|
|
1812
1853
|
let s = -(lo & 1);
|
|
1813
1854
|
lo = (lo >>> 1 | (hi & 1) << 31) ^ s;
|
|
@@ -1818,7 +1859,10 @@ class BinaryReader {
|
|
|
1818
1859
|
* Read a `bool` field, a variant.
|
|
1819
1860
|
*/
|
|
1820
1861
|
bool() {
|
|
1821
|
-
let
|
|
1862
|
+
let _this$varint3 = this.varint64(),
|
|
1863
|
+
_this$varint4 = _slicedToArray(_this$varint3, 2),
|
|
1864
|
+
lo = _this$varint4[0],
|
|
1865
|
+
hi = _this$varint4[1];
|
|
1822
1866
|
return lo !== 0 || hi !== 0;
|
|
1823
1867
|
}
|
|
1824
1868
|
/**
|
|
@@ -2085,19 +2129,6 @@ const protoBase64 = {
|
|
|
2085
2129
|
}
|
|
2086
2130
|
};
|
|
2087
2131
|
|
|
2088
|
-
// Copyright 2021-2024 Buf Technologies, Inc.
|
|
2089
|
-
//
|
|
2090
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
2091
|
-
// you may not use this file except in compliance with the License.
|
|
2092
|
-
// You may obtain a copy of the License at
|
|
2093
|
-
//
|
|
2094
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
2095
|
-
//
|
|
2096
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
2097
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
2098
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2099
|
-
// See the License for the specific language governing permissions and
|
|
2100
|
-
// limitations under the License.
|
|
2101
2132
|
/**
|
|
2102
2133
|
* Retrieve an extension value from a message.
|
|
2103
2134
|
*
|
|
@@ -2116,7 +2147,10 @@ function getExtension(message, extension, options) {
|
|
|
2116
2147
|
assertExtendee(extension, message);
|
|
2117
2148
|
const opt = extension.runtime.bin.makeReadOptions(options);
|
|
2118
2149
|
const ufs = filterUnknownFields(message.getType().runtime.bin.listUnknownFields(message), extension.field);
|
|
2119
|
-
const
|
|
2150
|
+
const _createExtensionConta = createExtensionContainer(extension),
|
|
2151
|
+
_createExtensionConta2 = _slicedToArray(_createExtensionConta, 2),
|
|
2152
|
+
container = _createExtensionConta2[0],
|
|
2153
|
+
get = _createExtensionConta2[1];
|
|
2120
2154
|
for (const uf of ufs) {
|
|
2121
2155
|
extension.runtime.bin.readField(container, opt.readerFactory(uf.data), extension.field, uf.wireType, opt);
|
|
2122
2156
|
}
|
|
@@ -2151,7 +2185,10 @@ function setExtension(message, extension, value, options) {
|
|
|
2151
2185
|
extension.runtime.bin.writeField(f, value, writer, writeOpt);
|
|
2152
2186
|
const reader = readOpt.readerFactory(writer.finish());
|
|
2153
2187
|
while (reader.pos < reader.len) {
|
|
2154
|
-
const
|
|
2188
|
+
const _reader$tag = reader.tag(),
|
|
2189
|
+
_reader$tag2 = _slicedToArray(_reader$tag, 2),
|
|
2190
|
+
no = _reader$tag2[0],
|
|
2191
|
+
wireType = _reader$tag2[1];
|
|
2155
2192
|
const data = reader.skip(wireType, no);
|
|
2156
2193
|
message.getType().runtime.bin.onUnknownField(message, no, wireType, data);
|
|
2157
2194
|
}
|
|
@@ -2320,19 +2357,6 @@ function wrapField(type, value) {
|
|
|
2320
2357
|
"google.protobuf.BytesValue": ScalarType.BYTES
|
|
2321
2358
|
});
|
|
2322
2359
|
|
|
2323
|
-
// Copyright 2021-2024 Buf Technologies, Inc.
|
|
2324
|
-
//
|
|
2325
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
2326
|
-
// you may not use this file except in compliance with the License.
|
|
2327
|
-
// You may obtain a copy of the License at
|
|
2328
|
-
//
|
|
2329
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
2330
|
-
//
|
|
2331
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
2332
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
2333
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2334
|
-
// See the License for the specific language governing permissions and
|
|
2335
|
-
// limitations under the License.
|
|
2336
2360
|
/* eslint-disable no-case-declarations,@typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call */
|
|
2337
2361
|
// Default options for parsing JSON.
|
|
2338
2362
|
const jsonReadDefaults = {
|
|
@@ -2364,7 +2388,10 @@ function makeJsonFormat() {
|
|
|
2364
2388
|
message = message !== null && message !== void 0 ? message : new type();
|
|
2365
2389
|
const oneofSeen = new Map();
|
|
2366
2390
|
const registry = options.typeRegistry;
|
|
2367
|
-
for (const
|
|
2391
|
+
for (const _ref of Object.entries(json)) {
|
|
2392
|
+
var _ref2 = _slicedToArray(_ref, 2);
|
|
2393
|
+
const jsonKey = _ref2[0];
|
|
2394
|
+
const jsonValue = _ref2[1];
|
|
2368
2395
|
const field = type.fields.findJsonName(jsonKey);
|
|
2369
2396
|
if (field) {
|
|
2370
2397
|
if (field.oneof) {
|
|
@@ -2385,7 +2412,10 @@ function makeJsonFormat() {
|
|
|
2385
2412
|
const ext = registry.findExtension(jsonKey.substring(1, jsonKey.length - 1));
|
|
2386
2413
|
if (ext && ext.extendee.typeName == type.typeName) {
|
|
2387
2414
|
found = true;
|
|
2388
|
-
const
|
|
2415
|
+
const _createExtensionConta = createExtensionContainer(ext),
|
|
2416
|
+
_createExtensionConta2 = _slicedToArray(_createExtensionConta, 2),
|
|
2417
|
+
container = _createExtensionConta2[0],
|
|
2418
|
+
get = _createExtensionConta2[1];
|
|
2389
2419
|
readField$1(container, jsonValue, ext.field, options, ext);
|
|
2390
2420
|
// We pass on the options as BinaryReadOptions/BinaryWriteOptions,
|
|
2391
2421
|
// so that users can bring their own binary reader and writer factories
|
|
@@ -2528,7 +2558,10 @@ function readField$1(target, jsonValue, field, options, parentType) {
|
|
|
2528
2558
|
throw new Error("cannot decode field ".concat(parentType.typeName, ".").concat(field.name, " from JSON: ").concat(debugJsonValue(jsonValue)));
|
|
2529
2559
|
}
|
|
2530
2560
|
const targetMap = target[localName];
|
|
2531
|
-
for (const
|
|
2561
|
+
for (const _ref3 of Object.entries(jsonValue)) {
|
|
2562
|
+
var _ref4 = _slicedToArray(_ref3, 2);
|
|
2563
|
+
const jsonMapKey = _ref4[0];
|
|
2564
|
+
const jsonMapValue = _ref4[1];
|
|
2532
2565
|
if (jsonMapValue === null) {
|
|
2533
2566
|
throw new Error("cannot decode field ".concat(parentType.typeName, ".").concat(field.name, " from JSON: map value null"));
|
|
2534
2567
|
}
|
|
@@ -2783,19 +2816,28 @@ function writeField$1(field, value, options) {
|
|
|
2783
2816
|
const entries = Object.entries(value);
|
|
2784
2817
|
switch (field.V.kind) {
|
|
2785
2818
|
case "scalar":
|
|
2786
|
-
for (const
|
|
2819
|
+
for (const _ref5 of entries) {
|
|
2820
|
+
var _ref6 = _slicedToArray(_ref5, 2);
|
|
2821
|
+
const entryKey = _ref6[0];
|
|
2822
|
+
const entryValue = _ref6[1];
|
|
2787
2823
|
jsonObj[entryKey.toString()] = writeScalar$1(field.V.T, entryValue); // JSON standard allows only (double quoted) string as property key
|
|
2788
2824
|
}
|
|
2789
2825
|
break;
|
|
2790
2826
|
case "message":
|
|
2791
|
-
for (const
|
|
2827
|
+
for (const _ref7 of entries) {
|
|
2828
|
+
var _ref8 = _slicedToArray(_ref7, 2);
|
|
2829
|
+
const entryKey = _ref8[0];
|
|
2830
|
+
const entryValue = _ref8[1];
|
|
2792
2831
|
// JSON standard allows only (double quoted) string as property key
|
|
2793
2832
|
jsonObj[entryKey.toString()] = entryValue.toJson(options);
|
|
2794
2833
|
}
|
|
2795
2834
|
break;
|
|
2796
2835
|
case "enum":
|
|
2797
2836
|
const enumType = field.V.T;
|
|
2798
|
-
for (const
|
|
2837
|
+
for (const _ref9 of entries) {
|
|
2838
|
+
var _ref0 = _slicedToArray(_ref9, 2);
|
|
2839
|
+
const entryKey = _ref0[0];
|
|
2840
|
+
const entryValue = _ref0[1];
|
|
2799
2841
|
// JSON standard allows only (double quoted) string as property key
|
|
2800
2842
|
jsonObj[entryKey.toString()] = writeEnum(enumType, entryValue, options.enumAsInteger);
|
|
2801
2843
|
}
|
|
@@ -2891,19 +2933,6 @@ function writeScalar$1(type, value) {
|
|
|
2891
2933
|
}
|
|
2892
2934
|
}
|
|
2893
2935
|
|
|
2894
|
-
// Copyright 2021-2024 Buf Technologies, Inc.
|
|
2895
|
-
//
|
|
2896
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
2897
|
-
// you may not use this file except in compliance with the License.
|
|
2898
|
-
// You may obtain a copy of the License at
|
|
2899
|
-
//
|
|
2900
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
2901
|
-
//
|
|
2902
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
2903
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
2904
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
2905
|
-
// See the License for the specific language governing permissions and
|
|
2906
|
-
// limitations under the License.
|
|
2907
2936
|
/* eslint-disable prefer-const,no-case-declarations,@typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-return */
|
|
2908
2937
|
const unknownFieldsSymbol = Symbol("@bufbuild/protobuf/unknown-fields");
|
|
2909
2938
|
// Default options for parsing binary data.
|
|
@@ -2959,7 +2988,10 @@ function makeBinaryFormat() {
|
|
|
2959
2988
|
const end = delimitedMessageEncoding ? reader.len : reader.pos + lengthOrEndTagFieldNo;
|
|
2960
2989
|
let fieldNo, wireType;
|
|
2961
2990
|
while (reader.pos < end) {
|
|
2962
|
-
|
|
2991
|
+
var _reader$tag = reader.tag();
|
|
2992
|
+
var _reader$tag2 = _slicedToArray(_reader$tag, 2);
|
|
2993
|
+
fieldNo = _reader$tag2[0];
|
|
2994
|
+
wireType = _reader$tag2[1];
|
|
2963
2995
|
if (delimitedMessageEncoding === true && wireType == WireType.EndGroup) {
|
|
2964
2996
|
break;
|
|
2965
2997
|
}
|
|
@@ -3012,10 +3044,8 @@ function makeBinaryFormat() {
|
|
|
3012
3044
|
function readField(target,
|
|
3013
3045
|
// eslint-disable-line @typescript-eslint/no-explicit-any -- `any` is the best choice for dynamic access
|
|
3014
3046
|
reader, field, wireType, options) {
|
|
3015
|
-
let
|
|
3016
|
-
|
|
3017
|
-
localName
|
|
3018
|
-
} = field;
|
|
3047
|
+
let repeated = field.repeated,
|
|
3048
|
+
localName = field.localName;
|
|
3019
3049
|
if (field.oneof) {
|
|
3020
3050
|
target = target[field.oneof.localName];
|
|
3021
3051
|
if (target.case != localName) {
|
|
@@ -3065,7 +3095,10 @@ reader, field, wireType, options) {
|
|
|
3065
3095
|
}
|
|
3066
3096
|
break;
|
|
3067
3097
|
case "map":
|
|
3068
|
-
let
|
|
3098
|
+
let _readMapEntry = readMapEntry(field, reader, options),
|
|
3099
|
+
_readMapEntry2 = _slicedToArray(_readMapEntry, 2),
|
|
3100
|
+
mapKey = _readMapEntry2[0],
|
|
3101
|
+
mapVal = _readMapEntry2[1];
|
|
3069
3102
|
// safe to assume presence of map object, oneof cannot contain repeated values
|
|
3070
3103
|
target[localName][mapKey] = mapVal;
|
|
3071
3104
|
break;
|
|
@@ -3087,7 +3120,9 @@ function readMapEntry(field, reader, options) {
|
|
|
3087
3120
|
end = reader.pos + length;
|
|
3088
3121
|
let key, val;
|
|
3089
3122
|
while (reader.pos < end) {
|
|
3090
|
-
const
|
|
3123
|
+
const _reader$tag3 = reader.tag(),
|
|
3124
|
+
_reader$tag4 = _slicedToArray(_reader$tag3, 1),
|
|
3125
|
+
fieldNo = _reader$tag4[0];
|
|
3091
3126
|
switch (fieldNo) {
|
|
3092
3127
|
case 1:
|
|
3093
3128
|
key = readScalar(reader, field.K);
|
|
@@ -3201,7 +3236,10 @@ function writeField(field, value, writer, options) {
|
|
|
3201
3236
|
break;
|
|
3202
3237
|
case "map":
|
|
3203
3238
|
assert(typeof value == "object" && value != null);
|
|
3204
|
-
for (const
|
|
3239
|
+
for (const _ref of Object.entries(value)) {
|
|
3240
|
+
var _ref2 = _slicedToArray(_ref, 2);
|
|
3241
|
+
const key = _ref2[0];
|
|
3242
|
+
const val = _ref2[1];
|
|
3205
3243
|
writeMapEntry(writer, options, field, key, val);
|
|
3206
3244
|
}
|
|
3207
3245
|
break;
|
|
@@ -3252,7 +3290,10 @@ function writeMessageField(writer, options, field, value) {
|
|
|
3252
3290
|
}
|
|
3253
3291
|
function writeScalar(writer, type, fieldNo, value) {
|
|
3254
3292
|
assert(value !== undefined);
|
|
3255
|
-
let
|
|
3293
|
+
let _scalarTypeInfo = scalarTypeInfo(type),
|
|
3294
|
+
_scalarTypeInfo2 = _slicedToArray(_scalarTypeInfo, 2),
|
|
3295
|
+
wireType = _scalarTypeInfo2[0],
|
|
3296
|
+
method = _scalarTypeInfo2[1];
|
|
3256
3297
|
writer.tag(fieldNo, wireType)[method](value);
|
|
3257
3298
|
}
|
|
3258
3299
|
function writePacked(writer, type, fieldNo, value) {
|
|
@@ -3260,7 +3301,9 @@ function writePacked(writer, type, fieldNo, value) {
|
|
|
3260
3301
|
return;
|
|
3261
3302
|
}
|
|
3262
3303
|
writer.tag(fieldNo, WireType.LengthDelimited).fork();
|
|
3263
|
-
let
|
|
3304
|
+
let _scalarTypeInfo3 = scalarTypeInfo(type),
|
|
3305
|
+
_scalarTypeInfo4 = _slicedToArray(_scalarTypeInfo3, 2),
|
|
3306
|
+
method = _scalarTypeInfo4[1];
|
|
3264
3307
|
for (let i = 0; i < value.length; i++) {
|
|
3265
3308
|
writer[method](value[i]);
|
|
3266
3309
|
}
|
|
@@ -3300,19 +3343,6 @@ function scalarTypeInfo(type) {
|
|
|
3300
3343
|
return [wireType, method];
|
|
3301
3344
|
}
|
|
3302
3345
|
|
|
3303
|
-
// Copyright 2021-2024 Buf Technologies, Inc.
|
|
3304
|
-
//
|
|
3305
|
-
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
3306
|
-
// you may not use this file except in compliance with the License.
|
|
3307
|
-
// You may obtain a copy of the License at
|
|
3308
|
-
//
|
|
3309
|
-
// http://www.apache.org/licenses/LICENSE-2.0
|
|
3310
|
-
//
|
|
3311
|
-
// Unless required by applicable law or agreed to in writing, software
|
|
3312
|
-
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
3313
|
-
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
3314
|
-
// See the License for the specific language governing permissions and
|
|
3315
|
-
// limitations under the License.
|
|
3316
3346
|
/* eslint-disable @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-argument,no-case-declarations */
|
|
3317
3347
|
function makeUtilCommon() {
|
|
3318
3348
|
return {
|
|
@@ -3361,7 +3391,10 @@ function makeUtilCommon() {
|
|
|
3361
3391
|
case "scalar":
|
|
3362
3392
|
case "enum":
|
|
3363
3393
|
if (member.V.T === ScalarType.BYTES) {
|
|
3364
|
-
for (const
|
|
3394
|
+
for (const _ref of Object.entries(s[localName])) {
|
|
3395
|
+
var _ref2 = _slicedToArray(_ref, 2);
|
|
3396
|
+
const k = _ref2[0];
|
|
3397
|
+
const v = _ref2[1];
|
|
3365
3398
|
t[localName][k] = toU8Arr(v);
|
|
3366
3399
|
}
|
|
3367
3400
|
} else {
|
|
@@ -3493,7 +3526,10 @@ function makeUtilCommon() {
|
|
|
3493
3526
|
copy = source.map(cloneSingularField);
|
|
3494
3527
|
} else if (member.kind == "map") {
|
|
3495
3528
|
copy = any[member.localName];
|
|
3496
|
-
for (const
|
|
3529
|
+
for (const _ref3 of Object.entries(source)) {
|
|
3530
|
+
var _ref4 = _slicedToArray(_ref3, 2);
|
|
3531
|
+
const key = _ref4[0];
|
|
3532
|
+
const v = _ref4[1];
|
|
3497
3533
|
copy[key] = cloneSingularField(v);
|
|
3498
3534
|
}
|
|
3499
3535
|
} else if (member.kind == "oneof") {
|
|
@@ -4682,9 +4718,7 @@ function getBrowser(userAgent) {
|
|
|
4682
4718
|
const ua = (navigator.userAgent).toLowerCase();
|
|
4683
4719
|
if (browserDetails === undefined || force) {
|
|
4684
4720
|
const browser = browsersList.find(_ref => {
|
|
4685
|
-
let
|
|
4686
|
-
test
|
|
4687
|
-
} = _ref;
|
|
4721
|
+
let test = _ref.test;
|
|
4688
4722
|
return test.test(ua);
|
|
4689
4723
|
});
|
|
4690
4724
|
browserDetails = browser === null || browser === void 0 ? void 0 : browser.describe(ua);
|
|
@@ -5411,6 +5445,7 @@ class VideoPreset {
|
|
|
5411
5445
|
};
|
|
5412
5446
|
}
|
|
5413
5447
|
}
|
|
5448
|
+
const videoCodecs = ['vp8', 'h264', 'vp9', 'av1', 'h265'];
|
|
5414
5449
|
var BackupCodecPolicy;
|
|
5415
5450
|
(function (BackupCodecPolicy) {
|
|
5416
5451
|
// codec regression is preferred, the sfu will try to regress codec if possible but not guaranteed
|
|
@@ -5481,6 +5516,9 @@ var AudioPresets;
|
|
|
5481
5516
|
original: new VideoPreset(0, 0, 7000000, 30, 'medium')
|
|
5482
5517
|
});
|
|
5483
5518
|
|
|
5519
|
+
function mimeTypeToVideoCodecString(mimeType) {
|
|
5520
|
+
return mimeType.split('/')[1].toLowerCase();
|
|
5521
|
+
}
|
|
5484
5522
|
function getLogContextFromTrack(track) {
|
|
5485
5523
|
if ('mediaStreamTrack' in track) {
|
|
5486
5524
|
return {
|
|
@@ -6435,6 +6473,11 @@ class FrameCryptor extends BaseFrameCryptor {
|
|
|
6435
6473
|
this.ERROR_THROTTLE_MS = 1000; // Emit error at most once per second
|
|
6436
6474
|
this.MAX_ERRORS_PER_MINUTE = 5; // Maximum errors to emit per minute per key
|
|
6437
6475
|
this.ERROR_WINDOW_MS = 60000; // 1 minute window
|
|
6476
|
+
/**
|
|
6477
|
+
* Tracks (participant, trackId, payloadType) tuples for which we've already logged a NALU
|
|
6478
|
+
* fallback, so a persistent bad state doesn't flood the console (Firefox doesn't filter debug).
|
|
6479
|
+
*/
|
|
6480
|
+
this.loggedNALUFallbacks = new Set();
|
|
6438
6481
|
this.sendCounts = new Map();
|
|
6439
6482
|
this.keys = opts.keys;
|
|
6440
6483
|
this.participantIdentity = opts.participantIdentity;
|
|
@@ -6677,9 +6720,7 @@ class FrameCryptor extends BaseFrameCryptor {
|
|
|
6677
6720
|
this.emitThrottledError(new CryptorError("key set not found for ".concat(this.participantIdentity, " at index ").concat(this.keys.getCurrentKeyIndex()), CryptorErrorReason.MissingKey, this.participantIdentity));
|
|
6678
6721
|
return;
|
|
6679
6722
|
}
|
|
6680
|
-
const
|
|
6681
|
-
encryptionKey
|
|
6682
|
-
} = keySet;
|
|
6723
|
+
const encryptionKey = keySet.encryptionKey;
|
|
6683
6724
|
const keyIndex = this.keys.getCurrentKeyIndex();
|
|
6684
6725
|
if (encryptionKey) {
|
|
6685
6726
|
const iv = this.makeIV((_a = encodedFrame.getMetadata().synchronizationSource) !== null && _a !== void 0 ? _a : -1, encodedFrame.timestamp);
|
|
@@ -6974,19 +7015,21 @@ class FrameCryptor extends BaseFrameCryptor {
|
|
|
6974
7015
|
};
|
|
6975
7016
|
}
|
|
6976
7017
|
// Try NALU processing for H.264/H.265 codecs
|
|
7018
|
+
const payloadType = frame.getMetadata().payloadType;
|
|
7019
|
+
const fallbackKey = "".concat(this.participantIdentity, "-").concat(this.trackId, "-").concat(payloadType);
|
|
6977
7020
|
try {
|
|
6978
7021
|
const knownCodec = detectedCodec === 'h264' || detectedCodec === 'h265' ? detectedCodec : undefined;
|
|
6979
7022
|
const naluResult = processNALUsForEncryption(new Uint8Array(frame.data), knownCodec);
|
|
6980
7023
|
if (naluResult.requiresNALUProcessing) {
|
|
7024
|
+
// Recovered for this tuple, allow a future failure to log again.
|
|
7025
|
+
this.loggedNALUFallbacks.delete(fallbackKey);
|
|
6981
7026
|
return {
|
|
6982
7027
|
unencryptedBytes: naluResult.unencryptedBytes,
|
|
6983
7028
|
requiresNALUProcessing: true
|
|
6984
7029
|
};
|
|
6985
7030
|
}
|
|
6986
7031
|
} catch (e) {
|
|
6987
|
-
|
|
6988
|
-
error: e
|
|
6989
|
-
}, this.logContext));
|
|
7032
|
+
this.logNALUFallbackOnce(fallbackKey, payloadType, e);
|
|
6990
7033
|
}
|
|
6991
7034
|
// Fallback to VP8 handling
|
|
6992
7035
|
return {
|
|
@@ -6995,13 +7038,34 @@ class FrameCryptor extends BaseFrameCryptor {
|
|
|
6995
7038
|
};
|
|
6996
7039
|
}
|
|
6997
7040
|
/**
|
|
6998
|
-
*
|
|
7041
|
+
* Logs a NALU processing fallback at most once per (participant, trackId, payloadType) tuple,
|
|
7042
|
+
* so a persistent bad state doesn't flood the console (Firefox doesn't filter debug).
|
|
7043
|
+
*/
|
|
7044
|
+
logNALUFallbackOnce(fallbackKey, payloadType, error) {
|
|
7045
|
+
if (this.loggedNALUFallbacks.has(fallbackKey)) {
|
|
7046
|
+
return;
|
|
7047
|
+
}
|
|
7048
|
+
this.loggedNALUFallbacks.add(fallbackKey);
|
|
7049
|
+
workerLogger.warn('NALU processing failed, falling back to VP8 handling', Object.assign({
|
|
7050
|
+
error,
|
|
7051
|
+
payloadType
|
|
7052
|
+
}, this.logContext));
|
|
7053
|
+
}
|
|
7054
|
+
/**
|
|
7055
|
+
* inspects frame mimetype if available. falls back to payloadtype and maps it to the codec specified in rtpMap
|
|
6999
7056
|
*/
|
|
7000
7057
|
getVideoCodec(frame) {
|
|
7058
|
+
const metadata = frame.getMetadata();
|
|
7059
|
+
if (metadata.mimeType) {
|
|
7060
|
+
const maybeKnownCodec = mimeTypeToVideoCodecString(metadata.mimeType);
|
|
7061
|
+
if (videoCodecs.includes(maybeKnownCodec)) {
|
|
7062
|
+
return maybeKnownCodec;
|
|
7063
|
+
}
|
|
7064
|
+
}
|
|
7001
7065
|
if (this.rtpMap.size === 0) {
|
|
7002
7066
|
return undefined;
|
|
7003
7067
|
}
|
|
7004
|
-
const payloadType =
|
|
7068
|
+
const payloadType = metadata.payloadType;
|
|
7005
7069
|
const codec = payloadType ? this.rtpMap.get(payloadType) : undefined;
|
|
7006
7070
|
return codec;
|
|
7007
7071
|
}
|
|
@@ -7215,10 +7279,9 @@ let rtpMap = new Map();
|
|
|
7215
7279
|
workerLogger.setDefaultLevel('info');
|
|
7216
7280
|
onmessage = ev => {
|
|
7217
7281
|
messageQueue.run(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
7218
|
-
const
|
|
7219
|
-
kind,
|
|
7220
|
-
data
|
|
7221
|
-
} = ev.data;
|
|
7282
|
+
const _ev$data = ev.data,
|
|
7283
|
+
kind = _ev$data.kind,
|
|
7284
|
+
data = _ev$data.data;
|
|
7222
7285
|
switch (kind) {
|
|
7223
7286
|
case 'init':
|
|
7224
7287
|
workerLogger.setLevel(data.loglevel);
|
|
@@ -7251,11 +7314,10 @@ onmessage = ev => {
|
|
|
7251
7314
|
pubCryptor.setupTransform(kind, data.readableStream, data.writableStream, data.trackId, data.isReuse, data.codec, data.packetTrailer);
|
|
7252
7315
|
break;
|
|
7253
7316
|
case 'encryptDataRequest':
|
|
7254
|
-
const
|
|
7255
|
-
payload
|
|
7256
|
-
iv,
|
|
7257
|
-
keyIndex
|
|
7258
|
-
} = yield DataCryptor.encrypt(data.payload, getParticipantKeyHandler(data.participantIdentity));
|
|
7317
|
+
const _yield$DataCryptor$en = yield DataCryptor.encrypt(data.payload, getParticipantKeyHandler(data.participantIdentity)),
|
|
7318
|
+
encryptedPayload = _yield$DataCryptor$en.payload,
|
|
7319
|
+
iv = _yield$DataCryptor$en.iv,
|
|
7320
|
+
keyIndex = _yield$DataCryptor$en.keyIndex;
|
|
7259
7321
|
console.log('encrypted payload', {
|
|
7260
7322
|
original: data.payload,
|
|
7261
7323
|
encrypted: encryptedPayload,
|
|
@@ -7273,9 +7335,8 @@ onmessage = ev => {
|
|
|
7273
7335
|
break;
|
|
7274
7336
|
case 'decryptDataRequest':
|
|
7275
7337
|
try {
|
|
7276
|
-
const
|
|
7277
|
-
payload
|
|
7278
|
-
} = yield DataCryptor.decrypt(data.payload, data.iv, getParticipantKeyHandler(data.participantIdentity), data.keyIndex);
|
|
7338
|
+
const _yield$DataCryptor$de = yield DataCryptor.decrypt(data.payload, data.iv, getParticipantKeyHandler(data.participantIdentity), data.keyIndex),
|
|
7339
|
+
decryptedPayload = _yield$DataCryptor$de.payload;
|
|
7279
7340
|
postMessage({
|
|
7280
7341
|
kind: 'decryptDataResponse',
|
|
7281
7342
|
data: {
|
|
@@ -7480,13 +7541,11 @@ if (self.RTCTransformEvent) {
|
|
|
7480
7541
|
// @ts-ignore
|
|
7481
7542
|
const transformer = event.transformer;
|
|
7482
7543
|
const options = transformer.options;
|
|
7483
|
-
const
|
|
7484
|
-
|
|
7485
|
-
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
hasPacketTrailer
|
|
7489
|
-
} = options;
|
|
7544
|
+
const kind = options.kind,
|
|
7545
|
+
participantIdentity = options.participantIdentity,
|
|
7546
|
+
trackId = options.trackId,
|
|
7547
|
+
codec = options.codec,
|
|
7548
|
+
hasPacketTrailer = options.hasPacketTrailer;
|
|
7490
7549
|
messageQueue.run(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
7491
7550
|
const cryptor = getTrackCryptor(participantIdentity, trackId);
|
|
7492
7551
|
cryptor.setHasPacketTrailer(hasPacketTrailer);
|