nets-service-sdk 1.0.1 → 1.0.2

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/dist/index.js CHANGED
@@ -1,2 +1,1010 @@
1
- function e(){return e=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var s in n)({}).hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},e.apply(null,arguments)}var r=require("./src/utils.helper"),n=require("./src/winston"),s=require("./src/manageConfig"),u=require("./src/queue"),a=require("./src/sendMessage"),t=require("./src/payment/communication"),i=require("./src/payment/hexRequest"),c=require("./src/payment/httpRequest"),o=require("./src/payment/parser"),p=require("./src/payment/responseHandler");module.exports=e({},r,{logger:n,manageConfig:s,queue:u,sendMessage:a,communication:t,hexRequest:i,httpRequest:c,parser:o,responseHandler:p});
2
- //# sourceMappingURL=index.js.map
1
+ var __getOwnPropNames = Object.getOwnPropertyNames;
2
+ var __commonJS = (cb, mod) => function __require() {
3
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
4
+ };
5
+
6
+ // src/utils.helper.js
7
+ var require_utils_helper = __commonJS({
8
+ "src/utils.helper.js"(exports2, module2) {
9
+ var { SerialPort } = require("serialport");
10
+ var crypto = require("crypto");
11
+ var _ = require("lodash");
12
+ module2.exports.padWithLeadingZeros = (num, totalLength) => {
13
+ return String(num).padStart(totalLength, "0");
14
+ };
15
+ module2.exports.xorCalculation = (value) => {
16
+ const splitted_arr = value.match(/[\w]{2}/g);
17
+ let response = "";
18
+ _.map(splitted_arr, (value2, i) => {
19
+ if (i == 0) {
20
+ response = value2;
21
+ } else {
22
+ response = xor(response, value2);
23
+ }
24
+ });
25
+ return response;
26
+ };
27
+ String.prototype.toHexString = function() {
28
+ var res = [];
29
+ for (var i = 0, j = this.length; i < j; ++i) {
30
+ var chr = this.charCodeAt(i).toString(16);
31
+ chr = (chr.length == 1 ? "0" : "") + chr;
32
+ res.push(chr);
33
+ }
34
+ return res.join("").toUpperCase();
35
+ };
36
+ function xor(hex1, hex2) {
37
+ const buf1 = Buffer.from(hex1, "hex");
38
+ const buf2 = Buffer.from(hex2, "hex");
39
+ const bufResult = buf1.map((b, i) => b ^ buf2[i]);
40
+ return bufResult.toString("hex");
41
+ }
42
+ String.prototype.toAsciiString = function() {
43
+ return this.match(/.{1,2}/g).map(function(v) {
44
+ return String.fromCharCode(parseInt(v, 16));
45
+ }).join("");
46
+ };
47
+ String.prototype.splitAtIndex = function(index) {
48
+ return [this.substring(0, index), this.substring(index)];
49
+ };
50
+ String.prototype.cleanUp = function() {
51
+ return this.replace(
52
+ /[^A-Za-z 0-9 \.,\?""!@#\$%\^&\*\(\)-_=\+;:<>\/\\\|\}\{\[\]`~]*/g,
53
+ ""
54
+ ).trim();
55
+ };
56
+ SerialPort.prototype._disconnected = function(err) {
57
+ this.paused = true;
58
+ this.emit("disconnect", err);
59
+ if (this.closing) {
60
+ return;
61
+ }
62
+ if (this.fd === null) {
63
+ return;
64
+ }
65
+ this.closing = true;
66
+ if (process.platform !== "win32") {
67
+ this.readable = false;
68
+ if (this.serialPoller) {
69
+ this.serialPoller.close();
70
+ }
71
+ }
72
+ SerialPortBinding.close(
73
+ this.fd,
74
+ function(err2) {
75
+ this.closing = false;
76
+ if (err2) {
77
+ debug("Disconnect close completed with error: ", err2);
78
+ }
79
+ this.fd = null;
80
+ this.emit("close");
81
+ }.bind(this)
82
+ );
83
+ };
84
+ module2.exports.generateServiceKey = (payload) => {
85
+ const key = `${process.env.user}:${process.env.password}`;
86
+ const algorithm = "aes256";
87
+ var cipher = crypto.createCipher(algorithm, key);
88
+ return cipher.update(JSON.stringify(payload), "utf8", "hex") + cipher.final("hex");
89
+ };
90
+ }
91
+ });
92
+
93
+ // src/winston.js
94
+ var require_winston = __commonJS({
95
+ "src/winston.js"(exports2, module2) {
96
+ var { createLogger, format, transports } = require("winston");
97
+ var { combine, timestamp, label, printf } = format;
98
+ var path = require("path");
99
+ var getLabel = (callingModule) => {
100
+ if (!callingModule || !callingModule.filename) {
101
+ return "unknown";
102
+ }
103
+ const parts = callingModule.filename.split(path.sep);
104
+ return path.join(parts[parts.length - 1], parts.pop());
105
+ };
106
+ var myFormat = printf(
107
+ ({ level, message, label: label2, timestamp: timestamp2 }) => `${timestamp2} [${label2}] ${level}: ${message}`
108
+ );
109
+ var logger = (module3) => createLogger({
110
+ format: combine(label({ label: getLabel(module3) }), timestamp(), myFormat),
111
+ transports: [
112
+ new transports.Console(),
113
+ new transports.File({
114
+ filename: "log/platform-access.log",
115
+ level: "info",
116
+ timestamp: true
117
+ }),
118
+ new transports.File({
119
+ filename: "log/platform-error.log",
120
+ level: "error",
121
+ timestamp: true
122
+ })
123
+ ]
124
+ });
125
+ module2.exports = logger;
126
+ }
127
+ });
128
+
129
+ // src/manageConfig.js
130
+ var require_manageConfig = __commonJS({
131
+ "src/manageConfig.js"(exports2, module2) {
132
+ var fs = require("fs");
133
+ var _ = require("lodash");
134
+ module2.exports.updateConfig = (data) => {
135
+ try {
136
+ const config = fs.readFileSync("./config.json");
137
+ const configJson = JSON.parse(config);
138
+ _.assignIn(configJson, data);
139
+ fs.writeFileSync("config.json", JSON.stringify(configJson, null, " "));
140
+ } catch (e) {
141
+ throw e;
142
+ }
143
+ };
144
+ module2.exports.getConfigByKey = (key) => {
145
+ try {
146
+ const config = fs.readFileSync("./config.json");
147
+ const configJson = JSON.parse(config);
148
+ return configJson[key];
149
+ } catch (e) {
150
+ throw e;
151
+ }
152
+ };
153
+ module2.exports.getConfig = () => {
154
+ try {
155
+ const config = fs.readFileSync("./config.json");
156
+ return JSON.parse(config);
157
+ } catch (e) {
158
+ throw e;
159
+ }
160
+ };
161
+ }
162
+ });
163
+
164
+ // src/queue.js
165
+ var require_queue = __commonJS({
166
+ "src/queue.js"(exports2, module2) {
167
+ "use strict";
168
+ var Node = class {
169
+ constructor(data) {
170
+ this.data = data;
171
+ }
172
+ };
173
+ var Queue = class {
174
+ constructor() {
175
+ this.elements = [];
176
+ }
177
+ enqueue(node) {
178
+ this.elements.push(node);
179
+ }
180
+ dequeue() {
181
+ if (this.elements.length > 0) {
182
+ return this.elements.shift();
183
+ } else {
184
+ return "Underflow situation";
185
+ }
186
+ }
187
+ isEmpty() {
188
+ return this.elements.length == 0;
189
+ }
190
+ front() {
191
+ if (this.elements.length > 0) {
192
+ return this.elements[0];
193
+ } else {
194
+ return "The Queue is empty!";
195
+ }
196
+ }
197
+ size() {
198
+ return this.elements.length;
199
+ }
200
+ print() {
201
+ return this.elements;
202
+ }
203
+ };
204
+ module2.exports = {
205
+ Node,
206
+ Queue
207
+ };
208
+ }
209
+ });
210
+
211
+ // src/sendMessage.js
212
+ var require_sendMessage = __commonJS({
213
+ "src/sendMessage.js"(exports2, module2) {
214
+ var logger = require_winston()(module2);
215
+ module2.exports.sendMessage = (room = "clientRoom", tag, msg) => {
216
+ logger.log({
217
+ level: "info",
218
+ message: JSON.stringify(msg)
219
+ });
220
+ global.io.emit(tag, msg);
221
+ };
222
+ }
223
+ });
224
+
225
+ // src/payment/hexRequest.js
226
+ var require_hexRequest = __commonJS({
227
+ "src/payment/hexRequest.js"(exports2, module2) {
228
+ var { padWithLeadingZeros, xorCalculation } = require_utils_helper();
229
+ var dollarsToCents = require("dollars-to-cents");
230
+ var _ = require("lodash");
231
+ var moment = require("moment");
232
+ module2.exports.generateStatusReq = () => {
233
+ const date = moment().format("DDMMYYHHmmss");
234
+ const paddedValue = padWithLeadingZeros(date, "12");
235
+ const hexValue = paddedValue.toHexString();
236
+ const calculated = `0018${hexValue}35353031301C03`;
237
+ const calculatedXor = xorCalculation(calculated);
238
+ const hexString = `02${calculated}` + calculatedXor;
239
+ const buffer = Buffer.from(hexString, "hex");
240
+ return { buffer, ecn: date };
241
+ };
242
+ module2.exports.generateLogonRequest = () => {
243
+ const date = moment().format("DDMMYYHHmmss");
244
+ const paddedValue = padWithLeadingZeros(date, "12");
245
+ const hexValue = paddedValue.toHexString();
246
+ const calculated = `0018${hexValue}38303031301C03`;
247
+ const calculatedXor = xorCalculation(calculated);
248
+ const hexString = `02${calculated}` + calculatedXor;
249
+ console.log(hexString);
250
+ const buffer = Buffer.from(hexString, "hex");
251
+ return { buffer, ecn: date };
252
+ };
253
+ module2.exports.generatePaymentRequest = (body) => {
254
+ const ecnPadded = padWithLeadingZeros(body.ecn, "12");
255
+ console.log("ecnPadded", ecnPadded);
256
+ const cents = dollarsToCents(body.amount);
257
+ console.log("cents", cents);
258
+ const amountPadded = padWithLeadingZeros(cents, "12").toHexString();
259
+ console.log("amountPadded", amountPadded);
260
+ const orderReference = padWithLeadingZeros(body.reference, "13").toHexString();
261
+ console.log("orderReference", orderReference);
262
+ let calculated;
263
+ if (body.isCreditTxn) {
264
+ const calculatedEcn = `${ecnPadded}I0010`.toHexString();
265
+ calculated = `0053${calculatedEcn}1C34300012${amountPadded}1C48440013${orderReference}1C03`;
266
+ } else {
267
+ const calculatedEcn = `${ecnPadded}30010`.toHexString();
268
+ calculated = `0077${calculatedEcn}1C5432000230311C34300012${amountPadded}1C343200123030303030303030303030301C48440013${orderReference}1C03`;
269
+ }
270
+ console.log("calculated", calculated);
271
+ const calculatedXor = xorCalculation(calculated);
272
+ console.log("calculatedXor", calculatedXor);
273
+ const hexString = `02${calculated}` + calculatedXor;
274
+ console.log("hexString", hexString);
275
+ const buffer = Buffer.from(hexString, "hex");
276
+ console.log("hexString", hexString);
277
+ console.log("buffer", buffer);
278
+ return { buffer, ecn: body.ecn, hexString };
279
+ };
280
+ }
281
+ });
282
+
283
+ // src/payment/httpRequest.js
284
+ var require_httpRequest = __commonJS({
285
+ "src/payment/httpRequest.js"(exports2, module2) {
286
+ var fw = require_manageConfig();
287
+ var request = require("request");
288
+ var logger = require_winston()(module2);
289
+ var { generateServiceKey } = require_utils_helper();
290
+ module2.exports.requestCompletion = (entryId, fullfillmentDetails, paymentStatus, paymentType) => new Promise(async (resolve, reject) => {
291
+ try {
292
+ const URL = `${process.env.URL}api/v1/hooks`;
293
+ const payload = {
294
+ ...fullfillmentDetails,
295
+ paymentType,
296
+ paymentStatus,
297
+ entryId
298
+ };
299
+ return request(
300
+ {
301
+ method: "POST",
302
+ uri: URL,
303
+ body: payload,
304
+ json: true,
305
+ headers: { "x-service-key": generateServiceKey(payload) }
306
+ },
307
+ async (err, res, body) => {
308
+ if (err) {
309
+ return reject(err);
310
+ }
311
+ if (res) {
312
+ return resolve(body);
313
+ }
314
+ }
315
+ );
316
+ } catch (e) {
317
+ console.log(`getToken Service Error: ${JSON.stringify(e)}`);
318
+ return reject(e);
319
+ }
320
+ });
321
+ module2.exports.initialiseRequest = (entryId, fullfillmentDetails, paymentType) => new Promise(async (resolve, reject) => {
322
+ try {
323
+ const config = fw.getConfig();
324
+ const URL = `${config.cloud_url}api/v1/hooks`;
325
+ const payload = {
326
+ ...fullfillmentDetails,
327
+ paymentType,
328
+ entryId,
329
+ update: "INIT"
330
+ };
331
+ logger.log({
332
+ level: "info",
333
+ message: `update Request: ${JSON.stringify(payload)}`
334
+ });
335
+ return request(
336
+ {
337
+ method: "POST",
338
+ uri: URL,
339
+ body: payload,
340
+ json: true,
341
+ headers: { "x-service-key": generateServiceKey(payload) }
342
+ },
343
+ async (err, res, body) => {
344
+ if (err) {
345
+ console.log(err);
346
+ return reject(err);
347
+ }
348
+ if (res) {
349
+ return resolve(body);
350
+ }
351
+ }
352
+ );
353
+ } catch (e) {
354
+ console.log(`getToken Service Error: ${JSON.stringify(e)}`);
355
+ return reject(e);
356
+ }
357
+ });
358
+ }
359
+ });
360
+
361
+ // src/payment/parser.js
362
+ var require_parser = __commonJS({
363
+ "src/payment/parser.js"(exports2, module2) {
364
+ module2.exports.statusParser = (hexCode, ecn) => {
365
+ const splitted = hexCode.split("1c");
366
+ for (let i = 0; i < splitted.length; i++) {
367
+ if (splitted[i].toAsciiString().indexOf(ecn) > -1) {
368
+ return true;
369
+ }
370
+ }
371
+ return false;
372
+ };
373
+ module2.exports.logonParser = (hexCode, ecn) => {
374
+ try {
375
+ const splitted = hexCode.split("1c");
376
+ let status = false;
377
+ const json = {};
378
+ for (let i = 0; i < splitted.length; i++) {
379
+ const ascii = splitted[i].toAsciiString();
380
+ if (ascii.indexOf(ecn) > -1) {
381
+ status = true;
382
+ json["ECN"] = ascii.cleanUp();
383
+ } else {
384
+ const subStringArray = ascii.splitAtIndex(2);
385
+ if (subStringArray.length > 1) {
386
+ if (subStringArray[0] == "02" && subStringArray[0].indexOf("APPROVED") > -1) {
387
+ status = true;
388
+ }
389
+ const identifier = subStringArray[0].cleanUp();
390
+ const value = subStringArray[1].cleanUp();
391
+ if (identifier && value) {
392
+ json[identifier] = value;
393
+ }
394
+ }
395
+ }
396
+ }
397
+ return { status, json };
398
+ } catch (e) {
399
+ throw e;
400
+ }
401
+ };
402
+ module2.exports.netsPaymentParser = (hexCode, ecn) => {
403
+ try {
404
+ const splitted = hexCode.split("1c");
405
+ let status = false;
406
+ const json = {};
407
+ for (let i = 0; i < splitted.length; i++) {
408
+ const ascii = splitted[i].toAsciiString();
409
+ if (ascii.indexOf(ecn) > -1) {
410
+ json["ECN"] = ascii.cleanUp();
411
+ } else {
412
+ const subStringArray = ascii.splitAtIndex(2);
413
+ if (subStringArray.length > 1) {
414
+ const identifier = subStringArray[0].cleanUp();
415
+ const value = subStringArray[1].cleanUp();
416
+ if (identifier && value) {
417
+ json[identifier] = value;
418
+ }
419
+ }
420
+ }
421
+ }
422
+ return json;
423
+ } catch (e) {
424
+ throw e;
425
+ }
426
+ };
427
+ module2.exports.creditPaymentParser = (hexCode, ecn) => {
428
+ try {
429
+ const splitted = hexCode.split("1c");
430
+ let status = false;
431
+ const json = {};
432
+ for (let i = 0; i < splitted.length; i++) {
433
+ const ascii = splitted[i].toAsciiString();
434
+ if (ascii.indexOf(ecn) > -1) {
435
+ json["ECN"] = ascii.cleanUp();
436
+ } else {
437
+ const subStringArray = ascii.splitAtIndex(2);
438
+ if (subStringArray.length > 1) {
439
+ const identifier = subStringArray[0].cleanUp();
440
+ const value = subStringArray[1].cleanUp();
441
+ if (identifier && value) {
442
+ json[identifier] = value;
443
+ }
444
+ }
445
+ }
446
+ }
447
+ return json;
448
+ } catch (e) {
449
+ throw e;
450
+ }
451
+ };
452
+ module2.exports.jsonProcessor = (obj) => {
453
+ const data = { ...obj };
454
+ const keys = Object.keys(data);
455
+ const translatedJson = {};
456
+ keys.forEach((key) => {
457
+ if (key == "01") {
458
+ translatedJson["approvalCode"] = obj[key];
459
+ }
460
+ if (key == "02") {
461
+ const statusResponse = statusCheck(obj[key]);
462
+ if (statusResponse) {
463
+ translatedJson.status = statusResponse.status;
464
+ translatedJson.description = statusResponse.detail;
465
+ if (statusResponse.balance) {
466
+ translatedJson["balance"] = statusResponse.balance;
467
+ }
468
+ }
469
+ const ecnnError = CheckECNERROR(obj["ECN"]);
470
+ if (ecnnError) {
471
+ translatedJson.status = ecnnError.status;
472
+ translatedJson.description = ecnnError.detail;
473
+ }
474
+ translatedJson["responsetext"] = obj[key];
475
+ }
476
+ if (key == "03") {
477
+ translatedJson["date"] = obj[key].match(/.{1,2}/g) ?? [];
478
+ }
479
+ if (key == "04") {
480
+ translatedJson["time"] = obj[key].match(/.{1,2}/g) ?? [];
481
+ }
482
+ if (key == "16") {
483
+ translatedJson["terminalId"] = obj[key];
484
+ }
485
+ if (key == "30") {
486
+ translatedJson["cardNumber"] = obj[key];
487
+ }
488
+ if (key == "31") {
489
+ translatedJson["expiryDate"] = obj[key];
490
+ }
491
+ if (key == "40") {
492
+ translatedJson["transactionAmount"] = obj[key];
493
+ }
494
+ if (key == "41") {
495
+ translatedJson["serviceFee"] = obj[key];
496
+ }
497
+ if (key == "50") {
498
+ translatedJson["batchNumber"] = obj[key];
499
+ }
500
+ if (key == "65") {
501
+ translatedJson["stan"] = obj[key];
502
+ }
503
+ if (key == "A1") {
504
+ translatedJson["transactionId"] = obj[key];
505
+ }
506
+ if (key == "D0") {
507
+ translatedJson["merchantNameAndAddress"] = obj[key];
508
+ }
509
+ if (key == "D1") {
510
+ translatedJson["merchantId"] = obj[key];
511
+ }
512
+ if (key == "D3") {
513
+ translatedJson["retrievalReferenceNumber"] = obj[key];
514
+ }
515
+ if (key == "D6") {
516
+ translatedJson["cardHolderName"] = obj[key];
517
+ }
518
+ if (key == "D7") {
519
+ translatedJson["processingGateway"] = obj[key];
520
+ }
521
+ if (key == "D8") {
522
+ translatedJson["cardDescription"] = obj[key];
523
+ }
524
+ if (key == "CN") {
525
+ translatedJson["cardEntryMode"] = obj[key];
526
+ }
527
+ if (key == "L1") {
528
+ translatedJson["loyaltyProgramName"] = obj[key];
529
+ }
530
+ if (key == "L2") {
531
+ translatedJson["loyaltyType"] = obj[key];
532
+ }
533
+ if (key == "L3") {
534
+ translatedJson["redemptionValue"] = obj[key];
535
+ }
536
+ if (key == "L4") {
537
+ translatedJson["currentLoyaltyBalance"] = obj[key];
538
+ }
539
+ if (key == "L5") {
540
+ translatedJson["posMessages"] = obj[key];
541
+ }
542
+ if (key == "L7") {
543
+ translatedJson["cardName"] = obj[key];
544
+ }
545
+ if (key == "L8") {
546
+ translatedJson["loyaltyProgramExpDate"] = obj[key];
547
+ }
548
+ if (key == "L9") {
549
+ translatedJson["loyaltyMarketingMessage"] = obj[key];
550
+ }
551
+ if (key == "HC") {
552
+ translatedJson["hostResponseCode"] = obj[key];
553
+ }
554
+ if (key == "HD") {
555
+ translatedJson["enhancedECRReferenceNumber"] = obj[key];
556
+ }
557
+ if (key == "9A") {
558
+ translatedJson["aid-EMV"] = obj[key];
559
+ }
560
+ if (key == "9B") {
561
+ translatedJson["applicationProfile-EMV"] = obj[key];
562
+ }
563
+ if (key == "9C") {
564
+ translatedJson["cid-EMV"] = obj[key];
565
+ }
566
+ if (key == "9D") {
567
+ translatedJson["transactionCertificate-EMV"] = obj[key];
568
+ }
569
+ if (key == "9E") {
570
+ translatedJson["tsi-EMV"] = obj[key];
571
+ }
572
+ if (key == "9F") {
573
+ translatedJson["tvr-EMV"] = obj[key];
574
+ }
575
+ if (key == "9H") {
576
+ translatedJson["invoiceNumber"] = obj[key];
577
+ }
578
+ if (key == "9I") {
579
+ translatedJson["posId"] = obj[key];
580
+ }
581
+ if (key == "9M") {
582
+ translatedJson["cardType"] = obj[key];
583
+ }
584
+ if (key == "9Q") {
585
+ translatedJson["schemeCategory"] = obj[key];
586
+ }
587
+ if (key == "O1") {
588
+ translatedJson["offlineTxnType"] = obj[key];
589
+ }
590
+ if (key == "RP") {
591
+ translatedJson["receiptTextFormat"] = obj[key];
592
+ }
593
+ });
594
+ return { translated: translatedJson, raw: obj };
595
+ };
596
+ function statusCheck(data) {
597
+ if (data.indexOf("APPROVED") > -1) {
598
+ const response = { status: "APPROVED", detail: "Payment Succeed" };
599
+ if (data.indexOf("BAL:") > -1) {
600
+ const balance = data.split("BAL:");
601
+ response.balance = balance[1].trim();
602
+ }
603
+ return response;
604
+ }
605
+ if (data.indexOf("INVALID CARD") > -1) {
606
+ return { status: "INVALID_CARD", detail: "Invalid Card" };
607
+ }
608
+ if (data.indexOf("F3905-Parameter") > -1) {
609
+ return { status: "INVALID_CARD", detail: "Invalid Card" };
610
+ }
611
+ if (data.indexOf("DECLINED") > -1) {
612
+ return { status: "DECLINED", detail: "Transaction Declined" };
613
+ }
614
+ if (data.indexOf("CARD NOT SUPPORTED") > -1) {
615
+ return { status: "CARD_NOT_SUPPORTED", detail: "Card not supported" };
616
+ }
617
+ return null;
618
+ }
619
+ function CheckECNERROR(data) {
620
+ if (data.indexOf("US") > -1) {
621
+ return { status: "USER_CANCELLED", detail: "User Cancelled" };
622
+ }
623
+ if (data.indexOf("GX") > -1) {
624
+ return { status: "OUT_OF_PAPER", detail: "Out of Paper" };
625
+ }
626
+ if (data.indexOf("TO") > -1) {
627
+ return { status: "TIME_OUT", detail: "Time Out" };
628
+ }
629
+ return null;
630
+ }
631
+ }
632
+ });
633
+
634
+ // src/payment/responseHandler.js
635
+ var require_responseHandler = __commonJS({
636
+ "src/payment/responseHandler.js"(exports2, module2) {
637
+ var fs = require("fs");
638
+ var { Queue, Node } = require_queue();
639
+ var { sendMessage: sendMessage2 } = require_sendMessage();
640
+ var logger = require_winston()(module2);
641
+ var { requestCompletion } = require_httpRequest();
642
+ var {
643
+ statusParser,
644
+ logonParser,
645
+ netsPaymentParser,
646
+ creditPaymentParser,
647
+ jsonProcessor
648
+ } = require_parser();
649
+ var fw = require_manageConfig();
650
+ var { xorCalculation } = require_utils_helper();
651
+ var queue2 = new Queue();
652
+ module2.exports.terminalStatus = (ecn) => {
653
+ const length = queue2.size();
654
+ let fullHex = "";
655
+ for (let i = 0; i < length; i++) {
656
+ const node = queue2.dequeue();
657
+ fullHex += node.data.hex;
658
+ }
659
+ const status = statusParser(fullHex, ecn);
660
+ console.log(fullHex);
661
+ logger.log({
662
+ level: "info",
663
+ message: status
664
+ });
665
+ if (status) {
666
+ fw.updateConfig({ terminal_status: true });
667
+ sendMessage2("clientRoom", "STATUS_MESSAGE", {
668
+ success: true,
669
+ request: "status_scheck",
670
+ action: "COMPLETED"
671
+ });
672
+ } else {
673
+ fw.updateConfig({ terminal_status: false });
674
+ sendMessage2("clientRoom", "STATUS_MESSAGE", {
675
+ success: false,
676
+ request: "status_scheck",
677
+ action: "FAILED_TO_GET_THE_STATUS"
678
+ });
679
+ }
680
+ };
681
+ module2.exports.terminalLogon = (ecn) => {
682
+ const length = queue2.size();
683
+ let fullHex = "";
684
+ for (let i = 0; i < length; i++) {
685
+ const node = queue2.dequeue();
686
+ fullHex += node.data.hex;
687
+ }
688
+ console.log(fullHex);
689
+ const response = logonParser(fullHex, ecn);
690
+ if (response.status) {
691
+ fw.updateConfig({ last_logon: /* @__PURE__ */ new Date() });
692
+ sendMessage2("clientRoom", "LOGON_MESSAGE", {
693
+ success: true,
694
+ request: "logon",
695
+ action: "COMPLETED"
696
+ });
697
+ } else {
698
+ sendMessage2("clientRoom", "LOGON_MESSAGE", {
699
+ success: false,
700
+ request: "logon",
701
+ action: "FAILED_TO_LOGON"
702
+ });
703
+ }
704
+ };
705
+ module2.exports.fetchFullDetails = () => {
706
+ const length = queue2.size();
707
+ let fullHex = "";
708
+ for (let i = 0; i < length; i++) {
709
+ const node = queue2.dequeue();
710
+ fullHex += node.data.hex;
711
+ }
712
+ return fullHex;
713
+ };
714
+ module2.exports.terminalPayment = (hexValue, ecn) => {
715
+ const parsedValue = netsPaymentParser(hexValue, ecn);
716
+ const response = jsonProcessor(parsedValue);
717
+ if (response.translated) {
718
+ if (response.translated.status == "APPROVED") {
719
+ sendMessage2("clientRoom", "PAYMENT_MESSAGE", {
720
+ success: true,
721
+ response,
722
+ action: "COMPLETED"
723
+ });
724
+ }
725
+ if (response.translated.status == "TIME_OUT") {
726
+ sendMessage2("clientRoom", "PAYMENT_MESSAGE", {
727
+ success: true,
728
+ response,
729
+ action: "RETRY"
730
+ });
731
+ }
732
+ if (response.translated.status == "USER_CANCELLED" || response.translated.status == "OUT_OF_PAPER" || response.translated.status == "INVALID_CARD" || response.translated.status == "DECLINED" || response.translated.status == "CARD_NOT_SUPPORTED") {
733
+ sendMessage2("clientRoom", "PAYMENT_MESSAGE", {
734
+ success: true,
735
+ response,
736
+ action: "CANCELLED"
737
+ });
738
+ }
739
+ }
740
+ };
741
+ module2.exports.terminalCreditPayment = (hexValue, ecn) => {
742
+ const parsedValue = creditPaymentParser(hexValue, ecn);
743
+ const response = jsonProcessor(parsedValue);
744
+ if (response.translated) {
745
+ if (response.translated.status == "APPROVED") {
746
+ sendMessage2("clientRoom", "PAYMENT_MESSAGE", {
747
+ success: true,
748
+ response,
749
+ action: "COMPLETED"
750
+ });
751
+ }
752
+ if (response.translated.status == "TIME_OUT") {
753
+ sendMessage2("clientRoom", "PAYMENT_MESSAGE", {
754
+ success: true,
755
+ response,
756
+ action: "RETRY"
757
+ });
758
+ }
759
+ if (response.translated.status == "USER_CANCELLED" || response.translated.status == "OUT_OF_PAPER" || response.translated.status == "INVALID_CARD" || response.translated.status == "DECLINED" || response.translated.status == "CARD_NOT_SUPPORTED") {
760
+ sendMessage2("clientRoom", "PAYMENT_MESSAGE", {
761
+ success: true,
762
+ response,
763
+ action: "CANCELLED"
764
+ });
765
+ }
766
+ }
767
+ };
768
+ module2.exports.verifyParser = (hex, ecn, type) => {
769
+ if (type == "LOGON") {
770
+ return logonParser(hex, ecn);
771
+ }
772
+ if (type == "PAYMENT") {
773
+ const response = netsPaymentParser(hex, ecn);
774
+ return jsonProcessor(response);
775
+ }
776
+ if (type == "CREDIT_PAYMENT") {
777
+ const response = creditPaymentParser(hex, ecn);
778
+ return jsonProcessor(response);
779
+ }
780
+ };
781
+ module2.exports.requestParser = (data, request, ecn) => {
782
+ try {
783
+ const hexValue = data.toString("hex");
784
+ queue2.enqueue(new Node({ hex: hexValue, alpha: hexValue.toAsciiString() }));
785
+ } catch (e) {
786
+ }
787
+ };
788
+ module2.exports.checkLrc = (hexValue) => {
789
+ const value = hexValue.substring(2, hexValue.length - 2);
790
+ const xor = xorCalculation(value);
791
+ const lrcCheck = hexValue.substring(hexValue.length - 2, hexValue.length);
792
+ console.log(`LRC Check: ${xor} === ${lrcCheck}`);
793
+ return xor == lrcCheck;
794
+ };
795
+ }
796
+ });
797
+
798
+ // src/payment/communication.js
799
+ var require_communication = __commonJS({
800
+ "src/payment/communication.js"(exports2, module2) {
801
+ var { SerialPort, ReadlineParser } = require("serialport");
802
+ var {
803
+ generateStatusReq,
804
+ generateLogonRequest,
805
+ generatePaymentRequest
806
+ } = require_hexRequest();
807
+ var logger = require_winston()(module2);
808
+ var {
809
+ requestParser,
810
+ terminalPayment,
811
+ terminalCreditPayment,
812
+ terminalLogon,
813
+ terminalStatus,
814
+ fetchFullDetails,
815
+ checkLrc,
816
+ verifyParser
817
+ } = require_responseHandler();
818
+ var { sendMessage: sendMessage2 } = require_sendMessage();
819
+ var fw = require_manageConfig();
820
+ var { initialiseRequest } = require_httpRequest();
821
+ var requestType;
822
+ var calculated;
823
+ var isTimeOutset = false;
824
+ var MAX_COUNT = 3;
825
+ var WRONG_LRC_MAX_COUNT = 3;
826
+ var count;
827
+ var lrcCount;
828
+ var ackOrNack;
829
+ var requestPayload;
830
+ var ACK = Buffer.alloc(1, 6, "hex");
831
+ var NACK = Buffer.alloc(1, 21, "hex");
832
+ var config = fw.getConfig();
833
+ var triggerTimer = () => {
834
+ if (requestType == "STATUS_CHECK") {
835
+ setTimeout(() => {
836
+ isTimeOutset = false;
837
+ terminalStatus(calculated.ecn);
838
+ }, 3e3);
839
+ }
840
+ if (requestType == "LOGON") {
841
+ setTimeout(() => {
842
+ isTimeOutset = false;
843
+ terminalLogon(calculated.ecn);
844
+ }, 5e3);
845
+ }
846
+ if (requestType == "PAYMENT") {
847
+ setTimeout(() => {
848
+ isTimeOutset = false;
849
+ lrcCount--;
850
+ if (lrcCount >= 0) {
851
+ const hexValue = fetchFullDetails();
852
+ const lrcResponse = checkLrc(hexValue);
853
+ if (!lrcResponse) {
854
+ logger.log({
855
+ level: "info",
856
+ message: `Terminal send response data with wrong LRC, POS expected to send NACK`
857
+ });
858
+ global.port.write(NACK);
859
+ } else {
860
+ logger.log({
861
+ level: "info",
862
+ message: `Terminal resend response data with correct LRC, POS expected to send ACK`
863
+ });
864
+ global.port.write(ACK);
865
+ terminalPayment(hexValue, calculated.ecn);
866
+ }
867
+ } else {
868
+ sendMessage2("clientRoom", "PAYMENT_MESSAGE", {
869
+ success: true,
870
+ action: "APPROVED_FLAGGED"
871
+ });
872
+ }
873
+ }, 8e3);
874
+ }
875
+ if (requestType === "CREDIT_PAYMENT") {
876
+ setTimeout(() => {
877
+ isTimeOutset = false;
878
+ const hexValue = fetchFullDetails();
879
+ const lrcResponse = checkLrc(hexValue);
880
+ if (!lrcResponse) {
881
+ global.port.write(NACK);
882
+ } else {
883
+ global.port.write(ACK);
884
+ terminalCreditPayment(hexValue, calculated.ecn);
885
+ }
886
+ }, 8e3);
887
+ }
888
+ };
889
+ module2.exports.reset = () => {
890
+ count = MAX_COUNT;
891
+ lrcCount = WRONG_LRC_MAX_COUNT;
892
+ ackOrNack = null;
893
+ };
894
+ module2.exports.checkACKorNACK = () => {
895
+ setTimeout(() => {
896
+ if (ackOrNack == null) {
897
+ count--;
898
+ if (count >= 0) {
899
+ logger.log({
900
+ level: "info",
901
+ message: `POS send Purchase command, Terminal doesn't send any reply`
902
+ });
903
+ resendData();
904
+ } else {
905
+ sendMessage2("clientRoom", "PAYMENT_MESSAGE", {
906
+ success: true,
907
+ action: "TERMINAL_ERROR"
908
+ });
909
+ }
910
+ }
911
+ }, 2e3);
912
+ };
913
+ var resendData = () => {
914
+ if (requestType == "STATUS_CHECK") {
915
+ calculated = generateStatusReq();
916
+ }
917
+ if (requestType == "LOGON") {
918
+ calculated = generateLogonRequest();
919
+ }
920
+ if (requestType == "PAYMENT" || requestType === "CREDIT_PAYMENT") {
921
+ calculated = generatePaymentRequest(requestPayload);
922
+ }
923
+ global.port.write(calculated.buffer);
924
+ exports2.checkACKorNACK();
925
+ };
926
+ module2.exports.initialize = async () => {
927
+ if (!config.terminal || config.terminal === "enable") {
928
+ global.port = new SerialPort({
929
+ path: config.simulation ? config.simulationPort : config.com,
930
+ baudRate: 9600,
931
+ dataBits: 8,
932
+ stopBits: 1,
933
+ parity: "none"
934
+ });
935
+ global.port.on("data", (data) => {
936
+ console.log(data);
937
+ if (data.toString("hex").length == 2 && data.toString("hex") == "15") {
938
+ count--;
939
+ ackOrNack = data;
940
+ if (count >= 0) {
941
+ logger.log({
942
+ level: "info",
943
+ message: `POS send Purchase command, Terminal reply NACK`
944
+ });
945
+ resendData();
946
+ } else {
947
+ sendMessage2("clientRoom", "PAYMENT_MESSAGE", {
948
+ success: true,
949
+ action: "TERMINAL_ERROR"
950
+ });
951
+ return;
952
+ }
953
+ } else if (data.toString("hex").length == 2 && data.toString("hex") == "06") {
954
+ ackOrNack = data;
955
+ } else if (data.length > 2) {
956
+ global.port.write(ACK);
957
+ if (!isTimeOutset) {
958
+ isTimeOutset = true;
959
+ triggerTimer();
960
+ }
961
+ requestParser(data, requestType, calculated?.ecn);
962
+ }
963
+ });
964
+ }
965
+ };
966
+ module2.exports.sentToTerminal = (type, body) => {
967
+ requestType = type;
968
+ requestPayload = body;
969
+ if (requestType == "STATUS_CHECK") {
970
+ calculated = generateStatusReq();
971
+ global.port.write(calculated.buffer);
972
+ }
973
+ if (requestType == "LOGON") {
974
+ calculated = generateLogonRequest();
975
+ global.port.write(calculated.buffer);
976
+ }
977
+ if (requestType == "PAYMENT" || requestType == "CREDIT_PAYMENT") {
978
+ exports2.reset();
979
+ calculated = generatePaymentRequest(body);
980
+ console.log(calculated);
981
+ global.port.write(calculated.buffer);
982
+ exports2.checkACKorNACK();
983
+ }
984
+ };
985
+ }
986
+ });
987
+
988
+ // src/index.js
989
+ var utilsHelper = require_utils_helper();
990
+ var winston = require_winston();
991
+ var manageConfig = require_manageConfig();
992
+ var queue = require_queue();
993
+ var sendMessage = require_sendMessage();
994
+ var communication = require_communication();
995
+ var hexRequest = require_hexRequest();
996
+ var httpRequest = require_httpRequest();
997
+ var parser = require_parser();
998
+ var responseHandler = require_responseHandler();
999
+ module.exports = {
1000
+ ...utilsHelper,
1001
+ logger: winston,
1002
+ manageConfig,
1003
+ queue,
1004
+ sendMessage,
1005
+ communication,
1006
+ hexRequest,
1007
+ httpRequest,
1008
+ parser,
1009
+ responseHandler
1010
+ };
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../index.js"],"sourcesContent":["const utilsHelper = require('./src/utils.helper');\nconst winston = require('./src/winston');\nconst manageConfig = require('./src/manageConfig');\nconst queue = require('./src/queue');\nconst sendMessage = require('./src/sendMessage');\nconst communication = require('./src/payment/communication');\nconst hexRequest = require('./src/payment/hexRequest');\nconst httpRequest = require('./src/payment/httpRequest');\nconst parser = require('./src/payment/parser');\nconst responseHandler = require('./src/payment/responseHandler');\n\nmodule.exports = {\n ...utilsHelper,\n logger: winston,\n manageConfig,\n queue,\n sendMessage,\n communication,\n hexRequest,\n httpRequest,\n parser,\n responseHandler\n};\n"],"names":["utilsHelper","require","winston","manageConfig","queue","sendMessage","communication","hexRequest","httpRequest","parser","responseHandler","module","exports","_extends","logger"],"mappings":"wNAAA,IAAMA,EAAcC,QAAQ,sBACtBC,EAAUD,QAAQ,iBAClBE,EAAeF,QAAQ,sBACvBG,EAAQH,QAAQ,eAChBI,EAAcJ,QAAQ,qBACtBK,EAAgBL,QAAQ,+BACxBM,EAAaN,QAAQ,4BACrBO,EAAcP,QAAQ,6BACtBQ,EAASR,QAAQ,wBACjBS,EAAkBT,QAAQ,iCAEhCU,OAAOC,QAAOC,EAAA,CAAA,EACPb,EAAW,CACdc,OAAQZ,EACRC,aAAAA,EACAC,MAAAA,EACAC,YAAAA,EACAC,cAAAA,EACAC,WAAAA,EACAC,YAAAA,EACAC,OAAAA,EACAC,gBAAAA"}
1
+ {"version":3,"file":"index.js","sources":["../src/index.js"],"sourcesContent":["const utilsHelper = require('./utils.helper');\nconst winston = require('./winston');\nconst manageConfig = require('./manageConfig');\nconst queue = require('./queue');\nconst sendMessage = require('./sendMessage');\nconst communication = require('./payment/communication');\nconst hexRequest = require('./payment/hexRequest');\nconst httpRequest = require('./payment/httpRequest');\nconst parser = require('./payment/parser');\nconst responseHandler = require('./payment/responseHandler');\n\nmodule.exports = {\n ...utilsHelper,\n logger: winston,\n manageConfig,\n queue,\n sendMessage,\n communication,\n hexRequest,\n httpRequest,\n parser,\n responseHandler\n};\n"],"names":["utilsHelper","require","winston","manageConfig","queue","sendMessage","communication","hexRequest","httpRequest","parser","responseHandler","module","exports","_extends","logger"],"mappings":"wNAAA,IAAMA,EAAcC,QAAQ,kBACtBC,EAAUD,QAAQ,aAClBE,EAAeF,QAAQ,kBACvBG,EAAQH,QAAQ,WAChBI,EAAcJ,QAAQ,iBACtBK,EAAgBL,QAAQ,2BACxBM,EAAaN,QAAQ,wBACrBO,EAAcP,QAAQ,yBACtBQ,EAASR,QAAQ,oBACjBS,EAAkBT,QAAQ,6BAEhCU,OAAOC,QAAOC,EAAA,CAAA,EACPb,EAAW,CACdc,OAAQZ,EACRC,aAAAA,EACAC,MAAAA,EACAC,YAAAA,EACAC,cAAAA,EACAC,WAAAA,EACAC,YAAAA,EACAC,OAAAA,EACAC,gBAAAA"}
@@ -1,2 +1,2 @@
1
- function e(){return e=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var s in n)({}).hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},e.apply(null,arguments)}const r=require("./src/utils.helper"),n=require("./src/winston"),s=require("./src/manageConfig"),t=require("./src/queue"),u=require("./src/sendMessage"),a=require("./src/payment/communication"),i=require("./src/payment/hexRequest"),c=require("./src/payment/httpRequest"),o=require("./src/payment/parser"),p=require("./src/payment/responseHandler");module.exports=e({},r,{logger:n,manageConfig:s,queue:t,sendMessage:u,communication:a,hexRequest:i,httpRequest:c,parser:o,responseHandler:p});
1
+ function e(){return e=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var t in n)({}).hasOwnProperty.call(n,t)&&(e[t]=n[t])}return e},e.apply(null,arguments)}const r=require("./utils.helper"),n=require("./winston"),t=require("./manageConfig"),u=require("./queue"),a=require("./sendMessage"),s=require("./payment/communication"),i=require("./payment/hexRequest"),o=require("./payment/httpRequest"),p=require("./payment/parser"),q=require("./payment/responseHandler");module.exports=e({},r,{logger:n,manageConfig:t,queue:u,sendMessage:a,communication:s,hexRequest:i,httpRequest:o,parser:p,responseHandler:q});
2
2
  //# sourceMappingURL=index.modern.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.modern.mjs","sources":["../index.js"],"sourcesContent":["const utilsHelper = require('./src/utils.helper');\nconst winston = require('./src/winston');\nconst manageConfig = require('./src/manageConfig');\nconst queue = require('./src/queue');\nconst sendMessage = require('./src/sendMessage');\nconst communication = require('./src/payment/communication');\nconst hexRequest = require('./src/payment/hexRequest');\nconst httpRequest = require('./src/payment/httpRequest');\nconst parser = require('./src/payment/parser');\nconst responseHandler = require('./src/payment/responseHandler');\n\nmodule.exports = {\n ...utilsHelper,\n logger: winston,\n manageConfig,\n queue,\n sendMessage,\n communication,\n hexRequest,\n httpRequest,\n parser,\n responseHandler\n};\n"],"names":["utilsHelper","require","winston","manageConfig","queue","sendMessage","communication","hexRequest","httpRequest","parser","responseHandler","module","exports","_extends","logger"],"mappings":"wNAAA,MAAMA,EAAcC,QAAQ,sBACtBC,EAAUD,QAAQ,iBAClBE,EAAeF,QAAQ,sBACvBG,EAAQH,QAAQ,eAChBI,EAAcJ,QAAQ,qBACtBK,EAAgBL,QAAQ,+BACxBM,EAAaN,QAAQ,4BACrBO,EAAcP,QAAQ,6BACtBQ,EAASR,QAAQ,wBACjBS,EAAkBT,QAAQ,iCAEhCU,OAAOC,QAAOC,EAAA,CAAA,EACPb,EAAW,CACdc,OAAQZ,EACRC,eACAC,QACAC,cACAC,gBACAC,aACAC,cACAC,SACAC"}
1
+ {"version":3,"file":"index.modern.mjs","sources":["../src/index.js"],"sourcesContent":["const utilsHelper = require('./utils.helper');\nconst winston = require('./winston');\nconst manageConfig = require('./manageConfig');\nconst queue = require('./queue');\nconst sendMessage = require('./sendMessage');\nconst communication = require('./payment/communication');\nconst hexRequest = require('./payment/hexRequest');\nconst httpRequest = require('./payment/httpRequest');\nconst parser = require('./payment/parser');\nconst responseHandler = require('./payment/responseHandler');\n\nmodule.exports = {\n ...utilsHelper,\n logger: winston,\n manageConfig,\n queue,\n sendMessage,\n communication,\n hexRequest,\n httpRequest,\n parser,\n responseHandler\n};\n"],"names":["utilsHelper","require","winston","manageConfig","queue","sendMessage","communication","hexRequest","httpRequest","parser","responseHandler","module","exports","_extends","logger"],"mappings":"wNAAA,MAAMA,EAAcC,QAAQ,kBACtBC,EAAUD,QAAQ,aAClBE,EAAeF,QAAQ,kBACvBG,EAAQH,QAAQ,WAChBI,EAAcJ,QAAQ,iBACtBK,EAAgBL,QAAQ,2BACxBM,EAAaN,QAAQ,wBACrBO,EAAcP,QAAQ,yBACtBQ,EAASR,QAAQ,oBACjBS,EAAkBT,QAAQ,6BAEhCU,OAAOC,QAAOC,EAAA,CAAA,EACPb,EAAW,CACdc,OAAQZ,EACRC,eACAC,QACAC,cACAC,gBACAC,aACAC,cACAC,SACAC"}
@@ -1,2 +1,2 @@
1
- function e(){return e=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var s in n)({}).hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},e.apply(null,arguments)}var r=require("./src/utils.helper"),n=require("./src/winston"),s=require("./src/manageConfig"),u=require("./src/queue"),a=require("./src/sendMessage"),t=require("./src/payment/communication"),i=require("./src/payment/hexRequest"),c=require("./src/payment/httpRequest"),o=require("./src/payment/parser"),p=require("./src/payment/responseHandler");module.exports=e({},r,{logger:n,manageConfig:s,queue:u,sendMessage:a,communication:t,hexRequest:i,httpRequest:c,parser:o,responseHandler:p});
1
+ function e(){return e=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var u in n)({}).hasOwnProperty.call(n,u)&&(e[u]=n[u])}return e},e.apply(null,arguments)}var r=require("./utils.helper"),n=require("./winston"),u=require("./manageConfig"),a=require("./queue"),t=require("./sendMessage"),i=require("./payment/communication"),s=require("./payment/hexRequest"),o=require("./payment/httpRequest"),p=require("./payment/parser"),q=require("./payment/responseHandler");module.exports=e({},r,{logger:n,manageConfig:u,queue:a,sendMessage:t,communication:i,hexRequest:s,httpRequest:o,parser:p,responseHandler:q});
2
2
  //# sourceMappingURL=index.module.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.module.js","sources":["../index.js"],"sourcesContent":["const utilsHelper = require('./src/utils.helper');\nconst winston = require('./src/winston');\nconst manageConfig = require('./src/manageConfig');\nconst queue = require('./src/queue');\nconst sendMessage = require('./src/sendMessage');\nconst communication = require('./src/payment/communication');\nconst hexRequest = require('./src/payment/hexRequest');\nconst httpRequest = require('./src/payment/httpRequest');\nconst parser = require('./src/payment/parser');\nconst responseHandler = require('./src/payment/responseHandler');\n\nmodule.exports = {\n ...utilsHelper,\n logger: winston,\n manageConfig,\n queue,\n sendMessage,\n communication,\n hexRequest,\n httpRequest,\n parser,\n responseHandler\n};\n"],"names":["utilsHelper","require","winston","manageConfig","queue","sendMessage","communication","hexRequest","httpRequest","parser","responseHandler","module","exports","_extends","logger"],"mappings":"wNAAA,IAAMA,EAAcC,QAAQ,sBACtBC,EAAUD,QAAQ,iBAClBE,EAAeF,QAAQ,sBACvBG,EAAQH,QAAQ,eAChBI,EAAcJ,QAAQ,qBACtBK,EAAgBL,QAAQ,+BACxBM,EAAaN,QAAQ,4BACrBO,EAAcP,QAAQ,6BACtBQ,EAASR,QAAQ,wBACjBS,EAAkBT,QAAQ,iCAEhCU,OAAOC,QAAOC,EAAA,CAAA,EACPb,EAAW,CACdc,OAAQZ,EACRC,aAAAA,EACAC,MAAAA,EACAC,YAAAA,EACAC,cAAAA,EACAC,WAAAA,EACAC,YAAAA,EACAC,OAAAA,EACAC,gBAAAA"}
1
+ {"version":3,"file":"index.module.js","sources":["../src/index.js"],"sourcesContent":["const utilsHelper = require('./utils.helper');\nconst winston = require('./winston');\nconst manageConfig = require('./manageConfig');\nconst queue = require('./queue');\nconst sendMessage = require('./sendMessage');\nconst communication = require('./payment/communication');\nconst hexRequest = require('./payment/hexRequest');\nconst httpRequest = require('./payment/httpRequest');\nconst parser = require('./payment/parser');\nconst responseHandler = require('./payment/responseHandler');\n\nmodule.exports = {\n ...utilsHelper,\n logger: winston,\n manageConfig,\n queue,\n sendMessage,\n communication,\n hexRequest,\n httpRequest,\n parser,\n responseHandler\n};\n"],"names":["utilsHelper","require","winston","manageConfig","queue","sendMessage","communication","hexRequest","httpRequest","parser","responseHandler","module","exports","_extends","logger"],"mappings":"wNAAA,IAAMA,EAAcC,QAAQ,kBACtBC,EAAUD,QAAQ,aAClBE,EAAeF,QAAQ,kBACvBG,EAAQH,QAAQ,WAChBI,EAAcJ,QAAQ,iBACtBK,EAAgBL,QAAQ,2BACxBM,EAAaN,QAAQ,wBACrBO,EAAcP,QAAQ,yBACtBQ,EAASR,QAAQ,oBACjBS,EAAkBT,QAAQ,6BAEhCU,OAAOC,QAAOC,EAAA,CAAA,EACPb,EAAW,CACdc,OAAQZ,EACRC,aAAAA,EACAC,MAAAA,EACAC,YAAAA,EACAC,cAAAA,EACAC,WAAAA,EACAC,YAAAA,EACAC,OAAAA,EACAC,gBAAAA"}
package/dist/index.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){function e(){return e=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var n=arguments[r];for(var s in n)({}).hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},e.apply(null,arguments)}var r=require("./src/utils.helper"),n=require("./src/winston"),s=require("./src/manageConfig"),i=require("./src/queue"),t=require("./src/sendMessage"),u=require("./src/payment/communication"),a=require("./src/payment/hexRequest"),c=require("./src/payment/httpRequest"),o=require("./src/payment/parser"),p=require("./src/payment/responseHandler");module.exports=e({},r,{logger:n,manageConfig:s,queue:i,sendMessage:t,communication:u,hexRequest:a,httpRequest:c,parser:o,responseHandler:p})});
1
+ !function(e){"function"==typeof define&&define.amd?define(e):e()}(function(){function e(){return e=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var i in r)({}).hasOwnProperty.call(r,i)&&(e[i]=r[i])}return e},e.apply(null,arguments)}var n=require("./utils.helper"),r=require("./winston"),i=require("./manageConfig"),t=require("./queue"),u=require("./sendMessage"),a=require("./payment/communication"),s=require("./payment/hexRequest"),o=require("./payment/httpRequest"),p=require("./payment/parser"),q=require("./payment/responseHandler");module.exports=e({},n,{logger:r,manageConfig:i,queue:t,sendMessage:u,communication:a,hexRequest:s,httpRequest:o,parser:p,responseHandler:q})});
2
2
  //# sourceMappingURL=index.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.umd.js","sources":["../index.js"],"sourcesContent":["const utilsHelper = require('./src/utils.helper');\nconst winston = require('./src/winston');\nconst manageConfig = require('./src/manageConfig');\nconst queue = require('./src/queue');\nconst sendMessage = require('./src/sendMessage');\nconst communication = require('./src/payment/communication');\nconst hexRequest = require('./src/payment/hexRequest');\nconst httpRequest = require('./src/payment/httpRequest');\nconst parser = require('./src/payment/parser');\nconst responseHandler = require('./src/payment/responseHandler');\n\nmodule.exports = {\n ...utilsHelper,\n logger: winston,\n manageConfig,\n queue,\n sendMessage,\n communication,\n hexRequest,\n httpRequest,\n parser,\n responseHandler\n};\n"],"names":["utilsHelper","require","winston","manageConfig","queue","sendMessage","communication","hexRequest","httpRequest","parser","responseHandler","module","exports","_extends","logger"],"mappings":"qSAAA,IAAMA,EAAcC,QAAQ,sBACtBC,EAAUD,QAAQ,iBAClBE,EAAeF,QAAQ,sBACvBG,EAAQH,QAAQ,eAChBI,EAAcJ,QAAQ,qBACtBK,EAAgBL,QAAQ,+BACxBM,EAAaN,QAAQ,4BACrBO,EAAcP,QAAQ,6BACtBQ,EAASR,QAAQ,wBACjBS,EAAkBT,QAAQ,iCAEhCU,OAAOC,QAAOC,EAAA,CAAA,EACPb,EAAW,CACdc,OAAQZ,EACRC,aAAAA,EACAC,MAAAA,EACAC,YAAAA,EACAC,cAAAA,EACAC,WAAAA,EACAC,YAAAA,EACAC,OAAAA,EACAC,gBAAAA"}
1
+ {"version":3,"file":"index.umd.js","sources":["../src/index.js"],"sourcesContent":["const utilsHelper = require('./utils.helper');\nconst winston = require('./winston');\nconst manageConfig = require('./manageConfig');\nconst queue = require('./queue');\nconst sendMessage = require('./sendMessage');\nconst communication = require('./payment/communication');\nconst hexRequest = require('./payment/hexRequest');\nconst httpRequest = require('./payment/httpRequest');\nconst parser = require('./payment/parser');\nconst responseHandler = require('./payment/responseHandler');\n\nmodule.exports = {\n ...utilsHelper,\n logger: winston,\n manageConfig,\n queue,\n sendMessage,\n communication,\n hexRequest,\n httpRequest,\n parser,\n responseHandler\n};\n"],"names":["utilsHelper","require","winston","manageConfig","queue","sendMessage","communication","hexRequest","httpRequest","parser","responseHandler","module","exports","_extends","logger"],"mappings":"qSAAA,IAAMA,EAAcC,QAAQ,kBACtBC,EAAUD,QAAQ,aAClBE,EAAeF,QAAQ,kBACvBG,EAAQH,QAAQ,WAChBI,EAAcJ,QAAQ,iBACtBK,EAAgBL,QAAQ,2BACxBM,EAAaN,QAAQ,wBACrBO,EAAcP,QAAQ,yBACtBQ,EAASR,QAAQ,oBACjBS,EAAkBT,QAAQ,6BAEhCU,OAAOC,QAAOC,EAAA,CAAA,EACPb,EAAW,CACdc,OAAQZ,EACRC,aAAAA,EACAC,MAAAA,EACAC,YAAAA,EACAC,cAAAA,EACAC,WAAAA,EACAC,YAAAA,EACAC,OAAAA,EACAC,gBAAAA"}
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "nets-service-sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.2",
4
4
  "description": "Utility functions for Nets Service",
5
- "source": "index.js",
5
+ "source": "src/index.js",
6
6
  "main": "dist/index.js",
7
7
  "module": "dist/index.module.js",
8
8
  "unpkg": "dist/index.umd.js",
9
9
  "scripts": {
10
- "build": "microbundle",
10
+ "build": "esbuild src/index.js --bundle --platform=node --packages=external --outfile=dist/index.js",
11
11
  "watch": "microbundle watch",
12
12
  "test": "echo \"Error: no test specified\" && exit 1"
13
13
  },
@@ -27,6 +27,7 @@
27
27
  "winston": "^3.8.2"
28
28
  },
29
29
  "devDependencies": {
30
+ "esbuild": "^0.27.0",
30
31
  "microbundle": "^0.15.1"
31
32
  }
32
33
  }