aeremmiddleware 1.0.2 → 1.0.3
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/README.md +29 -0
- package/dist/Finance/idfy.d.ts +35 -35
- package/dist/Finance/idfy.js +201 -201
- package/dist/Finance/index.d.ts +4 -4
- package/dist/Finance/index.js +10 -10
- package/dist/Maps/index.js +1 -1
- package/dist/Socials/Whatsapp.types.d.ts +97 -97
- package/dist/Socials/Whatsapp.types.js +8 -8
- package/dist/Socials/index.d.ts +4 -4
- package/dist/Socials/index.js +10 -10
- package/dist/Socials/message.d.ts +26 -26
- package/dist/Socials/message.js +211 -211
- package/dist/index.d.ts +8 -8
- package/dist/index.js +8 -8
- package/package.json +20 -17
- package/src/Finance/Ingenico.types.ts +18 -0
- package/src/Finance/encrypt.ts +18 -0
- package/src/Finance/idfy.ts +291 -204
- package/src/Finance/index.ts +7 -5
- package/src/Finance/ingenico.ts +210 -0
- package/src/Finance/novel.ts +226 -0
- package/src/Finance/novel.types.ts +24 -0
- package/src/Socials/Sms.types.ts +9 -0
- package/src/Socials/SmsSender.ts +79 -0
- package/src/Socials/Whatsapp.types.ts +95 -98
- package/src/Socials/index.ts +6 -5
- package/src/Socials/{message.ts → whatsApp.ts} +188 -236
- package/src/index.ts +7 -7
- package/tsconfig.json +111 -111
package/dist/Socials/message.js
CHANGED
|
@@ -1,212 +1,212 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const axios_1 = __importDefault(require("axios"));
|
|
16
|
-
const Whatsapp_types_1 = require("./Whatsapp.types");
|
|
17
|
-
class MessageSender {
|
|
18
|
-
constructor(payload) {
|
|
19
|
-
const { exotelSid, exotelToken, exotelApiKey, provider } = payload;
|
|
20
|
-
this.exotelSid = exotelSid;
|
|
21
|
-
this.exotelToken = exotelToken;
|
|
22
|
-
this.exotelApiKey = exotelApiKey;
|
|
23
|
-
this.provider = provider;
|
|
24
|
-
if (this.provider === Whatsapp_types_1.Provider.EXOTEL) {
|
|
25
|
-
this.whatsappApiUrl = `https://${exotelApiKey}:${exotelToken}@api.exotel.com/v2/accounts/${exotelSid}/messages`;
|
|
26
|
-
this.smsUrl = `https://${exotelApiKey}:${exotelToken}@api.exotel.com/v1/Accounts/${exotelSid}/Sms/send`;
|
|
27
|
-
}
|
|
28
|
-
else if (this.provider === Whatsapp_types_1.Provider.GUPSHUP) {
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
getTemplates() {
|
|
32
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
const request = yield axios_1.default.get(`https://${this.exotelApiKey}:${this.exotelToken}@api.exotel.com/v2/accounts/${this.exotelSid}/templates?waba_id=114033855070320`);
|
|
34
|
-
return request.data.response.whatsapp.templates;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
getUniquePlaceholderCount(str) {
|
|
38
|
-
const arr = [];
|
|
39
|
-
str.split("{{").map((s) => arr.push(...s.split("}}")));
|
|
40
|
-
const placeholders = arr.filter((i) => i.match(/[0-9]+/) && !isNaN(Number(i)));
|
|
41
|
-
return [...new Set(placeholders)].length;
|
|
42
|
-
}
|
|
43
|
-
validateTemplatePayload(template, payload) {
|
|
44
|
-
const templateComponents = template.data.components;
|
|
45
|
-
if (templateComponents.length != 2) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
const [headerTemplate, bodyTemplate] = templateComponents;
|
|
49
|
-
for (let index = 0; index < payload.whatsapp.messages.length; index++) {
|
|
50
|
-
const message = payload.whatsapp.messages[index];
|
|
51
|
-
const payloadComponents = message.content.template.components;
|
|
52
|
-
for (let index2 = 0; index2 < payloadComponents.length; index2++) {
|
|
53
|
-
const payloadComponent = payloadComponents[index2];
|
|
54
|
-
if (payloadComponent.type === headerTemplate.type.toLowerCase()) {
|
|
55
|
-
const headerPlaceholdersCount = this.getUniquePlaceholderCount(headerTemplate.text);
|
|
56
|
-
if (payloadComponent.parameters.length != headerPlaceholdersCount) {
|
|
57
|
-
console.log("invalid header");
|
|
58
|
-
throw new Error("header count mismatch");
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else if (payloadComponent.type === bodyTemplate.type.toLowerCase()) {
|
|
64
|
-
const bodyPlaceholdersCount = this.getUniquePlaceholderCount(bodyTemplate.text);
|
|
65
|
-
if (payloadComponent.parameters.length != bodyPlaceholdersCount) {
|
|
66
|
-
console.log("invalid body");
|
|
67
|
-
throw new Error("body count mismatch");
|
|
68
|
-
}
|
|
69
|
-
else {
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
else
|
|
73
|
-
throw new Error("type mismatch or incorrect");
|
|
74
|
-
}
|
|
75
|
-
return true;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
testType(obj) {
|
|
79
|
-
let returnValue = true;
|
|
80
|
-
obj.whatsapp.messages.every((message) => {
|
|
81
|
-
var _a, _b, _c, _d, _e;
|
|
82
|
-
returnValue =
|
|
83
|
-
Boolean(((_a = message === null || message === void 0 ? void 0 : message.content) === null || _a === void 0 ? void 0 : _a.type) === "text" && message.content.text) ||
|
|
84
|
-
Boolean(((_b = message === null || message === void 0 ? void 0 : message.content) === null || _b === void 0 ? void 0 : _b.type) === "document" && message.content.document) ||
|
|
85
|
-
Boolean(((_c = message === null || message === void 0 ? void 0 : message.content) === null || _c === void 0 ? void 0 : _c.type) === "image" && message.content.image) ||
|
|
86
|
-
Boolean(((_d = message === null || message === void 0 ? void 0 : message.content) === null || _d === void 0 ? void 0 : _d.type) === "video" && message.content.video) ||
|
|
87
|
-
Boolean(((_e = message === null || message === void 0 ? void 0 : message.content) === null || _e === void 0 ? void 0 : _e.type) === "template" && message.content.template);
|
|
88
|
-
return returnValue;
|
|
89
|
-
});
|
|
90
|
-
return returnValue;
|
|
91
|
-
}
|
|
92
|
-
sendMessage(messageData) {
|
|
93
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
-
try {
|
|
95
|
-
let config = {
|
|
96
|
-
method: "post",
|
|
97
|
-
maxBodyLength: Infinity,
|
|
98
|
-
url: this.whatsappApiUrl,
|
|
99
|
-
headers: {
|
|
100
|
-
"Content-Type": "application/json",
|
|
101
|
-
},
|
|
102
|
-
data: JSON.stringify(messageData),
|
|
103
|
-
};
|
|
104
|
-
const response = yield axios_1.default.request(config);
|
|
105
|
-
if (response.data.metadata && response.data.metadata.success != 0) {
|
|
106
|
-
console.log("WhatsApp message sent successfully:", response.data);
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
else {
|
|
110
|
-
console.error("Error sending WhatsApp message:", response.data);
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
catch (error) {
|
|
115
|
-
console.error("Error sending WhatsApp message:", error);
|
|
116
|
-
return false;
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
sendTemplateMessage(messageData) {
|
|
121
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
-
try {
|
|
123
|
-
const config = {
|
|
124
|
-
method: "post",
|
|
125
|
-
maxBodyLength: Infinity,
|
|
126
|
-
url: this.whatsappApiUrl,
|
|
127
|
-
headers: {
|
|
128
|
-
"Content-Type": "application/json",
|
|
129
|
-
},
|
|
130
|
-
data: JSON.stringify(messageData),
|
|
131
|
-
};
|
|
132
|
-
const response = yield axios_1.default.request(config);
|
|
133
|
-
if (response.data.metadata && response.data.metadata.success !== 0) {
|
|
134
|
-
console.log("WhatsApp template message sent successfully:", response.data);
|
|
135
|
-
return true;
|
|
136
|
-
}
|
|
137
|
-
else {
|
|
138
|
-
console.error("Error sending WhatsApp template message:", response.data);
|
|
139
|
-
return false;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
console.error("Error sending WhatsApp template message:", error);
|
|
144
|
-
return false;
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
sendOtpMessage(messageData) {
|
|
149
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
-
if (messageData.To && messageData.Body) {
|
|
151
|
-
if (messageData.Body.length != 6) {
|
|
152
|
-
throw new Error("Please enter 6 digit number");
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
else
|
|
156
|
-
throw new Error("All input data not found");
|
|
157
|
-
const bodyFormData = new FormData();
|
|
158
|
-
const smsTemplateMsg = "Your OTP for AEREMS login is %d. This %d will expire in 10 minutes.";
|
|
159
|
-
bodyFormData.append("To", messageData.To);
|
|
160
|
-
bodyFormData.append("From", "AEREM");
|
|
161
|
-
bodyFormData.append("Body", smsTemplateMsg.replace(/%d/g, messageData.Body));
|
|
162
|
-
bodyFormData.append("EncodingType", "plain");
|
|
163
|
-
bodyFormData.append("DltEntityId", "1301164059765333889");
|
|
164
|
-
bodyFormData.append("DltTemplateId", "1307164663997173809");
|
|
165
|
-
bodyFormData.append("SmsType", "transactional");
|
|
166
|
-
try {
|
|
167
|
-
let config = {
|
|
168
|
-
method: "post",
|
|
169
|
-
maxBodyLength: Infinity,
|
|
170
|
-
url: this.smsUrl,
|
|
171
|
-
headers: {
|
|
172
|
-
"Content-Type": "multipart/form-data",
|
|
173
|
-
},
|
|
174
|
-
data: bodyFormData,
|
|
175
|
-
};
|
|
176
|
-
yield axios_1.default.request(config);
|
|
177
|
-
return true;
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
console.error("Error sending sms:", error);
|
|
181
|
-
return false;
|
|
182
|
-
}
|
|
183
|
-
});
|
|
184
|
-
}
|
|
185
|
-
sendOtpSms(obj) {
|
|
186
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
-
return this.sendOtpMessage(obj);
|
|
188
|
-
});
|
|
189
|
-
}
|
|
190
|
-
sendWhatsAppMessage(obj) {
|
|
191
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
192
|
-
if (this.testType(obj))
|
|
193
|
-
return this.sendMessage(obj);
|
|
194
|
-
else
|
|
195
|
-
return false;
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
sendWhatsappTemplateMessage(obj) {
|
|
199
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
-
let templatevalue = yield this.getTemplates();
|
|
201
|
-
let tempVariable = obj.whatsapp.messages[0].content.template.name;
|
|
202
|
-
let template = templatevalue.find((e) => e.data.name == tempVariable);
|
|
203
|
-
if (this.validateTemplatePayload(template, obj)) {
|
|
204
|
-
return this.sendTemplateMessage(obj);
|
|
205
|
-
}
|
|
206
|
-
else
|
|
207
|
-
return false;
|
|
208
|
-
});
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
exports.default = MessageSender;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const axios_1 = __importDefault(require("axios"));
|
|
16
|
+
const Whatsapp_types_1 = require("./Whatsapp.types");
|
|
17
|
+
class MessageSender {
|
|
18
|
+
constructor(payload) {
|
|
19
|
+
const { exotelSid, exotelToken, exotelApiKey, provider } = payload;
|
|
20
|
+
this.exotelSid = exotelSid;
|
|
21
|
+
this.exotelToken = exotelToken;
|
|
22
|
+
this.exotelApiKey = exotelApiKey;
|
|
23
|
+
this.provider = provider;
|
|
24
|
+
if (this.provider === Whatsapp_types_1.Provider.EXOTEL) {
|
|
25
|
+
this.whatsappApiUrl = `https://${exotelApiKey}:${exotelToken}@api.exotel.com/v2/accounts/${exotelSid}/messages`;
|
|
26
|
+
this.smsUrl = `https://${exotelApiKey}:${exotelToken}@api.exotel.com/v1/Accounts/${exotelSid}/Sms/send`;
|
|
27
|
+
}
|
|
28
|
+
else if (this.provider === Whatsapp_types_1.Provider.GUPSHUP) {
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
getTemplates() {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
const request = yield axios_1.default.get(`https://${this.exotelApiKey}:${this.exotelToken}@api.exotel.com/v2/accounts/${this.exotelSid}/templates?waba_id=114033855070320`);
|
|
34
|
+
return request.data.response.whatsapp.templates;
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
getUniquePlaceholderCount(str) {
|
|
38
|
+
const arr = [];
|
|
39
|
+
str.split("{{").map((s) => arr.push(...s.split("}}")));
|
|
40
|
+
const placeholders = arr.filter((i) => i.match(/[0-9]+/) && !isNaN(Number(i)));
|
|
41
|
+
return [...new Set(placeholders)].length;
|
|
42
|
+
}
|
|
43
|
+
validateTemplatePayload(template, payload) {
|
|
44
|
+
const templateComponents = template.data.components;
|
|
45
|
+
if (templateComponents.length != 2) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const [headerTemplate, bodyTemplate] = templateComponents;
|
|
49
|
+
for (let index = 0; index < payload.whatsapp.messages.length; index++) {
|
|
50
|
+
const message = payload.whatsapp.messages[index];
|
|
51
|
+
const payloadComponents = message.content.template.components;
|
|
52
|
+
for (let index2 = 0; index2 < payloadComponents.length; index2++) {
|
|
53
|
+
const payloadComponent = payloadComponents[index2];
|
|
54
|
+
if (payloadComponent.type === headerTemplate.type.toLowerCase()) {
|
|
55
|
+
const headerPlaceholdersCount = this.getUniquePlaceholderCount(headerTemplate.text);
|
|
56
|
+
if (payloadComponent.parameters.length != headerPlaceholdersCount) {
|
|
57
|
+
console.log("invalid header");
|
|
58
|
+
throw new Error("header count mismatch");
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
else if (payloadComponent.type === bodyTemplate.type.toLowerCase()) {
|
|
64
|
+
const bodyPlaceholdersCount = this.getUniquePlaceholderCount(bodyTemplate.text);
|
|
65
|
+
if (payloadComponent.parameters.length != bodyPlaceholdersCount) {
|
|
66
|
+
console.log("invalid body");
|
|
67
|
+
throw new Error("body count mismatch");
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
else
|
|
73
|
+
throw new Error("type mismatch or incorrect");
|
|
74
|
+
}
|
|
75
|
+
return true;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
testType(obj) {
|
|
79
|
+
let returnValue = true;
|
|
80
|
+
obj.whatsapp.messages.every((message) => {
|
|
81
|
+
var _a, _b, _c, _d, _e;
|
|
82
|
+
returnValue =
|
|
83
|
+
Boolean(((_a = message === null || message === void 0 ? void 0 : message.content) === null || _a === void 0 ? void 0 : _a.type) === "text" && message.content.text) ||
|
|
84
|
+
Boolean(((_b = message === null || message === void 0 ? void 0 : message.content) === null || _b === void 0 ? void 0 : _b.type) === "document" && message.content.document) ||
|
|
85
|
+
Boolean(((_c = message === null || message === void 0 ? void 0 : message.content) === null || _c === void 0 ? void 0 : _c.type) === "image" && message.content.image) ||
|
|
86
|
+
Boolean(((_d = message === null || message === void 0 ? void 0 : message.content) === null || _d === void 0 ? void 0 : _d.type) === "video" && message.content.video) ||
|
|
87
|
+
Boolean(((_e = message === null || message === void 0 ? void 0 : message.content) === null || _e === void 0 ? void 0 : _e.type) === "template" && message.content.template);
|
|
88
|
+
return returnValue;
|
|
89
|
+
});
|
|
90
|
+
return returnValue;
|
|
91
|
+
}
|
|
92
|
+
sendMessage(messageData) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
94
|
+
try {
|
|
95
|
+
let config = {
|
|
96
|
+
method: "post",
|
|
97
|
+
maxBodyLength: Infinity,
|
|
98
|
+
url: this.whatsappApiUrl,
|
|
99
|
+
headers: {
|
|
100
|
+
"Content-Type": "application/json",
|
|
101
|
+
},
|
|
102
|
+
data: JSON.stringify(messageData),
|
|
103
|
+
};
|
|
104
|
+
const response = yield axios_1.default.request(config);
|
|
105
|
+
if (response.data.metadata && response.data.metadata.success != 0) {
|
|
106
|
+
console.log("WhatsApp message sent successfully:", response.data);
|
|
107
|
+
return true;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
console.error("Error sending WhatsApp message:", response.data);
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
console.error("Error sending WhatsApp message:", error);
|
|
116
|
+
return false;
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
sendTemplateMessage(messageData) {
|
|
121
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
122
|
+
try {
|
|
123
|
+
const config = {
|
|
124
|
+
method: "post",
|
|
125
|
+
maxBodyLength: Infinity,
|
|
126
|
+
url: this.whatsappApiUrl,
|
|
127
|
+
headers: {
|
|
128
|
+
"Content-Type": "application/json",
|
|
129
|
+
},
|
|
130
|
+
data: JSON.stringify(messageData),
|
|
131
|
+
};
|
|
132
|
+
const response = yield axios_1.default.request(config);
|
|
133
|
+
if (response.data.metadata && response.data.metadata.success !== 0) {
|
|
134
|
+
console.log("WhatsApp template message sent successfully:", response.data);
|
|
135
|
+
return true;
|
|
136
|
+
}
|
|
137
|
+
else {
|
|
138
|
+
console.error("Error sending WhatsApp template message:", response.data);
|
|
139
|
+
return false;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
catch (error) {
|
|
143
|
+
console.error("Error sending WhatsApp template message:", error);
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
sendOtpMessage(messageData) {
|
|
149
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
150
|
+
if (messageData.To && messageData.Body) {
|
|
151
|
+
if (messageData.Body.length != 6) {
|
|
152
|
+
throw new Error("Please enter 6 digit number");
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
else
|
|
156
|
+
throw new Error("All input data not found");
|
|
157
|
+
const bodyFormData = new FormData();
|
|
158
|
+
const smsTemplateMsg = "Your OTP for AEREMS login is %d. This %d will expire in 10 minutes.";
|
|
159
|
+
bodyFormData.append("To", messageData.To);
|
|
160
|
+
bodyFormData.append("From", "AEREM");
|
|
161
|
+
bodyFormData.append("Body", smsTemplateMsg.replace(/%d/g, messageData.Body));
|
|
162
|
+
bodyFormData.append("EncodingType", "plain");
|
|
163
|
+
bodyFormData.append("DltEntityId", "1301164059765333889");
|
|
164
|
+
bodyFormData.append("DltTemplateId", "1307164663997173809");
|
|
165
|
+
bodyFormData.append("SmsType", "transactional");
|
|
166
|
+
try {
|
|
167
|
+
let config = {
|
|
168
|
+
method: "post",
|
|
169
|
+
maxBodyLength: Infinity,
|
|
170
|
+
url: this.smsUrl,
|
|
171
|
+
headers: {
|
|
172
|
+
"Content-Type": "multipart/form-data",
|
|
173
|
+
},
|
|
174
|
+
data: bodyFormData,
|
|
175
|
+
};
|
|
176
|
+
yield axios_1.default.request(config);
|
|
177
|
+
return true;
|
|
178
|
+
}
|
|
179
|
+
catch (error) {
|
|
180
|
+
console.error("Error sending sms:", error);
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
sendOtpSms(obj) {
|
|
186
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
187
|
+
return this.sendOtpMessage(obj);
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
sendWhatsAppMessage(obj) {
|
|
191
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
192
|
+
if (this.testType(obj))
|
|
193
|
+
return this.sendMessage(obj);
|
|
194
|
+
else
|
|
195
|
+
return false;
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
sendWhatsappTemplateMessage(obj) {
|
|
199
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
200
|
+
let templatevalue = yield this.getTemplates();
|
|
201
|
+
let tempVariable = obj.whatsapp.messages[0].content.template.name;
|
|
202
|
+
let template = templatevalue.find((e) => e.data.name == tempVariable);
|
|
203
|
+
if (this.validateTemplatePayload(template, obj)) {
|
|
204
|
+
return this.sendTemplateMessage(obj);
|
|
205
|
+
}
|
|
206
|
+
else
|
|
207
|
+
return false;
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
exports.default = MessageSender;
|
|
212
212
|
//# sourceMappingURL=message.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export declare const AeremMiddleware: {
|
|
2
|
-
finance: {
|
|
3
|
-
idFy: typeof import("./Finance/idfy").default;
|
|
4
|
-
};
|
|
5
|
-
socials: {
|
|
6
|
-
message: typeof import("./Socials/message").default;
|
|
7
|
-
};
|
|
8
|
-
};
|
|
1
|
+
export declare const AeremMiddleware: {
|
|
2
|
+
finance: {
|
|
3
|
+
idFy: typeof import("./Finance/idfy").default;
|
|
4
|
+
};
|
|
5
|
+
socials: {
|
|
6
|
+
message: typeof import("./Socials/message").default;
|
|
7
|
+
};
|
|
8
|
+
};
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AeremMiddleware = void 0;
|
|
4
|
-
const Finance_1 = require("./Finance");
|
|
5
|
-
const Socials_1 = require("./Socials");
|
|
6
|
-
exports.AeremMiddleware = {
|
|
7
|
-
finance: Finance_1.finance, socials: Socials_1.socials
|
|
8
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AeremMiddleware = void 0;
|
|
4
|
+
const Finance_1 = require("./Finance");
|
|
5
|
+
const Socials_1 = require("./Socials");
|
|
6
|
+
exports.AeremMiddleware = {
|
|
7
|
+
finance: Finance_1.finance, socials: Socials_1.socials
|
|
8
|
+
};
|
|
9
9
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "aeremmiddleware",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
5
|
-
"type":"dist/index.d.ts",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "tsc",
|
|
9
|
-
"prod": "node ./build/src/index.js"
|
|
10
|
-
},
|
|
11
|
-
"keywords": [],
|
|
12
|
-
"author": "",
|
|
13
|
-
"license": "ISC",
|
|
14
|
-
"dependencies": {
|
|
15
|
-
"axios": "^1.
|
|
16
|
-
}
|
|
17
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "aeremmiddleware",
|
|
3
|
+
"version": "1.0.3",
|
|
4
|
+
"description": "",
|
|
5
|
+
"type": "dist/index.d.ts",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "tsc",
|
|
9
|
+
"prod": "node ./build/src/index.js"
|
|
10
|
+
},
|
|
11
|
+
"keywords": [],
|
|
12
|
+
"author": "",
|
|
13
|
+
"license": "ISC",
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"axios": "^1.5.1"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/node": "^20.8.2"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface MandateDataType {
|
|
2
|
+
merchantId: string;
|
|
3
|
+
txnId: string;
|
|
4
|
+
totalamount: string;
|
|
5
|
+
accountNo: string;
|
|
6
|
+
consumerId: string;
|
|
7
|
+
consumerMobileNo: string;
|
|
8
|
+
consumerEmailId: string;
|
|
9
|
+
debitStartDate: string;
|
|
10
|
+
debitEndDate: string;
|
|
11
|
+
maxAmount: string;
|
|
12
|
+
amountType: string;
|
|
13
|
+
frequency: string;
|
|
14
|
+
cardNumber?: string;
|
|
15
|
+
expMonth?: string;
|
|
16
|
+
expYear?: string;
|
|
17
|
+
cvvCode?: string;
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import crypto from "crypto";
|
|
2
|
+
|
|
3
|
+
export function createSHA512Hash(dataObject: any, salt: string) {
|
|
4
|
+
const sortedData = Object.keys(dataObject)
|
|
5
|
+
.map((key) => dataObject[key])
|
|
6
|
+
.join("|");
|
|
7
|
+
|
|
8
|
+
const pipeSeparatedData = `${sortedData}|${salt}`;
|
|
9
|
+
console.log(pipeSeparatedData);
|
|
10
|
+
|
|
11
|
+
const hash = crypto.createHash("sha512");
|
|
12
|
+
|
|
13
|
+
hash.update(pipeSeparatedData, "utf-8");
|
|
14
|
+
|
|
15
|
+
const hashedString = hash.digest("hex");
|
|
16
|
+
|
|
17
|
+
return hashedString;
|
|
18
|
+
}
|