-
Notifications
You must be signed in to change notification settings - Fork 290
Expand file tree
/
Copy pathcreateAndroidKeys.ts
More file actions
75 lines (63 loc) · 2.34 KB
/
createAndroidKeys.ts
File metadata and controls
75 lines (63 loc) · 2.34 KB
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
75
import childProcess from 'child_process'
import { randomBytes } from 'crypto'
// import fs from 'fs'
import { join } from 'path'
import prompts from 'prompts'
let _currentPath = __dirname
const main = async (): Promise<void> => {
mylog(_currentPath)
const newpath = join(_currentPath, '..', 'keystores')
chdir(newpath)
const password = randomBytes(16).toString('hex')
const { alias } = await prompts({
name: 'alias',
type: 'text',
message: 'Enter app alias (ie. "edge-develop")',
validate: (v: string) => v.trim() !== ''
})
const { encryptionKey } = await prompts({
name: 'encryptionKey',
type: 'text',
message:
'Enter encryptionKey provided by Google Play under the option "Export and upload a key from Java keystore"',
validate: (v: string) => v.trim() !== ''
})
call(
`keytool -genkey -keystore ${alias}-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias ${alias} -dname "cn=Unknown, ou=Unknown, o=Unknown, c=Unknown" -storepass ${password} -keypass ${password}`
)
mylog(`Enter the following password at the prompts: ${password}`)
call(
`java -jar ~/bin/pepk.jar --keystore=${alias}-keystore.jks --alias=${alias} --output=${alias}.zip --include-cert --encryptionkey=${encryptionKey}`
)
// Uncomment out if creating a separate upload key
// call(
// `keytool -genkey -keystore ${alias}-upload-keystore.jks -keyalg RSA -keysize 2048 -validity 10000 -alias ${alias}-upload -dname "cn=Unknown, ou=Unknown, o=Unknown, c=Unknown" -storepass ${password} -keypass ${password}`
// )
// call(
// `keytool -export -rfc -keystore ${alias}-upload-keystore.jks -alias ${alias}-upload -file ${alias}-upload-cert.pem -storepass ${password} -keypass ${password}`
// )
mylog(
'Keystore created in keystores directory. Save the following keystore password. It cannot be recovered if lost.'
)
mylog('********************************')
mylog(password)
mylog('********************************')
}
const mylog = console.log
function call(cmdstring: string) {
// console.log('call: ' + cmdstring)
childProcess.execSync(cmdstring, {
encoding: 'utf8',
timeout: 3600000,
stdio: 'inherit',
cwd: _currentPath,
killSignal: 'SIGKILL'
})
}
function chdir(path: string) {
console.log('chdir: ' + path)
_currentPath = path
}
main().catch(e => {
console.log(e.message)
})