-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
keysIOS.js
executable file
Β·60 lines (56 loc) Β· 1.79 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
#! /usr/bin/env node
const {
getKeys,
makeFileInIosDir,
makeFileInCPPDir,
getIosEnvironmentFile,
makeFileInProjectDirectoryIos,
splitPrivateKeyInto3ChunksOfArray,
makeCppFileTemplate,
generatePassword,
encrypt,
genTSType,
} = require('./src/util/common');
const {
makePrivateKeyTemplateIOS,
makeXcConfigFIlle,
makeGeneratedDotEnvTemplateIOS,
} = require('./src/util/keysFilesTemplateIos');
const makeIosJnuFiles = () => {
const KEYS_FILE_NAME = getIosEnvironmentFile();
const allKeys = getKeys(KEYS_FILE_NAME);
const secureKeys = allKeys.secure;
const publicKeys = allKeys.public;
const stringifyKeys = JSON.stringify(secureKeys);
const password = generatePassword();
const privateKey = encrypt(stringifyKeys, password);
const privateKeyIn3Chunks = splitPrivateKeyInto3ChunksOfArray(privateKey);
const cppFileContent = makeCppFileTemplate(privateKeyIn3Chunks, password);
const isDoneCryptoCppFile = makeFileInCPPDir(cppFileContent, 'crypto.cpp');
const halfKey = privateKey.substr(privateKey.length / 2);
const generatedPrivateKeyContent = makePrivateKeyTemplateIOS({
privateKey: halfKey,
});
const isGeneratedPrivateKeyFile = makeFileInIosDir(
generatedPrivateKeyContent,
'privateKey.m'
);
const xcConfigFileContent = makeXcConfigFIlle(publicKeys);
const isDoneCreatedXCodeConfigFile = makeFileInProjectDirectoryIos(
xcConfigFileContent,
'tmp.xcconfig'
);
const generatedDotEnvContent = makeGeneratedDotEnvTemplateIOS(publicKeys);
const isGeneratedDotEnvFile = makeFileInIosDir(
generatedDotEnvContent,
'GeneratedDotEnv.m'
);
genTSType(allKeys);
console.info('react-native-keys', {
isDoneCryptoCppFile,
isGeneratedPrivateKeyFile,
isDoneCreatedXCodeConfigFile,
isGeneratedDotEnvFile,
});
};
makeIosJnuFiles();