uuid 8.3.2-beta.0 → 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.
Files changed (56) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +47 -73
  3. package/dist/commonjs-browser/index.js +79 -0
  4. package/dist/commonjs-browser/md5.js +223 -0
  5. package/dist/commonjs-browser/native.js +11 -0
  6. package/dist/commonjs-browser/nil.js +8 -0
  7. package/dist/commonjs-browser/parse.js +45 -0
  8. package/dist/commonjs-browser/regex.js +8 -0
  9. package/dist/commonjs-browser/rng.js +25 -0
  10. package/dist/commonjs-browser/sha1.js +104 -0
  11. package/dist/commonjs-browser/stringify.js +44 -0
  12. package/dist/commonjs-browser/v1.js +107 -0
  13. package/dist/commonjs-browser/v3.js +16 -0
  14. package/dist/commonjs-browser/v35.js +80 -0
  15. package/dist/commonjs-browser/v4.js +43 -0
  16. package/dist/commonjs-browser/v5.js +16 -0
  17. package/dist/commonjs-browser/validate.js +17 -0
  18. package/dist/commonjs-browser/version.js +21 -0
  19. package/dist/esm-browser/md5.js +23 -23
  20. package/dist/esm-browser/native.js +4 -0
  21. package/dist/esm-browser/parse.js +2 -2
  22. package/dist/esm-browser/rng.js +4 -5
  23. package/dist/esm-browser/sha1.js +26 -26
  24. package/dist/esm-browser/stringify.js +9 -6
  25. package/dist/esm-browser/v1.js +17 -17
  26. package/dist/esm-browser/v3.js +1 -1
  27. package/dist/esm-browser/v35.js +12 -10
  28. package/dist/esm-browser/v4.js +9 -4
  29. package/dist/esm-browser/v5.js +1 -1
  30. package/dist/esm-browser/version.js +1 -1
  31. package/dist/esm-node/native.js +4 -0
  32. package/dist/esm-node/stringify.js +7 -3
  33. package/dist/esm-node/v1.js +2 -2
  34. package/dist/esm-node/v35.js +6 -4
  35. package/dist/esm-node/v4.js +7 -2
  36. package/dist/esm-node/version.js +1 -1
  37. package/dist/index.js +18 -18
  38. package/dist/native-browser.js +11 -0
  39. package/dist/native.js +15 -0
  40. package/dist/rng-browser.js +2 -3
  41. package/dist/stringify.js +8 -3
  42. package/dist/v1.js +2 -2
  43. package/dist/v35.js +7 -5
  44. package/dist/v4.js +8 -2
  45. package/dist/version.js +1 -1
  46. package/package.json +37 -41
  47. package/dist/umd/uuid.min.js +0 -1
  48. package/dist/umd/uuidNIL.min.js +0 -1
  49. package/dist/umd/uuidParse.min.js +0 -1
  50. package/dist/umd/uuidStringify.min.js +0 -1
  51. package/dist/umd/uuidValidate.min.js +0 -1
  52. package/dist/umd/uuidVersion.min.js +0 -1
  53. package/dist/umd/uuidv1.min.js +0 -1
  54. package/dist/umd/uuidv3.min.js +0 -1
  55. package/dist/umd/uuidv4.min.js +0 -1
  56. package/dist/umd/uuidv5.min.js +0 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,51 @@
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
+ ## [9.0.0](https://github.com/uuidjs/uuid/compare/v8.3.2...v9.0.0) (2022-09-05)
6
+
7
+ ### ⚠ BREAKING CHANGES
8
+
9
+ - Drop Node.js 10.x support. This library always aims at supporting one EOLed LTS release which by this time now is 12.x which has reached EOL 30 Apr 2022.
10
+
11
+ - Remove the minified UMD build from the package.
12
+
13
+ Minified code is hard to audit and since this is a widely used library it seems more appropriate nowadays to optimize for auditability than to ship a legacy module format that, at best, serves educational purposes nowadays.
14
+
15
+ For production browser use cases, users should be using a bundler. For educational purposes, today's online sandboxes like replit.com offer convenient ways to load npm modules, so the use case for UMD through repos like UNPKG or jsDelivr has largely vanished.
16
+
17
+ - Drop IE 11 and Safari 10 support. Drop support for browsers that don't correctly implement const/let and default arguments, and no longer transpile the browser build to ES2015.
18
+
19
+ This also removes the fallback on msCrypto instead of the crypto API.
20
+
21
+ Browser tests are run in the first supported version of each supported browser and in the latest (as of this commit) version available on Browserstack.
22
+
23
+ ### Features
24
+
25
+ - optimize uuid.v1 by 1.3x uuid.v4 by 4.3x (430%) ([#597](https://github.com/uuidjs/uuid/issues/597)) ([3a033f6](https://github.com/uuidjs/uuid/commit/3a033f6bab6bb3780ece6d645b902548043280bc))
26
+ - remove UMD build ([#645](https://github.com/uuidjs/uuid/issues/645)) ([e948a0f](https://github.com/uuidjs/uuid/commit/e948a0f22bf22f4619b27bd913885e478e20fe6f)), closes [#620](https://github.com/uuidjs/uuid/issues/620)
27
+ - use native crypto.randomUUID when available ([#600](https://github.com/uuidjs/uuid/issues/600)) ([c9e076c](https://github.com/uuidjs/uuid/commit/c9e076c852edad7e9a06baaa1d148cf4eda6c6c4))
28
+
29
+ ### Bug Fixes
30
+
31
+ - add Jest/jsdom compatibility ([#642](https://github.com/uuidjs/uuid/issues/642)) ([16f9c46](https://github.com/uuidjs/uuid/commit/16f9c469edf46f0786164cdf4dc980743984a6fd))
32
+ - change default export to named function ([#545](https://github.com/uuidjs/uuid/issues/545)) ([c57bc5a](https://github.com/uuidjs/uuid/commit/c57bc5a9a0653273aa639cda9177ce52efabe42a))
33
+ - handle error when parameter is not set in v3 and v5 ([#622](https://github.com/uuidjs/uuid/issues/622)) ([fcd7388](https://github.com/uuidjs/uuid/commit/fcd73881692d9fabb63872576ba28e30ff852091))
34
+ - run npm audit fix ([#644](https://github.com/uuidjs/uuid/issues/644)) ([04686f5](https://github.com/uuidjs/uuid/commit/04686f54c5fed2cfffc1b619f4970c4bb8532353))
35
+ - upgrading from uuid3 broken link ([#568](https://github.com/uuidjs/uuid/issues/568)) ([1c849da](https://github.com/uuidjs/uuid/commit/1c849da6e164259e72e18636726345b13a7eddd6))
36
+
37
+ ### build
38
+
39
+ - drop Node.js 8.x from babel transpile target ([#603](https://github.com/uuidjs/uuid/issues/603)) ([aa11485](https://github.com/uuidjs/uuid/commit/aa114858260402107ec8a1e1a825dea0a259bcb5))
40
+ - drop support for legacy browsers (IE11, Safari 10) ([#604](https://github.com/uuidjs/uuid/issues/604)) ([0f433e5](https://github.com/uuidjs/uuid/commit/0f433e5ec444edacd53016de67db021102f36148))
41
+
42
+ - drop node 10.x to upgrade dev dependencies ([#653](https://github.com/uuidjs/uuid/issues/653)) ([28a5712](https://github.com/uuidjs/uuid/commit/28a571283f8abda6b9d85e689f95b7d3ee9e282e)), closes [#643](https://github.com/uuidjs/uuid/issues/643)
43
+
44
+ ### [8.3.2](https://github.com/uuidjs/uuid/compare/v8.3.1...v8.3.2) (2020-12-08)
45
+
46
+ ### Bug Fixes
47
+
48
+ - lazy load getRandomValues ([#537](https://github.com/uuidjs/uuid/issues/537)) ([16c8f6d](https://github.com/uuidjs/uuid/commit/16c8f6df2f6b09b4d6235602d6a591188320a82e)), closes [#536](https://github.com/uuidjs/uuid/issues/536)
49
+
5
50
  ### [8.3.1](https://github.com/uuidjs/uuid/compare/v8.3.0...v8.3.1) (2020-10-04)
6
51
 
7
52
  ### Bug Fixes
package/README.md CHANGED
@@ -4,20 +4,20 @@
4
4
 
5
5
  # uuid [![CI](https://github.com/uuidjs/uuid/workflows/CI/badge.svg)](https://github.com/uuidjs/uuid/actions?query=workflow%3ACI) [![Browser](https://github.com/uuidjs/uuid/workflows/Browser/badge.svg)](https://github.com/uuidjs/uuid/actions?query=workflow%3ABrowser)
6
6
 
7
- For the creation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDs
7
+ For the creation of [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) UUIDs
8
8
 
9
9
  - **Complete** - Support for RFC4122 version 1, 3, 4, and 5 UUIDs
10
10
  - **Cross-platform** - Support for ...
11
11
  - CommonJS, [ECMAScript Modules](#ecmascript-modules) and [CDN builds](#cdn-builds)
12
- - Node 8, 10, 12, 14
13
- - Chrome, Safari, Firefox, Edge, IE 11 browsers
12
+ - Node 12, 14, 16, 18
13
+ - Chrome, Safari, Firefox, Edge browsers
14
14
  - Webpack and rollup.js module bundlers
15
15
  - [React Native / Expo](#react-native--expo)
16
16
  - **Secure** - Cryptographically-strong random values
17
17
  - **Small** - Zero-dependency, small footprint, plays nice with "tree shaking" packagers
18
18
  - **CLI** - Includes the [`uuid` command line](#command-line) utility
19
19
 
20
- **Upgrading from `uuid@3.x`?** Your code is probably okay, but check out [Upgrading From `uuid@3.x`](#upgrading-from-uuid3x) for details.
20
+ **Upgrading from `uuid@3`?** Your code is probably okay, but check out [Upgrading From `uuid@3`](#upgrading-from-uuid3) for details.
21
21
 
22
22
  ## Quickstart
23
23
 
@@ -122,22 +122,7 @@ Example:
122
122
  import { stringify as uuidStringify } from 'uuid';
123
123
 
124
124
  const uuidBytes = [
125
- 0x6e,
126
- 0xc0,
127
- 0xbd,
128
- 0x7f,
129
- 0x11,
130
- 0xc0,
131
- 0x43,
132
- 0xda,
133
- 0x97,
134
- 0x5e,
135
- 0x2a,
136
- 0x8a,
137
- 0xd9,
138
- 0xeb,
139
- 0xae,
140
- 0x0b,
125
+ 0x6e, 0xc0, 0xbd, 0x7f, 0x11, 0xc0, 0x43, 0xda, 0x97, 0x5e, 0x2a, 0x8a, 0xd9, 0xeb, 0xae, 0x0b,
141
126
  ];
142
127
 
143
128
  uuidStringify(uuidBytes); // ⇨ '6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b'
@@ -223,22 +208,7 @@ import { v4 as uuidv4 } from 'uuid';
223
208
 
224
209
  const v4options = {
225
210
  random: [
226
- 0x10,
227
- 0x91,
228
- 0x56,
229
- 0xbe,
230
- 0xc4,
231
- 0xfb,
232
- 0xc1,
233
- 0xea,
234
- 0x71,
235
- 0xb4,
236
- 0xef,
237
- 0xe1,
238
- 0x67,
239
- 0x1c,
240
- 0x58,
241
- 0x36,
211
+ 0x10, 0x91, 0x56, 0xbe, 0xc4, 0xfb, 0xc1, 0xea, 0x71, 0xb4, 0xef, 0xe1, 0x67, 0x1c, 0x58, 0x36,
242
212
  ],
243
213
  };
244
214
  uuidv4(v4options); // ⇨ '109156be-c4fb-41ea-b1b4-efe1671c5836'
@@ -296,6 +266,23 @@ uuidValidate('not a UUID'); // ⇨ false
296
266
  uuidValidate('6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b'); // ⇨ true
297
267
  ```
298
268
 
269
+ Using `validate` and `version` together it is possible to do per-version validation, e.g. validate for only v4 UUIds.
270
+
271
+ ```javascript
272
+ import { version as uuidVersion } from 'uuid';
273
+ import { validate as uuidValidate } from 'uuid';
274
+
275
+ function uuidValidateV4(uuid) {
276
+ return uuidValidate(uuid) && uuidVersion(uuid) === 4;
277
+ }
278
+
279
+ const v1Uuid = 'd9428888-122b-11e1-b85c-61cd3cbb3210';
280
+ const v4Uuid = '109156be-c4fb-41ea-b1b4-efe1671c5836';
281
+
282
+ uuidValidateV4(v4Uuid); // ⇨ true
283
+ uuidValidateV4(v1Uuid); // ⇨ false
284
+ ```
285
+
299
286
  ### uuid.version(str)
300
287
 
301
288
  Detect RFC version of a UUID
@@ -320,14 +307,14 @@ uuidVersion('6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b'); // ⇨ 4
320
307
  UUIDs can be generated from the command line using `uuid`.
321
308
 
322
309
  ```shell
323
- $ uuid
310
+ $ npx uuid
324
311
  ddeb27fb-d9a0-4624-be4d-4615062daed4
325
312
  ```
326
313
 
327
314
  The default is to generate version 4 UUIDS, however the other versions are supported. Type `uuid --help` for details:
328
315
 
329
316
  ```shell
330
- $ uuid --help
317
+ $ npx uuid --help
331
318
 
332
319
  Usage:
333
320
  uuid
@@ -371,37 +358,20 @@ To load this module directly into modern browsers that [support loading ECMAScri
371
358
 
372
359
  ### UMD
373
360
 
374
- To load this module directly into older browsers you can use the [UMD (Universal Module Definition)](https://github.com/umdjs/umd) builds from any of the following CDNs:
375
-
376
- **Using [UNPKG](https://unpkg.com/uuid@latest/dist/umd/)**:
377
-
378
- ```html
379
- <script src="https://unpkg.com/uuid@latest/dist/umd/uuidv4.min.js"></script>
380
- ```
381
-
382
- **Using [jsDelivr](https://cdn.jsdelivr.net/npm/uuid@latest/dist/umd/)**:
383
-
384
- ```html
385
- <script src="https://cdn.jsdelivr.net/npm/uuid@latest/dist/umd/uuidv4.min.js"></script>
386
- ```
361
+ As of `uuid@9` [UMD (Universal Module Definition)](https://github.com/umdjs/umd) builds are no longer shipped with this library.
387
362
 
388
- **Using [cdnjs](https://cdnjs.com/libraries/uuid)**:
363
+ If you need a UMD build of this library, use a bundler like Webpack or Rollup. Alternatively, refer to the documentation of [`uuid@8.3.2`](https://github.com/uuidjs/uuid/blob/v8.3.2/README.md#umd) which was the last version that shipped UMD builds.
389
364
 
390
- ```html
391
- <script src="https://cdnjs.cloudflare.com/ajax/libs/uuid/8.1.0/uuidv4.min.js"></script>
392
- ```
365
+ ## Known issues
393
366
 
394
- These CDNs all provide the same [`uuidv4()`](#uuidv4options-buffer-offset) method:
367
+ ### Duplicate UUIDs (Googlebot)
395
368
 
396
- ```html
397
- <script>
398
- uuidv4(); // ⇨ '55af1e37-0734-46d8-b070-a1e42e4fc392'
399
- </script>
400
- ```
369
+ This module may generate duplicate UUIDs when run in clients with _deterministic_ random number generators, such as [Googlebot crawlers](https://developers.google.com/search/docs/advanced/crawling/overview-google-crawlers). This can cause problems for apps that expect client-generated UUIDs to always be unique. Developers should be prepared for this and have a strategy for dealing with possible collisions, such as:
401
370
 
402
- Methods for the other algorithms ([`uuidv1()`](#uuidv1options-buffer-offset), [`uuidv3()`](#uuidv3name-namespace-buffer-offset) and [`uuidv5()`](#uuidv5name-namespace-buffer-offset)) are available from the files `uuidv1.min.js`, `uuidv3.min.js` and `uuidv5.min.js` respectively.
371
+ - Check for duplicate UUIDs, fail gracefully
372
+ - Disable write operations for Googlebot clients
403
373
 
404
- ## "getRandomValues() not supported"
374
+ ### "getRandomValues() not supported"
405
375
 
406
376
  This error occurs in environments where the standard [`crypto.getRandomValues()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues) API is not supported. This issue can be resolved by adding an appropriate polyfill:
407
377
 
@@ -421,11 +391,15 @@ Note: If you are using Expo, you must be using at least `react-native-get-random
421
391
 
422
392
  [In Edge <= 18, Web Crypto is not supported in Web Workers or Service Workers](https://caniuse.com/#feat=cryptography) and we are not aware of a polyfill (let us know if you find one, please).
423
393
 
424
- ## Upgrading From `uuid@7.x`
394
+ ### IE 11 (Internet Explorer)
395
+
396
+ Support for IE11 and other legacy browsers has been dropped as of `uuid@9`. If you need to support legacy browsers, you can always transpile the uuid module source yourself (e.g. using [Babel](https://babeljs.io/)).
397
+
398
+ ## Upgrading From `uuid@7`
425
399
 
426
400
  ### Only Named Exports Supported When Using with Node.js ESM
427
401
 
428
- `uuid@7.x` did not come with native ECMAScript Module (ESM) support for Node.js. Importing it in Node.js ESM consequently imported the CommonJS source with a default export. This library now comes with true Node.js ESM support and only provides named exports.
402
+ `uuid@7` did not come with native ECMAScript Module (ESM) support for Node.js. Importing it in Node.js ESM consequently imported the CommonJS source with a default export. This library now comes with true Node.js ESM support and only provides named exports.
429
403
 
430
404
  Instead of doing:
431
405
 
@@ -443,24 +417,24 @@ uuidv4();
443
417
 
444
418
  ### Deep Requires No Longer Supported
445
419
 
446
- Deep requires like `require('uuid/v4')` [which have been deprecated in `uuid@7.x`](#deep-requires-now-deprecated) are no longer supported.
420
+ Deep requires like `require('uuid/v4')` [which have been deprecated in `uuid@7`](#deep-requires-now-deprecated) are no longer supported.
447
421
 
448
- ## Upgrading From `uuid@3.x`
422
+ ## Upgrading From `uuid@3`
449
423
 
450
- "_Wait... what happened to `uuid@4.x` - `uuid@6.x`?!?_"
424
+ "_Wait... what happened to `uuid@4` thru `uuid@6`?!?_"
451
425
 
452
426
  In order to avoid confusion with RFC [version 4](#uuidv4options-buffer-offset) and [version 5](#uuidv5name-namespace-buffer-offset) UUIDs, and a possible [version 6](http://gh.peabody.io/uuidv6/), releases 4 thru 6 of this module have been skipped.
453
427
 
454
428
  ### Deep Requires Now Deprecated
455
429
 
456
- `uuid@3.x` encouraged the use of deep requires to minimize the bundle size of browser builds:
430
+ `uuid@3` encouraged the use of deep requires to minimize the bundle size of browser builds:
457
431
 
458
432
  ```javascript
459
433
  const uuidv4 = require('uuid/v4'); // <== NOW DEPRECATED!
460
434
  uuidv4();
461
435
  ```
462
436
 
463
- As of `uuid@7.x` this library now provides ECMAScript modules builds, which allow packagers like Webpack and Rollup to do "tree-shaking" to remove dead code. Instead, use the `import` syntax:
437
+ As of `uuid@7` this library now provides ECMAScript modules builds, which allow packagers like Webpack and Rollup to do "tree-shaking" to remove dead code. Instead, use the `import` syntax:
464
438
 
465
439
  ```javascript
466
440
  import { v4 as uuidv4 } from 'uuid';
@@ -476,13 +450,13 @@ uuidv4();
476
450
 
477
451
  ### Default Export Removed
478
452
 
479
- `uuid@3.x` was exporting the Version 4 UUID method as a default export:
453
+ `uuid@3` was exporting the Version 4 UUID method as a default export:
480
454
 
481
455
  ```javascript
482
456
  const uuid = require('uuid'); // <== REMOVED!
483
457
  ```
484
458
 
485
- This usage pattern was already discouraged in `uuid@3.x` and has been removed in `uuid@7.x`.
459
+ This usage pattern was already discouraged in `uuid@3` and has been removed in `uuid@7`.
486
460
 
487
461
  ----
488
- Markdown generated from [README_js.md](README_js.md) by [![RunMD Logo](http://i.imgur.com/h0FVyzU.png)](https://github.com/broofa/runmd)
462
+ Markdown generated from [README_js.md](README_js.md) by [![RunMD Logo](https://i.imgur.com/h0FVyzU.png)](https://github.com/broofa/runmd)
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "NIL", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _nil.default;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "parse", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _parse.default;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "stringify", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _stringify.default;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "v1", {
25
+ enumerable: true,
26
+ get: function get() {
27
+ return _v.default;
28
+ }
29
+ });
30
+ Object.defineProperty(exports, "v3", {
31
+ enumerable: true,
32
+ get: function get() {
33
+ return _v2.default;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "v4", {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return _v3.default;
40
+ }
41
+ });
42
+ Object.defineProperty(exports, "v5", {
43
+ enumerable: true,
44
+ get: function get() {
45
+ return _v4.default;
46
+ }
47
+ });
48
+ Object.defineProperty(exports, "validate", {
49
+ enumerable: true,
50
+ get: function get() {
51
+ return _validate.default;
52
+ }
53
+ });
54
+ Object.defineProperty(exports, "version", {
55
+ enumerable: true,
56
+ get: function get() {
57
+ return _version.default;
58
+ }
59
+ });
60
+
61
+ var _v = _interopRequireDefault(require("./v1.js"));
62
+
63
+ var _v2 = _interopRequireDefault(require("./v3.js"));
64
+
65
+ var _v3 = _interopRequireDefault(require("./v4.js"));
66
+
67
+ var _v4 = _interopRequireDefault(require("./v5.js"));
68
+
69
+ var _nil = _interopRequireDefault(require("./nil.js"));
70
+
71
+ var _version = _interopRequireDefault(require("./version.js"));
72
+
73
+ var _validate = _interopRequireDefault(require("./validate.js"));
74
+
75
+ var _stringify = _interopRequireDefault(require("./stringify.js"));
76
+
77
+ var _parse = _interopRequireDefault(require("./parse.js"));
78
+
79
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
@@ -0,0 +1,223 @@
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
+ const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
31
+
32
+ bytes = new Uint8Array(msg.length);
33
+
34
+ for (let i = 0; i < msg.length; ++i) {
35
+ bytes[i] = msg.charCodeAt(i);
36
+ }
37
+ }
38
+
39
+ return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
40
+ }
41
+ /*
42
+ * Convert an array of little-endian words to an array of bytes
43
+ */
44
+
45
+
46
+ function md5ToHexEncodedArray(input) {
47
+ const output = [];
48
+ const length32 = input.length * 32;
49
+ const hexTab = '0123456789abcdef';
50
+
51
+ for (let i = 0; i < length32; i += 8) {
52
+ const x = input[i >> 5] >>> i % 32 & 0xff;
53
+ const hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
54
+ output.push(hex);
55
+ }
56
+
57
+ return output;
58
+ }
59
+ /**
60
+ * Calculate output length with padding and bit length
61
+ */
62
+
63
+
64
+ function getOutputLength(inputLength8) {
65
+ return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
66
+ }
67
+ /*
68
+ * Calculate the MD5 of an array of little-endian words, and a bit length.
69
+ */
70
+
71
+
72
+ function wordsToMd5(x, len) {
73
+ /* append padding */
74
+ x[len >> 5] |= 0x80 << len % 32;
75
+ x[getOutputLength(len) - 1] = len;
76
+ let a = 1732584193;
77
+ let b = -271733879;
78
+ let c = -1732584194;
79
+ let d = 271733878;
80
+
81
+ for (let i = 0; i < x.length; i += 16) {
82
+ const olda = a;
83
+ const oldb = b;
84
+ const oldc = c;
85
+ const oldd = d;
86
+ a = md5ff(a, b, c, d, x[i], 7, -680876936);
87
+ d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
88
+ c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
89
+ b = md5ff(b, c, d, a, x[i + 3], 22, -1044525330);
90
+ a = md5ff(a, b, c, d, x[i + 4], 7, -176418897);
91
+ d = md5ff(d, a, b, c, x[i + 5], 12, 1200080426);
92
+ c = md5ff(c, d, a, b, x[i + 6], 17, -1473231341);
93
+ b = md5ff(b, c, d, a, x[i + 7], 22, -45705983);
94
+ a = md5ff(a, b, c, d, x[i + 8], 7, 1770035416);
95
+ d = md5ff(d, a, b, c, x[i + 9], 12, -1958414417);
96
+ c = md5ff(c, d, a, b, x[i + 10], 17, -42063);
97
+ b = md5ff(b, c, d, a, x[i + 11], 22, -1990404162);
98
+ a = md5ff(a, b, c, d, x[i + 12], 7, 1804603682);
99
+ d = md5ff(d, a, b, c, x[i + 13], 12, -40341101);
100
+ c = md5ff(c, d, a, b, x[i + 14], 17, -1502002290);
101
+ b = md5ff(b, c, d, a, x[i + 15], 22, 1236535329);
102
+ a = md5gg(a, b, c, d, x[i + 1], 5, -165796510);
103
+ d = md5gg(d, a, b, c, x[i + 6], 9, -1069501632);
104
+ c = md5gg(c, d, a, b, x[i + 11], 14, 643717713);
105
+ b = md5gg(b, c, d, a, x[i], 20, -373897302);
106
+ a = md5gg(a, b, c, d, x[i + 5], 5, -701558691);
107
+ d = md5gg(d, a, b, c, x[i + 10], 9, 38016083);
108
+ c = md5gg(c, d, a, b, x[i + 15], 14, -660478335);
109
+ b = md5gg(b, c, d, a, x[i + 4], 20, -405537848);
110
+ a = md5gg(a, b, c, d, x[i + 9], 5, 568446438);
111
+ d = md5gg(d, a, b, c, x[i + 14], 9, -1019803690);
112
+ c = md5gg(c, d, a, b, x[i + 3], 14, -187363961);
113
+ b = md5gg(b, c, d, a, x[i + 8], 20, 1163531501);
114
+ a = md5gg(a, b, c, d, x[i + 13], 5, -1444681467);
115
+ d = md5gg(d, a, b, c, x[i + 2], 9, -51403784);
116
+ c = md5gg(c, d, a, b, x[i + 7], 14, 1735328473);
117
+ b = md5gg(b, c, d, a, x[i + 12], 20, -1926607734);
118
+ a = md5hh(a, b, c, d, x[i + 5], 4, -378558);
119
+ d = md5hh(d, a, b, c, x[i + 8], 11, -2022574463);
120
+ c = md5hh(c, d, a, b, x[i + 11], 16, 1839030562);
121
+ b = md5hh(b, c, d, a, x[i + 14], 23, -35309556);
122
+ a = md5hh(a, b, c, d, x[i + 1], 4, -1530992060);
123
+ d = md5hh(d, a, b, c, x[i + 4], 11, 1272893353);
124
+ c = md5hh(c, d, a, b, x[i + 7], 16, -155497632);
125
+ b = md5hh(b, c, d, a, x[i + 10], 23, -1094730640);
126
+ a = md5hh(a, b, c, d, x[i + 13], 4, 681279174);
127
+ d = md5hh(d, a, b, c, x[i], 11, -358537222);
128
+ c = md5hh(c, d, a, b, x[i + 3], 16, -722521979);
129
+ b = md5hh(b, c, d, a, x[i + 6], 23, 76029189);
130
+ a = md5hh(a, b, c, d, x[i + 9], 4, -640364487);
131
+ d = md5hh(d, a, b, c, x[i + 12], 11, -421815835);
132
+ c = md5hh(c, d, a, b, x[i + 15], 16, 530742520);
133
+ b = md5hh(b, c, d, a, x[i + 2], 23, -995338651);
134
+ a = md5ii(a, b, c, d, x[i], 6, -198630844);
135
+ d = md5ii(d, a, b, c, x[i + 7], 10, 1126891415);
136
+ c = md5ii(c, d, a, b, x[i + 14], 15, -1416354905);
137
+ b = md5ii(b, c, d, a, x[i + 5], 21, -57434055);
138
+ a = md5ii(a, b, c, d, x[i + 12], 6, 1700485571);
139
+ d = md5ii(d, a, b, c, x[i + 3], 10, -1894986606);
140
+ c = md5ii(c, d, a, b, x[i + 10], 15, -1051523);
141
+ b = md5ii(b, c, d, a, x[i + 1], 21, -2054922799);
142
+ a = md5ii(a, b, c, d, x[i + 8], 6, 1873313359);
143
+ d = md5ii(d, a, b, c, x[i + 15], 10, -30611744);
144
+ c = md5ii(c, d, a, b, x[i + 6], 15, -1560198380);
145
+ b = md5ii(b, c, d, a, x[i + 13], 21, 1309151649);
146
+ a = md5ii(a, b, c, d, x[i + 4], 6, -145523070);
147
+ d = md5ii(d, a, b, c, x[i + 11], 10, -1120210379);
148
+ c = md5ii(c, d, a, b, x[i + 2], 15, 718787259);
149
+ b = md5ii(b, c, d, a, x[i + 9], 21, -343485551);
150
+ a = safeAdd(a, olda);
151
+ b = safeAdd(b, oldb);
152
+ c = safeAdd(c, oldc);
153
+ d = safeAdd(d, oldd);
154
+ }
155
+
156
+ return [a, b, c, d];
157
+ }
158
+ /*
159
+ * Convert an array bytes to an array of little-endian words
160
+ * Characters >255 have their high-byte silently ignored.
161
+ */
162
+
163
+
164
+ function bytesToWords(input) {
165
+ if (input.length === 0) {
166
+ return [];
167
+ }
168
+
169
+ const length8 = input.length * 8;
170
+ const output = new Uint32Array(getOutputLength(length8));
171
+
172
+ for (let i = 0; i < length8; i += 8) {
173
+ output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
174
+ }
175
+
176
+ return output;
177
+ }
178
+ /*
179
+ * Add integers, wrapping at 2^32. This uses 16-bit operations internally
180
+ * to work around bugs in some JS interpreters.
181
+ */
182
+
183
+
184
+ function safeAdd(x, y) {
185
+ const lsw = (x & 0xffff) + (y & 0xffff);
186
+ const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
187
+ return msw << 16 | lsw & 0xffff;
188
+ }
189
+ /*
190
+ * Bitwise rotate a 32-bit number to the left.
191
+ */
192
+
193
+
194
+ function bitRotateLeft(num, cnt) {
195
+ return num << cnt | num >>> 32 - cnt;
196
+ }
197
+ /*
198
+ * These functions implement the four basic operations the algorithm uses.
199
+ */
200
+
201
+
202
+ function md5cmn(q, a, b, x, s, t) {
203
+ return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
204
+ }
205
+
206
+ function md5ff(a, b, c, d, x, s, t) {
207
+ return md5cmn(b & c | ~b & d, a, b, x, s, t);
208
+ }
209
+
210
+ function md5gg(a, b, c, d, x, s, t) {
211
+ return md5cmn(b & d | c & ~d, a, b, x, s, t);
212
+ }
213
+
214
+ function md5hh(a, b, c, d, x, s, t) {
215
+ return md5cmn(b ^ c ^ d, a, b, x, s, t);
216
+ }
217
+
218
+ function md5ii(a, b, c, d, x, s, t) {
219
+ return md5cmn(c ^ (b | ~d), a, b, x, s, t);
220
+ }
221
+
222
+ var _default = md5;
223
+ exports.default = _default;
@@ -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;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = '00000000-0000-0000-0000-000000000000';
8
+ exports.default = _default;
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+
8
+ var _validate = _interopRequireDefault(require("./validate.js"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
+
12
+ function parse(uuid) {
13
+ if (!(0, _validate.default)(uuid)) {
14
+ throw TypeError('Invalid UUID');
15
+ }
16
+
17
+ let v;
18
+ const arr = new Uint8Array(16); // Parse ########-....-....-....-............
19
+
20
+ arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
21
+ arr[1] = v >>> 16 & 0xff;
22
+ arr[2] = v >>> 8 & 0xff;
23
+ arr[3] = v & 0xff; // Parse ........-####-....-....-............
24
+
25
+ arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
26
+ arr[5] = v & 0xff; // Parse ........-....-####-....-............
27
+
28
+ arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
29
+ arr[7] = v & 0xff; // Parse ........-....-....-####-............
30
+
31
+ arr[8] = (v = parseInt(uuid.slice(19, 23), 16)) >>> 8;
32
+ arr[9] = v & 0xff; // Parse ........-....-....-....-############
33
+ // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
34
+
35
+ arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
36
+ arr[11] = v / 0x100000000 & 0xff;
37
+ arr[12] = v >>> 24 & 0xff;
38
+ arr[13] = v >>> 16 & 0xff;
39
+ arr[14] = v >>> 8 & 0xff;
40
+ arr[15] = v & 0xff;
41
+ return arr;
42
+ }
43
+
44
+ var _default = parse;
45
+ exports.default = _default;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i;
8
+ exports.default = _default;
@@ -0,0 +1,25 @@
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
+ let getRandomValues;
11
+ const rnds8 = new Uint8Array(16);
12
+
13
+ function rng() {
14
+ // lazy load so that environments that need to polyfill have a chance to do so
15
+ if (!getRandomValues) {
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);
18
+
19
+ if (!getRandomValues) {
20
+ throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
21
+ }
22
+ }
23
+
24
+ return getRandomValues(rnds8);
25
+ }