parse 5.2.0-alpha.2 → 5.2.0-beta.1

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.
Files changed (58) hide show
  1. package/dist/parse.js +440 -240
  2. package/dist/parse.min.js +2 -2
  3. package/dist/parse.weapp.js +440 -240
  4. package/dist/parse.weapp.min.js +2 -2
  5. package/lib/browser/CoreManager.js +1 -1
  6. package/lib/browser/LiveQueryClient.js +7 -4
  7. package/lib/node/Analytics.js +3 -3
  8. package/lib/node/AnonymousUtils.js +3 -3
  9. package/lib/node/Cloud.js +3 -3
  10. package/lib/node/CoreManager.js +1 -1
  11. package/lib/node/EventuallyQueue.js +3 -3
  12. package/lib/node/FacebookUtils.js +3 -3
  13. package/lib/node/InstallationController.js +3 -3
  14. package/lib/node/LiveQueryClient.js +11 -7
  15. package/lib/node/LiveQuerySubscription.js +3 -3
  16. package/lib/node/LocalDatastore.js +3 -3
  17. package/lib/node/LocalDatastoreController.default.js +3 -3
  18. package/lib/node/LocalDatastoreController.js +3 -3
  19. package/lib/node/LocalDatastoreController.react-native.js +3 -3
  20. package/lib/node/ObjectStateMutations.js +3 -3
  21. package/lib/node/OfflineQuery.js +3 -3
  22. package/lib/node/Parse.js +3 -3
  23. package/lib/node/ParseACL.js +3 -3
  24. package/lib/node/ParseCLP.js +3 -3
  25. package/lib/node/ParseConfig.js +3 -3
  26. package/lib/node/ParseError.js +3 -3
  27. package/lib/node/ParseFile.js +3 -3
  28. package/lib/node/ParseHooks.js +3 -3
  29. package/lib/node/ParseInstallation.js +3 -3
  30. package/lib/node/ParseLiveQuery.js +3 -3
  31. package/lib/node/ParseObject.js +3 -3
  32. package/lib/node/ParseOp.js +3 -3
  33. package/lib/node/ParsePolygon.js +3 -3
  34. package/lib/node/ParseQuery.js +3 -3
  35. package/lib/node/ParseRelation.js +3 -3
  36. package/lib/node/ParseRole.js +3 -3
  37. package/lib/node/ParseSchema.js +3 -3
  38. package/lib/node/ParseSession.js +3 -3
  39. package/lib/node/ParseUser.js +3 -3
  40. package/lib/node/Push.js +3 -3
  41. package/lib/node/RESTController.js +3 -3
  42. package/lib/node/Storage.js +3 -3
  43. package/lib/node/StorageController.js +3 -3
  44. package/lib/node/StorageController.react-native.js +3 -3
  45. package/lib/node/UniqueInstanceStateController.js +3 -3
  46. package/lib/node/WebSocketController.js +3 -3
  47. package/lib/node/arrayContainsObject.js +3 -3
  48. package/lib/node/canBeSerialized.js +3 -3
  49. package/lib/node/decode.js +3 -3
  50. package/lib/node/encode.js +3 -3
  51. package/lib/node/equals.js +3 -3
  52. package/lib/node/unique.js +3 -3
  53. package/lib/node/unsavedChildren.js +3 -3
  54. package/lib/react-native/CoreManager.js +1 -1
  55. package/lib/react-native/LiveQueryClient.js +6 -3
  56. package/lib/weapp/CoreManager.js +1 -1
  57. package/lib/weapp/LiveQueryClient.js +7 -4
  58. package/package.json +12 -12
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Parse JavaScript SDK v5.2.0-alpha.2
2
+ * Parse JavaScript SDK v5.2.0-beta.1
3
3
  *
4
4
  * The source tree of this library can be found at
5
5
  * https://github.com/ParsePlatform/Parse-SDK-JS
@@ -358,7 +358,7 @@ const config = {
358
358
  SERVER_AUTH_TOKEN: null,
359
359
  LIVEQUERY_SERVER_URL: null,
360
360
  ENCRYPTED_KEY: null,
361
- VERSION: 'js' + "5.2.0-alpha.2",
361
+ VERSION: 'js' + "5.2.0-beta.1",
362
362
  APPLICATION_ID: null,
363
363
  JAVASCRIPT_KEY: null,
364
364
  MASTER_KEY: null,
@@ -1425,6 +1425,8 @@ const SUBSCRIPTION_EMMITER_TYPES = {
1425
1425
  LEAVE: 'leave',
1426
1426
  DELETE: 'delete'
1427
1427
  };
1428
+
1429
+ // Exponentially-growing random delay
1428
1430
  const generateInterval = k => {
1429
1431
  return Math.random() * Math.min(30, Math.pow(2, k) - 1) * 1000;
1430
1432
  };
@@ -1650,7 +1652,8 @@ class LiveQueryClient {
1650
1652
  const query = subscription.query;
1651
1653
  const queryJSON = query.toJSON();
1652
1654
  const where = queryJSON.where;
1653
- const fields = (0, _keys.default)(queryJSON) ? (0, _keys.default)(queryJSON).split(',') : undefined;
1655
+ const keys = (0, _keys.default)(queryJSON)?.split(',');
1656
+ const watch = queryJSON.watch?.split(',');
1654
1657
  const className = query.className;
1655
1658
  const sessionToken = subscription.sessionToken;
1656
1659
  const subscribeRequest = {
@@ -1659,7 +1662,8 @@ class LiveQueryClient {
1659
1662
  query: {
1660
1663
  className,
1661
1664
  where,
1662
- fields
1665
+ keys,
1666
+ watch
1663
1667
  },
1664
1668
  sessionToken: undefined
1665
1669
  };
@@ -1704,7 +1708,6 @@ class LiveQueryClient {
1704
1708
  this.subscriptions = new _map.default();
1705
1709
  }
1706
1710
  _handleWebSocketOpen() {
1707
- this.attempts = 1;
1708
1711
  const connectRequest = {
1709
1712
  op: OP_TYPES.CONNECT,
1710
1713
  applicationId: this.applicationId,
@@ -1743,6 +1746,7 @@ class LiveQueryClient {
1743
1746
  break;
1744
1747
  case OP_EVENTS.SUBSCRIBED:
1745
1748
  if (subscription) {
1749
+ this.attempts = 1;
1746
1750
  subscription.subscribed = true;
1747
1751
  subscription.subscribePromise.resolve();
1748
1752
  (0, _setTimeout2.default)(() => subscription.emit(SUBSCRIPTION_EMMITER_TYPES.OPEN, response), 200);
@@ -1846,7 +1850,6 @@ class LiveQueryClient {
1846
1850
  // we're unable to distinguish different between close/error when we're unable to reconnect therefore
1847
1851
  // we try to reconnect in both cases
1848
1852
  // server side ws and browser WebSocket behave differently in when close/error get triggered
1849
-
1850
1853
  if (this.reconnectHandle) {
1851
1854
  clearTimeout(this.reconnectHandle);
1852
1855
  }
@@ -15071,7 +15074,7 @@ try {
15071
15074
  }
15072
15075
  module.exports = WebSocketController;
15073
15076
  var _default = exports.default = WebSocketController;
15074
- },{"./Socket.weapp":42,"@babel/runtime-corejs3/core-js-stable/object/define-property":91,"@babel/runtime-corejs3/helpers/interopRequireDefault":105,"ws":512}],52:[function(_dereq_,module,exports){
15077
+ },{"./Socket.weapp":42,"@babel/runtime-corejs3/core-js-stable/object/define-property":91,"@babel/runtime-corejs3/helpers/interopRequireDefault":105,"ws":517}],52:[function(_dereq_,module,exports){
15075
15078
  "use strict";
15076
15079
 
15077
15080
  var _Object$defineProperty = _dereq_("@babel/runtime-corejs3/core-js-stable/object/define-property");
@@ -26367,6 +26370,12 @@ exports.values = values;
26367
26370
  Object.defineProperty(exports, "__esModule", {
26368
26371
  value: true
26369
26372
  });
26373
+ Object.defineProperty(exports, "MAX", {
26374
+ enumerable: true,
26375
+ get: function () {
26376
+ return _max.default;
26377
+ }
26378
+ });
26370
26379
  Object.defineProperty(exports, "NIL", {
26371
26380
  enumerable: true,
26372
26381
  get: function () {
@@ -26391,6 +26400,12 @@ Object.defineProperty(exports, "v1", {
26391
26400
  return _v.default;
26392
26401
  }
26393
26402
  });
26403
+ Object.defineProperty(exports, "v1ToV6", {
26404
+ enumerable: true,
26405
+ get: function () {
26406
+ return _v1ToV.default;
26407
+ }
26408
+ });
26394
26409
  Object.defineProperty(exports, "v3", {
26395
26410
  enumerable: true,
26396
26411
  get: function () {
@@ -26409,6 +26424,24 @@ Object.defineProperty(exports, "v5", {
26409
26424
  return _v4.default;
26410
26425
  }
26411
26426
  });
26427
+ Object.defineProperty(exports, "v6", {
26428
+ enumerable: true,
26429
+ get: function () {
26430
+ return _v5.default;
26431
+ }
26432
+ });
26433
+ Object.defineProperty(exports, "v6ToV1", {
26434
+ enumerable: true,
26435
+ get: function () {
26436
+ return _v6ToV.default;
26437
+ }
26438
+ });
26439
+ Object.defineProperty(exports, "v7", {
26440
+ enumerable: true,
26441
+ get: function () {
26442
+ return _v6.default;
26443
+ }
26444
+ });
26412
26445
  Object.defineProperty(exports, "validate", {
26413
26446
  enumerable: true,
26414
26447
  get: function () {
@@ -26421,34 +26454,36 @@ Object.defineProperty(exports, "version", {
26421
26454
  return _version.default;
26422
26455
  }
26423
26456
  });
26424
-
26457
+ var _max = _interopRequireDefault(_dereq_("./max.js"));
26458
+ var _nil = _interopRequireDefault(_dereq_("./nil.js"));
26459
+ var _parse = _interopRequireDefault(_dereq_("./parse.js"));
26460
+ var _stringify = _interopRequireDefault(_dereq_("./stringify.js"));
26425
26461
  var _v = _interopRequireDefault(_dereq_("./v1.js"));
26426
-
26462
+ var _v1ToV = _interopRequireDefault(_dereq_("./v1ToV6.js"));
26427
26463
  var _v2 = _interopRequireDefault(_dereq_("./v3.js"));
26428
-
26429
26464
  var _v3 = _interopRequireDefault(_dereq_("./v4.js"));
26430
-
26431
26465
  var _v4 = _interopRequireDefault(_dereq_("./v5.js"));
26432
-
26433
- var _nil = _interopRequireDefault(_dereq_("./nil.js"));
26434
-
26435
- var _version = _interopRequireDefault(_dereq_("./version.js"));
26436
-
26466
+ var _v5 = _interopRequireDefault(_dereq_("./v6.js"));
26467
+ var _v6ToV = _interopRequireDefault(_dereq_("./v6ToV1.js"));
26468
+ var _v6 = _interopRequireDefault(_dereq_("./v7.js"));
26437
26469
  var _validate = _interopRequireDefault(_dereq_("./validate.js"));
26438
-
26439
- var _stringify = _interopRequireDefault(_dereq_("./stringify.js"));
26440
-
26441
- var _parse = _interopRequireDefault(_dereq_("./parse.js"));
26442
-
26443
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26444
- },{"./nil.js":499,"./parse.js":500,"./stringify.js":504,"./v1.js":505,"./v3.js":506,"./v4.js":508,"./v5.js":509,"./validate.js":510,"./version.js":511}],497:[function(_dereq_,module,exports){
26470
+ var _version = _interopRequireDefault(_dereq_("./version.js"));
26471
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
26472
+ },{"./max.js":497,"./nil.js":500,"./parse.js":501,"./stringify.js":505,"./v1.js":506,"./v1ToV6.js":507,"./v3.js":508,"./v4.js":510,"./v5.js":511,"./v6.js":512,"./v6ToV1.js":513,"./v7.js":514,"./validate.js":515,"./version.js":516}],497:[function(_dereq_,module,exports){
26445
26473
  "use strict";
26446
26474
 
26447
26475
  Object.defineProperty(exports, "__esModule", {
26448
26476
  value: true
26449
26477
  });
26450
26478
  exports.default = void 0;
26479
+ var _default = exports.default = 'ffffffff-ffff-ffff-ffff-ffffffffffff';
26480
+ },{}],498:[function(_dereq_,module,exports){
26481
+ "use strict";
26451
26482
 
26483
+ Object.defineProperty(exports, "__esModule", {
26484
+ value: true
26485
+ });
26486
+ exports.default = void 0;
26452
26487
  /*
26453
26488
  * Browser-compatible JavaScript MD5
26454
26489
  *
@@ -26474,45 +26509,38 @@ function md5(bytes) {
26474
26509
  const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
26475
26510
 
26476
26511
  bytes = new Uint8Array(msg.length);
26477
-
26478
26512
  for (let i = 0; i < msg.length; ++i) {
26479
26513
  bytes[i] = msg.charCodeAt(i);
26480
26514
  }
26481
26515
  }
26482
-
26483
26516
  return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
26484
26517
  }
26518
+
26485
26519
  /*
26486
26520
  * Convert an array of little-endian words to an array of bytes
26487
26521
  */
26488
-
26489
-
26490
26522
  function md5ToHexEncodedArray(input) {
26491
26523
  const output = [];
26492
26524
  const length32 = input.length * 32;
26493
26525
  const hexTab = '0123456789abcdef';
26494
-
26495
26526
  for (let i = 0; i < length32; i += 8) {
26496
26527
  const x = input[i >> 5] >>> i % 32 & 0xff;
26497
26528
  const hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
26498
26529
  output.push(hex);
26499
26530
  }
26500
-
26501
26531
  return output;
26502
26532
  }
26533
+
26503
26534
  /**
26504
26535
  * Calculate output length with padding and bit length
26505
26536
  */
26506
-
26507
-
26508
26537
  function getOutputLength(inputLength8) {
26509
26538
  return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
26510
26539
  }
26540
+
26511
26541
  /*
26512
26542
  * Calculate the MD5 of an array of little-endian words, and a bit length.
26513
26543
  */
26514
-
26515
-
26516
26544
  function wordsToMd5(x, len) {
26517
26545
  /* append padding */
26518
26546
  x[len >> 5] |= 0x80 << len % 32;
@@ -26521,7 +26549,6 @@ function wordsToMd5(x, len) {
26521
26549
  let b = -271733879;
26522
26550
  let c = -1732584194;
26523
26551
  let d = 271733878;
26524
-
26525
26552
  for (let i = 0; i < x.length; i += 16) {
26526
26553
  const olda = a;
26527
26554
  const oldb = b;
@@ -26596,76 +26623,62 @@ function wordsToMd5(x, len) {
26596
26623
  c = safeAdd(c, oldc);
26597
26624
  d = safeAdd(d, oldd);
26598
26625
  }
26599
-
26600
26626
  return [a, b, c, d];
26601
26627
  }
26628
+
26602
26629
  /*
26603
26630
  * Convert an array bytes to an array of little-endian words
26604
26631
  * Characters >255 have their high-byte silently ignored.
26605
26632
  */
26606
-
26607
-
26608
26633
  function bytesToWords(input) {
26609
26634
  if (input.length === 0) {
26610
26635
  return [];
26611
26636
  }
26612
-
26613
26637
  const length8 = input.length * 8;
26614
26638
  const output = new Uint32Array(getOutputLength(length8));
26615
-
26616
26639
  for (let i = 0; i < length8; i += 8) {
26617
26640
  output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
26618
26641
  }
26619
-
26620
26642
  return output;
26621
26643
  }
26644
+
26622
26645
  /*
26623
26646
  * Add integers, wrapping at 2^32. This uses 16-bit operations internally
26624
26647
  * to work around bugs in some JS interpreters.
26625
26648
  */
26626
-
26627
-
26628
26649
  function safeAdd(x, y) {
26629
26650
  const lsw = (x & 0xffff) + (y & 0xffff);
26630
26651
  const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
26631
26652
  return msw << 16 | lsw & 0xffff;
26632
26653
  }
26654
+
26633
26655
  /*
26634
26656
  * Bitwise rotate a 32-bit number to the left.
26635
26657
  */
26636
-
26637
-
26638
26658
  function bitRotateLeft(num, cnt) {
26639
26659
  return num << cnt | num >>> 32 - cnt;
26640
26660
  }
26661
+
26641
26662
  /*
26642
26663
  * These functions implement the four basic operations the algorithm uses.
26643
26664
  */
26644
-
26645
-
26646
26665
  function md5cmn(q, a, b, x, s, t) {
26647
26666
  return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
26648
26667
  }
26649
-
26650
26668
  function md5ff(a, b, c, d, x, s, t) {
26651
26669
  return md5cmn(b & c | ~b & d, a, b, x, s, t);
26652
26670
  }
26653
-
26654
26671
  function md5gg(a, b, c, d, x, s, t) {
26655
26672
  return md5cmn(b & d | c & ~d, a, b, x, s, t);
26656
26673
  }
26657
-
26658
26674
  function md5hh(a, b, c, d, x, s, t) {
26659
26675
  return md5cmn(b ^ c ^ d, a, b, x, s, t);
26660
26676
  }
26661
-
26662
26677
  function md5ii(a, b, c, d, x, s, t) {
26663
26678
  return md5cmn(c ^ (b | ~d), a, b, x, s, t);
26664
26679
  }
26665
-
26666
- var _default = md5;
26667
- exports.default = _default;
26668
- },{}],498:[function(_dereq_,module,exports){
26680
+ var _default = exports.default = md5;
26681
+ },{}],499:[function(_dereq_,module,exports){
26669
26682
  "use strict";
26670
26683
 
26671
26684
  Object.defineProperty(exports, "__esModule", {
@@ -26673,54 +26686,53 @@ Object.defineProperty(exports, "__esModule", {
26673
26686
  });
26674
26687
  exports.default = void 0;
26675
26688
  const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
26676
- var _default = {
26689
+ var _default = exports.default = {
26677
26690
  randomUUID
26678
26691
  };
26679
- exports.default = _default;
26680
- },{}],499:[function(_dereq_,module,exports){
26692
+ },{}],500:[function(_dereq_,module,exports){
26681
26693
  "use strict";
26682
26694
 
26683
26695
  Object.defineProperty(exports, "__esModule", {
26684
26696
  value: true
26685
26697
  });
26686
26698
  exports.default = void 0;
26687
- var _default = '00000000-0000-0000-0000-000000000000';
26688
- exports.default = _default;
26689
- },{}],500:[function(_dereq_,module,exports){
26699
+ var _default = exports.default = '00000000-0000-0000-0000-000000000000';
26700
+ },{}],501:[function(_dereq_,module,exports){
26690
26701
  "use strict";
26691
26702
 
26692
26703
  Object.defineProperty(exports, "__esModule", {
26693
26704
  value: true
26694
26705
  });
26695
26706
  exports.default = void 0;
26696
-
26697
26707
  var _validate = _interopRequireDefault(_dereq_("./validate.js"));
26698
-
26699
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26700
-
26708
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
26701
26709
  function parse(uuid) {
26702
26710
  if (!(0, _validate.default)(uuid)) {
26703
26711
  throw TypeError('Invalid UUID');
26704
26712
  }
26705
-
26706
26713
  let v;
26707
- const arr = new Uint8Array(16); // Parse ########-....-....-....-............
26714
+ const arr = new Uint8Array(16);
26708
26715
 
26716
+ // Parse ########-....-....-....-............
26709
26717
  arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
26710
26718
  arr[1] = v >>> 16 & 0xff;
26711
26719
  arr[2] = v >>> 8 & 0xff;
26712
- arr[3] = v & 0xff; // Parse ........-####-....-....-............
26720
+ arr[3] = v & 0xff;
26713
26721
 
26722
+ // Parse ........-####-....-....-............
26714
26723
  arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
26715
- arr[5] = v & 0xff; // Parse ........-....-####-....-............
26724
+ arr[5] = v & 0xff;
26716
26725
 
26726
+ // Parse ........-....-####-....-............
26717
26727
  arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
26718
- arr[7] = v & 0xff; // Parse ........-....-....-####-............
26728
+ arr[7] = v & 0xff;
26719
26729
 
26730
+ // Parse ........-....-....-####-............
26720
26731
  arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
26721
- arr[9] = v & 0xff; // Parse ........-....-....-....-############
26722
- // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
26732
+ arr[9] = v & 0xff;
26723
26733
 
26734
+ // Parse ........-....-....-....-############
26735
+ // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
26724
26736
  arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
26725
26737
  arr[11] = v / 0x100000000 & 0xff;
26726
26738
  arr[12] = v >>> 24 & 0xff;
@@ -26729,19 +26741,16 @@ function parse(uuid) {
26729
26741
  arr[15] = v & 0xff;
26730
26742
  return arr;
26731
26743
  }
26732
-
26733
- var _default = parse;
26734
- exports.default = _default;
26735
- },{"./validate.js":510}],501:[function(_dereq_,module,exports){
26744
+ var _default = exports.default = parse;
26745
+ },{"./validate.js":515}],502:[function(_dereq_,module,exports){
26736
26746
  "use strict";
26737
26747
 
26738
26748
  Object.defineProperty(exports, "__esModule", {
26739
26749
  value: true
26740
26750
  });
26741
26751
  exports.default = void 0;
26742
- var _default = /^(?:[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;
26743
- exports.default = _default;
26744
- },{}],502:[function(_dereq_,module,exports){
26752
+ var _default = exports.default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
26753
+ },{}],503:[function(_dereq_,module,exports){
26745
26754
  "use strict";
26746
26755
 
26747
26756
  Object.defineProperty(exports, "__esModule", {
@@ -26751,61 +26760,51 @@ exports.default = rng;
26751
26760
  // Unique ID creation requires a high quality random # generator. In the browser we therefore
26752
26761
  // require the crypto API and do not support built-in fallback to lower quality random number
26753
26762
  // generators (like Math.random()).
26763
+
26754
26764
  let getRandomValues;
26755
26765
  const rnds8 = new Uint8Array(16);
26756
-
26757
26766
  function rng() {
26758
26767
  // lazy load so that environments that need to polyfill have a chance to do so
26759
26768
  if (!getRandomValues) {
26760
26769
  // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
26761
26770
  getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
26762
-
26763
26771
  if (!getRandomValues) {
26764
26772
  throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
26765
26773
  }
26766
26774
  }
26767
-
26768
26775
  return getRandomValues(rnds8);
26769
26776
  }
26770
- },{}],503:[function(_dereq_,module,exports){
26777
+ },{}],504:[function(_dereq_,module,exports){
26771
26778
  "use strict";
26772
26779
 
26773
26780
  Object.defineProperty(exports, "__esModule", {
26774
26781
  value: true
26775
26782
  });
26776
26783
  exports.default = void 0;
26777
-
26778
26784
  // Adapted from Chris Veness' SHA1 code at
26779
26785
  // http://www.movable-type.co.uk/scripts/sha1.html
26780
26786
  function f(s, x, y, z) {
26781
26787
  switch (s) {
26782
26788
  case 0:
26783
26789
  return x & y ^ ~x & z;
26784
-
26785
26790
  case 1:
26786
26791
  return x ^ y ^ z;
26787
-
26788
26792
  case 2:
26789
26793
  return x & y ^ x & z ^ y & z;
26790
-
26791
26794
  case 3:
26792
26795
  return x ^ y ^ z;
26793
26796
  }
26794
26797
  }
26795
-
26796
26798
  function ROTL(x, n) {
26797
26799
  return x << n | x >>> 32 - n;
26798
26800
  }
26799
-
26800
26801
  function sha1(bytes) {
26801
26802
  const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
26802
26803
  const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
26803
-
26804
26804
  if (typeof bytes === 'string') {
26805
26805
  const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
26806
26806
 
26807
26807
  bytes = [];
26808
-
26809
26808
  for (let i = 0; i < msg.length; ++i) {
26810
26809
  bytes.push(msg.charCodeAt(i));
26811
26810
  }
@@ -26813,43 +26812,33 @@ function sha1(bytes) {
26813
26812
  // Convert Array-like to Array
26814
26813
  bytes = Array.prototype.slice.call(bytes);
26815
26814
  }
26816
-
26817
26815
  bytes.push(0x80);
26818
26816
  const l = bytes.length / 4 + 2;
26819
26817
  const N = Math.ceil(l / 16);
26820
26818
  const M = new Array(N);
26821
-
26822
26819
  for (let i = 0; i < N; ++i) {
26823
26820
  const arr = new Uint32Array(16);
26824
-
26825
26821
  for (let j = 0; j < 16; ++j) {
26826
26822
  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];
26827
26823
  }
26828
-
26829
26824
  M[i] = arr;
26830
26825
  }
26831
-
26832
26826
  M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
26833
26827
  M[N - 1][14] = Math.floor(M[N - 1][14]);
26834
26828
  M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
26835
-
26836
26829
  for (let i = 0; i < N; ++i) {
26837
26830
  const W = new Uint32Array(80);
26838
-
26839
26831
  for (let t = 0; t < 16; ++t) {
26840
26832
  W[t] = M[i][t];
26841
26833
  }
26842
-
26843
26834
  for (let t = 16; t < 80; ++t) {
26844
26835
  W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
26845
26836
  }
26846
-
26847
26837
  let a = H[0];
26848
26838
  let b = H[1];
26849
26839
  let c = H[2];
26850
26840
  let d = H[3];
26851
26841
  let e = H[4];
26852
-
26853
26842
  for (let t = 0; t < 80; ++t) {
26854
26843
  const s = Math.floor(t / 20);
26855
26844
  const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
@@ -26859,20 +26848,16 @@ function sha1(bytes) {
26859
26848
  b = a;
26860
26849
  a = T;
26861
26850
  }
26862
-
26863
26851
  H[0] = H[0] + a >>> 0;
26864
26852
  H[1] = H[1] + b >>> 0;
26865
26853
  H[2] = H[2] + c >>> 0;
26866
26854
  H[3] = H[3] + d >>> 0;
26867
26855
  H[4] = H[4] + e >>> 0;
26868
26856
  }
26869
-
26870
26857
  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];
26871
26858
  }
26872
-
26873
- var _default = sha1;
26874
- exports.default = _default;
26875
- },{}],504:[function(_dereq_,module,exports){
26859
+ var _default = exports.default = sha1;
26860
+ },{}],505:[function(_dereq_,module,exports){
26876
26861
  "use strict";
26877
26862
 
26878
26863
  Object.defineProperty(exports, "__esModule", {
@@ -26880,169 +26865,209 @@ Object.defineProperty(exports, "__esModule", {
26880
26865
  });
26881
26866
  exports.default = void 0;
26882
26867
  exports.unsafeStringify = unsafeStringify;
26883
-
26884
26868
  var _validate = _interopRequireDefault(_dereq_("./validate.js"));
26885
-
26886
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26887
-
26869
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
26888
26870
  /**
26889
26871
  * Convert array of 16 byte values to UUID string format of the form:
26890
26872
  * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
26891
26873
  */
26892
26874
  const byteToHex = [];
26893
-
26894
26875
  for (let i = 0; i < 256; ++i) {
26895
26876
  byteToHex.push((i + 0x100).toString(16).slice(1));
26896
26877
  }
26897
-
26898
26878
  function unsafeStringify(arr, offset = 0) {
26899
26879
  // Note: Be careful editing this code! It's been tuned for performance
26900
26880
  // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
26901
- return 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]];
26881
+ //
26882
+ // Note to future-self: No, you can't remove the `toLowerCase()` call.
26883
+ // REF: https://github.com/uuidjs/uuid/pull/677#issuecomment-1757351351
26884
+ return (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();
26902
26885
  }
26903
-
26904
26886
  function stringify(arr, offset = 0) {
26905
- const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one
26887
+ const uuid = unsafeStringify(arr, offset);
26888
+ // Consistency check for valid UUID. If this throws, it's likely due to one
26906
26889
  // of the following:
26907
26890
  // - One or more input array values don't map to a hex octet (leading to
26908
26891
  // "undefined" in the uuid)
26909
26892
  // - Invalid input values for the RFC `version` or `variant` fields
26910
-
26911
26893
  if (!(0, _validate.default)(uuid)) {
26912
26894
  throw TypeError('Stringified UUID is invalid');
26913
26895
  }
26914
-
26915
26896
  return uuid;
26916
26897
  }
26917
-
26918
- var _default = stringify;
26919
- exports.default = _default;
26920
- },{"./validate.js":510}],505:[function(_dereq_,module,exports){
26898
+ var _default = exports.default = stringify;
26899
+ },{"./validate.js":515}],506:[function(_dereq_,module,exports){
26921
26900
  "use strict";
26922
26901
 
26923
26902
  Object.defineProperty(exports, "__esModule", {
26924
26903
  value: true
26925
26904
  });
26926
26905
  exports.default = void 0;
26927
-
26928
26906
  var _rng = _interopRequireDefault(_dereq_("./rng.js"));
26929
-
26930
26907
  var _stringify = _dereq_("./stringify.js");
26931
-
26932
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
26933
-
26908
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
26934
26909
  // **`v1()` - Generate time-based UUID**
26935
26910
  //
26936
26911
  // Inspired by https://github.com/LiosK/UUID.js
26937
26912
  // and http://docs.python.org/library/uuid.html
26938
- let _nodeId;
26939
-
26940
- let _clockseq; // Previous uuid creation time
26941
26913
 
26914
+ let _nodeId;
26915
+ let _clockseq;
26942
26916
 
26917
+ // Previous uuid creation time
26943
26918
  let _lastMSecs = 0;
26944
- let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
26919
+ let _lastNSecs = 0;
26945
26920
 
26921
+ // See https://github.com/uuidjs/uuid for API details
26946
26922
  function v1(options, buf, offset) {
26947
26923
  let i = buf && offset || 0;
26948
26924
  const b = buf || new Array(16);
26949
26925
  options = options || {};
26950
- let node = options.node || _nodeId;
26951
- let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
26952
- // specified. We do this lazily to minimize issues related to insufficient
26953
- // system entropy. See #189
26926
+ let node = options.node;
26927
+ let clockseq = options.clockseq;
26928
+
26929
+ // v1 only: Use cached `node` and `clockseq` values
26930
+ if (!options._v6) {
26931
+ if (!node) {
26932
+ node = _nodeId;
26933
+ }
26934
+ if (clockseq == null) {
26935
+ clockseq = _clockseq;
26936
+ }
26937
+ }
26954
26938
 
26939
+ // Handle cases where we need entropy. We do this lazily to minimize issues
26940
+ // related to insufficient system entropy. See #189
26955
26941
  if (node == null || clockseq == null) {
26956
26942
  const seedBytes = options.random || (options.rng || _rng.default)();
26957
26943
 
26944
+ // Randomize node
26958
26945
  if (node == null) {
26959
- // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
26960
- node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
26946
+ node = [seedBytes[0], seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
26947
+
26948
+ // v1 only: cache node value for reuse
26949
+ if (!_nodeId && !options._v6) {
26950
+ // per RFC4122 4.5: Set MAC multicast bit (v1 only)
26951
+ node[0] |= 0x01; // Set multicast bit
26952
+
26953
+ _nodeId = node;
26954
+ }
26961
26955
  }
26962
26956
 
26957
+ // Randomize clockseq
26963
26958
  if (clockseq == null) {
26964
26959
  // Per 4.2.2, randomize (14 bit) clockseq
26965
- clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
26960
+ clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
26961
+ if (_clockseq === undefined && !options._v6) {
26962
+ _clockseq = clockseq;
26963
+ }
26966
26964
  }
26967
- } // UUID timestamps are 100 nano-second units since the Gregorian epoch,
26968
- // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
26969
- // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
26970
- // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
26965
+ }
26971
26966
 
26967
+ // v1 & v6 timestamps are 100 nano-second units since the Gregorian epoch,
26968
+ // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so time is
26969
+ // handled internally as 'msecs' (integer milliseconds) and 'nsecs'
26970
+ // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
26971
+ let msecs = options.msecs !== undefined ? options.msecs : Date.now();
26972
26972
 
26973
- let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
26973
+ // Per 4.2.1.2, use count of uuid's generated during the current clock
26974
26974
  // cycle to simulate higher resolution clock
26975
+ let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1;
26975
26976
 
26976
- let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
26977
-
26978
- const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
26977
+ // Time since last uuid creation (in msecs)
26978
+ const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000;
26979
26979
 
26980
+ // Per 4.2.1.2, Bump clockseq on clock regression
26980
26981
  if (dt < 0 && options.clockseq === undefined) {
26981
26982
  clockseq = clockseq + 1 & 0x3fff;
26982
- } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
26983
- // time interval
26984
-
26983
+ }
26985
26984
 
26985
+ // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
26986
+ // time interval
26986
26987
  if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
26987
26988
  nsecs = 0;
26988
- } // Per 4.2.1.2 Throw error if too many uuids are requested
26989
-
26989
+ }
26990
26990
 
26991
+ // Per 4.2.1.2 Throw error if too many uuids are requested
26991
26992
  if (nsecs >= 10000) {
26992
26993
  throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
26993
26994
  }
26994
-
26995
26995
  _lastMSecs = msecs;
26996
26996
  _lastNSecs = nsecs;
26997
- _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
26997
+ _clockseq = clockseq;
26998
26998
 
26999
- msecs += 12219292800000; // `time_low`
26999
+ // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
27000
+ msecs += 12219292800000;
27000
27001
 
27002
+ // `time_low`
27001
27003
  const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
27002
27004
  b[i++] = tl >>> 24 & 0xff;
27003
27005
  b[i++] = tl >>> 16 & 0xff;
27004
27006
  b[i++] = tl >>> 8 & 0xff;
27005
- b[i++] = tl & 0xff; // `time_mid`
27007
+ b[i++] = tl & 0xff;
27006
27008
 
27009
+ // `time_mid`
27007
27010
  const tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
27008
27011
  b[i++] = tmh >>> 8 & 0xff;
27009
- b[i++] = tmh & 0xff; // `time_high_and_version`
27012
+ b[i++] = tmh & 0xff;
27010
27013
 
27014
+ // `time_high_and_version`
27011
27015
  b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
27016
+ b[i++] = tmh >>> 16 & 0xff;
27012
27017
 
27013
- b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
27018
+ // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
27019
+ b[i++] = clockseq >>> 8 | 0x80;
27014
27020
 
27015
- b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
27016
-
27017
- b[i++] = clockseq & 0xff; // `node`
27021
+ // `clock_seq_low`
27022
+ b[i++] = clockseq & 0xff;
27018
27023
 
27024
+ // `node`
27019
27025
  for (let n = 0; n < 6; ++n) {
27020
27026
  b[i + n] = node[n];
27021
27027
  }
27022
-
27023
27028
  return buf || (0, _stringify.unsafeStringify)(b);
27024
27029
  }
27030
+ var _default = exports.default = v1;
27031
+ },{"./rng.js":503,"./stringify.js":505}],507:[function(_dereq_,module,exports){
27032
+ "use strict";
27025
27033
 
27026
- var _default = v1;
27027
- exports.default = _default;
27028
- },{"./rng.js":502,"./stringify.js":504}],506:[function(_dereq_,module,exports){
27034
+ Object.defineProperty(exports, "__esModule", {
27035
+ value: true
27036
+ });
27037
+ exports.default = v1ToV6;
27038
+ var _parse = _interopRequireDefault(_dereq_("./parse.js"));
27039
+ var _stringify = _dereq_("./stringify.js");
27040
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
27041
+ /**
27042
+ * Convert a v1 UUID to a v6 UUID
27043
+ *
27044
+ * @param {string|Uint8Array} uuid - The v1 UUID to convert to v6
27045
+ * @returns {string|Uint8Array} The v6 UUID as the same type as the `uuid` arg
27046
+ * (string or Uint8Array)
27047
+ */
27048
+ function v1ToV6(uuid) {
27049
+ const v1Bytes = typeof uuid === 'string' ? (0, _parse.default)(uuid) : uuid;
27050
+ const v6Bytes = _v1ToV6(v1Bytes);
27051
+ return typeof uuid === 'string' ? (0, _stringify.unsafeStringify)(v6Bytes) : v6Bytes;
27052
+ }
27053
+
27054
+ // Do the field transformation needed for v1 -> v6
27055
+ function _v1ToV6(v1Bytes, randomize = false) {
27056
+ return Uint8Array.of((v1Bytes[6] & 0x0f) << 4 | v1Bytes[7] >> 4 & 0x0f, (v1Bytes[7] & 0x0f) << 4 | (v1Bytes[4] & 0xf0) >> 4, (v1Bytes[4] & 0x0f) << 4 | (v1Bytes[5] & 0xf0) >> 4, (v1Bytes[5] & 0x0f) << 4 | (v1Bytes[0] & 0xf0) >> 4, (v1Bytes[0] & 0x0f) << 4 | (v1Bytes[1] & 0xf0) >> 4, (v1Bytes[1] & 0x0f) << 4 | (v1Bytes[2] & 0xf0) >> 4, 0x60 | v1Bytes[2] & 0x0f, v1Bytes[3], v1Bytes[8], v1Bytes[9], v1Bytes[10], v1Bytes[11], v1Bytes[12], v1Bytes[13], v1Bytes[14], v1Bytes[15]);
27057
+ }
27058
+ },{"./parse.js":501,"./stringify.js":505}],508:[function(_dereq_,module,exports){
27029
27059
  "use strict";
27030
27060
 
27031
27061
  Object.defineProperty(exports, "__esModule", {
27032
27062
  value: true
27033
27063
  });
27034
27064
  exports.default = void 0;
27035
-
27036
27065
  var _v = _interopRequireDefault(_dereq_("./v35.js"));
27037
-
27038
27066
  var _md = _interopRequireDefault(_dereq_("./md5.js"));
27039
-
27040
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27041
-
27067
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
27042
27068
  const v3 = (0, _v.default)('v3', 0x30, _md.default);
27043
- var _default = v3;
27044
- exports.default = _default;
27045
- },{"./md5.js":497,"./v35.js":507}],507:[function(_dereq_,module,exports){
27069
+ var _default = exports.default = v3;
27070
+ },{"./md5.js":498,"./v35.js":509}],509:[function(_dereq_,module,exports){
27046
27071
  "use strict";
27047
27072
 
27048
27073
  Object.defineProperty(exports, "__esModule", {
@@ -27050,181 +27075,356 @@ Object.defineProperty(exports, "__esModule", {
27050
27075
  });
27051
27076
  exports.URL = exports.DNS = void 0;
27052
27077
  exports.default = v35;
27053
-
27054
27078
  var _stringify = _dereq_("./stringify.js");
27055
-
27056
27079
  var _parse = _interopRequireDefault(_dereq_("./parse.js"));
27057
-
27058
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27059
-
27080
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
27060
27081
  function stringToBytes(str) {
27061
27082
  str = unescape(encodeURIComponent(str)); // UTF8 escape
27062
27083
 
27063
27084
  const bytes = [];
27064
-
27065
27085
  for (let i = 0; i < str.length; ++i) {
27066
27086
  bytes.push(str.charCodeAt(i));
27067
27087
  }
27068
-
27069
27088
  return bytes;
27070
27089
  }
27071
-
27072
- const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
27073
- exports.DNS = DNS;
27074
- const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
27075
- exports.URL = URL;
27076
-
27090
+ const DNS = exports.DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
27091
+ const URL = exports.URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
27077
27092
  function v35(name, version, hashfunc) {
27078
27093
  function generateUUID(value, namespace, buf, offset) {
27079
27094
  var _namespace;
27080
-
27081
27095
  if (typeof value === 'string') {
27082
27096
  value = stringToBytes(value);
27083
27097
  }
27084
-
27085
27098
  if (typeof namespace === 'string') {
27086
27099
  namespace = (0, _parse.default)(namespace);
27087
27100
  }
27088
-
27089
27101
  if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
27090
27102
  throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
27091
- } // Compute hash of namespace and value, Per 4.3
27103
+ }
27104
+
27105
+ // Compute hash of namespace and value, Per 4.3
27092
27106
  // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
27093
27107
  // hashfunc([...namespace, ... value])`
27094
-
27095
-
27096
27108
  let bytes = new Uint8Array(16 + value.length);
27097
27109
  bytes.set(namespace);
27098
27110
  bytes.set(value, namespace.length);
27099
27111
  bytes = hashfunc(bytes);
27100
27112
  bytes[6] = bytes[6] & 0x0f | version;
27101
27113
  bytes[8] = bytes[8] & 0x3f | 0x80;
27102
-
27103
27114
  if (buf) {
27104
27115
  offset = offset || 0;
27105
-
27106
27116
  for (let i = 0; i < 16; ++i) {
27107
27117
  buf[offset + i] = bytes[i];
27108
27118
  }
27109
-
27110
27119
  return buf;
27111
27120
  }
27112
-
27113
27121
  return (0, _stringify.unsafeStringify)(bytes);
27114
- } // Function#name is not settable on some platforms (#270)
27115
-
27122
+ }
27116
27123
 
27124
+ // Function#name is not settable on some platforms (#270)
27117
27125
  try {
27118
- generateUUID.name = name; // eslint-disable-next-line no-empty
27119
- } catch (err) {} // For CommonJS default export support
27120
-
27126
+ generateUUID.name = name;
27127
+ } catch (err) {}
27121
27128
 
27129
+ // For CommonJS default export support
27122
27130
  generateUUID.DNS = DNS;
27123
27131
  generateUUID.URL = URL;
27124
27132
  return generateUUID;
27125
27133
  }
27126
- },{"./parse.js":500,"./stringify.js":504}],508:[function(_dereq_,module,exports){
27134
+ },{"./parse.js":501,"./stringify.js":505}],510:[function(_dereq_,module,exports){
27127
27135
  "use strict";
27128
27136
 
27129
27137
  Object.defineProperty(exports, "__esModule", {
27130
27138
  value: true
27131
27139
  });
27132
27140
  exports.default = void 0;
27133
-
27134
27141
  var _native = _interopRequireDefault(_dereq_("./native.js"));
27135
-
27136
27142
  var _rng = _interopRequireDefault(_dereq_("./rng.js"));
27137
-
27138
27143
  var _stringify = _dereq_("./stringify.js");
27139
-
27140
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27141
-
27144
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
27142
27145
  function v4(options, buf, offset) {
27143
27146
  if (_native.default.randomUUID && !buf && !options) {
27144
27147
  return _native.default.randomUUID();
27145
27148
  }
27146
-
27147
27149
  options = options || {};
27150
+ const rnds = options.random || (options.rng || _rng.default)();
27148
27151
 
27149
- const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
27150
-
27151
-
27152
+ // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
27152
27153
  rnds[6] = rnds[6] & 0x0f | 0x40;
27153
- rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
27154
+ rnds[8] = rnds[8] & 0x3f | 0x80;
27154
27155
 
27156
+ // Copy bytes to buffer, if provided
27155
27157
  if (buf) {
27156
27158
  offset = offset || 0;
27157
-
27158
27159
  for (let i = 0; i < 16; ++i) {
27159
27160
  buf[offset + i] = rnds[i];
27160
27161
  }
27161
-
27162
27162
  return buf;
27163
27163
  }
27164
-
27165
27164
  return (0, _stringify.unsafeStringify)(rnds);
27166
27165
  }
27167
-
27168
- var _default = v4;
27169
- exports.default = _default;
27170
- },{"./native.js":498,"./rng.js":502,"./stringify.js":504}],509:[function(_dereq_,module,exports){
27166
+ var _default = exports.default = v4;
27167
+ },{"./native.js":499,"./rng.js":503,"./stringify.js":505}],511:[function(_dereq_,module,exports){
27171
27168
  "use strict";
27172
27169
 
27173
27170
  Object.defineProperty(exports, "__esModule", {
27174
27171
  value: true
27175
27172
  });
27176
27173
  exports.default = void 0;
27177
-
27178
27174
  var _v = _interopRequireDefault(_dereq_("./v35.js"));
27179
-
27180
27175
  var _sha = _interopRequireDefault(_dereq_("./sha1.js"));
27176
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
27177
+ const v5 = (0, _v.default)('v5', 0x50, _sha.default);
27178
+ var _default = exports.default = v5;
27179
+ },{"./sha1.js":504,"./v35.js":509}],512:[function(_dereq_,module,exports){
27180
+ "use strict";
27181
27181
 
27182
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27182
+ Object.defineProperty(exports, "__esModule", {
27183
+ value: true
27184
+ });
27185
+ exports.default = v6;
27186
+ var _stringify = _dereq_("./stringify.js");
27187
+ var _v = _interopRequireDefault(_dereq_("./v1.js"));
27188
+ var _v1ToV = _interopRequireDefault(_dereq_("./v1ToV6.js"));
27189
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
27190
+ /**
27191
+ *
27192
+ * @param {object} options
27193
+ * @param {Uint8Array=} buf
27194
+ * @param {number=} offset
27195
+ * @returns
27196
+ */
27197
+ function v6(options = {}, buf, offset = 0) {
27198
+ // v6 is v1 with different field layout, so we start with a v1 UUID, albeit
27199
+ // with slightly different behavior around how the clock_seq and node fields
27200
+ // are randomized, which is why we call v1 with _v6: true.
27201
+ let bytes = (0, _v.default)({
27202
+ ...options,
27203
+ _v6: true
27204
+ }, new Uint8Array(16));
27205
+
27206
+ // Reorder the fields to v6 layout.
27207
+ bytes = (0, _v1ToV.default)(bytes);
27208
+
27209
+ // Return as a byte array if requested
27210
+ if (buf) {
27211
+ for (let i = 0; i < 16; i++) {
27212
+ buf[offset + i] = bytes[i];
27213
+ }
27214
+ return buf;
27215
+ }
27216
+ return (0, _stringify.unsafeStringify)(bytes);
27217
+ }
27218
+ },{"./stringify.js":505,"./v1.js":506,"./v1ToV6.js":507}],513:[function(_dereq_,module,exports){
27219
+ "use strict";
27183
27220
 
27184
- const v5 = (0, _v.default)('v5', 0x50, _sha.default);
27185
- var _default = v5;
27186
- exports.default = _default;
27187
- },{"./sha1.js":503,"./v35.js":507}],510:[function(_dereq_,module,exports){
27221
+ Object.defineProperty(exports, "__esModule", {
27222
+ value: true
27223
+ });
27224
+ exports.default = v6ToV1;
27225
+ var _parse = _interopRequireDefault(_dereq_("./parse.js"));
27226
+ var _stringify = _dereq_("./stringify.js");
27227
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
27228
+ /**
27229
+ * Convert a v6 UUID to a v1 UUID
27230
+ *
27231
+ * @param {string|Uint8Array} uuid - The v6 UUID to convert to v6
27232
+ * @returns {string|Uint8Array} The v1 UUID as the same type as the `uuid` arg
27233
+ * (string or Uint8Array)
27234
+ */
27235
+ function v6ToV1(uuid) {
27236
+ const v6Bytes = typeof uuid === 'string' ? (0, _parse.default)(uuid) : uuid;
27237
+ const v1Bytes = _v6ToV1(v6Bytes);
27238
+ return typeof uuid === 'string' ? (0, _stringify.unsafeStringify)(v1Bytes) : v1Bytes;
27239
+ }
27240
+
27241
+ // Do the field transformation needed for v6 -> v1
27242
+ function _v6ToV1(v6Bytes) {
27243
+ return Uint8Array.of((v6Bytes[3] & 0x0f) << 4 | v6Bytes[4] >> 4 & 0x0f, (v6Bytes[4] & 0x0f) << 4 | (v6Bytes[5] & 0xf0) >> 4, (v6Bytes[5] & 0x0f) << 4 | v6Bytes[6] & 0x0f, v6Bytes[7], (v6Bytes[1] & 0x0f) << 4 | (v6Bytes[2] & 0xf0) >> 4, (v6Bytes[2] & 0x0f) << 4 | (v6Bytes[3] & 0xf0) >> 4, 0x10 | (v6Bytes[0] & 0xf0) >> 4, (v6Bytes[0] & 0x0f) << 4 | (v6Bytes[1] & 0xf0) >> 4, v6Bytes[8], v6Bytes[9], v6Bytes[10], v6Bytes[11], v6Bytes[12], v6Bytes[13], v6Bytes[14], v6Bytes[15]);
27244
+ }
27245
+ },{"./parse.js":501,"./stringify.js":505}],514:[function(_dereq_,module,exports){
27188
27246
  "use strict";
27189
27247
 
27190
27248
  Object.defineProperty(exports, "__esModule", {
27191
27249
  value: true
27192
27250
  });
27193
27251
  exports.default = void 0;
27252
+ var _rng = _interopRequireDefault(_dereq_("./rng.js"));
27253
+ var _stringify = _dereq_("./stringify.js");
27254
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
27255
+ /**
27256
+ * UUID V7 - Unix Epoch time-based UUID
27257
+ *
27258
+ * The IETF has published RFC9562, introducing 3 new UUID versions (6,7,8). This
27259
+ * implementation of V7 is based on the accepted, though not yet approved,
27260
+ * revisions.
27261
+ *
27262
+ * RFC 9562:https://www.rfc-editor.org/rfc/rfc9562.html Universally Unique
27263
+ * IDentifiers (UUIDs)
27194
27264
 
27195
- var _regex = _interopRequireDefault(_dereq_("./regex.js"));
27265
+ *
27266
+ * Sample V7 value:
27267
+ * https://www.rfc-editor.org/rfc/rfc9562.html#name-example-of-a-uuidv7-value
27268
+ *
27269
+ * Monotonic Bit Layout: RFC rfc9562.6.2 Method 1, Dedicated Counter Bits ref:
27270
+ * https://www.rfc-editor.org/rfc/rfc9562.html#section-6.2-5.1
27271
+ *
27272
+ * 0 1 2 3 0 1 2 3 4 5 6
27273
+ * 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
27274
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27275
+ * | unix_ts_ms |
27276
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27277
+ * | unix_ts_ms | ver | seq_hi |
27278
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27279
+ * |var| seq_low | rand |
27280
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27281
+ * | rand |
27282
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27283
+ *
27284
+ * seq is a 31 bit serialized counter; comprised of 12 bit seq_hi and 19 bit
27285
+ * seq_low, and randomly initialized upon timestamp change. 31 bit counter size
27286
+ * was selected as any bitwise operations in node are done as _signed_ 32 bit
27287
+ * ints. we exclude the sign bit.
27288
+ */
27196
27289
 
27197
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27290
+ let _seqLow = null;
27291
+ let _seqHigh = null;
27292
+ let _msecs = 0;
27293
+ function v7(options, buf, offset) {
27294
+ options = options || {};
27198
27295
 
27296
+ // initialize buffer and pointer
27297
+ let i = buf && offset || 0;
27298
+ const b = buf || new Uint8Array(16);
27299
+
27300
+ // rnds is Uint8Array(16) filled with random bytes
27301
+ const rnds = options.random || (options.rng || _rng.default)();
27302
+
27303
+ // milliseconds since unix epoch, 1970-01-01 00:00
27304
+ const msecs = options.msecs !== undefined ? options.msecs : Date.now();
27305
+
27306
+ // seq is user provided 31 bit counter
27307
+ let seq = options.seq !== undefined ? options.seq : null;
27308
+
27309
+ // initialize local seq high/low parts
27310
+ let seqHigh = _seqHigh;
27311
+ let seqLow = _seqLow;
27312
+
27313
+ // check if clock has advanced and user has not provided msecs
27314
+ if (msecs > _msecs && options.msecs === undefined) {
27315
+ _msecs = msecs;
27316
+
27317
+ // unless user provided seq, reset seq parts
27318
+ if (seq !== null) {
27319
+ seqHigh = null;
27320
+ seqLow = null;
27321
+ }
27322
+ }
27323
+
27324
+ // if we have a user provided seq
27325
+ if (seq !== null) {
27326
+ // trim provided seq to 31 bits of value, avoiding overflow
27327
+ if (seq > 0x7fffffff) {
27328
+ seq = 0x7fffffff;
27329
+ }
27330
+
27331
+ // split provided seq into high/low parts
27332
+ seqHigh = seq >>> 19 & 0xfff;
27333
+ seqLow = seq & 0x7ffff;
27334
+ }
27335
+
27336
+ // randomly initialize seq
27337
+ if (seqHigh === null || seqLow === null) {
27338
+ seqHigh = rnds[6] & 0x7f;
27339
+ seqHigh = seqHigh << 8 | rnds[7];
27340
+ seqLow = rnds[8] & 0x3f; // pad for var
27341
+ seqLow = seqLow << 8 | rnds[9];
27342
+ seqLow = seqLow << 5 | rnds[10] >>> 3;
27343
+ }
27344
+
27345
+ // increment seq if within msecs window
27346
+ if (msecs + 10000 > _msecs && seq === null) {
27347
+ if (++seqLow > 0x7ffff) {
27348
+ seqLow = 0;
27349
+ if (++seqHigh > 0xfff) {
27350
+ seqHigh = 0;
27351
+
27352
+ // increment internal _msecs. this allows us to continue incrementing
27353
+ // while staying monotonic. Note, once we hit 10k milliseconds beyond system
27354
+ // clock, we will reset breaking monotonicity (after (2^31)*10000 generations)
27355
+ _msecs++;
27356
+ }
27357
+ }
27358
+ } else {
27359
+ // resetting; we have advanced more than
27360
+ // 10k milliseconds beyond system clock
27361
+ _msecs = msecs;
27362
+ }
27363
+ _seqHigh = seqHigh;
27364
+ _seqLow = seqLow;
27365
+
27366
+ // [bytes 0-5] 48 bits of local timestamp
27367
+ b[i++] = _msecs / 0x10000000000 & 0xff;
27368
+ b[i++] = _msecs / 0x100000000 & 0xff;
27369
+ b[i++] = _msecs / 0x1000000 & 0xff;
27370
+ b[i++] = _msecs / 0x10000 & 0xff;
27371
+ b[i++] = _msecs / 0x100 & 0xff;
27372
+ b[i++] = _msecs & 0xff;
27373
+
27374
+ // [byte 6] - set 4 bits of version (7) with first 4 bits seq_hi
27375
+ b[i++] = seqHigh >>> 4 & 0x0f | 0x70;
27376
+
27377
+ // [byte 7] remaining 8 bits of seq_hi
27378
+ b[i++] = seqHigh & 0xff;
27379
+
27380
+ // [byte 8] - variant (2 bits), first 6 bits seq_low
27381
+ b[i++] = seqLow >>> 13 & 0x3f | 0x80;
27382
+
27383
+ // [byte 9] 8 bits seq_low
27384
+ b[i++] = seqLow >>> 5 & 0xff;
27385
+
27386
+ // [byte 10] remaining 5 bits seq_low, 3 bits random
27387
+ b[i++] = seqLow << 3 & 0xff | rnds[10] & 0x07;
27388
+
27389
+ // [bytes 11-15] always random
27390
+ b[i++] = rnds[11];
27391
+ b[i++] = rnds[12];
27392
+ b[i++] = rnds[13];
27393
+ b[i++] = rnds[14];
27394
+ b[i++] = rnds[15];
27395
+ return buf || (0, _stringify.unsafeStringify)(b);
27396
+ }
27397
+ var _default = exports.default = v7;
27398
+ },{"./rng.js":503,"./stringify.js":505}],515:[function(_dereq_,module,exports){
27399
+ "use strict";
27400
+
27401
+ Object.defineProperty(exports, "__esModule", {
27402
+ value: true
27403
+ });
27404
+ exports.default = void 0;
27405
+ var _regex = _interopRequireDefault(_dereq_("./regex.js"));
27406
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
27199
27407
  function validate(uuid) {
27200
27408
  return typeof uuid === 'string' && _regex.default.test(uuid);
27201
27409
  }
27202
-
27203
- var _default = validate;
27204
- exports.default = _default;
27205
- },{"./regex.js":501}],511:[function(_dereq_,module,exports){
27410
+ var _default = exports.default = validate;
27411
+ },{"./regex.js":502}],516:[function(_dereq_,module,exports){
27206
27412
  "use strict";
27207
27413
 
27208
27414
  Object.defineProperty(exports, "__esModule", {
27209
27415
  value: true
27210
27416
  });
27211
27417
  exports.default = void 0;
27212
-
27213
27418
  var _validate = _interopRequireDefault(_dereq_("./validate.js"));
27214
-
27215
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
27216
-
27419
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
27217
27420
  function version(uuid) {
27218
27421
  if (!(0, _validate.default)(uuid)) {
27219
27422
  throw TypeError('Invalid UUID');
27220
27423
  }
27221
-
27222
27424
  return parseInt(uuid.slice(14, 15), 16);
27223
27425
  }
27224
-
27225
- var _default = version;
27226
- exports.default = _default;
27227
- },{"./validate.js":510}],512:[function(_dereq_,module,exports){
27426
+ var _default = exports.default = version;
27427
+ },{"./validate.js":515}],517:[function(_dereq_,module,exports){
27228
27428
  'use strict';
27229
27429
 
27230
27430
  module.exports = function () {