uuid 12.0.0 → 14.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.
Files changed (50) hide show
  1. package/README.md +100 -108
  2. package/dist/index.d.ts +1 -1
  3. package/dist/md5.d.ts +1 -3
  4. package/dist/md5.js +130 -6
  5. package/dist/parse.d.ts +2 -1
  6. package/dist/rng.js +2 -8
  7. package/dist/sha1.d.ts +1 -3
  8. package/dist/sha1.js +65 -6
  9. package/dist/types.d.ts +1 -0
  10. package/dist/v1.d.ts +1 -1
  11. package/dist/v1ToV6.d.ts +2 -1
  12. package/dist/v3.d.ts +1 -1
  13. package/dist/v35.d.ts +1 -1
  14. package/dist/v35.js +4 -1
  15. package/dist/v4.d.ts +1 -1
  16. package/dist/v4.js +6 -7
  17. package/dist/v5.d.ts +1 -1
  18. package/dist/v6.d.ts +1 -1
  19. package/dist/v6.js +3 -0
  20. package/dist/v7.d.ts +1 -1
  21. package/dist-node/md5.js +11 -0
  22. package/dist-node/rng.js +4 -0
  23. package/dist-node/sha1.js +11 -0
  24. package/{dist-browser → dist-node}/v35.js +4 -1
  25. package/{dist-browser → dist-node}/v4.js +6 -7
  26. package/{dist-browser → dist-node}/v6.js +3 -0
  27. package/package.json +32 -41
  28. package/dist/native.d.ts +0 -6
  29. package/dist/native.js +0 -2
  30. package/dist-browser/md5.js +0 -135
  31. package/dist-browser/native.js +0 -2
  32. package/dist-browser/rng.js +0 -11
  33. package/dist-browser/sha1.js +0 -70
  34. /package/{dist → dist-node}/bin/uuid +0 -0
  35. /package/{dist-browser → dist-node}/index.js +0 -0
  36. /package/{dist-browser → dist-node}/max.js +0 -0
  37. /package/{dist-browser → dist-node}/nil.js +0 -0
  38. /package/{dist-browser → dist-node}/parse.js +0 -0
  39. /package/{dist-browser → dist-node}/regex.js +0 -0
  40. /package/{dist-browser → dist-node}/stringify.js +0 -0
  41. /package/{dist-browser → dist-node}/types.js +0 -0
  42. /package/{dist-browser → dist-node}/uuid-bin.js +0 -0
  43. /package/{dist-browser → dist-node}/v1.js +0 -0
  44. /package/{dist-browser → dist-node}/v1ToV6.js +0 -0
  45. /package/{dist-browser → dist-node}/v3.js +0 -0
  46. /package/{dist-browser → dist-node}/v5.js +0 -0
  47. /package/{dist-browser → dist-node}/v6ToV1.js +0 -0
  48. /package/{dist-browser → dist-node}/v7.js +0 -0
  49. /package/{dist-browser → dist-node}/validate.js +0 -0
  50. /package/{dist-browser → dist-node}/version.js +0 -0
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) / 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/types.d.ts CHANGED
@@ -19,3 +19,4 @@ export type Version7Options = {
19
19
  seq?: number;
20
20
  rng?: () => Uint8Array;
21
21
  };
22
+ export type NonSharedArrayBuffer = ReturnType<typeof Uint8Array.of>;
package/dist/v1.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Version1Options } from './types.js';
1
+ import type { Version1Options } from './types.js';
2
2
  type V1State = {
3
3
  node?: Uint8Array;
4
4
  clockseq?: number;
package/dist/v1ToV6.d.ts CHANGED
@@ -1,2 +1,3 @@
1
+ import type { NonSharedArrayBuffer } from './types.js';
1
2
  export default function v1ToV6(uuid: string): string;
2
- export default function v1ToV6(uuid: Uint8Array): Uint8Array;
3
+ export default function v1ToV6(uuid: Uint8Array): NonSharedArrayBuffer;
package/dist/v3.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { UUIDTypes } from './types.js';
1
+ import type { UUIDTypes } from './types.js';
2
2
  export { DNS, URL } from './v35.js';
3
3
  declare function v3(value: string | Uint8Array, namespace: UUIDTypes, buf?: undefined, offset?: number): string;
4
4
  declare function v3<TBuf extends Uint8Array = Uint8Array>(value: string | Uint8Array, namespace: UUIDTypes, buf: TBuf, offset?: number): TBuf;
package/dist/v35.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { UUIDTypes } from './types.js';
1
+ import type { UUIDTypes } from './types.js';
2
2
  export declare function stringToBytes(str: string): Uint8Array;
3
3
  export declare const DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
4
4
  export declare const URL = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
package/dist/v35.js CHANGED
@@ -26,7 +26,10 @@ export default function v35(version, hash, value, namespace, buf, offset) {
26
26
  bytes[6] = (bytes[6] & 0x0f) | version;
27
27
  bytes[8] = (bytes[8] & 0x3f) | 0x80;
28
28
  if (buf) {
29
- offset = offset || 0;
29
+ 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/v4.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Version4Options } from './types.js';
1
+ import type { Version4Options } from './types.js';
2
2
  declare function v4(options?: Version4Options, buf?: undefined, offset?: number): string;
3
3
  declare function v4<TBuf extends Uint8Array = Uint8Array>(options: Version4Options | undefined, buf: TBuf, offset?: number): TBuf;
4
4
  export default v4;
package/dist/v4.js CHANGED
@@ -1,6 +1,11 @@
1
- import native from './native.js';
2
1
  import rng from './rng.js';
3
2
  import { unsafeStringify } from './stringify.js';
3
+ function v4(options, buf, offset) {
4
+ if (!buf && !options && crypto.randomUUID) {
5
+ return crypto.randomUUID();
6
+ }
7
+ return _v4(options, buf, offset);
8
+ }
4
9
  function _v4(options, buf, offset) {
5
10
  options = options || {};
6
11
  const rnds = options.random ?? options.rng?.() ?? rng();
@@ -21,10 +26,4 @@ function _v4(options, buf, offset) {
21
26
  }
22
27
  return unsafeStringify(rnds);
23
28
  }
24
- function v4(options, buf, offset) {
25
- if (native.randomUUID && !buf && !options) {
26
- return native.randomUUID();
27
- }
28
- return _v4(options, buf, offset);
29
- }
30
29
  export default v4;
package/dist/v5.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { UUIDTypes } from './types.js';
1
+ import type { UUIDTypes } from './types.js';
2
2
  export { DNS, URL } from './v35.js';
3
3
  declare function v5(value: string | Uint8Array, namespace: UUIDTypes, buf?: undefined, offset?: number): string;
4
4
  declare function v5<TBuf extends Uint8Array = Uint8Array>(value: string | Uint8Array, namespace: UUIDTypes, buf: TBuf, offset?: number): TBuf;
package/dist/v6.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Version6Options } from './types.js';
1
+ import type { Version6Options } from './types.js';
2
2
  declare function v6(options?: Version6Options, buf?: undefined, offset?: number): string;
3
3
  declare function v6<TBuf extends Uint8Array = Uint8Array>(options: Version6Options | undefined, buf: TBuf, offset?: number): TBuf;
4
4
  export default v6;
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
  }
package/dist/v7.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Version7Options } from './types.js';
1
+ import type { Version7Options } from './types.js';
2
2
  type V7State = {
3
3
  msecs?: number;
4
4
  seq?: number;
@@ -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,4 @@
1
+ const rnds8 = new Uint8Array(16);
2
+ export default function rng() {
3
+ return crypto.getRandomValues(rnds8);
4
+ }
@@ -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;
@@ -26,7 +26,10 @@ export default function v35(version, hash, value, namespace, buf, offset) {
26
26
  bytes[6] = (bytes[6] & 0x0f) | version;
27
27
  bytes[8] = (bytes[8] & 0x3f) | 0x80;
28
28
  if (buf) {
29
- offset = offset || 0;
29
+ 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
  }
@@ -1,6 +1,11 @@
1
- import native from './native.js';
2
1
  import rng from './rng.js';
3
2
  import { unsafeStringify } from './stringify.js';
3
+ function v4(options, buf, offset) {
4
+ if (!buf && !options && crypto.randomUUID) {
5
+ return crypto.randomUUID();
6
+ }
7
+ return _v4(options, buf, offset);
8
+ }
4
9
  function _v4(options, buf, offset) {
5
10
  options = options || {};
6
11
  const rnds = options.random ?? options.rng?.() ?? rng();
@@ -21,10 +26,4 @@ function _v4(options, buf, offset) {
21
26
  }
22
27
  return unsafeStringify(rnds);
23
28
  }
24
- function v4(options, buf, offset) {
25
- if (native.randomUUID && !buf && !options) {
26
- return native.randomUUID();
27
- }
28
- return _v4(options, buf, offset);
29
- }
30
29
  export default v4;
@@ -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": "14.0.0",
4
4
  "description": "RFC9562 UUIDs",
5
5
  "type": "module",
6
6
  "funding": [
@@ -20,67 +20,61 @@
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": {
40
- "@babel/eslint-parser": "7.27.1",
41
- "@commitlint/cli": "19.8.0",
42
- "@commitlint/config-conventional": "19.8.0",
43
- "@eslint/js": "9.26.0",
40
+ "@biomejs/biome": "2.4.10",
41
+ "@commitlint/cli": "20.5.0",
42
+ "@commitlint/config-conventional": "20.5.0",
44
43
  "bundlewatch": "0.4.1",
45
- "commander": "13.1.0",
46
- "eslint": "9.26.0",
47
- "eslint-config-prettier": "10.1.2",
48
- "eslint-plugin-prettier": "5.4.0",
49
- "globals": "16.0.0",
44
+ "commander": "14.0.3",
45
+ "globals": "17.4.0",
50
46
  "husky": "9.1.7",
51
- "jest": "29.7.0",
52
- "lint-staged": "15.5.2",
53
- "neostandard": "0.12.1",
54
- "npm-run-all": "4.1.5",
55
- "prettier": "3.5.3",
56
- "release-please": "17.0.0",
47
+ "jest": "30.3.0",
48
+ "lint-staged": "16.4.0",
49
+ "neostandard": "0.13.0",
50
+ "npm-run-all2": "8.0.4",
51
+ "release-please": "17.3.0",
57
52
  "runmd": "1.4.1",
58
53
  "standard-version": "9.5.0",
59
- "typescript": "5.2.2",
60
- "typescript-eslint": "8.32.0"
54
+ "typescript": "5.4.3"
61
55
  },
62
56
  "optionalDevDependencies": {
63
- "@wdio/browserstack-service": "9.2.1",
64
- "@wdio/cli": "9.2.1",
65
- "@wdio/jasmine-framework": "9.2.1",
66
- "@wdio/local-runner": "9.2.1",
67
- "@wdio/spec-reporter": "9.1.3",
68
- "@wdio/static-server-service": "9.1.3"
57
+ "@wdio/browserstack-service": "9.27.0",
58
+ "@wdio/cli": "9.27.0",
59
+ "@wdio/jasmine-framework": "9.27.0",
60
+ "@wdio/local-runner": "9.27.0",
61
+ "@wdio/spec-reporter": "9.27.0",
62
+ "@wdio/static-server-service": "9.27.0"
69
63
  },
70
64
  "scripts": {
71
65
  "build": "./scripts/build.sh",
72
66
  "build:watch": "tsc --watch -p tsconfig.json",
73
67
  "bundlewatch": "npm run pretest:browser && bundlewatch --config bundlewatch.config.json",
74
- "docs:diff": "npm run docs && git diff --quiet README.md",
68
+ "docs:diff": "npm run docs && git diff --quiet -I \"[0-9a-f-]{36}\" README.md",
75
69
  "docs": "npm run build && npx runmd --output=README.md README_js.md",
76
- "eslint:check": "eslint src/ test/ examples/ *.[jt]s",
77
- "eslint:fix": "eslint --fix src/ test/ examples/ *.[jt]s",
70
+ "biome:check": "biome check .",
71
+ "biome:fix": "biome check --write .",
78
72
  "examples:browser:rollup:build": "cd examples/browser-rollup && npm run build",
79
73
  "examples:browser:webpack:build": "cd examples/browser-webpack && npm run build",
80
74
  "examples:node:esmodules:test": "cd examples/node-esmodules && npm test",
81
75
  "examples:node:jest:test": "cd examples/node-jest && npm test",
82
76
  "examples:node:typescript:test": "cd examples/typescript && npm test",
83
- "lint": "npm run eslint:check && npm run prettier:check",
77
+ "lint": "npm run biome:check",
84
78
  "md": "runmd --watch --output=README.md README_js.md",
85
79
  "prepack": "npm run build -- --no-pack",
86
80
  "prepare": "husky",
@@ -89,14 +83,14 @@
89
83
  "pretest:browser": "./scripts/iodd && npm run build && npm-run-all --parallel examples:browser:**",
90
84
  "pretest:node": "npm run build",
91
85
  "pretest": "npm run build",
92
- "prettier:check": "prettier --check .",
93
- "prettier:fix": "prettier --write .",
86
+ "format": "biome format --write .",
87
+ "format:check": "biome format --check .",
94
88
  "release": "standard-version --no-verify",
95
89
  "test:benchmark": "cd examples/benchmark && npm test",
96
90
  "test:browser": "wdio run ./wdio.conf.js",
97
91
  "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"
92
+ "test:watch": "node --test --enable-source-maps --watch dist-node/test/*.js",
93
+ "test": "node --test --enable-source-maps dist-node/test/*.js"
100
94
  },
101
95
  "repository": {
102
96
  "type": "git",
@@ -104,16 +98,13 @@
104
98
  },
105
99
  "lint-staged": {
106
100
  "*": [
107
- "prettier --no-error-on-unmatched-pattern --write"
108
- ],
109
- "*.{js,jsx}": [
110
- "eslint --no-error-on-unmatched-pattern --fix"
101
+ "biome check --write --no-errors-on-unmatched"
111
102
  ]
112
103
  },
113
104
  "standard-version": {
114
105
  "scripts": {
115
- "postchangelog": "prettier --write CHANGELOG.md"
106
+ "postchangelog": "biome format --write CHANGELOG.md"
116
107
  }
117
108
  },
118
- "packageManager": "npm@11.3.0"
109
+ "packageManager": "npm@11.12.1"
119
110
  }
package/dist/native.d.ts DELETED
@@ -1,6 +0,0 @@
1
- /// <reference types="node" resolution-mode="require"/>
2
- import { randomUUID } from 'node:crypto';
3
- declare const _default: {
4
- randomUUID: typeof randomUUID;
5
- };
6
- export default _default;
package/dist/native.js DELETED
@@ -1,2 +0,0 @@
1
- import { randomUUID } from 'node:crypto';
2
- export default { randomUUID };
@@ -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