@houlak/plexo-sdk 0.1.21 → 0.1.23

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.
@@ -42,6 +42,7 @@ var evaluator_service_1 = require("./services/evaluator.service");
42
42
  var config_1 = require("../config/config");
43
43
  var PaymentGatewayMock_1 = require("../sdk/PaymentGatewayMock");
44
44
  var utils_1 = require("../utils");
45
+ var logger_lib_1 = require("../lib/logger.lib");
45
46
  var isTesting = config_1.config.env === 'TEST';
46
47
  var paymentGatewayClient = isTesting
47
48
  ? new PaymentGatewayMock_1.PaymentGatewayMock()
@@ -211,6 +212,7 @@ var UnwrapInstrumentCallback = function (instrumentCallback) { return __awaiter(
211
212
  return [4 /*yield*/, paymentGatewayClient.UnwrapInstrumentCallbackAsync(instrumentCallbackCamelCase)];
212
213
  case 1:
213
214
  instrumentCallbackResponse = _a.sent();
215
+ logger_lib_1.default.info(instrumentCallbackResponse, 'UnwrapInstrumentCallback response from us');
214
216
  return [2 /*return*/, evaluator_service_1.Evaluator.genericEvaluator(instrumentCallback, instrumentCallbackResponse)];
215
217
  }
216
218
  });
@@ -234,7 +234,7 @@ var getPlexoKey = function (fingerprint) { return __awaiter(void 0, void 0, void
234
234
  });
235
235
  }); };
236
236
  var getPlexoSignature = function (fingerprint, response) { return __awaiter(void 0, void 0, void 0, function () {
237
- var serverResponse, plexoResponse, err_1, key, objectInPascalCase, objectSorted, objectBuffer, verifySignature;
237
+ var serverResponse, plexoResponse, err_1, key, objectInPascalCase, objectSorted, objectBuffer, verifySignature, canonizedObject, objectInPascal, sarasas, sarasasSorted, sarasasBuffer, sarasasVerifySignature;
238
238
  return __generator(this, function (_a) {
239
239
  switch (_a.label) {
240
240
  case 0:
@@ -257,9 +257,21 @@ var getPlexoSignature = function (fingerprint, response) { return __awaiter(void
257
257
  objectInPascalCase = utils_1.caseUtils.toPascalKeys(response.object);
258
258
  objectSorted = sort(objectInPascalCase);
259
259
  objectBuffer = Buffer.from(JSON.stringify(objectSorted));
260
+ logger_lib_1.default.info(objectSorted, 'Objeto a verificar');
260
261
  verifySignature = (0, crypto_1.createVerify)('SHA512')
261
262
  .update(objectBuffer)
262
263
  .verify(key, response.signature, 'base64');
264
+ logger_lib_1.default.info(verifySignature, 'Verificacion de firma clasica');
265
+ canonizedObject = (0, exports.canonizeJson)(response.object);
266
+ objectInPascal = utils_1.caseUtils.toPascalKeys(canonizedObject);
267
+ sarasas = (0, stringifyWithFloats_1.stringifyAmountsWithFloats)(objectInPascal);
268
+ sarasasSorted = sort(sarasas);
269
+ sarasasBuffer = Buffer.from(JSON.stringify(sarasasSorted));
270
+ logger_lib_1.default.info(sarasasSorted, 'Nuevo Objeto a verificar');
271
+ sarasasVerifySignature = (0, crypto_1.createVerify)('SHA512')
272
+ .update(sarasasBuffer)
273
+ .verify(key, response.signature, 'base64');
274
+ logger_lib_1.default.info(sarasasVerifySignature, 'Verificacion de firma nueva');
263
275
  serverResponse = {
264
276
  response: response.object.object,
265
277
  resultCode: verifySignature ? __1.ResultCodes.Ok : __1.ResultCodes.InvalidSignature,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@houlak/plexo-sdk",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
4
4
  "description": "Node SDK for Plexo payment services",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",