livekit-client 2.22.2 → 2.22.4
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/README.md +35 -0
- 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 +488 -438
- package/dist/livekit-client.e2ee.worker.mjs.map +1 -1
- package/dist/livekit-client.esm.mjs +954 -301
- package/dist/livekit-client.esm.mjs.map +1 -1
- package/dist/livekit-client.fm.worker.js +1 -1
- package/dist/livekit-client.fm.worker.js.map +1 -1
- package/dist/livekit-client.fm.worker.mjs +10 -2
- package/dist/livekit-client.fm.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/api/SignalClient.d.ts +4 -2
- package/dist/src/api/SignalClient.d.ts.map +1 -1
- package/dist/src/api/WebSocketStream.d.ts.map +1 -1
- package/dist/src/api/utils.d.ts +1 -0
- package/dist/src/api/utils.d.ts.map +1 -1
- package/dist/src/e2ee/E2eeManager.d.ts +26 -0
- package/dist/src/e2ee/E2eeManager.d.ts.map +1 -1
- package/dist/src/e2ee/types.d.ts +15 -1
- package/dist/src/e2ee/types.d.ts.map +1 -1
- package/dist/src/e2ee/worker/DataCryptor.d.ts.map +1 -1
- package/dist/src/e2ee/worker/ErrorRateLimiter.d.ts +21 -0
- package/dist/src/e2ee/worker/ErrorRateLimiter.d.ts.map +1 -0
- package/dist/src/e2ee/worker/FrameCryptor.d.ts +1 -18
- package/dist/src/e2ee/worker/FrameCryptor.d.ts.map +1 -1
- package/dist/src/logger.d.ts +4 -0
- package/dist/src/logger.d.ts.map +1 -1
- package/dist/src/options.d.ts +14 -0
- package/dist/src/options.d.ts.map +1 -1
- package/dist/src/room/PCTransport.d.ts +78 -7
- package/dist/src/room/PCTransport.d.ts.map +1 -1
- package/dist/src/room/PCTransportManager.d.ts.map +1 -1
- package/dist/src/room/RTCEngine.d.ts +9 -0
- package/dist/src/room/RTCEngine.d.ts.map +1 -1
- package/dist/src/room/Room.d.ts +1 -1
- package/dist/src/room/Room.d.ts.map +1 -1
- package/dist/src/room/defaults.d.ts.map +1 -1
- package/dist/src/room/errors.d.ts +18 -0
- package/dist/src/room/errors.d.ts.map +1 -1
- package/dist/src/room/events.d.ts +3 -2
- package/dist/src/room/events.d.ts.map +1 -1
- package/dist/src/room/participant/LocalParticipant.d.ts.map +1 -1
- package/dist/src/room/participant/publishUtils.d.ts +16 -0
- package/dist/src/room/participant/publishUtils.d.ts.map +1 -1
- package/dist/src/room/rpc/client/RpcClientManager.d.ts.map +1 -1
- package/dist/src/room/track/LocalTrack.d.ts.map +1 -1
- package/dist/src/room/track/LocalVideoTrack.d.ts +9 -0
- package/dist/src/room/track/LocalVideoTrack.d.ts.map +1 -1
- package/dist/src/room/track/options.d.ts +1 -1
- package/dist/src/room/track/utils.d.ts +13 -0
- package/dist/src/room/track/utils.d.ts.map +1 -1
- package/dist/src/room/utils.d.ts +66 -0
- package/dist/src/room/utils.d.ts.map +1 -1
- package/dist/src/test/compressionStreamStubs.d.ts +12 -0
- package/dist/src/test/compressionStreamStubs.d.ts.map +1 -0
- package/dist/ts4.2/api/SignalClient.d.ts +187 -185
- package/dist/ts4.2/api/SignalClientStateMachine.d.ts +85 -85
- package/dist/ts4.2/api/WebSocketStream.d.ts +33 -33
- package/dist/ts4.2/api/utils.d.ts +9 -8
- package/dist/ts4.2/connectionHelper/ConnectionCheck.d.ts +30 -30
- package/dist/ts4.2/connectionHelper/checks/Checker.d.ts +62 -62
- package/dist/ts4.2/connectionHelper/checks/cloudRegion.d.ts +18 -18
- package/dist/ts4.2/connectionHelper/checks/connectionProtocol.d.ts +20 -20
- package/dist/ts4.2/connectionHelper/checks/publishAudio.d.ts +6 -6
- package/dist/ts4.2/connectionHelper/checks/publishVideo.d.ts +7 -7
- package/dist/ts4.2/connectionHelper/checks/reconnect.d.ts +6 -6
- package/dist/ts4.2/connectionHelper/checks/turn.d.ts +6 -6
- package/dist/ts4.2/connectionHelper/checks/webrtc.d.ts +6 -6
- package/dist/ts4.2/connectionHelper/checks/websocket.d.ts +6 -6
- package/dist/ts4.2/e2ee/E2eeManager.d.ts +111 -85
- package/dist/ts4.2/e2ee/KeyProvider.d.ts +54 -54
- package/dist/ts4.2/e2ee/constants.d.ts +21 -21
- package/dist/ts4.2/e2ee/errors.d.ts +12 -12
- package/dist/ts4.2/e2ee/events.d.ts +39 -39
- package/dist/ts4.2/e2ee/index.d.ts +6 -6
- package/dist/ts4.2/e2ee/types.d.ts +231 -217
- package/dist/ts4.2/e2ee/utils.d.ts +32 -32
- package/dist/ts4.2/e2ee/worker/DataCryptor.d.ts +16 -16
- package/dist/ts4.2/e2ee/worker/ErrorRateLimiter.d.ts +21 -0
- package/dist/ts4.2/e2ee/worker/FrameCryptor.d.ts +209 -226
- package/dist/ts4.2/e2ee/worker/ParticipantKeyHandler.d.ts +81 -84
- package/dist/ts4.2/e2ee/worker/e2ee.worker.d.ts +2 -2
- package/dist/ts4.2/e2ee/worker/naluUtils.d.ts +28 -28
- package/dist/ts4.2/e2ee/worker/sifPayload.d.ts +23 -23
- package/dist/ts4.2/frameMetadata/FrameMetadataManager.d.ts +53 -53
- package/dist/ts4.2/frameMetadata/frameMetadata.d.ts +33 -33
- package/dist/ts4.2/frameMetadata/types.d.ts +62 -62
- package/dist/ts4.2/frameMetadata/utils.d.ts +9 -9
- package/dist/ts4.2/frameMetadata/worker/frameMetadata.worker.d.ts +2 -2
- package/dist/ts4.2/index.d.ts +76 -76
- package/dist/ts4.2/logger.d.ts +66 -62
- package/dist/ts4.2/options.d.ts +163 -149
- package/dist/ts4.2/room/BackOffStrategy.d.ts +27 -27
- package/dist/ts4.2/room/DefaultReconnectPolicy.d.ts +8 -8
- package/dist/ts4.2/room/DeviceManager.d.ts +12 -12
- package/dist/ts4.2/room/PCTransport.d.ts +246 -175
- package/dist/ts4.2/room/PCTransportManager.d.ts +77 -77
- package/dist/ts4.2/room/RTCEngine.d.ts +269 -261
- package/dist/ts4.2/room/ReconnectPolicy.d.ts +24 -24
- package/dist/ts4.2/room/RegionUrlProvider.d.ts +36 -36
- package/dist/ts4.2/room/Room.d.ts +354 -365
- package/dist/ts4.2/room/attribute-typings.d.ts +35 -35
- package/dist/ts4.2/room/data-channel/DataChannelManager.d.ts +62 -62
- package/dist/ts4.2/room/data-channel/FlowControlledDataChannel.d.ts +94 -95
- package/dist/ts4.2/room/data-channel/LossyDataChannel.d.ts +41 -41
- package/dist/ts4.2/room/data-channel/ReliableDataChannel.d.ts +57 -57
- package/dist/ts4.2/room/data-channel/types.d.ts +12 -12
- package/dist/ts4.2/room/data-stream/compression.d.ts +49 -49
- package/dist/ts4.2/room/data-stream/constants.d.ts +18 -18
- package/dist/ts4.2/room/data-stream/incoming/IncomingDataStreamManager.d.ts +29 -29
- package/dist/ts4.2/room/data-stream/incoming/StreamReader.d.ts +80 -80
- package/dist/ts4.2/room/data-stream/outgoing/OutgoingDataStreamManager.d.ts +73 -73
- package/dist/ts4.2/room/data-stream/outgoing/StreamWriter.d.ts +16 -16
- package/dist/ts4.2/room/data-stream/outgoing/header-utils.d.ts +18 -18
- package/dist/ts4.2/room/data-track/LocalDataTrack.d.ts +79 -80
- package/dist/ts4.2/room/data-track/RemoteDataTrack.d.ts +50 -50
- package/dist/ts4.2/room/data-track/depacketizer.d.ts +59 -59
- package/dist/ts4.2/room/data-track/frame.d.ts +22 -22
- package/dist/ts4.2/room/data-track/handle.d.ts +27 -27
- package/dist/ts4.2/room/data-track/incoming/IncomingDataTrackManager.d.ts +124 -124
- package/dist/ts4.2/room/data-track/incoming/errors.d.ts +24 -24
- package/dist/ts4.2/room/data-track/incoming/pipeline.d.ts +41 -41
- package/dist/ts4.2/room/data-track/incoming/types.d.ts +20 -20
- package/dist/ts4.2/room/data-track/outgoing/OutgoingDataTrackManager.d.ts +126 -126
- package/dist/ts4.2/room/data-track/outgoing/errors.d.ts +74 -74
- package/dist/ts4.2/room/data-track/outgoing/pipeline.d.ts +23 -23
- package/dist/ts4.2/room/data-track/outgoing/types.d.ts +48 -48
- package/dist/ts4.2/room/data-track/packet/constants.d.ts +20 -20
- package/dist/ts4.2/room/data-track/packet/errors.d.ts +40 -40
- package/dist/ts4.2/room/data-track/packet/extensions.d.ts +69 -69
- package/dist/ts4.2/room/data-track/packet/index.d.ts +98 -98
- package/dist/ts4.2/room/data-track/packet/serializable.d.ts +13 -13
- package/dist/ts4.2/room/data-track/packetizer.d.ts +43 -43
- package/dist/ts4.2/room/data-track/track-interfaces.d.ts +23 -23
- package/dist/ts4.2/room/data-track/types.d.ts +22 -22
- package/dist/ts4.2/room/data-track/utils.d.ts +60 -60
- package/dist/ts4.2/room/debounce.d.ts +11 -11
- package/dist/ts4.2/room/defaults.d.ts +9 -9
- package/dist/ts4.2/room/errors.d.ts +180 -162
- package/dist/ts4.2/room/events.d.ts +638 -637
- package/dist/ts4.2/room/participant/LocalParticipant.d.ts +287 -287
- package/dist/ts4.2/room/participant/Participant.d.ts +142 -144
- package/dist/ts4.2/room/participant/ParticipantTrackPermission.d.ts +26 -26
- package/dist/ts4.2/room/participant/RemoteParticipant.d.ts +85 -86
- package/dist/ts4.2/room/participant/publishUtils.d.ts +53 -37
- package/dist/ts4.2/room/rpc/client/RpcClientManager.d.ts +43 -43
- package/dist/ts4.2/room/rpc/client/events.d.ts +8 -8
- package/dist/ts4.2/room/rpc/index.d.ts +7 -7
- package/dist/ts4.2/room/rpc/server/RpcServerManager.d.ts +44 -44
- package/dist/ts4.2/room/rpc/server/events.d.ts +8 -8
- package/dist/ts4.2/room/rpc/utils.d.ts +131 -131
- package/dist/ts4.2/room/stats.d.ts +71 -71
- package/dist/ts4.2/room/statsSummary.d.ts +13 -13
- package/dist/ts4.2/room/timers.d.ts +12 -12
- package/dist/ts4.2/room/token-source/TokenSource.d.ts +82 -82
- package/dist/ts4.2/room/token-source/types.d.ts +70 -70
- package/dist/ts4.2/room/token-source/utils.d.ts +8 -8
- package/dist/ts4.2/room/track/FrameMetadataExtractor.d.ts +19 -19
- package/dist/ts4.2/room/track/LocalAudioTrack.d.ts +39 -42
- package/dist/ts4.2/room/track/LocalTrack.d.ts +125 -125
- package/dist/ts4.2/room/track/LocalTrackPublication.d.ts +42 -42
- package/dist/ts4.2/room/track/LocalVideoTrack.d.ts +102 -93
- package/dist/ts4.2/room/track/RemoteAudioTrack.d.ts +55 -55
- package/dist/ts4.2/room/track/RemoteTrack.d.ts +38 -38
- package/dist/ts4.2/room/track/RemoteTrackPublication.d.ts +72 -75
- package/dist/ts4.2/room/track/RemoteVideoTrack.d.ts +73 -76
- package/dist/ts4.2/room/track/Track.d.ts +156 -166
- package/dist/ts4.2/room/track/TrackPublication.d.ts +75 -81
- package/dist/ts4.2/room/track/create.d.ts +25 -25
- package/dist/ts4.2/room/track/facingMode.d.ts +41 -41
- package/dist/ts4.2/room/track/options.d.ts +403 -403
- package/dist/ts4.2/room/track/processor/types.d.ts +31 -31
- package/dist/ts4.2/room/track/record.d.ts +13 -13
- package/dist/ts4.2/room/track/types.d.ts +28 -28
- package/dist/ts4.2/room/track/utils.d.ts +60 -47
- package/dist/ts4.2/room/types.d.ts +127 -127
- package/dist/ts4.2/room/utils.d.ts +246 -180
- package/dist/ts4.2/test/MockMediaStreamTrack.d.ts +26 -26
- package/dist/ts4.2/test/compressionStreamStubs.d.ts +12 -0
- package/dist/ts4.2/test/mocks.d.ts +12 -12
- package/dist/ts4.2/test/promiseState.d.ts +12 -12
- package/dist/ts4.2/test/signalToken.d.ts +26 -26
- package/dist/ts4.2/type-polyfills/non-shared-typed-arrays.d.ts +2 -2
- package/dist/ts4.2/utils/AsyncQueue.d.ts +23 -23
- package/dist/ts4.2/utils/TypedPromise.d.ts +17 -17
- package/dist/ts4.2/utils/abort-signal-polyfill.d.ts +13 -13
- package/dist/ts4.2/utils/browserParser.d.ts +13 -13
- package/dist/ts4.2/utils/camelToSnakeCase.d.ts +8 -8
- package/dist/ts4.2/utils/cloneDeep.d.ts +2 -2
- package/dist/ts4.2/utils/dataPacketBuffer.d.ts +34 -34
- package/dist/ts4.2/utils/deferrable-map.d.ts +32 -32
- package/dist/ts4.2/utils/machineInspector.d.ts +54 -54
- package/dist/ts4.2/utils/serializer.d.ts +48 -48
- package/dist/ts4.2/utils/subscribeToEvents.d.ts +15 -15
- package/dist/ts4.2/utils/ttlmap.d.ts +20 -20
- package/dist/ts4.2/version.d.ts +15 -15
- package/package.json +5 -4
- package/src/api/SignalClient.e2e.test.ts +1 -3
- package/src/api/SignalClient.test.ts +160 -10
- package/src/api/SignalClient.ts +75 -54
- package/src/api/WebSocketStream.ts +3 -8
- package/src/api/utils.ts +10 -0
- package/src/e2ee/E2eeManager.test.ts +196 -0
- package/src/e2ee/E2eeManager.ts +114 -19
- package/src/e2ee/types.ts +19 -1
- package/src/e2ee/worker/DataCryptor.ts +2 -1
- package/src/e2ee/worker/ErrorRateLimiter.test.ts +53 -0
- package/src/e2ee/worker/ErrorRateLimiter.ts +52 -0
- package/src/e2ee/worker/FrameCryptor.ts +20 -70
- package/src/e2ee/worker/e2ee.worker.ts +34 -11
- package/src/logger.ts +22 -0
- package/src/options.ts +16 -0
- package/src/room/PCTransport.test.ts +183 -7
- package/src/room/PCTransport.ts +197 -36
- package/src/room/PCTransportManager.ts +3 -1
- package/src/room/RTCEngine.test.ts +84 -0
- package/src/room/RTCEngine.ts +52 -12
- package/src/room/Room.test.ts +32 -6
- package/src/room/Room.ts +27 -7
- package/src/room/data-stream/incoming/IncomingDataStreamManager.test.ts +16 -20
- package/src/room/data-stream/incoming/IncomingDataStreamManager.ts +5 -5
- package/src/room/data-stream/outgoing/OutgoingDataStreamManager.test.ts +60 -39
- package/src/room/data-stream/outgoing/OutgoingDataStreamManager.ts +4 -4
- package/src/room/defaults.ts +1 -0
- package/src/room/errors.test.ts +36 -0
- package/src/room/errors.ts +27 -0
- package/src/room/events.ts +2 -1
- package/src/room/participant/LocalParticipant.ts +30 -14
- package/src/room/participant/publishUtils.test.ts +133 -0
- package/src/room/participant/publishUtils.ts +54 -38
- package/src/room/rpc/client/RpcClientManager.test.ts +51 -0
- package/src/room/rpc/client/RpcClientManager.ts +32 -15
- package/src/room/track/LocalTrack.ts +18 -7
- package/src/room/track/LocalVideoTrack.ts +25 -8
- package/src/room/track/RemoteAudioTrack.ts +3 -3
- package/src/room/track/RemoteVideoTrack.test.ts +210 -0
- package/src/room/track/RemoteVideoTrack.ts +29 -3
- package/src/room/track/options.ts +1 -1
- package/src/room/track/utils.test.ts +201 -2
- package/src/room/track/utils.ts +88 -0
- package/src/room/utils.test.ts +211 -0
- package/src/room/utils.ts +129 -0
- package/src/test/compressionStreamStubs.ts +53 -0
|
@@ -424,6 +424,13 @@ function wrapWithContext(base, ctxFn) {
|
|
|
424
424
|
return proxy;
|
|
425
425
|
}
|
|
426
426
|
const workerLogger = loglevelExports.getLogger(LoggerNames.E2EE);
|
|
427
|
+
const workerLogLevelListeners = new Set();
|
|
428
|
+
const originalWorkerSetLevel = workerLogger.setLevel.bind(workerLogger);
|
|
429
|
+
workerLogger.setLevel = (level, persist) => {
|
|
430
|
+
originalWorkerSetLevel(level, persist);
|
|
431
|
+
const numeric = workerLogger.getLevel();
|
|
432
|
+
workerLogLevelListeners.forEach(cb => cb(numeric));
|
|
433
|
+
};
|
|
427
434
|
|
|
428
435
|
var e = Object.defineProperty;
|
|
429
436
|
var h = (i, s, t) => s in i ? e(i, s, {
|
|
@@ -4105,285 +4112,163 @@ var CryptorEvent;
|
|
|
4105
4112
|
CryptorEvent["Error"] = "cryptorError";
|
|
4106
4113
|
})(CryptorEvent || (CryptorEvent = {}));
|
|
4107
4114
|
|
|
4108
|
-
|
|
4109
|
-
|
|
4110
|
-
|
|
4111
|
-
|
|
4112
|
-
|
|
4113
|
-
|
|
4114
|
-
|
|
4115
|
-
|
|
4116
|
-
|
|
4117
|
-
|
|
4118
|
-
|
|
4119
|
-
|
|
4120
|
-
|
|
4121
|
-
|
|
4122
|
-
}
|
|
4123
|
-
|
|
4124
|
-
|
|
4125
|
-
const encodedSalt = textEncoder.encode(salt);
|
|
4126
|
-
switch (algorithmName) {
|
|
4127
|
-
case 'HKDF':
|
|
4128
|
-
return {
|
|
4129
|
-
name: 'HKDF',
|
|
4130
|
-
salt: encodedSalt,
|
|
4131
|
-
hash: 'SHA-256',
|
|
4132
|
-
info: new ArrayBuffer(128)
|
|
4133
|
-
};
|
|
4134
|
-
case 'PBKDF2':
|
|
4135
|
-
{
|
|
4136
|
-
return {
|
|
4137
|
-
name: 'PBKDF2',
|
|
4138
|
-
salt: encodedSalt,
|
|
4139
|
-
hash: 'SHA-256',
|
|
4140
|
-
iterations: 100000
|
|
4141
|
-
};
|
|
4142
|
-
}
|
|
4143
|
-
default:
|
|
4144
|
-
throw new Error("algorithm ".concat(algorithmName, " is currently unsupported"));
|
|
4115
|
+
var _a, _b;
|
|
4116
|
+
class TypedPromise extends (_b = Promise) {
|
|
4117
|
+
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
4118
|
+
constructor(executor) {
|
|
4119
|
+
super(executor);
|
|
4120
|
+
}
|
|
4121
|
+
catch(onrejected) {
|
|
4122
|
+
return super.catch(onrejected);
|
|
4123
|
+
}
|
|
4124
|
+
static reject(reason) {
|
|
4125
|
+
return super.reject(reason);
|
|
4126
|
+
}
|
|
4127
|
+
static all(values) {
|
|
4128
|
+
return super.all(values);
|
|
4129
|
+
}
|
|
4130
|
+
static race(values) {
|
|
4131
|
+
return super.race(values);
|
|
4145
4132
|
}
|
|
4146
4133
|
}
|
|
4134
|
+
_a = TypedPromise;
|
|
4135
|
+
TypedPromise.resolve = value => {
|
|
4136
|
+
return Reflect.get(_b, "resolve", _a).call(_a, value);
|
|
4137
|
+
};
|
|
4138
|
+
|
|
4139
|
+
// tiny, simplified version of https://github.com/lancedikson/bowser/blob/master/src/parser-browsers.js
|
|
4140
|
+
// reduced to only differentiate Chrome(ium) based browsers / Firefox / Safari
|
|
4141
|
+
const commonVersionIdentifier = /version\/(\d+(\.?_?\d+)+)/i;
|
|
4142
|
+
let browserDetails;
|
|
4147
4143
|
/**
|
|
4148
|
-
*
|
|
4149
|
-
* See https://tools.ietf.org/html/draft-omara-sframe-00#section-4.3.1
|
|
4144
|
+
* @internal
|
|
4150
4145
|
*/
|
|
4151
|
-
function
|
|
4152
|
-
|
|
4153
|
-
|
|
4154
|
-
|
|
4155
|
-
|
|
4156
|
-
|
|
4157
|
-
|
|
4158
|
-
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4146
|
+
function getBrowser(userAgent) {
|
|
4147
|
+
let force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
4148
|
+
if (typeof navigator === 'undefined') {
|
|
4149
|
+
return;
|
|
4150
|
+
}
|
|
4151
|
+
const ua = (navigator.userAgent).toLowerCase();
|
|
4152
|
+
if (browserDetails === undefined || force) {
|
|
4153
|
+
const browser = browsersList.find(_ref => {
|
|
4154
|
+
let test = _ref.test;
|
|
4155
|
+
return test.test(ua);
|
|
4156
|
+
});
|
|
4157
|
+
browserDetails = browser === null || browser === void 0 ? void 0 : browser.describe(ua);
|
|
4158
|
+
}
|
|
4159
|
+
return browserDetails;
|
|
4160
|
+
}
|
|
4161
|
+
const browsersList = [{
|
|
4162
|
+
test: /firefox|iceweasel|fxios/i,
|
|
4163
|
+
describe(ua) {
|
|
4164
|
+
const browser = {
|
|
4165
|
+
name: 'Firefox',
|
|
4166
|
+
version: getMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i, ua),
|
|
4167
|
+
os: ua.toLowerCase().includes('fxios') ? 'iOS' : undefined,
|
|
4168
|
+
osVersion: getOSVersion(ua)
|
|
4163
4169
|
};
|
|
4164
|
-
|
|
4170
|
+
return browser;
|
|
4171
|
+
}
|
|
4172
|
+
}, {
|
|
4173
|
+
test: /chrom|crios|crmo/i,
|
|
4174
|
+
describe(ua) {
|
|
4175
|
+
const browser = {
|
|
4176
|
+
name: 'Chrome',
|
|
4177
|
+
version: getMatch(/(?:chrome|chromium|crios|crmo)\/(\d+(\.?_?\d+)+)/i, ua),
|
|
4178
|
+
os: ua.toLowerCase().includes('crios') ? 'iOS' : undefined,
|
|
4179
|
+
osVersion: getOSVersion(ua)
|
|
4180
|
+
};
|
|
4181
|
+
return browser;
|
|
4182
|
+
}
|
|
4183
|
+
}, /* Safari */
|
|
4184
|
+
{
|
|
4185
|
+
test: /safari|applewebkit/i,
|
|
4186
|
+
describe(ua) {
|
|
4187
|
+
const browser = {
|
|
4188
|
+
name: 'Safari',
|
|
4189
|
+
version: getMatch(commonVersionIdentifier, ua),
|
|
4190
|
+
os: ua.includes('mobile/') ? 'iOS' : 'macOS',
|
|
4191
|
+
osVersion: getOSVersion(ua)
|
|
4192
|
+
};
|
|
4193
|
+
return browser;
|
|
4194
|
+
}
|
|
4195
|
+
}];
|
|
4196
|
+
function getMatch(exp, ua) {
|
|
4197
|
+
let id = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
4198
|
+
const match = ua.match(exp);
|
|
4199
|
+
return match && match.length >= id && match[id] || '';
|
|
4165
4200
|
}
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
* https://tools.ietf.org/html/draft-omara-sframe-00#section-4.3.5.1
|
|
4169
|
-
*/
|
|
4170
|
-
function ratchet(material, salt) {
|
|
4171
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4172
|
-
const algorithmOptions = getAlgoOptions(material.algorithm.name, salt);
|
|
4173
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/deriveBits
|
|
4174
|
-
return crypto.subtle.deriveBits(algorithmOptions, material, 256);
|
|
4175
|
-
});
|
|
4201
|
+
function getOSVersion(ua) {
|
|
4202
|
+
return ua.includes('mac os') ? getMatch(/\(.+?(\d+_\d+(:?_\d+)?)/, ua, 1).replace(/_/g, '.') : undefined;
|
|
4176
4203
|
}
|
|
4177
|
-
|
|
4178
|
-
|
|
4179
|
-
|
|
4204
|
+
|
|
4205
|
+
var events = {exports: {}};
|
|
4206
|
+
|
|
4207
|
+
var hasRequiredEvents;
|
|
4208
|
+
function requireEvents() {
|
|
4209
|
+
if (hasRequiredEvents) return events.exports;
|
|
4210
|
+
hasRequiredEvents = 1;
|
|
4211
|
+
var R = typeof Reflect === 'object' ? Reflect : null;
|
|
4212
|
+
var ReflectApply = R && typeof R.apply === 'function' ? R.apply : function ReflectApply(target, receiver, args) {
|
|
4213
|
+
return Function.prototype.apply.call(target, receiver, args);
|
|
4214
|
+
};
|
|
4215
|
+
var ReflectOwnKeys;
|
|
4216
|
+
if (R && typeof R.ownKeys === 'function') {
|
|
4217
|
+
ReflectOwnKeys = R.ownKeys;
|
|
4218
|
+
} else if (Object.getOwnPropertySymbols) {
|
|
4219
|
+
ReflectOwnKeys = function ReflectOwnKeys(target) {
|
|
4220
|
+
return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target));
|
|
4221
|
+
};
|
|
4222
|
+
} else {
|
|
4223
|
+
ReflectOwnKeys = function ReflectOwnKeys(target) {
|
|
4224
|
+
return Object.getOwnPropertyNames(target);
|
|
4225
|
+
};
|
|
4180
4226
|
}
|
|
4181
|
-
|
|
4182
|
-
|
|
4183
|
-
|
|
4184
|
-
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
|
|
4189
|
-
|
|
4190
|
-
|
|
4191
|
-
|
|
4192
|
-
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
|
|
4198
|
-
|
|
4199
|
-
|
|
4227
|
+
function ProcessEmitWarning(warning) {
|
|
4228
|
+
if (console && console.warn) console.warn(warning);
|
|
4229
|
+
}
|
|
4230
|
+
var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
|
|
4231
|
+
return value !== value;
|
|
4232
|
+
};
|
|
4233
|
+
function EventEmitter() {
|
|
4234
|
+
EventEmitter.init.call(this);
|
|
4235
|
+
}
|
|
4236
|
+
events.exports = EventEmitter;
|
|
4237
|
+
events.exports.once = once;
|
|
4238
|
+
|
|
4239
|
+
// Backwards-compat with node 0.10.x
|
|
4240
|
+
EventEmitter.EventEmitter = EventEmitter;
|
|
4241
|
+
EventEmitter.prototype._events = undefined;
|
|
4242
|
+
EventEmitter.prototype._eventsCount = 0;
|
|
4243
|
+
EventEmitter.prototype._maxListeners = undefined;
|
|
4244
|
+
|
|
4245
|
+
// By default EventEmitters will print a warning if more than 10 listeners are
|
|
4246
|
+
// added to it. This is a useful default which helps finding memory leaks.
|
|
4247
|
+
var defaultMaxListeners = 10;
|
|
4248
|
+
function checkListener(listener) {
|
|
4249
|
+
if (typeof listener !== 'function') {
|
|
4250
|
+
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
|
|
4200
4251
|
}
|
|
4201
4252
|
}
|
|
4202
|
-
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
|
|
4206
|
-
|
|
4207
|
-
|
|
4208
|
-
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
|
|
4212
|
-
// Need to escape.
|
|
4213
|
-
dataOut.push(kEmulationByte);
|
|
4214
|
-
numConsecutiveZeros = 0;
|
|
4253
|
+
Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
|
|
4254
|
+
enumerable: true,
|
|
4255
|
+
get: function () {
|
|
4256
|
+
return defaultMaxListeners;
|
|
4257
|
+
},
|
|
4258
|
+
set: function (arg) {
|
|
4259
|
+
if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
|
|
4260
|
+
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
|
|
4261
|
+
}
|
|
4262
|
+
defaultMaxListeners = arg;
|
|
4215
4263
|
}
|
|
4216
|
-
|
|
4217
|
-
|
|
4218
|
-
|
|
4219
|
-
|
|
4220
|
-
|
|
4264
|
+
});
|
|
4265
|
+
EventEmitter.init = function () {
|
|
4266
|
+
if (this._events === undefined || this._events === Object.getPrototypeOf(this)._events) {
|
|
4267
|
+
this._events = Object.create(null);
|
|
4268
|
+
this._eventsCount = 0;
|
|
4221
4269
|
}
|
|
4222
|
-
|
|
4223
|
-
|
|
4224
|
-
}
|
|
4225
|
-
|
|
4226
|
-
class DataCryptor {
|
|
4227
|
-
static makeIV(timestamp) {
|
|
4228
|
-
const iv = new ArrayBuffer(12);
|
|
4229
|
-
const ivView = new DataView(iv);
|
|
4230
|
-
const randomBytes = crypto.getRandomValues(new Uint32Array(1));
|
|
4231
|
-
ivView.setUint32(0, randomBytes[0]);
|
|
4232
|
-
ivView.setUint32(4, timestamp);
|
|
4233
|
-
ivView.setUint32(8, timestamp - DataCryptor.sendCount % 0xffff);
|
|
4234
|
-
DataCryptor.sendCount++;
|
|
4235
|
-
return iv;
|
|
4236
|
-
}
|
|
4237
|
-
static encrypt(data, keys) {
|
|
4238
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
4239
|
-
const iv = DataCryptor.makeIV(performance.now());
|
|
4240
|
-
const keySet = yield keys.getKeySet();
|
|
4241
|
-
if (!keySet) {
|
|
4242
|
-
throw new Error('No key set found');
|
|
4243
|
-
}
|
|
4244
|
-
const cipherText = yield crypto.subtle.encrypt({
|
|
4245
|
-
name: ENCRYPTION_ALGORITHM,
|
|
4246
|
-
iv
|
|
4247
|
-
}, keySet.encryptionKey, new Uint8Array(data));
|
|
4248
|
-
return {
|
|
4249
|
-
payload: new Uint8Array(cipherText),
|
|
4250
|
-
iv: new Uint8Array(iv),
|
|
4251
|
-
keyIndex: keys.getCurrentKeyIndex()
|
|
4252
|
-
};
|
|
4253
|
-
});
|
|
4254
|
-
}
|
|
4255
|
-
static decrypt(data_1, iv_1, keys_1) {
|
|
4256
|
-
return __awaiter(this, arguments, void 0, function (data, iv, keys) {
|
|
4257
|
-
let keyIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
4258
|
-
let initialMaterial = arguments.length > 4 ? arguments[4] : undefined;
|
|
4259
|
-
let ratchetOpts = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
|
|
4260
|
-
ratchetCount: 0
|
|
4261
|
-
};
|
|
4262
|
-
return function* () {
|
|
4263
|
-
const keySet = yield keys.getKeySet(keyIndex);
|
|
4264
|
-
if (!keySet) {
|
|
4265
|
-
throw new Error('No key set found');
|
|
4266
|
-
}
|
|
4267
|
-
try {
|
|
4268
|
-
const plainText = yield crypto.subtle.decrypt({
|
|
4269
|
-
name: ENCRYPTION_ALGORITHM,
|
|
4270
|
-
iv
|
|
4271
|
-
}, keySet.encryptionKey, new Uint8Array(data));
|
|
4272
|
-
return {
|
|
4273
|
-
payload: new Uint8Array(plainText)
|
|
4274
|
-
};
|
|
4275
|
-
} catch (error) {
|
|
4276
|
-
if (keys.keyProviderOptions.ratchetWindowSize > 0) {
|
|
4277
|
-
if (ratchetOpts.ratchetCount < keys.keyProviderOptions.ratchetWindowSize) {
|
|
4278
|
-
workerLogger.debug("DataCryptor: ratcheting key attempt ".concat(ratchetOpts.ratchetCount, " of ").concat(keys.keyProviderOptions.ratchetWindowSize, ", for data packet"));
|
|
4279
|
-
let ratchetedKeySet;
|
|
4280
|
-
let ratchetResult;
|
|
4281
|
-
if ((initialMaterial !== null && initialMaterial !== void 0 ? initialMaterial : keySet) === keys.getKeySet(keyIndex)) {
|
|
4282
|
-
// only ratchet if the currently set key is still the same as the one used to decrypt this frame
|
|
4283
|
-
// if not, it might be that a different frame has already ratcheted and we try with that one first
|
|
4284
|
-
ratchetResult = yield keys.ratchetKey(keyIndex, false);
|
|
4285
|
-
ratchetedKeySet = yield deriveKeys(ratchetResult.cryptoKey, keys.keyProviderOptions);
|
|
4286
|
-
}
|
|
4287
|
-
const decryptedData = yield DataCryptor.decrypt(data, iv, keys, keyIndex, initialMaterial, {
|
|
4288
|
-
ratchetCount: ratchetOpts.ratchetCount + 1,
|
|
4289
|
-
encryptionKey: ratchetedKeySet === null || ratchetedKeySet === void 0 ? void 0 : ratchetedKeySet.encryptionKey
|
|
4290
|
-
});
|
|
4291
|
-
if (decryptedData && ratchetedKeySet) {
|
|
4292
|
-
// before updating the keys, make sure that the keySet used for this frame is still the same as the currently set key
|
|
4293
|
-
// if it's not, a new key might have been set already, which we don't want to override
|
|
4294
|
-
if ((initialMaterial !== null && initialMaterial !== void 0 ? initialMaterial : keySet) === keys.getKeySet(keyIndex)) {
|
|
4295
|
-
keys.setKeySet(ratchetedKeySet, keyIndex, ratchetResult);
|
|
4296
|
-
// decryption was successful, set the new key index to reflect the ratcheted key set
|
|
4297
|
-
keys.setCurrentKeyIndex(keyIndex);
|
|
4298
|
-
}
|
|
4299
|
-
}
|
|
4300
|
-
return decryptedData;
|
|
4301
|
-
} else {
|
|
4302
|
-
/**
|
|
4303
|
-
* Because we only set a new key once decryption has been successful,
|
|
4304
|
-
* we can be sure that we don't need to reset the key to the initial material at this point
|
|
4305
|
-
* as the key has not been updated on the keyHandler instance
|
|
4306
|
-
*/
|
|
4307
|
-
workerLogger.warn('DataCryptor: maximum ratchet attempts exceeded');
|
|
4308
|
-
throw new CryptorError("DataCryptor: valid key missing for participant ".concat(keys.participantIdentity), CryptorErrorReason.InvalidKey, keys.participantIdentity);
|
|
4309
|
-
}
|
|
4310
|
-
} else {
|
|
4311
|
-
throw new CryptorError("DataCryptor: Decryption failed: ".concat(error.message), CryptorErrorReason.InvalidKey, keys.participantIdentity);
|
|
4312
|
-
}
|
|
4313
|
-
}
|
|
4314
|
-
}();
|
|
4315
|
-
});
|
|
4316
|
-
}
|
|
4317
|
-
}
|
|
4318
|
-
DataCryptor.sendCount = 0;
|
|
4319
|
-
|
|
4320
|
-
var events = {exports: {}};
|
|
4321
|
-
|
|
4322
|
-
var hasRequiredEvents;
|
|
4323
|
-
function requireEvents() {
|
|
4324
|
-
if (hasRequiredEvents) return events.exports;
|
|
4325
|
-
hasRequiredEvents = 1;
|
|
4326
|
-
var R = typeof Reflect === 'object' ? Reflect : null;
|
|
4327
|
-
var ReflectApply = R && typeof R.apply === 'function' ? R.apply : function ReflectApply(target, receiver, args) {
|
|
4328
|
-
return Function.prototype.apply.call(target, receiver, args);
|
|
4329
|
-
};
|
|
4330
|
-
var ReflectOwnKeys;
|
|
4331
|
-
if (R && typeof R.ownKeys === 'function') {
|
|
4332
|
-
ReflectOwnKeys = R.ownKeys;
|
|
4333
|
-
} else if (Object.getOwnPropertySymbols) {
|
|
4334
|
-
ReflectOwnKeys = function ReflectOwnKeys(target) {
|
|
4335
|
-
return Object.getOwnPropertyNames(target).concat(Object.getOwnPropertySymbols(target));
|
|
4336
|
-
};
|
|
4337
|
-
} else {
|
|
4338
|
-
ReflectOwnKeys = function ReflectOwnKeys(target) {
|
|
4339
|
-
return Object.getOwnPropertyNames(target);
|
|
4340
|
-
};
|
|
4341
|
-
}
|
|
4342
|
-
function ProcessEmitWarning(warning) {
|
|
4343
|
-
if (console && console.warn) console.warn(warning);
|
|
4344
|
-
}
|
|
4345
|
-
var NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {
|
|
4346
|
-
return value !== value;
|
|
4347
|
-
};
|
|
4348
|
-
function EventEmitter() {
|
|
4349
|
-
EventEmitter.init.call(this);
|
|
4350
|
-
}
|
|
4351
|
-
events.exports = EventEmitter;
|
|
4352
|
-
events.exports.once = once;
|
|
4353
|
-
|
|
4354
|
-
// Backwards-compat with node 0.10.x
|
|
4355
|
-
EventEmitter.EventEmitter = EventEmitter;
|
|
4356
|
-
EventEmitter.prototype._events = undefined;
|
|
4357
|
-
EventEmitter.prototype._eventsCount = 0;
|
|
4358
|
-
EventEmitter.prototype._maxListeners = undefined;
|
|
4359
|
-
|
|
4360
|
-
// By default EventEmitters will print a warning if more than 10 listeners are
|
|
4361
|
-
// added to it. This is a useful default which helps finding memory leaks.
|
|
4362
|
-
var defaultMaxListeners = 10;
|
|
4363
|
-
function checkListener(listener) {
|
|
4364
|
-
if (typeof listener !== 'function') {
|
|
4365
|
-
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
|
|
4366
|
-
}
|
|
4367
|
-
}
|
|
4368
|
-
Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
|
|
4369
|
-
enumerable: true,
|
|
4370
|
-
get: function () {
|
|
4371
|
-
return defaultMaxListeners;
|
|
4372
|
-
},
|
|
4373
|
-
set: function (arg) {
|
|
4374
|
-
if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {
|
|
4375
|
-
throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + arg + '.');
|
|
4376
|
-
}
|
|
4377
|
-
defaultMaxListeners = arg;
|
|
4378
|
-
}
|
|
4379
|
-
});
|
|
4380
|
-
EventEmitter.init = function () {
|
|
4381
|
-
if (this._events === undefined || this._events === Object.getPrototypeOf(this)._events) {
|
|
4382
|
-
this._events = Object.create(null);
|
|
4383
|
-
this._eventsCount = 0;
|
|
4384
|
-
}
|
|
4385
|
-
this._maxListeners = this._maxListeners || undefined;
|
|
4386
|
-
};
|
|
4270
|
+
this._maxListeners = this._maxListeners || undefined;
|
|
4271
|
+
};
|
|
4387
4272
|
|
|
4388
4273
|
// Obviously not all Emitters should be limited to 10. This function allows
|
|
4389
4274
|
// that to be increased. Set to zero for unlimited.
|
|
@@ -4704,96 +4589,6 @@ function requireEvents() {
|
|
|
4704
4589
|
|
|
4705
4590
|
var eventsExports = requireEvents();
|
|
4706
4591
|
|
|
4707
|
-
var _a, _b;
|
|
4708
|
-
class TypedPromise extends (_b = Promise) {
|
|
4709
|
-
// eslint-disable-next-line @typescript-eslint/no-useless-constructor
|
|
4710
|
-
constructor(executor) {
|
|
4711
|
-
super(executor);
|
|
4712
|
-
}
|
|
4713
|
-
catch(onrejected) {
|
|
4714
|
-
return super.catch(onrejected);
|
|
4715
|
-
}
|
|
4716
|
-
static reject(reason) {
|
|
4717
|
-
return super.reject(reason);
|
|
4718
|
-
}
|
|
4719
|
-
static all(values) {
|
|
4720
|
-
return super.all(values);
|
|
4721
|
-
}
|
|
4722
|
-
static race(values) {
|
|
4723
|
-
return super.race(values);
|
|
4724
|
-
}
|
|
4725
|
-
}
|
|
4726
|
-
_a = TypedPromise;
|
|
4727
|
-
TypedPromise.resolve = value => {
|
|
4728
|
-
return Reflect.get(_b, "resolve", _a).call(_a, value);
|
|
4729
|
-
};
|
|
4730
|
-
|
|
4731
|
-
// tiny, simplified version of https://github.com/lancedikson/bowser/blob/master/src/parser-browsers.js
|
|
4732
|
-
// reduced to only differentiate Chrome(ium) based browsers / Firefox / Safari
|
|
4733
|
-
const commonVersionIdentifier = /version\/(\d+(\.?_?\d+)+)/i;
|
|
4734
|
-
let browserDetails;
|
|
4735
|
-
/**
|
|
4736
|
-
* @internal
|
|
4737
|
-
*/
|
|
4738
|
-
function getBrowser(userAgent) {
|
|
4739
|
-
let force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
4740
|
-
if (typeof navigator === 'undefined') {
|
|
4741
|
-
return;
|
|
4742
|
-
}
|
|
4743
|
-
const ua = (navigator.userAgent).toLowerCase();
|
|
4744
|
-
if (browserDetails === undefined || force) {
|
|
4745
|
-
const browser = browsersList.find(_ref => {
|
|
4746
|
-
let test = _ref.test;
|
|
4747
|
-
return test.test(ua);
|
|
4748
|
-
});
|
|
4749
|
-
browserDetails = browser === null || browser === void 0 ? void 0 : browser.describe(ua);
|
|
4750
|
-
}
|
|
4751
|
-
return browserDetails;
|
|
4752
|
-
}
|
|
4753
|
-
const browsersList = [{
|
|
4754
|
-
test: /firefox|iceweasel|fxios/i,
|
|
4755
|
-
describe(ua) {
|
|
4756
|
-
const browser = {
|
|
4757
|
-
name: 'Firefox',
|
|
4758
|
-
version: getMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i, ua),
|
|
4759
|
-
os: ua.toLowerCase().includes('fxios') ? 'iOS' : undefined,
|
|
4760
|
-
osVersion: getOSVersion(ua)
|
|
4761
|
-
};
|
|
4762
|
-
return browser;
|
|
4763
|
-
}
|
|
4764
|
-
}, {
|
|
4765
|
-
test: /chrom|crios|crmo/i,
|
|
4766
|
-
describe(ua) {
|
|
4767
|
-
const browser = {
|
|
4768
|
-
name: 'Chrome',
|
|
4769
|
-
version: getMatch(/(?:chrome|chromium|crios|crmo)\/(\d+(\.?_?\d+)+)/i, ua),
|
|
4770
|
-
os: ua.toLowerCase().includes('crios') ? 'iOS' : undefined,
|
|
4771
|
-
osVersion: getOSVersion(ua)
|
|
4772
|
-
};
|
|
4773
|
-
return browser;
|
|
4774
|
-
}
|
|
4775
|
-
}, /* Safari */
|
|
4776
|
-
{
|
|
4777
|
-
test: /safari|applewebkit/i,
|
|
4778
|
-
describe(ua) {
|
|
4779
|
-
const browser = {
|
|
4780
|
-
name: 'Safari',
|
|
4781
|
-
version: getMatch(commonVersionIdentifier, ua),
|
|
4782
|
-
os: ua.includes('mobile/') ? 'iOS' : 'macOS',
|
|
4783
|
-
osVersion: getOSVersion(ua)
|
|
4784
|
-
};
|
|
4785
|
-
return browser;
|
|
4786
|
-
}
|
|
4787
|
-
}];
|
|
4788
|
-
function getMatch(exp, ua) {
|
|
4789
|
-
let id = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
|
|
4790
|
-
const match = ua.match(exp);
|
|
4791
|
-
return match && match.length >= id && match[id] || '';
|
|
4792
|
-
}
|
|
4793
|
-
function getOSVersion(ua) {
|
|
4794
|
-
return ua.includes('mac os') ? getMatch(/\(.+?(\d+_\d+(:?_\d+)?)/, ua, 1).replace(/_/g, '.') : undefined;
|
|
4795
|
-
}
|
|
4796
|
-
|
|
4797
4592
|
/**
|
|
4798
4593
|
* Events are the primary way LiveKit notifies your application of changes.
|
|
4799
4594
|
*
|
|
@@ -4995,7 +4790,7 @@ var RoomEvent;
|
|
|
4995
4790
|
* Data packets provides the ability to use LiveKit to send/receive arbitrary payloads.
|
|
4996
4791
|
* All participants in the room will receive the messages sent to the room.
|
|
4997
4792
|
*
|
|
4998
|
-
* args: (payload: NonSharedUint8Array, participant: [[Participant]], kind: [[DataPacket_Kind]], topic?: string)
|
|
4793
|
+
* args: (payload: NonSharedUint8Array, participant: [[Participant]] | undefined, kind: [[DataPacket_Kind]], topic?: string, encryptionType?: Encryption_Type, participantIdentity?: string)
|
|
4999
4794
|
*/
|
|
5000
4795
|
RoomEvent["DataReceived"] = "dataReceived";
|
|
5001
4796
|
/**
|
|
@@ -5353,6 +5148,7 @@ var EngineEvent;
|
|
|
5353
5148
|
EngineEvent["Joined"] = "joined";
|
|
5354
5149
|
EngineEvent["TokenRefreshed"] = "tokenRefreshed";
|
|
5355
5150
|
EngineEvent["ServerRegionsReported"] = "serverRegionsReported";
|
|
5151
|
+
EngineEvent["RequestSubscribedCodecRefresh"] = "requestSubscribedCodecRefresh";
|
|
5356
5152
|
})(EngineEvent || (EngineEvent = {}));
|
|
5357
5153
|
var TrackEvent;
|
|
5358
5154
|
(function (TrackEvent) {
|
|
@@ -6156,16 +5952,290 @@ function isWeb() {
|
|
|
6156
5952
|
return typeof document !== 'undefined';
|
|
6157
5953
|
}
|
|
6158
5954
|
|
|
6159
|
-
function
|
|
6160
|
-
|
|
5955
|
+
function getErrorDescription(error, errorCategory) {
|
|
5956
|
+
if (error instanceof Error) {
|
|
5957
|
+
if (error.name && error.message) {
|
|
5958
|
+
return "".concat(error.name, ": ").concat(error.message);
|
|
5959
|
+
}
|
|
5960
|
+
return error.name;
|
|
5961
|
+
}
|
|
5962
|
+
return "Encountered unknown ".concat(errorCategory, " error: ").concat(String(error));
|
|
6161
5963
|
}
|
|
6162
5964
|
|
|
6163
|
-
|
|
6164
|
-
|
|
6165
|
-
|
|
6166
|
-
|
|
6167
|
-
|
|
6168
|
-
|
|
5965
|
+
function isVideoFrame(frame) {
|
|
5966
|
+
return 'type' in frame;
|
|
5967
|
+
}
|
|
5968
|
+
function importKey(keyBytes_1) {
|
|
5969
|
+
return __awaiter(this, arguments, void 0, function (keyBytes) {
|
|
5970
|
+
let algorithm = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
5971
|
+
name: ENCRYPTION_ALGORITHM
|
|
5972
|
+
};
|
|
5973
|
+
let usage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'encrypt';
|
|
5974
|
+
return function* () {
|
|
5975
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/importKey
|
|
5976
|
+
return crypto.subtle.importKey('raw', keyBytes, algorithm, false, usage === 'derive' ? ['deriveBits', 'deriveKey'] : ['encrypt', 'decrypt']);
|
|
5977
|
+
}();
|
|
5978
|
+
});
|
|
5979
|
+
}
|
|
5980
|
+
function getAlgoOptions(algorithmName, salt) {
|
|
5981
|
+
const textEncoder = new TextEncoder();
|
|
5982
|
+
const encodedSalt = textEncoder.encode(salt);
|
|
5983
|
+
switch (algorithmName) {
|
|
5984
|
+
case 'HKDF':
|
|
5985
|
+
return {
|
|
5986
|
+
name: 'HKDF',
|
|
5987
|
+
salt: encodedSalt,
|
|
5988
|
+
hash: 'SHA-256',
|
|
5989
|
+
info: new ArrayBuffer(128)
|
|
5990
|
+
};
|
|
5991
|
+
case 'PBKDF2':
|
|
5992
|
+
{
|
|
5993
|
+
return {
|
|
5994
|
+
name: 'PBKDF2',
|
|
5995
|
+
salt: encodedSalt,
|
|
5996
|
+
hash: 'SHA-256',
|
|
5997
|
+
iterations: 100000
|
|
5998
|
+
};
|
|
5999
|
+
}
|
|
6000
|
+
default:
|
|
6001
|
+
throw new Error("algorithm ".concat(algorithmName, " is currently unsupported"));
|
|
6002
|
+
}
|
|
6003
|
+
}
|
|
6004
|
+
/**
|
|
6005
|
+
* Derives a set of keys from the master key.
|
|
6006
|
+
* See https://tools.ietf.org/html/draft-omara-sframe-00#section-4.3.1
|
|
6007
|
+
*/
|
|
6008
|
+
function deriveKeys(material, options) {
|
|
6009
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6010
|
+
const algorithmOptions = getAlgoOptions(material.algorithm.name, options.ratchetSalt);
|
|
6011
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/deriveKey#HKDF
|
|
6012
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/HkdfParams
|
|
6013
|
+
const encryptionKey = yield crypto.subtle.deriveKey(algorithmOptions, material, {
|
|
6014
|
+
name: ENCRYPTION_ALGORITHM,
|
|
6015
|
+
length: options.keySize
|
|
6016
|
+
}, false, ['encrypt', 'decrypt']);
|
|
6017
|
+
return {
|
|
6018
|
+
material,
|
|
6019
|
+
encryptionKey
|
|
6020
|
+
};
|
|
6021
|
+
});
|
|
6022
|
+
}
|
|
6023
|
+
/**
|
|
6024
|
+
* Ratchets a key. See
|
|
6025
|
+
* https://tools.ietf.org/html/draft-omara-sframe-00#section-4.3.5.1
|
|
6026
|
+
*/
|
|
6027
|
+
function ratchet(material, salt) {
|
|
6028
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6029
|
+
const algorithmOptions = getAlgoOptions(material.algorithm.name, salt);
|
|
6030
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/deriveBits
|
|
6031
|
+
return crypto.subtle.deriveBits(algorithmOptions, material, 256);
|
|
6032
|
+
});
|
|
6033
|
+
}
|
|
6034
|
+
function needsRbspUnescaping(frameData) {
|
|
6035
|
+
for (var i = 0; i < frameData.length - 3; i++) {
|
|
6036
|
+
if (frameData[i] == 0 && frameData[i + 1] == 0 && frameData[i + 2] == 3) return true;
|
|
6037
|
+
}
|
|
6038
|
+
return false;
|
|
6039
|
+
}
|
|
6040
|
+
function parseRbsp(stream) {
|
|
6041
|
+
const dataOut = [];
|
|
6042
|
+
var length = stream.length;
|
|
6043
|
+
for (var i = 0; i < stream.length;) {
|
|
6044
|
+
// Be careful about over/underflow here. byte_length_ - 3 can underflow, and
|
|
6045
|
+
// i + 3 can overflow, but byte_length_ - i can't, because i < byte_length_
|
|
6046
|
+
// above, and that expression will produce the number of bytes left in
|
|
6047
|
+
// the stream including the byte at i.
|
|
6048
|
+
if (length - i >= 3 && !stream[i] && !stream[i + 1] && stream[i + 2] == 3) {
|
|
6049
|
+
// Two rbsp bytes.
|
|
6050
|
+
dataOut.push(stream[i++]);
|
|
6051
|
+
dataOut.push(stream[i++]);
|
|
6052
|
+
// Skip the emulation byte.
|
|
6053
|
+
i++;
|
|
6054
|
+
} else {
|
|
6055
|
+
// Single rbsp byte.
|
|
6056
|
+
dataOut.push(stream[i++]);
|
|
6057
|
+
}
|
|
6058
|
+
}
|
|
6059
|
+
return new Uint8Array(dataOut);
|
|
6060
|
+
}
|
|
6061
|
+
const kZerosInStartSequence = 2;
|
|
6062
|
+
const kEmulationByte = 3;
|
|
6063
|
+
function writeRbsp(data_in) {
|
|
6064
|
+
const dataOut = [];
|
|
6065
|
+
var numConsecutiveZeros = 0;
|
|
6066
|
+
for (var i = 0; i < data_in.length; ++i) {
|
|
6067
|
+
var byte = data_in[i];
|
|
6068
|
+
if (byte <= kEmulationByte && numConsecutiveZeros >= kZerosInStartSequence) {
|
|
6069
|
+
// Need to escape.
|
|
6070
|
+
dataOut.push(kEmulationByte);
|
|
6071
|
+
numConsecutiveZeros = 0;
|
|
6072
|
+
}
|
|
6073
|
+
dataOut.push(byte);
|
|
6074
|
+
if (byte == 0) {
|
|
6075
|
+
++numConsecutiveZeros;
|
|
6076
|
+
} else {
|
|
6077
|
+
numConsecutiveZeros = 0;
|
|
6078
|
+
}
|
|
6079
|
+
}
|
|
6080
|
+
return new Uint8Array(dataOut);
|
|
6081
|
+
}
|
|
6082
|
+
|
|
6083
|
+
class DataCryptor {
|
|
6084
|
+
static makeIV(timestamp) {
|
|
6085
|
+
const iv = new ArrayBuffer(12);
|
|
6086
|
+
const ivView = new DataView(iv);
|
|
6087
|
+
const randomBytes = crypto.getRandomValues(new Uint32Array(1));
|
|
6088
|
+
ivView.setUint32(0, randomBytes[0]);
|
|
6089
|
+
ivView.setUint32(4, timestamp);
|
|
6090
|
+
ivView.setUint32(8, timestamp - DataCryptor.sendCount % 0xffff);
|
|
6091
|
+
DataCryptor.sendCount++;
|
|
6092
|
+
return iv;
|
|
6093
|
+
}
|
|
6094
|
+
static encrypt(data, keys) {
|
|
6095
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
6096
|
+
const iv = DataCryptor.makeIV(performance.now());
|
|
6097
|
+
const keySet = yield keys.getKeySet();
|
|
6098
|
+
if (!keySet) {
|
|
6099
|
+
throw new Error('No key set found');
|
|
6100
|
+
}
|
|
6101
|
+
const cipherText = yield crypto.subtle.encrypt({
|
|
6102
|
+
name: ENCRYPTION_ALGORITHM,
|
|
6103
|
+
iv
|
|
6104
|
+
}, keySet.encryptionKey, new Uint8Array(data));
|
|
6105
|
+
return {
|
|
6106
|
+
payload: new Uint8Array(cipherText),
|
|
6107
|
+
iv: new Uint8Array(iv),
|
|
6108
|
+
keyIndex: keys.getCurrentKeyIndex()
|
|
6109
|
+
};
|
|
6110
|
+
});
|
|
6111
|
+
}
|
|
6112
|
+
static decrypt(data_1, iv_1, keys_1) {
|
|
6113
|
+
return __awaiter(this, arguments, void 0, function (data, iv, keys) {
|
|
6114
|
+
let keyIndex = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
|
|
6115
|
+
let initialMaterial = arguments.length > 4 ? arguments[4] : undefined;
|
|
6116
|
+
let ratchetOpts = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {
|
|
6117
|
+
ratchetCount: 0
|
|
6118
|
+
};
|
|
6119
|
+
return function* () {
|
|
6120
|
+
const keySet = yield keys.getKeySet(keyIndex);
|
|
6121
|
+
if (!keySet) {
|
|
6122
|
+
throw new Error('No key set found');
|
|
6123
|
+
}
|
|
6124
|
+
try {
|
|
6125
|
+
const plainText = yield crypto.subtle.decrypt({
|
|
6126
|
+
name: ENCRYPTION_ALGORITHM,
|
|
6127
|
+
iv
|
|
6128
|
+
}, keySet.encryptionKey, new Uint8Array(data));
|
|
6129
|
+
return {
|
|
6130
|
+
payload: new Uint8Array(plainText)
|
|
6131
|
+
};
|
|
6132
|
+
} catch (error) {
|
|
6133
|
+
if (keys.keyProviderOptions.ratchetWindowSize > 0) {
|
|
6134
|
+
if (ratchetOpts.ratchetCount < keys.keyProviderOptions.ratchetWindowSize) {
|
|
6135
|
+
workerLogger.debug("DataCryptor: ratcheting key attempt ".concat(ratchetOpts.ratchetCount, " of ").concat(keys.keyProviderOptions.ratchetWindowSize, ", for data packet"));
|
|
6136
|
+
let ratchetedKeySet;
|
|
6137
|
+
let ratchetResult;
|
|
6138
|
+
if ((initialMaterial !== null && initialMaterial !== void 0 ? initialMaterial : keySet) === keys.getKeySet(keyIndex)) {
|
|
6139
|
+
// only ratchet if the currently set key is still the same as the one used to decrypt this frame
|
|
6140
|
+
// if not, it might be that a different frame has already ratcheted and we try with that one first
|
|
6141
|
+
ratchetResult = yield keys.ratchetKey(keyIndex, false);
|
|
6142
|
+
ratchetedKeySet = yield deriveKeys(ratchetResult.cryptoKey, keys.keyProviderOptions);
|
|
6143
|
+
}
|
|
6144
|
+
const decryptedData = yield DataCryptor.decrypt(data, iv, keys, keyIndex, initialMaterial, {
|
|
6145
|
+
ratchetCount: ratchetOpts.ratchetCount + 1,
|
|
6146
|
+
encryptionKey: ratchetedKeySet === null || ratchetedKeySet === void 0 ? void 0 : ratchetedKeySet.encryptionKey
|
|
6147
|
+
});
|
|
6148
|
+
if (decryptedData && ratchetedKeySet) {
|
|
6149
|
+
// before updating the keys, make sure that the keySet used for this frame is still the same as the currently set key
|
|
6150
|
+
// if it's not, a new key might have been set already, which we don't want to override
|
|
6151
|
+
if ((initialMaterial !== null && initialMaterial !== void 0 ? initialMaterial : keySet) === keys.getKeySet(keyIndex)) {
|
|
6152
|
+
keys.setKeySet(ratchetedKeySet, keyIndex, ratchetResult);
|
|
6153
|
+
// decryption was successful, set the new key index to reflect the ratcheted key set
|
|
6154
|
+
keys.setCurrentKeyIndex(keyIndex);
|
|
6155
|
+
}
|
|
6156
|
+
}
|
|
6157
|
+
return decryptedData;
|
|
6158
|
+
} else {
|
|
6159
|
+
/**
|
|
6160
|
+
* Because we only set a new key once decryption has been successful,
|
|
6161
|
+
* we can be sure that we don't need to reset the key to the initial material at this point
|
|
6162
|
+
* as the key has not been updated on the keyHandler instance
|
|
6163
|
+
*/
|
|
6164
|
+
workerLogger.warn('DataCryptor: maximum ratchet attempts exceeded');
|
|
6165
|
+
throw new CryptorError("DataCryptor: valid key missing for participant ".concat(keys.participantIdentity), CryptorErrorReason.InvalidKey, keys.participantIdentity);
|
|
6166
|
+
}
|
|
6167
|
+
} else {
|
|
6168
|
+
throw new CryptorError("DataCryptor: Decryption failed: ".concat(getErrorDescription(error, 'decryption')), CryptorErrorReason.InvalidKey, keys.participantIdentity);
|
|
6169
|
+
}
|
|
6170
|
+
}
|
|
6171
|
+
}();
|
|
6172
|
+
});
|
|
6173
|
+
}
|
|
6174
|
+
}
|
|
6175
|
+
DataCryptor.sendCount = 0;
|
|
6176
|
+
|
|
6177
|
+
/**
|
|
6178
|
+
* Per-key rate limiter for repeated errors. Prevents log/emit floods and the
|
|
6179
|
+
* unbounded map growth that a per-event log would cause when a broken key
|
|
6180
|
+
* keeps producing failures.
|
|
6181
|
+
*/
|
|
6182
|
+
class ErrorRateLimiter {
|
|
6183
|
+
constructor() {
|
|
6184
|
+
let throttleMs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 1000;
|
|
6185
|
+
let windowMs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 60000;
|
|
6186
|
+
let maxPerWindow = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 5;
|
|
6187
|
+
this.throttleMs = throttleMs;
|
|
6188
|
+
this.windowMs = windowMs;
|
|
6189
|
+
this.maxPerWindow = maxPerWindow;
|
|
6190
|
+
this.lastAt = new Map();
|
|
6191
|
+
this.counts = new Map();
|
|
6192
|
+
}
|
|
6193
|
+
reset() {
|
|
6194
|
+
this.lastAt.clear();
|
|
6195
|
+
this.counts.clear();
|
|
6196
|
+
}
|
|
6197
|
+
countFor(key) {
|
|
6198
|
+
var _a;
|
|
6199
|
+
return (_a = this.counts.get(key)) !== null && _a !== void 0 ? _a : 0;
|
|
6200
|
+
}
|
|
6201
|
+
/**
|
|
6202
|
+
* Returns true if the caller should emit for this key. Invokes `onSuppress`
|
|
6203
|
+
* exactly once per window when the per-window limit is first crossed.
|
|
6204
|
+
*/
|
|
6205
|
+
shouldEmit(key, onSuppress) {
|
|
6206
|
+
var _a, _b;
|
|
6207
|
+
const now = Date.now();
|
|
6208
|
+
const last = (_a = this.lastAt.get(key)) !== null && _a !== void 0 ? _a : 0;
|
|
6209
|
+
const count = (_b = this.counts.get(key)) !== null && _b !== void 0 ? _b : 0;
|
|
6210
|
+
if (now - last > this.windowMs) {
|
|
6211
|
+
this.counts.set(key, 0);
|
|
6212
|
+
this.lastAt.set(key, now);
|
|
6213
|
+
return true;
|
|
6214
|
+
}
|
|
6215
|
+
if (now - last < this.throttleMs) return false;
|
|
6216
|
+
if (count >= this.maxPerWindow) {
|
|
6217
|
+
if (count === this.maxPerWindow) {
|
|
6218
|
+
onSuppress === null || onSuppress === void 0 ? void 0 : onSuppress();
|
|
6219
|
+
this.counts.set(key, count + 1);
|
|
6220
|
+
}
|
|
6221
|
+
return false;
|
|
6222
|
+
}
|
|
6223
|
+
this.lastAt.set(key, now);
|
|
6224
|
+
this.counts.set(key, count + 1);
|
|
6225
|
+
return true;
|
|
6226
|
+
}
|
|
6227
|
+
}
|
|
6228
|
+
|
|
6229
|
+
function hasFrameMetadataPublishOptions(options) {
|
|
6230
|
+
return !!((options === null || options === void 0 ? void 0 : options.timestamp) || (options === null || options === void 0 ? void 0 : options.frameId));
|
|
6231
|
+
}
|
|
6232
|
+
|
|
6233
|
+
const PACKET_TRAILER_MAGIC = Uint8Array.from(['L'.charCodeAt(0), 'K'.charCodeAt(0), 'T'.charCodeAt(0), 'S'.charCodeAt(0)]);
|
|
6234
|
+
const PACKET_TRAILER_TIMESTAMP_TAG = 0x01;
|
|
6235
|
+
const PACKET_TRAILER_FRAME_ID_TAG = 0x02;
|
|
6236
|
+
const PACKET_TRAILER_USER_DATA_TAG = 0x03;
|
|
6237
|
+
const PACKET_TRAILER_ENVELOPE_SIZE = 5;
|
|
6238
|
+
const TIMESTAMP_TLV_SIZE = 10;
|
|
6169
6239
|
const FRAME_ID_TLV_SIZE = 6;
|
|
6170
6240
|
function appendPacketTrailer(data, userTimestamp, frameId) {
|
|
6171
6241
|
const hasTimestamp = userTimestamp !== BigInt(0);
|
|
@@ -6686,14 +6756,7 @@ class FrameCryptor extends BaseFrameCryptor {
|
|
|
6686
6756
|
*/
|
|
6687
6757
|
this.hasFrameMetadata = false;
|
|
6688
6758
|
this.frameMetadataFrameId = 0;
|
|
6689
|
-
|
|
6690
|
-
* Throttling mechanism for decryption errors to prevent memory leaks
|
|
6691
|
-
*/
|
|
6692
|
-
this.lastErrorTimestamp = new Map();
|
|
6693
|
-
this.errorCounts = new Map();
|
|
6694
|
-
this.ERROR_THROTTLE_MS = 1000; // Emit error at most once per second
|
|
6695
|
-
this.MAX_ERRORS_PER_MINUTE = 5; // Maximum errors to emit per minute per key
|
|
6696
|
-
this.ERROR_WINDOW_MS = 60000; // 1 minute window
|
|
6759
|
+
this.errorLimiter = new ErrorRateLimiter();
|
|
6697
6760
|
/** grace period for a teardown or a resubscribe to land before we report a stalled track */
|
|
6698
6761
|
this.UNDECRYPTED_TRACK_GRACE_MS = 2000;
|
|
6699
6762
|
/**
|
|
@@ -6748,8 +6811,7 @@ class FrameCryptor extends BaseFrameCryptor {
|
|
|
6748
6811
|
clearTimeout(this.undecryptedTrackTimeout);
|
|
6749
6812
|
this.undecryptedTrackTimeout = undefined;
|
|
6750
6813
|
this.participantIdentity = undefined;
|
|
6751
|
-
this.
|
|
6752
|
-
this.errorCounts = new Map();
|
|
6814
|
+
this.errorLimiter.reset();
|
|
6753
6815
|
}
|
|
6754
6816
|
isEnabled() {
|
|
6755
6817
|
if (this.participantIdentity) {
|
|
@@ -6939,58 +7001,21 @@ class FrameCryptor extends BaseFrameCryptor {
|
|
|
6939
7001
|
}));
|
|
6940
7002
|
this.sifTrailer = trailer;
|
|
6941
7003
|
}
|
|
6942
|
-
/**
|
|
6943
|
-
* Checks if we should emit an error based on throttling rules to prevent memory leaks
|
|
6944
|
-
* @param errorKey - unique key identifying the error context
|
|
6945
|
-
* @returns true if the error should be emitted, false otherwise
|
|
6946
|
-
*/
|
|
6947
|
-
shouldEmitError(errorKey) {
|
|
6948
|
-
var _a, _b;
|
|
6949
|
-
const now = Date.now();
|
|
6950
|
-
const lastErrorTime = (_a = this.lastErrorTimestamp.get(errorKey)) !== null && _a !== void 0 ? _a : 0;
|
|
6951
|
-
const errorCount = (_b = this.errorCounts.get(errorKey)) !== null && _b !== void 0 ? _b : 0;
|
|
6952
|
-
// Reset count if we're in a new time window
|
|
6953
|
-
if (now - lastErrorTime > this.ERROR_WINDOW_MS) {
|
|
6954
|
-
this.errorCounts.set(errorKey, 0);
|
|
6955
|
-
this.lastErrorTimestamp.set(errorKey, now);
|
|
6956
|
-
return true;
|
|
6957
|
-
}
|
|
6958
|
-
// Check if we've exceeded the throttle time
|
|
6959
|
-
if (now - lastErrorTime < this.ERROR_THROTTLE_MS) {
|
|
6960
|
-
return false;
|
|
6961
|
-
}
|
|
6962
|
-
// Check if we've exceeded the max errors per window
|
|
6963
|
-
if (errorCount >= this.MAX_ERRORS_PER_MINUTE) {
|
|
6964
|
-
// Only log a warning once when hitting the limit
|
|
6965
|
-
if (errorCount === this.MAX_ERRORS_PER_MINUTE) {
|
|
6966
|
-
workerLogger.warn("Suppressing further decryption errors for ".concat(this.participantIdentity), Object.assign(Object.assign({}, this.logContext), {
|
|
6967
|
-
errorKey
|
|
6968
|
-
}));
|
|
6969
|
-
this.errorCounts.set(errorKey, errorCount + 1);
|
|
6970
|
-
}
|
|
6971
|
-
return false;
|
|
6972
|
-
}
|
|
6973
|
-
// Update tracking
|
|
6974
|
-
this.lastErrorTimestamp.set(errorKey, now);
|
|
6975
|
-
this.errorCounts.set(errorKey, errorCount + 1);
|
|
6976
|
-
return true;
|
|
6977
|
-
}
|
|
6978
|
-
/**
|
|
6979
|
-
* Emits a throttled error to prevent memory leaks from repeated decryption failures
|
|
6980
|
-
* @param error - the CryptorError to emit
|
|
6981
|
-
*/
|
|
6982
7004
|
emitThrottledError(error) {
|
|
6983
|
-
var _a;
|
|
6984
7005
|
const errorKey = "".concat(this.participantIdentity, "-").concat(error.reason, "-decrypt");
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
7006
|
+
const emit = this.errorLimiter.shouldEmit(errorKey, () => {
|
|
7007
|
+
workerLogger.warn("Suppressing further decryption errors for ".concat(this.participantIdentity), Object.assign(Object.assign({}, this.logContext), {
|
|
7008
|
+
errorKey
|
|
7009
|
+
}));
|
|
7010
|
+
});
|
|
7011
|
+
if (!emit) return;
|
|
7012
|
+
const count = this.errorLimiter.countFor(errorKey);
|
|
7013
|
+
if (count > 1) {
|
|
7014
|
+
workerLogger.debug("Decryption error (".concat(count, " occurrences in window)"), Object.assign(Object.assign({}, this.logContext), {
|
|
7015
|
+
reason: CryptorErrorReason[error.reason]
|
|
7016
|
+
}));
|
|
6993
7017
|
}
|
|
7018
|
+
this.emit(CryptorEvent.Error, error);
|
|
6994
7019
|
}
|
|
6995
7020
|
/**
|
|
6996
7021
|
* Function that will be injected in a stream and will encrypt the given encoded frames.
|
|
@@ -7069,7 +7094,9 @@ class FrameCryptor extends BaseFrameCryptor {
|
|
|
7069
7094
|
return controller.enqueue(encodedFrame);
|
|
7070
7095
|
} catch (e) {
|
|
7071
7096
|
// TODO: surface this to the app.
|
|
7072
|
-
workerLogger.error(
|
|
7097
|
+
workerLogger.error("error while encrypting", Object.assign(Object.assign({}, this.logContext), {
|
|
7098
|
+
error: e
|
|
7099
|
+
}));
|
|
7073
7100
|
}
|
|
7074
7101
|
} else {
|
|
7075
7102
|
workerLogger.debug('failed to encrypt, emitting error', this.logContext);
|
|
@@ -7268,7 +7295,7 @@ class FrameCryptor extends BaseFrameCryptor {
|
|
|
7268
7295
|
throw new CryptorError("valid key missing for participant ".concat(_this.participantIdentity), CryptorErrorReason.InvalidKey, _this.participantIdentity);
|
|
7269
7296
|
}
|
|
7270
7297
|
} else {
|
|
7271
|
-
throw new CryptorError("Decryption failed: ".concat(error
|
|
7298
|
+
throw new CryptorError("Decryption failed: ".concat(getErrorDescription(error, 'decryption')), CryptorErrorReason.InvalidKey, _this.participantIdentity);
|
|
7272
7299
|
}
|
|
7273
7300
|
}
|
|
7274
7301
|
}();
|
|
@@ -7606,7 +7633,22 @@ let useSharedKey = false;
|
|
|
7606
7633
|
let sifTrailer;
|
|
7607
7634
|
let keyProviderOptions = KEY_PROVIDER_DEFAULTS;
|
|
7608
7635
|
let rtpMap = new Map();
|
|
7636
|
+
const dataDecryptErrorLimiter = new ErrorRateLimiter();
|
|
7609
7637
|
workerLogger.setDefaultLevel('info');
|
|
7638
|
+
// Forward worker log calls to the main thread so they reach any
|
|
7639
|
+
// setLogExtension consumer installed there. The main-thread workerLogger
|
|
7640
|
+
// re-emits them, which invokes both the console and the extension.
|
|
7641
|
+
workerLogger.methodFactory = methodName => (msg, context) => {
|
|
7642
|
+
postMessage({
|
|
7643
|
+
kind: 'log',
|
|
7644
|
+
data: {
|
|
7645
|
+
level: methodName,
|
|
7646
|
+
msg,
|
|
7647
|
+
context
|
|
7648
|
+
}
|
|
7649
|
+
});
|
|
7650
|
+
};
|
|
7651
|
+
workerLogger.setLevel(workerLogger.getLevel());
|
|
7610
7652
|
onmessage = ev => {
|
|
7611
7653
|
messageQueue.run(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
7612
7654
|
const _ev$data = ev.data,
|
|
@@ -7615,7 +7657,7 @@ onmessage = ev => {
|
|
|
7615
7657
|
switch (kind) {
|
|
7616
7658
|
case 'init':
|
|
7617
7659
|
workerLogger.setLevel(data.loglevel);
|
|
7618
|
-
workerLogger.info('worker initialized');
|
|
7660
|
+
workerLogger.info('e2ee worker initialized');
|
|
7619
7661
|
keyProviderOptions = data.keyProviderOptions;
|
|
7620
7662
|
useSharedKey = !!data.keyProviderOptions.sharedKey;
|
|
7621
7663
|
// acknowledge init successful
|
|
@@ -7627,6 +7669,9 @@ onmessage = ev => {
|
|
|
7627
7669
|
};
|
|
7628
7670
|
postMessage(ackMsg);
|
|
7629
7671
|
break;
|
|
7672
|
+
case 'setLogLevel':
|
|
7673
|
+
workerLogger.setLevel(data.level);
|
|
7674
|
+
break;
|
|
7630
7675
|
case 'enable':
|
|
7631
7676
|
setEncryptionEnabled(data.enabled, data.participantIdentity);
|
|
7632
7677
|
workerLogger.info("updated e2ee enabled status for ".concat(data.participantIdentity, " to ").concat(data.enabled));
|
|
@@ -7648,11 +7693,6 @@ onmessage = ev => {
|
|
|
7648
7693
|
encryptedPayload = _yield$DataCryptor$en.payload,
|
|
7649
7694
|
iv = _yield$DataCryptor$en.iv,
|
|
7650
7695
|
keyIndex = _yield$DataCryptor$en.keyIndex;
|
|
7651
|
-
console.log('encrypted payload', {
|
|
7652
|
-
original: data.payload,
|
|
7653
|
-
encrypted: encryptedPayload,
|
|
7654
|
-
iv
|
|
7655
|
-
});
|
|
7656
7696
|
postMessage({
|
|
7657
7697
|
kind: 'encryptDataResponse',
|
|
7658
7698
|
data: {
|
|
@@ -7675,12 +7715,22 @@ onmessage = ev => {
|
|
|
7675
7715
|
}
|
|
7676
7716
|
});
|
|
7677
7717
|
} catch (error) {
|
|
7678
|
-
// Send error back to main thread with uuid so it can reject the corresponding promise
|
|
7679
|
-
|
|
7680
|
-
|
|
7681
|
-
|
|
7682
|
-
|
|
7718
|
+
// Send error back to main thread with uuid so it can reject the corresponding promise.
|
|
7719
|
+
// The error response must always be posted so the awaiting future resolves; only the
|
|
7720
|
+
// log is throttled to avoid flooding when a broken key keeps producing failures.
|
|
7721
|
+
const errorKey = "".concat(data.participantIdentity, "-datadecrypt");
|
|
7722
|
+
const shouldLog = dataDecryptErrorLimiter.shouldEmit(errorKey, () => {
|
|
7723
|
+
workerLogger.warn("Suppressing further data decryption errors for ".concat(data.participantIdentity), {
|
|
7724
|
+
errorKey
|
|
7725
|
+
});
|
|
7683
7726
|
});
|
|
7727
|
+
if (shouldLog) {
|
|
7728
|
+
workerLogger.error('DataCryptor decryption failed', {
|
|
7729
|
+
error,
|
|
7730
|
+
participantIdentity: data.participantIdentity,
|
|
7731
|
+
uuid: data.uuid
|
|
7732
|
+
});
|
|
7733
|
+
}
|
|
7684
7734
|
postMessage({
|
|
7685
7735
|
kind: 'error',
|
|
7686
7736
|
data: {
|