uuid 7.0.0 → 7.0.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [7.0.1](https://github.com/uuidjs/uuid/compare/v7.0.0...v7.0.1) (2020-02-25)
6
+
7
+ ### Bug Fixes
8
+
9
+ - clean up esm builds for node and browser ([#383](https://github.com/uuidjs/uuid/issues/383)) ([59e6a49](https://github.com/uuidjs/uuid/commit/59e6a49e7ce7b3e8fb0f3ee52b9daae72af467dc))
10
+ - provide browser versions independent from module system ([#380](https://github.com/uuidjs/uuid/issues/380)) ([4344a22](https://github.com/uuidjs/uuid/commit/4344a22e7aed33be8627eeaaf05360f256a21753)), closes [#378](https://github.com/uuidjs/uuid/issues/378)
11
+
5
12
  ## [7.0.0](https://github.com/uuidjs/uuid/compare/v3.4.0...v7.0.0) (2020-02-24)
6
13
 
7
14
  ### ⚠ BREAKING CHANGES
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Convert array of 16 byte values to UUID string format of the form:
3
+ * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
4
+ */
5
+ var byteToHex = [];
6
+
7
+ for (var i = 0; i < 256; ++i) {
8
+ byteToHex[i] = (i + 0x100).toString(16).substr(1);
9
+ }
10
+
11
+ function bytesToUuid(buf, offset) {
12
+ var i = offset || 0;
13
+ var bth = byteToHex; // join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
14
+
15
+ return [bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], '-', bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]], bth[buf[i++]]].join('');
16
+ }
17
+
18
+ export default bytesToUuid;
@@ -0,0 +1,4 @@
1
+ export { default as v1 } from './v1.js';
2
+ export { default as v3 } from './v3.js';
3
+ export { default as v4 } from './v4.js';
4
+ export { default as v5 } from './v5.js';
@@ -0,0 +1,13 @@
1
+ import crypto from 'crypto';
2
+
3
+ function md5(bytes) {
4
+ if (Array.isArray(bytes)) {
5
+ bytes = Buffer.from(bytes);
6
+ } else if (typeof bytes === 'string') {
7
+ bytes = Buffer.from(bytes, 'utf8');
8
+ }
9
+
10
+ return crypto.createHash('md5').update(bytes).digest();
11
+ }
12
+
13
+ export default md5;
@@ -0,0 +1,4 @@
1
+ import crypto from 'crypto';
2
+ export default function rng() {
3
+ return crypto.randomBytes(16);
4
+ }
@@ -0,0 +1,13 @@
1
+ import crypto from 'crypto';
2
+
3
+ function sha1(bytes) {
4
+ if (Array.isArray(bytes)) {
5
+ bytes = Buffer.from(bytes);
6
+ } else if (typeof bytes === 'string') {
7
+ bytes = Buffer.from(bytes, 'utf8');
8
+ }
9
+
10
+ return crypto.createHash('sha1').update(bytes).digest();
11
+ }
12
+
13
+ export default sha1;
@@ -0,0 +1,95 @@
1
+ import rng from './rng.js';
2
+ import bytesToUuid from './bytesToUuid.js'; // **`v1()` - Generate time-based UUID**
3
+ //
4
+ // Inspired by https://github.com/LiosK/UUID.js
5
+ // and http://docs.python.org/library/uuid.html
6
+
7
+ var _nodeId;
8
+
9
+ var _clockseq; // Previous uuid creation time
10
+
11
+
12
+ var _lastMSecs = 0;
13
+ var _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
14
+
15
+ function v1(options, buf, offset) {
16
+ var i = buf && offset || 0;
17
+ var b = buf || [];
18
+ options = options || {};
19
+ var node = options.node || _nodeId;
20
+ var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
21
+ // specified. We do this lazily to minimize issues related to insufficient
22
+ // system entropy. See #189
23
+
24
+ if (node == null || clockseq == null) {
25
+ var seedBytes = options.random || (options.rng || rng)();
26
+
27
+ if (node == null) {
28
+ // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
29
+ node = _nodeId = [seedBytes[0] | 0x01, seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]];
30
+ }
31
+
32
+ if (clockseq == null) {
33
+ // Per 4.2.2, randomize (14 bit) clockseq
34
+ clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
35
+ }
36
+ } // UUID timestamps are 100 nano-second units since the Gregorian epoch,
37
+ // (1582-10-15 00:00). JSNumbers aren't precise enough for this, so
38
+ // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
39
+ // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
40
+
41
+
42
+ var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime(); // Per 4.2.1.2, use count of uuid's generated during the current clock
43
+ // cycle to simulate higher resolution clock
44
+
45
+ var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
46
+
47
+ var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
48
+
49
+ if (dt < 0 && options.clockseq === undefined) {
50
+ clockseq = clockseq + 1 & 0x3fff;
51
+ } // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
52
+ // time interval
53
+
54
+
55
+ if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
56
+ nsecs = 0;
57
+ } // Per 4.2.1.2 Throw error if too many uuids are requested
58
+
59
+
60
+ if (nsecs >= 10000) {
61
+ throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");
62
+ }
63
+
64
+ _lastMSecs = msecs;
65
+ _lastNSecs = nsecs;
66
+ _clockseq = clockseq; // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
67
+
68
+ msecs += 12219292800000; // `time_low`
69
+
70
+ var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
71
+ b[i++] = tl >>> 24 & 0xff;
72
+ b[i++] = tl >>> 16 & 0xff;
73
+ b[i++] = tl >>> 8 & 0xff;
74
+ b[i++] = tl & 0xff; // `time_mid`
75
+
76
+ var tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
77
+ b[i++] = tmh >>> 8 & 0xff;
78
+ b[i++] = tmh & 0xff; // `time_high_and_version`
79
+
80
+ b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
81
+
82
+ b[i++] = tmh >>> 16 & 0xff; // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
83
+
84
+ b[i++] = clockseq >>> 8 | 0x80; // `clock_seq_low`
85
+
86
+ b[i++] = clockseq & 0xff; // `node`
87
+
88
+ for (var n = 0; n < 6; ++n) {
89
+ b[i + n] = node[n];
90
+ }
91
+
92
+ return buf ? buf : bytesToUuid(b);
93
+ }
94
+
95
+ export default v1;
@@ -0,0 +1,4 @@
1
+ import v35 from './v35.js';
2
+ import md5 from './md5.js';
3
+ const v3 = v35('v3', 0x30, md5);
4
+ export default v3;
@@ -0,0 +1,56 @@
1
+ import bytesToUuid from './bytesToUuid.js';
2
+
3
+ function uuidToBytes(uuid) {
4
+ // Note: We assume we're being passed a valid uuid string
5
+ var bytes = [];
6
+ uuid.replace(/[a-fA-F0-9]{2}/g, function (hex) {
7
+ bytes.push(parseInt(hex, 16));
8
+ });
9
+ return bytes;
10
+ }
11
+
12
+ function stringToBytes(str) {
13
+ str = unescape(encodeURIComponent(str)); // UTF8 escape
14
+
15
+ var bytes = new Array(str.length);
16
+
17
+ for (var i = 0; i < str.length; i++) {
18
+ bytes[i] = str.charCodeAt(i);
19
+ }
20
+
21
+ return bytes;
22
+ }
23
+
24
+ export const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
25
+ export const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
26
+ export default function (name, version, hashfunc) {
27
+ var generateUUID = function (value, namespace, buf, offset) {
28
+ var off = buf && offset || 0;
29
+ if (typeof value == 'string') value = stringToBytes(value);
30
+ if (typeof namespace == 'string') namespace = uuidToBytes(namespace);
31
+ if (!Array.isArray(value)) throw TypeError('value must be an array of bytes');
32
+ if (!Array.isArray(namespace) || namespace.length !== 16) throw TypeError('namespace must be uuid string or an Array of 16 byte values'); // Per 4.3
33
+
34
+ var bytes = hashfunc(namespace.concat(value));
35
+ bytes[6] = bytes[6] & 0x0f | version;
36
+ bytes[8] = bytes[8] & 0x3f | 0x80;
37
+
38
+ if (buf) {
39
+ for (var idx = 0; idx < 16; ++idx) {
40
+ buf[off + idx] = bytes[idx];
41
+ }
42
+ }
43
+
44
+ return buf || bytesToUuid(bytes);
45
+ }; // Function#name is not settable on some platforms (#270)
46
+
47
+
48
+ try {
49
+ generateUUID.name = name;
50
+ } catch (err) {} // For CommonJS default export support
51
+
52
+
53
+ generateUUID.DNS = DNS;
54
+ generateUUID.URL = URL;
55
+ return generateUUID;
56
+ }
@@ -0,0 +1,27 @@
1
+ import rng from './rng.js';
2
+ import bytesToUuid from './bytesToUuid.js';
3
+
4
+ function v4(options, buf, offset) {
5
+ var i = buf && offset || 0;
6
+
7
+ if (typeof options == 'string') {
8
+ buf = options === 'binary' ? new Array(16) : null;
9
+ options = null;
10
+ }
11
+
12
+ options = options || {};
13
+ var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
14
+
15
+ rnds[6] = rnds[6] & 0x0f | 0x40;
16
+ rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
17
+
18
+ if (buf) {
19
+ for (var ii = 0; ii < 16; ++ii) {
20
+ buf[i + ii] = rnds[ii];
21
+ }
22
+ }
23
+
24
+ return buf || bytesToUuid(rnds);
25
+ }
26
+
27
+ export default v4;
@@ -0,0 +1,4 @@
1
+ import v35 from './v35.js';
2
+ import sha1 from './sha1.js';
3
+ const v5 = v35('v5', 0x50, sha1);
4
+ export default v5;
@@ -0,0 +1,225 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ /*
9
+ * Browser-compatible JavaScript MD5
10
+ *
11
+ * Modification of JavaScript MD5
12
+ * https://github.com/blueimp/JavaScript-MD5
13
+ *
14
+ * Copyright 2011, Sebastian Tschan
15
+ * https://blueimp.net
16
+ *
17
+ * Licensed under the MIT license:
18
+ * https://opensource.org/licenses/MIT
19
+ *
20
+ * Based on
21
+ * A JavaScript implementation of the RSA Data Security, Inc. MD5 Message
22
+ * Digest Algorithm, as defined in RFC 1321.
23
+ * Version 2.2 Copyright (C) Paul Johnston 1999 - 2009
24
+ * Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
25
+ * Distributed under the BSD License
26
+ * See http://pajhome.org.uk/crypt/md5 for more info.
27
+ */
28
+ function md5(bytes) {
29
+ if (typeof bytes == 'string') {
30
+ var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
31
+
32
+ bytes = new Array(msg.length);
33
+
34
+ for (var i = 0; i < msg.length; i++) bytes[i] = msg.charCodeAt(i);
35
+ }
36
+
37
+ return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
38
+ }
39
+ /*
40
+ * Convert an array of little-endian words to an array of bytes
41
+ */
42
+
43
+
44
+ function md5ToHexEncodedArray(input) {
45
+ var i;
46
+ var x;
47
+ var output = [];
48
+ var length32 = input.length * 32;
49
+ var hexTab = '0123456789abcdef';
50
+ var hex;
51
+
52
+ for (i = 0; i < length32; i += 8) {
53
+ x = input[i >> 5] >>> i % 32 & 0xff;
54
+ hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
55
+ output.push(hex);
56
+ }
57
+
58
+ return output;
59
+ }
60
+ /*
61
+ * Calculate the MD5 of an array of little-endian words, and a bit length.
62
+ */
63
+
64
+
65
+ function wordsToMd5(x, len) {
66
+ /* append padding */
67
+ x[len >> 5] |= 0x80 << len % 32;
68
+ x[(len + 64 >>> 9 << 4) + 14] = len;
69
+ var i;
70
+ var olda;
71
+ var oldb;
72
+ var oldc;
73
+ var oldd;
74
+ var a = 1732584193;
75
+ var b = -271733879;
76
+ var c = -1732584194;
77
+ var d = 271733878;
78
+
79
+ for (i = 0; i < x.length; i += 16) {
80
+ olda = a;
81
+ oldb = b;
82
+ oldc = c;
83
+ oldd = d;
84
+ a = md5ff(a, b, c, d, x[i], 7, -680876936);
85
+ d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
86
+ c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
87
+ b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
88
+ a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
89
+ d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
90
+ c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
91
+ b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
92
+ a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
93
+ d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
94
+ c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
95
+ b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
96
+ a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
97
+ d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
98
+ c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
99
+ b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
100
+ a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
101
+ d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
102
+ c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
103
+ b = md5gg(b, c, d, a, x[i], 20, -373897302);
104
+ a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
105
+ d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
106
+ c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
107
+ b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
108
+ a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
109
+ d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
110
+ c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
111
+ b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
112
+ a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
113
+ d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
114
+ c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
115
+ b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
116
+ a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
117
+ d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
118
+ c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
119
+ b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
120
+ a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
121
+ d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
122
+ c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
123
+ b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
124
+ a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
125
+ d = md5hh(d, a, b, c, x[i], 11, -358537222);
126
+ c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
127
+ b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
128
+ a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
129
+ d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
130
+ c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
131
+ b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
132
+ a = md5ii(a, b, c, d, x[i], 6, -198630844);
133
+ d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
134
+ c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
135
+ b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
136
+ a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
137
+ d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
138
+ c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
139
+ b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
140
+ a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
141
+ d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
142
+ c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
143
+ b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
144
+ a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
145
+ d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
146
+ c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
147
+ b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
148
+ a = safeAdd(a, olda);
149
+ b = safeAdd(b, oldb);
150
+ c = safeAdd(c, oldc);
151
+ d = safeAdd(d, oldd);
152
+ }
153
+
154
+ return [a, b, c, d];
155
+ }
156
+ /*
157
+ * Convert an array bytes to an array of little-endian words
158
+ * Characters >255 have their high-byte silently ignored.
159
+ */
160
+
161
+
162
+ function bytesToWords(input) {
163
+ var i;
164
+ var output = [];
165
+ output[(input.length >> 2) - 1] = undefined;
166
+
167
+ for (i = 0; i < output.length; i += 1) {
168
+ output[i] = 0;
169
+ }
170
+
171
+ var length8 = input.length * 8;
172
+
173
+ for (i = 0; i < length8; i += 8) {
174
+ output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
175
+ }
176
+
177
+ return output;
178
+ }
179
+ /*
180
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
181
+ * to work around bugs in some JS interpreters.
182
+ */
183
+
184
+
185
+ function safeAdd(x, y) {
186
+ var lsw = (x & 0xffff) + (y & 0xffff);
187
+ var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
188
+ return msw << 16 | lsw & 0xffff;
189
+ }
190
+ /*
191
+ * Bitwise rotate a 32-bit number to the left.
192
+ */
193
+
194
+
195
+ function bitRotateLeft(num, cnt) {
196
+ return num << cnt | num >>> 32 - cnt;
197
+ }
198
+ /*
199
+ * These functions implement the four basic operations the algorithm uses.
200
+ */
201
+
202
+
203
+ function md5cmn(q, a, b, x, s, t) {
204
+ return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
205
+ }
206
+
207
+ function md5ff(a, b, c, d, x, s, t) {
208
+ return md5cmn(b & c | ~b & d, a, b, x, s, t);
209
+ }
210
+
211
+ function md5gg(a, b, c, d, x, s, t) {
212
+ return md5cmn(b & d | c & ~d, a, b, x, s, t);
213
+ }
214
+
215
+ function md5hh(a, b, c, d, x, s, t) {
216
+ return md5cmn(b ^ c ^ d, a, b, x, s, t);
217
+ }
218
+
219
+ function md5ii(a, b, c, d, x, s, t) {
220
+ return md5cmn(c ^ (b | ~d), a, b, x, s, t);
221
+ }
222
+
223
+ var _default = md5;
224
+ exports.default = _default;
225
+ module.exports = exports.default;
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = rng;
7
+ // Unique ID creation requires a high quality random # generator. In the browser we therefore
8
+ // require the crypto API and do not support built-in fallback to lower quality random number
9
+ // generators (like Math.random()).
10
+ // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
11
+ // find the complete implementation of crypto (msCrypto) on IE11.
12
+ var getRandomValues = typeof crypto != 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto != 'undefined' && typeof window.msCrypto.getRandomValues == 'function' && msCrypto.getRandomValues.bind(msCrypto);
13
+ var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef
14
+
15
+ function rng() {
16
+ if (!getRandomValues) {
17
+ throw new Error('uuid: This browser does not seem to support crypto.getRandomValues(). If you need to support this browser, please provide a custom random number generator through options.rng.');
18
+ }
19
+
20
+ return getRandomValues(rnds8);
21
+ }
22
+
23
+ module.exports = exports.default;
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ // Adapted from Chris Veness' SHA1 code at
9
+ // http://www.movable-type.co.uk/scripts/sha1.html
10
+ function f(s, x, y, z) {
11
+ switch (s) {
12
+ case 0:
13
+ return x & y ^ ~x & z;
14
+
15
+ case 1:
16
+ return x ^ y ^ z;
17
+
18
+ case 2:
19
+ return x & y ^ x & z ^ y & z;
20
+
21
+ case 3:
22
+ return x ^ y ^ z;
23
+ }
24
+ }
25
+
26
+ function ROTL(x, n) {
27
+ return x << n | x >>> 32 - n;
28
+ }
29
+
30
+ function sha1(bytes) {
31
+ var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
32
+ var H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
33
+
34
+ if (typeof bytes == 'string') {
35
+ var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
36
+
37
+ bytes = new Array(msg.length);
38
+
39
+ for (var i = 0; i < msg.length; i++) bytes[i] = msg.charCodeAt(i);
40
+ }
41
+
42
+ bytes.push(0x80);
43
+ var l = bytes.length / 4 + 2;
44
+ var N = Math.ceil(l / 16);
45
+ var M = new Array(N);
46
+
47
+ for (var i = 0; i < N; i++) {
48
+ M[i] = new Array(16);
49
+
50
+ for (var j = 0; j < 16; j++) {
51
+ M[i][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];
52
+ }
53
+ }
54
+
55
+ M[N - 1][14] = (bytes.length - 1) * 8 / Math.pow(2, 32);
56
+ M[N - 1][14] = Math.floor(M[N - 1][14]);
57
+ M[N - 1][15] = (bytes.length - 1) * 8 & 0xffffffff;
58
+
59
+ for (var i = 0; i < N; i++) {
60
+ var W = new Array(80);
61
+
62
+ for (var t = 0; t < 16; t++) W[t] = M[i][t];
63
+
64
+ for (var t = 16; t < 80; t++) {
65
+ W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
66
+ }
67
+
68
+ var a = H[0];
69
+ var b = H[1];
70
+ var c = H[2];
71
+ var d = H[3];
72
+ var e = H[4];
73
+
74
+ for (var t = 0; t < 80; t++) {
75
+ var s = Math.floor(t / 20);
76
+ var T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
77
+ e = d;
78
+ d = c;
79
+ c = ROTL(b, 30) >>> 0;
80
+ b = a;
81
+ a = T;
82
+ }
83
+
84
+ H[0] = H[0] + a >>> 0;
85
+ H[1] = H[1] + b >>> 0;
86
+ H[2] = H[2] + c >>> 0;
87
+ H[3] = H[3] + d >>> 0;
88
+ H[4] = H[4] + e >>> 0;
89
+ }
90
+
91
+ 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];
92
+ }
93
+
94
+ var _default = sha1;
95
+ exports.default = _default;
96
+ module.exports = exports.default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uuid",
3
- "version": "7.0.0",
3
+ "version": "7.0.1",
4
4
  "description": "RFC4122 (v1, v4, and v5) UUIDs",
5
5
  "commitlint": {
6
6
  "extends": [
@@ -18,7 +18,13 @@
18
18
  },
19
19
  "sideEffects": false,
20
20
  "main": "dist/index.js",
21
- "module": "dist/esm-browser/index.js",
21
+ "module": "dist/esm-node/index.js",
22
+ "browser": {
23
+ "./dist/md5.js": "./dist/md5-browser.js",
24
+ "./dist/rng.js": "./dist/rng-browser.js",
25
+ "./dist/sha1.js": "./dist/sha1-browser.js",
26
+ "./dist/esm-node/index.js": "./dist/esm-browser/index.js"
27
+ },
22
28
  "files": [
23
29
  "CHANGELOG.md",
24
30
  "CONTRIBUTING.md",
@@ -36,6 +42,7 @@
36
42
  "@babel/preset-env": "7.8.4",
37
43
  "@commitlint/cli": "8.3.5",
38
44
  "@commitlint/config-conventional": "8.3.4",
45
+ "@rollup/plugin-node-resolve": "7.1.1",
39
46
  "babel-eslint": "10.0.3",
40
47
  "babel-plugin-add-module-exports": "1.0.2",
41
48
  "browserstack-local": "1.4.5",