@konplit-services/common 1.7.3 → 1.7.5
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.
package/build/app.configs.d.ts
CHANGED
|
@@ -310,6 +310,16 @@ declare class AppConfigs {
|
|
|
310
310
|
secretKey: string;
|
|
311
311
|
sender: string;
|
|
312
312
|
};
|
|
313
|
+
ebulk: {
|
|
314
|
+
apiKey: string;
|
|
315
|
+
sender: string;
|
|
316
|
+
username: string;
|
|
317
|
+
};
|
|
318
|
+
};
|
|
319
|
+
getEbulkSMSKey(): {
|
|
320
|
+
apiKey: string;
|
|
321
|
+
sender: string;
|
|
322
|
+
username: string;
|
|
313
323
|
};
|
|
314
324
|
getTermiiSMSKey(): {
|
|
315
325
|
apiKey: string;
|
package/build/app.configs.js
CHANGED
|
@@ -457,7 +457,24 @@ class AppConfigs {
|
|
|
457
457
|
}
|
|
458
458
|
return {
|
|
459
459
|
vendor: this.env.SMS_VENDOR,
|
|
460
|
-
termii: this.getTermiiSMSKey()
|
|
460
|
+
termii: this.getTermiiSMSKey(),
|
|
461
|
+
ebulk: this.getEbulkSMSKey()
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
getEbulkSMSKey() {
|
|
465
|
+
if (!this.env.EBULK_API_KEY) {
|
|
466
|
+
throw new Error("EBULK_API_KEY is required");
|
|
467
|
+
}
|
|
468
|
+
if (!this.env.EBULK_SENDER_ID) {
|
|
469
|
+
throw new Error("EBULK_SENDER_ID is required");
|
|
470
|
+
}
|
|
471
|
+
if (!this.env.EBULK_USERNAME) {
|
|
472
|
+
throw new Error("EBULK_USERNAME is required");
|
|
473
|
+
}
|
|
474
|
+
return {
|
|
475
|
+
apiKey: this.env.EBULK_API_KEY,
|
|
476
|
+
sender: this.env.EBULK_SENDER_ID,
|
|
477
|
+
username: this.env.EBULK_USERNAME,
|
|
461
478
|
};
|
|
462
479
|
}
|
|
463
480
|
getTermiiSMSKey() {
|
package/build/helper/index.d.ts
CHANGED
package/build/helper/index.js
CHANGED
|
@@ -69,3 +69,5 @@ __exportStar(require("./bank-account-types"), exports);
|
|
|
69
69
|
__exportStar(require("./subaccount"), exports);
|
|
70
70
|
__exportStar(require("./remove-query-properties"), exports);
|
|
71
71
|
__exportStar(require("./ussd"), exports);
|
|
72
|
+
//validation
|
|
73
|
+
__exportStar(require("./phone-validator"), exports);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const validatePhoneNumber: (phone: string, region?: string) => {
|
|
2
|
+
valid: boolean;
|
|
3
|
+
formatted: null;
|
|
4
|
+
error: string;
|
|
5
|
+
national?: undefined;
|
|
6
|
+
international?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
valid: boolean;
|
|
9
|
+
formatted: string;
|
|
10
|
+
national: string;
|
|
11
|
+
international: string;
|
|
12
|
+
error?: undefined;
|
|
13
|
+
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validatePhoneNumber = void 0;
|
|
4
|
+
const google_libphonenumber_1 = require("google-libphonenumber");
|
|
5
|
+
const phoneUtil = google_libphonenumber_1.PhoneNumberUtil.getInstance();
|
|
6
|
+
const validatePhoneNumber = (phone, region = 'NG') => {
|
|
7
|
+
try {
|
|
8
|
+
const number = phoneUtil.parseAndKeepRawInput(phone, region);
|
|
9
|
+
// Check if the number is valid
|
|
10
|
+
if (!phoneUtil.isValidNumber(number)) {
|
|
11
|
+
return {
|
|
12
|
+
valid: false,
|
|
13
|
+
formatted: null,
|
|
14
|
+
error: 'Invalid phone number',
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
valid: true,
|
|
19
|
+
formatted: phoneUtil.format(number, google_libphonenumber_1.PhoneNumberFormat.E164).trim(), // +2348000000000
|
|
20
|
+
national: phoneUtil.format(number, google_libphonenumber_1.PhoneNumberFormat.NATIONAL).trim(), // 0800 000 0000
|
|
21
|
+
international: phoneUtil.format(number, google_libphonenumber_1.PhoneNumberFormat.INTERNATIONAL).trim(), // +234 800 000 0000
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
catch (err) {
|
|
25
|
+
return {
|
|
26
|
+
valid: false,
|
|
27
|
+
formatted: null,
|
|
28
|
+
error: 'Error parsing number',
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.validatePhoneNumber = validatePhoneNumber;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@konplit-services/common",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.5",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./build/index.js",
|
|
6
6
|
"types": "./build/index.d.ts",
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"@dinero.js/currencies": "^2.0.0-alpha.14",
|
|
32
32
|
"@prisma/client": "^6.13.0",
|
|
33
33
|
"@types/express": "^4.17.13",
|
|
34
|
+
"@types/google-libphonenumber": "^7.4.30",
|
|
34
35
|
"@types/jsonwebtoken": "^8.5.8",
|
|
35
36
|
"@types/morgan": "^1.9.9",
|
|
36
37
|
"@types/node": "^18.6.1",
|
|
@@ -42,6 +43,7 @@
|
|
|
42
43
|
"dinero.js": "^2.0.0-alpha.14",
|
|
43
44
|
"express": "^4.18.1",
|
|
44
45
|
"express-validator": "^6.14.2",
|
|
46
|
+
"google-libphonenumber": "^3.2.43",
|
|
45
47
|
"ioredis": "^5.4.1",
|
|
46
48
|
"jsonwebtoken": "^9.0.0",
|
|
47
49
|
"mailersend": "^2.0.5",
|