Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

uuid

Package Overview
Dependencies
0
Maintainers
2
Versions
38
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 8.3.2 to 9.0.0-beta.0

dist/commonjs-browser/index.js

44

dist/esm-browser/md5.js

@@ -23,7 +23,7 @@ /*

if (typeof bytes === 'string') {
var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
bytes = new Uint8Array(msg.length);
for (var i = 0; i < msg.length; ++i) {
for (let i = 0; i < msg.length; ++i) {
bytes[i] = msg.charCodeAt(i);

@@ -41,9 +41,9 @@ }

function md5ToHexEncodedArray(input) {
var output = [];
var length32 = input.length * 32;
var hexTab = '0123456789abcdef';
const output = [];
const length32 = input.length * 32;
const hexTab = '0123456789abcdef';
for (var i = 0; i < length32; i += 8) {
var x = input[i >> 5] >>> i % 32 & 0xff;
var hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
for (let i = 0; i < length32; i += 8) {
const x = input[i >> 5] >>> i % 32 & 0xff;
const hex = parseInt(hexTab.charAt(x >>> 4 & 0x0f) + hexTab.charAt(x & 0x0f), 16);
output.push(hex);

@@ -71,12 +71,12 @@ }

x[getOutputLength(len) - 1] = len;
var a = 1732584193;
var b = -271733879;
var c = -1732584194;
var d = 271733878;
let a = 1732584193;
let b = -271733879;
let c = -1732584194;
let d = 271733878;
for (var i = 0; i < x.length; i += 16) {
var olda = a;
var oldb = b;
var oldc = c;
var oldd = d;
for (let i = 0; i < x.length; i += 16) {
const olda = a;
const oldb = b;
const oldc = c;
const oldd = d;
a = md5ff(a, b, c, d, x[i], 7, -680876936);

@@ -165,6 +165,6 @@ d = md5ff(d, a, b, c, x[i + 1], 12, -389564586);

var length8 = input.length * 8;
var output = new Uint32Array(getOutputLength(length8));
const length8 = input.length * 8;
const output = new Uint32Array(getOutputLength(length8));
for (var i = 0; i < length8; i += 8) {
for (let i = 0; i < length8; i += 8) {
output[i >> 5] |= (input[i / 8] & 0xff) << i % 32;

@@ -182,4 +182,4 @@ }

function safeAdd(x, y) {
var lsw = (x & 0xffff) + (y & 0xffff);
var msw = (x >> 16) + (y >> 16) + (lsw >> 16);
const lsw = (x & 0xffff) + (y & 0xffff);
const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
return msw << 16 | lsw & 0xffff;

@@ -186,0 +186,0 @@ }

@@ -8,4 +8,4 @@ import validate from './validate.js';

var v;
var arr = new Uint8Array(16); // Parse ########-....-....-....-............
let v;
const arr = new Uint8Array(16); // Parse ########-....-....-....-............

@@ -12,0 +12,0 @@ arr[0] = (v = parseInt(uuid.slice(0, 8), 16)) >>> 24;

// Unique ID creation requires a high quality random # generator. In the browser we therefore
// require the crypto API and do not support built-in fallback to lower quality random number
// generators (like Math.random()).
var getRandomValues;
var rnds8 = new Uint8Array(16);
let getRandomValues;
const rnds8 = new Uint8Array(16);
export default function rng() {
// lazy load so that environments that need to polyfill have a chance to do so
if (!getRandomValues) {
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
// find the complete implementation of crypto (msCrypto) on IE11.
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);

@@ -13,0 +12,0 @@ if (!getRandomValues) {

@@ -24,11 +24,11 @@ // Adapted from Chris Veness' SHA1 code at

function sha1(bytes) {
var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
var H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
const K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
const H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
if (typeof bytes === 'string') {
var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
const msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
bytes = [];
for (var i = 0; i < msg.length; ++i) {
for (let i = 0; i < msg.length; ++i) {
bytes.push(msg.charCodeAt(i));

@@ -42,14 +42,14 @@ }

bytes.push(0x80);
var l = bytes.length / 4 + 2;
var N = Math.ceil(l / 16);
var M = new Array(N);
const l = bytes.length / 4 + 2;
const N = Math.ceil(l / 16);
const M = new Array(N);
for (var _i = 0; _i < N; ++_i) {
var arr = new Uint32Array(16);
for (let i = 0; i < N; ++i) {
const arr = new Uint32Array(16);
for (var j = 0; j < 16; ++j) {
arr[j] = bytes[_i * 64 + j * 4] << 24 | bytes[_i * 64 + j * 4 + 1] << 16 | bytes[_i * 64 + j * 4 + 2] << 8 | bytes[_i * 64 + j * 4 + 3];
for (let j = 0; j < 16; ++j) {
arr[j] = bytes[i * 64 + j * 4] << 24 | bytes[i * 64 + j * 4 + 1] << 16 | bytes[i * 64 + j * 4 + 2] << 8 | bytes[i * 64 + j * 4 + 3];
}
M[_i] = arr;
M[i] = arr;
}

@@ -61,22 +61,22 @@

for (var _i2 = 0; _i2 < N; ++_i2) {
var W = new Uint32Array(80);
for (let i = 0; i < N; ++i) {
const W = new Uint32Array(80);
for (var t = 0; t < 16; ++t) {
W[t] = M[_i2][t];
for (let t = 0; t < 16; ++t) {
W[t] = M[i][t];
}
for (var _t = 16; _t < 80; ++_t) {
W[_t] = ROTL(W[_t - 3] ^ W[_t - 8] ^ W[_t - 14] ^ W[_t - 16], 1);
for (let t = 16; t < 80; ++t) {
W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
}
var a = H[0];
var b = H[1];
var c = H[2];
var d = H[3];
var e = H[4];
let a = H[0];
let b = H[1];
let c = H[2];
let d = H[3];
let e = H[4];
for (var _t2 = 0; _t2 < 80; ++_t2) {
var s = Math.floor(_t2 / 20);
var T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[_t2] >>> 0;
for (let t = 0; t < 80; ++t) {
const s = Math.floor(t / 20);
const T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
e = d;

@@ -83,0 +83,0 @@ d = c;

@@ -7,13 +7,16 @@ import validate from './validate.js';

var byteToHex = [];
const byteToHex = [];
for (var i = 0; i < 256; ++i) {
byteToHex.push((i + 0x100).toString(16).substr(1));
for (let i = 0; i < 256; ++i) {
byteToHex.push((i + 0x100).toString(16).slice(1));
}
function stringify(arr) {
var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
export function unsafeStringify(arr, offset = 0) {
// Note: Be careful editing this code! It's been tuned for performance
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
var uuid = (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(); // Consistency check for valid UUID. If this throws, it's likely due to one
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); // Consistency check for valid UUID. If this throws, it's likely due to one
// of the following:

@@ -20,0 +23,0 @@ // - One or more input array values don't map to a hex octet (leading to

import rng from './rng.js';
import stringify from './stringify.js'; // **`v1()` - Generate time-based UUID**
import { unsafeStringify } from './stringify.js'; // **`v1()` - Generate time-based UUID**
//

@@ -7,16 +7,16 @@ // Inspired by https://github.com/LiosK/UUID.js

var _nodeId;
let _nodeId;
var _clockseq; // Previous uuid creation time
let _clockseq; // Previous uuid creation time
var _lastMSecs = 0;
var _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
let _lastMSecs = 0;
let _lastNSecs = 0; // See https://github.com/uuidjs/uuid for API details
function v1(options, buf, offset) {
var i = buf && offset || 0;
var b = buf || new Array(16);
let i = buf && offset || 0;
const b = buf || new Array(16);
options = options || {};
var node = options.node || _nodeId;
var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
let node = options.node || _nodeId;
let clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq; // node and clockseq need to be initialized to random values if they're not
// specified. We do this lazily to minimize issues related to insufficient

@@ -26,3 +26,3 @@ // system entropy. See #189

if (node == null || clockseq == null) {
var seedBytes = options.random || (options.rng || rng)();
const seedBytes = options.random || (options.rng || rng)();

@@ -44,8 +44,8 @@ if (node == null) {

var msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
let msecs = options.msecs !== undefined ? options.msecs : Date.now(); // Per 4.2.1.2, use count of uuid's generated during the current clock
// cycle to simulate higher resolution clock
var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
let nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1; // Time since last uuid creation (in msecs)
var dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression
const dt = msecs - _lastMSecs + (nsecs - _lastNSecs) / 10000; // Per 4.2.1.2, Bump clockseq on clock regression

@@ -73,3 +73,3 @@ if (dt < 0 && options.clockseq === undefined) {

var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
const tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
b[i++] = tl >>> 24 & 0xff;

@@ -80,3 +80,3 @@ b[i++] = tl >>> 16 & 0xff;

var tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
const tmh = msecs / 0x100000000 * 10000 & 0xfffffff;
b[i++] = tmh >>> 8 & 0xff;

@@ -93,9 +93,9 @@ b[i++] = tmh & 0xff; // `time_high_and_version`

for (var n = 0; n < 6; ++n) {
for (let n = 0; n < 6; ++n) {
b[i + n] = node[n];
}
return buf || stringify(b);
return buf || unsafeStringify(b);
}
export default v1;
import v35 from './v35.js';
import md5 from './md5.js';
var v3 = v35('v3', 0x30, md5);
const v3 = v35('v3', 0x30, md5);
export default v3;

@@ -1,2 +0,2 @@

import stringify from './stringify.js';
import { unsafeStringify } from './stringify.js';
import parse from './parse.js';

@@ -7,5 +7,5 @@

var bytes = [];
const bytes = [];
for (var i = 0; i < str.length; ++i) {
for (let i = 0; i < str.length; ++i) {
bytes.push(str.charCodeAt(i));

@@ -17,6 +17,8 @@ }

export var DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
export var URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
export default function (name, version, hashfunc) {
export const DNS = '6ba7b810-9dad-11d1-80b4-00c04fd430c8';
export const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
export default function v35(name, version, hashfunc) {
function generateUUID(value, namespace, buf, offset) {
var _namespace;
if (typeof value === 'string') {

@@ -30,3 +32,3 @@ value = stringToBytes(value);

if (namespace.length !== 16) {
if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');

@@ -38,3 +40,3 @@ } // Compute hash of namespace and value, Per 4.3

var bytes = new Uint8Array(16 + value.length);
let bytes = new Uint8Array(16 + value.length);
bytes.set(namespace);

@@ -49,3 +51,3 @@ bytes.set(value, namespace.length);

for (var i = 0; i < 16; ++i) {
for (let i = 0; i < 16; ++i) {
buf[offset + i] = bytes[i];

@@ -57,3 +59,3 @@ }

return stringify(bytes);
return unsafeStringify(bytes);
} // Function#name is not settable on some platforms (#270)

@@ -60,0 +62,0 @@

@@ -0,7 +1,12 @@

import native from './native.js';
import rng from './rng.js';
import stringify from './stringify.js';
import { unsafeStringify } from './stringify.js';
function v4(options, buf, offset) {
if (native.randomUUID && !buf && !options) {
return native.randomUUID();
}
options = options || {};
var rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`

@@ -14,3 +19,3 @@ rnds[6] = rnds[6] & 0x0f | 0x40;

for (var i = 0; i < 16; ++i) {
for (let i = 0; i < 16; ++i) {
buf[offset + i] = rnds[i];

@@ -22,5 +27,5 @@ }

return stringify(rnds);
return unsafeStringify(rnds);
}
export default v4;
import v35 from './v35.js';
import sha1 from './sha1.js';
var v5 = v35('v5', 0x50, sha1);
const v5 = v35('v5', 0x50, sha1);
export default v5;

@@ -8,5 +8,5 @@ import validate from './validate.js';

return parseInt(uuid.substr(14, 1), 16);
return parseInt(uuid.slice(14, 15), 16);
}
export default version;

@@ -10,9 +10,13 @@ import validate from './validate.js';

for (let i = 0; i < 256; ++i) {
byteToHex.push((i + 0x100).toString(16).substr(1));
byteToHex.push((i + 0x100).toString(16).slice(1));
}
function stringify(arr, offset = 0) {
export function unsafeStringify(arr, offset = 0) {
// Note: Be careful editing this code! It's been tuned for performance
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
const uuid = (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(); // Consistency check for valid UUID. If this throws, it's likely due to one
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); // Consistency check for valid UUID. If this throws, it's likely due to one
// of the following:

@@ -19,0 +23,0 @@ // - One or more input array values don't map to a hex octet (leading to

import rng from './rng.js';
import stringify from './stringify.js'; // **`v1()` - Generate time-based UUID**
import { unsafeStringify } from './stringify.js'; // **`v1()` - Generate time-based UUID**
//

@@ -92,5 +92,5 @@ // Inspired by https://github.com/LiosK/UUID.js

return buf || stringify(b);
return buf || unsafeStringify(b);
}
export default v1;

@@ -1,2 +0,2 @@

import stringify from './stringify.js';
import { unsafeStringify } from './stringify.js';
import parse from './parse.js';

@@ -18,4 +18,6 @@

export const URL = '6ba7b811-9dad-11d1-80b4-00c04fd430c8';
export default function (name, version, hashfunc) {
export default function v35(name, version, hashfunc) {
function generateUUID(value, namespace, buf, offset) {
var _namespace;
if (typeof value === 'string') {

@@ -29,3 +31,3 @@ value = stringToBytes(value);

if (namespace.length !== 16) {
if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');

@@ -54,3 +56,3 @@ } // Compute hash of namespace and value, Per 4.3

return stringify(bytes);
return unsafeStringify(bytes);
} // Function#name is not settable on some platforms (#270)

@@ -57,0 +59,0 @@

@@ -0,5 +1,10 @@

import native from './native.js';
import rng from './rng.js';
import stringify from './stringify.js';
import { unsafeStringify } from './stringify.js';
function v4(options, buf, offset) {
if (native.randomUUID && !buf && !options) {
return native.randomUUID();
}
options = options || {};

@@ -21,5 +26,5 @@ const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`

return stringify(rnds);
return unsafeStringify(rnds);
}
export default v4;

@@ -8,5 +8,5 @@ import validate from './validate.js';

return parseInt(uuid.substr(14, 1), 16);
return parseInt(uuid.slice(14, 15), 16);
}
export default version;

@@ -6,54 +6,54 @@ "use strict";

});
Object.defineProperty(exports, "v1", {
Object.defineProperty(exports, "NIL", {
enumerable: true,
get: function () {
return _v.default;
return _nil.default;
}
});
Object.defineProperty(exports, "v3", {
Object.defineProperty(exports, "parse", {
enumerable: true,
get: function () {
return _v2.default;
return _parse.default;
}
});
Object.defineProperty(exports, "v4", {
Object.defineProperty(exports, "stringify", {
enumerable: true,
get: function () {
return _v3.default;
return _stringify.default;
}
});
Object.defineProperty(exports, "v5", {
Object.defineProperty(exports, "v1", {
enumerable: true,
get: function () {
return _v4.default;
return _v.default;
}
});
Object.defineProperty(exports, "NIL", {
Object.defineProperty(exports, "v3", {
enumerable: true,
get: function () {
return _nil.default;
return _v2.default;
}
});
Object.defineProperty(exports, "version", {
Object.defineProperty(exports, "v4", {
enumerable: true,
get: function () {
return _version.default;
return _v3.default;
}
});
Object.defineProperty(exports, "validate", {
Object.defineProperty(exports, "v5", {
enumerable: true,
get: function () {
return _validate.default;
return _v4.default;
}
});
Object.defineProperty(exports, "stringify", {
Object.defineProperty(exports, "validate", {
enumerable: true,
get: function () {
return _stringify.default;
return _validate.default;
}
});
Object.defineProperty(exports, "parse", {
Object.defineProperty(exports, "version", {
enumerable: true,
get: function () {
return _parse.default;
return _version.default;
}

@@ -60,0 +60,0 @@ });

@@ -16,5 +16,4 @@ "use strict";

if (!getRandomValues) {
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation. Also,
// find the complete implementation of crypto (msCrypto) on IE11.
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto) || typeof msCrypto !== 'undefined' && typeof msCrypto.getRandomValues === 'function' && msCrypto.getRandomValues.bind(msCrypto);
// getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);

@@ -21,0 +20,0 @@ if (!getRandomValues) {

@@ -7,2 +7,3 @@ "use strict";

exports.default = void 0;
exports.unsafeStringify = unsafeStringify;

@@ -20,9 +21,13 @@ var _validate = _interopRequireDefault(require("./validate.js"));

for (let i = 0; i < 256; ++i) {
byteToHex.push((i + 0x100).toString(16).substr(1));
byteToHex.push((i + 0x100).toString(16).slice(1));
}
function stringify(arr, offset = 0) {
function unsafeStringify(arr, offset = 0) {
// Note: Be careful editing this code! It's been tuned for performance
// and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
const uuid = (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(); // Consistency check for valid UUID. If this throws, it's likely due to one
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); // Consistency check for valid UUID. If this throws, it's likely due to one
// of the following:

@@ -29,0 +34,0 @@ // - One or more input array values don't map to a hex octet (leading to

@@ -10,3 +10,3 @@ "use strict";

var _stringify = _interopRequireDefault(require("./stringify.js"));
var _stringify = require("./stringify.js");

@@ -104,3 +104,3 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

return buf || (0, _stringify.default)(b);
return buf || (0, _stringify.unsafeStringify)(b);
}

@@ -107,0 +107,0 @@

@@ -6,6 +6,6 @@ "use strict";

});
exports.default = _default;
exports.URL = exports.DNS = void 0;
exports.default = v35;
var _stringify = _interopRequireDefault(require("./stringify.js"));
var _stringify = require("./stringify.js");

@@ -33,4 +33,6 @@ var _parse = _interopRequireDefault(require("./parse.js"));

function _default(name, version, hashfunc) {
function v35(name, version, hashfunc) {
function generateUUID(value, namespace, buf, offset) {
var _namespace;
if (typeof value === 'string') {

@@ -44,3 +46,3 @@ value = stringToBytes(value);

if (namespace.length !== 16) {
if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
throw TypeError('Namespace must be array-like (16 iterable integer values, 0-255)');

@@ -69,3 +71,3 @@ } // Compute hash of namespace and value, Per 4.3

return (0, _stringify.default)(bytes);
return (0, _stringify.unsafeStringify)(bytes);
} // Function#name is not settable on some platforms (#270)

@@ -72,0 +74,0 @@

@@ -8,5 +8,7 @@ "use strict";

var _native = _interopRequireDefault(require("./native.js"));
var _rng = _interopRequireDefault(require("./rng.js"));
var _stringify = _interopRequireDefault(require("./stringify.js"));
var _stringify = require("./stringify.js");

@@ -16,2 +18,6 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function v4(options, buf, offset) {
if (_native.default.randomUUID && !buf && !options) {
return _native.default.randomUUID();
}
options = options || {};

@@ -35,3 +41,3 @@

return (0, _stringify.default)(rnds);
return (0, _stringify.unsafeStringify)(rnds);
}

@@ -38,0 +44,0 @@

@@ -17,3 +17,3 @@ "use strict";

return parseInt(uuid.substr(14, 1), 16);
return parseInt(uuid.slice(14, 15), 16);
}

@@ -20,0 +20,0 @@

{
"name": "uuid",
"version": "8.3.2",
"version": "9.0.0-beta.0",
"description": "RFC4122 (v1, v4, and v5) UUIDs",

@@ -28,2 +28,6 @@ "commitlint": {

},
"browser": {
"import": "./dist/esm-browser/index.js",
"require": "./dist/commonjs-browser/index.js"
},
"default": "./dist/esm-browser/index.js"

@@ -36,2 +40,3 @@ },

"./dist/md5.js": "./dist/md5-browser.js",
"./dist/native.js": "./dist/native-browser.js",
"./dist/rng.js": "./dist/rng-browser.js",

@@ -50,38 +55,33 @@ "./dist/sha1.js": "./dist/sha1-browser.js",

"devDependencies": {
"@babel/cli": "7.11.6",
"@babel/core": "7.11.6",
"@babel/preset-env": "7.11.5",
"@commitlint/cli": "11.0.0",
"@commitlint/config-conventional": "11.0.0",
"@rollup/plugin-node-resolve": "9.0.0",
"babel-eslint": "10.1.0",
"bundlewatch": "0.3.1",
"eslint": "7.10.0",
"eslint-config-prettier": "6.12.0",
"eslint-config-standard": "14.1.1",
"eslint-plugin-import": "2.22.1",
"@babel/cli": "7.18.10",
"@babel/core": "7.18.10",
"@babel/eslint-parser": "7.18.9",
"@babel/preset-env": "7.18.10",
"@commitlint/cli": "17.0.3",
"@commitlint/config-conventional": "17.0.3",
"bundlewatch": "0.3.3",
"eslint": "8.21.0",
"eslint-config-prettier": "8.5.0",
"eslint-config-standard": "17.0.0",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-prettier": "3.1.4",
"eslint-plugin-promise": "4.2.1",
"eslint-plugin-standard": "4.0.1",
"husky": "4.3.0",
"jest": "25.5.4",
"lint-staged": "10.4.0",
"eslint-plugin-prettier": "4.2.1",
"eslint-plugin-promise": "6.0.0",
"husky": "8.0.1",
"jest": "28.1.3",
"lint-staged": "13.0.3",
"npm-run-all": "4.1.5",
"optional-dev-dependency": "2.0.1",
"prettier": "2.1.2",
"prettier": "2.7.1",
"random-seed": "0.3.0",
"rollup": "2.28.2",
"rollup-plugin-terser": "7.0.2",
"runmd": "1.3.2",
"standard-version": "9.0.0"
"runmd": "1.3.6",
"standard-version": "9.5.0"
},
"optionalDevDependencies": {
"@wdio/browserstack-service": "6.4.0",
"@wdio/cli": "6.4.0",
"@wdio/jasmine-framework": "6.4.0",
"@wdio/local-runner": "6.4.0",
"@wdio/spec-reporter": "6.4.0",
"@wdio/static-server-service": "6.4.0",
"@wdio/sync": "6.4.0"
"@wdio/browserstack-service": "7.16.10",
"@wdio/cli": "7.16.10",
"@wdio/jasmine-framework": "7.16.6",
"@wdio/local-runner": "7.16.10",
"@wdio/spec-reporter": "7.16.9",
"@wdio/static-server-service": "7.16.6"
},

@@ -93,2 +93,4 @@ "scripts": {

"examples:node:esmodules:test": "cd examples/node-esmodules && npm install && npm test",
"examples:node:jest:test": "cd examples/node-jest && npm install && npm test",
"prepare": "cd $( git rev-parse --show-toplevel ) && husky install",
"lint": "npm run eslint:check && npm run prettier:check",

@@ -98,3 +100,3 @@ "eslint:check": "eslint src/ test/ examples/ *.js",

"pretest": "[ -n $CI ] || npm run build",
"test": "BABEL_ENV=commonjs node --throw-deprecation node_modules/.bin/jest test/unit/",
"test": "BABEL_ENV=commonjsNode node --throw-deprecation node_modules/.bin/jest test/unit/",
"pretest:browser": "optional-dev-dependency && npm run build && npm-run-all --parallel examples:browser:**",

@@ -107,7 +109,7 @@ "test:browser": "wdio run ./wdio.conf.js",

"test:benchmark": "cd examples/benchmark && npm install && npm test",
"prettier:check": "prettier --ignore-path .prettierignore --check '**/*.{js,jsx,json,md}'",
"prettier:fix": "prettier --ignore-path .prettierignore --write '**/*.{js,jsx,json,md}'",
"prettier:check": "prettier --check '**/*.{js,jsx,json,md}'",
"prettier:fix": "prettier --write '**/*.{js,jsx,json,md}'",
"bundlewatch": "npm run pretest:browser && bundlewatch --config bundlewatch.config.json",
"md": "runmd --watch --output=README.md README_js.md",
"docs": "( node --version | grep -q 'v12' ) && ( npm run build && runmd --output=README.md README_js.md )",
"docs": "( node --version | grep -q 'v16' ) && ( npm run build && runmd --output=README.md README_js.md )",
"docs:diff": "npm run docs && git diff --quiet README.md",

@@ -122,8 +124,2 @@ "build": "./scripts/build.sh",

},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "lint-staged"
}
},
"lint-staged": {

@@ -130,0 +126,0 @@ "*.{js,jsx,json,md}": [

@@ -7,3 +7,3 @@ <!--

For the creation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDs
For the creation of [RFC4122](https://www.ietf.org/rfc/rfc4122.txt) UUIDs

@@ -13,4 +13,4 @@ - **Complete** - Support for RFC4122 version 1, 3, 4, and 5 UUIDs

- CommonJS, [ECMAScript Modules](#ecmascript-modules) and [CDN builds](#cdn-builds)
- Node 8, 10, 12, 14
- Chrome, Safari, Firefox, Edge, IE 11 browsers
- Node 10, 12, 14, 16
- Chrome, Safari, Firefox, Edge browsers
- Webpack and rollup.js module bundlers

@@ -22,3 +22,3 @@ - [React Native / Expo](#react-native--expo)

**Upgrading from `uuid@3.x`?** Your code is probably okay, but check out [Upgrading From `uuid@3.x`](#upgrading-from-uuid3x) for details.
**Upgrading from `uuid@3`?** Your code is probably okay, but check out [Upgrading From `uuid@3`](#upgrading-from-uuid3) for details.

@@ -128,18 +128,3 @@ ## Quickstart

const uuidBytes = [
0x6e,
0xc0,
0xbd,
0x7f,
0x11,
0xc0,
0x43,
0xda,
0x97,
0x5e,
0x2a,
0x8a,
0xd9,
0xeb,
0xae,
0x0b,
0x6e, 0xc0, 0xbd, 0x7f, 0x11, 0xc0, 0x43, 0xda, 0x97, 0x5e, 0x2a, 0x8a, 0xd9, 0xeb, 0xae, 0x0b,
];

@@ -230,18 +215,3 @@

random: [
0x10,
0x91,
0x56,
0xbe,
0xc4,
0xfb,
0xc1,
0xea,
0x71,
0xb4,
0xef,
0xe1,
0x67,
0x1c,
0x58,
0x36,
0x10, 0x91, 0x56, 0xbe, 0xc4, 0xfb, 0xc1, 0xea, 0x71, 0xb4, 0xef, 0xe1, 0x67, 0x1c, 0x58, 0x36,
],

@@ -345,3 +315,3 @@ };

```shell
$ uuid
$ npx uuid
ddeb27fb-d9a0-4624-be4d-4615062daed4

@@ -353,3 +323,3 @@ ```

```shell
$ uuid --help
$ npx uuid --help

@@ -398,34 +368,17 @@ Usage:

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:
As of `uuid@9` [UMD (Universal Module Definition)](https://github.com/umdjs/umd) builds are no longer shipped with this library.
**Using [UNPKG](https://unpkg.com/uuid@latest/dist/umd/)**:
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.
```html
<script src="https://unpkg.com/uuid@latest/dist/umd/uuidv4.min.js"></script>
```
## Known issues
**Using [jsDelivr](https://cdn.jsdelivr.net/npm/uuid@latest/dist/umd/)**:
### Duplicate UUIDs (Googlebot)
```html
<script src="https://cdn.jsdelivr.net/npm/uuid@latest/dist/umd/uuidv4.min.js"></script>
```
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:
**Using [cdnjs](https://cdnjs.com/libraries/uuid)**:
- Check for duplicate UUIDs, fail gracefully
- Disable write operations for Googlebot clients
```html
<script src="https://cdnjs.cloudflare.com/ajax/libs/uuid/8.1.0/uuidv4.min.js"></script>
```
### "getRandomValues() not supported"
These CDNs all provide the same [`uuidv4()`](#uuidv4options-buffer-offset) method:
```html
<script>
uuidv4(); // ⇨ '55af1e37-0734-46d8-b070-a1e42e4fc392'
</script>
```
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.
## "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:

@@ -449,7 +402,11 @@

## Upgrading From `uuid@7.x`
### IE 11 (Internet Explorer)
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/)).
## Upgrading From `uuid@7`
### Only Named Exports Supported When Using with Node.js ESM
`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.
`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.

@@ -472,7 +429,7 @@ Instead of doing:

Deep requires like `require('uuid/v4')` [which have been deprecated in `uuid@7.x`](#deep-requires-now-deprecated) are no longer supported.
Deep requires like `require('uuid/v4')` [which have been deprecated in `uuid@7`](#deep-requires-now-deprecated) are no longer supported.
## Upgrading From `uuid@3.x`
## Upgrading From `uuid@3`
"_Wait... what happened to `uuid@4.x` - `uuid@6.x`?!?_"
"_Wait... what happened to `uuid@4` thru `uuid@6`?!?_"

@@ -483,3 +440,3 @@ 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.

`uuid@3.x` encouraged the use of deep requires to minimize the bundle size of browser builds:
`uuid@3` encouraged the use of deep requires to minimize the bundle size of browser builds:

@@ -491,3 +448,3 @@ ```javascript

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:
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:

@@ -508,3 +465,3 @@ ```javascript

`uuid@3.x` was exporting the Version 4 UUID method as a default export:
`uuid@3` was exporting the Version 4 UUID method as a default export:

@@ -515,5 +472,5 @@ ```javascript

This usage pattern was already discouraged in `uuid@3.x` and has been removed in `uuid@7.x`.
This usage pattern was already discouraged in `uuid@3` and has been removed in `uuid@7`.
----
Markdown generated from [README_js.md](README_js.md) by [![RunMD Logo](http://i.imgur.com/h0FVyzU.png)](https://github.com/broofa/runmd)
Markdown generated from [README_js.md](README_js.md) by [![RunMD Logo](https://i.imgur.com/h0FVyzU.png)](https://github.com/broofa/runmd)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc