apacuana-sdk-core 0.11.0 → 0.12.0

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.
Files changed (42) hide show
  1. package/coverage/clover.xml +117 -114
  2. package/coverage/coverage-final.json +6 -6
  3. package/coverage/lcov-report/index.html +12 -12
  4. package/coverage/lcov-report/src/api/certs.js.html +1 -1
  5. package/coverage/lcov-report/src/api/faceLiveness.js.html +34 -7
  6. package/coverage/lcov-report/src/api/index.html +1 -1
  7. package/coverage/lcov-report/src/api/revocations.js.html +50 -5
  8. package/coverage/lcov-report/src/api/signatures.js.html +1 -1
  9. package/coverage/lcov-report/src/api/users.js.html +20 -5
  10. package/coverage/lcov-report/src/config/index.html +1 -1
  11. package/coverage/lcov-report/src/config/index.js.html +1 -1
  12. package/coverage/lcov-report/src/errors/index.html +1 -1
  13. package/coverage/lcov-report/src/errors/index.js.html +8 -8
  14. package/coverage/lcov-report/src/index.html +13 -13
  15. package/coverage/lcov-report/src/index.js.html +72 -12
  16. package/coverage/lcov-report/src/success/index.html +1 -1
  17. package/coverage/lcov-report/src/success/index.js.html +5 -5
  18. package/coverage/lcov-report/src/utils/constant.js.html +1 -1
  19. package/coverage/lcov-report/src/utils/helpers.js.html +1 -1
  20. package/coverage/lcov-report/src/utils/httpClient.js.html +1 -1
  21. package/coverage/lcov-report/src/utils/index.html +1 -1
  22. package/coverage/lcov.info +195 -188
  23. package/dist/api/revocations.d.ts +6 -3
  24. package/dist/api/users.d.ts +16 -6
  25. package/dist/index.js +58 -15
  26. package/dist/index.js.map +1 -1
  27. package/dist/index.mjs +58 -15
  28. package/dist/index.mjs.map +1 -1
  29. package/dist/types/faceLiveness.d.ts +6 -5
  30. package/dist/types/revocations.d.ts +26 -15
  31. package/dist/types/signatures.d.ts +60 -65
  32. package/package.json +1 -1
  33. package/src/api/faceLiveness.js +13 -4
  34. package/src/api/revocations.js +18 -3
  35. package/src/api/users.js +8 -3
  36. package/src/index.js +25 -5
  37. package/src/types/faceLiveness.js +11 -2
  38. package/src/types/revocations.js +29 -9
  39. package/src/types/signatures.js +42 -28
  40. package/tests/api/faceLiveness.test.js +28 -30
  41. package/tests/api/revocations.test.js +4 -4
  42. package/tests/index.test.js +16 -8
package/dist/index.mjs CHANGED
@@ -539,10 +539,15 @@ var ApacuanaSuccess = /*#__PURE__*/_createClass(function ApacuanaSuccess(data) {
539
539
  });
540
540
 
541
541
  /**
542
- * @typedef {object} GetCustomerResponse
542
+ * @typedef {object} GetCustomerData
543
543
  * @property {string} token - El token de sesión del usuario.
544
544
  * @property {object} userData - Los datos del usuario obtenidos.
545
- * @property {boolean} success - Indica si la operación fue exitosa.
545
+ */
546
+
547
+ /**
548
+ * @typedef {object} GetCustomerResponse
549
+ * @property {true} success - Indica que la operación fue exitosa.
550
+ * @property {GetCustomerData} data - El payload de la respuesta.
546
551
  */
547
552
 
548
553
  /**
@@ -550,7 +555,7 @@ var ApacuanaSuccess = /*#__PURE__*/_createClass(function ApacuanaSuccess(data) {
550
555
  * Este método es útil para endpoints que requieren datos en el cuerpo de la petición
551
556
  * para buscar un usuario, como un ID de sesión o un token de acceso.
552
557
  *
553
- * @returns {Promise<GetCustomerResponse>} Objeto con el token de sesión, los datos del usuario y un indicador de éxito.
558
+ * @returns {Promise<GetCustomerResponse>} Una promesa que resuelve a un objeto con la respuesta exitosa.
554
559
  * @throws {Error} Si los parámetros de entrada son inválidos.
555
560
  * @throws {ApacuanaAPIError} Si ocurre un error en la API de Apacuana.
556
561
  */
@@ -606,6 +611,9 @@ var getCustomer = /*#__PURE__*/function () {
606
611
  };
607
612
  }();
608
613
 
614
+ /** @typedef {import("../types/revocations").RequestRevocationResponse} RequestRevocationResponse */
615
+ /** @typedef {import("../types/revocations").GetRevocationReasonsResponse} GetRevocationReasonsResponse */
616
+
609
617
  var requestRevocationOnBoarding = /*#__PURE__*/function () {
610
618
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
611
619
  var response, _t;
@@ -614,7 +622,7 @@ var requestRevocationOnBoarding = /*#__PURE__*/function () {
614
622
  case 0:
615
623
  _context.p = 0;
616
624
  _context.n = 1;
617
- return httpRequest("services/api/certificate/revocation", params, "POST");
625
+ return httpRequest("services/api/onboardingclient/requestcert", params, "POST");
618
626
  case 1:
619
627
  response = _context.v;
620
628
  return _context.a(2, new ApacuanaSuccess(response));
@@ -652,6 +660,14 @@ var requestRevocationOnPremise = /*#__PURE__*/function () {
652
660
  return _ref2.apply(this, arguments);
653
661
  };
654
662
  }();
663
+
664
+ /**
665
+ * Solicita la revocación de un certificado.
666
+ * @param {object} params - Parámetros para la solicitud.
667
+ * @param {number} params.reasonCode - El código de la razón de la revocación.
668
+ * @returns {Promise<RequestRevocationResponse>} Una promesa que resuelve con la confirmación de la solicitud.
669
+ * @throws {Error} Si los parámetros son inválidos.
670
+ */
655
671
  var requestRevocation = /*#__PURE__*/function () {
656
672
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(params) {
657
673
  var _getConfig, integrationType;
@@ -695,7 +711,7 @@ var getRevocationReasonsOnBoarding = /*#__PURE__*/function () {
695
711
  case 0:
696
712
  _context4.p = 0;
697
713
  _context4.n = 1;
698
- return httpRequest("services/api/certificate/revocation-reasons", {}, "GET");
714
+ return httpRequest("config/api/revocation/reasonsonboarding", {}, "GET");
699
715
  case 1:
700
716
  response = _context4.v;
701
717
  if (!(!response || !response.records)) {
@@ -704,7 +720,9 @@ var getRevocationReasonsOnBoarding = /*#__PURE__*/function () {
704
720
  }
705
721
  throw new ApacuanaAPIError("Failed to fetch revocation reasons.");
706
722
  case 2:
707
- return _context4.a(2, new ApacuanaSuccess(response.records));
723
+ return _context4.a(2, new ApacuanaSuccess({
724
+ reasons: response.records
725
+ }));
708
726
  case 3:
709
727
  _context4.p = 3;
710
728
  _t2 = _context4.v;
@@ -739,6 +757,12 @@ var getRevocationReasonsOnPremise = /*#__PURE__*/function () {
739
757
  return _ref5.apply(this, arguments);
740
758
  };
741
759
  }();
760
+
761
+ /**
762
+ * Obtiene la lista de razones de revocación de certificados.
763
+ * @returns {Promise<GetRevocationReasonsResponse>} Una promesa que resuelve con la lista de razones de revocación.
764
+ * @throws {ApacuanaAPIError} Si la llamada a la API falla o el tipo de integración no es soportado.
765
+ */
742
766
  var getRevocationReasons = /*#__PURE__*/function () {
743
767
  var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
744
768
  var _getConfig2, integrationType;
@@ -34047,6 +34071,12 @@ var deleteSignatureVariant = /*#__PURE__*/function () {
34047
34071
  };
34048
34072
  }();
34049
34073
 
34074
+ /**
34075
+ * Creates a new Face Liveness session.
34076
+ * @returns {Promise<CreateFaceLivenessSessionResponse>} Object with the session ID and a success indicator.
34077
+ * @throws {ApacuanaAPIError} If the API response is invalid or the integration type is not supported.
34078
+ * @throws {Error} If the request fails for another reason.
34079
+ */
34050
34080
  var createFaceLivenessSessionOnBoarding = /*#__PURE__*/function () {
34051
34081
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
34052
34082
  var response, _t;
@@ -34058,14 +34088,14 @@ var createFaceLivenessSessionOnBoarding = /*#__PURE__*/function () {
34058
34088
  return httpRequest("services/api/faceliveness/create", {}, "POST");
34059
34089
  case 1:
34060
34090
  response = _context.v;
34061
- if (response.sessionId) {
34091
+ if (response.sessionid) {
34062
34092
  _context.n = 2;
34063
34093
  break;
34064
34094
  }
34065
34095
  throw new ApacuanaAPIError("The API response does not contain the session ID.", response.status, "INVALID_API_RESPONSE");
34066
34096
  case 2:
34067
34097
  return _context.a(2, new ApacuanaSuccess({
34068
- sessionId: response.sessionId
34098
+ sessionId: response.sessionid
34069
34099
  }));
34070
34100
  case 3:
34071
34101
  _context.p = 3;
@@ -34076,7 +34106,7 @@ var createFaceLivenessSessionOnBoarding = /*#__PURE__*/function () {
34076
34106
  }
34077
34107
  throw _t;
34078
34108
  case 4:
34079
- throw new Error("Failed to create Face Liveness session: ".concat(_t.message));
34109
+ throw new ApacuanaAPIError("Failed to create Face Liveness session: ".concat(_t.message));
34080
34110
  case 5:
34081
34111
  return _context.a(2);
34082
34112
  }
@@ -34266,7 +34296,7 @@ var apacuana = {
34266
34296
  */
34267
34297
  init: function () {
34268
34298
  var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config) {
34269
- var currentConfig, _yield$getCustomer, token, userData, _t;
34299
+ var currentConfig, customer, _customer$data, token, userData, _t;
34270
34300
  return _regenerator().w(function (_context) {
34271
34301
  while (1) switch (_context.p = _context.n) {
34272
34302
  case 0:
@@ -34278,27 +34308,37 @@ var apacuana = {
34278
34308
  _context.n = 1;
34279
34309
  break;
34280
34310
  }
34281
- throw new Error("Apacuana SDK: La configuración de CustomerId no se ha guardado" + " correctamente.");
34311
+ throw new ApacuanaAPIError("Apacuana SDK: La configuración de CustomerId no se ha guardado" + " correctamente.", 400, {
34312
+ code: "CONFIG_ERROR"
34313
+ });
34282
34314
  case 1:
34283
34315
  _context.n = 2;
34284
34316
  return getCustomer();
34285
34317
  case 2:
34286
- _yield$getCustomer = _context.v;
34287
- token = _yield$getCustomer.token;
34288
- userData = _yield$getCustomer.userData;
34318
+ customer = _context.v;
34319
+ _customer$data = customer.data, token = _customer$data.token, userData = _customer$data.userData;
34289
34320
  setConfig(_objectSpread2(_objectSpread2({}, currentConfig), {}, {
34290
34321
  token: token,
34291
34322
  userData: userData
34292
34323
  }));
34293
34324
  setAuthToken(token);
34294
- return _context.a(2, true);
34325
+ return _context.a(2, new ApacuanaSuccess({
34326
+ initialized: true,
34327
+ message: "SDK inicializado correctamente."
34328
+ }));
34295
34329
  case 3:
34296
34330
  _context.p = 3;
34297
34331
  _t = _context.v;
34298
34332
  // eslint-disable-next-line no-console
34299
34333
  console.error("Error durante la inicialización del SDK:", _t);
34334
+ if (!(_t instanceof ApacuanaAPIError)) {
34335
+ _context.n = 4;
34336
+ break;
34337
+ }
34300
34338
  throw _t;
34301
34339
  case 4:
34340
+ throw new ApacuanaAPIError(_t.message || "Error desconocido durante la inicialización.", 500, _t);
34341
+ case 5:
34302
34342
  return _context.a(2);
34303
34343
  }
34304
34344
  }, _callee, null, [[0, 3]]);
@@ -34308,6 +34348,9 @@ var apacuana = {
34308
34348
  }
34309
34349
  return init;
34310
34350
  }(),
34351
+ /**
34352
+ * Permite obtener la configuración actual del SDK.
34353
+ */
34311
34354
  close: function close$1() {
34312
34355
  return close();
34313
34356
  },