@pezkuwi/x-randomvalues 14.0.10 → 14.0.12
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/browser.d.ts +3 -0
- package/browser.js +6 -0
- package/build/cjs/packageInfo.js +1 -1
- package/build/package.json +10 -49
- package/build/packageInfo.js +1 -1
- package/build-deno/packageInfo.ts +1 -1
- package/build-tsc-cjs/packageInfo.js +1 -1
- package/build-tsc-esm/packageInfo.js +1 -1
- package/cjs/browser.d.ts +3 -0
- package/cjs/browser.js +11 -0
- package/cjs/fallback.d.ts +1 -0
- package/cjs/fallback.js +18 -0
- package/cjs/node.d.ts +3 -0
- package/cjs/node.js +13 -0
- package/cjs/package.json +3 -0
- package/cjs/packageInfo.d.ts +6 -0
- package/cjs/packageInfo.js +4 -0
- package/cjs/react-native.d.ts +12 -0
- package/cjs/react-native.js +35 -0
- package/cjs/shim.d.ts +1 -0
- package/cjs/shim.js +5 -0
- package/fallback.d.ts +1 -0
- package/fallback.js +15 -0
- package/node.d.ts +3 -0
- package/node.js +7 -0
- package/package.json +175 -10
- package/packageInfo.d.ts +6 -0
- package/packageInfo.js +1 -0
- package/react-native.d.ts +12 -0
- package/react-native.js +31 -0
- package/shim.d.ts +1 -0
- package/shim.js +3 -0
- package/src/packageInfo.ts +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/tsconfig.spec.tsbuildinfo +1 -1
package/browser.d.ts
ADDED
package/browser.js
ADDED
package/build/cjs/packageInfo.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.packageInfo = void 0;
|
|
4
|
-
exports.packageInfo = { name: '@pezkuwi/x-randomvalues', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '14.0.
|
|
4
|
+
exports.packageInfo = { name: '@pezkuwi/x-randomvalues', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '14.0.12' };
|
package/build/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"author": "
|
|
2
|
+
"author": "Dijital Kurdistan Tech Institute <dev@pezkuwichain.io>",
|
|
3
3
|
"bugs": "https://github.com/pezkuwichain/pezkuwi-common/issues",
|
|
4
4
|
"description": "A cross-environment window.crypto.getRandomValues replacement",
|
|
5
5
|
"engines": {
|
|
@@ -15,59 +15,20 @@
|
|
|
15
15
|
},
|
|
16
16
|
"sideEffects": false,
|
|
17
17
|
"type": "module",
|
|
18
|
-
"version": "14.0.
|
|
18
|
+
"version": "14.0.12",
|
|
19
19
|
"main": "./cjs/node.js",
|
|
20
|
-
"module": "./node.js",
|
|
20
|
+
"module": "./cjs/node.js",
|
|
21
21
|
"browser": "./cjs/browser.js",
|
|
22
22
|
"react-native": "./cjs/react-native.js",
|
|
23
|
-
"types": "./node.d.ts",
|
|
23
|
+
"types": "./cjs/node.d.ts",
|
|
24
24
|
"exports": {
|
|
25
25
|
"./cjs/package.json": "./cjs/package.json",
|
|
26
26
|
"./cjs/*": "./cjs/*.js",
|
|
27
27
|
".": {
|
|
28
|
-
"types": "./node.d.ts",
|
|
29
|
-
"react-native":
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
"default": "./react-native.js"
|
|
33
|
-
},
|
|
34
|
-
"require": {
|
|
35
|
-
"types": "./cjs/react-native.d.ts",
|
|
36
|
-
"default": "./cjs/react-native.js"
|
|
37
|
-
},
|
|
38
|
-
"default": {
|
|
39
|
-
"types": "./react-native.d.ts",
|
|
40
|
-
"default": "./react-native.js"
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
"browser": {
|
|
44
|
-
"module": {
|
|
45
|
-
"types": "./browser.d.ts",
|
|
46
|
-
"default": "./browser.js"
|
|
47
|
-
},
|
|
48
|
-
"require": {
|
|
49
|
-
"types": "./cjs/browser.d.ts",
|
|
50
|
-
"default": "./cjs/browser.js"
|
|
51
|
-
},
|
|
52
|
-
"default": {
|
|
53
|
-
"types": "./browser.d.ts",
|
|
54
|
-
"default": "./browser.js"
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
"node": {
|
|
58
|
-
"module": {
|
|
59
|
-
"types": "./node.d.ts",
|
|
60
|
-
"default": "./node.js"
|
|
61
|
-
},
|
|
62
|
-
"require": {
|
|
63
|
-
"types": "./cjs/node.d.ts",
|
|
64
|
-
"default": "./cjs/node.js"
|
|
65
|
-
},
|
|
66
|
-
"default": {
|
|
67
|
-
"types": "./node.d.ts",
|
|
68
|
-
"default": "./node.js"
|
|
69
|
-
}
|
|
70
|
-
}
|
|
28
|
+
"types": "./cjs/node.d.ts./cjs/node.js",
|
|
29
|
+
"react-native": "./cjs/react-native.js./cjs/react-native.js",
|
|
30
|
+
"browser": "./cjs/browser.js./cjs/browser.js",
|
|
31
|
+
"node": "./cjs/node.js./cjs/node.js"
|
|
71
32
|
},
|
|
72
33
|
"./browser": {
|
|
73
34
|
"module": {
|
|
@@ -187,11 +148,11 @@
|
|
|
187
148
|
}
|
|
188
149
|
},
|
|
189
150
|
"dependencies": {
|
|
190
|
-
"@pezkuwi/x-global": "
|
|
151
|
+
"@pezkuwi/x-global": "14.0.12",
|
|
191
152
|
"tslib": "^2.8.0"
|
|
192
153
|
},
|
|
193
154
|
"peerDependencies": {
|
|
194
|
-
"@pezkuwi/util": "
|
|
155
|
+
"@pezkuwi/util": "14.0.12",
|
|
195
156
|
"@pezkuwi/wasm-util": "*"
|
|
196
157
|
}
|
|
197
158
|
}
|
package/build/packageInfo.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const packageInfo = { name: '@pezkuwi/x-randomvalues', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '14.0.
|
|
1
|
+
export const packageInfo = { name: '@pezkuwi/x-randomvalues', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '14.0.12' };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
export const packageInfo = { name: '@pezkuwi/x-randomvalues', path: new URL(import.meta.url).pathname, type: 'deno', version: '14.0.
|
|
3
|
+
export const packageInfo = { name: '@pezkuwi/x-randomvalues', path: new URL(import.meta.url).pathname, type: 'deno', version: '14.0.12' };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.packageInfo = void 0;
|
|
4
|
-
exports.packageInfo = { name: '@pezkuwi/x-randomvalues', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '14.0.
|
|
4
|
+
exports.packageInfo = { name: '@pezkuwi/x-randomvalues', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '14.0.12' };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const packageInfo = { name: '@pezkuwi/x-randomvalues', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '14.0.
|
|
1
|
+
export const packageInfo = { name: '@pezkuwi/x-randomvalues', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '14.0.12' };
|
package/cjs/browser.d.ts
ADDED
package/cjs/browser.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.crypto = exports.packageInfo = void 0;
|
|
4
|
+
exports.getRandomValues = getRandomValues;
|
|
5
|
+
const x_global_1 = require("@pezkuwi/x-global");
|
|
6
|
+
var packageInfo_js_1 = require("./packageInfo.js");
|
|
7
|
+
Object.defineProperty(exports, "packageInfo", { enumerable: true, get: function () { return packageInfo_js_1.packageInfo; } });
|
|
8
|
+
exports.crypto = x_global_1.xglobal.crypto;
|
|
9
|
+
function getRandomValues(arr) {
|
|
10
|
+
return exports.crypto.getRandomValues(arr);
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function insecureRandomValues<T extends Uint8Array>(arr: T): T;
|
package/cjs/fallback.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.insecureRandomValues = insecureRandomValues;
|
|
4
|
+
let warned = false;
|
|
5
|
+
function insecureRandomValues(arr) {
|
|
6
|
+
if (!warned) {
|
|
7
|
+
console.warn('Using an insecure random number generator, this should only happen when running in a debugger without support for crypto');
|
|
8
|
+
warned = true;
|
|
9
|
+
}
|
|
10
|
+
let r = 0;
|
|
11
|
+
for (let i = 0, count = arr.length; i < count; i++) {
|
|
12
|
+
if ((i & 0b11) === 0) {
|
|
13
|
+
r = Math.random() * 0x100000000;
|
|
14
|
+
}
|
|
15
|
+
arr[i] = (r >>> ((i & 0b11) << 3)) & 0xff;
|
|
16
|
+
}
|
|
17
|
+
return arr;
|
|
18
|
+
}
|
package/cjs/node.d.ts
ADDED
package/cjs/node.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.crypto = exports.packageInfo = void 0;
|
|
4
|
+
exports.getRandomValues = getRandomValues;
|
|
5
|
+
const tslib_1 = require("tslib");
|
|
6
|
+
const node_crypto_1 = tslib_1.__importDefault(require("node:crypto"));
|
|
7
|
+
const x_global_1 = require("@pezkuwi/x-global");
|
|
8
|
+
var packageInfo_js_1 = require("./packageInfo.js");
|
|
9
|
+
Object.defineProperty(exports, "packageInfo", { enumerable: true, get: function () { return packageInfo_js_1.packageInfo; } });
|
|
10
|
+
exports.crypto = (0, x_global_1.extractGlobal)('crypto', node_crypto_1.default.webcrypto);
|
|
11
|
+
function getRandomValues(output) {
|
|
12
|
+
return exports.crypto.getRandomValues(output);
|
|
13
|
+
}
|
package/cjs/package.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { packageInfo } from './packageInfo.js';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*
|
|
5
|
+
* A getRandomValues util that detects and uses the available RN
|
|
6
|
+
* random utiliy generation functions.
|
|
7
|
+
**/
|
|
8
|
+
declare function getRandomValuesRn(output: Uint8Array): Uint8Array;
|
|
9
|
+
export declare const getRandomValues: typeof getRandomValuesRn;
|
|
10
|
+
export declare const crypto: Crypto | {
|
|
11
|
+
getRandomValues: typeof getRandomValuesRn;
|
|
12
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.crypto = exports.getRandomValues = exports.packageInfo = void 0;
|
|
4
|
+
const react_native_1 = require("react-native");
|
|
5
|
+
const base64_1 = require("@pezkuwi/wasm-util/base64");
|
|
6
|
+
const x_global_1 = require("@pezkuwi/x-global");
|
|
7
|
+
const browser_js_1 = require("./browser.js");
|
|
8
|
+
var packageInfo_js_1 = require("./packageInfo.js");
|
|
9
|
+
Object.defineProperty(exports, "packageInfo", { enumerable: true, get: function () { return packageInfo_js_1.packageInfo; } });
|
|
10
|
+
/**
|
|
11
|
+
* @internal
|
|
12
|
+
*
|
|
13
|
+
* A getRandomValues util that detects and uses the available RN
|
|
14
|
+
* random utiliy generation functions.
|
|
15
|
+
**/
|
|
16
|
+
function getRandomValuesRn(output) {
|
|
17
|
+
if (!react_native_1.NativeModules['ExpoRandom'] && !react_native_1.NativeModules.RNGetRandomValues) {
|
|
18
|
+
throw new Error('No secure random number generator available. This environment does not support crypto.getRandomValues and no React Native secure RNG module is available.');
|
|
19
|
+
}
|
|
20
|
+
return (0, base64_1.base64Decode)(react_native_1.NativeModules.RNGetRandomValues
|
|
21
|
+
? react_native_1.NativeModules.RNGetRandomValues.getRandomBase64(output.length)
|
|
22
|
+
: react_native_1.NativeModules.ExpoRandom.getRandomBase64String(output.length), output);
|
|
23
|
+
}
|
|
24
|
+
const hasNativeRNModules = !!react_native_1.NativeModules['ExpoRandom'] || !!react_native_1.NativeModules.RNGetRandomValues;
|
|
25
|
+
const hasNativeCrypto = typeof x_global_1.xglobal.crypto === 'object' && typeof x_global_1.xglobal.crypto.getRandomValues === 'function';
|
|
26
|
+
exports.getRandomValues = (hasNativeRNModules
|
|
27
|
+
? getRandomValuesRn
|
|
28
|
+
: hasNativeCrypto
|
|
29
|
+
? browser_js_1.getRandomValues
|
|
30
|
+
: () => {
|
|
31
|
+
throw new Error('No secure random number generator available. This environment does not support crypto.getRandomValues.');
|
|
32
|
+
});
|
|
33
|
+
exports.crypto = (exports.getRandomValues === browser_js_1.getRandomValues
|
|
34
|
+
? browser_js_1.crypto
|
|
35
|
+
: { getRandomValues: exports.getRandomValues });
|
package/cjs/shim.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/cjs/shim.js
ADDED
package/fallback.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function insecureRandomValues<T extends Uint8Array>(arr: T): T;
|
package/fallback.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
let warned = false;
|
|
2
|
+
export function insecureRandomValues(arr) {
|
|
3
|
+
if (!warned) {
|
|
4
|
+
console.warn('Using an insecure random number generator, this should only happen when running in a debugger without support for crypto');
|
|
5
|
+
warned = true;
|
|
6
|
+
}
|
|
7
|
+
let r = 0;
|
|
8
|
+
for (let i = 0, count = arr.length; i < count; i++) {
|
|
9
|
+
if ((i & 0b11) === 0) {
|
|
10
|
+
r = Math.random() * 0x100000000;
|
|
11
|
+
}
|
|
12
|
+
arr[i] = (r >>> ((i & 0b11) << 3)) & 0xff;
|
|
13
|
+
}
|
|
14
|
+
return arr;
|
|
15
|
+
}
|
package/node.d.ts
ADDED
package/node.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import nodeCrypto from 'node:crypto';
|
|
2
|
+
import { extractGlobal } from '@pezkuwi/x-global';
|
|
3
|
+
export { packageInfo } from './packageInfo.js';
|
|
4
|
+
export const crypto = /*#__PURE__*/ extractGlobal('crypto', nodeCrypto.webcrypto);
|
|
5
|
+
export function getRandomValues(output) {
|
|
6
|
+
return crypto.getRandomValues(output);
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"author": "
|
|
2
|
+
"author": "Dijital Kurdistan Tech Institute <dev@pezkuwichain.io>",
|
|
3
3
|
"bugs": "https://github.com/pezkuwichain/pezkuwi-common/issues",
|
|
4
4
|
"description": "A cross-environment window.crypto.getRandomValues replacement",
|
|
5
5
|
"engines": {
|
|
@@ -15,21 +15,186 @@
|
|
|
15
15
|
},
|
|
16
16
|
"sideEffects": false,
|
|
17
17
|
"type": "module",
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
18
|
+
"types": "./node.d.ts",
|
|
19
|
+
"version": "14.0.12",
|
|
20
|
+
"browser": "./cjs/browser.js",
|
|
21
|
+
"main": "./cjs/node.js",
|
|
22
|
+
"module": "./node.js",
|
|
23
|
+
"react-native": "./cjs/react-native.js",
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"types": "./node.d.ts",
|
|
27
|
+
"react-native": {
|
|
28
|
+
"module": {
|
|
29
|
+
"types": "./react-native.d.ts",
|
|
30
|
+
"default": "./react-native.js"
|
|
31
|
+
},
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./cjs/react-native.d.ts",
|
|
34
|
+
"default": "./cjs/react-native.js"
|
|
35
|
+
},
|
|
36
|
+
"default": {
|
|
37
|
+
"types": "./react-native.d.ts",
|
|
38
|
+
"default": "./react-native.js"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"browser": {
|
|
42
|
+
"module": {
|
|
43
|
+
"types": "./browser.d.ts",
|
|
44
|
+
"default": "./browser.js"
|
|
45
|
+
},
|
|
46
|
+
"require": {
|
|
47
|
+
"types": "./cjs/browser.d.ts",
|
|
48
|
+
"default": "./cjs/browser.js"
|
|
49
|
+
},
|
|
50
|
+
"default": {
|
|
51
|
+
"types": "./browser.d.ts",
|
|
52
|
+
"default": "./browser.js"
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"node": {
|
|
56
|
+
"module": {
|
|
57
|
+
"types": "./node.d.ts",
|
|
58
|
+
"default": "./node.js"
|
|
59
|
+
},
|
|
60
|
+
"require": {
|
|
61
|
+
"types": "./cjs/node.d.ts",
|
|
62
|
+
"default": "./cjs/node.js"
|
|
63
|
+
},
|
|
64
|
+
"default": {
|
|
65
|
+
"types": "./node.d.ts",
|
|
66
|
+
"default": "./node.js"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
"./browser": {
|
|
71
|
+
"module": {
|
|
72
|
+
"types": "./browser.d.ts",
|
|
73
|
+
"default": "./browser.js"
|
|
74
|
+
},
|
|
75
|
+
"require": {
|
|
76
|
+
"types": "./cjs/browser.d.ts",
|
|
77
|
+
"default": "./cjs/browser.js"
|
|
78
|
+
},
|
|
79
|
+
"default": {
|
|
80
|
+
"types": "./browser.d.ts",
|
|
81
|
+
"default": "./browser.js"
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
"./cjs/*": "./cjs/*.js",
|
|
85
|
+
"./cjs/package.json": "./cjs/package.json",
|
|
86
|
+
"./fallback": {
|
|
87
|
+
"module": {
|
|
88
|
+
"types": "./fallback.d.ts",
|
|
89
|
+
"default": "./fallback.js"
|
|
90
|
+
},
|
|
91
|
+
"require": {
|
|
92
|
+
"types": "./cjs/fallback.d.ts",
|
|
93
|
+
"default": "./cjs/fallback.js"
|
|
94
|
+
},
|
|
95
|
+
"default": {
|
|
96
|
+
"types": "./fallback.d.ts",
|
|
97
|
+
"default": "./fallback.js"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"./node": {
|
|
101
|
+
"module": {
|
|
102
|
+
"types": "./node.d.ts",
|
|
103
|
+
"default": "./node.js"
|
|
104
|
+
},
|
|
105
|
+
"require": {
|
|
106
|
+
"types": "./cjs/node.d.ts",
|
|
107
|
+
"default": "./cjs/node.js"
|
|
108
|
+
},
|
|
109
|
+
"default": {
|
|
110
|
+
"types": "./node.d.ts",
|
|
111
|
+
"default": "./node.js"
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
"./package.json": {
|
|
115
|
+
"require": "./cjs/package.json",
|
|
116
|
+
"default": "./package.json"
|
|
117
|
+
},
|
|
118
|
+
"./packageInfo": {
|
|
119
|
+
"module": {
|
|
120
|
+
"types": "./packageInfo.d.ts",
|
|
121
|
+
"default": "./packageInfo.js"
|
|
122
|
+
},
|
|
123
|
+
"require": {
|
|
124
|
+
"types": "./cjs/packageInfo.d.ts",
|
|
125
|
+
"default": "./cjs/packageInfo.js"
|
|
126
|
+
},
|
|
127
|
+
"default": {
|
|
128
|
+
"types": "./packageInfo.d.ts",
|
|
129
|
+
"default": "./packageInfo.js"
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"./packageInfo.js": {
|
|
133
|
+
"module": {
|
|
134
|
+
"types": "./packageInfo.d.ts",
|
|
135
|
+
"default": "./packageInfo.js"
|
|
136
|
+
},
|
|
137
|
+
"require": {
|
|
138
|
+
"types": "./cjs/packageInfo.d.ts",
|
|
139
|
+
"default": "./cjs/packageInfo.js"
|
|
140
|
+
},
|
|
141
|
+
"default": {
|
|
142
|
+
"types": "./packageInfo.d.ts",
|
|
143
|
+
"default": "./packageInfo.js"
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
"./react-native": {
|
|
147
|
+
"module": {
|
|
148
|
+
"types": "./react-native.d.ts",
|
|
149
|
+
"default": "./react-native.js"
|
|
150
|
+
},
|
|
151
|
+
"require": {
|
|
152
|
+
"types": "./cjs/react-native.d.ts",
|
|
153
|
+
"default": "./cjs/react-native.js"
|
|
154
|
+
},
|
|
155
|
+
"default": {
|
|
156
|
+
"types": "./react-native.d.ts",
|
|
157
|
+
"default": "./react-native.js"
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"./shim": {
|
|
161
|
+
"module": {
|
|
162
|
+
"types": "./shim.d.ts",
|
|
163
|
+
"default": "./shim.js"
|
|
164
|
+
},
|
|
165
|
+
"require": {
|
|
166
|
+
"types": "./cjs/shim.d.ts",
|
|
167
|
+
"default": "./cjs/shim.js"
|
|
168
|
+
},
|
|
169
|
+
"default": {
|
|
170
|
+
"types": "./shim.d.ts",
|
|
171
|
+
"default": "./shim.js"
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
"./shim.js": {
|
|
175
|
+
"module": {
|
|
176
|
+
"types": "./shim.d.ts",
|
|
177
|
+
"default": "./shim.js"
|
|
178
|
+
},
|
|
179
|
+
"require": {
|
|
180
|
+
"types": "./cjs/shim.d.ts",
|
|
181
|
+
"default": "./cjs/shim.js"
|
|
182
|
+
},
|
|
183
|
+
"default": {
|
|
184
|
+
"types": "./shim.d.ts",
|
|
185
|
+
"default": "./shim.js"
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
},
|
|
22
189
|
"dependencies": {
|
|
23
|
-
"@pezkuwi/x-global": "14.0.
|
|
190
|
+
"@pezkuwi/x-global": "14.0.12",
|
|
24
191
|
"tslib": "^2.8.0"
|
|
25
192
|
},
|
|
26
193
|
"devDependencies": {
|
|
27
|
-
"@pezkuwi/util": "14.0.10",
|
|
28
|
-
"@pezkuwi/wasm-util": "^7.5.3",
|
|
29
194
|
"@types/react-native": "^0.73.0"
|
|
30
195
|
},
|
|
31
196
|
"peerDependencies": {
|
|
32
|
-
"@pezkuwi/util": "14.0.
|
|
197
|
+
"@pezkuwi/util": "14.0.12",
|
|
33
198
|
"@pezkuwi/wasm-util": "*"
|
|
34
199
|
}
|
|
35
|
-
}
|
|
200
|
+
}
|
package/packageInfo.d.ts
ADDED
package/packageInfo.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const packageInfo = { name: '@pezkuwi/x-randomvalues', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '14.0.10' };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export { packageInfo } from './packageInfo.js';
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
*
|
|
5
|
+
* A getRandomValues util that detects and uses the available RN
|
|
6
|
+
* random utiliy generation functions.
|
|
7
|
+
**/
|
|
8
|
+
declare function getRandomValuesRn(output: Uint8Array): Uint8Array;
|
|
9
|
+
export declare const getRandomValues: typeof getRandomValuesRn;
|
|
10
|
+
export declare const crypto: Crypto | {
|
|
11
|
+
getRandomValues: typeof getRandomValuesRn;
|
|
12
|
+
};
|
package/react-native.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { NativeModules } from 'react-native';
|
|
2
|
+
import { base64Decode } from '@pezkuwi/wasm-util/base64';
|
|
3
|
+
import { xglobal } from '@pezkuwi/x-global';
|
|
4
|
+
import { crypto as cryptoBrowser, getRandomValues as getRandomValuesBrowser } from './browser.js';
|
|
5
|
+
export { packageInfo } from './packageInfo.js';
|
|
6
|
+
/**
|
|
7
|
+
* @internal
|
|
8
|
+
*
|
|
9
|
+
* A getRandomValues util that detects and uses the available RN
|
|
10
|
+
* random utiliy generation functions.
|
|
11
|
+
**/
|
|
12
|
+
function getRandomValuesRn(output) {
|
|
13
|
+
if (!NativeModules['ExpoRandom'] && !NativeModules.RNGetRandomValues) {
|
|
14
|
+
throw new Error('No secure random number generator available. This environment does not support crypto.getRandomValues and no React Native secure RNG module is available.');
|
|
15
|
+
}
|
|
16
|
+
return base64Decode(NativeModules.RNGetRandomValues
|
|
17
|
+
? NativeModules.RNGetRandomValues.getRandomBase64(output.length)
|
|
18
|
+
: NativeModules.ExpoRandom.getRandomBase64String(output.length), output);
|
|
19
|
+
}
|
|
20
|
+
const hasNativeRNModules = !!NativeModules['ExpoRandom'] || !!NativeModules.RNGetRandomValues;
|
|
21
|
+
const hasNativeCrypto = typeof xglobal.crypto === 'object' && typeof xglobal.crypto.getRandomValues === 'function';
|
|
22
|
+
export const getRandomValues = (hasNativeRNModules
|
|
23
|
+
? getRandomValuesRn
|
|
24
|
+
: hasNativeCrypto
|
|
25
|
+
? getRandomValuesBrowser
|
|
26
|
+
: () => {
|
|
27
|
+
throw new Error('No secure random number generator available. This environment does not support crypto.getRandomValues.');
|
|
28
|
+
});
|
|
29
|
+
export const crypto = (getRandomValues === getRandomValuesBrowser
|
|
30
|
+
? cryptoBrowser
|
|
31
|
+
: { getRandomValues });
|
package/shim.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/shim.js
ADDED
package/src/packageInfo.ts
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
|
|
4
4
|
// Do not edit, auto-generated by @pezkuwi/dev
|
|
5
5
|
|
|
6
|
-
export const packageInfo = { name: '@pezkuwi/x-randomvalues', path: 'auto', type: 'auto', version: '14.0.
|
|
6
|
+
export const packageInfo = { name: '@pezkuwi/x-randomvalues', path: 'auto', type: 'auto', version: '14.0.12' };
|