@react-native-module/crypto 2.1.2 → 2.1.3-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/.eslintrc.js CHANGED
@@ -22,6 +22,9 @@ module.exports = {
22
22
  ],
23
23
  "parserOptions": {
24
24
  "project": "./tsconfig.json"
25
+ },
26
+ rules: {
27
+ "@typescript-eslint/ban-ts-comment": 0
25
28
  }
26
29
  }
27
30
  ]
package/lib/cjs/index.js CHANGED
@@ -29,7 +29,7 @@ const Hash = createHashModule__default["default"];
29
29
  const createHash = Hash;
30
30
  const Hmac = createHmacModule__default["default"];
31
31
  const createHmac = createHmacModule__default["default"];
32
- const randomBytes = randomBytesModule__default["default"].randomBytes;
32
+ const randomBytes = randomBytesModule__default["default"];
33
33
  const rng = randomBytes;
34
34
  const pseudoRandomBytes = randomBytes;
35
35
  const prng = randomBytes;
package/lib/es/index.js CHANGED
@@ -13,7 +13,7 @@ const Hash = createHashModule;
13
13
  const createHash = Hash;
14
14
  const Hmac = createHmacModule;
15
15
  const createHmac = createHmacModule;
16
- const randomBytes = randomBytesModule.randomBytes;
16
+ const randomBytes = randomBytesModule;
17
17
  const rng = randomBytes;
18
18
  const pseudoRandomBytes = randomBytes;
19
19
  const prng = randomBytes;
@@ -0,0 +1 @@
1
+ export {};
@@ -4,10 +4,10 @@ export declare const Hash: any;
4
4
  export declare const createHash: any;
5
5
  export declare const Hmac: any;
6
6
  export declare const createHmac: any;
7
- export declare const randomBytes: typeof randomBytesModule.randomBytes;
8
- export declare const rng: typeof randomBytesModule.randomBytes;
9
- export declare const pseudoRandomBytes: typeof randomBytesModule.randomBytes;
10
- export declare const prng: typeof randomBytesModule.randomBytes;
7
+ export declare const randomBytes: typeof randomBytesModule;
8
+ export declare const rng: typeof randomBytesModule;
9
+ export declare const pseudoRandomBytes: typeof randomBytesModule;
10
+ export declare const prng: typeof randomBytesModule;
11
11
  export declare function getHashes(): string[];
12
12
  export declare const pbkdf2: typeof pbkdf2Ori;
13
13
  export declare const pbkdf2Sync: typeof pbkdf2SyncOri;
package/package.json CHANGED
@@ -2,11 +2,12 @@
2
2
  "author": "sacru2red <sacru2red@gmail.com>",
3
3
  "name": "@react-native-module/crypto",
4
4
  "description": "implementation of crypto for React Native",
5
- "version": "2.1.2",
5
+ "version": "2.1.3-0",
6
6
  "main": "lib/cjs/index.js",
7
7
  "module": "lib/es/index.js",
8
8
  "types": "lib/types/index.d.ts",
9
9
  "source": "src/index",
10
+ "react-native": "src/index.ts",
10
11
  "homepage": "https://github.com/react-native-module/crypto",
11
12
  "repository": {
12
13
  "type": "git",
@@ -22,7 +23,7 @@
22
23
  },
23
24
  "dependencies": {
24
25
  "@react-native-module/pbkdf2": "^0.3.7",
25
- "@react-native-module/randombytes": "^3.6.6-3",
26
+ "@react-native-module/randombytes": "^3.6.6-4",
26
27
  "browserify-cipher": "^1.0.0",
27
28
  "browserify-sign": "^4.0.4",
28
29
  "create-ecdh": "^4.0.0",
package/src/global.ts ADDED
@@ -0,0 +1,13 @@
1
+ /* eslint-disable @typescript-eslint/strict-boolean-expressions */
2
+ import { randomBytesWithoutNativeModule } from '@react-native-module/randombytes/src/randomBytesWithoutNativeModule'
3
+
4
+ // https://github.com/mvayngrib/react-native-crypto/blob/204384f06e3fa78c3a272ac55dd3a9de4743f1f3/index.js#L7
5
+ if (typeof globalThis === 'object') {
6
+ if (!globalThis.crypto) {
7
+ // @ts-expect-error
8
+ globalThis.crypto = {}
9
+ }
10
+ if (!globalThis.crypto.getRandomValues) {
11
+ globalThis.crypto.getRandomValues = randomBytesWithoutNativeModule
12
+ }
13
+ }
package/src/index.ts CHANGED
@@ -13,7 +13,7 @@ export const Hash = createHashModule
13
13
  export const createHash = Hash
14
14
  export const Hmac = createHmacModule
15
15
  export const createHmac = createHmacModule
16
- export const randomBytes = randomBytesModule.randomBytes
16
+ export const randomBytes = randomBytesModule
17
17
  export const rng = randomBytes
18
18
  export const pseudoRandomBytes = randomBytes
19
19
  export const prng = randomBytes