@houlak/plexo-sdk 0.1.62 → 0.1.65
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/lib/handler/PlexoHandler.js +8 -1
- package/lib/sdk/PaymentGatewayClient.js +2 -2
- package/lib/sdk/helpers/signature/signatureHelper.js +11 -8
- package/lib/sdk/helpers/signature/signatureUtils.js +3 -3
- package/lib/sdk/models/Authorization.d.ts +1 -1
- package/lib/utils/boolean.utils.d.ts +4 -0
- package/lib/utils/boolean.utils.js +53 -0
- package/package.json +1 -1
|
@@ -304,7 +304,14 @@ var Purchase = function (purchase) { return __awaiter(void 0, void 0, void 0, fu
|
|
|
304
304
|
case 0: return [4 /*yield*/, paymentGatewayClient.PurchaseAsync(purchase)];
|
|
305
305
|
case 1:
|
|
306
306
|
purchaseResponse = _a.sent();
|
|
307
|
-
return [2 /*return*/, evaluator_service_1.Evaluator.
|
|
307
|
+
return [2 /*return*/, evaluator_service_1.Evaluator.genericEvaluator(purchase, purchaseResponse)
|
|
308
|
+
/*return Evaluator.transactionEvaluator(
|
|
309
|
+
purchase,
|
|
310
|
+
purchaseResponse,
|
|
311
|
+
'Purchase',
|
|
312
|
+
TransactionType.Purchase,
|
|
313
|
+
)*/
|
|
314
|
+
];
|
|
308
315
|
}
|
|
309
316
|
});
|
|
310
317
|
}); };
|
|
@@ -74,8 +74,8 @@ var requestToPlexo = function (endpoint, request) { return __awaiter(void 0, voi
|
|
|
74
74
|
return [4 /*yield*/, signatureHelper_1.SignatureHelper.signRequest(stateObject)];
|
|
75
75
|
case 1:
|
|
76
76
|
signedClientRequest = _a.sent();
|
|
77
|
-
logger_lib_1.default.debug("URL PX
|
|
78
|
-
logger_lib_1.default.debug(
|
|
77
|
+
logger_lib_1.default.debug("URL PX: ".concat(endpoint));
|
|
78
|
+
logger_lib_1.default.debug(signedClientRequest, 'Signed client request');
|
|
79
79
|
return [4 /*yield*/, client.post(endpoint, __assign({}, signedClientRequest))];
|
|
80
80
|
case 2:
|
|
81
81
|
data = (_a.sent()).data;
|
|
@@ -39,16 +39,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.SignatureHelper = void 0;
|
|
40
40
|
var axios_1 = require("axios");
|
|
41
41
|
var crypto_1 = require("crypto");
|
|
42
|
-
var logger_lib_1 = require("../../../lib/logger.lib");
|
|
43
|
-
var config_1 = require("../../../config/config");
|
|
44
42
|
var __1 = require("../..");
|
|
43
|
+
var config_1 = require("../../../config/config");
|
|
44
|
+
var logger_lib_1 = require("../../../lib/logger.lib");
|
|
45
45
|
var utils_1 = require("../../../utils");
|
|
46
|
+
var boolean_utils_1 = require("../../../utils/boolean.utils");
|
|
46
47
|
var signatureUtils_1 = require("./signatureUtils");
|
|
47
48
|
var client = axios_1.default.create({
|
|
48
49
|
baseURL: config_1.config.plexoUrl,
|
|
49
50
|
});
|
|
50
51
|
var signRequest = function (objectToSign) { return __awaiter(void 0, void 0, void 0, function () {
|
|
51
|
-
var cert, privateKey, stringifiedCert, signedObject, thumbnail, canonizedObject, objectoToPascalKeys, signKey;
|
|
52
|
+
var cert, privateKey, stringifiedCert, signedObject, thumbnail, canonizedObject, objectoToPascalKeys, objectWithStringBooleans, signKey;
|
|
52
53
|
return __generator(this, function (_a) {
|
|
53
54
|
switch (_a.label) {
|
|
54
55
|
case 0: return [4 /*yield*/, signatureUtils_1.signatureUtils.getCertificate()];
|
|
@@ -71,10 +72,11 @@ var signRequest = function (objectToSign) { return __awaiter(void 0, void 0, voi
|
|
|
71
72
|
objectToSign.fingerprint = thumbnail;
|
|
72
73
|
canonizedObject = signatureUtils_1.signatureUtils.canonizeJson(objectToSign);
|
|
73
74
|
objectoToPascalKeys = utils_1.caseUtils.toPascalKeys(canonizedObject);
|
|
74
|
-
|
|
75
|
-
signKey = signatureUtils_1.signatureUtils.generateSignature(
|
|
75
|
+
objectWithStringBooleans = boolean_utils_1.booleanUtils.stringifyBooleans(objectoToPascalKeys);
|
|
76
|
+
signKey = signatureUtils_1.signatureUtils.generateSignature(objectWithStringBooleans, privateKey);
|
|
77
|
+
logger_lib_1.default.debug(objectWithStringBooleans, 'Object to sign');
|
|
76
78
|
signedObject.signature = signKey;
|
|
77
|
-
signedObject.object =
|
|
79
|
+
signedObject.object = objectWithStringBooleans;
|
|
78
80
|
return [2 /*return*/, signedObject];
|
|
79
81
|
}
|
|
80
82
|
});
|
|
@@ -94,7 +96,7 @@ var getPlexoKey = function (fingerprint) { return __awaiter(void 0, void 0, void
|
|
|
94
96
|
});
|
|
95
97
|
}); };
|
|
96
98
|
var unwrapCallback = function (fingerprint, response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
97
|
-
var serverResponse, plexoResponse, err_1, certificate, key, canonizedObject, objectInPascalCase, objectSorted, objectBuffer, verifySignature;
|
|
99
|
+
var serverResponse, plexoResponse, err_1, certificate, key, canonizedObject, objectInPascalCase, objectWithStringBooleans, objectSorted, objectBuffer, verifySignature;
|
|
98
100
|
return __generator(this, function (_a) {
|
|
99
101
|
switch (_a.label) {
|
|
100
102
|
case 0:
|
|
@@ -120,7 +122,8 @@ var unwrapCallback = function (fingerprint, response) { return __awaiter(void 0,
|
|
|
120
122
|
'creditLimits',
|
|
121
123
|
]);
|
|
122
124
|
objectInPascalCase = utils_1.caseUtils.toPascalKeys(canonizedObject);
|
|
123
|
-
|
|
125
|
+
objectWithStringBooleans = boolean_utils_1.booleanUtils.stringifyBooleans(objectInPascalCase);
|
|
126
|
+
objectSorted = signatureUtils_1.signatureUtils.sortObject(objectWithStringBooleans);
|
|
124
127
|
objectBuffer = Buffer.from(JSON.stringify(objectSorted));
|
|
125
128
|
verifySignature = (0, crypto_1.createVerify)('SHA512')
|
|
126
129
|
.update(objectBuffer)
|
|
@@ -37,12 +37,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.signatureUtils = void 0;
|
|
40
|
+
var crypto_1 = require("crypto");
|
|
40
41
|
var fs = require("fs");
|
|
41
42
|
var pem = require("pem");
|
|
42
|
-
var crypto_1 = require("crypto");
|
|
43
43
|
var util_1 = require("util");
|
|
44
|
-
var logger_lib_1 = require("../../../lib/logger.lib");
|
|
45
44
|
var config_1 = require("../../../config/config");
|
|
45
|
+
var logger_lib_1 = require("../../../lib/logger.lib");
|
|
46
46
|
var stringifyWithFloats_1 = require("./stringifyWithFloats");
|
|
47
47
|
var canonizeJson = function (object, keysToSkip) {
|
|
48
48
|
var cleanObject = deleteObjectUndefined(object, keysToSkip);
|
|
@@ -142,7 +142,7 @@ var getCertificate = function () { return __awaiter(void 0, void 0, void 0, func
|
|
|
142
142
|
}); };
|
|
143
143
|
var generateSignature = function (object, privateKey) {
|
|
144
144
|
var canonizedString = (0, stringifyWithFloats_1.stringifyAmountsWithFloats)(object);
|
|
145
|
-
logger_lib_1.default.debug('
|
|
145
|
+
logger_lib_1.default.debug(canonizedString, 'String to sign');
|
|
146
146
|
var canonizedStringEncoded = new util_1.TextEncoder().encode(canonizedString);
|
|
147
147
|
var signKey = (0, crypto_1.sign)('SHA512', canonizedStringEncoded, privateKey).toString('base64');
|
|
148
148
|
return signKey;
|
|
@@ -8,7 +8,7 @@ export declare class Authorization extends AuthorizationInfo {
|
|
|
8
8
|
redirectUri: string;
|
|
9
9
|
limitIssuers: string[];
|
|
10
10
|
optionalCommerceId: number;
|
|
11
|
-
webFormSettings
|
|
11
|
+
webFormSettings?: WebFormSettings;
|
|
12
12
|
doNotUseCallback?: boolean;
|
|
13
13
|
clientInformation?: any;
|
|
14
14
|
optionalMetadata?: string;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.booleanUtils = void 0;
|
|
4
|
+
var signatureUtils_1 = require("../sdk/helpers/signature/signatureUtils");
|
|
5
|
+
var booleanValues = [
|
|
6
|
+
'CrossBankTransfers'
|
|
7
|
+
];
|
|
8
|
+
var stringifyBooleans = function (object) {
|
|
9
|
+
booleanValues.forEach(function (word) {
|
|
10
|
+
if (JSON.stringify(object).includes(word)) {
|
|
11
|
+
substituteValueRecursively(object, word, true);
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
return object;
|
|
15
|
+
};
|
|
16
|
+
var substituteValueRecursively = function (object, specialWord, toString) {
|
|
17
|
+
if (object && typeof object === 'object') {
|
|
18
|
+
Object.keys(object).map(function (key) {
|
|
19
|
+
if (key === specialWord) {
|
|
20
|
+
if (toString)
|
|
21
|
+
if (object[key] === true) {
|
|
22
|
+
object[key] = 'True';
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
object[key] = 'False';
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
if (object[key] === 'True') {
|
|
29
|
+
object[key] = true;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
object[key] = false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
if (typeof object[key] === 'object') {
|
|
37
|
+
substituteValueRecursively(object[key], specialWord, toString);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var booleanizeStrings = function (object) {
|
|
43
|
+
booleanValues.forEach(function (specialWord) {
|
|
44
|
+
if (JSON.stringify(object).includes(specialWord)) {
|
|
45
|
+
substituteValueRecursively(object, specialWord, false);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return signatureUtils_1.signatureUtils.sortObject(object);
|
|
49
|
+
};
|
|
50
|
+
exports.booleanUtils = {
|
|
51
|
+
stringifyBooleans: stringifyBooleans,
|
|
52
|
+
booleanizeStrings: booleanizeStrings,
|
|
53
|
+
};
|