@webex/web-client-media-engine 2.1.4 → 2.1.6

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/cjs/index.js CHANGED
@@ -6258,623 +6258,7 @@ function getDefaultExportFromCjs (x) {
6258
6258
  return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
6259
6259
  }
6260
6260
 
6261
- function getAugmentedNamespace(n) {
6262
- if (n.__esModule) return n;
6263
- var a = Object.defineProperty({}, '__esModule', {value: true});
6264
- Object.keys(n).forEach(function (k) {
6265
- var d = Object.getOwnPropertyDescriptor(n, k);
6266
- Object.defineProperty(a, k, d.get ? d : {
6267
- enumerable: true,
6268
- get: function () {
6269
- return n[k];
6270
- }
6271
- });
6272
- });
6273
- return a;
6274
- }
6275
-
6276
- // Unique ID creation requires a high quality random # generator. In the browser we therefore
6277
- // require the crypto API and do not support built-in fallback to lower quality random number
6278
- // generators (like Math.random()).
6279
- var getRandomValues;
6280
- var rnds8 = new Uint8Array(16);
6281
- function rng() {
6282
- // lazy load so that environments that need to polyfill have a chance to do so
6283
- if (!getRandomValues) {
6284
- // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
6285
- // find the complete implementation of crypto (msCrypto) on IE11.
6286
- getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
6287
-
6288
- if (!getRandomValues) {
6289
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
6290
- }
6291
- }
6292
-
6293
- return getRandomValues(rnds8);
6294
- }
6295
-
6296
- var REGEX = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
6297
-
6298
- function validate(uuid) {
6299
- return typeof uuid === 'string' && REGEX.test(uuid);
6300
- }
6301
-
6302
- /**
6303
- * Convert array of 16 byte values to UUID string format of the form:
6304
- * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
6305
- */
6306
-
6307
- var byteToHex = [];
6308
-
6309
- for (var i = 0; i < 256; ++i) {
6310
- byteToHex.push((i + 0x100).toString(16).substr(1));
6311
- }
6312
-
6313
- function stringify(arr) {
6314
- var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
6315
- // Note: Be careful editing this code! It's been tuned for performance
6316
- // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
6317
- var uuid = (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase(); // Consistency check for valid UUID. If this throws, it's likely due to one
6318
- // of the following:
6319
- // - One or more input array values don't map to a hex octet (leading to
6320
- // "undefined" in the uuid)
6321
- // - Invalid input values for the RFC `version` or `variant` fields
6322
-
6323
- if (!validate(uuid)) {
6324
- throw TypeError('Stringified UUID is invalid');
6325
- }
6326
-
6327
- return uuid;
6328
- }
6329
-
6330
- //
6331
- // Inspired by https://github.com/LiosK/UUID.js
6332
- // and http://docs.python.org/library/uuid.html
6333
-
6334
- var _nodeId;
6335
-
6336
- var _clockseq; // Previous uuid creation time
6337
-
6338
-
6339
- var _lastMSecs = 0;
6340
- var _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
6341
-
6342
- function v1(options, buf, offset) {
6343
- var i = buf && offset || 0;
6344
- var b = buf || new Array(16);
6345
- options = options || {};
6346
- var node = options.node || _nodeId;
6347
- var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
6348
- // specified. We do this lazily to minimize issues related to insufficient
6349
- // system entropy. See #189
6350
-
6351
- if (node == null || clockseq == null) {
6352
- var seedBytes = options.random || (options.rng || rng)();
6353
-
6354
- if (node == null) {
6355
- // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
6356
- node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
6357
- }
6358
-
6359
- if (clockseq == null) {
6360
- // Per 4.2.2, randomize (14 bit) clockseq
6361
- clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
6362
- }
6363
- } // UUID timestamps are 100 nano-second units since the Gregorian epoch,
6364
- // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
6365
- // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
6366
- // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
6367
-
6368
-
6369
- var msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
6370
- // cycle to simulate higher resolution clock
6371
-
6372
- var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
6373
-
6374
- var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
6375
-
6376
- if (dt < 0 && options.clockseq === undefined) {
6377
- clockseq = clockseq + 1 & 0x3fff;
6378
- } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
6379
- // time interval
6380
-
6381
-
6382
- if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
6383
- nsecs = 0;
6384
- } // Per 4.2.1.2 Throw error if too many uuids are requested
6385
-
6386
-
6387
- if (nsecs >= 10000) {
6388
- throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
6389
- }
6390
-
6391
- _lastMSecs = msecs;
6392
- _lastNSecs = nsecs;
6393
- _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
6394
-
6395
- msecs += 12219292800000; // `time_low`
6396
-
6397
- var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
6398
- b[i++] = tl >>> 24 & 0xff;
6399
- b[i++] = tl >>> 16 & 0xff;
6400
- b[i++] = tl >>> 8 & 0xff;
6401
- b[i++] = tl & 0xff; // `time_mid`
6402
-
6403
- var tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
6404
- b[i++] = tmh >>> 8 & 0xff;
6405
- b[i++] = tmh & 0xff; // `time_high_and_version`
6406
-
6407
- b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
6408
-
6409
- b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
6410
-
6411
- b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
6412
-
6413
- b[i++] = clockseq & 0xff; // `node`
6414
-
6415
- for (var n = 0; n < 6; ++n) {
6416
- b[i + n] = node[n];
6417
- }
6418
-
6419
- return buf || stringify(b);
6420
- }
6421
-
6422
- function parse$1(uuid) {
6423
- if (!validate(uuid)) {
6424
- throw TypeError('Invalid UUID');
6425
- }
6426
-
6427
- var v;
6428
- var arr = new Uint8Array(16); // Parse ########-....-....-....-............
6429
-
6430
- arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
6431
- arr[1] = v >>> 16 & 0xff;
6432
- arr[2] = v >>> 8 & 0xff;
6433
- arr[3] = v & 0xff; // Parse ........-####-....-....-............
6434
-
6435
- arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
6436
- arr[5] = v & 0xff; // Parse ........-....-####-....-............
6437
-
6438
- arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
6439
- arr[7] = v & 0xff; // Parse ........-....-....-####-............
6440
-
6441
- arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
6442
- arr[9] = v & 0xff; // Parse ........-....-....-....-############
6443
- // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
6444
-
6445
- arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
6446
- arr[11] = v / 0x100000000 & 0xff;
6447
- arr[12] = v >>> 24 & 0xff;
6448
- arr[13] = v >>> 16 & 0xff;
6449
- arr[14] = v >>> 8 & 0xff;
6450
- arr[15] = v & 0xff;
6451
- return arr;
6452
- }
6453
-
6454
- function stringToBytes(str) {
6455
- str = unescape(encodeURIComponent(str)); // UTF8 escape
6456
-
6457
- var bytes = [];
6458
-
6459
- for (var i = 0; i < str.length; ++i) {
6460
- bytes.push(str.charCodeAt(i));
6461
- }
6462
-
6463
- return bytes;
6464
- }
6465
-
6466
- var DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
6467
- var URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
6468
- function v35 (name, version, hashfunc) {
6469
- function generateUUID(value, namespace, buf, offset) {
6470
- if (typeof value === 'string') {
6471
- value = stringToBytes(value);
6472
- }
6473
-
6474
- if (typeof namespace === 'string') {
6475
- namespace = parse$1(namespace);
6476
- }
6477
-
6478
- if (namespace.length !== 16) {
6479
- throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
6480
- } // Compute hash of namespace and value, Per 4.3
6481
- // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
6482
- // hashfunc([...namespace, ... value])`
6483
-
6484
-
6485
- var bytes = new Uint8Array(16 + value.length);
6486
- bytes.set(namespace);
6487
- bytes.set(value, namespace.length);
6488
- bytes = hashfunc(bytes);
6489
- bytes[6] = bytes[6] & 0x0f | version;
6490
- bytes[8] = bytes[8] & 0x3f | 0x80;
6491
-
6492
- if (buf) {
6493
- offset = offset || 0;
6494
-
6495
- for (var i = 0; i < 16; ++i) {
6496
- buf[offset + i] = bytes[i];
6497
- }
6498
-
6499
- return buf;
6500
- }
6501
-
6502
- return stringify(bytes);
6503
- } // Function#name is not settable on some platforms (#270)
6504
-
6505
-
6506
- try {
6507
- generateUUID.name = name; // eslint-disable-next-line no-empty
6508
- } catch (err) {} // For CommonJS default export support
6509
-
6510
-
6511
- generateUUID.DNS = DNS;
6512
- generateUUID.URL = URL;
6513
- return generateUUID;
6514
- }
6515
-
6516
- /*
6517
- * Browser-compatible JavaScript MD5
6518
- *
6519
- * Modification of JavaScript MD5
6520
- * https://github.com/blueimp/JavaScript-MD5
6521
- *
6522
- * Copyright 2011, Sebastian Tschan
6523
- * https://blueimp.net
6524
- *
6525
- * Licensed under the MIT license:
6526
- * https://opensource.org/licenses/MIT
6527
- *
6528
- * Based on
6529
- * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
6530
- * Digest Algorithm, as defined in RFC 1321.
6531
- * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
6532
- * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
6533
- * Distributed under the BSD License
6534
- * See http://pajhome.org.uk/crypt/md5 for more info.
6535
- */
6536
- function md5(bytes) {
6537
- if (typeof bytes === 'string') {
6538
- var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
6539
-
6540
- bytes = new Uint8Array(msg.length);
6541
-
6542
- for (var i = 0; i < msg.length; ++i) {
6543
- bytes[i] = msg.charCodeAt(i);
6544
- }
6545
- }
6546
-
6547
- return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
6548
- }
6549
- /*
6550
- * Convert an array of little-endian words to an array of bytes
6551
- */
6552
-
6553
-
6554
- function md5ToHexEncodedArray(input) {
6555
- var output = [];
6556
- var length32 = input.length * 32;
6557
- var hexTab = '0123456789abcdef';
6558
-
6559
- for (var i = 0; i < length32; i += 8) {
6560
- var x = input[i >> 5] >>> i % 32 & 0xff;
6561
- var hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
6562
- output.push(hex);
6563
- }
6564
-
6565
- return output;
6566
- }
6567
- /**
6568
- * Calculate output length with padding and bit length
6569
- */
6570
-
6571
-
6572
- function getOutputLength(inputLength8) {
6573
- return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
6574
- }
6575
- /*
6576
- * Calculate the MD5 of an array of little-endian words, and a bit length.
6577
- */
6578
-
6579
-
6580
- function wordsToMd5(x, len) {
6581
- /* append padding */
6582
- x[len >> 5] |= 0x80 << len % 32;
6583
- x[getOutputLength(len) - 1] = len;
6584
- var a = 1732584193;
6585
- var b = -271733879;
6586
- var c = -1732584194;
6587
- var d = 271733878;
6588
-
6589
- for (var i = 0; i < x.length; i += 16) {
6590
- var olda = a;
6591
- var oldb = b;
6592
- var oldc = c;
6593
- var oldd = d;
6594
- a = md5ff(a, b, c, d, x[i], 7, -680876936);
6595
- d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
6596
- c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
6597
- b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
6598
- a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
6599
- d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
6600
- c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
6601
- b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
6602
- a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
6603
- d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
6604
- c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
6605
- b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
6606
- a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
6607
- d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
6608
- c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
6609
- b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
6610
- a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
6611
- d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
6612
- c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
6613
- b = md5gg(b, c, d, a, x[i], 20, -373897302);
6614
- a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
6615
- d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
6616
- c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
6617
- b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
6618
- a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
6619
- d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
6620
- c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
6621
- b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
6622
- a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
6623
- d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
6624
- c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
6625
- b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
6626
- a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
6627
- d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
6628
- c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
6629
- b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
6630
- a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
6631
- d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
6632
- c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
6633
- b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
6634
- a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
6635
- d = md5hh(d, a, b, c, x[i], 11, -358537222);
6636
- c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
6637
- b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
6638
- a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
6639
- d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
6640
- c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
6641
- b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
6642
- a = md5ii(a, b, c, d, x[i], 6, -198630844);
6643
- d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
6644
- c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
6645
- b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
6646
- a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
6647
- d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
6648
- c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
6649
- b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
6650
- a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
6651
- d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
6652
- c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
6653
- b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
6654
- a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
6655
- d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
6656
- c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
6657
- b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
6658
- a = safeAdd(a, olda);
6659
- b = safeAdd(b, oldb);
6660
- c = safeAdd(c, oldc);
6661
- d = safeAdd(d, oldd);
6662
- }
6663
-
6664
- return [a, b, c, d];
6665
- }
6666
- /*
6667
- * Convert an array bytes to an array of little-endian words
6668
- * Characters >255 have their high-byte silently ignored.
6669
- */
6670
-
6671
-
6672
- function bytesToWords(input) {
6673
- if (input.length === 0) {
6674
- return [];
6675
- }
6676
-
6677
- var length8 = input.length * 8;
6678
- var output = new Uint32Array(getOutputLength(length8));
6679
-
6680
- for (var i = 0; i < length8; i += 8) {
6681
- output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
6682
- }
6683
-
6684
- return output;
6685
- }
6686
- /*
6687
- * Add integers, wrapping at 2^32. This uses 16-bit operations internally
6688
- * to work around bugs in some JS interpreters.
6689
- */
6690
-
6691
-
6692
- function safeAdd(x, y) {
6693
- var lsw = (x & 0xffff) + (y & 0xffff);
6694
- var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
6695
- return msw << 16 | lsw & 0xffff;
6696
- }
6697
- /*
6698
- * Bitwise rotate a 32-bit number to the left.
6699
- */
6700
-
6701
-
6702
- function bitRotateLeft(num, cnt) {
6703
- return num << cnt | num >>> 32 - cnt;
6704
- }
6705
- /*
6706
- * These functions implement the four basic operations the algorithm uses.
6707
- */
6708
-
6709
-
6710
- function md5cmn(q, a, b, x, s, t) {
6711
- return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
6712
- }
6713
-
6714
- function md5ff(a, b, c, d, x, s, t) {
6715
- return md5cmn(b & c | ~b & d, a, b, x, s, t);
6716
- }
6717
-
6718
- function md5gg(a, b, c, d, x, s, t) {
6719
- return md5cmn(b & d | c & ~d, a, b, x, s, t);
6720
- }
6721
-
6722
- function md5hh(a, b, c, d, x, s, t) {
6723
- return md5cmn(b ^ c ^ d, a, b, x, s, t);
6724
- }
6725
-
6726
- function md5ii(a, b, c, d, x, s, t) {
6727
- return md5cmn(c ^ (b | ~d), a, b, x, s, t);
6728
- }
6729
-
6730
- var v3 = v35('v3', 0x30, md5);
6731
- var v3$1 = v3;
6732
-
6733
- function v4(options, buf, offset) {
6734
- options = options || {};
6735
- var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
6736
-
6737
- rnds[6] = rnds[6] & 0x0f | 0x40;
6738
- rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
6739
-
6740
- if (buf) {
6741
- offset = offset || 0;
6742
-
6743
- for (var i = 0; i < 16; ++i) {
6744
- buf[offset + i] = rnds[i];
6745
- }
6746
-
6747
- return buf;
6748
- }
6749
-
6750
- return stringify(rnds);
6751
- }
6752
-
6753
- // Adapted from Chris Veness' SHA1 code at
6754
- // http://www.movable-type.co.uk/scripts/sha1.html
6755
- function f(s, x, y, z) {
6756
- switch (s) {
6757
- case 0:
6758
- return x & y ^ ~x & z;
6759
-
6760
- case 1:
6761
- return x ^ y ^ z;
6762
-
6763
- case 2:
6764
- return x & y ^ x & z ^ y & z;
6765
-
6766
- case 3:
6767
- return x ^ y ^ z;
6768
- }
6769
- }
6770
-
6771
- function ROTL(x, n) {
6772
- return x << n | x >>> 32 - n;
6773
- }
6774
-
6775
- function sha1(bytes) {
6776
- var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
6777
- var H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
6778
-
6779
- if (typeof bytes === 'string') {
6780
- var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
6781
-
6782
- bytes = [];
6783
-
6784
- for (var i = 0; i < msg.length; ++i) {
6785
- bytes.push(msg.charCodeAt(i));
6786
- }
6787
- } else if (!Array.isArray(bytes)) {
6788
- // Convert Array-like to Array
6789
- bytes = Array.prototype.slice.call(bytes);
6790
- }
6791
-
6792
- bytes.push(0x80);
6793
- var l = bytes.length / 4 + 2;
6794
- var N = Math.ceil(l / 16);
6795
- var M = new Array(N);
6796
-
6797
- for (var _i = 0; _i < N; ++_i) {
6798
- var arr = new Uint32Array(16);
6799
-
6800
- for (var j = 0; j < 16; ++j) {
6801
- arr[j] = bytes[_i * 64 + j * 4] << 24 | bytes[_i * 64 + j * 4 + 1] << 16 | bytes[_i * 64 + j * 4 + 2] << 8 | bytes[_i * 64 + j * 4 + 3];
6802
- }
6803
-
6804
- M[_i] = arr;
6805
- }
6806
-
6807
- M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
6808
- M[N - 1][14] = Math.floor(M[N - 1][14]);
6809
- M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
6810
-
6811
- for (var _i2 = 0; _i2 < N; ++_i2) {
6812
- var W = new Uint32Array(80);
6813
-
6814
- for (var t = 0; t < 16; ++t) {
6815
- W[t] = M[_i2][t];
6816
- }
6817
-
6818
- for (var _t = 16; _t < 80; ++_t) {
6819
- W[_t] = ROTL(W[_t - 3] ^ W[_t - 8] ^ W[_t - 14] ^ W[_t - 16], 1);
6820
- }
6821
-
6822
- var a = H[0];
6823
- var b = H[1];
6824
- var c = H[2];
6825
- var d = H[3];
6826
- var e = H[4];
6827
-
6828
- for (var _t2 = 0; _t2 < 80; ++_t2) {
6829
- var s = Math.floor(_t2 / 20);
6830
- var T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[_t2] >>> 0;
6831
- e = d;
6832
- d = c;
6833
- c = ROTL(b, 30) >>> 0;
6834
- b = a;
6835
- a = T;
6836
- }
6837
-
6838
- H[0] = H[0] + a >>> 0;
6839
- H[1] = H[1] + b >>> 0;
6840
- H[2] = H[2] + c >>> 0;
6841
- H[3] = H[3] + d >>> 0;
6842
- H[4] = H[4] + e >>> 0;
6843
- }
6844
-
6845
- return [H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff, H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff, H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff, H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff, H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff];
6846
- }
6847
-
6848
- var v5 = v35('v5', 0x50, sha1);
6849
- var v5$1 = v5;
6850
-
6851
- var nil = '00000000-0000-0000-0000-000000000000';
6852
-
6853
- function version(uuid) {
6854
- if (!validate(uuid)) {
6855
- throw TypeError('Invalid UUID');
6856
- }
6857
-
6858
- return parseInt(uuid.substr(14, 1), 16);
6859
- }
6860
-
6861
- var esmBrowser = /*#__PURE__*/Object.freeze({
6862
- __proto__: null,
6863
- v1: v1,
6864
- v3: v3$1,
6865
- v4: v4,
6866
- v5: v5$1,
6867
- NIL: nil,
6868
- version: version,
6869
- validate: validate,
6870
- stringify: stringify,
6871
- parse: parse$1
6872
- });
6873
-
6874
- var require$$0 = /*@__PURE__*/getAugmentedNamespace(esmBrowser);
6875
-
6876
6261
  var rtcStats_1 = void 0;
6877
- var uuid_1 = require$$0;
6878
6262
  /**
6879
6263
  * Copies values of any nested depth.
6880
6264
  *
@@ -6902,9 +6286,10 @@ var deepEqual = function (value1, value2) {
6902
6286
  if (Object.keys(value1).length !== Object.keys(value2).length) {
6903
6287
  return false;
6904
6288
  }
6905
- // Deep equal check each property in the opject.
6906
- for (var prop in value1) {
6907
- if (value2.hasOwnProperty(prop)) {
6289
+ // Deep equal check each property in the object, returns true if we found no
6290
+ // differing properties.
6291
+ return Object.keys(value1).reduce(function (val, prop) {
6292
+ if (value2[prop]) {
6908
6293
  if (!deepEqual(value1[prop], value2[prop])) {
6909
6294
  return false;
6910
6295
  }
@@ -6912,17 +6297,16 @@ var deepEqual = function (value1, value2) {
6912
6297
  else {
6913
6298
  return false;
6914
6299
  }
6915
- }
6916
- // Return true if we found no differing properties.
6917
- return true;
6300
+ return val;
6301
+ }, true);
6918
6302
  }
6919
6303
  // Return false if no other conditions are met.
6920
6304
  return false;
6921
6305
  };
6922
6306
  /**
6923
- * Translates a RTCStatsReport into an object.
6307
+ * Translates a Map into an object.
6924
6308
  *
6925
- * @param report - The report.
6309
+ * @param report - The report in Map form.
6926
6310
  * @returns - A deduped object.
6927
6311
  */
6928
6312
  var map2obj = function (report) {
@@ -6942,6 +6326,7 @@ var persistedKeys = ['type', 'id', 'timestamp'];
6942
6326
  * @param report - The report line being checked.
6943
6327
  * @returns True if the report item contains non-persisted keys, false otherwise.
6944
6328
  */
6329
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
6945
6330
  var hasNonMetadata = function (report) {
6946
6331
  return !!Object.keys(report).filter(function (key) { return !persistedKeys.includes(key); }).length;
6947
6332
  };
@@ -6998,7 +6383,7 @@ var deltaCompression = function (oldStats, newStats) {
6998
6383
  var formatStatsReport = function (report) {
6999
6384
  return Object.keys(report)
7000
6385
  .filter(function (name) { return name !== 'timestamp'; })
7001
- .map(function (name) { return report[name]; });
6386
+ .map(function (name) { return JSON.stringify(report[name]); });
7002
6387
  };
7003
6388
  /**
7004
6389
  * Parametrize a single string event to contain type and an (empty) id.
@@ -7006,18 +6391,16 @@ var formatStatsReport = function (report) {
7006
6391
  * @param value - The value to parametrize.
7007
6392
  * @returns An event object.
7008
6393
  */
7009
- var makeEvent = function (value) { return ([{ value: value, type: 'string', id: '' }]); };
6394
+ var makeEvent = function (value) { return [JSON.stringify({ value: value, type: 'string', id: '' })]; };
7010
6395
  /**
7011
6396
  * Attach a Peer Connection to periodically get updated on events and stats.
7012
6397
  *
7013
6398
  * @param pc - Peer Connection in which we attach.
7014
6399
  * @param logger - Logging function to log events and stats.
7015
6400
  * @param intervalTime - Time between each `getStats` check.
7016
- * @param id - Optional id string used for logging.
7017
6401
  * @param statsPreProcessor - Optional function that modifies stats.
7018
6402
  */
7019
- var rtcStats = function (pc, logger, intervalTime, id, statsPreProcessor) {
7020
- if (id === void 0) { id = (0, uuid_1.v4)(); }
6403
+ var rtcStats = function (pc, logger, intervalTime, statsPreProcessor) {
7021
6404
  if (statsPreProcessor === void 0) { statsPreProcessor = function () { return Promise.resolve(); }; }
7022
6405
  var prev = {};
7023
6406
  /**
@@ -7025,9 +6408,10 @@ var rtcStats = function (pc, logger, intervalTime, id, statsPreProcessor) {
7025
6408
  *
7026
6409
  * @param name - Name of the event to log.
7027
6410
  * @param payload - Log data pertaining to the event.
6411
+ * @param timestamp - Time the event happened in milliseconds.
7028
6412
  */
7029
6413
  var trace = function (name, payload, timestamp) {
7030
- logger({ id: id, timestamp: timestamp ? Math.round(timestamp) : Date.now(), name: name, payload: payload });
6414
+ logger({ timestamp: timestamp ? Math.round(timestamp) : Date.now(), name: name, payload: payload });
7031
6415
  };
7032
6416
  pc.addEventListener('icecandidate', function (e) {
7033
6417
  if (e.candidate) {
@@ -7039,7 +6423,9 @@ var rtcStats = function (pc, logger, intervalTime, id, statsPreProcessor) {
7039
6423
  trace('onicecandidateerror', makeEvent("".concat(errorCode, ": ").concat(errorText)));
7040
6424
  });
7041
6425
  pc.addEventListener('track', function (e) {
7042
- trace('ontrack', makeEvent("".concat(e.track.kind, ":").concat(e.track.id, " ").concat(e.streams.map(function (stream) { return "stream:".concat(stream.id); }).join(' '))));
6426
+ trace('ontrack', makeEvent("".concat(e.track.kind, ":").concat(e.track.id, " ").concat(e.streams
6427
+ .map(function (stream) { return "stream:".concat(stream.id); })
6428
+ .join(' '))));
7043
6429
  });
7044
6430
  pc.addEventListener('signalingstatechange', function () {
7045
6431
  trace('onsignalingstatechange', makeEvent(pc.signalingState));
@@ -7065,8 +6451,11 @@ var rtcStats = function (pc, logger, intervalTime, id, statsPreProcessor) {
7065
6451
  return;
7066
6452
  }
7067
6453
  pc.getStats(null).then(function (res) {
7068
- var now = map2obj(res);
7069
- statsPreProcessor(now).then(function () {
6454
+ // Convert from stats report to js Map in order to have values set in `statsPreProcessor`
6455
+ var statsMap = new Map();
6456
+ res.forEach(function (stats, key) { return statsMap.set(key, stats); });
6457
+ statsPreProcessor(statsMap).then(function () {
6458
+ var now = map2obj(statsMap);
7070
6459
  var base = deepCopy$1(now); // our new prev
7071
6460
  var compressed = deltaCompression(prev, now);
7072
6461
  trace('stats-report', formatStatsReport(compressed), compressed.timestamp !== -Infinity ? compressed.timestamp : undefined);
@@ -13999,7 +13388,7 @@ class MultistreamConnection extends EventEmitter {
13999
13388
  });
14000
13389
  }
14001
13390
  attachMetricsObserver() {
14002
- rtcStats_1(this.pc.getUnderlyingRTCPeerConnection(), (data) => this.metricsCallback(data), 5000);
13391
+ rtcStats_1(this.pc.getUnderlyingRTCPeerConnection(), (data) => this.metricsCallback(data), 5000, (stats) => this.preProcessStats(stats));
14003
13392
  }
14004
13393
  setMetricsCallback(callback) {
14005
13394
  this.metricsCallback = callback;