@react-native-module/crypto 2.1.1 → 2.1.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/.eslintrc.js +29 -0
- package/README.md +2 -0
- package/lib/cjs/index.js +109 -0
- package/lib/es/index.js +58 -0
- package/lib/types/index.d.ts +38 -0
- package/package.json +37 -15
- package/rollup.config.js +49 -0
- package/src/index.ts +63 -0
- package/index.js +0 -99
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
}
|
|
27
|
+
]
|
|
28
|
+
}
|
|
29
|
+
|
package/README.md
CHANGED
package/lib/cjs/index.js
ADDED
|
@@ -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"].randomBytes;
|
|
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;
|
package/lib/es/index.js
ADDED
|
@@ -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.randomBytes;
|
|
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,38 @@
|
|
|
1
|
+
import randomBytesModule from '@react-native-module/randombytes';
|
|
2
|
+
import { pbkdf2 as pbkdf2Ori, pbkdf2Sync as pbkdf2SyncOri } from '@react-native-module/pbkdf2';
|
|
3
|
+
export declare const Hash: any;
|
|
4
|
+
export declare const createHash: any;
|
|
5
|
+
export declare const Hmac: any;
|
|
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;
|
|
11
|
+
export declare function getHashes(): string[];
|
|
12
|
+
export declare const pbkdf2: typeof pbkdf2Ori;
|
|
13
|
+
export declare const pbkdf2Sync: typeof pbkdf2SyncOri;
|
|
14
|
+
export declare const Cipher: any;
|
|
15
|
+
export declare const createCipher: any;
|
|
16
|
+
export declare const Cipheriv: any;
|
|
17
|
+
export declare const createCipheriv: any;
|
|
18
|
+
export declare const Decipher: any;
|
|
19
|
+
export declare const createDecipher: any;
|
|
20
|
+
export declare const Decipheriv: any;
|
|
21
|
+
export declare const createDecipheriv: any;
|
|
22
|
+
export declare const getCiphers: any;
|
|
23
|
+
export declare const listCiphers: any;
|
|
24
|
+
export declare const DiffieHellmanGroup: any;
|
|
25
|
+
export declare const createDiffieHellmanGroup: any;
|
|
26
|
+
export declare const getDiffieHellman: any;
|
|
27
|
+
export declare const createDiffieHellman: any;
|
|
28
|
+
export declare const DiffieHellman: any;
|
|
29
|
+
export declare const createSign: any;
|
|
30
|
+
export declare const Sign: any;
|
|
31
|
+
export declare const createVerify: any;
|
|
32
|
+
export declare const Verify: any;
|
|
33
|
+
export declare const createECDH: any;
|
|
34
|
+
export declare const publicEncrypt: any;
|
|
35
|
+
export declare const privateEncrypt: any;
|
|
36
|
+
export declare const publicDecrypt: any;
|
|
37
|
+
export declare const privateDecrypt: any;
|
|
38
|
+
export declare const createCredentials: () => any;
|
package/package.json
CHANGED
|
@@ -2,21 +2,27 @@
|
|
|
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.
|
|
5
|
+
"version": "2.1.2",
|
|
6
|
+
"main": "lib/cjs/index.js",
|
|
7
|
+
"module": "lib/es/index.js",
|
|
8
|
+
"types": "lib/types/index.d.ts",
|
|
9
|
+
"source": "src/index",
|
|
6
10
|
"homepage": "https://github.com/react-native-module/crypto",
|
|
7
11
|
"repository": {
|
|
8
12
|
"type": "git",
|
|
9
|
-
"url": "git://github.com/react-native-module/crypto.git"
|
|
13
|
+
"url": "git+https://github.com/react-native-module/crypto.git"
|
|
10
14
|
},
|
|
11
15
|
"scripts": {
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
16
|
+
"lint": "eslint",
|
|
17
|
+
"build": "rimraf ./lib && rollup -c ./rollup.config.js && npm run build:types",
|
|
18
|
+
"build:types": "tsc --emitDeclarationOnly --declaration --declarationDir lib/types",
|
|
19
|
+
"release": "npm run build && release-it",
|
|
20
|
+
"test": "npm run unit",
|
|
21
|
+
"unit": "echo 'tests not set up for React Native yet'"
|
|
18
22
|
},
|
|
19
23
|
"dependencies": {
|
|
24
|
+
"@react-native-module/pbkdf2": "^0.3.7",
|
|
25
|
+
"@react-native-module/randombytes": "^3.6.6-3",
|
|
20
26
|
"browserify-cipher": "^1.0.0",
|
|
21
27
|
"browserify-sign": "^4.0.4",
|
|
22
28
|
"create-ecdh": "^4.0.0",
|
|
@@ -24,23 +30,39 @@
|
|
|
24
30
|
"create-hmac": "^1.1.0",
|
|
25
31
|
"diffie-hellman": "^5.0.0",
|
|
26
32
|
"inherits": "^2.0.1",
|
|
27
|
-
"pbkdf2": "^3.1.2",
|
|
28
33
|
"public-encrypt": "^4.0.0"
|
|
29
34
|
},
|
|
30
|
-
"peerDependencies": {
|
|
31
|
-
"react-native-randombytes": ">=2.0.0 <4.0.0"
|
|
32
|
-
},
|
|
33
35
|
"devDependencies": {
|
|
36
|
+
"@rollup/plugin-commonjs": "^22.0.1",
|
|
37
|
+
"@rollup/plugin-json": "^4.1.0",
|
|
38
|
+
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
39
|
+
"@rollup/plugin-typescript": "^8.3.3",
|
|
40
|
+
"@typescript-eslint/eslint-plugin": "^5.30.7",
|
|
41
|
+
"@typescript-eslint/parser": "^5.30.7",
|
|
42
|
+
"eslint": "^8.20.0",
|
|
43
|
+
"eslint-config-standard-with-typescript": "^22.0.0",
|
|
44
|
+
"eslint-plugin-import": "^2.26.0",
|
|
45
|
+
"eslint-plugin-n": "^15.2.4",
|
|
46
|
+
"eslint-plugin-promise": "^6.0.0",
|
|
34
47
|
"hash-test-vectors": "~1.3.2",
|
|
35
48
|
"pseudorandombytes": "^2.0.0",
|
|
36
|
-
"
|
|
49
|
+
"release-it": "^15.1.3",
|
|
50
|
+
"rimraf": "^3.0.2",
|
|
51
|
+
"rollup": "^2.77.0",
|
|
37
52
|
"tape": "~2.3.2",
|
|
53
|
+
"typescript": "^4.7.4",
|
|
38
54
|
"zuul": "^3.12.0"
|
|
39
55
|
},
|
|
40
|
-
"
|
|
56
|
+
"peerDependencies": {
|
|
57
|
+
"react-native": "*"
|
|
58
|
+
},
|
|
41
59
|
"keywords": [
|
|
60
|
+
"react native",
|
|
42
61
|
"react-native",
|
|
43
|
-
"crypto"
|
|
62
|
+
"crypto",
|
|
63
|
+
"ios",
|
|
64
|
+
"android",
|
|
65
|
+
"web"
|
|
44
66
|
],
|
|
45
67
|
"license": "MIT"
|
|
46
68
|
}
|
package/rollup.config.js
ADDED
|
@@ -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/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.randomBytes
|
|
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
|
-
})
|