forked from numandev1/react-native-keys
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeysIOS.js
executable file
·74 lines (67 loc) · 2.01 KB
/
keysIOS.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#! /usr/bin/env node
const SHA256 = require('crypto-js/sha256');
const {
getKeys,
makeFileInIosDir,
makeEncryptionFile,
getIosEnviromentFile,
makeFileInProjectDirectoryIos,
} = require('./src/util/common');
const {
makeCppFileTemplateIOS,
makeHppFileTemplateIOS,
makeKeysPackageMMTemplateIOS,
makeXcConfigFIlle,
makeGeneratedDotEnvTemplateIOS,
} = require('./src/util/keysFilesTemplateIos');
const makeIosJnuFiles = () => {
const KEYS_FILE_NAME = getIosEnviromentFile();
const allKeys = getKeys(KEYS_FILE_NAME);
const secureKeys = allKeys.secure;
const publicKeys = allKeys.public;
const stringifyKeys = JSON.stringify(secureKeys);
const cppFileContent = makeCppFileTemplateIOS(
stringifyKeys.replace(/(")/g, '\\"')
);
const isDoneCreatedIosCppFile = makeFileInIosDir(
cppFileContent,
'crypto.cpp'
);
const hppFileContent = makeHppFileTemplateIOS();
const isDoneCreatedIosHppFile = makeFileInIosDir(
hppFileContent,
'crypto.hpp'
);
const encryptionFileContent = makeEncryptionFile();
const isDoneCreatedIosEncryptionFile = makeFileInIosDir(
encryptionFileContent,
'encrypt.h'
);
const privateKey = SHA256(stringifyKeys).toString();
const halfKey = privateKey.substr(privateKey.length / 2);
const jniKeysPackageMMFile = makeKeysPackageMMTemplateIOS(halfKey);
const isDoneCreatedNniKeysPackageFile = makeFileInIosDir(
jniKeysPackageMMFile,
'Keys.mm'
);
const xcConfigFileContent = makeXcConfigFIlle(publicKeys);
const isDoneCreatedIosxcConfigFile = makeFileInProjectDirectoryIos(
xcConfigFileContent,
'tmp.xcconfig'
);
const generatedDotEnvContent = makeGeneratedDotEnvTemplateIOS(publicKeys);
const isGeneratedDotEnvFile = makeFileInIosDir(
generatedDotEnvContent,
'GeneratedDotEnv.m'
);
console.log(
'test',
isDoneCreatedIosCppFile,
isDoneCreatedIosHppFile,
isDoneCreatedIosEncryptionFile,
isDoneCreatedNniKeysPackageFile,
isDoneCreatedIosxcConfigFile,
isGeneratedDotEnvFile
);
};
makeIosJnuFiles();