get-random-values 1.1.0 → 1.2.2
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 +13 -0
- package/LICENSE.txt +2 -2
- package/README.md +4 -4
- package/index.js +10 -6
- package/package.json +16 -6
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
### [1.2.2](https://github.com/KenanY/get-random-values/compare/1.2.1...1.2.2) (2020-08-25)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* update copyright year to 2020 ([4761fef](https://github.com/KenanY/get-random-values/commit/4761fef0e5513b84f0ab340d22ef31d97e50ab4c))
|
|
7
|
+
|
|
8
|
+
### [1.2.1](https://github.com/KenanY/get-random-values/compare/1.2.0...1.2.1) (2020-08-25)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* **deps:** global@4.4.0 ([18f7674](https://github.com/KenanY/get-random-values/commit/18f7674e87441f5d682b27390e992e18215456ab))
|
package/LICENSE.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright 2014 Kenan Yildirim <
|
|
1
|
+
Copyright 2014–2020 Kenan Yildirim <https://kenany.me/>
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
4
4
|
this software and associated documentation files (the "Software"), to deal in
|
|
@@ -15,4 +15,4 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
|
15
15
|
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
16
16
|
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
17
17
|
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
18
|
-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
18
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
# get-random-values
|
|
2
2
|
|
|
3
|
-
[](https://travis-ci.org/KenanY/get-random-values)
|
|
4
|
-
[](https://gemnasium.com/KenanY/get-random-values)
|
|
5
|
-
|
|
6
3
|
`window.crypto.getRandomValues` or `window.msCrypto.getRandomValues` or
|
|
7
4
|
`require('crypto').randomBytes` or an _Error_.
|
|
8
5
|
|
|
@@ -51,4 +48,7 @@ Checks for and uses the first of the following:
|
|
|
51
48
|
If none of the above are available, then an _Error_ is thrown.
|
|
52
49
|
|
|
53
50
|
Throws _QuotaExceededError_ if `buf.length > 65536` (even if Node.js crypto,
|
|
54
|
-
which doesn't have that limit, is being used).
|
|
51
|
+
which doesn't have that limit, is being used).
|
|
52
|
+
|
|
53
|
+
`buf` **must** be a _Uint8Array_ if Node.js crypto is used, otherwise a
|
|
54
|
+
_TypeError_ will be thrown.
|
package/index.js
CHANGED
|
@@ -3,12 +3,15 @@ var nodeCrypto = require('crypto');
|
|
|
3
3
|
|
|
4
4
|
function getRandomValues(buf) {
|
|
5
5
|
if (window.crypto && window.crypto.getRandomValues) {
|
|
6
|
-
window.crypto.getRandomValues(buf);
|
|
6
|
+
return window.crypto.getRandomValues(buf);
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
window.msCrypto.getRandomValues(buf);
|
|
8
|
+
if (typeof window.msCrypto === 'object' && typeof window.msCrypto.getRandomValues === 'function') {
|
|
9
|
+
return window.msCrypto.getRandomValues(buf);
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
if (nodeCrypto.randomBytes) {
|
|
12
|
+
if (!(buf instanceof Uint8Array)) {
|
|
13
|
+
throw new TypeError('expected Uint8Array');
|
|
14
|
+
}
|
|
12
15
|
if (buf.length > 65536) {
|
|
13
16
|
var e = new Error();
|
|
14
17
|
e.code = 22;
|
|
@@ -20,10 +23,11 @@ function getRandomValues(buf) {
|
|
|
20
23
|
}
|
|
21
24
|
var bytes = nodeCrypto.randomBytes(buf.length);
|
|
22
25
|
buf.set(bytes);
|
|
26
|
+
return buf;
|
|
23
27
|
}
|
|
24
28
|
else {
|
|
25
29
|
throw new Error('No secure random number generator available.');
|
|
26
30
|
}
|
|
27
|
-
}
|
|
31
|
+
}
|
|
28
32
|
|
|
29
|
-
module.exports = getRandomValues;
|
|
33
|
+
module.exports = getRandomValues;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "get-random-values",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "`window.crypto.getRandomValues` with fallback to Node.js crypto",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"crypto"
|
|
@@ -16,18 +16,28 @@
|
|
|
16
16
|
"directories": {
|
|
17
17
|
"test": "test"
|
|
18
18
|
},
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": "10 || 12 || >=14"
|
|
21
|
+
},
|
|
19
22
|
"scripts": {
|
|
23
|
+
"release": "semantic-release",
|
|
20
24
|
"test": "tape test/*.js"
|
|
21
25
|
},
|
|
22
26
|
"dependencies": {
|
|
23
|
-
"global": "^4.
|
|
27
|
+
"global": "^4.4.0"
|
|
24
28
|
},
|
|
25
29
|
"devDependencies": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"
|
|
30
|
+
"@kenan/renovate-config": "1.4.0",
|
|
31
|
+
"@semantic-release/changelog": "5.0.1",
|
|
32
|
+
"@semantic-release/git": "9.0.0",
|
|
33
|
+
"conventional-changelog-conventionalcommits": "4.4.0",
|
|
34
|
+
"is-browser": "2.1.0",
|
|
35
|
+
"lodash.foreach": "4.5.0",
|
|
36
|
+
"lodash.isfunction": "3.0.9",
|
|
37
|
+
"semantic-release": "17.1.1",
|
|
38
|
+
"tape": "5.0.1"
|
|
29
39
|
},
|
|
30
40
|
"browser": {
|
|
31
41
|
"crypto": false
|
|
32
42
|
}
|
|
33
|
-
}
|
|
43
|
+
}
|