@react-native-module/crypto 2.1.1 → 2.1.3-1

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 ADDED
@@ -0,0 +1,32 @@
1
+ module.exports = {
2
+ "env": {
3
+ "es2021": true,
4
+ node: true,
5
+ },
6
+ "extends": [
7
+ "eslint:recommended",
8
+ "plugin:@typescript-eslint/recommended"
9
+ ],
10
+ "parser": "@typescript-eslint/parser",
11
+ "parserOptions": {
12
+ "ecmaVersion": "latest",
13
+ },
14
+ "plugins": [
15
+ "@typescript-eslint"
16
+ ],
17
+ "overrides": [
18
+ {
19
+ files: ['*.ts', '*.d.ts'],
20
+ extends: [
21
+ "standard-with-typescript"
22
+ ],
23
+ "parserOptions": {
24
+ "project": "./tsconfig.json"
25
+ },
26
+ rules: {
27
+ "@typescript-eslint/ban-ts-comment": 0
28
+ }
29
+ }
30
+ ]
31
+ }
32
+
package/.travis.yml CHANGED
@@ -1,31 +1,31 @@
1
- sudo: false
2
- language: node_js
3
- matrix:
4
- include:
5
- - node_js: '0.10'
6
- env: TEST_SUITE=unit
7
- - node_js: '0.11'
8
- env: TEST_SUITE=unit
9
- - node_js: '0.12'
10
- env: TEST_SUITE=unit
11
- - node_js: '4'
12
- env: TEST_SUITE=unit
13
- - node_js: '4'
14
- env: TEST_SUITE=standard
15
- - node_js: '4'
16
- env: TEST_SUITE=browser BROWSER_NAME=ie BROWSER_VERSION="10..latest"
17
- - node_js: '4'
18
- env: TEST_SUITE=browser BROWSER_NAME=chrome BROWSER_VERSION="44..beta"
19
- - node_js: '4'
20
- env: TEST_SUITE=browser BROWSER_NAME=firefox BROWSER_VERSION="40..latest"
21
- - node_js: '4'
22
- env: TEST_SUITE=browser BROWSER_NAME=iphone BROWSER_VERSION="8.0..latest"
23
- - node_js: '4'
24
- env: TEST_SUITE=browser BROWSER_NAME=safari BROWSER_VERSION="5..latest"
25
- - node_js: '4'
26
- env: TEST_SUITE=browser BROWSER_NAME=android BROWSER_VERSION="4.0..latest"
27
- script: "npm run-script $TEST_SUITE"
28
- env:
29
- global:
30
- - secure: YHNUDQmx/WiW3gmDcRCfb6KLDeio7Mr5tqPY2kHPdZlBSytsQjNk75ytM4U6Cu8Uk8iEIoj/aFlxiVMpJNA8J4QSUyW/YkbVaIz0+1oywoV0Ht8aRBfZ1jvXfX6789+1Q9c4xaMkYYbJpXSh9JcirsiwmqWd4+IDd7hcESodsDQ=
31
- - secure: Nhj5yejKZxUbtHGZta+GjYWqXGaOZB7ainTkOuGcpXM+OwwjeDpYlTBrwS90Q7hqens7KXVzQM09aDbadpsDCsOo1nyaEigMtomAorZ1UC1CpEoVz1ZuikF9bEhb+/7M9pzuL1fX+Ke9Dx4mPPeb8sf/2SrAu1RqXkSwZV/duAc=
1
+ sudo: false
2
+ language: node_js
3
+ matrix:
4
+ include:
5
+ - node_js: '0.10'
6
+ env: TEST_SUITE=unit
7
+ - node_js: '0.11'
8
+ env: TEST_SUITE=unit
9
+ - node_js: '0.12'
10
+ env: TEST_SUITE=unit
11
+ - node_js: '4'
12
+ env: TEST_SUITE=unit
13
+ - node_js: '4'
14
+ env: TEST_SUITE=standard
15
+ - node_js: '4'
16
+ env: TEST_SUITE=browser BROWSER_NAME=ie BROWSER_VERSION="10..latest"
17
+ - node_js: '4'
18
+ env: TEST_SUITE=browser BROWSER_NAME=chrome BROWSER_VERSION="44..beta"
19
+ - node_js: '4'
20
+ env: TEST_SUITE=browser BROWSER_NAME=firefox BROWSER_VERSION="40..latest"
21
+ - node_js: '4'
22
+ env: TEST_SUITE=browser BROWSER_NAME=iphone BROWSER_VERSION="8.0..latest"
23
+ - node_js: '4'
24
+ env: TEST_SUITE=browser BROWSER_NAME=safari BROWSER_VERSION="5..latest"
25
+ - node_js: '4'
26
+ env: TEST_SUITE=browser BROWSER_NAME=android BROWSER_VERSION="4.0..latest"
27
+ script: "npm run-script $TEST_SUITE"
28
+ env:
29
+ global:
30
+ - secure: YHNUDQmx/WiW3gmDcRCfb6KLDeio7Mr5tqPY2kHPdZlBSytsQjNk75ytM4U6Cu8Uk8iEIoj/aFlxiVMpJNA8J4QSUyW/YkbVaIz0+1oywoV0Ht8aRBfZ1jvXfX6789+1Q9c4xaMkYYbJpXSh9JcirsiwmqWd4+IDd7hcESodsDQ=
31
+ - secure: Nhj5yejKZxUbtHGZta+GjYWqXGaOZB7ainTkOuGcpXM+OwwjeDpYlTBrwS90Q7hqens7KXVzQM09aDbadpsDCsOo1nyaEigMtomAorZ1UC1CpEoVz1ZuikF9bEhb+/7M9pzuL1fX+Ke9Dx4mPPeb8sf/2SrAu1RqXkSwZV/duAc=
package/.zuul.yml CHANGED
@@ -1 +1 @@
1
- ui: tape
1
+ ui: tape
package/LICENSE CHANGED
@@ -1,24 +1,24 @@
1
- The MIT License
2
-
3
- Copyright (c) 2013 Dominic Tarr
4
-
5
- Permission is hereby granted, free of charge,
6
- to any person obtaining a copy of this software and
7
- associated documentation files (the "Software"), to
8
- deal in the Software without restriction, including
9
- without limitation the rights to use, copy, modify,
10
- merge, publish, distribute, sublicense, and/or sell
11
- copies of the Software, and to permit persons to whom
12
- the Software is furnished to do so,
13
- subject to the following conditions:
14
-
15
- The above copyright notice and this permission notice
16
- shall be included in all copies or substantial portions of the Software.
17
-
18
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
- OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
22
- ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1
+ The MIT License
2
+
3
+ Copyright (c) 2013 Dominic Tarr
4
+
5
+ Permission is hereby granted, free of charge,
6
+ to any person obtaining a copy of this software and
7
+ associated documentation files (the "Software"), to
8
+ deal in the Software without restriction, including
9
+ without limitation the rights to use, copy, modify,
10
+ merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom
12
+ the Software is furnished to do so,
13
+ subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice
16
+ shall be included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
21
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
22
+ ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24
24
  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,64 +1,66 @@
1
- # react-native-module/crypto
2
-
3
- A port of node's `crypto` module to React Native.
4
- The goal of this module is to reimplement node's crypto module so that it can run in react-native supported environments.
5
- Features and interface must be compatible with node's crypto
6
-
7
- this module is a clone of [crypto-browserify](https://github.com/crypto-browserify/crypto-browserify), [react-native-crypto](https://github.com/mvayngrib/react-native-crypto)
8
-
9
- ## Why use this module and Not others
10
-
11
- If your app is running on mobile [android, ios] only, sufficient to use module react-native-crypto
12
- Use this module if you are considering other platforms
13
-
14
- ## Install
15
-
16
- A typical workflow:
17
-
18
- ```
19
- npm i --save @react-native-module/crypto
20
- ```
21
-
22
- ```
23
- yarn add @react-native-module/crypto
24
- ```
25
-
26
- ## List of Support node's features
27
-
28
- Here is the subset that is currently implemented:
29
-
30
- - createHash (sha1, sha224, sha256, sha384, sha512, md5, rmd160)
31
- - createHmac (sha1, sha224, sha256, sha384, sha512, md5, rmd160)
32
- - pbkdf2
33
- - pbkdf2Sync
34
- - randomBytes
35
- - pseudoRandomBytes
36
- - createCipher (aes)
37
- - createDecipher (aes)
38
- - createDiffieHellman
39
- - createSign (rsa, ecdsa)
40
- - createVerify (rsa, ecdsa)
41
- - createECDH (secp256k1)
42
- - publicEncrypt/privateDecrypt (rsa)
43
-
44
- ## Todo
45
-
46
- these features from node's `crypto` are still unimplemented.
47
-
48
- - createCredentials
49
-
50
- these features would benefit from native implementations
51
-
52
- - pbkdf2
53
- - createSign
54
- - createVerify
55
- - createECDH
56
- - publicEncrypto/privateDecrypt (rsa)
57
-
58
- ## contributions
59
-
60
- Thank you for investing your time in contributing to this project!
61
-
62
- ## License
63
-
64
- MIT
1
+ # react-native-module/crypto
2
+
3
+ A port of node's `crypto` module to React Native.
4
+ The goal of this module is to reimplement node's crypto module so that it can run in react-native supported environments.
5
+ Features and interface must be compatible with node's crypto
6
+
7
+ this module is a clone of [crypto-browserify](https://github.com/crypto-browserify/crypto-browserify), [react-native-crypto](https://github.com/mvayngrib/react-native-crypto)
8
+
9
+ ## Why use this module and Not others
10
+
11
+ If your app is running on mobile [android, ios] only, sufficient to use module react-native-crypto
12
+ Use this module if you are considering other platforms
13
+
14
+ ## Install
15
+
16
+ This module has peerDependency "react-native"
17
+
18
+ A typical workflow:
19
+
20
+ ```
21
+ npm i --save @react-native-module/crypto
22
+ ```
23
+
24
+ ```
25
+ yarn add @react-native-module/crypto
26
+ ```
27
+
28
+ ## List of Support node's features
29
+
30
+ Here is the subset that is currently implemented:
31
+
32
+ - createHash (sha1, sha224, sha256, sha384, sha512, md5, rmd160)
33
+ - createHmac (sha1, sha224, sha256, sha384, sha512, md5, rmd160)
34
+ - pbkdf2
35
+ - pbkdf2Sync
36
+ - randomBytes
37
+ - pseudoRandomBytes
38
+ - createCipher (aes)
39
+ - createDecipher (aes)
40
+ - createDiffieHellman
41
+ - createSign (rsa, ecdsa)
42
+ - createVerify (rsa, ecdsa)
43
+ - createECDH (secp256k1)
44
+ - publicEncrypt/privateDecrypt (rsa)
45
+
46
+ ## Todo
47
+
48
+ these features from node's `crypto` are still unimplemented.
49
+
50
+ - createCredentials
51
+
52
+ these features would benefit from native implementations
53
+
54
+ - pbkdf2
55
+ - createSign
56
+ - createVerify
57
+ - createECDH
58
+ - publicEncrypto/privateDecrypt (rsa)
59
+
60
+ ## contributions
61
+
62
+ Thank you for investing your time in contributing to this project!
63
+
64
+ ## License
65
+
66
+ MIT
@@ -0,0 +1,109 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var createHashModule = require('create-hash');
6
+ var createHmacModule = require('create-hmac');
7
+ var randomBytesModule = require('@react-native-module/randombytes');
8
+ var signAlogos = require('browserify-sign/browser/algorithms.json');
9
+ var pbkdf2$1 = require('@react-native-module/pbkdf2');
10
+ var aes = require('browserify-cipher');
11
+ var dh = require('diffie-hellman');
12
+ var sign = require('browserify-sign');
13
+ var createEcdhModule = require('create-ecdh');
14
+ var publicEncryptModule = require('public-encrypt');
15
+
16
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
+
18
+ var createHashModule__default = /*#__PURE__*/_interopDefaultLegacy(createHashModule);
19
+ var createHmacModule__default = /*#__PURE__*/_interopDefaultLegacy(createHmacModule);
20
+ var randomBytesModule__default = /*#__PURE__*/_interopDefaultLegacy(randomBytesModule);
21
+ var signAlogos__default = /*#__PURE__*/_interopDefaultLegacy(signAlogos);
22
+ var aes__default = /*#__PURE__*/_interopDefaultLegacy(aes);
23
+ var dh__default = /*#__PURE__*/_interopDefaultLegacy(dh);
24
+ var sign__default = /*#__PURE__*/_interopDefaultLegacy(sign);
25
+ var createEcdhModule__default = /*#__PURE__*/_interopDefaultLegacy(createEcdhModule);
26
+ var publicEncryptModule__default = /*#__PURE__*/_interopDefaultLegacy(publicEncryptModule);
27
+
28
+ const Hash = createHashModule__default["default"];
29
+ const createHash = Hash;
30
+ const Hmac = createHmacModule__default["default"];
31
+ const createHmac = createHmacModule__default["default"];
32
+ const randomBytes = randomBytesModule__default["default"];
33
+ const rng = randomBytes;
34
+ const pseudoRandomBytes = randomBytes;
35
+ const prng = randomBytes;
36
+ const hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(Object.keys(signAlogos__default["default"]));
37
+ function getHashes() {
38
+ return hashes;
39
+ }
40
+ const pbkdf2 = pbkdf2$1.pbkdf2;
41
+ const pbkdf2Sync = pbkdf2$1.pbkdf2Sync;
42
+ const Cipher = aes__default["default"].Cipher;
43
+ const createCipher = aes__default["default"].createCipher;
44
+ const Cipheriv = aes__default["default"].Cipheriv;
45
+ const createCipheriv = aes__default["default"].createCipheriv;
46
+ const Decipher = aes__default["default"].Decipher;
47
+ const createDecipher = aes__default["default"].createDecipher;
48
+ const Decipheriv = aes__default["default"].Decipheriv;
49
+ const createDecipheriv = aes__default["default"].createDecipheriv;
50
+ const getCiphers = aes__default["default"].getCiphers;
51
+ const listCiphers = aes__default["default"].listCiphers;
52
+ const DiffieHellmanGroup = dh__default["default"].DiffieHellmanGroup;
53
+ const createDiffieHellmanGroup = dh__default["default"].createDiffieHellmanGroup;
54
+ const getDiffieHellman = dh__default["default"].getDiffieHellman;
55
+ const createDiffieHellman = dh__default["default"].createDiffieHellman;
56
+ const DiffieHellman = dh__default["default"].DiffieHellman;
57
+ const createSign = sign__default["default"].createSign;
58
+ const Sign = sign__default["default"].Sign;
59
+ const createVerify = sign__default["default"].createVerify;
60
+ const Verify = sign__default["default"].Verify;
61
+ const createECDH = createEcdhModule__default["default"];
62
+ const publicEncrypt = publicEncryptModule__default["default"].publicEncrypt;
63
+ const privateEncrypt = publicEncryptModule__default["default"].privateEncrypt;
64
+ const publicDecrypt = publicEncryptModule__default["default"].publicDecrypt;
65
+ const privateDecrypt = publicEncryptModule__default["default"].privateDecrypt;
66
+ const createCredentials = () => {
67
+ throw new Error([
68
+ 'sorry, createCredentials is not implemented yet',
69
+ 'we accept pull requests',
70
+ 'https://github.com/crypto-browserify/crypto-browserify'
71
+ ].join('\n'));
72
+ };
73
+
74
+ exports.Cipher = Cipher;
75
+ exports.Cipheriv = Cipheriv;
76
+ exports.Decipher = Decipher;
77
+ exports.Decipheriv = Decipheriv;
78
+ exports.DiffieHellman = DiffieHellman;
79
+ exports.DiffieHellmanGroup = DiffieHellmanGroup;
80
+ exports.Hash = Hash;
81
+ exports.Hmac = Hmac;
82
+ exports.Sign = Sign;
83
+ exports.Verify = Verify;
84
+ exports.createCipher = createCipher;
85
+ exports.createCipheriv = createCipheriv;
86
+ exports.createCredentials = createCredentials;
87
+ exports.createDecipher = createDecipher;
88
+ exports.createDecipheriv = createDecipheriv;
89
+ exports.createDiffieHellman = createDiffieHellman;
90
+ exports.createDiffieHellmanGroup = createDiffieHellmanGroup;
91
+ exports.createECDH = createECDH;
92
+ exports.createHash = createHash;
93
+ exports.createHmac = createHmac;
94
+ exports.createSign = createSign;
95
+ exports.createVerify = createVerify;
96
+ exports.getCiphers = getCiphers;
97
+ exports.getDiffieHellman = getDiffieHellman;
98
+ exports.getHashes = getHashes;
99
+ exports.listCiphers = listCiphers;
100
+ exports.pbkdf2 = pbkdf2;
101
+ exports.pbkdf2Sync = pbkdf2Sync;
102
+ exports.privateDecrypt = privateDecrypt;
103
+ exports.privateEncrypt = privateEncrypt;
104
+ exports.prng = prng;
105
+ exports.pseudoRandomBytes = pseudoRandomBytes;
106
+ exports.publicDecrypt = publicDecrypt;
107
+ exports.publicEncrypt = publicEncrypt;
108
+ exports.randomBytes = randomBytes;
109
+ exports.rng = rng;
@@ -0,0 +1,58 @@
1
+ import createHashModule from 'create-hash';
2
+ import createHmacModule from 'create-hmac';
3
+ import randomBytesModule from '@react-native-module/randombytes';
4
+ import signAlogos from 'browserify-sign/browser/algorithms.json';
5
+ import { pbkdf2 as pbkdf2$1, pbkdf2Sync as pbkdf2Sync$1 } from '@react-native-module/pbkdf2';
6
+ import aes from 'browserify-cipher';
7
+ import dh from 'diffie-hellman';
8
+ import sign from 'browserify-sign';
9
+ import createEcdhModule from 'create-ecdh';
10
+ import publicEncryptModule from 'public-encrypt';
11
+
12
+ const Hash = createHashModule;
13
+ const createHash = Hash;
14
+ const Hmac = createHmacModule;
15
+ const createHmac = createHmacModule;
16
+ const randomBytes = randomBytesModule;
17
+ const rng = randomBytes;
18
+ const pseudoRandomBytes = randomBytes;
19
+ const prng = randomBytes;
20
+ const hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(Object.keys(signAlogos));
21
+ function getHashes() {
22
+ return hashes;
23
+ }
24
+ const pbkdf2 = pbkdf2$1;
25
+ const pbkdf2Sync = pbkdf2Sync$1;
26
+ const Cipher = aes.Cipher;
27
+ const createCipher = aes.createCipher;
28
+ const Cipheriv = aes.Cipheriv;
29
+ const createCipheriv = aes.createCipheriv;
30
+ const Decipher = aes.Decipher;
31
+ const createDecipher = aes.createDecipher;
32
+ const Decipheriv = aes.Decipheriv;
33
+ const createDecipheriv = aes.createDecipheriv;
34
+ const getCiphers = aes.getCiphers;
35
+ const listCiphers = aes.listCiphers;
36
+ const DiffieHellmanGroup = dh.DiffieHellmanGroup;
37
+ const createDiffieHellmanGroup = dh.createDiffieHellmanGroup;
38
+ const getDiffieHellman = dh.getDiffieHellman;
39
+ const createDiffieHellman = dh.createDiffieHellman;
40
+ const DiffieHellman = dh.DiffieHellman;
41
+ const createSign = sign.createSign;
42
+ const Sign = sign.Sign;
43
+ const createVerify = sign.createVerify;
44
+ const Verify = sign.Verify;
45
+ const createECDH = createEcdhModule;
46
+ const publicEncrypt = publicEncryptModule.publicEncrypt;
47
+ const privateEncrypt = publicEncryptModule.privateEncrypt;
48
+ const publicDecrypt = publicEncryptModule.publicDecrypt;
49
+ const privateDecrypt = publicEncryptModule.privateDecrypt;
50
+ const createCredentials = () => {
51
+ throw new Error([
52
+ 'sorry, createCredentials is not implemented yet',
53
+ 'we accept pull requests',
54
+ 'https://github.com/crypto-browserify/crypto-browserify'
55
+ ].join('\n'));
56
+ };
57
+
58
+ export { Cipher, Cipheriv, Decipher, Decipheriv, DiffieHellman, DiffieHellmanGroup, Hash, Hmac, Sign, Verify, createCipher, createCipheriv, createCredentials, createDecipher, createDecipheriv, createDiffieHellman, createDiffieHellmanGroup, createECDH, createHash, createHmac, createSign, createVerify, getCiphers, getDiffieHellman, getHashes, listCiphers, pbkdf2, pbkdf2Sync, privateDecrypt, privateEncrypt, prng, pseudoRandomBytes, publicDecrypt, publicEncrypt, randomBytes, rng };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,37 @@
1
+ import { pbkdf2 as pbkdf2Ori, pbkdf2Sync as pbkdf2SyncOri } from '@react-native-module/pbkdf2';
2
+ export declare const Hash: any;
3
+ export declare const createHash: any;
4
+ export declare const Hmac: any;
5
+ export declare const createHmac: any;
6
+ export declare const randomBytes: any;
7
+ export declare const rng: any;
8
+ export declare const pseudoRandomBytes: any;
9
+ export declare const prng: any;
10
+ export declare function getHashes(): string[];
11
+ export declare const pbkdf2: typeof pbkdf2Ori;
12
+ export declare const pbkdf2Sync: typeof pbkdf2SyncOri;
13
+ export declare const Cipher: any;
14
+ export declare const createCipher: any;
15
+ export declare const Cipheriv: any;
16
+ export declare const createCipheriv: any;
17
+ export declare const Decipher: any;
18
+ export declare const createDecipher: any;
19
+ export declare const Decipheriv: any;
20
+ export declare const createDecipheriv: any;
21
+ export declare const getCiphers: any;
22
+ export declare const listCiphers: any;
23
+ export declare const DiffieHellmanGroup: any;
24
+ export declare const createDiffieHellmanGroup: any;
25
+ export declare const getDiffieHellman: any;
26
+ export declare const createDiffieHellman: any;
27
+ export declare const DiffieHellman: any;
28
+ export declare const createSign: any;
29
+ export declare const Sign: any;
30
+ export declare const createVerify: any;
31
+ export declare const Verify: any;
32
+ export declare const createECDH: any;
33
+ export declare const publicEncrypt: any;
34
+ export declare const privateEncrypt: any;
35
+ export declare const publicDecrypt: any;
36
+ export declare const privateDecrypt: any;
37
+ export declare const createCredentials: () => any;
package/package.json CHANGED
@@ -1,46 +1,69 @@
1
- {
2
- "author": "sacru2red <sacru2red@gmail.com>",
3
- "name": "@react-native-module/crypto",
4
- "description": "implementation of crypto for React Native",
5
- "version": "2.1.1",
6
- "homepage": "https://github.com/react-native-module/crypto",
7
- "repository": {
8
- "type": "git",
9
- "url": "git://github.com/react-native-module/crypto.git"
10
- },
11
- "scripts": {
12
- "standard": "standard",
13
- "test": "npm run standard && npm run unit",
14
- "unit": "Echo 'tests not set up for React Native yet'"
15
- },
16
- "engines": {
17
- "node": "*"
18
- },
19
- "dependencies": {
20
- "browserify-cipher": "^1.0.0",
21
- "browserify-sign": "^4.0.4",
22
- "create-ecdh": "^4.0.0",
23
- "create-hash": "^1.1.0",
24
- "create-hmac": "^1.1.0",
25
- "diffie-hellman": "^5.0.0",
26
- "inherits": "^2.0.1",
27
- "pbkdf2": "^3.1.2",
28
- "public-encrypt": "^4.0.0"
29
- },
30
- "peerDependencies": {
31
- "react-native-randombytes": ">=2.0.0 <4.0.0"
32
- },
33
- "devDependencies": {
34
- "hash-test-vectors": "~1.3.2",
35
- "pseudorandombytes": "^2.0.0",
36
- "standard": "^16.0.4",
37
- "tape": "~2.3.2",
38
- "zuul": "^3.12.0"
39
- },
40
- "optionalDependencies": {},
41
- "keywords": [
42
- "react-native",
43
- "crypto"
44
- ],
45
- "license": "MIT"
46
- }
1
+ {
2
+ "author": "sacru2red <sacru2red@gmail.com>",
3
+ "name": "@react-native-module/crypto",
4
+ "description": "implementation of crypto for React Native",
5
+ "version": "2.1.3-1",
6
+ "main": "lib/cjs/index.js",
7
+ "module": "lib/es/index.js",
8
+ "types": "lib/types/index.d.ts",
9
+ "source": "src/index",
10
+ "react-native": "src/index.ts",
11
+ "homepage": "https://github.com/react-native-module/crypto",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/react-native-module/crypto.git"
15
+ },
16
+ "scripts": {
17
+ "lint": "eslint",
18
+ "build": "rimraf ./lib && rollup -c ./rollup.config.js && npm run build:types",
19
+ "build:types": "tsc --emitDeclarationOnly --declaration --declarationDir lib/types",
20
+ "release": "npm run build && release-it",
21
+ "test": "npm run unit",
22
+ "unit": "echo 'tests not set up for React Native yet'"
23
+ },
24
+ "dependencies": {
25
+ "@react-native-module/pbkdf2": "^0.3.7",
26
+ "@react-native-module/randombytes": "^3.6.6-5",
27
+ "browserify-cipher": "^1.0.0",
28
+ "browserify-sign": "^4.0.4",
29
+ "create-ecdh": "^4.0.0",
30
+ "create-hash": "^1.1.0",
31
+ "create-hmac": "^1.1.0",
32
+ "diffie-hellman": "^5.0.0",
33
+ "inherits": "^2.0.1",
34
+ "public-encrypt": "^4.0.0"
35
+ },
36
+ "devDependencies": {
37
+ "@rollup/plugin-commonjs": "^22.0.1",
38
+ "@rollup/plugin-json": "^4.1.0",
39
+ "@rollup/plugin-node-resolve": "^13.3.0",
40
+ "@rollup/plugin-typescript": "^8.3.3",
41
+ "@typescript-eslint/eslint-plugin": "^5.30.7",
42
+ "@typescript-eslint/parser": "^5.30.7",
43
+ "eslint": "^8.20.0",
44
+ "eslint-config-standard-with-typescript": "^22.0.0",
45
+ "eslint-plugin-import": "^2.26.0",
46
+ "eslint-plugin-n": "^15.2.4",
47
+ "eslint-plugin-promise": "^6.0.0",
48
+ "hash-test-vectors": "~1.3.2",
49
+ "pseudorandombytes": "^2.0.0",
50
+ "release-it": "^15.1.3",
51
+ "rimraf": "^3.0.2",
52
+ "rollup": "^2.77.0",
53
+ "tape": "~2.3.2",
54
+ "typescript": "^4.7.4",
55
+ "zuul": "^3.12.0"
56
+ },
57
+ "peerDependencies": {
58
+ "react-native": "*"
59
+ },
60
+ "keywords": [
61
+ "react native",
62
+ "react-native",
63
+ "crypto",
64
+ "ios",
65
+ "android",
66
+ "web"
67
+ ],
68
+ "license": "MIT"
69
+ }
@@ -0,0 +1,49 @@
1
+ import commonjs from "@rollup/plugin-commonjs"
2
+ import { nodeResolve } from "@rollup/plugin-node-resolve"
3
+ import typescript from '@rollup/plugin-typescript';
4
+ import json from "@rollup/plugin-json";
5
+
6
+ const inputSrc = [
7
+ ["./src/index.ts", "es"],
8
+ ["./src/index.ts", "cjs"],
9
+ ]
10
+
11
+ const extensions = [".mjs", ".json", ".ts", ".native.ts", ".native.js"]
12
+
13
+ export default inputSrc
14
+ .map(([input, format]) => {
15
+ return {
16
+ input,
17
+ output: {
18
+ dir: `lib/${format}`,
19
+ format,
20
+ },
21
+ preserveModules: true,
22
+ external: [
23
+ "@react-native-module/randombytes",
24
+ '@react-native-module/pbkdf2',
25
+ "browserify-cipher",
26
+ "browserify-sign",
27
+ 'browserify-sign/browser/algorithms.json',
28
+ "create-ecdh",
29
+ "create-hash",
30
+ "create-hmac",
31
+ "diffie-hellman",
32
+ "elliptic",
33
+ "inherits",
34
+ "pbkdf2",
35
+ "public-encrypt",
36
+ 'react-native'
37
+ ],
38
+ plugins: [
39
+ json(),
40
+ typescript(),
41
+ nodeResolve(),
42
+ // https://velog.io/@peterkimzz/rollup-%ED%94%8C%EB%9F%AC%EA%B7%B8%EC%9D%B8
43
+ // CommonJS 로 작성된 모듈들을 ES6 바꾸어서 rollup이 해석할 수 있게 도와줍니다.
44
+ commonjs({
45
+ extensions: [...extensions, ".js"],
46
+ }),
47
+ ]
48
+ }
49
+ })
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 ADDED
@@ -0,0 +1,63 @@
1
+ import createHashModule from 'create-hash'
2
+ import createHmacModule from 'create-hmac'
3
+ import randomBytesModule from '@react-native-module/randombytes'
4
+ import signAlogos from 'browserify-sign/browser/algorithms.json'
5
+ import { pbkdf2 as pbkdf2Ori, pbkdf2Sync as pbkdf2SyncOri } from '@react-native-module/pbkdf2'
6
+ import aes from 'browserify-cipher'
7
+ import dh from 'diffie-hellman'
8
+ import sign from 'browserify-sign'
9
+ import createEcdhModule from 'create-ecdh'
10
+ import publicEncryptModule from 'public-encrypt'
11
+
12
+ export const Hash = createHashModule
13
+ export const createHash = Hash
14
+ export const Hmac = createHmacModule
15
+ export const createHmac = createHmacModule
16
+ export const randomBytes = randomBytesModule
17
+ export const rng = randomBytes
18
+ export const pseudoRandomBytes = randomBytes
19
+ export const prng = randomBytes
20
+
21
+ const hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(Object.keys(signAlogos))
22
+ export function getHashes (): string[] {
23
+ return hashes
24
+ }
25
+ export const pbkdf2 = pbkdf2Ori
26
+ export const pbkdf2Sync = pbkdf2SyncOri
27
+
28
+ export const Cipher = aes.Cipher
29
+ export const createCipher = aes.createCipher
30
+ export const Cipheriv = aes.Cipheriv
31
+ export const createCipheriv = aes.createCipheriv
32
+ export const Decipher = aes.Decipher
33
+ export const createDecipher = aes.createDecipher
34
+ export const Decipheriv = aes.Decipheriv
35
+ export const createDecipheriv = aes.createDecipheriv
36
+ export const getCiphers = aes.getCiphers
37
+ export const listCiphers = aes.listCiphers
38
+
39
+ export const DiffieHellmanGroup = dh.DiffieHellmanGroup
40
+ export const createDiffieHellmanGroup = dh.createDiffieHellmanGroup
41
+ export const getDiffieHellman = dh.getDiffieHellman
42
+ export const createDiffieHellman = dh.createDiffieHellman
43
+ export const DiffieHellman = dh.DiffieHellman
44
+
45
+ export const createSign = sign.createSign
46
+ export const Sign = sign.Sign
47
+ export const createVerify = sign.createVerify
48
+ export const Verify = sign.Verify
49
+
50
+ export const createECDH = createEcdhModule
51
+
52
+ export const publicEncrypt = publicEncryptModule.publicEncrypt
53
+ export const privateEncrypt = publicEncryptModule.privateEncrypt
54
+ export const publicDecrypt = publicEncryptModule.publicDecrypt
55
+ export const privateDecrypt = publicEncryptModule.privateDecrypt
56
+
57
+ export const createCredentials = (): any => {
58
+ throw new Error([
59
+ 'sorry, createCredentials is not implemented yet',
60
+ 'we accept pull requests',
61
+ 'https://github.com/crypto-browserify/crypto-browserify'
62
+ ].join('\n'))
63
+ }
package/index.js DELETED
@@ -1,99 +0,0 @@
1
- 'use strict'
2
-
3
- import { randomBytes } from 'react-native-randombytes'
4
- exports.randomBytes = exports.rng = exports.pseudoRandomBytes = exports.prng = randomBytes
5
-
6
- // implement window.getRandomValues(), for packages that rely on it
7
- if (typeof window === 'object') {
8
- if (!window.crypto) window.crypto = {}
9
- if (!window.crypto.getRandomValues) {
10
- window.crypto.getRandomValues = function getRandomValues (arr) {
11
- const orig = arr
12
- if (arr.byteLength !== arr.length) {
13
- // Get access to the underlying raw bytes
14
- arr = new Uint8Array(arr.buffer)
15
- }
16
- const bytes = randomBytes(arr.length)
17
- for (let i = 0; i < bytes.length; i++) {
18
- arr[i] = bytes[i]
19
- }
20
-
21
- return orig
22
- }
23
- }
24
- }
25
-
26
- exports.createHash = exports.Hash = require('create-hash')
27
- exports.createHmac = exports.Hmac = require('create-hmac')
28
-
29
- const hashes = ['sha1', 'sha224', 'sha256', 'sha384', 'sha512', 'md5', 'rmd160'].concat(Object.keys(require('browserify-sign/algos')))
30
- exports.getHashes = function () {
31
- return hashes
32
- }
33
-
34
- const p = require('pbkdf2')
35
- exports.pbkdf2 = p.pbkdf2
36
- exports.pbkdf2Sync = p.pbkdf2Sync
37
-
38
- const aes = require('browserify-cipher')
39
- ;[
40
- 'Cipher',
41
- 'createCipher',
42
- 'Cipheriv',
43
- 'createCipheriv',
44
- 'Decipher',
45
- 'createDecipher',
46
- 'Decipheriv',
47
- 'createDecipheriv',
48
- 'getCiphers',
49
- 'listCiphers'
50
- ].forEach(function (key) {
51
- exports[key] = aes[key]
52
- })
53
-
54
- const dh = require('diffie-hellman')
55
- ;[
56
- 'DiffieHellmanGroup',
57
- 'createDiffieHellmanGroup',
58
- 'getDiffieHellman',
59
- 'createDiffieHellman',
60
- 'DiffieHellman'
61
- ].forEach(function (key) {
62
- exports[key] = dh[key]
63
- })
64
-
65
- const sign = require('browserify-sign')
66
- ;[
67
- 'createSign',
68
- 'Sign',
69
- 'createVerify',
70
- 'Verify'
71
- ].forEach(function (key) {
72
- exports[key] = sign[key]
73
- })
74
-
75
- exports.createECDH = require('create-ecdh')
76
-
77
- const publicEncrypt = require('public-encrypt')
78
-
79
- ;[
80
- 'publicEncrypt',
81
- 'privateEncrypt',
82
- 'publicDecrypt',
83
- 'privateDecrypt'
84
- ].forEach(function (key) {
85
- exports[key] = publicEncrypt[key]
86
- })
87
-
88
- // the least I can do is make error messages for the rest of the node.js/crypto api.
89
- ;[
90
- 'createCredentials'
91
- ].forEach(function (name) {
92
- exports[name] = function () {
93
- throw new Error([
94
- 'sorry, ' + name + ' is not implemented yet',
95
- 'we accept pull requests',
96
- 'https://github.com/crypto-browserify/crypto-browserify'
97
- ].join('\n'))
98
- }
99
- })