uuid 12.0.0 → 13.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.
Files changed (38) hide show
  1. package/dist/md5.d.ts +1 -3
  2. package/dist/md5.js +130 -6
  3. package/dist/native.d.ts +1 -3
  4. package/dist/native.js +1 -1
  5. package/dist/rng.js +8 -7
  6. package/dist/sha1.d.ts +1 -3
  7. package/dist/sha1.js +65 -6
  8. package/dist/v35.js +3 -0
  9. package/dist/v6.js +3 -0
  10. package/dist-node/md5.js +11 -0
  11. package/dist-node/native.js +2 -0
  12. package/dist-node/rng.js +10 -0
  13. package/dist-node/sha1.js +11 -0
  14. package/{dist-browser → dist-node}/v35.js +3 -0
  15. package/{dist-browser → dist-node}/v6.js +3 -0
  16. package/package.json +7 -7
  17. package/dist-browser/md5.js +0 -135
  18. package/dist-browser/native.js +0 -2
  19. package/dist-browser/rng.js +0 -11
  20. package/dist-browser/sha1.js +0 -70
  21. /package/{dist → dist-node}/bin/uuid +0 -0
  22. /package/{dist-browser → dist-node}/index.js +0 -0
  23. /package/{dist-browser → dist-node}/max.js +0 -0
  24. /package/{dist-browser → dist-node}/nil.js +0 -0
  25. /package/{dist-browser → dist-node}/parse.js +0 -0
  26. /package/{dist-browser → dist-node}/regex.js +0 -0
  27. /package/{dist-browser → dist-node}/stringify.js +0 -0
  28. /package/{dist-browser → dist-node}/types.js +0 -0
  29. /package/{dist-browser → dist-node}/uuid-bin.js +0 -0
  30. /package/{dist-browser → dist-node}/v1.js +0 -0
  31. /package/{dist-browser → dist-node}/v1ToV6.js +0 -0
  32. /package/{dist-browser → dist-node}/v3.js +0 -0
  33. /package/{dist-browser → dist-node}/v4.js +0 -0
  34. /package/{dist-browser → dist-node}/v5.js +0 -0
  35. /package/{dist-browser → dist-node}/v6ToV1.js +0 -0
  36. /package/{dist-browser → dist-node}/v7.js +0 -0
  37. /package/{dist-browser → dist-node}/validate.js +0 -0
  38. /package/{dist-browser → dist-node}/version.js +0 -0
package/dist/md5.d.ts CHANGED
@@ -1,4 +1,2 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- declare function md5(bytes: Uint8Array): Buffer;
1
+ declare function md5(bytes: Uint8Array): Uint8Array;
4
2
  export default md5;
package/dist/md5.js CHANGED
@@ -1,11 +1,135 @@
1
- import { createHash } from 'node:crypto';
2
1
  function md5(bytes) {
3
- if (Array.isArray(bytes)) {
4
- bytes = Buffer.from(bytes);
2
+ const words = uint8ToUint32(bytes);
3
+ const md5Bytes = wordsToMd5(words, bytes.length * 8);
4
+ return uint32ToUint8(md5Bytes);
5
+ }
6
+ function uint32ToUint8(input) {
7
+ const bytes = new Uint8Array(input.length * 4);
8
+ for (let i = 0; i < input.length * 4; i++) {
9
+ bytes[i] = (input[i >> 2] >>> ((i % 4) * 8)) & 0xff;
5
10
  }
6
- else if (typeof bytes === 'string') {
7
- bytes = Buffer.from(bytes, 'utf8');
11
+ return bytes;
12
+ }
13
+ function getOutputLength(inputLength8) {
14
+ return (((inputLength8 + 64) >>> 9) << 4) + 14 + 1;
15
+ }
16
+ function wordsToMd5(x, len) {
17
+ const xpad = new Uint32Array(getOutputLength(len)).fill(0);
18
+ xpad.set(x);
19
+ xpad[len >> 5] |= 0x80 << len % 32;
20
+ xpad[xpad.length - 1] = len;
21
+ x = xpad;
22
+ let a = 1732584193;
23
+ let b = -271733879;
24
+ let c = -1732584194;
25
+ let d = 271733878;
26
+ for (let i = 0; i < x.length; i += 16) {
27
+ const olda = a;
28
+ const oldb = b;
29
+ const oldc = c;
30
+ const oldd = d;
31
+ a = md5ff(a, b, c, d, x[i], 7, -680876936);
32
+ d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
33
+ c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
34
+ b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
35
+ a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
36
+ d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
37
+ c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
38
+ b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
39
+ a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
40
+ d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
41
+ c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
42
+ b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
43
+ a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
44
+ d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
45
+ c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
46
+ b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
47
+ a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
48
+ d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
49
+ c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
50
+ b = md5gg(b, c, d, a, x[i], 20, -373897302);
51
+ a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
52
+ d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
53
+ c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
54
+ b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
55
+ a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
56
+ d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
57
+ c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
58
+ b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
59
+ a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
60
+ d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
61
+ c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
62
+ b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
63
+ a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
64
+ d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
65
+ c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
66
+ b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
67
+ a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
68
+ d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
69
+ c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
70
+ b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
71
+ a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
72
+ d = md5hh(d, a, b, c, x[i], 11, -358537222);
73
+ c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
74
+ b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
75
+ a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
76
+ d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
77
+ c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
78
+ b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
79
+ a = md5ii(a, b, c, d, x[i], 6, -198630844);
80
+ d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
81
+ c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
82
+ b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
83
+ a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
84
+ d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
85
+ c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
86
+ b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
87
+ a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
88
+ d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
89
+ c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
90
+ b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
91
+ a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
92
+ d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
93
+ c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
94
+ b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
95
+ a = safeAdd(a, olda);
96
+ b = safeAdd(b, oldb);
97
+ c = safeAdd(c, oldc);
98
+ d = safeAdd(d, oldd);
8
99
  }
9
- return createHash('md5').update(bytes).digest();
100
+ return Uint32Array.of(a, b, c, d);
101
+ }
102
+ function uint8ToUint32(input) {
103
+ if (input.length === 0) {
104
+ return new Uint32Array();
105
+ }
106
+ const output = new Uint32Array(getOutputLength(input.length * 8)).fill(0);
107
+ for (let i = 0; i < input.length; i++) {
108
+ output[i >> 2] |= (input[i] & 0xff) << ((i % 4) * 8);
109
+ }
110
+ return output;
111
+ }
112
+ function safeAdd(x, y) {
113
+ const lsw = (x & 0xffff) + (y & 0xffff);
114
+ const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
115
+ return (msw << 16) | (lsw & 0xffff);
116
+ }
117
+ function bitRotateLeft(num, cnt) {
118
+ return (num << cnt) | (num >>> (32 - cnt));
119
+ }
120
+ function md5cmn(q, a, b, x, s, t) {
121
+ return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
122
+ }
123
+ function md5ff(a, b, c, d, x, s, t) {
124
+ return md5cmn((b & c) | (~b & d), a, b, x, s, t);
125
+ }
126
+ function md5gg(a, b, c, d, x, s, t) {
127
+ return md5cmn((b & d) | (c & ~d), a, b, x, s, t);
128
+ }
129
+ function md5hh(a, b, c, d, x, s, t) {
130
+ return md5cmn(b ^ c ^ d, a, b, x, s, t);
131
+ }
132
+ function md5ii(a, b, c, d, x, s, t) {
133
+ return md5cmn(c ^ (b | ~d), a, b, x, s, t);
10
134
  }
11
135
  export default md5;
package/dist/native.d.ts CHANGED
@@ -1,6 +1,4 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import { randomUUID } from 'node:crypto';
3
1
  declare const _default: {
4
- randomUUID: typeof randomUUID;
2
+ randomUUID: false | (() => `${string}-${string}-${string}-${string}-${string}`);
5
3
  };
6
4
  export default _default;
package/dist/native.js CHANGED
@@ -1,2 +1,2 @@
1
- import { randomUUID } from 'node:crypto';
1
+ const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
2
2
  export default { randomUUID };
package/dist/rng.js CHANGED
@@ -1,10 +1,11 @@
1
- import { randomFillSync } from 'node:crypto';
2
- const rnds8Pool = new Uint8Array(256);
3
- let poolPtr = rnds8Pool.length;
1
+ let getRandomValues;
2
+ const rnds8 = new Uint8Array(16);
4
3
  export default function rng() {
5
- if (poolPtr > rnds8Pool.length - 16) {
6
- randomFillSync(rnds8Pool);
7
- poolPtr = 0;
4
+ if (!getRandomValues) {
5
+ if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
6
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
7
+ }
8
+ getRandomValues = crypto.getRandomValues.bind(crypto);
8
9
  }
9
- return rnds8Pool.slice(poolPtr, (poolPtr += 16));
10
+ return getRandomValues(rnds8);
10
11
  }
package/dist/sha1.d.ts CHANGED
@@ -1,4 +1,2 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- /// <reference types="node" resolution-mode="require"/>
3
- declare function sha1(bytes: Uint8Array): Buffer;
1
+ declare function sha1(bytes: Uint8Array): Uint8Array;
4
2
  export default sha1;
package/dist/sha1.js CHANGED
@@ -1,11 +1,70 @@
1
- import { createHash } from 'node:crypto';
1
+ function f(s, x, y, z) {
2
+ switch (s) {
3
+ case 0:
4
+ return (x & y) ^ (~x & z);
5
+ case 1:
6
+ return x ^ y ^ z;
7
+ case 2:
8
+ return (x & y) ^ (x & z) ^ (y & z);
9
+ case 3:
10
+ return x ^ y ^ z;
11
+ }
12
+ }
13
+ function ROTL(x, n) {
14
+ return (x << n) | (x >>> (32 - n));
15
+ }
2
16
  function sha1(bytes) {
3
- if (Array.isArray(bytes)) {
4
- bytes = Buffer.from(bytes);
17
+ const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
18
+ const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
19
+ const newBytes = new Uint8Array(bytes.length + 1);
20
+ newBytes.set(bytes);
21
+ newBytes[bytes.length] = 0x80;
22
+ bytes = newBytes;
23
+ const l = bytes.length / 4 + 2;
24
+ const N = Math.ceil(l / 16);
25
+ const M = new Array(N);
26
+ for (let i = 0; i < N; ++i) {
27
+ const arr = new Uint32Array(16);
28
+ for (let j = 0; j < 16; ++j) {
29
+ arr[j] =
30
+ (bytes[i * 64 + j * 4] << 24) |
31
+ (bytes[i * 64 + j * 4 + 1] << 16) |
32
+ (bytes[i * 64 + j * 4 + 2] << 8) |
33
+ bytes[i * 64 + j * 4 + 3];
34
+ }
35
+ M[i] = arr;
5
36
  }
6
- else if (typeof bytes === 'string') {
7
- bytes = Buffer.from(bytes, 'utf8');
37
+ M[N - 1][14] = ((bytes.length - 1) * 8) / Math.pow(2, 32);
38
+ M[N - 1][14] = Math.floor(M[N - 1][14]);
39
+ M[N - 1][15] = ((bytes.length - 1) * 8) & 0xffffffff;
40
+ for (let i = 0; i < N; ++i) {
41
+ const W = new Uint32Array(80);
42
+ for (let t = 0; t < 16; ++t) {
43
+ W[t] = M[i][t];
44
+ }
45
+ for (let t = 16; t < 80; ++t) {
46
+ W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
47
+ }
48
+ let a = H[0];
49
+ let b = H[1];
50
+ let c = H[2];
51
+ let d = H[3];
52
+ let e = H[4];
53
+ for (let t = 0; t < 80; ++t) {
54
+ const s = Math.floor(t / 20);
55
+ const T = (ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t]) >>> 0;
56
+ e = d;
57
+ d = c;
58
+ c = ROTL(b, 30) >>> 0;
59
+ b = a;
60
+ a = T;
61
+ }
62
+ H[0] = (H[0] + a) >>> 0;
63
+ H[1] = (H[1] + b) >>> 0;
64
+ H[2] = (H[2] + c) >>> 0;
65
+ H[3] = (H[3] + d) >>> 0;
66
+ H[4] = (H[4] + e) >>> 0;
8
67
  }
9
- return createHash('sha1').update(bytes).digest();
68
+ return Uint8Array.of(H[0] >> 24, H[0] >> 16, H[0] >> 8, H[0], H[1] >> 24, H[1] >> 16, H[1] >> 8, H[1], H[2] >> 24, H[2] >> 16, H[2] >> 8, H[2], H[3] >> 24, H[3] >> 16, H[3] >> 8, H[3], H[4] >> 24, H[4] >> 16, H[4] >> 8, H[4]);
10
69
  }
11
70
  export default sha1;
package/dist/v35.js CHANGED
@@ -27,6 +27,9 @@ export default function v35(version, hash, value, namespace, buf, offset) {
27
27
  bytes[8] = (bytes[8] & 0x3f) | 0x80;
28
28
  if (buf) {
29
29
  offset = offset || 0;
30
+ if (offset < 0 || offset + 16 > buf.length) {
31
+ throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
32
+ }
30
33
  for (let i = 0; i < 16; ++i) {
31
34
  buf[offset + i] = bytes[i];
32
35
  }
package/dist/v6.js CHANGED
@@ -7,6 +7,9 @@ function v6(options, buf, offset) {
7
7
  let bytes = v1({ ...options, _v6: true }, new Uint8Array(16));
8
8
  bytes = v1ToV6(bytes);
9
9
  if (buf) {
10
+ if (offset < 0 || offset + 16 > buf.length) {
11
+ throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
12
+ }
10
13
  for (let i = 0; i < 16; i++) {
11
14
  buf[offset + i] = bytes[i];
12
15
  }
@@ -0,0 +1,11 @@
1
+ import { createHash } from 'node:crypto';
2
+ function md5(bytes) {
3
+ if (Array.isArray(bytes)) {
4
+ bytes = Buffer.from(bytes);
5
+ }
6
+ else if (typeof bytes === 'string') {
7
+ bytes = Buffer.from(bytes, 'utf8');
8
+ }
9
+ return createHash('md5').update(bytes).digest();
10
+ }
11
+ export default md5;
@@ -0,0 +1,2 @@
1
+ import { randomUUID } from 'node:crypto';
2
+ export default { randomUUID };
@@ -0,0 +1,10 @@
1
+ import { randomFillSync } from 'node:crypto';
2
+ const rnds8Pool = new Uint8Array(256);
3
+ let poolPtr = rnds8Pool.length;
4
+ export default function rng() {
5
+ if (poolPtr > rnds8Pool.length - 16) {
6
+ randomFillSync(rnds8Pool);
7
+ poolPtr = 0;
8
+ }
9
+ return rnds8Pool.slice(poolPtr, (poolPtr += 16));
10
+ }
@@ -0,0 +1,11 @@
1
+ import { createHash } from 'node:crypto';
2
+ function sha1(bytes) {
3
+ if (Array.isArray(bytes)) {
4
+ bytes = Buffer.from(bytes);
5
+ }
6
+ else if (typeof bytes === 'string') {
7
+ bytes = Buffer.from(bytes, 'utf8');
8
+ }
9
+ return createHash('sha1').update(bytes).digest();
10
+ }
11
+ export default sha1;
@@ -27,6 +27,9 @@ export default function v35(version, hash, value, namespace, buf, offset) {
27
27
  bytes[8] = (bytes[8] & 0x3f) | 0x80;
28
28
  if (buf) {
29
29
  offset = offset || 0;
30
+ if (offset < 0 || offset + 16 > buf.length) {
31
+ throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
32
+ }
30
33
  for (let i = 0; i < 16; ++i) {
31
34
  buf[offset + i] = bytes[i];
32
35
  }
@@ -7,6 +7,9 @@ function v6(options, buf, offset) {
7
7
  let bytes = v1({ ...options, _v6: true }, new Uint8Array(16));
8
8
  bytes = v1ToV6(bytes);
9
9
  if (buf) {
10
+ if (offset < 0 || offset + 16 > buf.length) {
11
+ throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`);
12
+ }
10
13
  for (let i = 0; i < 16; i++) {
11
14
  buf[offset + i] = bytes[i];
12
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uuid",
3
- "version": "12.0.0",
3
+ "version": "13.0.1",
4
4
  "description": "RFC9562 UUIDs",
5
5
  "type": "module",
6
6
  "funding": [
@@ -20,20 +20,20 @@
20
20
  ],
21
21
  "license": "MIT",
22
22
  "bin": {
23
- "uuid": "./dist/bin/uuid"
23
+ "uuid": "./dist-node/bin/uuid"
24
24
  },
25
25
  "sideEffects": false,
26
26
  "types": "./dist/index.d.ts",
27
27
  "exports": {
28
28
  ".": {
29
- "browser": "./dist-browser/index.js",
29
+ "node": "./dist-node/index.js",
30
30
  "default": "./dist/index.js"
31
31
  },
32
32
  "./package.json": "./package.json"
33
33
  },
34
34
  "files": [
35
35
  "dist",
36
- "dist-browser",
36
+ "dist-node",
37
37
  "!**/test"
38
38
  ],
39
39
  "devDependencies": {
@@ -71,7 +71,7 @@
71
71
  "build": "./scripts/build.sh",
72
72
  "build:watch": "tsc --watch -p tsconfig.json",
73
73
  "bundlewatch": "npm run pretest:browser && bundlewatch --config bundlewatch.config.json",
74
- "docs:diff": "npm run docs && git diff --quiet README.md",
74
+ "docs:diff": "npm run docs && git diff --quiet -I \"[0-9a-f-]{36}\" README.md",
75
75
  "docs": "npm run build && npx runmd --output=README.md README_js.md",
76
76
  "eslint:check": "eslint src/ test/ examples/ *.[jt]s",
77
77
  "eslint:fix": "eslint --fix src/ test/ examples/ *.[jt]s",
@@ -95,8 +95,8 @@
95
95
  "test:benchmark": "cd examples/benchmark && npm test",
96
96
  "test:browser": "wdio run ./wdio.conf.js",
97
97
  "test:node": "npm-run-all --parallel examples:node:**",
98
- "test:watch": "node --test --enable-source-maps --watch dist/test/*.js",
99
- "test": "node --test --enable-source-maps dist/test/*.js"
98
+ "test:watch": "node --test --enable-source-maps --watch dist-node/test/*.js",
99
+ "test": "node --test --enable-source-maps dist-node/test/*.js"
100
100
  },
101
101
  "repository": {
102
102
  "type": "git",
@@ -1,135 +0,0 @@
1
- function md5(bytes) {
2
- const words = uint8ToUint32(bytes);
3
- const md5Bytes = wordsToMd5(words, bytes.length * 8);
4
- return uint32ToUint8(md5Bytes);
5
- }
6
- function uint32ToUint8(input) {
7
- const bytes = new Uint8Array(input.length * 4);
8
- for (let i = 0; i < input.length * 4; i++) {
9
- bytes[i] = (input[i >> 2] >>> ((i % 4) * 8)) & 0xff;
10
- }
11
- return bytes;
12
- }
13
- function getOutputLength(inputLength8) {
14
- return (((inputLength8 + 64) >>> 9) << 4) + 14 + 1;
15
- }
16
- function wordsToMd5(x, len) {
17
- const xpad = new Uint32Array(getOutputLength(len)).fill(0);
18
- xpad.set(x);
19
- xpad[len >> 5] |= 0x80 << len % 32;
20
- xpad[xpad.length - 1] = len;
21
- x = xpad;
22
- let a = 1732584193;
23
- let b = -271733879;
24
- let c = -1732584194;
25
- let d = 271733878;
26
- for (let i = 0; i < x.length; i += 16) {
27
- const olda = a;
28
- const oldb = b;
29
- const oldc = c;
30
- const oldd = d;
31
- a = md5ff(a, b, c, d, x[i], 7, -680876936);
32
- d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
33
- c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
34
- b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
35
- a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
36
- d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
37
- c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
38
- b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
39
- a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
40
- d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
41
- c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
42
- b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
43
- a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
44
- d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
45
- c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
46
- b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
47
- a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
48
- d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
49
- c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
50
- b = md5gg(b, c, d, a, x[i], 20, -373897302);
51
- a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
52
- d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
53
- c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
54
- b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
55
- a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
56
- d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
57
- c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
58
- b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
59
- a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
60
- d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
61
- c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
62
- b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
63
- a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
64
- d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
65
- c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
66
- b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
67
- a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
68
- d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
69
- c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
70
- b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
71
- a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
72
- d = md5hh(d, a, b, c, x[i], 11, -358537222);
73
- c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
74
- b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
75
- a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
76
- d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
77
- c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
78
- b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
79
- a = md5ii(a, b, c, d, x[i], 6, -198630844);
80
- d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
81
- c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
82
- b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
83
- a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
84
- d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
85
- c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
86
- b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
87
- a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
88
- d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
89
- c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
90
- b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
91
- a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
92
- d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
93
- c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
94
- b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
95
- a = safeAdd(a, olda);
96
- b = safeAdd(b, oldb);
97
- c = safeAdd(c, oldc);
98
- d = safeAdd(d, oldd);
99
- }
100
- return Uint32Array.of(a, b, c, d);
101
- }
102
- function uint8ToUint32(input) {
103
- if (input.length === 0) {
104
- return new Uint32Array();
105
- }
106
- const output = new Uint32Array(getOutputLength(input.length * 8)).fill(0);
107
- for (let i = 0; i < input.length; i++) {
108
- output[i >> 2] |= (input[i] & 0xff) << ((i % 4) * 8);
109
- }
110
- return output;
111
- }
112
- function safeAdd(x, y) {
113
- const lsw = (x & 0xffff) + (y & 0xffff);
114
- const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
115
- return (msw << 16) | (lsw & 0xffff);
116
- }
117
- function bitRotateLeft(num, cnt) {
118
- return (num << cnt) | (num >>> (32 - cnt));
119
- }
120
- function md5cmn(q, a, b, x, s, t) {
121
- return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
122
- }
123
- function md5ff(a, b, c, d, x, s, t) {
124
- return md5cmn((b & c) | (~b & d), a, b, x, s, t);
125
- }
126
- function md5gg(a, b, c, d, x, s, t) {
127
- return md5cmn((b & d) | (c & ~d), a, b, x, s, t);
128
- }
129
- function md5hh(a, b, c, d, x, s, t) {
130
- return md5cmn(b ^ c ^ d, a, b, x, s, t);
131
- }
132
- function md5ii(a, b, c, d, x, s, t) {
133
- return md5cmn(c ^ (b | ~d), a, b, x, s, t);
134
- }
135
- export default md5;
@@ -1,2 +0,0 @@
1
- const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
2
- export default { randomUUID };
@@ -1,11 +0,0 @@
1
- let getRandomValues;
2
- const rnds8 = new Uint8Array(16);
3
- export default function rng() {
4
- if (!getRandomValues) {
5
- if (typeof crypto === 'undefined' || !crypto.getRandomValues) {
6
- throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
7
- }
8
- getRandomValues = crypto.getRandomValues.bind(crypto);
9
- }
10
- return getRandomValues(rnds8);
11
- }
@@ -1,70 +0,0 @@
1
- function f(s, x, y, z) {
2
- switch (s) {
3
- case 0:
4
- return (x & y) ^ (~x & z);
5
- case 1:
6
- return x ^ y ^ z;
7
- case 2:
8
- return (x & y) ^ (x & z) ^ (y & z);
9
- case 3:
10
- return x ^ y ^ z;
11
- }
12
- }
13
- function ROTL(x, n) {
14
- return (x << n) | (x >>> (32 - n));
15
- }
16
- function sha1(bytes) {
17
- const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
18
- const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
19
- const newBytes = new Uint8Array(bytes.length + 1);
20
- newBytes.set(bytes);
21
- newBytes[bytes.length] = 0x80;
22
- bytes = newBytes;
23
- const l = bytes.length / 4 + 2;
24
- const N = Math.ceil(l / 16);
25
- const M = new Array(N);
26
- for (let i = 0; i < N; ++i) {
27
- const arr = new Uint32Array(16);
28
- for (let j = 0; j < 16; ++j) {
29
- arr[j] =
30
- (bytes[i * 64 + j * 4] << 24) |
31
- (bytes[i * 64 + j * 4 + 1] << 16) |
32
- (bytes[i * 64 + j * 4 + 2] << 8) |
33
- bytes[i * 64 + j * 4 + 3];
34
- }
35
- M[i] = arr;
36
- }
37
- M[N - 1][14] = ((bytes.length - 1) * 8) / Math.pow(2, 32);
38
- M[N - 1][14] = Math.floor(M[N - 1][14]);
39
- M[N - 1][15] = ((bytes.length - 1) * 8) & 0xffffffff;
40
- for (let i = 0; i < N; ++i) {
41
- const W = new Uint32Array(80);
42
- for (let t = 0; t < 16; ++t) {
43
- W[t] = M[i][t];
44
- }
45
- for (let t = 16; t < 80; ++t) {
46
- W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
47
- }
48
- let a = H[0];
49
- let b = H[1];
50
- let c = H[2];
51
- let d = H[3];
52
- let e = H[4];
53
- for (let t = 0; t < 80; ++t) {
54
- const s = Math.floor(t / 20);
55
- const T = (ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t]) >>> 0;
56
- e = d;
57
- d = c;
58
- c = ROTL(b, 30) >>> 0;
59
- b = a;
60
- a = T;
61
- }
62
- H[0] = (H[0] + a) >>> 0;
63
- H[1] = (H[1] + b) >>> 0;
64
- H[2] = (H[2] + c) >>> 0;
65
- H[3] = (H[3] + d) >>> 0;
66
- H[4] = (H[4] + e) >>> 0;
67
- }
68
- return Uint8Array.of(H[0] >> 24, H[0] >> 16, H[0] >> 8, H[0], H[1] >> 24, H[1] >> 16, H[1] >> 8, H[1], H[2] >> 24, H[2] >> 16, H[2] >> 8, H[2], H[3] >> 24, H[3] >> 16, H[3] >> 8, H[3], H[4] >> 24, H[4] >> 16, H[4] >> 8, H[4]);
69
- }
70
- export default sha1;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes