uuid 8.3.2 → 9.0.0
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/CHANGELOG.md +39 -0
- package/README.md +30 -73
- package/dist/commonjs-browser/index.js +79 -0
- package/dist/commonjs-browser/md5.js +223 -0
- package/dist/commonjs-browser/native.js +11 -0
- package/dist/commonjs-browser/nil.js +8 -0
- package/dist/commonjs-browser/parse.js +45 -0
- package/dist/commonjs-browser/regex.js +8 -0
- package/dist/commonjs-browser/rng.js +25 -0
- package/dist/commonjs-browser/sha1.js +104 -0
- package/dist/commonjs-browser/stringify.js +44 -0
- package/dist/commonjs-browser/v1.js +107 -0
- package/dist/commonjs-browser/v3.js +16 -0
- package/dist/commonjs-browser/v35.js +80 -0
- package/dist/commonjs-browser/v4.js +43 -0
- package/dist/commonjs-browser/v5.js +16 -0
- package/dist/commonjs-browser/validate.js +17 -0
- package/dist/commonjs-browser/version.js +21 -0
- package/dist/esm-browser/md5.js +23 -23
- package/dist/esm-browser/native.js +4 -0
- package/dist/esm-browser/parse.js +2 -2
- package/dist/esm-browser/rng.js +4 -5
- package/dist/esm-browser/sha1.js +26 -26
- package/dist/esm-browser/stringify.js +9 -6
- package/dist/esm-browser/v1.js +17 -17
- package/dist/esm-browser/v3.js +1 -1
- package/dist/esm-browser/v35.js +12 -10
- package/dist/esm-browser/v4.js +9 -4
- package/dist/esm-browser/v5.js +1 -1
- package/dist/esm-browser/version.js +1 -1
- package/dist/esm-node/native.js +4 -0
- package/dist/esm-node/stringify.js +7 -3
- package/dist/esm-node/v1.js +2 -2
- package/dist/esm-node/v35.js +6 -4
- package/dist/esm-node/v4.js +7 -2
- package/dist/esm-node/version.js +1 -1
- package/dist/index.js +18 -18
- package/dist/native-browser.js +11 -0
- package/dist/native.js +15 -0
- package/dist/rng-browser.js +2 -3
- package/dist/stringify.js +8 -3
- package/dist/v1.js +2 -2
- package/dist/v35.js +7 -5
- package/dist/v4.js +8 -2
- package/dist/version.js +1 -1
- package/package.json +37 -41
- package/dist/umd/uuid.min.js +0 -1
- package/dist/umd/uuidNIL.min.js +0 -1
- package/dist/umd/uuidParse.min.js +0 -1
- package/dist/umd/uuidStringify.min.js +0 -1
- package/dist/umd/uuidValidate.min.js +0 -1
- package/dist/umd/uuidVersion.min.js +0 -1
- package/dist/umd/uuidv1.min.js +0 -1
- package/dist/umd/uuidv3.min.js +0 -1
- package/dist/umd/uuidv4.min.js +0 -1
- package/dist/umd/uuidv5.min.js +0 -1
|
@@ -4,17 +4,20 @@ import validate from './validate.js';
|
|
|
4
4
|
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const byteToHex = [];
|
|
8
8
|
|
|
9
|
-
for (
|
|
10
|
-
byteToHex.push((i + 0x100).toString(16).
|
|
9
|
+
for (let i = 0; i < 256; ++i) {
|
|
10
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
function
|
|
14
|
-
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
13
|
+
export function unsafeStringify(arr, offset = 0) {
|
|
15
14
|
// Note: Be careful editing this code! It's been tuned for performance
|
|
16
15
|
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
17
|
-
|
|
16
|
+
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();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function stringify(arr, offset = 0) {
|
|
20
|
+
const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one
|
|
18
21
|
// of the following:
|
|
19
22
|
// - One or more input array values don't map to a hex octet (leading to
|
|
20
23
|
// "undefined" in the uuid)
|
package/dist/esm-browser/v1.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import rng from './rng.js';
|
|
2
|
-
import
|
|
2
|
+
import { unsafeStringify } from './stringify.js'; // **`v1()` - Generate time-based UUID**
|
|
3
3
|
//
|
|
4
4
|
// Inspired by https://github.com/LiosK/UUID.js
|
|
5
5
|
// and http://docs.python.org/library/uuid.html
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
let _nodeId;
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
let _clockseq; // Previous uuid creation time
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
let _lastMSecs = 0;
|
|
13
|
+
let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
|
|
14
14
|
|
|
15
15
|
function v1(options, buf, offset) {
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
let i = buf && offset || 0;
|
|
17
|
+
const b = buf || new Array(16);
|
|
18
18
|
options = options || {};
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
let node = options.node || _nodeId;
|
|
20
|
+
let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
|
|
21
21
|
// specified. We do this lazily to minimize issues related to insufficient
|
|
22
22
|
// system entropy. See #189
|
|
23
23
|
|
|
24
24
|
if (node == null || clockseq == null) {
|
|
25
|
-
|
|
25
|
+
const seedBytes = options.random || (options.rng || rng)();
|
|
26
26
|
|
|
27
27
|
if (node == null) {
|
|
28
28
|
// Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
|
|
@@ -39,12 +39,12 @@ function v1(options, buf, offset) {
|
|
|
39
39
|
// (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
|
|
40
40
|
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
|
|
43
43
|
// cycle to simulate higher resolution clock
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
|
|
46
46
|
|
|
47
|
-
|
|
47
|
+
const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
|
|
48
48
|
|
|
49
49
|
if (dt < 0 && options.clockseq === undefined) {
|
|
50
50
|
clockseq = clockseq + 1 & 0x3fff;
|
|
@@ -67,13 +67,13 @@ function v1(options, buf, offset) {
|
|
|
67
67
|
|
|
68
68
|
msecs += 12219292800000; // `time_low`
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
|
|
71
71
|
b[i++] = tl >>> 24 & 0xff;
|
|
72
72
|
b[i++] = tl >>> 16 & 0xff;
|
|
73
73
|
b[i++] = tl >>> 8 & 0xff;
|
|
74
74
|
b[i++] = tl & 0xff; // `time_mid`
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
const tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
|
|
77
77
|
b[i++] = tmh >>> 8 & 0xff;
|
|
78
78
|
b[i++] = tmh & 0xff; // `time_high_and_version`
|
|
79
79
|
|
|
@@ -85,11 +85,11 @@ function v1(options, buf, offset) {
|
|
|
85
85
|
|
|
86
86
|
b[i++] = clockseq & 0xff; // `node`
|
|
87
87
|
|
|
88
|
-
for (
|
|
88
|
+
for (let n = 0; n < 6; ++n) {
|
|
89
89
|
b[i + n] = node[n];
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
return buf ||
|
|
92
|
+
return buf || unsafeStringify(b);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
export default v1;
|
package/dist/esm-browser/v3.js
CHANGED
package/dist/esm-browser/v35.js
CHANGED
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { unsafeStringify } from './stringify.js';
|
|
2
2
|
import parse from './parse.js';
|
|
3
3
|
|
|
4
4
|
function stringToBytes(str) {
|
|
5
5
|
str = unescape(encodeURIComponent(str)); // UTF8 escape
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
const bytes = [];
|
|
8
8
|
|
|
9
|
-
for (
|
|
9
|
+
for (let i = 0; i < str.length; ++i) {
|
|
10
10
|
bytes.push(str.charCodeAt(i));
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
return bytes;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export
|
|
17
|
-
export
|
|
18
|
-
export default function (name, version, hashfunc) {
|
|
16
|
+
export const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
|
17
|
+
export const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
|
18
|
+
export default function v35(name, version, hashfunc) {
|
|
19
19
|
function generateUUID(value, namespace, buf, offset) {
|
|
20
|
+
var _namespace;
|
|
21
|
+
|
|
20
22
|
if (typeof value === 'string') {
|
|
21
23
|
value = stringToBytes(value);
|
|
22
24
|
}
|
|
@@ -25,14 +27,14 @@ export default function (name, version, hashfunc) {
|
|
|
25
27
|
namespace = parse(namespace);
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
if (namespace.length !== 16) {
|
|
30
|
+
if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
|
|
29
31
|
throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
|
|
30
32
|
} // Compute hash of namespace and value, Per 4.3
|
|
31
33
|
// Future: Use spread syntax when supported on all platforms, e.g. `bytes =
|
|
32
34
|
// hashfunc([...namespace, ... value])`
|
|
33
35
|
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
let bytes = new Uint8Array(16 + value.length);
|
|
36
38
|
bytes.set(namespace);
|
|
37
39
|
bytes.set(value, namespace.length);
|
|
38
40
|
bytes = hashfunc(bytes);
|
|
@@ -42,14 +44,14 @@ export default function (name, version, hashfunc) {
|
|
|
42
44
|
if (buf) {
|
|
43
45
|
offset = offset || 0;
|
|
44
46
|
|
|
45
|
-
for (
|
|
47
|
+
for (let i = 0; i < 16; ++i) {
|
|
46
48
|
buf[offset + i] = bytes[i];
|
|
47
49
|
}
|
|
48
50
|
|
|
49
51
|
return buf;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
return
|
|
54
|
+
return unsafeStringify(bytes);
|
|
53
55
|
} // Function#name is not settable on some platforms (#270)
|
|
54
56
|
|
|
55
57
|
|
package/dist/esm-browser/v4.js
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
import native from './native.js';
|
|
1
2
|
import rng from './rng.js';
|
|
2
|
-
import
|
|
3
|
+
import { unsafeStringify } from './stringify.js';
|
|
3
4
|
|
|
4
5
|
function v4(options, buf, offset) {
|
|
6
|
+
if (native.randomUUID && !buf && !options) {
|
|
7
|
+
return native.randomUUID();
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
options = options || {};
|
|
6
|
-
|
|
11
|
+
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
7
12
|
|
|
8
13
|
rnds[6] = rnds[6] & 0x0f | 0x40;
|
|
9
14
|
rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
|
|
@@ -11,14 +16,14 @@ function v4(options, buf, offset) {
|
|
|
11
16
|
if (buf) {
|
|
12
17
|
offset = offset || 0;
|
|
13
18
|
|
|
14
|
-
for (
|
|
19
|
+
for (let i = 0; i < 16; ++i) {
|
|
15
20
|
buf[offset + i] = rnds[i];
|
|
16
21
|
}
|
|
17
22
|
|
|
18
23
|
return buf;
|
|
19
24
|
}
|
|
20
25
|
|
|
21
|
-
return
|
|
26
|
+
return unsafeStringify(rnds);
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
export default v4;
|
package/dist/esm-browser/v5.js
CHANGED
|
@@ -7,13 +7,17 @@ import validate from './validate.js';
|
|
|
7
7
|
const byteToHex = [];
|
|
8
8
|
|
|
9
9
|
for (let i = 0; i < 256; ++i) {
|
|
10
|
-
byteToHex.push((i + 0x100).toString(16).
|
|
10
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
function
|
|
13
|
+
export function unsafeStringify(arr, offset = 0) {
|
|
14
14
|
// Note: Be careful editing this code! It's been tuned for performance
|
|
15
15
|
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
16
|
-
|
|
16
|
+
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();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function stringify(arr, offset = 0) {
|
|
20
|
+
const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one
|
|
17
21
|
// of the following:
|
|
18
22
|
// - One or more input array values don't map to a hex octet (leading to
|
|
19
23
|
// "undefined" in the uuid)
|
package/dist/esm-node/v1.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import rng from './rng.js';
|
|
2
|
-
import
|
|
2
|
+
import { unsafeStringify } from './stringify.js'; // **`v1()` - Generate time-based UUID**
|
|
3
3
|
//
|
|
4
4
|
// Inspired by https://github.com/LiosK/UUID.js
|
|
5
5
|
// and http://docs.python.org/library/uuid.html
|
|
@@ -89,7 +89,7 @@ function v1(options, buf, offset) {
|
|
|
89
89
|
b[i + n] = node[n];
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
return buf ||
|
|
92
|
+
return buf || unsafeStringify(b);
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
export default v1;
|
package/dist/esm-node/v35.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { unsafeStringify } from './stringify.js';
|
|
2
2
|
import parse from './parse.js';
|
|
3
3
|
|
|
4
4
|
function stringToBytes(str) {
|
|
@@ -15,8 +15,10 @@ function stringToBytes(str) {
|
|
|
15
15
|
|
|
16
16
|
export const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
|
|
17
17
|
export const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
|
18
|
-
export default function (name, version, hashfunc) {
|
|
18
|
+
export default function v35(name, version, hashfunc) {
|
|
19
19
|
function generateUUID(value, namespace, buf, offset) {
|
|
20
|
+
var _namespace;
|
|
21
|
+
|
|
20
22
|
if (typeof value === 'string') {
|
|
21
23
|
value = stringToBytes(value);
|
|
22
24
|
}
|
|
@@ -25,7 +27,7 @@ export default function (name, version, hashfunc) {
|
|
|
25
27
|
namespace = parse(namespace);
|
|
26
28
|
}
|
|
27
29
|
|
|
28
|
-
if (namespace.length !== 16) {
|
|
30
|
+
if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
|
|
29
31
|
throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
|
|
30
32
|
} // Compute hash of namespace and value, Per 4.3
|
|
31
33
|
// Future: Use spread syntax when supported on all platforms, e.g. `bytes =
|
|
@@ -49,7 +51,7 @@ export default function (name, version, hashfunc) {
|
|
|
49
51
|
return buf;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
|
-
return
|
|
54
|
+
return unsafeStringify(bytes);
|
|
53
55
|
} // Function#name is not settable on some platforms (#270)
|
|
54
56
|
|
|
55
57
|
|
package/dist/esm-node/v4.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import native from './native.js';
|
|
1
2
|
import rng from './rng.js';
|
|
2
|
-
import
|
|
3
|
+
import { unsafeStringify } from './stringify.js';
|
|
3
4
|
|
|
4
5
|
function v4(options, buf, offset) {
|
|
6
|
+
if (native.randomUUID && !buf && !options) {
|
|
7
|
+
return native.randomUUID();
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
options = options || {};
|
|
6
11
|
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
7
12
|
|
|
@@ -18,7 +23,7 @@ function v4(options, buf, offset) {
|
|
|
18
23
|
return buf;
|
|
19
24
|
}
|
|
20
25
|
|
|
21
|
-
return
|
|
26
|
+
return unsafeStringify(rnds);
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
export default v4;
|
package/dist/esm-node/version.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -3,58 +3,58 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
Object.defineProperty(exports, "
|
|
6
|
+
Object.defineProperty(exports, "NIL", {
|
|
7
7
|
enumerable: true,
|
|
8
8
|
get: function () {
|
|
9
|
-
return
|
|
9
|
+
return _nil.default;
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
|
-
Object.defineProperty(exports, "
|
|
12
|
+
Object.defineProperty(exports, "parse", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function () {
|
|
15
|
-
return
|
|
15
|
+
return _parse.default;
|
|
16
16
|
}
|
|
17
17
|
});
|
|
18
|
-
Object.defineProperty(exports, "
|
|
18
|
+
Object.defineProperty(exports, "stringify", {
|
|
19
19
|
enumerable: true,
|
|
20
20
|
get: function () {
|
|
21
|
-
return
|
|
21
|
+
return _stringify.default;
|
|
22
22
|
}
|
|
23
23
|
});
|
|
24
|
-
Object.defineProperty(exports, "
|
|
24
|
+
Object.defineProperty(exports, "v1", {
|
|
25
25
|
enumerable: true,
|
|
26
26
|
get: function () {
|
|
27
|
-
return
|
|
27
|
+
return _v.default;
|
|
28
28
|
}
|
|
29
29
|
});
|
|
30
|
-
Object.defineProperty(exports, "
|
|
30
|
+
Object.defineProperty(exports, "v3", {
|
|
31
31
|
enumerable: true,
|
|
32
32
|
get: function () {
|
|
33
|
-
return
|
|
33
|
+
return _v2.default;
|
|
34
34
|
}
|
|
35
35
|
});
|
|
36
|
-
Object.defineProperty(exports, "
|
|
36
|
+
Object.defineProperty(exports, "v4", {
|
|
37
37
|
enumerable: true,
|
|
38
38
|
get: function () {
|
|
39
|
-
return
|
|
39
|
+
return _v3.default;
|
|
40
40
|
}
|
|
41
41
|
});
|
|
42
|
-
Object.defineProperty(exports, "
|
|
42
|
+
Object.defineProperty(exports, "v5", {
|
|
43
43
|
enumerable: true,
|
|
44
44
|
get: function () {
|
|
45
|
-
return
|
|
45
|
+
return _v4.default;
|
|
46
46
|
}
|
|
47
47
|
});
|
|
48
|
-
Object.defineProperty(exports, "
|
|
48
|
+
Object.defineProperty(exports, "validate", {
|
|
49
49
|
enumerable: true,
|
|
50
50
|
get: function () {
|
|
51
|
-
return
|
|
51
|
+
return _validate.default;
|
|
52
52
|
}
|
|
53
53
|
});
|
|
54
|
-
Object.defineProperty(exports, "
|
|
54
|
+
Object.defineProperty(exports, "version", {
|
|
55
55
|
enumerable: true,
|
|
56
56
|
get: function () {
|
|
57
|
-
return
|
|
57
|
+
return _version.default;
|
|
58
58
|
}
|
|
59
59
|
});
|
|
60
60
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
8
|
+
var _default = {
|
|
9
|
+
randomUUID
|
|
10
|
+
};
|
|
11
|
+
exports.default = _default;
|
package/dist/native.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _crypto = _interopRequireDefault(require("crypto"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
+
|
|
12
|
+
var _default = {
|
|
13
|
+
randomUUID: _crypto.default.randomUUID
|
|
14
|
+
};
|
|
15
|
+
exports.default = _default;
|
package/dist/rng-browser.js
CHANGED
|
@@ -13,9 +13,8 @@ const rnds8 = new Uint8Array(16);
|
|
|
13
13
|
function rng() {
|
|
14
14
|
// lazy load so that environments that need to polyfill have a chance to do so
|
|
15
15
|
if (!getRandomValues) {
|
|
16
|
-
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
17
|
-
|
|
18
|
-
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
|
|
16
|
+
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
|
|
17
|
+
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
|
|
19
18
|
|
|
20
19
|
if (!getRandomValues) {
|
|
21
20
|
throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
|
package/dist/stringify.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
|
+
exports.unsafeStringify = unsafeStringify;
|
|
7
8
|
|
|
8
9
|
var _validate = _interopRequireDefault(require("./validate.js"));
|
|
9
10
|
|
|
@@ -16,13 +17,17 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
16
17
|
const byteToHex = [];
|
|
17
18
|
|
|
18
19
|
for (let i = 0; i < 256; ++i) {
|
|
19
|
-
byteToHex.push((i + 0x100).toString(16).
|
|
20
|
+
byteToHex.push((i + 0x100).toString(16).slice(1));
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
function
|
|
23
|
+
function unsafeStringify(arr, offset = 0) {
|
|
23
24
|
// Note: Be careful editing this code! It's been tuned for performance
|
|
24
25
|
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
|
|
25
|
-
|
|
26
|
+
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();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function stringify(arr, offset = 0) {
|
|
30
|
+
const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one
|
|
26
31
|
// of the following:
|
|
27
32
|
// - One or more input array values don't map to a hex octet (leading to
|
|
28
33
|
// "undefined" in the uuid)
|
package/dist/v1.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _rng = _interopRequireDefault(require("./rng.js"));
|
|
9
9
|
|
|
10
|
-
var _stringify =
|
|
10
|
+
var _stringify = require("./stringify.js");
|
|
11
11
|
|
|
12
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
13
|
|
|
@@ -100,7 +100,7 @@ function v1(options, buf, offset) {
|
|
|
100
100
|
b[i + n] = node[n];
|
|
101
101
|
}
|
|
102
102
|
|
|
103
|
-
return buf || (0, _stringify.
|
|
103
|
+
return buf || (0, _stringify.unsafeStringify)(b);
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
var _default = v1;
|
package/dist/v35.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.default = _default;
|
|
7
6
|
exports.URL = exports.DNS = void 0;
|
|
7
|
+
exports.default = v35;
|
|
8
8
|
|
|
9
|
-
var _stringify =
|
|
9
|
+
var _stringify = require("./stringify.js");
|
|
10
10
|
|
|
11
11
|
var _parse = _interopRequireDefault(require("./parse.js"));
|
|
12
12
|
|
|
@@ -29,8 +29,10 @@ exports.DNS = DNS;
|
|
|
29
29
|
const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
|
|
30
30
|
exports.URL = URL;
|
|
31
31
|
|
|
32
|
-
function
|
|
32
|
+
function v35(name, version, hashfunc) {
|
|
33
33
|
function generateUUID(value, namespace, buf, offset) {
|
|
34
|
+
var _namespace;
|
|
35
|
+
|
|
34
36
|
if (typeof value === 'string') {
|
|
35
37
|
value = stringToBytes(value);
|
|
36
38
|
}
|
|
@@ -39,7 +41,7 @@ function _default(name, version, hashfunc) {
|
|
|
39
41
|
namespace = (0, _parse.default)(namespace);
|
|
40
42
|
}
|
|
41
43
|
|
|
42
|
-
if (namespace.length !== 16) {
|
|
44
|
+
if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
|
|
43
45
|
throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');
|
|
44
46
|
} // Compute hash of namespace and value, Per 4.3
|
|
45
47
|
// Future: Use spread syntax when supported on all platforms, e.g. `bytes =
|
|
@@ -63,7 +65,7 @@ function _default(name, version, hashfunc) {
|
|
|
63
65
|
return buf;
|
|
64
66
|
}
|
|
65
67
|
|
|
66
|
-
return (0, _stringify.
|
|
68
|
+
return (0, _stringify.unsafeStringify)(bytes);
|
|
67
69
|
} // Function#name is not settable on some platforms (#270)
|
|
68
70
|
|
|
69
71
|
|
package/dist/v4.js
CHANGED
|
@@ -5,13 +5,19 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
|
|
8
|
+
var _native = _interopRequireDefault(require("./native.js"));
|
|
9
|
+
|
|
8
10
|
var _rng = _interopRequireDefault(require("./rng.js"));
|
|
9
11
|
|
|
10
|
-
var _stringify =
|
|
12
|
+
var _stringify = require("./stringify.js");
|
|
11
13
|
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
15
|
|
|
14
16
|
function v4(options, buf, offset) {
|
|
17
|
+
if (_native.default.randomUUID && !buf && !options) {
|
|
18
|
+
return _native.default.randomUUID();
|
|
19
|
+
}
|
|
20
|
+
|
|
15
21
|
options = options || {};
|
|
16
22
|
|
|
17
23
|
const rnds = options.random || (options.rng || _rng.default)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
|
|
@@ -30,7 +36,7 @@ function v4(options, buf, offset) {
|
|
|
30
36
|
return buf;
|
|
31
37
|
}
|
|
32
38
|
|
|
33
|
-
return (0, _stringify.
|
|
39
|
+
return (0, _stringify.unsafeStringify)(rnds);
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
var _default = v4;
|