Auto-commit 2026-05-02 09:37
This commit is contained in:
1
node_modules/@lukeed/csprng/browser/index.d.ts
generated
vendored
Normal file
1
node_modules/@lukeed/csprng/browser/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export function random<T=Uint8Array>(len: number): T;
|
||||
5
node_modules/@lukeed/csprng/browser/index.js
generated
vendored
Normal file
5
node_modules/@lukeed/csprng/browser/index.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
function random(len) {
|
||||
return crypto.getRandomValues(new Uint8Array(len));
|
||||
}
|
||||
|
||||
exports.random = random;
|
||||
1
node_modules/@lukeed/csprng/browser/index.min.js
generated
vendored
Normal file
1
node_modules/@lukeed/csprng/browser/index.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e["@lukeed/csprng"]={})}(this,(function(e){e.random=function(e){return crypto.getRandomValues(new Uint8Array(e))}}));
|
||||
3
node_modules/@lukeed/csprng/browser/index.mjs
generated
vendored
Normal file
3
node_modules/@lukeed/csprng/browser/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
export function random(len) {
|
||||
return crypto.getRandomValues(new Uint8Array(len));
|
||||
}
|
||||
1
node_modules/@lukeed/csprng/index.d.ts
generated
vendored
Normal file
1
node_modules/@lukeed/csprng/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export function random<T = Buffer | Uint8Array>(len: number): T;
|
||||
9
node_modules/@lukeed/csprng/license
generated
vendored
Normal file
9
node_modules/@lukeed/csprng/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)
|
||||
|
||||
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.
|
||||
1
node_modules/@lukeed/csprng/node/index.d.ts
generated
vendored
Normal file
1
node_modules/@lukeed/csprng/node/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export function random<T=Buffer>(len: number): T;
|
||||
7
node_modules/@lukeed/csprng/node/index.js
generated
vendored
Normal file
7
node_modules/@lukeed/csprng/node/index.js
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
const { randomBytes } = require('crypto');
|
||||
|
||||
function random(len) {
|
||||
return randomBytes(len);
|
||||
}
|
||||
|
||||
exports.random = random;
|
||||
1
node_modules/@lukeed/csprng/node/index.min.js
generated
vendored
Normal file
1
node_modules/@lukeed/csprng/node/index.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e["@lukeed/csprng"]={})}(this,(function(e){const{randomBytes:n}=require("crypto");e.random=function(e){return n(e)}}));
|
||||
5
node_modules/@lukeed/csprng/node/index.mjs
generated
vendored
Normal file
5
node_modules/@lukeed/csprng/node/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
import { randomBytes } from 'crypto';
|
||||
|
||||
export function random(len) {
|
||||
return randomBytes(len);
|
||||
}
|
||||
73
node_modules/@lukeed/csprng/package.json
generated
vendored
Normal file
73
node_modules/@lukeed/csprng/package.json
generated
vendored
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"version": "1.1.0",
|
||||
"name": "@lukeed/csprng",
|
||||
"repository": "lukeed/csprng",
|
||||
"description": "An alias package for `crypto.randomBytes` in Node.js and/or browsers",
|
||||
"unpkg": "browser/index.min.js",
|
||||
"browser": "browser/index.mjs",
|
||||
"module": "node/index.mjs",
|
||||
"main": "node/index.js",
|
||||
"types": "index.d.ts",
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "Luke Edwards",
|
||||
"email": "luke.edwards05@gmail.com",
|
||||
"url": "https://lukeed.com"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"browser": {
|
||||
"types": "./browser/index.d.ts",
|
||||
"import": "./browser/index.mjs",
|
||||
"require": "./browser/index.js"
|
||||
},
|
||||
"types": "./node/index.d.ts",
|
||||
"import": "./node/index.mjs",
|
||||
"require": "./node/index.js"
|
||||
},
|
||||
"./node": {
|
||||
"types": "./node/index.d.ts",
|
||||
"import": "./node/index.mjs",
|
||||
"require": "./node/index.js"
|
||||
},
|
||||
"./browser": {
|
||||
"types": "./browser/index.d.ts",
|
||||
"import": "./browser/index.mjs",
|
||||
"require": "./browser/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "bundt",
|
||||
"test": "uvu -r esm test"
|
||||
},
|
||||
"files": [
|
||||
"*.d.ts",
|
||||
"browser",
|
||||
"node"
|
||||
],
|
||||
"modes": {
|
||||
"browser": "src/browser.js",
|
||||
"node": "src/node.js"
|
||||
},
|
||||
"keywords": [
|
||||
"crypto",
|
||||
"browser",
|
||||
"isomorphic",
|
||||
"getRandomValues",
|
||||
"randomFill",
|
||||
"random",
|
||||
"csprng"
|
||||
],
|
||||
"devDependencies": {
|
||||
"bundt": "1.1.1",
|
||||
"esm": "3.2.25",
|
||||
"uvu": "0.5.2"
|
||||
},
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
}
|
||||
}
|
||||
76
node_modules/@lukeed/csprng/readme.md
generated
vendored
Normal file
76
node_modules/@lukeed/csprng/readme.md
generated
vendored
Normal file
@@ -0,0 +1,76 @@
|
||||
# @lukeed/csprng  [](https://codecov.io/gh/lukeed/csprng)
|
||||
|
||||
> A tiny (~90B) isomorphic wrapper for `crypto.randomBytes` in Node.js and browsers.
|
||||
|
||||
***Why?***
|
||||
|
||||
This package allows you/dependents to import a cryptographically secure generator (CSPRNG) _without_ worrying about (aka, checking the runtime environment for) the different `crypto` implementations. Instead, by extracting a `random` function into a third-party/external package, one can rely on bundlers and/or module resolution to load the correct implementation for the desired environment.
|
||||
|
||||
In other words, one can include the browser-specific implementation when bundling for the browser, completely ignoring the Node.js code – or vice versa.
|
||||
|
||||
By default, this module is set up to work with Rollup, webpack, and Node's native ESM _and_ CommonJS path resolutions.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save @lukeed/csprng
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
***General Usage***
|
||||
|
||||
```js
|
||||
// Rely on bundlers/environment detection
|
||||
import { random } from '@lukeed/csprng';
|
||||
|
||||
const array = random(12);
|
||||
// browser => Uint8Array(12) [...]
|
||||
// Node.js => <Buffer ...>
|
||||
```
|
||||
|
||||
***Specific Environment***
|
||||
|
||||
```js
|
||||
// Choose the "browser" implementation explicitly.
|
||||
//=> ! NOTE ! Will break in Node.js environments!
|
||||
import { random } from '@lukeed/csprng/browser';
|
||||
|
||||
const array = random(1024);
|
||||
//=> Uint8Array(1024) [...]
|
||||
|
||||
// ---
|
||||
|
||||
// Choose the "node" implementation explicitly.
|
||||
//=> ! NOTE ! Will break in browser environments!
|
||||
import { random } from '@lukeed/csprng/node';
|
||||
|
||||
const array = random(1024);
|
||||
//=> <Buffer ...>
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### random(length)
|
||||
Returns: `Buffer` or `Uint8Array`
|
||||
|
||||
Returns a typed array of given `length`.
|
||||
|
||||
|
||||
#### length
|
||||
Type: `Number`
|
||||
|
||||
The desired length of your output TypedArray.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [uid](https://github.com/lukeed/uid) - A tiny (134B) and fast utility to randomize unique IDs of fixed length
|
||||
- [@lukeed/uuid](https://github.com/lukeed/uuid) - A tiny (230B), fast, and cryptographically secure UUID (V4) generator for Node and the browser
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Luke Edwards](https://lukeed.com)
|
||||
26
node_modules/@lukeed/uuid/dist/index.js
generated
vendored
Normal file
26
node_modules/@lukeed/uuid/dist/index.js
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
var IDX=256, HEX=[], BUFFER;
|
||||
while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);
|
||||
|
||||
function v4() {
|
||||
var i=0, num, out='';
|
||||
|
||||
if (!BUFFER || ((IDX + 16) > 256)) {
|
||||
BUFFER = Array(i=256);
|
||||
while (i--) BUFFER[i] = 256 * Math.random() | 0;
|
||||
i = IDX = 0;
|
||||
}
|
||||
|
||||
for (; i < 16; i++) {
|
||||
num = BUFFER[IDX + i];
|
||||
if (i==6) out += HEX[num & 15 | 64];
|
||||
else if (i==8) out += HEX[num & 63 | 128];
|
||||
else out += HEX[num];
|
||||
|
||||
if (i & 1 && i > 1 && i < 11) out += '-';
|
||||
}
|
||||
|
||||
IDX++;
|
||||
return out;
|
||||
}
|
||||
|
||||
exports.v4 = v4;
|
||||
1
node_modules/@lukeed/uuid/dist/index.min.js
generated
vendored
Normal file
1
node_modules/@lukeed/uuid/dist/index.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.uuid={})}(this,(function(e){for(var n,o=256,t=[];o--;)t[o]=(o+256).toString(16).substring(1);e.v4=function(){var e,f=0,r="";if(!n||o+16>256){for(n=Array(f=256);f--;)n[f]=256*Math.random()|0;f=o=0}for(;f<16;f++)e=n[o+f],r+=6==f?t[15&e|64]:8==f?t[63&e|128]:t[e],1&f&&f>1&&f<11&&(r+="-");return o++,r}}));
|
||||
24
node_modules/@lukeed/uuid/dist/index.mjs
generated
vendored
Normal file
24
node_modules/@lukeed/uuid/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
var IDX=256, HEX=[], BUFFER;
|
||||
while (IDX--) HEX[IDX] = (IDX + 256).toString(16).substring(1);
|
||||
|
||||
export function v4() {
|
||||
var i=0, num, out='';
|
||||
|
||||
if (!BUFFER || ((IDX + 16) > 256)) {
|
||||
BUFFER = Array(i=256);
|
||||
while (i--) BUFFER[i] = 256 * Math.random() | 0;
|
||||
i = IDX = 0;
|
||||
}
|
||||
|
||||
for (; i < 16; i++) {
|
||||
num = BUFFER[IDX + i];
|
||||
if (i==6) out += HEX[num & 15 | 64];
|
||||
else if (i==8) out += HEX[num & 63 | 128];
|
||||
else out += HEX[num];
|
||||
|
||||
if (i & 1 && i > 1 && i < 11) out += '-';
|
||||
}
|
||||
|
||||
IDX++;
|
||||
return out;
|
||||
}
|
||||
1
node_modules/@lukeed/uuid/index.d.ts
generated
vendored
Normal file
1
node_modules/@lukeed/uuid/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export function v4(): string;
|
||||
9
node_modules/@lukeed/uuid/license
generated
vendored
Normal file
9
node_modules/@lukeed/uuid/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Luke Edwards <luke.edwards05@gmail.com> (lukeed.com)
|
||||
|
||||
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.
|
||||
69
node_modules/@lukeed/uuid/package.json
generated
vendored
Normal file
69
node_modules/@lukeed/uuid/package.json
generated
vendored
Normal file
@@ -0,0 +1,69 @@
|
||||
{
|
||||
"version": "2.0.1",
|
||||
"name": "@lukeed/uuid",
|
||||
"repository": "lukeed/uuid",
|
||||
"description": "A tiny (230B) and fast UUID (v4) generator for Node and the browser",
|
||||
"unpkg": "dist/index.min.js",
|
||||
"module": "dist/index.mjs",
|
||||
"main": "dist/index.js",
|
||||
"types": "index.d.ts",
|
||||
"umd:name": "uuid",
|
||||
"license": "MIT",
|
||||
"author": {
|
||||
"name": "Luke Edwards",
|
||||
"email": "luke.edwards05@gmail.com",
|
||||
"url": "https://lukeed.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "bundt",
|
||||
"pretest": "npm run build",
|
||||
"test": "uvu -r esm test"
|
||||
},
|
||||
"exports": {
|
||||
".": {
|
||||
"types": "./index.d.ts",
|
||||
"import": "./dist/index.mjs",
|
||||
"require": "./dist/index.js"
|
||||
},
|
||||
"./secure": {
|
||||
"types": "./secure/index.d.ts",
|
||||
"import": "./secure/index.mjs",
|
||||
"require": "./secure/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"files": [
|
||||
"*.d.ts",
|
||||
"secure",
|
||||
"dist"
|
||||
],
|
||||
"modes": {
|
||||
"secure": "src/secure.js",
|
||||
"default": "src/index.js"
|
||||
},
|
||||
"keywords": [
|
||||
"guid",
|
||||
"secure",
|
||||
"browser",
|
||||
"cryptographic",
|
||||
"isomorphic",
|
||||
"rfc4122",
|
||||
"random",
|
||||
"crypto",
|
||||
"csprng",
|
||||
"uuid",
|
||||
"uid"
|
||||
],
|
||||
"dependencies": {
|
||||
"@lukeed/csprng": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"bundt": "1.1.1",
|
||||
"esm": "3.2.25",
|
||||
"is-uuid": "1.0.2",
|
||||
"uvu": "0.3.4"
|
||||
}
|
||||
}
|
||||
109
node_modules/@lukeed/uuid/readme.md
generated
vendored
Normal file
109
node_modules/@lukeed/uuid/readme.md
generated
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
# @lukeed/uuid  [](https://codecov.io/gh/lukeed/uuid)
|
||||
|
||||
> A tiny (~230B) and [fast](#benchmarks) UUID (v4) generator for Node and the browser.
|
||||
|
||||
This module offers two [modes](#modes) for your needs:
|
||||
|
||||
* [`@lukeed/uuid`](#lukeeduuid)<br>_The default is "non-secure", which uses `Math.random` to produce UUIDs._
|
||||
* [`@lukeed/uuid/secure`](#lukeeduuidsecure)<br>_The "secure" mode produces cryptographically secure (CSPRNG) UUIDs using the current environment's `crypto` module._
|
||||
|
||||
> **Important:** <br>Version `1.0.0` only offered a "secure" implementation.<br>In `v2.0.0`, this is now exported as the `"@lukeed/uuid/secure"` entry.
|
||||
|
||||
Additionally, this module is preconfigured for native ESM support in Node.js with fallback to CommonJS. It will also work with any Rollup and webpack configuration.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install --save @lukeed/uuid
|
||||
```
|
||||
|
||||
## Modes
|
||||
|
||||
There are two "versions" of `@lukeed/uuid` available:
|
||||
|
||||
#### `@lukeed/uuid`
|
||||
> **Size (gzip):** 231 bytes<br>
|
||||
> **Availability:** [CommonJS](https://unpkg.com/@lukeed/uuid/dist/index.js), [ES Module](https://unpkg.com/@lukeed/uuid/dist/index.mjs), [UMD](https://unpkg.com/@lukeed/uuid/dist/index.min.js)
|
||||
|
||||
Relies on `Math.random`, which means that, while faster, this mode **is not** cryptographically secure. <br>Works in Node.js and all browsers.
|
||||
|
||||
#### `@lukeed/uuid/secure`
|
||||
> **Size (gzip):** 235 bytes<br>
|
||||
> **Availability:** [CommonJS](https://unpkg.com/@lukeed/uuid/secure/index.js), [ES Module](https://unpkg.com/@lukeed/uuid/secure/index.mjs), [UMD](https://unpkg.com/@lukeed/uuid/secure/index.min.js)
|
||||
|
||||
Relies on the environment's `crypto` module in order to produce cryptographically secure (CSPRNG) values. <br>Works in all versions of Node.js. Works in all browsers with [`crypto.getRandomValues()` support](https://caniuse.com/#feat=getrandomvalues).
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import { v4 as uuid } from '@lukeed/uuid';
|
||||
import { v4 as secure } from '@lukeed/uuid/secure';
|
||||
|
||||
uuid(); //=> '400fa120-5e9f-411e-94bd-2a23f6695704'
|
||||
uuid(); //=> 'cd6ffb4d-2eda-4c84-aef5-71eb360ac8c5'
|
||||
|
||||
secure(); //=> '8641f70e-8112-4168-9d81-d38170bfa612'
|
||||
secure(); //=> 'd175fabc-2a4d-475f-be56-29ba8104c2f2'
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### uuid.v4()
|
||||
Returns: `string`
|
||||
|
||||
Creates a new Version 4 (random) [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUID.
|
||||
|
||||
|
||||
## Benchmarks
|
||||
|
||||
> Running on Node.js v12.18.4
|
||||
|
||||
```
|
||||
Validation:
|
||||
✔ String.replace(Math.random)
|
||||
✔ String.replace(crypto)
|
||||
✔ uuid/v4
|
||||
✔ @lukeed/uuid
|
||||
✔ @lukeed/uuid/secure
|
||||
|
||||
Benchmark:
|
||||
String.replace(Math.random) x 381,358 ops/sec ±0.31% (93 runs sampled)
|
||||
String.replace(crypto) x 15,842 ops/sec ±1.16% (86 runs sampled)
|
||||
uuid/v4 x 1,259,600 ops/sec ±0.45% (91 runs sampled)
|
||||
@lukeed/uuid x 6,384,840 ops/sec ±0.22% (95 runs sampled)
|
||||
@lukeed/uuid/secure x 5,439,096 ops/sec ±0.23% (98 runs sampled)
|
||||
```
|
||||
|
||||
> Running on Chrome v85.0.4183.121
|
||||
|
||||
```
|
||||
Validation:
|
||||
✔ String.replace(Math.random)
|
||||
✔ uuid/v4
|
||||
✔ @lukeed/uuid
|
||||
✔ @lukeed/uuid/secure
|
||||
|
||||
Benchmark:
|
||||
String.replace(Math.random) x 313,213 ops/sec ±0.58% (65 runs sampled)
|
||||
uuid/v4 x 302,914 ops/sec ±0.94% (64 runs sampled)
|
||||
@lukeed/uuid x 5,881,761 ops/sec ±1.29% (62 runs sampled)
|
||||
@lukeed/uuid/secure x 852,939 ops/sec ±0.88% (65 runs sampled)
|
||||
```
|
||||
|
||||
## Performance
|
||||
|
||||
The reason why this UUID.V4 implementation is so much faster is two-fold:
|
||||
|
||||
1) It composes an output with hexadecimal pairs (from a cached dictionary) instead of single characters.
|
||||
2) It allocates a larger Buffer/ArrayBuffer up front (expensive) and slices off chunks as needed (cheap).
|
||||
|
||||
The `@lukeed/uuid/secure` module maintains an internal ArrayBuffer of 4096 bytes, which supplies **256** `uuid.v4()` invocations. However, the default module preallocates **256** invocations using less memory upfront. Both implementations will regenerate its internal allocation as needed.
|
||||
|
||||
A larger buffer would result in higher performance over time, but I found this to be a good balance of performance and memory space.
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Luke Edwards](https://lukeed.com)
|
||||
1
node_modules/@lukeed/uuid/secure/index.d.ts
generated
vendored
Normal file
1
node_modules/@lukeed/uuid/secure/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export function v4(): string;
|
||||
29
node_modules/@lukeed/uuid/secure/index.js
generated
vendored
Normal file
29
node_modules/@lukeed/uuid/secure/index.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
const { random } = require('@lukeed/csprng');
|
||||
|
||||
var SIZE=4096, HEX=[], IDX=0, BUFFER;
|
||||
|
||||
for (; IDX < 256; IDX++) {
|
||||
HEX[IDX] = (IDX + 256).toString(16).substring(1);
|
||||
}
|
||||
|
||||
function v4() {
|
||||
if (!BUFFER || ((IDX + 16) > SIZE)) {
|
||||
BUFFER = random(SIZE);
|
||||
IDX = 0;
|
||||
}
|
||||
|
||||
var i=0, tmp, out='';
|
||||
for (; i < 16; i++) {
|
||||
tmp = BUFFER[IDX + i];
|
||||
if (i==6) out += HEX[tmp & 15 | 64];
|
||||
else if (i==8) out += HEX[tmp & 63 | 128];
|
||||
else out += HEX[tmp];
|
||||
|
||||
if (i & 1 && i > 1 && i < 11) out += '-';
|
||||
}
|
||||
|
||||
IDX += 16;
|
||||
return out;
|
||||
}
|
||||
|
||||
exports.v4 = v4;
|
||||
1
node_modules/@lukeed/uuid/secure/index.min.js
generated
vendored
Normal file
1
node_modules/@lukeed/uuid/secure/index.min.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(e.uuid={})}(this,(function(e){const{random:n}=require("@lukeed/csprng");for(var o,t=[],r=0;r<256;r++)t[r]=(r+256).toString(16).substring(1);e.v4=function(){(!o||r+16>4096)&&(o=n(4096),r=0);for(var e,f=0,i="";f<16;f++)e=o[r+f],i+=6==f?t[15&e|64]:8==f?t[63&e|128]:t[e],1&f&&f>1&&f<11&&(i+="-");return r+=16,i}}));
|
||||
27
node_modules/@lukeed/uuid/secure/index.mjs
generated
vendored
Normal file
27
node_modules/@lukeed/uuid/secure/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,27 @@
|
||||
import { random } from '@lukeed/csprng';
|
||||
|
||||
var SIZE=4096, HEX=[], IDX=0, BUFFER;
|
||||
|
||||
for (; IDX < 256; IDX++) {
|
||||
HEX[IDX] = (IDX + 256).toString(16).substring(1);
|
||||
}
|
||||
|
||||
export function v4() {
|
||||
if (!BUFFER || ((IDX + 16) > SIZE)) {
|
||||
BUFFER = random(SIZE);
|
||||
IDX = 0;
|
||||
}
|
||||
|
||||
var i=0, tmp, out='';
|
||||
for (; i < 16; i++) {
|
||||
tmp = BUFFER[IDX + i];
|
||||
if (i==6) out += HEX[tmp & 15 | 64];
|
||||
else if (i==8) out += HEX[tmp & 63 | 128];
|
||||
else out += HEX[tmp];
|
||||
|
||||
if (i & 1 && i > 1 && i < 11) out += '-';
|
||||
}
|
||||
|
||||
IDX += 16;
|
||||
return out;
|
||||
}
|
||||
Reference in New Issue
Block a user