uuid 9.0.0 → 10.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 (89) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +140 -18
  3. package/dist/commonjs-browser/index.js +40 -15
  4. package/dist/commonjs-browser/max.js +7 -0
  5. package/dist/commonjs-browser/md5.js +30 -53
  6. package/dist/commonjs-browser/native.js +3 -4
  7. package/dist/commonjs-browser/nil.js +1 -2
  8. package/dist/commonjs-browser/parse.js +14 -15
  9. package/dist/commonjs-browser/regex.js +1 -2
  10. package/dist/commonjs-browser/rng.js +2 -4
  11. package/dist/commonjs-browser/sha1.js +27 -49
  12. package/dist/commonjs-browser/stringify.js +9 -15
  13. package/dist/commonjs-browser/v1.js +73 -49
  14. package/dist/commonjs-browser/v1ToV6.js +26 -0
  15. package/dist/commonjs-browser/v3.js +3 -8
  16. package/dist/commonjs-browser/v35.js +15 -32
  17. package/dist/commonjs-browser/v4.js +7 -18
  18. package/dist/commonjs-browser/v5.js +3 -8
  19. package/dist/commonjs-browser/v6.js +42 -0
  20. package/dist/commonjs-browser/v6ToV1.js +26 -0
  21. package/dist/commonjs-browser/v7.js +152 -0
  22. package/dist/commonjs-browser/validate.js +2 -7
  23. package/dist/commonjs-browser/version.js +2 -8
  24. package/dist/esm-browser/index.js +9 -4
  25. package/dist/esm-browser/max.js +1 -0
  26. package/dist/esm-browser/md5.js +29 -50
  27. package/dist/esm-browser/native.js +1 -1
  28. package/dist/esm-browser/parse.js +12 -10
  29. package/dist/esm-browser/regex.js +1 -1
  30. package/dist/esm-browser/rng.js +3 -4
  31. package/dist/esm-browser/sha1.js +26 -46
  32. package/dist/esm-browser/stringify.js +8 -10
  33. package/dist/esm-browser/v1.js +74 -44
  34. package/dist/esm-browser/v1ToV6.js +20 -0
  35. package/dist/esm-browser/v3.js +1 -1
  36. package/dist/esm-browser/v35.js +14 -25
  37. package/dist/esm-browser/v4.js +5 -9
  38. package/dist/esm-browser/v5.js +1 -1
  39. package/dist/esm-browser/v6.js +36 -0
  40. package/dist/esm-browser/v6ToV1.js +20 -0
  41. package/dist/esm-browser/v7.js +146 -0
  42. package/dist/esm-browser/validate.js +0 -2
  43. package/dist/esm-browser/version.js +0 -3
  44. package/dist/esm-node/index.js +9 -4
  45. package/dist/esm-node/max.js +1 -0
  46. package/dist/esm-node/md5.js +1 -4
  47. package/dist/esm-node/native.js +1 -1
  48. package/dist/esm-node/parse.js +11 -9
  49. package/dist/esm-node/regex.js +1 -1
  50. package/dist/esm-node/rng.js +1 -3
  51. package/dist/esm-node/sha1.js +1 -4
  52. package/dist/esm-node/stringify.js +6 -8
  53. package/dist/esm-node/v1.js +66 -36
  54. package/dist/esm-node/v1ToV6.js +20 -0
  55. package/dist/esm-node/v35.js +8 -19
  56. package/dist/esm-node/v4.js +4 -8
  57. package/dist/esm-node/v6.js +32 -0
  58. package/dist/esm-node/v6ToV1.js +20 -0
  59. package/dist/esm-node/v7.js +146 -0
  60. package/dist/esm-node/validate.js +0 -2
  61. package/dist/esm-node/version.js +0 -3
  62. package/dist/index.js +40 -15
  63. package/dist/max.js +7 -0
  64. package/dist/md5-browser.js +8 -31
  65. package/dist/md5.js +4 -10
  66. package/dist/native-browser.js +2 -3
  67. package/dist/native.js +5 -9
  68. package/dist/nil.js +1 -2
  69. package/dist/parse.js +13 -14
  70. package/dist/regex.js +1 -2
  71. package/dist/rng-browser.js +1 -3
  72. package/dist/rng.js +3 -10
  73. package/dist/sha1-browser.js +1 -23
  74. package/dist/sha1.js +4 -10
  75. package/dist/stringify.js +7 -13
  76. package/dist/uuid-bin.js +12 -22
  77. package/dist/v1.js +66 -42
  78. package/dist/v1ToV6.js +26 -0
  79. package/dist/v3.js +2 -7
  80. package/dist/v35.js +11 -28
  81. package/dist/v4.js +6 -17
  82. package/dist/v5.js +2 -7
  83. package/dist/v6.js +38 -0
  84. package/dist/v6ToV1.js +26 -0
  85. package/dist/v7.js +152 -0
  86. package/dist/validate.js +2 -7
  87. package/dist/version.js +2 -8
  88. package/package.json +46 -35
  89. package/wrapper.mjs +5 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,30 @@
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
+ ## [10.0.0](https://github.com/uuidjs/uuid/compare/v9.0.0...v10.0.0) (2024-06-07)
6
+
7
+ ### ⚠ BREAKING CHANGES
8
+
9
+ - update node support (drop node@12, node@14, add node@20) (#750)
10
+
11
+ ### Features
12
+
13
+ - support support rfc9562 MAX uuid (new in RFC9562) ([#714](https://github.com/uuidjs/uuid/issues/714)) ([0385cd3](https://github.com/uuidjs/uuid/commit/0385cd3f18ae9920678b2849932fa7a9d9aee7d0))
14
+ - support rfc9562 v6 uuids ([#754](https://github.com/uuidjs/uuid/issues/754)) ([c4ed13e](https://github.com/uuidjs/uuid/commit/c4ed13e7159d87c9e42a349bdd9dc955f1af46b6))
15
+ - support rfc9562 v7 uuids ([#681](https://github.com/uuidjs/uuid/issues/681)) ([db76a12](https://github.com/uuidjs/uuid/commit/db76a1284760c441438f50a57924b322dae08891))
16
+ - update node support matrix (only support node 16-20) ([#750](https://github.com/uuidjs/uuid/issues/750)) ([883b163](https://github.com/uuidjs/uuid/commit/883b163b9ab9d6655bfbd8a35e61a3c71674dfe1))
17
+ - support rfc9562 v8 uuids ([#759](https://github.com/uuidjs/uuid/issues/759)) ([35a5342](https://github.com/uuidjs/uuid/commit/35a53428202657e402e6b4aa68f56c08194541bf))
18
+
19
+ ### Bug Fixes
20
+
21
+ - revert "perf: remove superfluous call to toLowerCase ([#677](https://github.com/uuidjs/uuid/issues/677))" ([#738](https://github.com/uuidjs/uuid/issues/738)) ([e267b90](https://github.com/uuidjs/uuid/commit/e267b9073df1d0ce119ee53c0487fe76acb2be37))
22
+
23
+ ## [9.0.1](https://github.com/uuidjs/uuid/compare/v9.0.0...v9.0.1) (2023-09-12)
24
+
25
+ ### build
26
+
27
+ - Fix CI to work with Node.js 20.x
28
+
5
29
  ## [9.0.0](https://github.com/uuidjs/uuid/compare/v8.3.2...v9.0.0) (2022-09-05)
6
30
 
7
31
  ### ⚠ BREAKING CHANGES
package/README.md CHANGED
@@ -2,14 +2,15 @@
2
2
  -- This file is auto-generated from README_js.md. Changes should be made there.
3
3
  -->
4
4
 
5
+
5
6
  # 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
7
 
7
- For the creation of [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) UUIDs
8
+ For the creation of [RFC9562](https://www.rfc-editor.org/rfc/rfc9562.html) (formally [RFC4122](https://www.rfc-editor.org/rfc/rfc4122.html)) UUIDs
8
9
 
9
- - **Complete** - Support for RFC4122 version 1, 3, 4, and 5 UUIDs
10
+ - **Complete** - Support for all RFC9562 (nee RFC4122) UUID versions
10
11
  - **Cross-platform** - Support for ...
11
12
  - CommonJS, [ECMAScript Modules](#ecmascript-modules) and [CDN builds](#cdn-builds)
12
- - Node 12, 14, 16, 18
13
+ - NodeJS 16+ ([LTS releases](https://github.com/nodejs/Release))
13
14
  - Chrome, Safari, Firefox, Edge browsers
14
15
  - Webpack and rollup.js module bundlers
15
16
  - [React Native / Expo](#react-native--expo)
@@ -17,7 +18,13 @@ For the creation of [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) UUIDs
17
18
  - **Small** - Zero-dependency, small footprint, plays nice with "tree shaking" packagers
18
19
  - **CLI** - Includes the [`uuid` command line](#command-line) utility
19
20
 
20
- **Upgrading from `uuid@3`?** Your code is probably okay, but check out [Upgrading From `uuid@3`](#upgrading-from-uuid3) for details.
21
+ <!-- prettier-ignore -->
22
+ > [!NOTE]
23
+ > Upgrading from `uuid@3`? Your code is probably okay, but check out [Upgrading From `uuid@3`](#upgrading-from-uuid3) for details.
24
+
25
+ <!-- prettier-ignore -->
26
+ > [!NOTE]
27
+ > Only interested in creating a version 4 UUID? You might be able to use [`crypto.randomUUID()`](https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID), eliminating the need to install this library.
21
28
 
22
29
  ## Quickstart
23
30
 
@@ -50,12 +57,18 @@ For timestamp UUIDs, namespace UUIDs, and other options read on ...
50
57
  | | | |
51
58
  | --- | --- | --- |
52
59
  | [`uuid.NIL`](#uuidnil) | The nil UUID string (all zeros) | New in `uuid@8.3` |
60
+ | [`uuid.MAX`](#uuidmax) | The max UUID string (all ones) | New in `uuid@9.1` |
53
61
  | [`uuid.parse()`](#uuidparsestr) | Convert UUID string to array of bytes | New in `uuid@8.3` |
54
62
  | [`uuid.stringify()`](#uuidstringifyarr-offset) | Convert array of bytes to UUID string | New in `uuid@8.3` |
55
63
  | [`uuid.v1()`](#uuidv1options-buffer-offset) | Create a version 1 (timestamp) UUID | |
64
+ | [`uuid.v1ToV6()`](#uuidv1tov6uuid) | Create a version 6 UUID from a version 1 UUID | New in `uuid@10` |
56
65
  | [`uuid.v3()`](#uuidv3name-namespace-buffer-offset) | Create a version 3 (namespace w/ MD5) UUID | |
57
66
  | [`uuid.v4()`](#uuidv4options-buffer-offset) | Create a version 4 (random) UUID | |
58
67
  | [`uuid.v5()`](#uuidv5name-namespace-buffer-offset) | Create a version 5 (namespace w/ SHA-1) UUID | |
68
+ | [`uuid.v6()`](#uuidv6options-buffer-offset) | Create a version 6 (timestamp, reordered) UUID | New in `uuid@10` |
69
+ | [`uuid.v6ToV1()`](#uuidv6tov1uuid) | Create a version 1 UUID from a version 6 UUID | New in `uuid@10` |
70
+ | [`uuid.v7()`](#uuidv7options-buffer-offset) | Create a version 7 (Unix Epoch time-based) UUID | New in `uuid@10` |
71
+ | ~~[`uuid.v8()`](#uuidv8)~~ | "Intentionally left blank" | |
59
72
  | [`uuid.validate()`](#uuidvalidatestr) | Test a string to see if it is a valid UUID | New in `uuid@8.3` |
60
73
  | [`uuid.version()`](#uuidversionstr) | Detect RFC version of a UUID | New in `uuid@8.3` |
61
74
 
@@ -73,6 +86,18 @@ import { NIL as NIL_UUID } from 'uuid';
73
86
  NIL_UUID; // ⇨ '00000000-0000-0000-0000-000000000000'
74
87
  ```
75
88
 
89
+ ### uuid.MAX
90
+
91
+ The max UUID string (all ones).
92
+
93
+ Example:
94
+
95
+ ```javascript
96
+ import { MAX as MAX_UUID } from 'uuid';
97
+
98
+ MAX_UUID; // ⇨ 'ffffffff-ffff-ffff-ffff-ffffffffffff'
99
+ ```
100
+
76
101
  ### uuid.parse(str)
77
102
 
78
103
  Convert UUID string to array of bytes
@@ -83,7 +108,9 @@ Convert UUID string to array of bytes
83
108
  | _returns_ | `Uint8Array[16]` |
84
109
  | _throws_ | `TypeError` if `str` is not a valid UUID |
85
110
 
86
- Note: Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left &Rarr; right order of hex-pairs in UUID strings. As shown in the example below.
111
+ <!-- prettier-ignore -->
112
+ > [!NOTE]
113
+ > Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left &Rarr; right order of hex-pairs in UUID strings. As shown in the example below.
87
114
 
88
115
  Example:
89
116
 
@@ -94,7 +121,7 @@ import { parse as uuidParse } from 'uuid';
94
121
  const bytes = uuidParse('6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b');
95
122
 
96
123
  // Convert to hex strings to show byte order (for documentation purposes)
97
- [...bytes].map((v) => v.toString(16).padStart(2, '0')); // ⇨
124
+ [...bytes].map((v) => v.toString(16).padStart(2, '0')); // ⇨
98
125
  // [
99
126
  // '6e', 'c0', 'bd', '7f',
100
127
  // '11', 'c0', '43', 'da',
@@ -114,7 +141,9 @@ Convert array of bytes to UUID string
114
141
  | _returns_ | `String` |
115
142
  | _throws_ | `TypeError` if a valid UUID string cannot be generated |
116
143
 
117
- Note: Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left &Rarr; right order of hex-pairs in UUID strings. As shown in the example below.
144
+ <!-- prettier-ignore -->
145
+ > [!NOTE]
146
+ > Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left &Rarr; right order of hex-pairs in UUID strings. As shown in the example below.
118
147
 
119
148
  Example:
120
149
 
@@ -138,7 +167,7 @@ Create an RFC version 1 (timestamp) UUID
138
167
  | [`options.node` ] | RFC "node" field as an `Array[6]` of byte values (per 4.1.6) |
139
168
  | [`options.clockseq`] | RFC "clock sequence" as a `Number` between 0 - 0x3fff |
140
169
  | [`options.msecs`] | RFC "timestamp" field (`Number` of milliseconds, unix epoch) |
141
- | [`options.nsecs`] | RFC "timestamp" field (`Number` of nanseconds to add to `msecs`, should be 0-10,000) |
170
+ | [`options.nsecs`] | RFC "timestamp" field (`Number` of nanoseconds to add to `msecs`, should be 0-10,000) |
142
171
  | [`options.random`] | `Array` of 16 random bytes (0-255) |
143
172
  | [`options.rng`] | Alternative to `options.random`, a `Function` that returns an `Array` of 16 random bytes (0-255) |
144
173
  | [`buffer`] | `Array \| Buffer` If specified, uuid will be written here in byte-form, starting at `offset` |
@@ -146,9 +175,13 @@ Create an RFC version 1 (timestamp) UUID
146
175
  | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
147
176
  | _throws_ | `Error` if more than 10M UUIDs/sec are requested |
148
177
 
149
- Note: The default [node id](https://tools.ietf.org/html/rfc4122#section-4.1.6) (the last 12 digits in the UUID) is generated once, randomly, on process startup, and then remains unchanged for the duration of the process.
178
+ <!-- prettier-ignore -->
179
+ > [!NOTE]
180
+ > The default [node id](https://datatracker.ietf.org/doc/html/rfc9562#section-5.1) (the last 12 digits in the UUID) is generated once, randomly, on process startup, and then remains unchanged for the duration of the process.
150
181
 
151
- Note: `options.random` and `options.rng` are only meaningful on the very first call to `v1()`, where they may be passed to initialize the internal `node` and `clockseq` fields.
182
+ <!-- prettier-ignore -->
183
+ > [!NOTE]
184
+ > `options.random` and `options.rng` are only meaningful on the very first call to `v1()`, where they may be passed to initialize the internal `node` and `clockseq` fields.
152
185
 
153
186
  Example:
154
187
 
@@ -163,13 +196,23 @@ Example using `options`:
163
196
  ```javascript
164
197
  import { v1 as uuidv1 } from 'uuid';
165
198
 
166
- const v1options = {
199
+ const options = {
167
200
  node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
168
201
  clockseq: 0x1234,
169
202
  msecs: new Date('2011-11-01').getTime(),
170
203
  nsecs: 5678,
171
204
  };
172
- uuidv1(v1options); // ⇨ '710b962e-041c-11e1-9234-0123456789ab'
205
+ uuidv1(options); // ⇨ '710b962e-041c-11e1-9234-0123456789ab'
206
+ ```
207
+
208
+ ### uuid.v1ToV6(uuid)
209
+
210
+ Convert a UUID from version 1 to version 6
211
+
212
+ ```javascript
213
+ import { v1ToV6 } from 'uuid';
214
+
215
+ v1ToV6('92f62d9e-22c4-11ef-97e9-325096b39f47'); // ⇨ '1ef22c49-2f62-6d9e-97e9-325096b39f47'
173
216
  ```
174
217
 
175
218
  ### uuid.v3(name, namespace[, buffer[, offset]])
@@ -178,7 +221,9 @@ Create an RFC version 3 (namespace w/ MD5) UUID
178
221
 
179
222
  API is identical to `v5()`, but uses "v3" instead.
180
223
 
181
- &#x26a0;&#xfe0f; Note: Per the RFC, "_If backward compatibility is not an issue, SHA-1 [Version 5] is preferred_."
224
+ <!-- prettier-ignore -->
225
+ > [!IMPORTANT]
226
+ > Per the RFC, "_If backward compatibility is not an issue, SHA-1 [Version 5] is preferred_."
182
227
 
183
228
  ### uuid.v4([options[, buffer[, offset]]])
184
229
 
@@ -226,7 +271,9 @@ Create an RFC version 5 (namespace w/ SHA-1) UUID
226
271
  | [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` |
227
272
  | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
228
273
 
229
- Note: The RFC `DNS` and `URL` namespaces are available as `v5.DNS` and `v5.URL`.
274
+ <!-- prettier-ignore -->
275
+ > [!NOTE]
276
+ > The RFC `DNS` and `URL` namespaces are available as `v5.DNS` and `v5.URL`.
230
277
 
231
278
  Example with custom namespace:
232
279
 
@@ -248,6 +295,73 @@ import { v5 as uuidv5 } from 'uuid';
248
295
  uuidv5('https://www.w3.org/', uuidv5.URL); // ⇨ 'c106a26a-21bb-5538-8bf2-57095d1976c1'
249
296
  ```
250
297
 
298
+ ### uuid.v6([options[, buffer[, offset]]])
299
+
300
+ Create an RFC version 6 (timestamp, reordered) UUID
301
+
302
+ This method takes the same arguments as uuid.v1().
303
+
304
+ ```javascript
305
+ import { v6 as uuidv6 } from 'uuid';
306
+
307
+ uuidv6(); // ⇨ '1e940672-c5ea-64c0-8bad-9b1deb4d3b7d'
308
+ ```
309
+
310
+ Example using `options`:
311
+
312
+ ```javascript
313
+ import { v6 as uuidv6 } from 'uuid';
314
+
315
+ const options = {
316
+ node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
317
+ clockseq: 0x1234,
318
+ msecs: new Date('2011-11-01').getTime(),
319
+ nsecs: 5678,
320
+ };
321
+ uuidv6(options); // ⇨ '1e1041c7-10b9-662e-9234-0123456789ab'
322
+ ```
323
+
324
+ ### uuid.v6ToV1(uuid)
325
+
326
+ Convert a UUID from version 6 to version 1
327
+
328
+ ```javascript
329
+ import { v6ToV1 } from 'uuid';
330
+
331
+ v6ToV1('1ef22c49-2f62-6d9e-97e9-325096b39f47'); // ⇨ '92f62d9e-22c4-11ef-97e9-325096b39f47'
332
+ ```
333
+
334
+ ### uuid.v7([options[, buffer[, offset]]])
335
+
336
+ Create an RFC version 7 (random) UUID
337
+
338
+ | | |
339
+ | --- | --- |
340
+ | [`options`] | `Object` with one or more of the following properties: |
341
+ | [`options.msecs`] | RFC "timestamp" field (`Number` of milliseconds, unix epoch) |
342
+ | [`options.random`] | `Array` of 16 random bytes (0-255) |
343
+ | [`options.rng`] | Alternative to `options.random`, a `Function` that returns an `Array` of 16 random bytes (0-255) |
344
+ | [`options.seq`] | 31 bit monotonic sequence counter as `Number` between 0 - 0x7fffffff |
345
+ | [`buffer`] | `Array \| Buffer` If specified, uuid will be written here in byte-form, starting at `offset` |
346
+ | [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` |
347
+ | _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` |
348
+
349
+ Example:
350
+
351
+ ```javascript
352
+ import { v7 as uuidv7 } from 'uuid';
353
+
354
+ uuidv7(); // ⇨ '01695553-c90c-722d-9b5d-b38dfbbd4bed'
355
+ ```
356
+
357
+ ### ~~uuid.v8()~~
358
+
359
+ **_"Intentionally left blank"_**
360
+
361
+ <!-- prettier-ignore -->
362
+ > [!NOTE]
363
+ > Version 8 (experimental) UUIDs are "[for experimental or vendor-specific use cases](https://www.rfc-editor.org/rfc/rfc9562.html#name-uuid-version-8)". The RFC does not define a creation algorithm for them, which is why this package does not offer a `v8()` method. The `validate()` and `version()` methods do work with such UUIDs, however.
364
+
251
365
  ### uuid.validate(str)
252
366
 
253
367
  Test a string to see if it is a valid UUID
@@ -302,6 +416,10 @@ uuidVersion('45637ec4-c85f-11ea-87d0-0242ac130003'); // ⇨ 1
302
416
  uuidVersion('6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b'); // ⇨ 4
303
417
  ```
304
418
 
419
+ <!-- prettier-ignore -->
420
+ > [!NOTE]
421
+ > This method returns `0` for the `NIL` UUID, and `15` for the `MAX` UUID.
422
+
305
423
  ## Command Line
306
424
 
307
425
  UUIDs can be generated from the command line using `uuid`.
@@ -322,10 +440,11 @@ Usage:
322
440
  uuid v3 <name> <namespace uuid>
323
441
  uuid v4
324
442
  uuid v5 <name> <namespace uuid>
443
+ uuid v7
325
444
  uuid --help
326
445
 
327
446
  Note: <namespace uuid> may be "URL" or "DNS" to use the corresponding UUIDs
328
- defined by RFC4122
447
+ defined by RFC9562
329
448
  ```
330
449
 
331
450
  ## ECMAScript Modules
@@ -385,7 +504,9 @@ import 'react-native-get-random-values';
385
504
  import { v4 as uuidv4 } from 'uuid';
386
505
  ```
387
506
 
388
- Note: If you are using Expo, you must be using at least `react-native-get-random-values@1.5.0` and `expo@39.0.0`.
507
+ <!-- prettier-ignore -->
508
+ > [!NOTE]
509
+ > If you are using Expo, you must be using at least `react-native-get-random-values@1.5.0` and `expo@39.0.0`.
389
510
 
390
511
  ### Web Workers / Service Workers (Edge <= 18)
391
512
 
@@ -458,5 +579,6 @@ const uuid = require('uuid'); // <== REMOVED!
458
579
 
459
580
  This usage pattern was already discouraged in `uuid@3` and has been removed in `uuid@7`.
460
581
 
461
- ----
462
- Markdown generated from [README_js.md](README_js.md) by [![RunMD Logo](https://i.imgur.com/h0FVyzU.png)](https://github.com/broofa/runmd)
582
+ ---
583
+
584
+ Markdown generated from [README_js.md](README_js.md) by <a href="https://github.com/broofa/runmd"><image height="12px" src="https://camo.githubusercontent.com/5c7c603cd1e6a43370b0a5063d457e0dabb74cf317adc7baba183acb686ee8d0/687474703a2f2f692e696d6775722e636f6d2f634a4b6f3662552e706e67" /></a>
@@ -3,6 +3,12 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
+ Object.defineProperty(exports, "MAX", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _max.default;
10
+ }
11
+ });
6
12
  Object.defineProperty(exports, "NIL", {
7
13
  enumerable: true,
8
14
  get: function get() {
@@ -27,6 +33,12 @@ Object.defineProperty(exports, "v1", {
27
33
  return _v.default;
28
34
  }
29
35
  });
36
+ Object.defineProperty(exports, "v1ToV6", {
37
+ enumerable: true,
38
+ get: function get() {
39
+ return _v1ToV.default;
40
+ }
41
+ });
30
42
  Object.defineProperty(exports, "v3", {
31
43
  enumerable: true,
32
44
  get: function get() {
@@ -45,6 +57,24 @@ Object.defineProperty(exports, "v5", {
45
57
  return _v4.default;
46
58
  }
47
59
  });
60
+ Object.defineProperty(exports, "v6", {
61
+ enumerable: true,
62
+ get: function get() {
63
+ return _v5.default;
64
+ }
65
+ });
66
+ Object.defineProperty(exports, "v6ToV1", {
67
+ enumerable: true,
68
+ get: function get() {
69
+ return _v6ToV.default;
70
+ }
71
+ });
72
+ Object.defineProperty(exports, "v7", {
73
+ enumerable: true,
74
+ get: function get() {
75
+ return _v6.default;
76
+ }
77
+ });
48
78
  Object.defineProperty(exports, "validate", {
49
79
  enumerable: true,
50
80
  get: function get() {
@@ -57,23 +87,18 @@ Object.defineProperty(exports, "version", {
57
87
  return _version.default;
58
88
  }
59
89
  });
60
-
90
+ var _max = _interopRequireDefault(require("./max.js"));
91
+ var _nil = _interopRequireDefault(require("./nil.js"));
92
+ var _parse = _interopRequireDefault(require("./parse.js"));
93
+ var _stringify = _interopRequireDefault(require("./stringify.js"));
61
94
  var _v = _interopRequireDefault(require("./v1.js"));
62
-
95
+ var _v1ToV = _interopRequireDefault(require("./v1ToV6.js"));
63
96
  var _v2 = _interopRequireDefault(require("./v3.js"));
64
-
65
97
  var _v3 = _interopRequireDefault(require("./v4.js"));
66
-
67
98
  var _v4 = _interopRequireDefault(require("./v5.js"));
68
-
69
- var _nil = _interopRequireDefault(require("./nil.js"));
70
-
71
- var _version = _interopRequireDefault(require("./version.js"));
72
-
99
+ var _v5 = _interopRequireDefault(require("./v6.js"));
100
+ var _v6ToV = _interopRequireDefault(require("./v6ToV1.js"));
101
+ var _v6 = _interopRequireDefault(require("./v7.js"));
73
102
  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 }; }
103
+ var _version = _interopRequireDefault(require("./version.js"));
104
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _default = exports.default = 'ffffffff-ffff-ffff-ffff-ffffffffffff';
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  /*
9
8
  * Browser-compatible JavaScript MD5
10
9
  *
@@ -27,62 +26,54 @@ exports.default = void 0;
27
26
  */
28
27
  function md5(bytes) {
29
28
  if (typeof bytes === 'string') {
30
- const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
29
+ var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
31
30
 
32
31
  bytes = new Uint8Array(msg.length);
33
-
34
- for (let i = 0; i < msg.length; ++i) {
32
+ for (var i = 0; i < msg.length; ++i) {
35
33
  bytes[i] = msg.charCodeAt(i);
36
34
  }
37
35
  }
38
-
39
36
  return md5ToHexEncodedArray(wordsToMd5(bytesToWords(bytes), bytes.length * 8));
40
37
  }
38
+
41
39
  /*
42
40
  * Convert an array of little-endian words to an array of bytes
43
41
  */
44
-
45
-
46
42
  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);
43
+ var output = [];
44
+ var length32 = input.length * 32;
45
+ var hexTab = '0123456789abcdef';
46
+ for (var i = 0; i < length32; i += 8) {
47
+ var x = input[i >> 5] >>> i % 32 & 0xff;
48
+ var hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
54
49
  output.push(hex);
55
50
  }
56
-
57
51
  return output;
58
52
  }
53
+
59
54
  /**
60
55
  * Calculate output length with padding and bit length
61
56
  */
62
-
63
-
64
57
  function getOutputLength(inputLength8) {
65
58
  return (inputLength8 + 64 >>> 9 << 4) + 14 + 1;
66
59
  }
60
+
67
61
  /*
68
62
  * Calculate the MD5 of an array of little-endian words, and a bit length.
69
63
  */
70
-
71
-
72
64
  function wordsToMd5(x, len) {
73
65
  /* append padding */
74
66
  x[len >> 5] |= 0x80 << len % 32;
75
67
  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;
68
+ var a = 1732584193;
69
+ var b = -271733879;
70
+ var c = -1732584194;
71
+ var d = 271733878;
72
+ for (var i = 0; i < x.length; i += 16) {
73
+ var olda = a;
74
+ var oldb = b;
75
+ var oldc = c;
76
+ var oldd = d;
86
77
  a = md5ff(a, b, c, d, x[i], 7, -680876936);
87
78
  d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);
88
79
  c = md5ff(c, d, a, b, x[i + 2], 17, 606105819);
@@ -152,72 +143,58 @@ function wordsToMd5(x, len) {
152
143
  c = safeAdd(c, oldc);
153
144
  d = safeAdd(d, oldd);
154
145
  }
155
-
156
146
  return [a, b, c, d];
157
147
  }
148
+
158
149
  /*
159
150
  * Convert an array bytes to an array of little-endian words
160
151
  * Characters >255 have their high-byte silently ignored.
161
152
  */
162
-
163
-
164
153
  function bytesToWords(input) {
165
154
  if (input.length === 0) {
166
155
  return [];
167
156
  }
168
-
169
- const length8 = input.length * 8;
170
- const output = new Uint32Array(getOutputLength(length8));
171
-
172
- for (let i = 0; i < length8; i += 8) {
157
+ var length8 = input.length * 8;
158
+ var output = new Uint32Array(getOutputLength(length8));
159
+ for (var i = 0; i < length8; i += 8) {
173
160
  output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;
174
161
  }
175
-
176
162
  return output;
177
163
  }
164
+
178
165
  /*
179
166
  * Add integers, wrapping at 2^32. This uses 16-bit operations internally
180
167
  * to work around bugs in some JS interpreters.
181
168
  */
182
-
183
-
184
169
  function safeAdd(x, y) {
185
- const lsw = (x & 0xffff) + (y & 0xffff);
186
- const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
170
+ var lsw = (x & 0xffff) + (y & 0xffff);
171
+ var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
187
172
  return msw << 16 | lsw & 0xffff;
188
173
  }
174
+
189
175
  /*
190
176
  * Bitwise rotate a 32-bit number to the left.
191
177
  */
192
-
193
-
194
178
  function bitRotateLeft(num, cnt) {
195
179
  return num << cnt | num >>> 32 - cnt;
196
180
  }
181
+
197
182
  /*
198
183
  * These functions implement the four basic operations the algorithm uses.
199
184
  */
200
-
201
-
202
185
  function md5cmn(q, a, b, x, s, t) {
203
186
  return safeAdd(bitRotateLeft(safeAdd(safeAdd(a, q), safeAdd(x, t)), s), b);
204
187
  }
205
-
206
188
  function md5ff(a, b, c, d, x, s, t) {
207
189
  return md5cmn(b & c | ~b & d, a, b, x, s, t);
208
190
  }
209
-
210
191
  function md5gg(a, b, c, d, x, s, t) {
211
192
  return md5cmn(b & d | c & ~d, a, b, x, s, t);
212
193
  }
213
-
214
194
  function md5hh(a, b, c, d, x, s, t) {
215
195
  return md5cmn(b ^ c ^ d, a, b, x, s, t);
216
196
  }
217
-
218
197
  function md5ii(a, b, c, d, x, s, t) {
219
198
  return md5cmn(c ^ (b | ~d), a, b, x, s, t);
220
199
  }
221
-
222
- var _default = md5;
223
- exports.default = _default;
200
+ var _default = exports.default = md5;
@@ -4,8 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
8
- var _default = {
7
+ var randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
8
+ var _default = exports.default = {
9
9
  randomUUID
10
- };
11
- exports.default = _default;
10
+ };
@@ -4,5 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = '00000000-0000-0000-0000-000000000000';
8
- exports.default = _default;
7
+ var _default = exports.default = '00000000-0000-0000-0000-000000000000';
@@ -4,34 +4,35 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
-
8
7
  var _validate = _interopRequireDefault(require("./validate.js"));
9
-
10
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
11
-
8
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
12
9
  function parse(uuid) {
13
10
  if (!(0, _validate.default)(uuid)) {
14
11
  throw TypeError('Invalid UUID');
15
12
  }
13
+ var v;
14
+ var arr = new Uint8Array(16);
16
15
 
17
- let v;
18
- const arr = new Uint8Array(16); // Parse ########-....-....-....-............
19
-
16
+ // Parse ########-....-....-....-............
20
17
  arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;
21
18
  arr[1] = v >>> 16 & 0xff;
22
19
  arr[2] = v >>> 8 & 0xff;
23
- arr[3] = v & 0xff; // Parse ........-####-....-....-............
20
+ arr[3] = v & 0xff;
24
21
 
22
+ // Parse ........-####-....-....-............
25
23
  arr[4] = (v = parseInt(uuid.slice(9, 13), 16)) >>> 8;
26
- arr[5] = v & 0xff; // Parse ........-....-####-....-............
24
+ arr[5] = v & 0xff;
27
25
 
26
+ // Parse ........-....-####-....-............
28
27
  arr[6] = (v = parseInt(uuid.slice(14, 18), 16)) >>> 8;
29
- arr[7] = v & 0xff; // Parse ........-....-....-####-............
28
+ arr[7] = v & 0xff;
30
29
 
30
+ // Parse ........-....-....-####-............
31
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)
32
+ arr[9] = v & 0xff;
34
33
 
34
+ // Parse ........-....-....-....-############
35
+ // (Use "/" to avoid 32-bit truncation when bit-shifting high-order bytes)
35
36
  arr[10] = (v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000 & 0xff;
36
37
  arr[11] = v / 0x100000000 & 0xff;
37
38
  arr[12] = v >>> 24 & 0xff;
@@ -40,6 +41,4 @@ function parse(uuid) {
40
41
  arr[15] = v & 0xff;
41
42
  return arr;
42
43
  }
43
-
44
- var _default = parse;
45
- exports.default = _default;
44
+ var _default = exports.default = parse;
@@ -4,5 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
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;
7
+ var _default = exports.default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;