@nocobase/plugin-notification-in-app-message 2.1.0-beta.2 → 2.1.0-beta.21

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 (104) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +99 -1
  3. package/dist/client/index.js +1 -1
  4. package/dist/externalVersion.js +9 -11
  5. package/dist/node_modules/uuid/dist/bin/uuid +2 -0
  6. package/dist/node_modules/uuid/dist/commonjs-browser/index.js +104 -0
  7. package/dist/node_modules/uuid/dist/commonjs-browser/max.js +7 -0
  8. package/dist/node_modules/uuid/dist/commonjs-browser/md5.js +200 -0
  9. package/dist/node_modules/uuid/dist/commonjs-browser/native.js +10 -0
  10. package/dist/node_modules/uuid/dist/commonjs-browser/nil.js +7 -0
  11. package/dist/node_modules/uuid/dist/commonjs-browser/parse.js +44 -0
  12. package/dist/node_modules/uuid/dist/commonjs-browser/regex.js +7 -0
  13. package/dist/node_modules/uuid/dist/commonjs-browser/rng.js +23 -0
  14. package/dist/node_modules/uuid/dist/commonjs-browser/sha1.js +82 -0
  15. package/dist/node_modules/uuid/dist/commonjs-browser/stringify.js +38 -0
  16. package/dist/node_modules/uuid/dist/commonjs-browser/v1.js +131 -0
  17. package/dist/node_modules/uuid/dist/commonjs-browser/v1ToV6.js +26 -0
  18. package/dist/node_modules/uuid/dist/commonjs-browser/v3.js +11 -0
  19. package/dist/node_modules/uuid/dist/commonjs-browser/v35.js +63 -0
  20. package/dist/node_modules/uuid/dist/commonjs-browser/v4.js +32 -0
  21. package/dist/node_modules/uuid/dist/commonjs-browser/v5.js +11 -0
  22. package/dist/node_modules/uuid/dist/commonjs-browser/v6.js +42 -0
  23. package/dist/node_modules/uuid/dist/commonjs-browser/v6ToV1.js +26 -0
  24. package/dist/node_modules/uuid/dist/commonjs-browser/v7.js +152 -0
  25. package/dist/node_modules/uuid/dist/commonjs-browser/validate.js +12 -0
  26. package/dist/node_modules/uuid/dist/commonjs-browser/version.js +15 -0
  27. package/dist/node_modules/uuid/dist/esm-browser/index.js +14 -0
  28. package/dist/node_modules/uuid/dist/esm-browser/max.js +1 -0
  29. package/dist/node_modules/uuid/dist/esm-browser/md5.js +194 -0
  30. package/dist/node_modules/uuid/dist/esm-browser/native.js +4 -0
  31. package/dist/node_modules/uuid/dist/esm-browser/nil.js +1 -0
  32. package/dist/node_modules/uuid/dist/esm-browser/parse.js +37 -0
  33. package/dist/node_modules/uuid/dist/esm-browser/regex.js +1 -0
  34. package/dist/node_modules/uuid/dist/esm-browser/rng.js +17 -0
  35. package/dist/node_modules/uuid/dist/esm-browser/sha1.js +76 -0
  36. package/dist/node_modules/uuid/dist/esm-browser/stringify.js +31 -0
  37. package/dist/node_modules/uuid/dist/esm-browser/v1.js +125 -0
  38. package/dist/node_modules/uuid/dist/esm-browser/v1ToV6.js +20 -0
  39. package/dist/node_modules/uuid/dist/esm-browser/v3.js +4 -0
  40. package/dist/node_modules/uuid/dist/esm-browser/v35.js +55 -0
  41. package/dist/node_modules/uuid/dist/esm-browser/v4.js +25 -0
  42. package/dist/node_modules/uuid/dist/esm-browser/v5.js +4 -0
  43. package/dist/node_modules/uuid/dist/esm-browser/v6.js +36 -0
  44. package/dist/node_modules/uuid/dist/esm-browser/v6ToV1.js +20 -0
  45. package/dist/node_modules/uuid/dist/esm-browser/v7.js +146 -0
  46. package/dist/node_modules/uuid/dist/esm-browser/validate.js +5 -0
  47. package/dist/node_modules/uuid/dist/esm-browser/version.js +8 -0
  48. package/dist/node_modules/uuid/dist/esm-node/index.js +14 -0
  49. package/dist/node_modules/uuid/dist/esm-node/max.js +1 -0
  50. package/dist/node_modules/uuid/dist/esm-node/md5.js +10 -0
  51. package/dist/node_modules/uuid/dist/esm-node/native.js +4 -0
  52. package/dist/node_modules/uuid/dist/esm-node/nil.js +1 -0
  53. package/dist/node_modules/uuid/dist/esm-node/parse.js +37 -0
  54. package/dist/node_modules/uuid/dist/esm-node/regex.js +1 -0
  55. package/dist/node_modules/uuid/dist/esm-node/rng.js +10 -0
  56. package/dist/node_modules/uuid/dist/esm-node/sha1.js +10 -0
  57. package/dist/node_modules/uuid/dist/esm-node/stringify.js +31 -0
  58. package/dist/node_modules/uuid/dist/esm-node/v1.js +125 -0
  59. package/dist/node_modules/uuid/dist/esm-node/v1ToV6.js +20 -0
  60. package/dist/node_modules/uuid/dist/esm-node/v3.js +4 -0
  61. package/dist/node_modules/uuid/dist/esm-node/v35.js +55 -0
  62. package/dist/node_modules/uuid/dist/esm-node/v4.js +25 -0
  63. package/dist/node_modules/uuid/dist/esm-node/v5.js +4 -0
  64. package/dist/node_modules/uuid/dist/esm-node/v6.js +32 -0
  65. package/dist/node_modules/uuid/dist/esm-node/v6ToV1.js +20 -0
  66. package/dist/node_modules/uuid/dist/esm-node/v7.js +146 -0
  67. package/dist/node_modules/uuid/dist/esm-node/validate.js +5 -0
  68. package/dist/node_modules/uuid/dist/esm-node/version.js +8 -0
  69. package/dist/node_modules/uuid/dist/index.js +1 -0
  70. package/dist/node_modules/uuid/dist/max.js +7 -0
  71. package/dist/node_modules/uuid/dist/md5-browser.js +200 -0
  72. package/dist/node_modules/uuid/dist/md5.js +17 -0
  73. package/dist/node_modules/uuid/dist/native-browser.js +10 -0
  74. package/dist/node_modules/uuid/dist/native.js +11 -0
  75. package/dist/node_modules/uuid/dist/nil.js +7 -0
  76. package/dist/node_modules/uuid/dist/parse.js +44 -0
  77. package/dist/node_modules/uuid/dist/regex.js +7 -0
  78. package/dist/node_modules/uuid/dist/rng-browser.js +23 -0
  79. package/dist/node_modules/uuid/dist/rng.js +17 -0
  80. package/dist/node_modules/uuid/dist/sha1-browser.js +82 -0
  81. package/dist/node_modules/uuid/dist/sha1.js +17 -0
  82. package/dist/node_modules/uuid/dist/stringify.js +38 -0
  83. package/dist/node_modules/uuid/dist/uuid-bin.js +75 -0
  84. package/dist/node_modules/uuid/dist/v1.js +131 -0
  85. package/dist/node_modules/uuid/dist/v1ToV6.js +26 -0
  86. package/dist/node_modules/uuid/dist/v3.js +11 -0
  87. package/dist/node_modules/uuid/dist/v35.js +63 -0
  88. package/dist/node_modules/uuid/dist/v4.js +32 -0
  89. package/dist/node_modules/uuid/dist/v5.js +11 -0
  90. package/dist/node_modules/uuid/dist/v6.js +38 -0
  91. package/dist/node_modules/uuid/dist/v6ToV1.js +26 -0
  92. package/dist/node_modules/uuid/dist/v7.js +152 -0
  93. package/dist/node_modules/uuid/dist/validate.js +12 -0
  94. package/dist/node_modules/uuid/dist/version.js +15 -0
  95. package/dist/node_modules/uuid/package.json +1 -0
  96. package/dist/server/InAppNotificationChannel.d.ts +5 -0
  97. package/dist/server/InAppNotificationChannel.js +93 -35
  98. package/dist/server/defineMyInAppMessages.js +2 -1
  99. package/dist/server/parseUserSelectionConf.d.ts +2 -1
  100. package/dist/server/parseUserSelectionConf.js +3 -2
  101. package/package.json +5 -2
  102. package/LICENSE.txt +0 -172
  103. package/dist/client/components/UsersAddition.d.ts +0 -10
  104. package/dist/client/components/UsersSelect.d.ts +0 -18
@@ -0,0 +1,131 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _rng = _interopRequireDefault(require("./rng.js"));
8
+ var _stringify = require("./stringify.js");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ // **`v1()` - Generate time-based UUID**
11
+ //
12
+ // Inspired by https://github.com/LiosK/UUID.js
13
+ // and http://docs.python.org/library/uuid.html
14
+
15
+ var _nodeId;
16
+ var _clockseq;
17
+
18
+ // Previous uuid creation time
19
+ var _lastMSecs = 0;
20
+ var _lastNSecs = 0;
21
+
22
+ // See https://github.com/uuidjs/uuid for API details
23
+ function v1(options, buf, offset) {
24
+ var i = buf && offset || 0;
25
+ var b = buf || new Array(16);
26
+ options = options || {};
27
+ var node = options.node;
28
+ var clockseq = options.clockseq;
29
+
30
+ // v1 only: Use cached `node` and `clockseq` values
31
+ if (!options._v6) {
32
+ if (!node) {
33
+ node = _nodeId;
34
+ }
35
+ if (clockseq == null) {
36
+ clockseq = _clockseq;
37
+ }
38
+ }
39
+
40
+ // Handle cases where we need entropy. We do this lazily to minimize issues
41
+ // related to insufficient system entropy. See #189
42
+ if (node == null || clockseq == null) {
43
+ var seedBytes = options.random || (options.rng || _rng.default)();
44
+
45
+ // Randomize node
46
+ if (node == null) {
47
+ node = [seedBytes[0], seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
48
+
49
+ // v1 only: cache node value for reuse
50
+ if (!_nodeId && !options._v6) {
51
+ // per RFC4122 4.5: Set MAC multicast bit (v1 only)
52
+ node[0] |= 0x01; // Set multicast bit
53
+
54
+ _nodeId = node;
55
+ }
56
+ }
57
+
58
+ // Randomize clockseq
59
+ if (clockseq == null) {
60
+ // Per 4.2.2, randomize (14 bit) clockseq
61
+ clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
62
+ if (_clockseq === undefined && !options._v6) {
63
+ _clockseq = clockseq;
64
+ }
65
+ }
66
+ }
67
+
68
+ // v1 & v6 timestamps are 100 nano-second units since the Gregorian epoch,
69
+ // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so time is
70
+ // handled internally as 'msecs' (integer milliseconds) and 'nsecs'
71
+ // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
72
+ var msecs = options.msecs !== undefined ? options.msecs : Date.now();
73
+
74
+ // Per 4.2.1.2, use count of uuid's generated during the current clock
75
+ // cycle to simulate higher resolution clock
76
+ var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1;
77
+
78
+ // Time since last uuid creation (in msecs)
79
+ var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000;
80
+
81
+ // Per 4.2.1.2, Bump clockseq on clock regression
82
+ if (dt < 0 && options.clockseq === undefined) {
83
+ clockseq = clockseq + 1 & 0x3fff;
84
+ }
85
+
86
+ // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
87
+ // time interval
88
+ if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
89
+ nsecs = 0;
90
+ }
91
+
92
+ // Per 4.2.1.2 Throw error if too many uuids are requested
93
+ if (nsecs >= 10000) {
94
+ throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
95
+ }
96
+ _lastMSecs = msecs;
97
+ _lastNSecs = nsecs;
98
+ _clockseq = clockseq;
99
+
100
+ // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
101
+ msecs += 12219292800000;
102
+
103
+ // `time_low`
104
+ var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
105
+ b[i++] = tl >>> 24 & 0xff;
106
+ b[i++] = tl >>> 16 & 0xff;
107
+ b[i++] = tl >>> 8 & 0xff;
108
+ b[i++] = tl & 0xff;
109
+
110
+ // `time_mid`
111
+ var tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
112
+ b[i++] = tmh >>> 8 & 0xff;
113
+ b[i++] = tmh & 0xff;
114
+
115
+ // `time_high_and_version`
116
+ b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
117
+ b[i++] = tmh >>> 16 & 0xff;
118
+
119
+ // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
120
+ b[i++] = clockseq >>> 8 | 0x80;
121
+
122
+ // `clock_seq_low`
123
+ b[i++] = clockseq & 0xff;
124
+
125
+ // `node`
126
+ for (var n = 0; n < 6; ++n) {
127
+ b[i + n] = node[n];
128
+ }
129
+ return buf || (0, _stringify.unsafeStringify)(b);
130
+ }
131
+ var _default = exports.default = v1;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = v1ToV6;
7
+ var _parse = _interopRequireDefault(require("./parse.js"));
8
+ var _stringify = require("./stringify.js");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ /**
11
+ * Convert a v1 UUID to a v6 UUID
12
+ *
13
+ * @param {string|Uint8Array} uuid - The v1 UUID to convert to v6
14
+ * @returns {string|Uint8Array} The v6 UUID as the same type as the `uuid` arg
15
+ * (string or Uint8Array)
16
+ */
17
+ function v1ToV6(uuid) {
18
+ var v1Bytes = typeof uuid === 'string' ? (0, _parse.default)(uuid) : uuid;
19
+ var v6Bytes = _v1ToV6(v1Bytes);
20
+ return typeof uuid === 'string' ? (0, _stringify.unsafeStringify)(v6Bytes) : v6Bytes;
21
+ }
22
+
23
+ // Do the field transformation needed for v1 -> v6
24
+ function _v1ToV6(v1Bytes, randomize = false) {
25
+ 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]);
26
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _v = _interopRequireDefault(require("./v35.js"));
8
+ var _md = _interopRequireDefault(require("./md5.js"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ var v3 = (0, _v.default)('v3', 0x30, _md.default);
11
+ var _default = exports.default = v3;
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.URL = exports.DNS = void 0;
7
+ exports.default = v35;
8
+ var _stringify = require("./stringify.js");
9
+ var _parse = _interopRequireDefault(require("./parse.js"));
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ function stringToBytes(str) {
12
+ str = unescape(encodeURIComponent(str)); // UTF8 escape
13
+
14
+ var bytes = [];
15
+ for (var i = 0; i < str.length; ++i) {
16
+ bytes.push(str.charCodeAt(i));
17
+ }
18
+ return bytes;
19
+ }
20
+ var DNS = exports.DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
21
+ var URL = exports.URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
22
+ function v35(name, version, hashfunc) {
23
+ function generateUUID(value, namespace, buf, offset) {
24
+ var _namespace;
25
+ if (typeof value === 'string') {
26
+ value = stringToBytes(value);
27
+ }
28
+ if (typeof namespace === 'string') {
29
+ namespace = (0, _parse.default)(namespace);
30
+ }
31
+ if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
32
+ throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
33
+ }
34
+
35
+ // Compute hash of namespace and value, Per 4.3
36
+ // Future: Use spread syntax when supported on all platforms, e.g. `bytes =
37
+ // hashfunc([...namespace, ... value])`
38
+ var bytes = new Uint8Array(16 + value.length);
39
+ bytes.set(namespace);
40
+ bytes.set(value, namespace.length);
41
+ bytes = hashfunc(bytes);
42
+ bytes[6] = bytes[6] & 0x0f | version;
43
+ bytes[8] = bytes[8] & 0x3f | 0x80;
44
+ if (buf) {
45
+ offset = offset || 0;
46
+ for (var i = 0; i < 16; ++i) {
47
+ buf[offset + i] = bytes[i];
48
+ }
49
+ return buf;
50
+ }
51
+ return (0, _stringify.unsafeStringify)(bytes);
52
+ }
53
+
54
+ // Function#name is not settable on some platforms (#270)
55
+ try {
56
+ generateUUID.name = name;
57
+ } catch (err) {}
58
+
59
+ // For CommonJS default export support
60
+ generateUUID.DNS = DNS;
61
+ generateUUID.URL = URL;
62
+ return generateUUID;
63
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _native = _interopRequireDefault(require("./native.js"));
8
+ var _rng = _interopRequireDefault(require("./rng.js"));
9
+ var _stringify = require("./stringify.js");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ function v4(options, buf, offset) {
12
+ if (_native.default.randomUUID && !buf && !options) {
13
+ return _native.default.randomUUID();
14
+ }
15
+ options = options || {};
16
+ var rnds = options.random || (options.rng || _rng.default)();
17
+
18
+ // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
19
+ rnds[6] = rnds[6] & 0x0f | 0x40;
20
+ rnds[8] = rnds[8] & 0x3f | 0x80;
21
+
22
+ // Copy bytes to buffer, if provided
23
+ if (buf) {
24
+ offset = offset || 0;
25
+ for (var i = 0; i < 16; ++i) {
26
+ buf[offset + i] = rnds[i];
27
+ }
28
+ return buf;
29
+ }
30
+ return (0, _stringify.unsafeStringify)(rnds);
31
+ }
32
+ var _default = exports.default = v4;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _v = _interopRequireDefault(require("./v35.js"));
8
+ var _sha = _interopRequireDefault(require("./sha1.js"));
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ var v5 = (0, _v.default)('v5', 0x50, _sha.default);
11
+ var _default = exports.default = v5;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = v6;
7
+ var _stringify = require("./stringify.js");
8
+ var _v = _interopRequireDefault(require("./v1.js"));
9
+ var _v1ToV = _interopRequireDefault(require("./v1ToV6.js"));
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
12
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
13
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
14
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
15
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
16
+ /**
17
+ *
18
+ * @param {object} options
19
+ * @param {Uint8Array=} buf
20
+ * @param {number=} offset
21
+ * @returns
22
+ */
23
+ function v6(options = {}, buf, offset = 0) {
24
+ // v6 is v1 with different field layout, so we start with a v1 UUID, albeit
25
+ // with slightly different behavior around how the clock_seq and node fields
26
+ // are randomized, which is why we call v1 with _v6: true.
27
+ var bytes = (0, _v.default)(_objectSpread(_objectSpread({}, options), {}, {
28
+ _v6: true
29
+ }), new Uint8Array(16));
30
+
31
+ // Reorder the fields to v6 layout.
32
+ bytes = (0, _v1ToV.default)(bytes);
33
+
34
+ // Return as a byte array if requested
35
+ if (buf) {
36
+ for (var i = 0; i < 16; i++) {
37
+ buf[offset + i] = bytes[i];
38
+ }
39
+ return buf;
40
+ }
41
+ return (0, _stringify.unsafeStringify)(bytes);
42
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = v6ToV1;
7
+ var _parse = _interopRequireDefault(require("./parse.js"));
8
+ var _stringify = require("./stringify.js");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ /**
11
+ * Convert a v6 UUID to a v1 UUID
12
+ *
13
+ * @param {string|Uint8Array} uuid - The v6 UUID to convert to v6
14
+ * @returns {string|Uint8Array} The v1 UUID as the same type as the `uuid` arg
15
+ * (string or Uint8Array)
16
+ */
17
+ function v6ToV1(uuid) {
18
+ var v6Bytes = typeof uuid === 'string' ? (0, _parse.default)(uuid) : uuid;
19
+ var v1Bytes = _v6ToV1(v6Bytes);
20
+ return typeof uuid === 'string' ? (0, _stringify.unsafeStringify)(v1Bytes) : v1Bytes;
21
+ }
22
+
23
+ // Do the field transformation needed for v6 -> v1
24
+ function _v6ToV1(v6Bytes) {
25
+ 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]);
26
+ }
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _rng = _interopRequireDefault(require("./rng.js"));
8
+ var _stringify = require("./stringify.js");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ /**
11
+ * UUID V7 - Unix Epoch time-based UUID
12
+ *
13
+ * The IETF has published RFC9562, introducing 3 new UUID versions (6,7,8). This
14
+ * implementation of V7 is based on the accepted, though not yet approved,
15
+ * revisions.
16
+ *
17
+ * RFC 9562:https://www.rfc-editor.org/rfc/rfc9562.html Universally Unique
18
+ * IDentifiers (UUIDs)
19
+
20
+ *
21
+ * Sample V7 value:
22
+ * https://www.rfc-editor.org/rfc/rfc9562.html#name-example-of-a-uuidv7-value
23
+ *
24
+ * Monotonic Bit Layout: RFC rfc9562.6.2 Method 1, Dedicated Counter Bits ref:
25
+ * https://www.rfc-editor.org/rfc/rfc9562.html#section-6.2-5.1
26
+ *
27
+ * 0 1 2 3 0 1 2 3 4 5 6
28
+ * 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
29
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
30
+ * | unix_ts_ms |
31
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
32
+ * | unix_ts_ms | ver | seq_hi |
33
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
34
+ * |var| seq_low | rand |
35
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36
+ * | rand |
37
+ * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38
+ *
39
+ * seq is a 31 bit serialized counter; comprised of 12 bit seq_hi and 19 bit
40
+ * seq_low, and randomly initialized upon timestamp change. 31 bit counter size
41
+ * was selected as any bitwise operations in node are done as _signed_ 32 bit
42
+ * ints. we exclude the sign bit.
43
+ */
44
+
45
+ var _seqLow = null;
46
+ var _seqHigh = null;
47
+ var _msecs = 0;
48
+ function v7(options, buf, offset) {
49
+ options = options || {};
50
+
51
+ // initialize buffer and pointer
52
+ var i = buf && offset || 0;
53
+ var b = buf || new Uint8Array(16);
54
+
55
+ // rnds is Uint8Array(16) filled with random bytes
56
+ var rnds = options.random || (options.rng || _rng.default)();
57
+
58
+ // milliseconds since unix epoch, 1970-01-01 00:00
59
+ var msecs = options.msecs !== undefined ? options.msecs : Date.now();
60
+
61
+ // seq is user provided 31 bit counter
62
+ var seq = options.seq !== undefined ? options.seq : null;
63
+
64
+ // initialize local seq high/low parts
65
+ var seqHigh = _seqHigh;
66
+ var seqLow = _seqLow;
67
+
68
+ // check if clock has advanced and user has not provided msecs
69
+ if (msecs > _msecs && options.msecs === undefined) {
70
+ _msecs = msecs;
71
+
72
+ // unless user provided seq, reset seq parts
73
+ if (seq !== null) {
74
+ seqHigh = null;
75
+ seqLow = null;
76
+ }
77
+ }
78
+
79
+ // if we have a user provided seq
80
+ if (seq !== null) {
81
+ // trim provided seq to 31 bits of value, avoiding overflow
82
+ if (seq > 0x7fffffff) {
83
+ seq = 0x7fffffff;
84
+ }
85
+
86
+ // split provided seq into high/low parts
87
+ seqHigh = seq >>> 19 & 0xfff;
88
+ seqLow = seq & 0x7ffff;
89
+ }
90
+
91
+ // randomly initialize seq
92
+ if (seqHigh === null || seqLow === null) {
93
+ seqHigh = rnds[6] & 0x7f;
94
+ seqHigh = seqHigh << 8 | rnds[7];
95
+ seqLow = rnds[8] & 0x3f; // pad for var
96
+ seqLow = seqLow << 8 | rnds[9];
97
+ seqLow = seqLow << 5 | rnds[10] >>> 3;
98
+ }
99
+
100
+ // increment seq if within msecs window
101
+ if (msecs + 10000 > _msecs && seq === null) {
102
+ if (++seqLow > 0x7ffff) {
103
+ seqLow = 0;
104
+ if (++seqHigh > 0xfff) {
105
+ seqHigh = 0;
106
+
107
+ // increment internal _msecs. this allows us to continue incrementing
108
+ // while staying monotonic. Note, once we hit 10k milliseconds beyond system
109
+ // clock, we will reset breaking monotonicity (after (2^31)*10000 generations)
110
+ _msecs++;
111
+ }
112
+ }
113
+ } else {
114
+ // resetting; we have advanced more than
115
+ // 10k milliseconds beyond system clock
116
+ _msecs = msecs;
117
+ }
118
+ _seqHigh = seqHigh;
119
+ _seqLow = seqLow;
120
+
121
+ // [bytes 0-5] 48 bits of local timestamp
122
+ b[i++] = _msecs / 0x10000000000 & 0xff;
123
+ b[i++] = _msecs / 0x100000000 & 0xff;
124
+ b[i++] = _msecs / 0x1000000 & 0xff;
125
+ b[i++] = _msecs / 0x10000 & 0xff;
126
+ b[i++] = _msecs / 0x100 & 0xff;
127
+ b[i++] = _msecs & 0xff;
128
+
129
+ // [byte 6] - set 4 bits of version (7) with first 4 bits seq_hi
130
+ b[i++] = seqHigh >>> 4 & 0x0f | 0x70;
131
+
132
+ // [byte 7] remaining 8 bits of seq_hi
133
+ b[i++] = seqHigh & 0xff;
134
+
135
+ // [byte 8] - variant (2 bits), first 6 bits seq_low
136
+ b[i++] = seqLow >>> 13 & 0x3f | 0x80;
137
+
138
+ // [byte 9] 8 bits seq_low
139
+ b[i++] = seqLow >>> 5 & 0xff;
140
+
141
+ // [byte 10] remaining 5 bits seq_low, 3 bits random
142
+ b[i++] = seqLow << 3 & 0xff | rnds[10] & 0x07;
143
+
144
+ // [bytes 11-15] always random
145
+ b[i++] = rnds[11];
146
+ b[i++] = rnds[12];
147
+ b[i++] = rnds[13];
148
+ b[i++] = rnds[14];
149
+ b[i++] = rnds[15];
150
+ return buf || (0, _stringify.unsafeStringify)(b);
151
+ }
152
+ var _default = exports.default = v7;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _regex = _interopRequireDefault(require("./regex.js"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ function validate(uuid) {
10
+ return typeof uuid === 'string' && _regex.default.test(uuid);
11
+ }
12
+ var _default = exports.default = validate;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _validate = _interopRequireDefault(require("./validate.js"));
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
9
+ function version(uuid) {
10
+ if (!(0, _validate.default)(uuid)) {
11
+ throw TypeError('Invalid UUID');
12
+ }
13
+ return parseInt(uuid.slice(14, 15), 16);
14
+ }
15
+ var _default = exports.default = version;
@@ -0,0 +1,14 @@
1
+ export { default as MAX } from './max.js';
2
+ export { default as NIL } from './nil.js';
3
+ export { default as parse } from './parse.js';
4
+ export { default as stringify } from './stringify.js';
5
+ export { default as v1 } from './v1.js';
6
+ export { default as v1ToV6 } from './v1ToV6.js';
7
+ export { default as v3 } from './v3.js';
8
+ export { default as v4 } from './v4.js';
9
+ export { default as v5 } from './v5.js';
10
+ export { default as v6 } from './v6.js';
11
+ export { default as v6ToV1 } from './v6ToV1.js';
12
+ export { default as v7 } from './v7.js';
13
+ export { default as validate } from './validate.js';
14
+ export { default as version } from './version.js';
@@ -0,0 +1 @@
1
+ export default 'ffffffff-ffff-ffff-ffff-ffffffffffff';