-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.rollup.config.ts
62 lines (56 loc) · 1.62 KB
/
vite.rollup.config.ts
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
import Hashids from 'hashids'
import { obfuscator } from 'rollup-obfuscator'
import replace from '@rollup/plugin-replace'
const config: any = {}
config.obfuscator = {
compact: true,
controlFlowFlattening: false,
deadCodeInjection: false,
debugProtection: false,
debugProtectionInterval: 0,
disableConsoleOutput: false,
identifierNamesGenerator: 'mangled-shuffled',
log: false,
numbersToExpressions: false,
renameGlobals: false,
selfDefending: false,
simplify: true,
splitStrings: false,
stringArray: true,
stringArrayCallsTransform: false,
stringArrayCallsTransformThreshold: 0.5,
stringArrayEncoding: [],
stringArrayIndexShift: true,
stringArrayRotate: true,
stringArrayShuffle: true,
stringArrayWrappersCount: 1,
stringArrayWrappersChainedCalls: true,
stringArrayWrappersParametersMaxCount: 2,
stringArrayWrappersType: 'variable',
stringArrayThreshold: 0.75,
unicodeEscapeSequence: false,
}
// List all sensitive strings from production code
const keywords = [
'ENCRYPTED_EXTENSION_ID',
'ENCRYPTION_KEY',
'MAINNET_RPC_URL',
'TESTNET_RPC_URL',
'PRICE_URL',
'BALANCE_TTL',
'PRICE_TTL',
'TX_CONF_ETA',
]
config.replace = {
preventAssignment: true,
values: {},
}
var hashids = new Hashids('Pocket')
Object.entries(keywords).forEach(([index, keyword]) => {
config.replace.values[keyword] = 'e' + hashids.encode(1e3 + index)
config.replace.values[`_${keyword}`] = '_e' + hashids.encode(1e3 + index)
})
const rollupPlugins = []
rollupPlugins.push(replace(config.replace))
rollupPlugins.push(obfuscator(config.obfuscator))
export { rollupPlugins }