uuid 3.3.2 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +74 -49
- package/CONTRIBUTING.md +20 -0
- package/README.md +246 -156
- package/dist/bin/uuid +2 -0
- package/dist/bytesToUuid.js +27 -0
- package/dist/esm-browser/bytesToUuid.js +18 -0
- package/dist/esm-browser/index.js +4 -0
- package/{lib/md5-browser.js → dist/esm-browser/md5.js} +53 -51
- package/dist/esm-browser/rng.js +15 -0
- package/dist/esm-browser/sha1.js +91 -0
- package/dist/esm-browser/v1.js +95 -0
- package/dist/esm-browser/v3.js +4 -0
- package/{lib → dist/esm-browser}/v35.js +21 -22
- package/dist/esm-browser/v4.js +27 -0
- package/dist/esm-browser/v5.js +4 -0
- package/dist/index.js +39 -0
- package/dist/md5.js +24 -0
- package/dist/rng.js +16 -0
- package/dist/sha1.js +24 -0
- package/dist/umd/uuid.min.js +1 -0
- package/dist/umd/uuidv1.min.js +1 -0
- package/dist/umd/uuidv3.min.js +1 -0
- package/dist/umd/uuidv4.min.js +1 -0
- package/dist/umd/uuidv5.min.js +1 -0
- package/dist/uuid-bin.js +67 -0
- package/dist/v1.js +108 -0
- package/dist/v3.js +17 -0
- package/dist/v35.js +69 -0
- package/dist/v4.js +41 -0
- package/dist/v5.js +17 -0
- package/package.json +79 -19
- package/v1.js +6 -107
- package/v3.js +7 -3
- package/v4.js +6 -27
- package/v5.js +8 -3
- package/.eslintrc.json +0 -47
- package/AUTHORS +0 -5
- package/README_js.md +0 -280
- package/bin/uuid +0 -65
- package/index.js +0 -8
- package/lib/bytesToUuid.js +0 -24
- package/lib/md5.js +0 -25
- package/lib/rng-browser.js +0 -34
- package/lib/rng.js +0 -8
- package/lib/sha1-browser.js +0 -89
- package/lib/sha1.js +0 -25
package/.eslintrc.json
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"root": true,
|
|
3
|
-
"env": {
|
|
4
|
-
"browser": true,
|
|
5
|
-
"commonjs": true,
|
|
6
|
-
"node": true,
|
|
7
|
-
"mocha": true
|
|
8
|
-
},
|
|
9
|
-
"extends": ["eslint:recommended"],
|
|
10
|
-
"rules": {
|
|
11
|
-
"array-bracket-spacing": ["warn", "never"],
|
|
12
|
-
"arrow-body-style": ["warn", "as-needed"],
|
|
13
|
-
"arrow-parens": ["warn", "as-needed"],
|
|
14
|
-
"arrow-spacing": "warn",
|
|
15
|
-
"brace-style": ["warn", "1tbs"],
|
|
16
|
-
"camelcase": "warn",
|
|
17
|
-
"comma-spacing": ["warn", {"after": true}],
|
|
18
|
-
"dot-notation": "warn",
|
|
19
|
-
"eqeqeq": ["warn", "smart"],
|
|
20
|
-
"indent": ["warn", 2, {
|
|
21
|
-
"SwitchCase": 1,
|
|
22
|
-
"FunctionDeclaration": {"parameters": 1},
|
|
23
|
-
"MemberExpression": 1,
|
|
24
|
-
"CallExpression": {"arguments": 1}
|
|
25
|
-
}],
|
|
26
|
-
"key-spacing": ["warn", {"beforeColon": false, "afterColon": true, "mode": "minimum"}],
|
|
27
|
-
"keyword-spacing": "warn",
|
|
28
|
-
"no-console": "off",
|
|
29
|
-
"no-empty": "off",
|
|
30
|
-
"no-multi-spaces": "warn",
|
|
31
|
-
"no-redeclare": "off",
|
|
32
|
-
"no-restricted-globals": ["warn", "Promise"],
|
|
33
|
-
"no-trailing-spaces": "warn",
|
|
34
|
-
"no-undef": "error",
|
|
35
|
-
"no-unused-vars": ["warn", {"args": "none"}],
|
|
36
|
-
"one-var": ["warn", "never"],
|
|
37
|
-
"padded-blocks": ["warn", "never"],
|
|
38
|
-
"object-curly-spacing": ["warn", "never"],
|
|
39
|
-
"quotes": ["warn", "single"],
|
|
40
|
-
"react/prop-types": "off",
|
|
41
|
-
"react/jsx-no-bind": "off",
|
|
42
|
-
"semi": ["warn", "always"],
|
|
43
|
-
"space-before-blocks": ["warn", "always"],
|
|
44
|
-
"space-before-function-paren": ["warn", "never"],
|
|
45
|
-
"space-in-parens": ["warn", "never"]
|
|
46
|
-
}
|
|
47
|
-
}
|
package/AUTHORS
DELETED
package/README_js.md
DELETED
|
@@ -1,280 +0,0 @@
|
|
|
1
|
-
```javascript --hide
|
|
2
|
-
runmd.onRequire = path => path.replace(/^uuid/, './');
|
|
3
|
-
```
|
|
4
|
-
|
|
5
|
-
# uuid [](http://travis-ci.org/kelektiv/node-uuid) #
|
|
6
|
-
|
|
7
|
-
Simple, fast generation of [RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDS.
|
|
8
|
-
|
|
9
|
-
Features:
|
|
10
|
-
|
|
11
|
-
* Support for version 1, 3, 4 and 5 UUIDs
|
|
12
|
-
* Cross-platform
|
|
13
|
-
* Uses cryptographically-strong random number APIs (when available)
|
|
14
|
-
* Zero-dependency, small footprint (... but not [this small](https://gist.github.com/982883))
|
|
15
|
-
|
|
16
|
-
[**Deprecation warning**: The use of `require('uuid')` is deprecated and will not be
|
|
17
|
-
supported after version 3.x of this module. Instead, use `require('uuid/[v1|v3|v4|v5]')` as shown in the examples below.]
|
|
18
|
-
|
|
19
|
-
## Quickstart - CommonJS (Recommended)
|
|
20
|
-
|
|
21
|
-
```shell
|
|
22
|
-
npm install uuid
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
Then generate your uuid version of choice ...
|
|
26
|
-
|
|
27
|
-
Version 1 (timestamp):
|
|
28
|
-
|
|
29
|
-
```javascript --run v1
|
|
30
|
-
const uuidv1 = require('uuid/v1');
|
|
31
|
-
uuidv1(); // RESULT
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
Version 3 (namespace):
|
|
35
|
-
|
|
36
|
-
```javascript --run v3
|
|
37
|
-
const uuidv3 = require('uuid/v3');
|
|
38
|
-
|
|
39
|
-
// ... using predefined DNS namespace (for domain names)
|
|
40
|
-
uuidv3('hello.example.com', uuidv3.DNS); // RESULT
|
|
41
|
-
|
|
42
|
-
// ... using predefined URL namespace (for, well, URLs)
|
|
43
|
-
uuidv3('http://example.com/hello', uuidv3.URL); // RESULT
|
|
44
|
-
|
|
45
|
-
// ... using a custom namespace
|
|
46
|
-
//
|
|
47
|
-
// Note: Custom namespaces should be a UUID string specific to your application!
|
|
48
|
-
// E.g. the one here was generated using this modules `uuid` CLI.
|
|
49
|
-
const MY_NAMESPACE = '1b671a64-40d5-491e-99b0-da01ff1f3341';
|
|
50
|
-
uuidv3('Hello, World!', MY_NAMESPACE); // RESULT
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
Version 4 (random):
|
|
54
|
-
|
|
55
|
-
```javascript --run v4
|
|
56
|
-
const uuidv4 = require('uuid/v4');
|
|
57
|
-
uuidv4(); // RESULT
|
|
58
|
-
```
|
|
59
|
-
|
|
60
|
-
Version 5 (namespace):
|
|
61
|
-
|
|
62
|
-
```javascript --run v5
|
|
63
|
-
const uuidv5 = require('uuid/v5');
|
|
64
|
-
|
|
65
|
-
// ... using predefined DNS namespace (for domain names)
|
|
66
|
-
uuidv5('hello.example.com', uuidv5.DNS); // RESULT
|
|
67
|
-
|
|
68
|
-
// ... using predefined URL namespace (for, well, URLs)
|
|
69
|
-
uuidv5('http://example.com/hello', uuidv5.URL); // RESULT
|
|
70
|
-
|
|
71
|
-
// ... using a custom namespace
|
|
72
|
-
//
|
|
73
|
-
// Note: Custom namespaces should be a UUID string specific to your application!
|
|
74
|
-
// E.g. the one here was generated using this modules `uuid` CLI.
|
|
75
|
-
const MY_NAMESPACE = '1b671a64-40d5-491e-99b0-da01ff1f3341';
|
|
76
|
-
uuidv5('Hello, World!', MY_NAMESPACE); // RESULT
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
## Quickstart - Browser-ready Versions
|
|
80
|
-
|
|
81
|
-
Browser-ready versions of this module are available via [wzrd.in](https://github.com/jfhbrook/wzrd.in).
|
|
82
|
-
|
|
83
|
-
For version 1 uuids:
|
|
84
|
-
|
|
85
|
-
```html
|
|
86
|
-
<script src="http://wzrd.in/standalone/uuid%2Fv1@latest"></script>
|
|
87
|
-
<script>
|
|
88
|
-
uuidv1(); // -> v1 UUID
|
|
89
|
-
</script>
|
|
90
|
-
```
|
|
91
|
-
|
|
92
|
-
For version 3 uuids:
|
|
93
|
-
|
|
94
|
-
```html
|
|
95
|
-
<script src="http://wzrd.in/standalone/uuid%2Fv3@latest"></script>
|
|
96
|
-
<script>
|
|
97
|
-
uuidv3('http://example.com/hello', uuidv3.URL); // -> v3 UUID
|
|
98
|
-
</script>
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
For version 4 uuids:
|
|
102
|
-
|
|
103
|
-
```html
|
|
104
|
-
<script src="http://wzrd.in/standalone/uuid%2Fv4@latest"></script>
|
|
105
|
-
<script>
|
|
106
|
-
uuidv4(); // -> v4 UUID
|
|
107
|
-
</script>
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
For version 5 uuids:
|
|
111
|
-
|
|
112
|
-
```html
|
|
113
|
-
<script src="http://wzrd.in/standalone/uuid%2Fv5@latest"></script>
|
|
114
|
-
<script>
|
|
115
|
-
uuidv5('http://example.com/hello', uuidv5.URL); // -> v5 UUID
|
|
116
|
-
</script>
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
## API
|
|
120
|
-
|
|
121
|
-
### Version 1
|
|
122
|
-
|
|
123
|
-
```javascript
|
|
124
|
-
const uuidv1 = require('uuid/v1');
|
|
125
|
-
|
|
126
|
-
// Incantations
|
|
127
|
-
uuidv1();
|
|
128
|
-
uuidv1(options);
|
|
129
|
-
uuidv1(options, buffer, offset);
|
|
130
|
-
```
|
|
131
|
-
|
|
132
|
-
Generate and return a RFC4122 v1 (timestamp-based) UUID.
|
|
133
|
-
|
|
134
|
-
* `options` - (Object) Optional uuid state to apply. Properties may include:
|
|
135
|
-
|
|
136
|
-
* `node` - (Array) Node id as Array of 6 bytes (per 4.1.6). Default: Randomly generated ID. See note 1.
|
|
137
|
-
* `clockseq` - (Number between 0 - 0x3fff) RFC clock sequence. Default: An internally maintained clockseq is used.
|
|
138
|
-
* `msecs` - (Number) Time in milliseconds since unix Epoch. Default: The current time is used.
|
|
139
|
-
* `nsecs` - (Number between 0-9999) additional time, in 100-nanosecond units. Ignored if `msecs` is unspecified. Default: internal uuid counter is used, as per 4.2.1.2.
|
|
140
|
-
|
|
141
|
-
* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.
|
|
142
|
-
* `offset` - (Number) Starting index in `buffer` at which to begin writing.
|
|
143
|
-
|
|
144
|
-
Returns `buffer`, if specified, otherwise the string form of the UUID
|
|
145
|
-
|
|
146
|
-
Note: The <node> id is generated guaranteed to stay constant for the lifetime of the current JS runtime. (Future versions of this module may use persistent storage mechanisms to extend this guarantee.)
|
|
147
|
-
|
|
148
|
-
Example: Generate string UUID with fully-specified options
|
|
149
|
-
|
|
150
|
-
```javascript --run v1
|
|
151
|
-
const v1options = {
|
|
152
|
-
node: [0x01, 0x23, 0x45, 0x67, 0x89, 0xab],
|
|
153
|
-
clockseq: 0x1234,
|
|
154
|
-
msecs: new Date('2011-11-01').getTime(),
|
|
155
|
-
nsecs: 5678
|
|
156
|
-
};
|
|
157
|
-
uuidv1(v1options); // RESULT
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
Example: In-place generation of two binary IDs
|
|
161
|
-
|
|
162
|
-
```javascript --run v1
|
|
163
|
-
// Generate two ids in an array
|
|
164
|
-
const arr = new Array();
|
|
165
|
-
uuidv1(null, arr, 0); // RESULT
|
|
166
|
-
uuidv1(null, arr, 16); // RESULT
|
|
167
|
-
```
|
|
168
|
-
|
|
169
|
-
### Version 3
|
|
170
|
-
|
|
171
|
-
```javascript
|
|
172
|
-
const uuidv3 = require('uuid/v3');
|
|
173
|
-
|
|
174
|
-
// Incantations
|
|
175
|
-
uuidv3(name, namespace);
|
|
176
|
-
uuidv3(name, namespace, buffer);
|
|
177
|
-
uuidv3(name, namespace, buffer, offset);
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
Generate and return a RFC4122 v3 UUID.
|
|
181
|
-
|
|
182
|
-
* `name` - (String | Array[]) "name" to create UUID with
|
|
183
|
-
* `namespace` - (String | Array[]) "namespace" UUID either as a String or Array[16] of byte values
|
|
184
|
-
* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.
|
|
185
|
-
* `offset` - (Number) Starting index in `buffer` at which to begin writing. Default = 0
|
|
186
|
-
|
|
187
|
-
Returns `buffer`, if specified, otherwise the string form of the UUID
|
|
188
|
-
|
|
189
|
-
Example:
|
|
190
|
-
|
|
191
|
-
```javascript --run v3
|
|
192
|
-
uuidv3('hello world', MY_NAMESPACE); // RESULT
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
### Version 4
|
|
196
|
-
|
|
197
|
-
```javascript
|
|
198
|
-
const uuidv4 = require('uuid/v4')
|
|
199
|
-
|
|
200
|
-
// Incantations
|
|
201
|
-
uuidv4();
|
|
202
|
-
uuidv4(options);
|
|
203
|
-
uuidv4(options, buffer, offset);
|
|
204
|
-
```
|
|
205
|
-
|
|
206
|
-
Generate and return a RFC4122 v4 UUID.
|
|
207
|
-
|
|
208
|
-
* `options` - (Object) Optional uuid state to apply. Properties may include:
|
|
209
|
-
* `random` - (Number[16]) Array of 16 numbers (0-255) to use in place of randomly generated values
|
|
210
|
-
* `rng` - (Function) Random # generator function that returns an Array[16] of byte values (0-255)
|
|
211
|
-
* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.
|
|
212
|
-
* `offset` - (Number) Starting index in `buffer` at which to begin writing.
|
|
213
|
-
|
|
214
|
-
Returns `buffer`, if specified, otherwise the string form of the UUID
|
|
215
|
-
|
|
216
|
-
Example: Generate string UUID with predefined `random` values
|
|
217
|
-
|
|
218
|
-
```javascript --run v4
|
|
219
|
-
const v4options = {
|
|
220
|
-
random: [
|
|
221
|
-
0x10, 0x91, 0x56, 0xbe, 0xc4, 0xfb, 0xc1, 0xea,
|
|
222
|
-
0x71, 0xb4, 0xef, 0xe1, 0x67, 0x1c, 0x58, 0x36
|
|
223
|
-
]
|
|
224
|
-
};
|
|
225
|
-
uuidv4(v4options); // RESULT
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
Example: Generate two IDs in a single buffer
|
|
229
|
-
|
|
230
|
-
```javascript --run v4
|
|
231
|
-
const buffer = new Array();
|
|
232
|
-
uuidv4(null, buffer, 0); // RESULT
|
|
233
|
-
uuidv4(null, buffer, 16); // RESULT
|
|
234
|
-
```
|
|
235
|
-
|
|
236
|
-
### Version 5
|
|
237
|
-
|
|
238
|
-
```javascript
|
|
239
|
-
const uuidv5 = require('uuid/v5');
|
|
240
|
-
|
|
241
|
-
// Incantations
|
|
242
|
-
uuidv5(name, namespace);
|
|
243
|
-
uuidv5(name, namespace, buffer);
|
|
244
|
-
uuidv5(name, namespace, buffer, offset);
|
|
245
|
-
```
|
|
246
|
-
|
|
247
|
-
Generate and return a RFC4122 v5 UUID.
|
|
248
|
-
|
|
249
|
-
* `name` - (String | Array[]) "name" to create UUID with
|
|
250
|
-
* `namespace` - (String | Array[]) "namespace" UUID either as a String or Array[16] of byte values
|
|
251
|
-
* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are to be written.
|
|
252
|
-
* `offset` - (Number) Starting index in `buffer` at which to begin writing. Default = 0
|
|
253
|
-
|
|
254
|
-
Returns `buffer`, if specified, otherwise the string form of the UUID
|
|
255
|
-
|
|
256
|
-
Example:
|
|
257
|
-
|
|
258
|
-
```javascript --run v5
|
|
259
|
-
uuidv5('hello world', MY_NAMESPACE); // RESULT
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
## Command Line
|
|
263
|
-
|
|
264
|
-
UUIDs can be generated from the command line with the `uuid` command.
|
|
265
|
-
|
|
266
|
-
```shell
|
|
267
|
-
$ uuid
|
|
268
|
-
ddeb27fb-d9a0-4624-be4d-4615062daed4
|
|
269
|
-
|
|
270
|
-
$ uuid v1
|
|
271
|
-
02d37060-d446-11e7-a9fa-7bdae751ebe1
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
Type `uuid --help` for usage details
|
|
275
|
-
|
|
276
|
-
## Testing
|
|
277
|
-
|
|
278
|
-
```shell
|
|
279
|
-
npm test
|
|
280
|
-
```
|
package/bin/uuid
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
var assert = require('assert');
|
|
3
|
-
|
|
4
|
-
function usage() {
|
|
5
|
-
console.log('Usage:');
|
|
6
|
-
console.log(' uuid');
|
|
7
|
-
console.log(' uuid v1');
|
|
8
|
-
console.log(' uuid v3 <name> <namespace uuid>');
|
|
9
|
-
console.log(' uuid v4');
|
|
10
|
-
console.log(' uuid v5 <name> <namespace uuid>');
|
|
11
|
-
console.log(' uuid --help');
|
|
12
|
-
console.log('\nNote: <namespace uuid> may be "URL" or "DNS" to use the corresponding UUIDs defined by RFC4122');
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
var args = process.argv.slice(2);
|
|
16
|
-
|
|
17
|
-
if (args.indexOf('--help') >= 0) {
|
|
18
|
-
usage();
|
|
19
|
-
process.exit(0);
|
|
20
|
-
}
|
|
21
|
-
var version = args.shift() || 'v4';
|
|
22
|
-
|
|
23
|
-
switch (version) {
|
|
24
|
-
case 'v1':
|
|
25
|
-
var uuidV1 = require('../v1');
|
|
26
|
-
console.log(uuidV1());
|
|
27
|
-
break;
|
|
28
|
-
|
|
29
|
-
case 'v3':
|
|
30
|
-
var uuidV3 = require('../v3');
|
|
31
|
-
|
|
32
|
-
var name = args.shift();
|
|
33
|
-
var namespace = args.shift();
|
|
34
|
-
assert(name != null, 'v3 name not specified');
|
|
35
|
-
assert(namespace != null, 'v3 namespace not specified');
|
|
36
|
-
|
|
37
|
-
if (namespace == 'URL') namespace = uuidV3.URL;
|
|
38
|
-
if (namespace == 'DNS') namespace = uuidV3.DNS;
|
|
39
|
-
|
|
40
|
-
console.log(uuidV3(name, namespace));
|
|
41
|
-
break;
|
|
42
|
-
|
|
43
|
-
case 'v4':
|
|
44
|
-
var uuidV4 = require('../v4');
|
|
45
|
-
console.log(uuidV4());
|
|
46
|
-
break;
|
|
47
|
-
|
|
48
|
-
case 'v5':
|
|
49
|
-
var uuidV5 = require('../v5');
|
|
50
|
-
|
|
51
|
-
var name = args.shift();
|
|
52
|
-
var namespace = args.shift();
|
|
53
|
-
assert(name != null, 'v5 name not specified');
|
|
54
|
-
assert(namespace != null, 'v5 namespace not specified');
|
|
55
|
-
|
|
56
|
-
if (namespace == 'URL') namespace = uuidV5.URL;
|
|
57
|
-
if (namespace == 'DNS') namespace = uuidV5.DNS;
|
|
58
|
-
|
|
59
|
-
console.log(uuidV5(name, namespace));
|
|
60
|
-
break;
|
|
61
|
-
|
|
62
|
-
default:
|
|
63
|
-
usage();
|
|
64
|
-
process.exit(1);
|
|
65
|
-
}
|
package/index.js
DELETED
package/lib/bytesToUuid.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Convert array of 16 byte values to UUID string format of the form:
|
|
3
|
-
* XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
|
|
4
|
-
*/
|
|
5
|
-
var byteToHex = [];
|
|
6
|
-
for (var i = 0; i < 256; ++i) {
|
|
7
|
-
byteToHex[i] = (i + 0x100).toString(16).substr(1);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
function bytesToUuid(buf, offset) {
|
|
11
|
-
var i = offset || 0;
|
|
12
|
-
var bth = byteToHex;
|
|
13
|
-
// join used to fix memory issue caused by concatenation: https://bugs.chromium.org/p/v8/issues/detail?id=3175#c4
|
|
14
|
-
return ([bth[buf[i++]], bth[buf[i++]],
|
|
15
|
-
bth[buf[i++]], bth[buf[i++]], '-',
|
|
16
|
-
bth[buf[i++]], bth[buf[i++]], '-',
|
|
17
|
-
bth[buf[i++]], bth[buf[i++]], '-',
|
|
18
|
-
bth[buf[i++]], bth[buf[i++]], '-',
|
|
19
|
-
bth[buf[i++]], bth[buf[i++]],
|
|
20
|
-
bth[buf[i++]], bth[buf[i++]],
|
|
21
|
-
bth[buf[i++]], bth[buf[i++]]]).join('');
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
module.exports = bytesToUuid;
|
package/lib/md5.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var crypto = require('crypto');
|
|
4
|
-
|
|
5
|
-
function md5(bytes) {
|
|
6
|
-
if (typeof Buffer.from === 'function') {
|
|
7
|
-
// Modern Buffer API
|
|
8
|
-
if (Array.isArray(bytes)) {
|
|
9
|
-
bytes = Buffer.from(bytes);
|
|
10
|
-
} else if (typeof bytes === 'string') {
|
|
11
|
-
bytes = Buffer.from(bytes, 'utf8');
|
|
12
|
-
}
|
|
13
|
-
} else {
|
|
14
|
-
// Pre-v4 Buffer API
|
|
15
|
-
if (Array.isArray(bytes)) {
|
|
16
|
-
bytes = new Buffer(bytes);
|
|
17
|
-
} else if (typeof bytes === 'string') {
|
|
18
|
-
bytes = new Buffer(bytes, 'utf8');
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return crypto.createHash('md5').update(bytes).digest();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = md5;
|
package/lib/rng-browser.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// Unique ID creation requires a high quality random # generator. In the
|
|
2
|
-
// browser this is a little complicated due to unknown quality of Math.random()
|
|
3
|
-
// and inconsistent support for the `crypto` API. We do the best we can via
|
|
4
|
-
// feature-detection
|
|
5
|
-
|
|
6
|
-
// getRandomValues needs to be invoked in a context where "this" is a Crypto
|
|
7
|
-
// implementation. Also, find the complete implementation of crypto on IE11.
|
|
8
|
-
var getRandomValues = (typeof(crypto) != 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto)) ||
|
|
9
|
-
(typeof(msCrypto) != 'undefined' && typeof window.msCrypto.getRandomValues == 'function' && msCrypto.getRandomValues.bind(msCrypto));
|
|
10
|
-
|
|
11
|
-
if (getRandomValues) {
|
|
12
|
-
// WHATWG crypto RNG - http://wiki.whatwg.org/wiki/Crypto
|
|
13
|
-
var rnds8 = new Uint8Array(16); // eslint-disable-line no-undef
|
|
14
|
-
|
|
15
|
-
module.exports = function whatwgRNG() {
|
|
16
|
-
getRandomValues(rnds8);
|
|
17
|
-
return rnds8;
|
|
18
|
-
};
|
|
19
|
-
} else {
|
|
20
|
-
// Math.random()-based (RNG)
|
|
21
|
-
//
|
|
22
|
-
// If all else fails, use Math.random(). It's fast, but is of unspecified
|
|
23
|
-
// quality.
|
|
24
|
-
var rnds = new Array(16);
|
|
25
|
-
|
|
26
|
-
module.exports = function mathRNG() {
|
|
27
|
-
for (var i = 0, r; i < 16; i++) {
|
|
28
|
-
if ((i & 0x03) === 0) r = Math.random() * 0x100000000;
|
|
29
|
-
rnds[i] = r >>> ((i & 0x03) << 3) & 0xff;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return rnds;
|
|
33
|
-
};
|
|
34
|
-
}
|
package/lib/rng.js
DELETED
package/lib/sha1-browser.js
DELETED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
// Adapted from Chris Veness' SHA1 code at
|
|
2
|
-
// http://www.movable-type.co.uk/scripts/sha1.html
|
|
3
|
-
'use strict';
|
|
4
|
-
|
|
5
|
-
function f(s, x, y, z) {
|
|
6
|
-
switch (s) {
|
|
7
|
-
case 0: return (x & y) ^ (~x & z);
|
|
8
|
-
case 1: return x ^ y ^ z;
|
|
9
|
-
case 2: return (x & y) ^ (x & z) ^ (y & z);
|
|
10
|
-
case 3: return x ^ y ^ z;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function ROTL(x, n) {
|
|
15
|
-
return (x << n) | (x>>> (32 - n));
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
function sha1(bytes) {
|
|
19
|
-
var K = [0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6];
|
|
20
|
-
var H = [0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0];
|
|
21
|
-
|
|
22
|
-
if (typeof(bytes) == 'string') {
|
|
23
|
-
var msg = unescape(encodeURIComponent(bytes)); // UTF8 escape
|
|
24
|
-
bytes = new Array(msg.length);
|
|
25
|
-
for (var i = 0; i < msg.length; i++) bytes[i] = msg.charCodeAt(i);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
bytes.push(0x80);
|
|
29
|
-
|
|
30
|
-
var l = bytes.length/4 + 2;
|
|
31
|
-
var N = Math.ceil(l/16);
|
|
32
|
-
var M = new Array(N);
|
|
33
|
-
|
|
34
|
-
for (var i=0; i<N; i++) {
|
|
35
|
-
M[i] = new Array(16);
|
|
36
|
-
for (var j=0; j<16; j++) {
|
|
37
|
-
M[i][j] =
|
|
38
|
-
bytes[i * 64 + j * 4] << 24 |
|
|
39
|
-
bytes[i * 64 + j * 4 + 1] << 16 |
|
|
40
|
-
bytes[i * 64 + j * 4 + 2] << 8 |
|
|
41
|
-
bytes[i * 64 + j * 4 + 3];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
M[N - 1][14] = ((bytes.length - 1) * 8) /
|
|
46
|
-
Math.pow(2, 32); M[N - 1][14] = Math.floor(M[N - 1][14]);
|
|
47
|
-
M[N - 1][15] = ((bytes.length - 1) * 8) & 0xffffffff;
|
|
48
|
-
|
|
49
|
-
for (var i=0; i<N; i++) {
|
|
50
|
-
var W = new Array(80);
|
|
51
|
-
|
|
52
|
-
for (var t=0; t<16; t++) W[t] = M[i][t];
|
|
53
|
-
for (var t=16; t<80; t++) {
|
|
54
|
-
W[t] = ROTL(W[t - 3] ^ W[t - 8] ^ W[t - 14] ^ W[t - 16], 1);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
var a = H[0];
|
|
58
|
-
var b = H[1];
|
|
59
|
-
var c = H[2];
|
|
60
|
-
var d = H[3];
|
|
61
|
-
var e = H[4];
|
|
62
|
-
|
|
63
|
-
for (var t=0; t<80; t++) {
|
|
64
|
-
var s = Math.floor(t/20);
|
|
65
|
-
var T = ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t] >>> 0;
|
|
66
|
-
e = d;
|
|
67
|
-
d = c;
|
|
68
|
-
c = ROTL(b, 30) >>> 0;
|
|
69
|
-
b = a;
|
|
70
|
-
a = T;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
H[0] = (H[0] + a) >>> 0;
|
|
74
|
-
H[1] = (H[1] + b) >>> 0;
|
|
75
|
-
H[2] = (H[2] + c) >>> 0;
|
|
76
|
-
H[3] = (H[3] + d) >>> 0;
|
|
77
|
-
H[4] = (H[4] + e) >>> 0;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return [
|
|
81
|
-
H[0] >> 24 & 0xff, H[0] >> 16 & 0xff, H[0] >> 8 & 0xff, H[0] & 0xff,
|
|
82
|
-
H[1] >> 24 & 0xff, H[1] >> 16 & 0xff, H[1] >> 8 & 0xff, H[1] & 0xff,
|
|
83
|
-
H[2] >> 24 & 0xff, H[2] >> 16 & 0xff, H[2] >> 8 & 0xff, H[2] & 0xff,
|
|
84
|
-
H[3] >> 24 & 0xff, H[3] >> 16 & 0xff, H[3] >> 8 & 0xff, H[3] & 0xff,
|
|
85
|
-
H[4] >> 24 & 0xff, H[4] >> 16 & 0xff, H[4] >> 8 & 0xff, H[4] & 0xff
|
|
86
|
-
];
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
module.exports = sha1;
|
package/lib/sha1.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var crypto = require('crypto');
|
|
4
|
-
|
|
5
|
-
function sha1(bytes) {
|
|
6
|
-
if (typeof Buffer.from === 'function') {
|
|
7
|
-
// Modern Buffer API
|
|
8
|
-
if (Array.isArray(bytes)) {
|
|
9
|
-
bytes = Buffer.from(bytes);
|
|
10
|
-
} else if (typeof bytes === 'string') {
|
|
11
|
-
bytes = Buffer.from(bytes, 'utf8');
|
|
12
|
-
}
|
|
13
|
-
} else {
|
|
14
|
-
// Pre-v4 Buffer API
|
|
15
|
-
if (Array.isArray(bytes)) {
|
|
16
|
-
bytes = new Buffer(bytes);
|
|
17
|
-
} else if (typeof bytes === 'string') {
|
|
18
|
-
bytes = new Buffer(bytes, 'utf8');
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return crypto.createHash('sha1').update(bytes).digest();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
module.exports = sha1;
|