-
Notifications
You must be signed in to change notification settings - Fork 12
/
server.config.js
437 lines (433 loc) · 10 KB
/
server.config.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
import networks from './networks'
import ContractsAddress from '@gooddollar/goodcontracts/releases/deployment.json'
import { version } from '../../package.json'
const envFile = process.env.NODE_ENV === 'test' ? `.env.test` : '.env'
require('dotenv').config({ path: envFile })
const convict = require('convict')
// Define a schema
const conf = convict({
env: {
doc: 'The applicaton environment.',
format: ['production', 'development', 'staging', 'test'],
default: 'development',
arg: 'nodeEnv',
env: 'NODE_ENV'
},
version: {
doc: 'The applicaton version from package.json.',
format: String,
default: version,
env: 'VERSION'
},
logLevel: {
doc: 'Log level',
format: ['error', 'warn', 'info', 'debug', 'silent'],
default: 'debug',
env: 'LOG_LEVEL'
},
ip: {
doc: 'The IP address to bind.',
format: 'ipaddress',
default: '127.0.0.1',
env: 'IP_ADDRESS'
},
port: {
doc: 'The port to bind.',
format: 'port',
default: 3003,
env: 'PORT'
},
gundbPassword: {
doc: 'The password to gundb',
format: '*',
default: '',
env: 'GUNDB_PASS'
},
gundbPeers: {
doc: 'superpeer to connect with for public db as a client if server mode is off',
format: Array,
default: undefined,
env: 'GUNDB_PEERS'
},
gundbServerMode: {
doc: 'should we start as a superpeer',
format: Boolean,
default: true,
env: 'GUNDB_SERVERMODE'
},
jwtPassword: {
doc: 'The password to sign the JWT token with',
format: '*',
default: undefined,
env: 'JWT_PASS'
},
mnemonic: {
doc: 'Wallet mnemonic',
format: String,
env: 'MNEMONIC',
default: null
},
numberOfAdminWalletAccounts: {
doc: 'Number of admin wallet accounts',
format: Number,
env: 'NUMBER_OF_ADMIN_WALLET_ACCOUNTS',
default: 10
},
adminMinBalance: {
doc: 'min balance in GWEIs for valid admin addresses',
format: Number,
env: 'ADMIN_MIN_BALANCE',
default: 1000000
},
mongoQueueMaxLockTime: {
doc: 'Max lock time for one each in mongo queue in seconds',
format: Number,
env: 'MONGO_QUEUE_MAX_LOCK_TIME',
default: 30
},
privateKey: {
doc: 'Wallet private key',
format: '*',
env: 'PRIVATE_KEY',
default: undefined
},
infuraKey: {
doc: 'Infura API Key',
format: '*',
env: 'INFURA_API',
default: ''
},
ethereum: {
network_id: 42,
httpWeb3Provider: 'https://kovan.infura.io/v3/',
websocketWeb3Provider: 'wss://kovan.infura.io/ws',
web3Transport: 'HttpProvider'
},
network: {
doc: 'The blockchain network to connect to',
format: [
'kovan',
'mainnet',
'rinkbey',
'ropsten',
'truffle',
'ganache',
'fuse',
'production',
'develop',
'staging',
'etoro'
],
default: 'develop',
env: 'NETWORK'
},
twilioAuthID: {
doc: "Twilio's authorization ID",
format: '*',
env: 'TWILIO_AUTH_ID',
default: ''
},
twilioAuthToken: {
doc: "Twilio's authorization Token",
format: '*',
env: 'TWILIO_AUTH_TOKEN',
default: ''
},
twilioPhoneNumber: {
doc: "Plivo's Phone Number",
format: '*',
env: 'TWILIO_PHONE_NUMBER',
default: ''
},
otpDigits: {
doc: 'Amount of digits for the OTP',
format: '*',
env: 'OTP_DIGITS',
default: '6'
},
otpTtlMinutes: {
doc: 'Time, in minutes, for the OTP to be valid',
format: '*',
env: 'OTP_TTL_MINUTES',
default: '60'
},
sendGrid: {
apiKey: {
doc: 'Sendgrid API KEY',
format: '*',
env: 'SENDGRID_API_KEY',
default: 'YOUR_API_KEY'
},
templates: {
recoveryInstructions: {
doc: 'Sendgrid Transactional Template ID',
format: '*',
env: 'SENDGRID_TEMPLATE_RECOVERY_INSTRUCTIONS',
default: ''
},
emailConfirmation: {
doc: 'Sendgrid Transactional Template ID',
format: '*',
env: 'SENDGRID_TEMPLATE_EMAIL_CONFIRMATION',
default: ''
}
}
},
mongodb: {
uri: {
doc: 'Mongo DB URI',
format: '*',
env: 'MONGO_DB_URI',
default: ''
}
},
noReplyEmail: {
doc: 'no-reply GD email',
format: '*',
env: 'NO_REPLY_GD_EMAIL',
default: 'no-reply@gooddollar.com'
},
walletUrl: {
doc: 'wallet URL',
format: '*',
env: 'WALLET_URL',
default: 'WALLET_URL'
},
mauticURL: {
doc: 'mautic URL',
format: '*',
env: 'MAUTIC_URL',
default: 'WALLET_URL'
},
mauticToken: {
doc: 'mautic token',
format: '*',
env: 'MAUTIC_TOKEN',
default: 'MAUTIC_TOKEN'
},
mauticBasicToken: {
doc: 'mautic basic auth token',
format: String,
env: 'MAUTIC_BASIC_TOKEN',
default: null
},
mauticRecoveryEmailId: {
doc: 'id of email template',
format: '*',
env: 'MAUTIC_RECOVERY_ID',
default: '9'
},
mauticmagicLinkEmailId: {
doc: 'id of email template',
format: '*',
env: 'MAUTIC_MAGICLINK_ID',
default: '30'
},
mauticVerifyEmailId: {
doc: 'id of email template',
format: '*',
env: 'MAUTIC_VERIFY_ID',
default: '31'
},
mauticClaimQueueSegmentId: {
doc: 'id of segment',
format: '*',
env: 'MAUTIC_CLAIM_QUEUE_SEG_ID',
default: '52'
},
mauticClaimQueueApprovedSegmentId: {
doc: 'id of segment',
format: '*',
env: 'MAUTIC_CLAIM_QUEUE_APPROVED_SEG_ID',
default: '53'
},
mauticClaimQueueWhitelistedSegmentId: {
doc: 'id of segment',
format: '*',
env: 'MAUTIC_CLAIM_QUEUE_APPROVED_SEG_ID',
default: '54'
},
zoomMinimalMatchLevel: {
doc: 'Minimal FaceTec Match Level threshold to mark enrollment as duplicate',
format: Number,
env: 'ZOOM_MINIMAL_MATCHLEVEL',
default: 1
},
zoomServerBaseUrl: {
doc: 'FaceTec Managed Testing API URL',
format: '*',
env: 'ZOOM_SERVER_BASEURL',
default: 'https://api.zoomauth.com/api/v2/biometrics'
},
zoomLicenseKey: {
doc: 'Zoom (Face Recognition / Liveness Test API) License key',
format: '*',
env: 'ZOOM_LICENSE_KEY',
default: ''
},
gunPrivateS3: {
key: {
format: '*',
default: undefined
},
secret: {
format: '*',
default: undefined
},
bucket: {
format: '*',
default: undefined
}
},
gunPublicS3: {
key: {
format: '*',
default: undefined
},
secret: {
format: '*',
default: undefined
},
bucket: {
format: '*',
default: undefined
}
},
allowDuplicateUserData: {
doc: 'Allow to register with existing mobile/email',
format: Boolean,
env: 'ALLOW_DUPLICATE_USER_DATA',
default: false
},
skipEmailVerification: {
doc: 'Allow to register with unverified email',
format: Boolean,
env: 'SKIP_EMAIL_VERIFICATION',
default: false
},
keepFaceVerificationRecords: {
doc:
'Time interval (in hours) to store face verification records after user deletes his account.' +
' Set to 0 or -1 to remove face verification records immediately',
format: Number,
env: 'KEEP_FACE_VERIFICATION_RECORDS',
default: 24
},
enableMongoLock: {
doc: 'Enable or disable transaction locks for mongo',
format: Boolean,
env: 'ENABLE_MONGO_LOCK',
default: false
},
disableFaceVerification: {
doc: 'Whitelist user once they register, returns already enrolled with no Zoom API interaction',
format: Boolean,
env: 'DISABLE_FACE_VERIFICATION',
default: false
},
rollbarToken: {
doc: 'access token for rollbar logging',
format: '*',
env: 'ROLLBAR_TOKEN',
default: undefined
},
secure_key: {
doc: 'Secure key word used to create secure hash by which server can communicate with web3',
format: String,
env: 'SECURE_KEY',
default: null
},
fuse: {
doc: 'Main url for fuse api',
format: 'url',
env: 'FUSE_API',
default: 'https://explorer.fuse.io'
},
web3SiteUrl: {
doc: 'Web3 site url',
format: 'url',
env: 'WEB3_SITE_URL',
default: 'https://w3.gooddollar.org'
},
marketPassword: {
doc: 'password for market jwt',
format: String,
env: 'MARKET_PASSWORD',
default: null
},
rateLimitMinutes: {
doc: 'Amount of minutes used for request rate limiter',
format: '*',
env: 'REQUEST_RATE_LIMIT_MINUTES',
default: 1
},
rateLimitRequestsCount: {
doc: 'Max number of requests count per rateLimitMinutes',
format: '*',
env: 'REQUEST_RATE_LIMIT_COUNT',
default: 3
},
isEtoro: {
doc: 'eToro GoodMarket',
format: Boolean,
env: 'ETORO',
default: false
},
hanukaStartDate: {
doc: 'Hanuka Start Day',
format: '*',
env: 'HANUKA_START_DATE',
default: undefined
},
hanukaEndDate: {
doc: 'Hanuka End Day',
format: '*',
env: 'HANUKA_END_DATE',
default: undefined
},
autoApproveW3: {
doc: 'should new user be automatically approved on w3',
format: '*',
env: 'AUTO_APPROVE_W3',
default: true
},
enableInvites: {
doc: 'enable w3',
format: '*',
env: 'ENABLE_INVITES',
default: true
},
topAdminsOnStartup: {
doc: 'call topAdmins in adminwallet smart contract',
format: '*',
env: 'TOP_ADMINS',
default: false
},
claimQueueAllowed: {
doc: 'From how many users start to enqueue',
format: Number,
env: 'CLAIM_QUEUE_ALLOWED',
default: 0
}
})
// Load environment dependent configuration
const network = conf.get('network')
const networkId = ContractsAddress[network].networkId
conf.set('ethereum', networks[networkId])
//parse S3 details for gundb in format of key,secret,bucket
const privateS3 = process.env.GUN_PRIVATE_S3
if (privateS3) {
let s3Vals = privateS3.split(',')
let s3Conf = { key: s3Vals[0], secret: s3Vals[1], bucket: s3Vals[2] }
conf.set('gunPrivateS3', s3Conf)
}
const publicS3 = process.env.GUN_PUBLIC_S3
if (publicS3) {
let s3Vals = publicS3.split(',')
let s3Conf = { key: s3Vals[0], secret: s3Vals[1], bucket: s3Vals[2] }
conf.set('gunPublicS3', s3Conf)
}
// Perform validation
conf.validate({ allowed: 'strict' })
// eslint-disable-next-line
export default conf.getProperties()