@konplit-services/common 1.0.7 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,153 @@
1
+ /// <reference types="node" />
2
+ import { env } from "process";
3
+ interface EmailTemplate {
4
+ forgot_password: string;
5
+ verify_account: string;
6
+ payee_invoice: string;
7
+ password_changed: string;
8
+ customer_receipt: string;
9
+ business_receipt: string;
10
+ account_verified: string;
11
+ chargeback_request: string;
12
+ chargeback_update: string;
13
+ chargeback_resolved: string;
14
+ refund_request: string;
15
+ refund_update: string;
16
+ refund_resolved: string;
17
+ invoice: string;
18
+ }
19
+ interface Interswitch {
20
+ merchant_id: string;
21
+ pay_item_id: string;
22
+ data_ref: string;
23
+ client_id: string;
24
+ secret_key: string;
25
+ access_token_url: string;
26
+ card_base_url: string;
27
+ exponent_key: string;
28
+ modulus_key: string;
29
+ visa_callback_url: string;
30
+ recurrent_client_id: string;
31
+ recurrent_secret_key: string;
32
+ }
33
+ interface MessageQueue {
34
+ sendMail: string;
35
+ Payment: string;
36
+ settlement: string;
37
+ transaction: string;
38
+ notification: string;
39
+ webhook: string;
40
+ subscription: string;
41
+ task_worker: string;
42
+ reminder: string;
43
+ }
44
+ interface EasyPay {
45
+ base_url: string;
46
+ clientId: string;
47
+ secret: string;
48
+ easyPayBillerID: string;
49
+ easyPayMandateRef: string;
50
+ easyPayClientCode: string;
51
+ }
52
+ interface PayPlus {
53
+ base_url: string;
54
+ clientId: string;
55
+ secret: string;
56
+ }
57
+ interface BVN {
58
+ bvnclientid: string;
59
+ bvnSecret: string;
60
+ valuePayRedirect: string;
61
+ bvnBaseUrl: string;
62
+ token_url: string;
63
+ }
64
+ interface NQRCode {
65
+ nqrBaseUrl: string;
66
+ nqrclientid: string;
67
+ nqrpluSecret: string;
68
+ nqrInstitutionId: string;
69
+ nqrApiKey: string;
70
+ }
71
+ interface NIBSS {
72
+ easyPay: EasyPay;
73
+ payplus: PayPlus;
74
+ nqrCode: NQRCode;
75
+ bvn: BVN;
76
+ resetURL: string;
77
+ }
78
+ declare class AppConfigs {
79
+ private env;
80
+ constructor(processEnv: typeof env);
81
+ getAppName(): string;
82
+ getJWTKEY(): string;
83
+ getDBURI(): string;
84
+ getNATSURI(): string;
85
+ getNATSPassword(): string;
86
+ getNATSUsername(): string;
87
+ getNodeMAilDetails(): {
88
+ host: string;
89
+ port: number;
90
+ password: string;
91
+ username: string;
92
+ };
93
+ getBcryptSalt(): number;
94
+ getJWTTokens(): {
95
+ refresh_in: string;
96
+ access_in: string;
97
+ };
98
+ getAPIPrivateKey(): string;
99
+ getRedisHost(): {
100
+ url: string;
101
+ host: string;
102
+ username: string;
103
+ port: string;
104
+ password: string;
105
+ };
106
+ getMessageQueueNames(): MessageQueue;
107
+ getEmailTemplates(): EmailTemplate;
108
+ getCloudinaryKey(): string;
109
+ getMailSenderKey(): string;
110
+ getCloudWatchDetails(): {
111
+ accessKey: string;
112
+ secretKey: string;
113
+ region: string;
114
+ groupName: string;
115
+ };
116
+ getAWSEncryptionDetails(): {
117
+ accessKey: string;
118
+ secretKey: string;
119
+ masterKey: string;
120
+ keyID: string;
121
+ };
122
+ getValuePayDetails(): {
123
+ visa_redirect_url: string;
124
+ visa_callback_url: string;
125
+ valuepay_ceo: string;
126
+ support_email: string;
127
+ support_phone: string;
128
+ ip_token: string;
129
+ invoice_url: string;
130
+ };
131
+ getNIBSSDetails(): NIBSS;
132
+ getFidelityDetails(): {
133
+ fbase_url: string;
134
+ fclient: string;
135
+ fsecret: string;
136
+ fdclient: string;
137
+ fdsecret: string;
138
+ account_mode: string;
139
+ };
140
+ getInterswitchDetails(): Interswitch;
141
+ getMonoDetails(): {
142
+ base_url: string;
143
+ public_key: string;
144
+ secret_key: string;
145
+ account_id: string;
146
+ webhook_secret: string;
147
+ };
148
+ getValue(key: string): string;
149
+ ensureValues(keys?: string[]): this;
150
+ getNODE_ENV(): string | undefined;
151
+ }
152
+ declare const appConfigs: AppConfigs;
153
+ export { appConfigs };
@@ -0,0 +1,514 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.appConfigs = void 0;
4
+ class AppConfigs {
5
+ constructor(processEnv) {
6
+ this.env = processEnv;
7
+ }
8
+ getAppName() {
9
+ if (!this.env.APP_NAME) {
10
+ throw new Error("APP_NAME is required");
11
+ }
12
+ return this.env.APP_NAME;
13
+ }
14
+ getJWTKEY() {
15
+ if (!this.env.JWT_KEY) {
16
+ throw new Error("JWT_KEY is required");
17
+ }
18
+ return this.env.JWT_KEY;
19
+ }
20
+ getDBURI() {
21
+ if (!this.env.Mongo_URI) {
22
+ throw new Error("Mongo_URI is required");
23
+ }
24
+ return this.env.Mongo_URI;
25
+ }
26
+ getNATSURI() {
27
+ if (!this.env.NATS_URI) {
28
+ throw new Error("NATS_URI is required");
29
+ }
30
+ return this.env.NATS_URI;
31
+ }
32
+ getNATSPassword() {
33
+ if (!this.env.NATS_PASSWORD) {
34
+ throw new Error("NATS_PASSWORD is required");
35
+ }
36
+ return this.env.NATS_PASSWORD;
37
+ }
38
+ getNATSUsername() {
39
+ if (!this.env.NATS_USERNAME) {
40
+ throw new Error("NATS_USERNAME is required");
41
+ }
42
+ return this.env.NATS_USERNAME;
43
+ }
44
+ getNodeMAilDetails() {
45
+ if (!this.env.MAIL_HOST) {
46
+ throw new Error("MAIL_HOST is required");
47
+ }
48
+ if (!this.env.MAIL_PORT) {
49
+ throw new Error("MAIL_PORT is required");
50
+ }
51
+ if (!this.env.MAIL_USERNAME) {
52
+ throw new Error("MAIL_USERNAME is required");
53
+ }
54
+ if (!this.env.MAIL_PASSWORD) {
55
+ throw new Error("MAIL_PASSWORD is required");
56
+ }
57
+ return {
58
+ host: this.env.MAIL_HOST,
59
+ port: parseInt(this.env.MAIL_PORT, 10),
60
+ password: this.env.MAIL_PASSWORD,
61
+ username: this.env.MAIL_USERNAME,
62
+ };
63
+ }
64
+ getBcryptSalt() {
65
+ if (!this.env.BCRYPT_SALT) {
66
+ throw new Error("BCRYPT_SALT is required");
67
+ }
68
+ return parseInt(this.env.BCRYPT_SALT, 10);
69
+ }
70
+ getJWTTokens() {
71
+ if (!this.env.REFRESH_TOKEN_IN) {
72
+ throw new Error("REFRESH_TOKEN_IN is required");
73
+ }
74
+ if (!this.env.ACCESS_TOKEN_IN) {
75
+ throw new Error("ACCESS_TOKEN_IN is required");
76
+ }
77
+ return {
78
+ refresh_in: this.env.REFRESH_TOKEN_IN,
79
+ access_in: this.env.ACCESS_TOKEN_IN,
80
+ };
81
+ }
82
+ getAPIPrivateKey() {
83
+ if (!this.env.API_PRIVATE_KEY) {
84
+ throw new Error("API_PRIVATE_KEY is required");
85
+ }
86
+ return this.env.API_PRIVATE_KEY;
87
+ }
88
+ getRedisHost() {
89
+ if (!this.env.REDIS_URL) {
90
+ throw new Error("REDIS_URL is required");
91
+ }
92
+ if (!this.env.REDIS_USERNAME) {
93
+ throw new Error("REDIS_USERNAME is required");
94
+ }
95
+ if (!this.env.REDIS_PASSWORD) {
96
+ throw new Error("REDIS_PASSWORD is required");
97
+ }
98
+ if (!this.env.REDIS_PORT) {
99
+ throw new Error("REDIS_PASSWORD is required");
100
+ }
101
+ return {
102
+ url: this.env.REDIS_URL,
103
+ host: this.env.REDIS_URL,
104
+ username: this.env.REDIS_USERNAME,
105
+ port: this.env.REDIS_PORT,
106
+ password: this.env.REDIS_PASSWORD,
107
+ };
108
+ }
109
+ getMessageQueueNames() {
110
+ if (!this.env.MESSAGEQUEUE_SEND_EMAIL) {
111
+ throw new Error("MESSAGEQUEUE_SEND_EMAIL is required");
112
+ }
113
+ if (!this.env.MESSAGEQUEUE_PAYMENT) {
114
+ throw new Error("MESSAGEQUEUE_PAYMENT is required");
115
+ }
116
+ if (!this.env.MESSAGEQUEUE_SETTLEMENT) {
117
+ throw new Error("MESSAGEQUEUE_SETTLEMENT is required");
118
+ }
119
+ if (!this.env.MESSAGEQUEUE_TRANSACTION) {
120
+ throw new Error("MESSAGEQUEUE_TRANSACTION is required");
121
+ }
122
+ if (!this.env.MESSAGEQUEUE_NOTIFICATION) {
123
+ throw new Error("MESSAGEQUEUE_NOTIFICATION is required");
124
+ }
125
+ if (!this.env.MESSAGEQUEUE_WEBHOOK) {
126
+ throw new Error("MESSAGEQUEUE_WEBHOOK is required");
127
+ }
128
+ if (!this.env.MESSAGEQUEUE_SUBSCRIPTION) {
129
+ throw new Error("MESSAGEQUEUE_SUBSCRIPTION is required");
130
+ }
131
+ if (!this.env.MESSAGEQUEUE_TASK_WORKER) {
132
+ throw new Error("MESSAGEQUEUE_TASK_WORKER is required");
133
+ }
134
+ if (!this.env.MESSAGEQUEUE_REMINDER) {
135
+ throw new Error("MESSAGEQUEUE_REMINDER is required");
136
+ }
137
+ return {
138
+ sendMail: this.env.MESSAGEQUEUE_SEND_EMAIL,
139
+ Payment: this.env.MESSAGEQUEUE_PAYMENT,
140
+ settlement: this.env.MESSAGEQUEUE_SETTLEMENT,
141
+ transaction: this.env.MESSAGEQUEUE_TRANSACTION,
142
+ notification: this.env.MESSAGEQUEUE_NOTIFICATION,
143
+ webhook: this.env.MESSAGEQUEUE_WEBHOOK,
144
+ subscription: this.env.MESSAGEQUEUE_SUBSCRIPTION,
145
+ task_worker: this.env.MESSAGEQUEUE_TASK_WORKER,
146
+ reminder: this.env.MESSAGEQUEUE_REMINDER,
147
+ };
148
+ }
149
+ getEmailTemplates() {
150
+ if (!this.env.EMAIL_TEMPLATE_FORGET_PASSWORD) {
151
+ throw new Error("EMAIL_TEMPLATE_FORGET_PASSWORD is required");
152
+ }
153
+ if (!this.env.EMAIL_TEMPLATE_VERIFY_ACCOUNT) {
154
+ throw new Error("EMAIL_TEMPLATE_VERIFY_ACCOUNT is required");
155
+ }
156
+ if (!this.env.EMAIL_TEMPLATE_PAYEE_INVOICE) {
157
+ throw new Error("EMAIL_TEMPLATE_PAYEE_INVOICE is required");
158
+ }
159
+ if (!this.env.EMAIL_TEMPLATE_PASSWORD_CHANGED) {
160
+ throw new Error("EMAIL_TEMPLATE_PASSWORD_CHANGED is required");
161
+ }
162
+ if (!this.env.EMAIL_TEMPLATE_CUSTOMER_RECEIPT) {
163
+ throw new Error("EMAIL_TEMPLATE_CUSTOMER_RECEIPT is required");
164
+ }
165
+ if (!this.env.EMAIL_TEMPLATE_BUSINESS_RECEIPT) {
166
+ throw new Error("EMAIL_TEMPLATE_BUSINESS_RECEIPT is required");
167
+ }
168
+ if (!this.env.EMAIL_TEMPLATE_ACCOUNT_VERIFIED) {
169
+ throw new Error("EMAIL_TEMPLATE_ACCOUNT_VERIFIED is required");
170
+ }
171
+ if (!this.env.EMAIL_TEMPLATE_CHARGEBACK_REQUEST) {
172
+ throw new Error("EMAIL_TEMPLATE_CHARGEBACK_REQUEST is required");
173
+ }
174
+ if (!this.env.EMAIL_TEMPLATE_CHARGEBACK_UPDATE) {
175
+ throw new Error("EMAIL_TEMPLATE_CHARGEBACK_UPDATE is required");
176
+ }
177
+ if (!this.env.EMAIL_TEMPLATE_CHARGEBACK_RESOLVED) {
178
+ throw new Error("EMAIL_TEMPLATE_CHARGEBACK_RESOLVED is required");
179
+ }
180
+ if (!this.env.EMAIL_TEMPLATE_REFUND_REQUEST) {
181
+ throw new Error("EMAIL_TEMPLATE_REFUND_REQUEST is required");
182
+ }
183
+ if (!this.env.EMAIL_TEMPLATE_REFUND_UPDATE) {
184
+ throw new Error("EMAIL_TEMPLATE_REFUND_UPDATE is required");
185
+ }
186
+ if (!this.env.EMAIL_TEMPLATE_REFUND_RESOLVED) {
187
+ throw new Error("EMAIL_TEMPLATE_REFUND_RESOLVED is required");
188
+ }
189
+ if (!this.env.EMAIL_TEMPLATE_INVOICE) {
190
+ throw new Error("EMAIL_TEMPLATE_INVOICE is required");
191
+ }
192
+ return {
193
+ forgot_password: this.env.EMAIL_TEMPLATE_FORGET_PASSWORD,
194
+ verify_account: this.env.EMAIL_TEMPLATE_VERIFY_ACCOUNT,
195
+ payee_invoice: this.env.EMAIL_TEMPLATE_PAYEE_INVOICE,
196
+ password_changed: this.env.EMAIL_TEMPLATE_PASSWORD_CHANGED,
197
+ customer_receipt: this.env.EMAIL_TEMPLATE_CUSTOMER_RECEIPT,
198
+ business_receipt: this.env.EMAIL_TEMPLATE_BUSINESS_RECEIPT,
199
+ account_verified: this.env.EMAIL_TEMPLATE_ACCOUNT_VERIFIED,
200
+ chargeback_request: this.env.EMAIL_TEMPLATE_CHARGEBACK_REQUEST,
201
+ chargeback_update: this.env.EMAIL_TEMPLATE_CHARGEBACK_UPDATE,
202
+ chargeback_resolved: this.env.EMAIL_TEMPLATE_CHARGEBACK_RESOLVED,
203
+ refund_request: this.env.EMAIL_TEMPLATE_REFUND_REQUEST,
204
+ refund_update: this.env.EMAIL_TEMPLATE_REFUND_UPDATE,
205
+ refund_resolved: this.env.EMAIL_TEMPLATE_REFUND_RESOLVED,
206
+ invoice: this.env.EMAIL_TEMPLATE_INVOICE,
207
+ };
208
+ }
209
+ getCloudinaryKey() {
210
+ if (!this.env.CLOUDINARY_KEY) {
211
+ throw new Error("CLOUDINARY_KEY is required");
212
+ }
213
+ return this.env.CLOUDINARY_KEY;
214
+ }
215
+ getMailSenderKey() {
216
+ if (!this.env.MAIL_SENDER_KEY) {
217
+ throw new Error("MAIL_SENDER_KEY is required");
218
+ }
219
+ return this.env.MAIL_SENDER_KEY;
220
+ }
221
+ getCloudWatchDetails() {
222
+ if (!this.env.CLOUDWATCH_ACCESSKEY) {
223
+ throw new Error("CLOUDWATCH_ACCESSKEY is required");
224
+ }
225
+ if (!this.env.CLOUDWATCH_SECRETKEY) {
226
+ throw new Error("CLOUDWATCH_SECRETKEY is required");
227
+ }
228
+ if (!this.env.CLOUDWATCH_REGION) {
229
+ throw new Error("CLOUDWATCH_REGION is required");
230
+ }
231
+ if (!this.env.CLOUDWATCH_GROUPNAME) {
232
+ throw new Error("CLOUDWATCH_GROUPNAME is required");
233
+ }
234
+ return {
235
+ accessKey: this.env.CLOUDWATCH_ACCESSKEY,
236
+ secretKey: this.env.CLOUDWATCH_SECRETKEY,
237
+ region: this.env.CLOUDWATCH_REGION,
238
+ groupName: this.env.CLOUDWATCH_GROUPNAME,
239
+ };
240
+ }
241
+ getAWSEncryptionDetails() {
242
+ if (!this.env.AWS_ACCESSKEY) {
243
+ throw new Error("AWS_ACCESSKEY is required");
244
+ }
245
+ if (!this.env.AWS_SECRETKEY) {
246
+ throw new Error("AWS_SECRETKEY is required");
247
+ }
248
+ if (!this.env.AWS_MASTERKEY) {
249
+ throw new Error("AWS_MASTERKEY is required");
250
+ }
251
+ if (!this.env.AWS_KEYID) {
252
+ throw new Error("AWS_KEYID is required");
253
+ }
254
+ return {
255
+ accessKey: this.env.AWS_ACCESSKEY,
256
+ secretKey: this.env.AWS_SECRETKEY,
257
+ masterKey: this.env.AWS_MASTERKEY,
258
+ keyID: this.env.AWS_KEYID,
259
+ };
260
+ }
261
+ getValuePayDetails() {
262
+ if (!this.env.VALUEPAY_VISA_REDIRECT_URL) {
263
+ throw new Error("VALUEPAY_VISA_REDIRECT_URL is required");
264
+ }
265
+ if (!this.env.VALUEPAY_VISA_CALLBACK_URL) {
266
+ throw new Error("VALUEPAY_VISA_CALLBACK_URL is required");
267
+ }
268
+ if (!this.env.VALUEPAY_CEO) {
269
+ throw new Error("VALUEPAY_CEO is required");
270
+ }
271
+ if (!this.env.VALUEPAY_SUPPORT_EMAIL) {
272
+ throw new Error("VALUEPAY_SUPPORT_EMAIL is required");
273
+ }
274
+ if (!this.env.VALUEPAY_SUPPORT_PHONE) {
275
+ throw new Error("VALUEPAY_SUPPORT_PHONE is required");
276
+ }
277
+ if (!this.env.VALUEPAY_IP_TOKEN) {
278
+ throw new Error("VALUEPAY_IP_TOKEN is required");
279
+ }
280
+ if (!this.env.VALUEPAY_INVOICE_URL) {
281
+ throw new Error("VALUEPAY_INVOICE_URL is required");
282
+ }
283
+ return {
284
+ visa_redirect_url: this.env.VALUEPAY_VISA_REDIRECT_URL,
285
+ visa_callback_url: this.env.VALUEPAY_VISA_CALLBACK_URL,
286
+ valuepay_ceo: this.env.VALUEPAY_CEO,
287
+ support_email: this.env.VALUEPAY_SUPPORT_EMAIL,
288
+ support_phone: this.env.VALUEPAY_SUPPORT_PHONE,
289
+ ip_token: this.env.VALUEPAY_IP_TOKEN,
290
+ invoice_url: this.env.VALUEPAY_INVOICE_URL,
291
+ };
292
+ }
293
+ getNIBSSDetails() {
294
+ if (!this.env.NIBSS_EASYPAY_BASE_URL) {
295
+ throw new Error("NIBSS_EASYPAY_BASE_URL is required");
296
+ }
297
+ if (!this.env.NIBSS_EASYPAY_CLIENT_ID) {
298
+ throw new Error("NIBSS_EASYPAY_CLIENT_ID is required");
299
+ }
300
+ if (!this.env.NIBSS_EASYPAY_SECRET) {
301
+ throw new Error("NIBSS_EASYPAY_SECRET is required");
302
+ }
303
+ if (!this.env.NIBSS_EASYPAY_BILLER_ID) {
304
+ throw new Error("NIBSS_EASYPAY_BILLER_ID is required");
305
+ }
306
+ if (!this.env.NIBSS_EASYPAY_MANDATE_REF) {
307
+ throw new Error("NIBSS_EASYPAY_MANDATE_REF is required");
308
+ }
309
+ if (!this.env.NIBSS_EASYPAY_CLIENT_CODE) {
310
+ throw new Error("NIBSS_EASYPAY_CLIENT_CODE is required");
311
+ }
312
+ if (!this.env.NIBSS_PAYPLUS_BASE_URL) {
313
+ throw new Error("NIBSS_PAYPLUS_BASE_URL is required");
314
+ }
315
+ if (!this.env.NIBSS_PAYPLUS_CLIENT_ID) {
316
+ throw new Error("NIBSS_PAYPLUS_CLIENT_ID is required");
317
+ }
318
+ if (!this.env.NIBSS_PAYPLUS_SECRET) {
319
+ throw new Error("NIBSS_PAYPLUS_SECRET is required");
320
+ }
321
+ if (!this.env.NIBSS_NQRCODE_BASE_URL) {
322
+ throw new Error("NIBSS_NQRCODE_BASE_URL is required");
323
+ }
324
+ if (!this.env.NIBSS_NQRCODE_CLIENT_ID) {
325
+ throw new Error("NIBSS_NQRCODE_CLIENT_ID is required");
326
+ }
327
+ if (!this.env.NIBSS_NQRCODE_SECRET) {
328
+ throw new Error("NIBSS_NQRCODE_SECRET is required");
329
+ }
330
+ if (!this.env.NIBSS_NQRCODE_INSTITUTION_ID) {
331
+ throw new Error("NIBSS_NQRCODE_INSTITUTION_ID is required");
332
+ }
333
+ if (!this.env.NIBSS_NQRCODE_API_KEY) {
334
+ throw new Error("NIBSS_NQRCODE_API_KEY is required");
335
+ }
336
+ if (!this.env.NIBSS_BVN_CLIENT_ID) {
337
+ throw new Error("NIBSS_BVN_CLIENT_ID is required");
338
+ }
339
+ if (!this.env.NIBSS_BVN_SECRET) {
340
+ throw new Error("NIBSS_BVN_SECRET is required");
341
+ }
342
+ if (!this.env.NIBSS_BVN_VALUEPART_REDIRECT) {
343
+ throw new Error("NIBSS_BVN_VALUEPART_REDIRECT is required");
344
+ }
345
+ if (!this.env.NIBSS_BVN_BASE_URL) {
346
+ throw new Error("NIBSS_BVN_BASE_URL is required");
347
+ }
348
+ if (!this.env.NIBSS_BVN_TOKEN_URL) {
349
+ throw new Error("NIBSS_BVN_TOKEN_URL is required");
350
+ }
351
+ if (!this.env.NIBSS_BVN_RESET_URL) {
352
+ throw new Error("NIBSS_BVN_RESET_URL is required");
353
+ }
354
+ return {
355
+ easyPay: {
356
+ base_url: this.env.NIBSS_EASYPAY_BASE_URL,
357
+ clientId: this.env.NIBSS_EASYPAY_CLIENT_ID,
358
+ secret: this.env.NIBSS_EASYPAY_SECRET,
359
+ easyPayBillerID: this.env.NIBSS_EASYPAY_BILLER_ID,
360
+ easyPayMandateRef: this.env.NIBSS_EASYPAY_MANDATE_REF,
361
+ easyPayClientCode: this.env.NIBSS_EASYPAY_CLIENT_CODE,
362
+ },
363
+ payplus: {
364
+ base_url: this.env.NIBSS_PAYPLUS_BASE_URL,
365
+ clientId: this.env.NIBSS_PAYPLUS_CLIENT_ID,
366
+ secret: this.env.NIBSS_PAYPLUS_SECRET,
367
+ },
368
+ nqrCode: {
369
+ nqrBaseUrl: this.env.NIBSS_NQRCODE_BASE_URL,
370
+ nqrclientid: this.env.NIBSS_NQRCODE_CLIENT_ID,
371
+ nqrpluSecret: this.env.NIBSS_NQRCODE_SECRET,
372
+ nqrInstitutionId: this.env.NIBSS_NQRCODE_INSTITUTION_ID,
373
+ nqrApiKey: this.env.NIBSS_NQRCODE_API_KEY,
374
+ },
375
+ bvn: {
376
+ bvnclientid: this.env.NIBSS_BVN_CLIENT_ID,
377
+ bvnSecret: this.env.NIBSS_BVN_SECRET,
378
+ valuePayRedirect: this.env.NIBSS_BVN_VALUEPART_REDIRECT,
379
+ bvnBaseUrl: this.env.NIBSS_BVN_BASE_URL,
380
+ token_url: this.env.NIBSS_BVN_TOKEN_URL,
381
+ },
382
+ resetURL: this.env.NIBSS_BVN_RESET_URL,
383
+ };
384
+ }
385
+ // Fidelity
386
+ getFidelityDetails() {
387
+ // fidelity
388
+ if (!this.env.FIDELITY_FBASE_URL) {
389
+ throw new Error("FIDELITY_FBASE_URL is required");
390
+ }
391
+ if (!this.env.FIDELITY_FCLIENT) {
392
+ throw new Error("FIDELITY_FCLIENT is required");
393
+ }
394
+ if (!this.env.FIDELITY_FSECRET) {
395
+ throw new Error("FIDELITY_FSECRET is required");
396
+ }
397
+ if (!this.env.FIDELITY_DCLIENT) {
398
+ throw new Error("FIDELITY_DCLIENT is required");
399
+ }
400
+ if (!this.env.FIDELITY_DSECRET) {
401
+ throw new Error("FIDELITY_DSECRET is required");
402
+ }
403
+ if (!this.env.FIDELITY_ACCOUNT_MODE) {
404
+ throw new Error("FIDELITY_ACCOUNT_MODE is required");
405
+ }
406
+ return {
407
+ fbase_url: this.env.FIDELITY_FBASE_URL,
408
+ fclient: this.env.FIDELITY_FCLIENT,
409
+ fsecret: this.env.FIDELITY_FSECRET,
410
+ fdclient: this.env.FIDELITY_DCLIENT,
411
+ fdsecret: this.env.FIDELITY_DSECRET,
412
+ account_mode: this.env.FIDELITY_ACCOUNT_MODE,
413
+ };
414
+ }
415
+ // Interswitch
416
+ getInterswitchDetails() {
417
+ // Interswitch
418
+ if (!this.env.INTERSWITCH_MERCHANT_ID) {
419
+ throw new Error("INTERSWITCH_MERCHANT_ID is required");
420
+ }
421
+ if (!this.env.INTERSWITCH_PAY_ITEM_ID) {
422
+ throw new Error("INTERSWITCH_PAY_ITEM_ID is required");
423
+ }
424
+ if (!this.env.INTERSWITCH_DATA_REF) {
425
+ throw new Error("INTERSWITCH_DATA_REF is required");
426
+ }
427
+ if (!this.env.INTERSWITCH_CLIENT_ID) {
428
+ throw new Error("INTERSWITCH_CLIENT_ID is required");
429
+ }
430
+ if (!this.env.INTERSWITCH_SECRET_KEY) {
431
+ throw new Error("INTERSWITCH_SECRET_KEY is required");
432
+ }
433
+ if (!this.env.INTERSWITCH_ACCESS_TOKEN_URL) {
434
+ throw new Error("INTERSWITCH_ACCESS_TOKEN_URL is required");
435
+ }
436
+ if (!this.env.INTERSWITCH_CARD_BASE_URL) {
437
+ throw new Error("INTERSWITCH_CARD_BASE_URL is required");
438
+ }
439
+ if (!this.env.INTERSWITCH_EXPONENT_KEY) {
440
+ throw new Error("INTERSWITCH_EXPONENT_KEY is required");
441
+ }
442
+ if (!this.env.INTERSWITCH_MODulus_KEY) {
443
+ throw new Error("INTERSWITCH_MODulus_KEY is required");
444
+ }
445
+ if (!this.env.INTERSWITCH_VISA_CALLBACK_URL) {
446
+ throw new Error("INTERSWITCH_VISA_CALLBACK_URL is required");
447
+ }
448
+ if (!this.env.INTERSWITCH_RECURRENT_CLIENT_ID) {
449
+ throw new Error("INTERSWITCH_RECURRENT_CLIENT_ID is required");
450
+ }
451
+ if (!this.env.INTERSWITCH_RECURRENT_SECRET_KEY) {
452
+ throw new Error("INTERSWITCH_RECURRENT_SECRET_KEY is required");
453
+ }
454
+ return {
455
+ merchant_id: this.env.INTERSWITCH_MERCHANT_ID,
456
+ pay_item_id: this.env.INTERSWITCH_PAY_ITEM_ID,
457
+ data_ref: this.env.INTERSWITCH_DATA_REF,
458
+ client_id: this.env.INTERSWITCH_CLIENT_ID,
459
+ secret_key: this.env.INTERSWITCH_SECRET_KEY,
460
+ access_token_url: this.env.INTERSWITCH_ACCESS_TOKEN_URL,
461
+ card_base_url: this.env.INTERSWITCH_CARD_BASE_URL,
462
+ exponent_key: this.env.INTERSWITCH_EXPONENT_KEY,
463
+ modulus_key: this.env.INTERSWITCH_MODulus_KEY,
464
+ visa_callback_url: this.env.INTERSWITCH_VISA_CALLBACK_URL,
465
+ recurrent_client_id: this.env.INTERSWITCH_RECURRENT_CLIENT_ID,
466
+ recurrent_secret_key: this.env.INTERSWITCH_RECURRENT_SECRET_KEY,
467
+ };
468
+ }
469
+ // MONO MOBILE MONEY
470
+ getMonoDetails() {
471
+ if (!this.env.MONO_BASE_URL) {
472
+ throw new Error("MONO_BASE_URL is required");
473
+ }
474
+ if (!this.env.MONO_PUBLIC_KEY) {
475
+ throw new Error("MONO_PUBLIC_KEY is required");
476
+ }
477
+ if (!this.env.MONO_SECRET_KEY) {
478
+ throw new Error("MONO_SECRET_KEY is required");
479
+ }
480
+ if (!this.env.MONO_ACCOUNT_ID) {
481
+ throw new Error("MONO_ACCOUNT_ID is required");
482
+ }
483
+ if (!this.env.MONO_WEBHOOK_SECRET) {
484
+ throw new Error("MONO_WEBHOOK_SECRET is required");
485
+ }
486
+ return {
487
+ base_url: this.env.MONO_BASE_URL,
488
+ public_key: this.env.MONO_PUBLIC_KEY,
489
+ secret_key: this.env.MONO_SECRET_KEY,
490
+ account_id: this.env.MONO_ACCOUNT_ID,
491
+ webhook_secret: this.env.MONO_WEBHOOK_SECRET,
492
+ };
493
+ }
494
+ getValue(key) {
495
+ const value = this.env[key];
496
+ if (!value) {
497
+ throw new Error(`environment variable - missing env.${key}`);
498
+ }
499
+ return value;
500
+ }
501
+ ensureValues(keys = []) {
502
+ if (keys.length === 0) {
503
+ throw new Error("Please make sure all required variables are present");
504
+ }
505
+ keys.forEach((k) => this.getValue(k));
506
+ return this;
507
+ }
508
+ getNODE_ENV() {
509
+ return this.env.NODE_ENV;
510
+ }
511
+ }
512
+ // make sure all keys are available on startup
513
+ const appConfigs = new AppConfigs(process.env);
514
+ exports.appConfigs = appConfigs;
package/build/index.d.ts CHANGED
@@ -9,3 +9,4 @@ export * from "./Schema/CFLESCHEMA";
9
9
  export * from "./services";
10
10
  export * from "./log-activities/actions";
11
11
  export * from "./swagger/config";
12
+ export * from "./app.configs";
package/build/index.js CHANGED
@@ -36,3 +36,5 @@ __exportStar(require("./services"), exports);
36
36
  __exportStar(require("./log-activities/actions"), exports);
37
37
  //Swagger docs
38
38
  __exportStar(require("./swagger/config"), exports);
39
+ //environment variables
40
+ __exportStar(require("./app.configs"), exports);
@@ -10,6 +10,7 @@ const isJwt = (token) => {
10
10
  if (parts.length !== 3) {
11
11
  return false;
12
12
  }
13
+ // jwt parts for testting
13
14
  const [header, payload, signature] = parts;
14
15
  if (!isBase64Url(header) ||
15
16
  !isBase64Url(payload) ||
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konplit-services/common",
3
- "version": "1.0.7",
3
+ "version": "1.0.10",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",