From ba84a97fb53f35d34c6640f860669bbbd7d8ce04 Mon Sep 17 00:00:00 2001 From: admin Date: Tue, 28 Apr 2026 12:13:38 +0000 Subject: [PATCH] =?UTF-8?q?Acgregado=20uuid=20para=20la=20genearci=C3=B3n?= =?UTF-8?q?=20del=20masterIdentifier?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bus-gateway/controllers/iti65.js | 10 +- bus-gateway/package-lock.json | 16 +- bus-gateway/package.json | 3 +- node_modules/.bin/uuid | 1 + node_modules/.package-lock.json | 20 + node_modules/uuid/LICENSE.md | 9 + node_modules/uuid/README.md | 491 +++++++++++++++++++++++ node_modules/uuid/dist-node/bin/uuid | 2 + node_modules/uuid/dist-node/index.js | 14 + node_modules/uuid/dist-node/max.js | 1 + node_modules/uuid/dist-node/md5.js | 11 + node_modules/uuid/dist-node/nil.js | 1 + node_modules/uuid/dist-node/parse.js | 9 + node_modules/uuid/dist-node/regex.js | 1 + node_modules/uuid/dist-node/rng.js | 4 + node_modules/uuid/dist-node/sha1.js | 11 + node_modules/uuid/dist-node/stringify.js | 35 ++ node_modules/uuid/dist-node/types.js | 1 + node_modules/uuid/dist-node/uuid-bin.js | 70 ++++ node_modules/uuid/dist-node/v1.js | 83 ++++ node_modules/uuid/dist-node/v1ToV6.js | 10 + node_modules/uuid/dist-node/v3.js | 9 + node_modules/uuid/dist-node/v35.js | 39 ++ node_modules/uuid/dist-node/v4.js | 29 ++ node_modules/uuid/dist-node/v5.js | 9 + node_modules/uuid/dist-node/v6.js | 20 + node_modules/uuid/dist-node/v6ToV1.js | 10 + node_modules/uuid/dist-node/v7.js | 65 +++ node_modules/uuid/dist-node/validate.js | 5 + node_modules/uuid/dist-node/version.js | 8 + node_modules/uuid/package.json | 110 +++++ package-lock.json | 25 ++ package.json | 5 + 33 files changed, 1132 insertions(+), 5 deletions(-) create mode 120000 node_modules/.bin/uuid create mode 100644 node_modules/.package-lock.json create mode 100644 node_modules/uuid/LICENSE.md create mode 100644 node_modules/uuid/README.md create mode 100755 node_modules/uuid/dist-node/bin/uuid create mode 100644 node_modules/uuid/dist-node/index.js create mode 100644 node_modules/uuid/dist-node/max.js create mode 100644 node_modules/uuid/dist-node/md5.js create mode 100644 node_modules/uuid/dist-node/nil.js create mode 100644 node_modules/uuid/dist-node/parse.js create mode 100644 node_modules/uuid/dist-node/regex.js create mode 100644 node_modules/uuid/dist-node/rng.js create mode 100644 node_modules/uuid/dist-node/sha1.js create mode 100644 node_modules/uuid/dist-node/stringify.js create mode 100644 node_modules/uuid/dist-node/types.js create mode 100644 node_modules/uuid/dist-node/uuid-bin.js create mode 100644 node_modules/uuid/dist-node/v1.js create mode 100644 node_modules/uuid/dist-node/v1ToV6.js create mode 100644 node_modules/uuid/dist-node/v3.js create mode 100644 node_modules/uuid/dist-node/v35.js create mode 100644 node_modules/uuid/dist-node/v4.js create mode 100644 node_modules/uuid/dist-node/v5.js create mode 100644 node_modules/uuid/dist-node/v6.js create mode 100644 node_modules/uuid/dist-node/v6ToV1.js create mode 100644 node_modules/uuid/dist-node/v7.js create mode 100644 node_modules/uuid/dist-node/validate.js create mode 100644 node_modules/uuid/dist-node/version.js create mode 100644 node_modules/uuid/package.json create mode 100644 package-lock.json create mode 100644 package.json diff --git a/bus-gateway/controllers/iti65.js b/bus-gateway/controllers/iti65.js index b88f1fe..580d245 100644 --- a/bus-gateway/controllers/iti65.js +++ b/bus-gateway/controllers/iti65.js @@ -4,8 +4,8 @@ const config = require('../config'); const { getBusToken, createBusRequest } = require('../utils/busAuth'); const { searchPatient } = require('../services/patient'); const { postDocumentReference, fetchDocumentReference } = require('../services/documentReference'); -const { logger } = require('../utils/logger') - +const { logger } = require('../utils/logger'); +const { uuidv4 } = require('uuid'); const DOCUMENT_REFERENCE_RESOURCE_TYPE = "DocumentReference"; @@ -17,7 +17,7 @@ const LIST_RESOURCE_TYPE = 'List'; const NATIONAL_ID_SYSTEM = 'https://federador.msal.gob.ar/patient-id'; const DNI_SYSTEM = 'http://www.renaper.gob.ar/dni'; const CUSTODIAN_ID_SYSTEM = 'https://federador.msal.gob.ar/uri'; - +const MASTER_ID_SYSTEM = '' /** * Procesa una transacción y devuelve los recursos persistidos en el servidor HAPI FHIR @@ -90,6 +90,10 @@ async function createBusDocumentReference(token, localIPSDocument, localPatient) const busDocumentReference = { resourceType: 'DocumentReference', status: 'current', + masterIdentifier: { + system: 'urn:ietf:rfc:3986', + value: `urn:uuid:${uuidv4()}` + }, type: { coding: [ { diff --git a/bus-gateway/package-lock.json b/bus-gateway/package-lock.json index 0b1c719..759e479 100644 --- a/bus-gateway/package-lock.json +++ b/bus-gateway/package-lock.json @@ -16,7 +16,8 @@ "http-errors": "~1.6.3", "jade": "~1.11.0", "morgan": "~1.9.1", - "pino": "^10.3.1" + "pino": "^10.3.1", + "uuid": "^14.0.0" }, "devDependencies": { "jest": "^30.3.0" @@ -5500,6 +5501,19 @@ "node": ">= 0.4.0" } }, + "node_modules/uuid": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-14.0.0.tgz", + "integrity": "sha512-Qo+uWgilfSmAhXCMav1uYFynlQO7fMFiMVZsQqZRMIXp0O7rR7qjkj+cPvBHLgBqi960QCoo/PH2/6ZtVqKvrg==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist-node/bin/uuid" + } + }, "node_modules/v8-to-istanbul": { "version": "9.3.0", "resolved": "https://registry.npmjs.org/v8-to-istanbul/-/v8-to-istanbul-9.3.0.tgz", diff --git a/bus-gateway/package.json b/bus-gateway/package.json index 5f544dd..3ed3f59 100644 --- a/bus-gateway/package.json +++ b/bus-gateway/package.json @@ -15,7 +15,8 @@ "http-errors": "~1.6.3", "jade": "~1.11.0", "morgan": "~1.9.1", - "pino": "^10.3.1" + "pino": "^10.3.1", + "uuid": "^14.0.0" }, "devDependencies": { "jest": "^30.3.0" diff --git a/node_modules/.bin/uuid b/node_modules/.bin/uuid new file mode 120000 index 0000000..a0e681c --- /dev/null +++ b/node_modules/.bin/uuid @@ -0,0 +1 @@ +../uuid/dist-node/bin/uuid \ No newline at end of file diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json new file mode 100644 index 0000000..d199d05 --- /dev/null +++ b/node_modules/.package-lock.json @@ -0,0 +1,20 @@ +{ + "name": "ips-nodo-dominio", + "lockfileVersion": 3, + "requires": true, + "packages": { + "node_modules/uuid": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-14.0.0.tgz", + "integrity": "sha512-Qo+uWgilfSmAhXCMav1uYFynlQO7fMFiMVZsQqZRMIXp0O7rR7qjkj+cPvBHLgBqi960QCoo/PH2/6ZtVqKvrg==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist-node/bin/uuid" + } + } + } +} diff --git a/node_modules/uuid/LICENSE.md b/node_modules/uuid/LICENSE.md new file mode 100644 index 0000000..3934168 --- /dev/null +++ b/node_modules/uuid/LICENSE.md @@ -0,0 +1,9 @@ +The MIT License (MIT) + +Copyright (c) 2010-2020 Robert Kieffer and other contributors + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/node_modules/uuid/README.md b/node_modules/uuid/README.md new file mode 100644 index 0000000..c4e2cbd --- /dev/null +++ b/node_modules/uuid/README.md @@ -0,0 +1,491 @@ + + +# 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/workflows/browser.yml) + +For the creation of [RFC9562](https://www.rfc-editor.org/rfc/rfc9562.html) (formerly [RFC4122](https://www.rfc-editor.org/rfc/rfc4122.html)) UUIDs + +- **Complete** - Support for all RFC9562 UUID versions +- **Cross-platform** - Support for... + - [Typescript](#support) + - [Chrome, Safari, Firefox, and Edge](#support) + - [NodeJS](#support) + - [React Native / Expo](#react-native--expo) +- **Secure** - Uses modern `crypto` API for random values +- **Compact** - Zero-dependency, [tree-shakable](https://developer.mozilla.org/en-US/docs/Glossary/Tree_shaking) +- **CLI** - [`uuid` command line](#command-line) utility + + +> [!NOTE] +> +> Starting with `uuid@12` CommonJS is no longer supported. See [implications](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) and [motivation](https://github.com/uuidjs/uuid/issues/881) for details. + +## Quickstart + +**1. Install** + +```shell +npm install uuid +``` + +**2. Create a UUID** + +```javascript +import { v4 as uuidv4 } from "uuid"; + +uuidv4(); // ⇨ 'ab16e731-6cee-424d-81a0-5929e9bdb0cc' +``` + +For timestamp UUIDs, namespace UUIDs, and other options read on ... + +## API Summary + +| | | | +| -------------------------------------------------- | ----------------------------------------------- | ----------------- | +| [`uuid.NIL`](#uuidnil) | The nil UUID string (all zeros) | New in `uuid@8.3` | +| [`uuid.MAX`](#uuidmax) | The max UUID string (all ones) | New in `uuid@9.1` | +| [`uuid.parse()`](#uuidparsestr) | Convert UUID string to array of bytes | New in `uuid@8.3` | +| [`uuid.stringify()`](#uuidstringifyarr-offset) | Convert array of bytes to UUID string | New in `uuid@8.3` | +| [`uuid.v1()`](#uuidv1options-buffer-offset) | Create a version 1 (timestamp) UUID | | +| [`uuid.v1ToV6()`](#uuidv1tov6uuid) | Create a version 6 UUID from a version 1 UUID | New in `uuid@10` | +| [`uuid.v3()`](#uuidv3name-namespace-buffer-offset) | Create a version 3 (namespace w/ MD5) UUID | | +| [`uuid.v4()`](#uuidv4options-buffer-offset) | Create a version 4 (random) UUID | | +| [`uuid.v5()`](#uuidv5name-namespace-buffer-offset) | Create a version 5 (namespace w/ SHA-1) UUID | | +| [`uuid.v6()`](#uuidv6options-buffer-offset) | Create a version 6 (timestamp, reordered) UUID | New in `uuid@10` | +| [`uuid.v6ToV1()`](#uuidv6tov1uuid) | Create a version 1 UUID from a version 6 UUID | New in `uuid@10` | +| [`uuid.v7()`](#uuidv7options-buffer-offset) | Create a version 7 (Unix Epoch time-based) UUID | New in `uuid@10` | +| ~~[`uuid.v8()`](#uuidv8)~~ | "Intentionally left blank" | | +| [`uuid.validate()`](#uuidvalidatestr) | Test a string to see if it is a valid UUID | New in `uuid@8.3` | +| [`uuid.version()`](#uuidversionstr) | Detect RFC version of a UUID | New in `uuid@8.3` | + +## API + +### uuid.NIL + +The nil UUID string (all zeros). + +Example: + +```javascript +import { NIL as NIL_UUID } from "uuid"; + +NIL_UUID; // ⇨ '00000000-0000-0000-0000-000000000000' +``` + +### uuid.MAX + +The max UUID string (all ones). + +Example: + +```javascript +import { MAX as MAX_UUID } from "uuid"; + +MAX_UUID; // ⇨ 'ffffffff-ffff-ffff-ffff-ffffffffffff' +``` + +### uuid.parse(str) + +Convert UUID string to array of bytes + +| | | +| --------- | ---------------------------------------- | +| `str` | A valid UUID `String` | +| _returns_ | `Uint8Array[16]` | +| _throws_ | `TypeError` if `str` is not a valid UUID | + + +> [!NOTE] +> Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below. + +Example: + +```javascript +import { parse as uuidParse } from "uuid"; + +// Parse a UUID +uuidParse("6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b"); // ⇨ +// Uint8Array(16) [ +// 110, 192, 189, 127, 17, +// 192, 67, 218, 151, 94, +// 42, 138, 217, 235, 174, +// 11 +// ] +``` + +### uuid.stringify(arr[, offset]) + +Convert array of bytes to UUID string + +| | | +| -------------- | ---------------------------------------------------------------------------- | +| `arr` | `Array`-like collection of 16 values (starting from `offset`) between 0-255. | +| [`offset` = 0] | `Number` Starting index in the Array | +| _returns_ | `String` | +| _throws_ | `TypeError` if a valid UUID string cannot be generated | + + +> [!NOTE] +> Ordering of values in the byte arrays used by `parse()` and `stringify()` follows the left ↠ right order of hex-pairs in UUID strings. As shown in the example below. + +Example: + +```javascript +import { stringify as uuidStringify } from "uuid"; + +const uuidBytes = Uint8Array.of( + 0x6e, + 0xc0, + 0xbd, + 0x7f, + 0x11, + 0xc0, + 0x43, + 0xda, + 0x97, + 0x5e, + 0x2a, + 0x8a, + 0xd9, + 0xeb, + 0xae, + 0x0b, +); + +uuidStringify(uuidBytes); // ⇨ '6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b' +``` + +### uuid.v1([options[, buffer[, offset]]]) + +Create an RFC version 1 (timestamp) UUID + +| | | +| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | +| [`options`] | `Object` with one or more of the following properties: | +| [`options.node = (random)` ] | RFC "node" field as an `Array[6]` of byte values (per 4.1.6) | +| [`options.clockseq = (random)`] | RFC "clock sequence" as a `Number` between 0 - 0x3fff | +| [`options.msecs = (current time)`] | RFC "timestamp" field (`Number` of milliseconds, unix epoch) | +| [`options.nsecs = 0`] | RFC "timestamp" field (`Number` of nanoseconds to add to `msecs`, should be 0-10,000) | +| [`options.random = (random)`] | `Array` of 16 random bytes (0-255) used to generate other fields, above | +| [`options.rng`] | Alternative to `options.random`, a `Function` that returns an `Array` of 16 random bytes (0-255) | +| [`buffer`] | `Uint8Array` or `Uint8Array` subtype (e.g. Node.js `Buffer`). If provided, binary UUID is written into the array, starting at `offset` | +| [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` | +| _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` | +| _throws_ | `Error` if more than 10M UUIDs/sec are requested | + +Example: + +```javascript +import { v1 as uuidv1 } from "uuid"; + +uuidv1(); // ⇨ '4d9d2960-31d0-11f1-aba8-29728d41eeed' +``` + +Example using `options`: + +```javascript +import { v1 as uuidv1 } from "uuid"; + +const options = { + node: Uint8Array.of(0x01, 0x23, 0x45, 0x67, 0x89, 0xab), + clockseq: 0x1234, + msecs: new Date("2011-11-01").getTime(), + nsecs: 5678, +}; +uuidv1(options); // ⇨ '710b962e-041c-11e1-9234-0123456789ab' +``` + +### uuid.v1ToV6(uuid) + +Convert a UUID from version 1 to version 6 + +```javascript +import { v1ToV6 } from "uuid"; + +v1ToV6("92f62d9e-22c4-11ef-97e9-325096b39f47"); // ⇨ '1ef22c49-2f62-6d9e-97e9-325096b39f47' +``` + +### uuid.v3(name, namespace[, buffer[, offset]]) + +Create an RFC version 3 (namespace w/ MD5) UUID + +API is identical to `v5()`, but uses "v3" instead. + + +> [!IMPORTANT] +> Per the RFC, "_If backward compatibility is not an issue, SHA-1 [Version 5] is preferred_." + +### uuid.v4([options[, buffer[, offset]]]) + +Create an RFC version 4 (random) UUID + +| | | +| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------- | +| [`options`] | `Object` with one or more of the following properties: | +| [`options.random`] | `Array` of 16 random bytes (0-255) | +| [`options.rng`] | Alternative to `options.random`, a `Function` that returns an `Array` of 16 random bytes (0-255) | +| [`buffer`] | `Uint8Array` or `Uint8Array` subtype (e.g. Node.js `Buffer`). If provided, binary UUID is written into the array, starting at `offset` | +| [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` | +| _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` | + +Example: + +```javascript +import { v4 as uuidv4 } from "uuid"; + +uuidv4(); // ⇨ '7934256a-bc92-4b69-b240-f9e463881aea' +``` + +Example using predefined `random` values: + +```javascript +import { v4 as uuidv4 } from "uuid"; + +const v4options = { + random: Uint8Array.of( + 0x10, + 0x91, + 0x56, + 0xbe, + 0xc4, + 0xfb, + 0xc1, + 0xea, + 0x71, + 0xb4, + 0xef, + 0xe1, + 0x67, + 0x1c, + 0x58, + 0x36, + ), +}; +uuidv4(v4options); // ⇨ '109156be-c4fb-41ea-b1b4-efe1671c5836' +``` + +### uuid.v5(name, namespace[, buffer[, offset]]) + +Create an RFC version 5 (namespace w/ SHA-1) UUID + +| | | +| -------------- | -------------------------------------------------------------------------------------------------------------------------------------- | +| `name` | `String \| Array` | +| `namespace` | `String \| Array[16]` Namespace UUID | +| [`buffer`] | `Uint8Array` or `Uint8Array` subtype (e.g. Node.js `Buffer`). If provided, binary UUID is written into the array, starting at `offset` | +| [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` | +| _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` | + + +> [!NOTE] +> The RFC `DNS` and `URL` namespaces are available as `v5.DNS` and `v5.URL`. + +Example with custom namespace: + +```javascript +import { v5 as uuidv5 } from "uuid"; + +// Define a custom namespace. Readers, create your own using something like +// https://www.uuidgenerator.net/ +const MY_NAMESPACE = "1b671a64-40d5-491e-99b0-da01ff1f3341"; + +uuidv5("Hello, World!", MY_NAMESPACE); // ⇨ '630eb68f-e0fa-5ecc-887a-7c7a62614681' +``` + +Example with RFC `URL` namespace: + +```javascript +import { v5 as uuidv5 } from "uuid"; + +uuidv5("https://www.w3.org/", uuidv5.URL); // ⇨ 'c106a26a-21bb-5538-8bf2-57095d1976c1' +``` + +### uuid.v6([options[, buffer[, offset]]]) + +Create an RFC version 6 (timestamp, reordered) UUID + +This method takes the same arguments as uuid.v1(). + +```javascript +import { v6 as uuidv6 } from "uuid"; + +uuidv6(); // ⇨ '1f131d04-d9dc-65a0-9516-5be66631ce97' +``` + +Example using `options`: + +```javascript +import { v6 as uuidv6 } from "uuid"; + +const options = { + node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab], + clockseq: 0x1234, + msecs: new Date("2011-11-01").getTime(), + nsecs: 5678, +}; +uuidv6(options); // ⇨ '1e1041c7-10b9-662e-9234-0123456789ab' +``` + +### uuid.v6ToV1(uuid) + +Convert a UUID from version 6 to version 1 + +```javascript +import { v6ToV1 } from "uuid"; + +v6ToV1("1ef22c49-2f62-6d9e-97e9-325096b39f47"); // ⇨ '92f62d9e-22c4-11ef-97e9-325096b39f47' +``` + +### uuid.v7([options[, buffer[, offset]]]) + +Create an RFC version 7 (random) UUID + +| | | +| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| [`options`] | `Object` with one or more of the following properties: | +| [`options.msecs = (current time)`] | RFC "timestamp" field (`Number` of milliseconds, unix epoch) | +| [`options.random = (random)`] | `Array` of 16 random bytes (0-255) used to generate other fields, above | +| [`options.rng`] | Alternative to `options.random`, a `Function` that returns an `Array` of 16 random bytes (0-255) | +| [`options.seq = (random)`] | 32-bit sequence `Number` between 0 - 0xffffffff. This may be provided to help ensure uniqueness for UUIDs generated within the same millisecond time interval. Default = random value. | +| [`buffer`] | `Uint8Array` or `Uint8Array` subtype (e.g. Node.js `Buffer`). If provided, binary UUID is written into the array, starting at `offset` | +| [`offset` = 0] | `Number` Index to start writing UUID bytes in `buffer` | +| _returns_ | UUID `String` if no `buffer` is specified, otherwise returns `buffer` | + +Example: + +```javascript +import { v7 as uuidv7 } from "uuid"; + +uuidv7(); // ⇨ '019d637c-c6fb-74e9-8b9d-2f1d459a4201' +``` + +### ~~uuid.v8()~~ + +**_"Intentionally left blank"_** + + +> [!NOTE] +> 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. + +### uuid.validate(str) + +Test a string to see if it is a valid UUID + +| | | +| --------- | --------------------------------------------------- | +| `str` | `String` to validate | +| _returns_ | `true` if string is a valid UUID, `false` otherwise | + +Example: + +```javascript +import { validate as uuidValidate } from "uuid"; + +uuidValidate("not a UUID"); // ⇨ false +uuidValidate("6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b"); // ⇨ true +``` + +Using `validate` and `version` together it is possible to do per-version validation, e.g. validate for only v4 UUIds. + +```javascript +import { version as uuidVersion } from "uuid"; +import { validate as uuidValidate } from "uuid"; + +function uuidValidateV4(uuid) { + return uuidValidate(uuid) && uuidVersion(uuid) === 4; +} + +const v1Uuid = "d9428888-122b-11e1-b85c-61cd3cbb3210"; +const v4Uuid = "109156be-c4fb-41ea-b1b4-efe1671c5836"; + +uuidValidateV4(v4Uuid); // ⇨ true +uuidValidateV4(v1Uuid); // ⇨ false +``` + +### uuid.version(str) + +Detect RFC version of a UUID + +| | | +| --------- | ---------------------------------------- | +| `str` | A valid UUID `String` | +| _returns_ | `Number` The RFC version of the UUID | +| _throws_ | `TypeError` if `str` is not a valid UUID | + +Example: + +```javascript +import { version as uuidVersion } from "uuid"; + +uuidVersion("45637ec4-c85f-11ea-87d0-0242ac130003"); // ⇨ 1 +uuidVersion("6ec0bd7f-11c0-43da-975e-2a8ad9ebae0b"); // ⇨ 4 +``` + + +> [!NOTE] +> This method returns `0` for the `NIL` UUID, and `15` for the `MAX` UUID. + +## Command Line + +UUIDs can be generated from the command line using `uuid`. + +```shell +$ npx uuid +ddeb27fb-d9a0-4624-be4d-4615062daed4 +``` + +The default is to generate version 4 UUIDS, however the other versions are supported. Type `uuid --help` for details: + +```shell +$ npx uuid --help + +Usage: + uuid + uuid v1 + uuid v3 + uuid v4 + uuid v5 + uuid v7 + uuid --help + +Note: may be "URL" or "DNS" to use the corresponding UUIDs +defined by RFC9562 +``` + +## `options` Handling for Timestamp UUIDs + +Prior to `uuid@11`, it was possible for `options` state to interfere with the internal state used to ensure uniqueness of timestamp-based UUIDs (the `v1()`, `v6()`, and `v7()` methods). Starting with `uuid@11`, this issue has been addressed by using the presence of the `options` argument as a flag to select between two possible behaviors: + +- Without `options`: Internal state is utilized to improve UUID uniqueness. +- With `options`: Internal state is **NOT** used and, instead, appropriate defaults are applied as needed. + +## Support + +**Browsers**: `uuid` [builds are tested](/uuidjs/uuid/blob/main/wdio.conf.js) against the latest version of desktop Chrome, Safari, Firefox, and Edge. Mobile versions of these same browsers are expected to work but aren't currently tested. + +**Node**: `uuid` [builds are tested](https://github.com/uuidjs/uuid/blob/main/.github/workflows/ci.yml#L26-L27) against node ([LTS releases](https://github.com/nodejs/Release)), plus one prior. E.g. At the time of this writing `node@20` is the "maintenance" release and `node@24` is the "current" release, so `uuid` supports `node@20`-`node@24`. + +**Typescript**: TS versions released within the past two years are supported. [source](https://github.com/microsoft/TypeScript/issues/49088#issuecomment-2468723715) + +## Known issues + + + +### "getRandomValues() not supported" + +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: + +#### React Native / Expo + +1. Install [`react-native-get-random-values`](https://github.com/LinusU/react-native-get-random-values#readme) +1. Import it _before_ `uuid`. Since `uuid` might also appear as a transitive dependency of some other imports it's safest to just import `react-native-get-random-values` as the very first thing in your entry point: + +```javascript +import "react-native-get-random-values"; +import { v4 as uuidv4 } from "uuid"; +``` + +--- + +Markdown generated from [README_js.md](README_js.md) by diff --git a/node_modules/uuid/dist-node/bin/uuid b/node_modules/uuid/dist-node/bin/uuid new file mode 100755 index 0000000..b4f612d --- /dev/null +++ b/node_modules/uuid/dist-node/bin/uuid @@ -0,0 +1,2 @@ +#!/usr/bin/env node +import '../uuid-bin.js'; diff --git a/node_modules/uuid/dist-node/index.js b/node_modules/uuid/dist-node/index.js new file mode 100644 index 0000000..3193e9a --- /dev/null +++ b/node_modules/uuid/dist-node/index.js @@ -0,0 +1,14 @@ +export { default as MAX } from './max.js'; +export { default as NIL } from './nil.js'; +export { default as parse } from './parse.js'; +export { default as stringify } from './stringify.js'; +export { default as v1 } from './v1.js'; +export { default as v1ToV6 } from './v1ToV6.js'; +export { default as v3 } from './v3.js'; +export { default as v4 } from './v4.js'; +export { default as v5 } from './v5.js'; +export { default as v6 } from './v6.js'; +export { default as v6ToV1 } from './v6ToV1.js'; +export { default as v7 } from './v7.js'; +export { default as validate } from './validate.js'; +export { default as version } from './version.js'; diff --git a/node_modules/uuid/dist-node/max.js b/node_modules/uuid/dist-node/max.js new file mode 100644 index 0000000..58951f6 --- /dev/null +++ b/node_modules/uuid/dist-node/max.js @@ -0,0 +1 @@ +export default 'ffffffff-ffff-ffff-ffff-ffffffffffff'; diff --git a/node_modules/uuid/dist-node/md5.js b/node_modules/uuid/dist-node/md5.js new file mode 100644 index 0000000..4fae485 --- /dev/null +++ b/node_modules/uuid/dist-node/md5.js @@ -0,0 +1,11 @@ +import { createHash } from 'node:crypto'; +function md5(bytes) { + if (Array.isArray(bytes)) { + bytes = Buffer.from(bytes); + } + else if (typeof bytes === 'string') { + bytes = Buffer.from(bytes, 'utf8'); + } + return createHash('md5').update(bytes).digest(); +} +export default md5; diff --git a/node_modules/uuid/dist-node/nil.js b/node_modules/uuid/dist-node/nil.js new file mode 100644 index 0000000..de6f830 --- /dev/null +++ b/node_modules/uuid/dist-node/nil.js @@ -0,0 +1 @@ +export default '00000000-0000-0000-0000-000000000000'; diff --git a/node_modules/uuid/dist-node/parse.js b/node_modules/uuid/dist-node/parse.js new file mode 100644 index 0000000..64ac401 --- /dev/null +++ b/node_modules/uuid/dist-node/parse.js @@ -0,0 +1,9 @@ +import validate from './validate.js'; +function parse(uuid) { + if (!validate(uuid)) { + throw TypeError('Invalid UUID'); + } + let v; + return Uint8Array.of((v = parseInt(uuid.slice(0, 8), 16)) >>> 24, (v >>> 16) & 0xff, (v >>> 8) & 0xff, v & 0xff, (v = parseInt(uuid.slice(9, 13), 16)) >>> 8, v & 0xff, (v = parseInt(uuid.slice(14, 18), 16)) >>> 8, v & 0xff, (v = parseInt(uuid.slice(19, 23), 16)) >>> 8, v & 0xff, ((v = parseInt(uuid.slice(24, 36), 16)) / 0x10000000000) & 0xff, (v / 0x100000000) & 0xff, (v >>> 24) & 0xff, (v >>> 16) & 0xff, (v >>> 8) & 0xff, v & 0xff); +} +export default parse; diff --git a/node_modules/uuid/dist-node/regex.js b/node_modules/uuid/dist-node/regex.js new file mode 100644 index 0000000..3e38591 --- /dev/null +++ b/node_modules/uuid/dist-node/regex.js @@ -0,0 +1 @@ +export 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; diff --git a/node_modules/uuid/dist-node/rng.js b/node_modules/uuid/dist-node/rng.js new file mode 100644 index 0000000..0511e89 --- /dev/null +++ b/node_modules/uuid/dist-node/rng.js @@ -0,0 +1,4 @@ +const rnds8 = new Uint8Array(16); +export default function rng() { + return crypto.getRandomValues(rnds8); +} diff --git a/node_modules/uuid/dist-node/sha1.js b/node_modules/uuid/dist-node/sha1.js new file mode 100644 index 0000000..7dfd27c --- /dev/null +++ b/node_modules/uuid/dist-node/sha1.js @@ -0,0 +1,11 @@ +import { createHash } from 'node:crypto'; +function sha1(bytes) { + if (Array.isArray(bytes)) { + bytes = Buffer.from(bytes); + } + else if (typeof bytes === 'string') { + bytes = Buffer.from(bytes, 'utf8'); + } + return createHash('sha1').update(bytes).digest(); +} +export default sha1; diff --git a/node_modules/uuid/dist-node/stringify.js b/node_modules/uuid/dist-node/stringify.js new file mode 100644 index 0000000..962738c --- /dev/null +++ b/node_modules/uuid/dist-node/stringify.js @@ -0,0 +1,35 @@ +import validate from './validate.js'; +const byteToHex = []; +for (let i = 0; i < 256; ++i) { + byteToHex.push((i + 0x100).toString(16).slice(1)); +} +export function unsafeStringify(arr, offset = 0) { + return (byteToHex[arr[offset + 0]] + + byteToHex[arr[offset + 1]] + + byteToHex[arr[offset + 2]] + + byteToHex[arr[offset + 3]] + + '-' + + byteToHex[arr[offset + 4]] + + byteToHex[arr[offset + 5]] + + '-' + + byteToHex[arr[offset + 6]] + + byteToHex[arr[offset + 7]] + + '-' + + byteToHex[arr[offset + 8]] + + byteToHex[arr[offset + 9]] + + '-' + + byteToHex[arr[offset + 10]] + + byteToHex[arr[offset + 11]] + + byteToHex[arr[offset + 12]] + + byteToHex[arr[offset + 13]] + + byteToHex[arr[offset + 14]] + + byteToHex[arr[offset + 15]]).toLowerCase(); +} +function stringify(arr, offset = 0) { + const uuid = unsafeStringify(arr, offset); + if (!validate(uuid)) { + throw TypeError('Stringified UUID is invalid'); + } + return uuid; +} +export default stringify; diff --git a/node_modules/uuid/dist-node/types.js b/node_modules/uuid/dist-node/types.js new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/node_modules/uuid/dist-node/types.js @@ -0,0 +1 @@ +export {}; diff --git a/node_modules/uuid/dist-node/uuid-bin.js b/node_modules/uuid/dist-node/uuid-bin.js new file mode 100644 index 0000000..aa4d4ac --- /dev/null +++ b/node_modules/uuid/dist-node/uuid-bin.js @@ -0,0 +1,70 @@ +import * as assert from 'node:assert/strict'; +import v1 from './v1.js'; +import v3 from './v3.js'; +import v4 from './v4.js'; +import v5 from './v5.js'; +import v6 from './v6.js'; +import v7 from './v7.js'; +function usage() { + console.log('Usage:'); + console.log(' uuid'); + console.log(' uuid v1'); + console.log(' uuid v3 '); + console.log(' uuid v4'); + console.log(' uuid v5 '); + console.log(' uuid v6'); + console.log(' uuid v7'); + console.log(' uuid --help'); + console.log('\nNote: may be "URL" or "DNS" to use the corresponding UUIDs defined by RFC9562'); +} +const args = process.argv.slice(2); +if (args.indexOf('--help') >= 0) { + usage(); + process.exit(0); +} +const version = args.shift() || 'v4'; +switch (version) { + case 'v1': + console.log(v1()); + break; + case 'v3': { + const name = args.shift(); + let namespace = args.shift(); + assert.ok(name != null, 'v3 name not specified'); + assert.ok(namespace != null, 'v3 namespace not specified'); + if (namespace === 'URL') { + namespace = v3.URL; + } + if (namespace === 'DNS') { + namespace = v3.DNS; + } + console.log(v3(name, namespace)); + break; + } + case 'v4': + console.log(v4()); + break; + case 'v5': { + const name = args.shift(); + let namespace = args.shift(); + assert.ok(name != null, 'v5 name not specified'); + assert.ok(namespace != null, 'v5 namespace not specified'); + if (namespace === 'URL') { + namespace = v5.URL; + } + if (namespace === 'DNS') { + namespace = v5.DNS; + } + console.log(v5(name, namespace)); + break; + } + case 'v6': + console.log(v6()); + break; + case 'v7': + console.log(v7()); + break; + default: + usage(); + process.exit(1); +} diff --git a/node_modules/uuid/dist-node/v1.js b/node_modules/uuid/dist-node/v1.js new file mode 100644 index 0000000..65e3f68 --- /dev/null +++ b/node_modules/uuid/dist-node/v1.js @@ -0,0 +1,83 @@ +import rng from './rng.js'; +import { unsafeStringify } from './stringify.js'; +const _state = {}; +function v1(options, buf, offset) { + let bytes; + const isV6 = options?._v6 ?? false; + if (options) { + const optionsKeys = Object.keys(options); + if (optionsKeys.length === 1 && optionsKeys[0] === '_v6') { + options = undefined; + } + } + if (options) { + bytes = v1Bytes(options.random ?? options.rng?.() ?? rng(), options.msecs, options.nsecs, options.clockseq, options.node, buf, offset); + } + else { + const now = Date.now(); + const rnds = rng(); + updateV1State(_state, now, rnds); + bytes = v1Bytes(rnds, _state.msecs, _state.nsecs, isV6 ? undefined : _state.clockseq, isV6 ? undefined : _state.node, buf, offset); + } + return buf ?? unsafeStringify(bytes); +} +export function updateV1State(state, now, rnds) { + state.msecs ??= -Infinity; + state.nsecs ??= 0; + if (now === state.msecs) { + state.nsecs++; + if (state.nsecs >= 10000) { + state.node = undefined; + state.nsecs = 0; + } + } + else if (now > state.msecs) { + state.nsecs = 0; + } + else if (now < state.msecs) { + state.node = undefined; + } + if (!state.node) { + state.node = rnds.slice(10, 16); + state.node[0] |= 0x01; + state.clockseq = ((rnds[8] << 8) | rnds[9]) & 0x3fff; + } + state.msecs = now; + return state; +} +function v1Bytes(rnds, msecs, nsecs, clockseq, node, buf, offset = 0) { + if (rnds.length < 16) { + throw new Error('Random bytes length must be >= 16'); + } + if (!buf) { + buf = new Uint8Array(16); + offset = 0; + } + else { + if (offset < 0 || offset + 16 > buf.length) { + throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`); + } + } + msecs ??= Date.now(); + nsecs ??= 0; + clockseq ??= ((rnds[8] << 8) | rnds[9]) & 0x3fff; + node ??= rnds.slice(10, 16); + msecs += 12219292800000; + const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000; + buf[offset++] = (tl >>> 24) & 0xff; + buf[offset++] = (tl >>> 16) & 0xff; + buf[offset++] = (tl >>> 8) & 0xff; + buf[offset++] = tl & 0xff; + const tmh = ((msecs / 0x100000000) * 10000) & 0xfffffff; + buf[offset++] = (tmh >>> 8) & 0xff; + buf[offset++] = tmh & 0xff; + buf[offset++] = ((tmh >>> 24) & 0xf) | 0x10; + buf[offset++] = (tmh >>> 16) & 0xff; + buf[offset++] = (clockseq >>> 8) | 0x80; + buf[offset++] = clockseq & 0xff; + for (let n = 0; n < 6; ++n) { + buf[offset++] = node[n]; + } + return buf; +} +export default v1; diff --git a/node_modules/uuid/dist-node/v1ToV6.js b/node_modules/uuid/dist-node/v1ToV6.js new file mode 100644 index 0000000..da0f763 --- /dev/null +++ b/node_modules/uuid/dist-node/v1ToV6.js @@ -0,0 +1,10 @@ +import parse from './parse.js'; +import { unsafeStringify } from './stringify.js'; +export default function v1ToV6(uuid) { + const v1Bytes = typeof uuid === 'string' ? parse(uuid) : uuid; + const v6Bytes = _v1ToV6(v1Bytes); + return typeof uuid === 'string' ? unsafeStringify(v6Bytes) : v6Bytes; +} +function _v1ToV6(v1Bytes) { + return Uint8Array.of(((v1Bytes[6] & 0x0f) << 4) | ((v1Bytes[7] >> 4) & 0x0f), ((v1Bytes[7] & 0x0f) << 4) | ((v1Bytes[4] & 0xf0) >> 4), ((v1Bytes[4] & 0x0f) << 4) | ((v1Bytes[5] & 0xf0) >> 4), ((v1Bytes[5] & 0x0f) << 4) | ((v1Bytes[0] & 0xf0) >> 4), ((v1Bytes[0] & 0x0f) << 4) | ((v1Bytes[1] & 0xf0) >> 4), ((v1Bytes[1] & 0x0f) << 4) | ((v1Bytes[2] & 0xf0) >> 4), 0x60 | (v1Bytes[2] & 0x0f), v1Bytes[3], v1Bytes[8], v1Bytes[9], v1Bytes[10], v1Bytes[11], v1Bytes[12], v1Bytes[13], v1Bytes[14], v1Bytes[15]); +} diff --git a/node_modules/uuid/dist-node/v3.js b/node_modules/uuid/dist-node/v3.js new file mode 100644 index 0000000..b5c3781 --- /dev/null +++ b/node_modules/uuid/dist-node/v3.js @@ -0,0 +1,9 @@ +import md5 from './md5.js'; +import v35, { DNS, URL } from './v35.js'; +export { DNS, URL } from './v35.js'; +function v3(value, namespace, buf, offset) { + return v35(0x30, md5, value, namespace, buf, offset); +} +v3.DNS = DNS; +v3.URL = URL; +export default v3; diff --git a/node_modules/uuid/dist-node/v35.js b/node_modules/uuid/dist-node/v35.js new file mode 100644 index 0000000..8c5fc66 --- /dev/null +++ b/node_modules/uuid/dist-node/v35.js @@ -0,0 +1,39 @@ +import parse from './parse.js'; +import { unsafeStringify } from './stringify.js'; +export function stringToBytes(str) { + str = unescape(encodeURIComponent(str)); + const bytes = new Uint8Array(str.length); + for (let i = 0; i < str.length; ++i) { + bytes[i] = str.charCodeAt(i); + } + return bytes; +} +export const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8'; +export const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8'; +export default function v35(version, hash, value, namespace, buf, offset) { + const valueBytes = typeof value === 'string' ? stringToBytes(value) : value; + const namespaceBytes = typeof namespace === 'string' ? parse(namespace) : namespace; + if (typeof namespace === 'string') { + namespace = parse(namespace); + } + if (namespace?.length !== 16) { + throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)'); + } + let bytes = new Uint8Array(16 + valueBytes.length); + bytes.set(namespaceBytes); + bytes.set(valueBytes, namespaceBytes.length); + bytes = hash(bytes); + bytes[6] = (bytes[6] & 0x0f) | version; + bytes[8] = (bytes[8] & 0x3f) | 0x80; + if (buf) { + offset ??= 0; + if (offset < 0 || offset + 16 > buf.length) { + throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`); + } + for (let i = 0; i < 16; ++i) { + buf[offset + i] = bytes[i]; + } + return buf; + } + return unsafeStringify(bytes); +} diff --git a/node_modules/uuid/dist-node/v4.js b/node_modules/uuid/dist-node/v4.js new file mode 100644 index 0000000..b3017c9 --- /dev/null +++ b/node_modules/uuid/dist-node/v4.js @@ -0,0 +1,29 @@ +import rng from './rng.js'; +import { unsafeStringify } from './stringify.js'; +function v4(options, buf, offset) { + if (!buf && !options && crypto.randomUUID) { + return crypto.randomUUID(); + } + return _v4(options, buf, offset); +} +function _v4(options, buf, offset) { + options = options || {}; + const rnds = options.random ?? options.rng?.() ?? rng(); + if (rnds.length < 16) { + throw new Error('Random bytes length must be >= 16'); + } + rnds[6] = (rnds[6] & 0x0f) | 0x40; + rnds[8] = (rnds[8] & 0x3f) | 0x80; + if (buf) { + offset = offset || 0; + if (offset < 0 || offset + 16 > buf.length) { + throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`); + } + for (let i = 0; i < 16; ++i) { + buf[offset + i] = rnds[i]; + } + return buf; + } + return unsafeStringify(rnds); +} +export default v4; diff --git a/node_modules/uuid/dist-node/v5.js b/node_modules/uuid/dist-node/v5.js new file mode 100644 index 0000000..bd470a4 --- /dev/null +++ b/node_modules/uuid/dist-node/v5.js @@ -0,0 +1,9 @@ +import sha1 from './sha1.js'; +import v35, { DNS, URL } from './v35.js'; +export { DNS, URL } from './v35.js'; +function v5(value, namespace, buf, offset) { + return v35(0x50, sha1, value, namespace, buf, offset); +} +v5.DNS = DNS; +v5.URL = URL; +export default v5; diff --git a/node_modules/uuid/dist-node/v6.js b/node_modules/uuid/dist-node/v6.js new file mode 100644 index 0000000..bd1fc35 --- /dev/null +++ b/node_modules/uuid/dist-node/v6.js @@ -0,0 +1,20 @@ +import { unsafeStringify } from './stringify.js'; +import v1 from './v1.js'; +import v1ToV6 from './v1ToV6.js'; +function v6(options, buf, offset) { + options ??= {}; + offset ??= 0; + let bytes = v1({ ...options, _v6: true }, new Uint8Array(16)); + bytes = v1ToV6(bytes); + if (buf) { + if (offset < 0 || offset + 16 > buf.length) { + throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`); + } + for (let i = 0; i < 16; i++) { + buf[offset + i] = bytes[i]; + } + return buf; + } + return unsafeStringify(bytes); +} +export default v6; diff --git a/node_modules/uuid/dist-node/v6ToV1.js b/node_modules/uuid/dist-node/v6ToV1.js new file mode 100644 index 0000000..bfd942f --- /dev/null +++ b/node_modules/uuid/dist-node/v6ToV1.js @@ -0,0 +1,10 @@ +import parse from './parse.js'; +import { unsafeStringify } from './stringify.js'; +export default function v6ToV1(uuid) { + const v6Bytes = typeof uuid === 'string' ? parse(uuid) : uuid; + const v1Bytes = _v6ToV1(v6Bytes); + return typeof uuid === 'string' ? unsafeStringify(v1Bytes) : v1Bytes; +} +function _v6ToV1(v6Bytes) { + return Uint8Array.of(((v6Bytes[3] & 0x0f) << 4) | ((v6Bytes[4] >> 4) & 0x0f), ((v6Bytes[4] & 0x0f) << 4) | ((v6Bytes[5] & 0xf0) >> 4), ((v6Bytes[5] & 0x0f) << 4) | (v6Bytes[6] & 0x0f), v6Bytes[7], ((v6Bytes[1] & 0x0f) << 4) | ((v6Bytes[2] & 0xf0) >> 4), ((v6Bytes[2] & 0x0f) << 4) | ((v6Bytes[3] & 0xf0) >> 4), 0x10 | ((v6Bytes[0] & 0xf0) >> 4), ((v6Bytes[0] & 0x0f) << 4) | ((v6Bytes[1] & 0xf0) >> 4), v6Bytes[8], v6Bytes[9], v6Bytes[10], v6Bytes[11], v6Bytes[12], v6Bytes[13], v6Bytes[14], v6Bytes[15]); +} diff --git a/node_modules/uuid/dist-node/v7.js b/node_modules/uuid/dist-node/v7.js new file mode 100644 index 0000000..276c9bf --- /dev/null +++ b/node_modules/uuid/dist-node/v7.js @@ -0,0 +1,65 @@ +import rng from './rng.js'; +import { unsafeStringify } from './stringify.js'; +const _state = {}; +function v7(options, buf, offset) { + let bytes; + if (options) { + bytes = v7Bytes(options.random ?? options.rng?.() ?? rng(), options.msecs, options.seq, buf, offset); + } + else { + const now = Date.now(); + const rnds = rng(); + updateV7State(_state, now, rnds); + bytes = v7Bytes(rnds, _state.msecs, _state.seq, buf, offset); + } + return buf ?? unsafeStringify(bytes); +} +export function updateV7State(state, now, rnds) { + state.msecs ??= -Infinity; + state.seq ??= 0; + if (now > state.msecs) { + state.seq = (rnds[6] << 23) | (rnds[7] << 16) | (rnds[8] << 8) | rnds[9]; + state.msecs = now; + } + else { + state.seq = (state.seq + 1) | 0; + if (state.seq === 0) { + state.msecs++; + } + } + return state; +} +function v7Bytes(rnds, msecs, seq, buf, offset = 0) { + if (rnds.length < 16) { + throw new Error('Random bytes length must be >= 16'); + } + if (!buf) { + buf = new Uint8Array(16); + offset = 0; + } + else { + if (offset < 0 || offset + 16 > buf.length) { + throw new RangeError(`UUID byte range ${offset}:${offset + 15} is out of buffer bounds`); + } + } + msecs ??= Date.now(); + seq ??= ((rnds[6] * 0x7f) << 24) | (rnds[7] << 16) | (rnds[8] << 8) | rnds[9]; + buf[offset++] = (msecs / 0x10000000000) & 0xff; + buf[offset++] = (msecs / 0x100000000) & 0xff; + buf[offset++] = (msecs / 0x1000000) & 0xff; + buf[offset++] = (msecs / 0x10000) & 0xff; + buf[offset++] = (msecs / 0x100) & 0xff; + buf[offset++] = msecs & 0xff; + buf[offset++] = 0x70 | ((seq >>> 28) & 0x0f); + buf[offset++] = (seq >>> 20) & 0xff; + buf[offset++] = 0x80 | ((seq >>> 14) & 0x3f); + buf[offset++] = (seq >>> 6) & 0xff; + buf[offset++] = ((seq << 2) & 0xff) | (rnds[10] & 0x03); + buf[offset++] = rnds[11]; + buf[offset++] = rnds[12]; + buf[offset++] = rnds[13]; + buf[offset++] = rnds[14]; + buf[offset++] = rnds[15]; + return buf; +} +export default v7; diff --git a/node_modules/uuid/dist-node/validate.js b/node_modules/uuid/dist-node/validate.js new file mode 100644 index 0000000..444a1a2 --- /dev/null +++ b/node_modules/uuid/dist-node/validate.js @@ -0,0 +1,5 @@ +import REGEX from './regex.js'; +function validate(uuid) { + return typeof uuid === 'string' && REGEX.test(uuid); +} +export default validate; diff --git a/node_modules/uuid/dist-node/version.js b/node_modules/uuid/dist-node/version.js new file mode 100644 index 0000000..bae91d3 --- /dev/null +++ b/node_modules/uuid/dist-node/version.js @@ -0,0 +1,8 @@ +import validate from './validate.js'; +function version(uuid) { + if (!validate(uuid)) { + throw TypeError('Invalid UUID'); + } + return parseInt(uuid.slice(14, 15), 16); +} +export default version; diff --git a/node_modules/uuid/package.json b/node_modules/uuid/package.json new file mode 100644 index 0000000..7bcefdc --- /dev/null +++ b/node_modules/uuid/package.json @@ -0,0 +1,110 @@ +{ + "name": "uuid", + "version": "14.0.0", + "description": "RFC9562 UUIDs", + "type": "module", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "commitlint": { + "extends": [ + "@commitlint/config-conventional" + ] + }, + "keywords": [ + "uuid", + "guid", + "rfc4122", + "rfc9562" + ], + "license": "MIT", + "bin": { + "uuid": "./dist-node/bin/uuid" + }, + "sideEffects": false, + "types": "./dist/index.d.ts", + "exports": { + ".": { + "node": "./dist-node/index.js", + "default": "./dist/index.js" + }, + "./package.json": "./package.json" + }, + "files": [ + "dist", + "dist-node", + "!**/test" + ], + "devDependencies": { + "@biomejs/biome": "2.4.10", + "@commitlint/cli": "20.5.0", + "@commitlint/config-conventional": "20.5.0", + "bundlewatch": "0.4.1", + "commander": "14.0.3", + "globals": "17.4.0", + "husky": "9.1.7", + "jest": "30.3.0", + "lint-staged": "16.4.0", + "neostandard": "0.13.0", + "npm-run-all2": "8.0.4", + "release-please": "17.3.0", + "runmd": "1.4.1", + "standard-version": "9.5.0", + "typescript": "5.4.3" + }, + "optionalDevDependencies": { + "@wdio/browserstack-service": "9.27.0", + "@wdio/cli": "9.27.0", + "@wdio/jasmine-framework": "9.27.0", + "@wdio/local-runner": "9.27.0", + "@wdio/spec-reporter": "9.27.0", + "@wdio/static-server-service": "9.27.0" + }, + "scripts": { + "build": "./scripts/build.sh", + "build:watch": "tsc --watch -p tsconfig.json", + "bundlewatch": "npm run pretest:browser && bundlewatch --config bundlewatch.config.json", + "docs:diff": "npm run docs && git diff --quiet -I \"[0-9a-f-]{36}\" README.md", + "docs": "npm run build && npx runmd --output=README.md README_js.md", + "biome:check": "biome check .", + "biome:fix": "biome check --write .", + "examples:browser:rollup:build": "cd examples/browser-rollup && npm run build", + "examples:browser:webpack:build": "cd examples/browser-webpack && npm run build", + "examples:node:esmodules:test": "cd examples/node-esmodules && npm test", + "examples:node:jest:test": "cd examples/node-jest && npm test", + "examples:node:typescript:test": "cd examples/typescript && npm test", + "lint": "npm run biome:check", + "md": "runmd --watch --output=README.md README_js.md", + "prepack": "npm run build -- --no-pack", + "prepare": "husky", + "prepublishOnly": "npm run build", + "pretest:benchmark": "npm run build", + "pretest:browser": "./scripts/iodd && npm run build && npm-run-all --parallel examples:browser:**", + "pretest:node": "npm run build", + "pretest": "npm run build", + "format": "biome format --write .", + "format:check": "biome format --check .", + "release": "standard-version --no-verify", + "test:benchmark": "cd examples/benchmark && npm test", + "test:browser": "wdio run ./wdio.conf.js", + "test:node": "npm-run-all --parallel examples:node:**", + "test:watch": "node --test --enable-source-maps --watch dist-node/test/*.js", + "test": "node --test --enable-source-maps dist-node/test/*.js" + }, + "repository": { + "type": "git", + "url": "https://github.com/uuidjs/uuid.git" + }, + "lint-staged": { + "*": [ + "biome check --write --no-errors-on-unmatched" + ] + }, + "standard-version": { + "scripts": { + "postchangelog": "biome format --write CHANGELOG.md" + } + }, + "packageManager": "npm@11.12.1" +} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..0f50327 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,25 @@ +{ + "name": "ips-nodo-dominio", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "dependencies": { + "uuid": "^14.0.0" + } + }, + "node_modules/uuid": { + "version": "14.0.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-14.0.0.tgz", + "integrity": "sha512-Qo+uWgilfSmAhXCMav1uYFynlQO7fMFiMVZsQqZRMIXp0O7rR7qjkj+cPvBHLgBqi960QCoo/PH2/6ZtVqKvrg==", + "funding": [ + "https://github.com/sponsors/broofa", + "https://github.com/sponsors/ctavan" + ], + "license": "MIT", + "bin": { + "uuid": "dist-node/bin/uuid" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..4ff46b3 --- /dev/null +++ b/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "uuid": "^14.0.0" + } +}