-
-
Notifications
You must be signed in to change notification settings - Fork 27
/
keysAndroid.js
executable file
Β·41 lines (39 loc) Β· 1.31 KB
/
keysAndroid.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
#! /usr/bin/env node
const {
getKeys,
makeFileInAndroidMainAssetsFolder,
getAndroidEnvironmentFile,
generatePassword,
encrypt,
makeCppFileTemplate,
splitPrivateKeyInto3ChunksOfArray,
makeFileInCPPDir,
genTSType,
} = require('./src/util/common');
const {
makeCryptographicModuleTemplateAndroid,
} = require('./src/util/keysFilesTemplateAndroid');
const makeAndroidJnuFiles = () => {
const KEYS_FILE_NAME = getAndroidEnvironmentFile();
const allKeys = getKeys(KEYS_FILE_NAME);
const secureKeys = allKeys.secure;
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 cryptographicModuleFileContent =
makeCryptographicModuleTemplateAndroid(halfKey);
const isDoneAddedPrivateKey = makeFileInAndroidMainAssetsFolder(
cryptographicModuleFileContent,
'PrivateKey.java'
);
genTSType(allKeys);
console.info('react-native-keys', {
isDoneCryptoCppFile,
isDoneAddedPrivateKey,
});
};
makeAndroidJnuFiles();