@houlak/plexo-sdk 0.1.42 → 0.1.44
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.
|
@@ -44,6 +44,7 @@ var config_1 = require("../../../config/config");
|
|
|
44
44
|
var __1 = require("../..");
|
|
45
45
|
var utils_1 = require("../../../utils");
|
|
46
46
|
var signatureUtils_1 = require("./signatureUtils");
|
|
47
|
+
var stringifyWithFloats_1 = require("./stringifyWithFloats");
|
|
47
48
|
var client = axios_1.default.create({
|
|
48
49
|
baseURL: config_1.config.plexoUrl,
|
|
49
50
|
});
|
|
@@ -93,7 +94,7 @@ var getPlexoKey = function (fingerprint) { return __awaiter(void 0, void 0, void
|
|
|
93
94
|
});
|
|
94
95
|
}); };
|
|
95
96
|
var unwrapCallback = function (fingerprint, response) { return __awaiter(void 0, void 0, void 0, function () {
|
|
96
|
-
var serverResponse, plexoResponse, err_1, certificate, key, canonizedObject, objectInPascalCase, objectSorted, objectBuffer, verifySignature;
|
|
97
|
+
var serverResponse, plexoResponse, err_1, certificate, key, canonizedObject, objectInPascalCase, objectSorted, objectWithAmounts, objectBuffer, verifySignature;
|
|
97
98
|
return __generator(this, function (_a) {
|
|
98
99
|
switch (_a.label) {
|
|
99
100
|
case 0:
|
|
@@ -122,8 +123,9 @@ var unwrapCallback = function (fingerprint, response) { return __awaiter(void 0,
|
|
|
122
123
|
logger_lib_1.default.info(canonizedObject, 'Objeto canonizado');
|
|
123
124
|
objectInPascalCase = utils_1.caseUtils.toPascalKeys(canonizedObject);
|
|
124
125
|
objectSorted = signatureUtils_1.signatureUtils.sortObject(objectInPascalCase);
|
|
125
|
-
|
|
126
|
-
|
|
126
|
+
objectWithAmounts = (0, stringifyWithFloats_1.stringifyAmountsWithFloats)(objectSorted);
|
|
127
|
+
logger_lib_1.default.info(objectWithAmounts, 'Objeto a verificar');
|
|
128
|
+
objectBuffer = Buffer.from(JSON.stringify(objectWithAmounts));
|
|
127
129
|
verifySignature = (0, crypto_1.createVerify)('SHA512')
|
|
128
130
|
.update(objectBuffer)
|
|
129
131
|
.verify(key, response.signature, 'base64');
|
|
@@ -62,10 +62,12 @@ var stringifyAmountsWithFloats = function (object) {
|
|
|
62
62
|
billedAmount: 'float',
|
|
63
63
|
taxedAmount: 'float',
|
|
64
64
|
vatAmount: 'float',
|
|
65
|
+
returnAmount: 'float',
|
|
65
66
|
Amount: 'float',
|
|
66
67
|
BilledAmount: 'float',
|
|
67
68
|
TaxedAmount: 'float',
|
|
68
69
|
VATAmount: 'float',
|
|
70
|
+
ReturnAmount: 'float',
|
|
69
71
|
}, 1)(object, null, 0);
|
|
70
72
|
};
|
|
71
73
|
exports.stringifyAmountsWithFloats = stringifyAmountsWithFloats;
|
package/lib/utils/case.util.js
CHANGED
|
@@ -8,6 +8,7 @@ var specialWords = [
|
|
|
8
8
|
{ word: 'utcunixTimeExpiration', substitute: 'UTCUnixTimeExpiration' },
|
|
9
9
|
{ word: 'VatAmount', substitute: 'VATAmount' },
|
|
10
10
|
{ word: 'InstrumentExpirationUtc', substitute: 'InstrumentExpirationUTC' },
|
|
11
|
+
{ word: 'ExecutionDateUtc', substitute: 'ExecutionDateUTC' },
|
|
11
12
|
];
|
|
12
13
|
var camelCaseSpecialWords = [
|
|
13
14
|
{
|