apacuana-sdk-core 0.10.0 → 0.11.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 (56) hide show
  1. package/README.md +305 -286
  2. package/coverage/clover.xml +337 -243
  3. package/coverage/coverage-final.json +9 -7
  4. package/coverage/lcov-report/index.html +34 -19
  5. package/coverage/lcov-report/src/api/certs.js.html +162 -87
  6. package/coverage/lcov-report/src/api/faceLiveness.js.html +496 -0
  7. package/coverage/lcov-report/src/api/index.html +43 -28
  8. package/coverage/lcov-report/src/api/revocations.js.html +103 -106
  9. package/coverage/lcov-report/src/api/signatures.js.html +25 -253
  10. package/coverage/lcov-report/src/api/users.js.html +7 -13
  11. package/coverage/lcov-report/src/config/index.html +1 -1
  12. package/coverage/lcov-report/src/config/index.js.html +1 -1
  13. package/coverage/lcov-report/src/errors/index.html +1 -1
  14. package/coverage/lcov-report/src/errors/index.js.html +8 -8
  15. package/coverage/lcov-report/src/index.html +1 -1
  16. package/coverage/lcov-report/src/index.js.html +26 -2
  17. package/coverage/lcov-report/src/success/index.html +116 -0
  18. package/coverage/lcov-report/src/success/index.js.html +106 -0
  19. package/coverage/lcov-report/src/utils/constant.js.html +4 -4
  20. package/coverage/lcov-report/src/utils/helpers.js.html +1 -1
  21. package/coverage/lcov-report/src/utils/httpClient.js.html +1 -1
  22. package/coverage/lcov-report/src/utils/index.html +1 -1
  23. package/coverage/lcov.info +582 -406
  24. package/dist/api/certs.d.ts +9 -70
  25. package/dist/api/faceLiveness.d.ts +6 -0
  26. package/dist/api/revocations.d.ts +3 -42
  27. package/dist/api/signatures.d.ts +11 -153
  28. package/dist/index.d.ts +6 -0
  29. package/dist/index.js +463 -252
  30. package/dist/index.js.map +1 -1
  31. package/dist/index.mjs +463 -252
  32. package/dist/index.mjs.map +1 -1
  33. package/dist/success/index.d.ts +7 -0
  34. package/dist/types/certs.d.ts +97 -0
  35. package/dist/types/faceLiveness.d.ts +10 -0
  36. package/dist/types/revocations.d.ts +40 -0
  37. package/dist/types/signatures.d.ts +152 -0
  38. package/dist/types/users.d.ts +260 -0
  39. package/package.json +1 -1
  40. package/src/api/certs.js +74 -49
  41. package/src/api/faceLiveness.js +137 -0
  42. package/src/api/revocations.js +66 -67
  43. package/src/api/signatures.js +21 -97
  44. package/src/api/users.js +4 -6
  45. package/src/index.js +8 -0
  46. package/src/success/index.js +8 -0
  47. package/src/types/certs.js +56 -0
  48. package/src/types/faceLiveness.js +7 -0
  49. package/src/types/revocations.js +25 -0
  50. package/src/types/signatures.js +77 -0
  51. package/src/types/users.js +73 -0
  52. package/tests/api/certs.test.js +99 -6
  53. package/tests/api/faceLiveness.test.js +172 -0
  54. package/tests/api/revocations.test.js +37 -37
  55. package/tests/api/signatures.test.js +11 -5
  56. package/tests/api/users.test.js +3 -2
package/dist/index.mjs CHANGED
@@ -529,6 +529,15 @@ var httpRequest = /*#__PURE__*/function () {
529
529
  };
530
530
  }();
531
531
 
532
+ var ApacuanaSuccess = /*#__PURE__*/_createClass(function ApacuanaSuccess(data) {
533
+ var statusCode = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 200;
534
+ _classCallCheck(this, ApacuanaSuccess);
535
+ this.success = true;
536
+ this.statusCode = statusCode;
537
+ this.name = "ApacuanaSuccess";
538
+ this.data = data;
539
+ });
540
+
532
541
  /**
533
542
  * @typedef {object} GetCustomerResponse
534
543
  * @property {string} token - El token de sesión del usuario.
@@ -573,11 +582,10 @@ var getCustomer = /*#__PURE__*/function () {
573
582
  }
574
583
  throw new ApacuanaAPIError("The API response does not contain the user.", 200, "INVALID_API_RESPONSE");
575
584
  case 4:
576
- return _context.a(2, {
585
+ return _context.a(2, new ApacuanaSuccess({
577
586
  token: response.sessionid,
578
- userData: response.entry,
579
- success: true
580
- });
587
+ userData: response.entry
588
+ }));
581
589
  case 5:
582
590
  _context.p = 5;
583
591
  _t = _context.v;
@@ -598,122 +606,166 @@ var getCustomer = /*#__PURE__*/function () {
598
606
  };
599
607
  }();
600
608
 
601
- /**
602
- * @typedef {object} RequestRevocationResponse
603
- * @property {string} revocationStatus - El estado de la solicitud de revocación (e.g., "pending").
604
- * @property {string|number} requestId - El ID de la solicitud de revocación.
605
- */
606
-
607
- /**
608
- * Simula la solicitud de revocación de un certificado.
609
- * @param {string} reasonCode - Código o descripción del motivo de la revocación.
610
- * @returns {Promise<RequestRevocationResponse>} Objeto con el estado de la solicitud de revocación.
611
- */
612
- /**
613
- * @typedef {object} RevocationResponse
614
- * @property {boolean} success - Indicates if the revocation request was successful.
615
- * @property {string} [message] - A message providing details about the outcome.
616
- */
617
-
618
- /**
619
- * @typedef {object} RevocationReason
620
- * @property {string} code - The code for the revocation reason.
621
- * @property {string} description - The description of the revocation reason.
622
- */
623
-
624
- /**
625
- * @typedef {object} RevocationReasonsResponse
626
- * @property {boolean} success - Indicates if the request was successful.
627
- * @property {RevocationReason[]} reasons - A list of revocation reasons.
628
- */
629
-
630
- /**
631
- * Requests the revocation of a certificate.
632
- * @param {number} reasonCode - Código o descripción del motivo de la revocación.
633
- * @returns {Promise<RevocationResponse>} An object indicating the success of the request.
634
- * @throws {ApacuanaAPIError} If the revocation request fails.
635
- */
636
- var requestRevocation = /*#__PURE__*/function () {
637
- var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(reasonCode) {
609
+ var requestRevocationOnBoarding = /*#__PURE__*/function () {
610
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
638
611
  var response, _t;
639
612
  return _regenerator().w(function (_context) {
640
613
  while (1) switch (_context.p = _context.n) {
641
614
  case 0:
642
- if (reasonCode) {
643
- _context.n = 1;
644
- break;
645
- }
646
- throw new Error("Código de motivo es requerido para requestRevocation.");
615
+ _context.p = 0;
616
+ _context.n = 1;
617
+ return httpRequest("services/api/certificate/revocation", params, "POST");
647
618
  case 1:
648
- _context.p = 1;
649
- _context.n = 2;
650
- return httpRequest("services/api/onboardingclient/requestcert", {
651
- reason: reasonCode
652
- }, "POST");
653
- case 2:
654
619
  response = _context.v;
655
- return _context.a(2, response);
656
- case 3:
657
- _context.p = 3;
620
+ return _context.a(2, new ApacuanaSuccess(response));
621
+ case 2:
622
+ _context.p = 2;
658
623
  _t = _context.v;
659
- throw new Error("Fallo en la solicitud de revocaci\xF3n: ".concat(_t.message));
624
+ if (!(_t instanceof ApacuanaAPIError)) {
625
+ _context.n = 3;
626
+ break;
627
+ }
628
+ throw _t;
629
+ case 3:
630
+ throw new Error("Failed to request revocation: ".concat(_t.message));
660
631
  case 4:
661
632
  return _context.a(2);
662
633
  }
663
- }, _callee, null, [[1, 3]]);
634
+ }, _callee, null, [[0, 2]]);
664
635
  }));
665
- return function requestRevocation(_x) {
636
+ return function requestRevocationOnBoarding(_x) {
666
637
  return _ref.apply(this, arguments);
667
638
  };
668
639
  }();
669
-
670
- /**
671
- * Retrieves the available reasons for certificate revocation.
672
- * @returns {Promise<RevocationReasonsResponse>} An object containing the list of revocation reasons.
673
- * @throws {ApacuanaAPIError} If fetching the reasons fails.
674
- */
675
- var getRevocationReasons = /*#__PURE__*/function () {
640
+ var requestRevocationOnPremise = /*#__PURE__*/function () {
676
641
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
677
- var _getConfig, integrationType, response, _t2;
678
642
  return _regenerator().w(function (_context2) {
679
- while (1) switch (_context2.p = _context2.n) {
643
+ while (1) switch (_context2.n) {
680
644
  case 0:
645
+ throw new ApacuanaAPIError("Requesting revocation is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
646
+ case 1:
647
+ return _context2.a(2);
648
+ }
649
+ }, _callee2);
650
+ }));
651
+ return function requestRevocationOnPremise() {
652
+ return _ref2.apply(this, arguments);
653
+ };
654
+ }();
655
+ var requestRevocation = /*#__PURE__*/function () {
656
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(params) {
657
+ var _getConfig, integrationType;
658
+ return _regenerator().w(function (_context3) {
659
+ while (1) switch (_context3.n) {
660
+ case 0:
661
+ if (!(!params || typeof params.reasonCode !== "number")) {
662
+ _context3.n = 1;
663
+ break;
664
+ }
665
+ throw new Error('The "params" object with a numeric "reasonCode" property is required.');
666
+ case 1:
681
667
  _getConfig = getConfig(), integrationType = _getConfig.integrationType;
668
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
669
+ _context3.n = 2;
670
+ break;
671
+ }
672
+ return _context3.a(2, requestRevocationOnBoarding(params));
673
+ case 2:
682
674
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
683
- _context2.n = 1;
675
+ _context3.n = 3;
684
676
  break;
685
677
  }
686
- throw new ApacuanaAPIError("Get revocation reasons is not supported for integration type: ".concat(integrationType), 501, "NOT_IMPLEMENTED");
678
+ return _context3.a(2, requestRevocationOnPremise(params));
679
+ case 3:
680
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
681
+ case 4:
682
+ return _context3.a(2);
683
+ }
684
+ }, _callee3);
685
+ }));
686
+ return function requestRevocation(_x2) {
687
+ return _ref3.apply(this, arguments);
688
+ };
689
+ }();
690
+ var getRevocationReasonsOnBoarding = /*#__PURE__*/function () {
691
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
692
+ var response, _t2;
693
+ return _regenerator().w(function (_context4) {
694
+ while (1) switch (_context4.p = _context4.n) {
695
+ case 0:
696
+ _context4.p = 0;
697
+ _context4.n = 1;
698
+ return httpRequest("services/api/certificate/revocation-reasons", {}, "GET");
687
699
  case 1:
688
- _context2.p = 1;
689
- _context2.n = 2;
690
- return httpRequest("GET", "config/api/revocation/reasonsonboarding", {});
691
- case 2:
692
- response = _context2.v;
693
- if (response.records) {
694
- _context2.n = 3;
700
+ response = _context4.v;
701
+ if (!(!response || !response.records)) {
702
+ _context4.n = 2;
695
703
  break;
696
704
  }
697
705
  throw new ApacuanaAPIError("Failed to fetch revocation reasons.");
706
+ case 2:
707
+ return _context4.a(2, new ApacuanaSuccess(response.records));
698
708
  case 3:
699
- return _context2.a(2, response.records);
700
- case 4:
701
- _context2.p = 4;
702
- _t2 = _context2.v;
709
+ _context4.p = 3;
710
+ _t2 = _context4.v;
703
711
  if (!(_t2 instanceof ApacuanaAPIError)) {
704
- _context2.n = 5;
712
+ _context4.n = 4;
705
713
  break;
706
714
  }
707
715
  throw _t2;
716
+ case 4:
717
+ throw new Error("Failed to get revocation reasons: ".concat(_t2.message));
708
718
  case 5:
709
- throw new Error("Failed to get revocation reasons. Please try again later.");
710
- case 6:
711
- return _context2.a(2);
719
+ return _context4.a(2);
712
720
  }
713
- }, _callee2, null, [[1, 4]]);
721
+ }, _callee4, null, [[0, 3]]);
722
+ }));
723
+ return function getRevocationReasonsOnBoarding() {
724
+ return _ref4.apply(this, arguments);
725
+ };
726
+ }();
727
+ var getRevocationReasonsOnPremise = /*#__PURE__*/function () {
728
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
729
+ return _regenerator().w(function (_context5) {
730
+ while (1) switch (_context5.n) {
731
+ case 0:
732
+ throw new ApacuanaAPIError("Getting revocation reasons is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
733
+ case 1:
734
+ return _context5.a(2);
735
+ }
736
+ }, _callee5);
737
+ }));
738
+ return function getRevocationReasonsOnPremise() {
739
+ return _ref5.apply(this, arguments);
740
+ };
741
+ }();
742
+ var getRevocationReasons = /*#__PURE__*/function () {
743
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
744
+ var _getConfig2, integrationType;
745
+ return _regenerator().w(function (_context6) {
746
+ while (1) switch (_context6.n) {
747
+ case 0:
748
+ _getConfig2 = getConfig(), integrationType = _getConfig2.integrationType;
749
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
750
+ _context6.n = 1;
751
+ break;
752
+ }
753
+ return _context6.a(2, getRevocationReasonsOnBoarding());
754
+ case 1:
755
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
756
+ _context6.n = 2;
757
+ break;
758
+ }
759
+ return _context6.a(2, getRevocationReasonsOnPremise());
760
+ case 2:
761
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
762
+ case 3:
763
+ return _context6.a(2);
764
+ }
765
+ }, _callee6);
714
766
  }));
715
767
  return function getRevocationReasons() {
716
- return _ref2.apply(this, arguments);
768
+ return _ref6.apply(this, arguments);
717
769
  };
718
770
  }();
719
771
 
@@ -32951,24 +33003,6 @@ var helpers = {
32951
33003
  validateOnBoardingSignDocumentData: validateOnBoardingSignDocumentData
32952
33004
  };
32953
33005
 
32954
- /**
32955
- * @typedef {object} GenerateCertResponse
32956
- * @property {string} cert - El certificado generado en formato string.
32957
- * @property {string} certifiedid - El ID del certificado generado.
32958
- * @property {boolean} success - Indica si la operación fue exitosa.
32959
- */
32960
-
32961
- /**
32962
- * @typedef {object} GetCertStatusResponse
32963
- * @property {string} status - El estado actual del certificado del usuario.
32964
- * @property {boolean} success - Indica si la operación fue exitosa.
32965
- */
32966
-
32967
- /**
32968
- * @typedef {object} EncryptedCSRObject
32969
- * @property {string} csr - The encrypted Certificate Signing Request.
32970
- */
32971
-
32972
33006
  /**
32973
33007
  * @param {EncryptedCSRObject} encryptedCSR
32974
33008
  */
@@ -32990,11 +33024,10 @@ var generateCertOnBoarding = /*#__PURE__*/function () {
32990
33024
  }
32991
33025
  throw new ApacuanaAPIError("The API response does not contain the certificate.", response.status, "INVALID_API_RESPONSE");
32992
33026
  case 2:
32993
- return _context.a(2, {
33027
+ return _context.a(2, new ApacuanaSuccess({
32994
33028
  cert: cert,
32995
- certifiedid: certifiedid,
32996
- success: true
32997
- });
33029
+ certifiedid: certifiedid
33030
+ }));
32998
33031
  case 3:
32999
33032
  _context.p = 3;
33000
33033
  _t = _context.v;
@@ -33077,24 +33110,10 @@ var getCertStatus = function getCertStatus() {
33077
33110
  var isCertificateInDevice = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
33078
33111
  var config = getConfig();
33079
33112
  var status = helpers.getCertificateStatus(config.userData, isCertificateInDevice);
33080
- return {
33081
- status: status,
33082
- success: true
33083
- };
33113
+ return new ApacuanaSuccess({
33114
+ status: status
33115
+ });
33084
33116
  };
33085
-
33086
- /**
33087
- * @typedef {object} CertType
33088
- * @property {string} id - The ID of the certificate type.
33089
- * @property {string} name - The name of the certificate type.
33090
- */
33091
-
33092
- /**
33093
- * @typedef {object} GetCertTypesResponse
33094
- * @property {Array<CertType>} types - A list of available certificate types.
33095
- * @property {boolean} success - Indicates if the operation was successful.
33096
- */
33097
-
33098
33117
  var getCertTypesOnBoarding = /*#__PURE__*/function () {
33099
33118
  var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
33100
33119
  var response, _t2;
@@ -33106,9 +33125,7 @@ var getCertTypesOnBoarding = /*#__PURE__*/function () {
33106
33125
  return httpRequest("services/api/customer/typeusers", {}, "GET");
33107
33126
  case 1:
33108
33127
  response = _context4.v;
33109
- return _context4.a(2, _objectSpread2(_objectSpread2({}, response), {}, {
33110
- success: true
33111
- }));
33128
+ return _context4.a(2, new ApacuanaSuccess(response));
33112
33129
  case 2:
33113
33130
  _context4.p = 2;
33114
33131
  _t2 = _context4.v;
@@ -33179,19 +33196,6 @@ var getCertTypes = /*#__PURE__*/function () {
33179
33196
  return _ref6.apply(this, arguments);
33180
33197
  };
33181
33198
  }();
33182
-
33183
- /**
33184
- * @typedef {object} Requirement
33185
- * @property {string} id - The ID of the requirement.
33186
- * @property {string} description - The description of the requirement.
33187
- */
33188
-
33189
- /**
33190
- * @typedef {object} GetRequirementsResponse
33191
- * @property {Array<Requirement>} requirements - A list of requirements for the user type.
33192
- * @property {boolean} success - Indicates if the operation was successful.
33193
- */
33194
-
33195
33199
  var getRequerimentsByTypeUserOnBoarding = /*#__PURE__*/function () {
33196
33200
  var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(type) {
33197
33201
  var response, _t3;
@@ -33203,9 +33207,7 @@ var getRequerimentsByTypeUserOnBoarding = /*#__PURE__*/function () {
33203
33207
  return httpRequest("services/api/customer/documentspref?typeuser=".concat(type), {}, "GET");
33204
33208
  case 1:
33205
33209
  response = _context7.v;
33206
- return _context7.a(2, _objectSpread2(_objectSpread2({}, response), {}, {
33207
- success: true
33208
- }));
33210
+ return _context7.a(2, new ApacuanaSuccess(response));
33209
33211
  case 2:
33210
33212
  _context7.p = 2;
33211
33213
  _t3 = _context7.v;
@@ -33285,70 +33287,106 @@ var getRequerimentsByTypeUser = /*#__PURE__*/function () {
33285
33287
  return _ref9.apply(this, arguments);
33286
33288
  };
33287
33289
  }();
33288
-
33289
- // =================================================================
33290
- // Type Definitions
33291
- // =================================================================
33292
-
33293
- /**
33294
- * Define la estructura de un objeto Firmante.
33295
- * @typedef {object} Signer
33296
- * @property {string} name - Nombre completo del firmante.
33297
- * @property {string} email - Correo electrónico del firmante.
33298
- * @property {string} document - Documento de identidad del firmante.
33299
- */
33300
-
33301
- /**
33302
- * Define la estructura de datos para añadir un firmante.
33303
- * @typedef {object} SignerData
33304
- * @property {string} docId - Identificador único del documento.
33305
- */
33306
-
33307
- /**
33308
- * Define la estructura de la respuesta al añadir un firmante.
33309
- * @typedef {object} AddSignerResponse
33310
- * @property {string} signer - Identificador de confirmación del firmante añadido.
33311
- * @property {boolean} success - Indica si la operación fue exitosa.
33312
- */
33313
-
33314
- /**
33315
- * Define la estructura de datos para obtener el digest de un documento.
33316
- * @typedef {object} GetDigestData
33317
- * @property {string} cert - Certificado del firmante en formato base64.
33318
- * @property {string} signatureId - Identificador único del proceso de firma.
33319
- */
33320
-
33321
- /**
33322
- * Define la estructura de la respuesta al obtener el digest.
33323
- * @typedef {object} GetDigestResponse
33324
- * @property {string} digest - El digest del documento que se va a firmar.
33325
- * @property {boolean} success - Indica si la operación fue exitosa.
33326
- */
33327
-
33328
- /**
33329
- * Define la estructura de los parámetros para obtener documentos.
33330
- * @typedef {object} GetDocsParams
33331
- * @property {number} page - Número de página para la paginación.
33332
- * @property {number} size - Cantidad de registros por página.
33333
- * @property {string} [status] - (Opcional) Estado para filtrar los documentos.
33334
- */
33290
+ var requestCertificateOnBoarding = /*#__PURE__*/function () {
33291
+ var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(params) {
33292
+ var response, _t4;
33293
+ return _regenerator().w(function (_context0) {
33294
+ while (1) switch (_context0.p = _context0.n) {
33295
+ case 0:
33296
+ _context0.p = 0;
33297
+ _context0.n = 1;
33298
+ return httpRequest("services/api/customer/request-certificate", params, "POST");
33299
+ case 1:
33300
+ response = _context0.v;
33301
+ return _context0.a(2, new ApacuanaSuccess(response));
33302
+ case 2:
33303
+ _context0.p = 2;
33304
+ _t4 = _context0.v;
33305
+ if (!(_t4 instanceof ApacuanaAPIError)) {
33306
+ _context0.n = 3;
33307
+ break;
33308
+ }
33309
+ throw _t4;
33310
+ case 3:
33311
+ throw new Error("Failed to request certificate: ".concat(_t4.message));
33312
+ case 4:
33313
+ return _context0.a(2);
33314
+ }
33315
+ }, _callee0, null, [[0, 2]]);
33316
+ }));
33317
+ return function requestCertificateOnBoarding(_x5) {
33318
+ return _ref0.apply(this, arguments);
33319
+ };
33320
+ }();
33321
+ var requestCertificateOnPremise = /*#__PURE__*/function () {
33322
+ var _ref1 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
33323
+ return _regenerator().w(function (_context1) {
33324
+ while (1) switch (_context1.n) {
33325
+ case 0:
33326
+ throw new ApacuanaAPIError("Requesting a certificate is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
33327
+ case 1:
33328
+ return _context1.a(2);
33329
+ }
33330
+ }, _callee1);
33331
+ }));
33332
+ return function requestCertificateOnPremise() {
33333
+ return _ref1.apply(this, arguments);
33334
+ };
33335
+ }();
33335
33336
 
33336
33337
  /**
33337
- * Define la estructura de la respuesta al obtener documentos.
33338
- * @typedef {object} GetDocsResponse
33339
- * @property {number} totalRecords - El número total de registros encontrados.
33340
- * @property {Array<object>} records - Un arreglo con los registros de los documentos.
33341
- * @property {boolean} success - Indica si la operación fue exitosa.
33338
+ * Requests a certificate for the user.
33339
+ * @param {CertificateRequestParams} params - The parameters for the certificate request.
33340
+ * @returns {Promise<RequestCertificateResponse>} Object with a confirmation message and a success indicator.
33341
+ * @throws {ApacuanaAPIError} If the API response is invalid or the integration type is not supported.
33342
+ * @throws {Error} If the request fails for another reason or the params are invalid.
33342
33343
  */
33344
+ var requestCertificate = /*#__PURE__*/function () {
33345
+ var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(params) {
33346
+ var _getConfig4, integrationType;
33347
+ return _regenerator().w(function (_context10) {
33348
+ while (1) switch (_context10.n) {
33349
+ case 0:
33350
+ if (!(!params || typeof params.type !== "number" || !Array.isArray(params.documents))) {
33351
+ _context10.n = 1;
33352
+ break;
33353
+ }
33354
+ throw new Error('The "params" object with a numeric "type" property and a "documents" array is required.');
33355
+ case 1:
33356
+ _getConfig4 = getConfig(), integrationType = _getConfig4.integrationType;
33357
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33358
+ _context10.n = 2;
33359
+ break;
33360
+ }
33361
+ return _context10.a(2, requestCertificateOnBoarding(params));
33362
+ case 2:
33363
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33364
+ _context10.n = 3;
33365
+ break;
33366
+ }
33367
+ return _context10.a(2, requestCertificateOnPremise());
33368
+ case 3:
33369
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
33370
+ case 4:
33371
+ return _context10.a(2);
33372
+ }
33373
+ }, _callee10);
33374
+ }));
33375
+ return function requestCertificate(_x6) {
33376
+ return _ref10.apply(this, arguments);
33377
+ };
33378
+ }();
33343
33379
 
33344
- /**
33345
- * @typedef {object} SignDocumentData
33346
- * @property {object} signature - Objeto con información de la firma.
33347
- * @property {string} signature.id - ID de la firma.
33348
- * @property {Array<object>} signature.positions - Posiciones de la firma.
33349
- * @property {string} cert - Certificado en base64.
33350
- * @property {string} signedDigest - Digest firmado.
33351
- */
33380
+ /** @typedef {import("../types/signatures").Signer} Signer */
33381
+ /** @typedef {import("../types/signatures").SignerData} SignerData */
33382
+ /** @typedef {import("../types/signatures").AddSignerResponse} AddSignerResponse */
33383
+ /** @typedef {import("../types/signatures").GetDigestData} GetDigestData */
33384
+ /** @typedef {import("../types/signatures").GetDigestResponse} GetDigestResponse */
33385
+ /** @typedef {import("../types/signatures").GetDocsParams} GetDocsParams */
33386
+ /** @typedef {import("../types/signatures").GetDocsResponse} GetDocsResponse */
33387
+ /** @typedef {import("../types/signatures").SignDocumentData} SignDocumentData */
33388
+ /** @typedef {import("../types/signatures").SignaturePosition} SignaturePosition */
33389
+ /** @typedef {import("../types/signatures").OnboardingSignerData} OnboardingSignerData */
33352
33390
 
33353
33391
  // =================================================================
33354
33392
  // Internal Functions
@@ -33379,7 +33417,7 @@ var signDocumentOnBoarding = /*#__PURE__*/function () {
33379
33417
  return httpRequest("services/api/documents/sign/".concat(signature.id), signBody, "PUT");
33380
33418
  case 2:
33381
33419
  response = _context.v;
33382
- return _context.a(2, response);
33420
+ return _context.a(2, new ApacuanaSuccess(response));
33383
33421
  case 3:
33384
33422
  _context.p = 3;
33385
33423
  _t = _context.v;
@@ -33434,10 +33472,9 @@ var getDigestToSignOnBoarding = /*#__PURE__*/function () {
33434
33472
  }
33435
33473
  throw new ApacuanaAPIError("Signature generation failed: digest not found in the response.", 500, "API_RESPONSE_ERROR");
33436
33474
  case 2:
33437
- return _context3.a(2, {
33438
- digest: digest,
33439
- success: true
33440
- });
33475
+ return _context3.a(2, new ApacuanaSuccess({
33476
+ digest: digest
33477
+ }));
33441
33478
  case 3:
33442
33479
  _context3.p = 3;
33443
33480
  _t2 = _context3.v;
@@ -33483,10 +33520,9 @@ var addSignerOnBoarding = /*#__PURE__*/function () {
33483
33520
  _context5.n = 2;
33484
33521
  return httpRequest("services/api/documents/signing", signerData, "POST");
33485
33522
  case 2:
33486
- return _context5.a(2, {
33487
- signer: signerData.typedoc + signerData.doc,
33488
- success: true
33489
- });
33523
+ return _context5.a(2, new ApacuanaSuccess({
33524
+ signer: signerData.typedoc + signerData.doc
33525
+ }));
33490
33526
  case 3:
33491
33527
  _context5.p = 3;
33492
33528
  _t3 = _context5.v;
@@ -33563,11 +33599,10 @@ var getDocsOnBoarding = /*#__PURE__*/function () {
33563
33599
  return httpRequest(apiUrl, {}, "GET");
33564
33600
  case 2:
33565
33601
  response = _context8.v;
33566
- return _context8.a(2, {
33602
+ return _context8.a(2, new ApacuanaSuccess({
33567
33603
  totalRecords: response.numofrecords,
33568
- records: response.records,
33569
- success: true
33570
- });
33604
+ records: response.records
33605
+ }));
33571
33606
  case 3:
33572
33607
  _context8.p = 3;
33573
33608
  _t4 = _context8.v;
@@ -33601,9 +33636,7 @@ var uploadSignatureVariantOnBoarding = /*#__PURE__*/function () {
33601
33636
  }, "POST");
33602
33637
  case 2:
33603
33638
  response = _context9.v;
33604
- return _context9.a(2, _objectSpread2(_objectSpread2({}, response), {}, {
33605
- success: true
33606
- }));
33639
+ return _context9.a(2, new ApacuanaSuccess(response));
33607
33640
  case 3:
33608
33641
  _context9.p = 3;
33609
33642
  _t5 = _context9.v;
@@ -33650,9 +33683,7 @@ var getSignatureVariantOnBoarding = /*#__PURE__*/function () {
33650
33683
  return httpRequest("services/api/customer/getsignaturephotosdk/".concat(customerId), {}, "GET");
33651
33684
  case 2:
33652
33685
  response = _context1.v;
33653
- return _context1.a(2, _objectSpread2(_objectSpread2({}, response), {}, {
33654
- success: true
33655
- }));
33686
+ return _context1.a(2, new ApacuanaSuccess(response));
33656
33687
  case 3:
33657
33688
  _context1.p = 3;
33658
33689
  _t6 = _context1.v;
@@ -33698,9 +33729,7 @@ var deleteSignatureVariantOnBoarding = /*#__PURE__*/function () {
33698
33729
  return httpRequest("services/api/customer/cleansignaturephoto", {}, "DELETE");
33699
33730
  case 1:
33700
33731
  response = _context11.v;
33701
- return _context11.a(2, _objectSpread2(_objectSpread2({}, response), {}, {
33702
- success: true
33703
- }));
33732
+ return _context11.a(2, new ApacuanaSuccess(response));
33704
33733
  case 2:
33705
33734
  _context11.p = 2;
33706
33735
  _t7 = _context11.v;
@@ -33820,31 +33849,6 @@ var getDigest = /*#__PURE__*/function () {
33820
33849
  * @returns {Promise<AddSignerResponse>} Una promesa que resuelve a un objeto con el resultado de la operación.
33821
33850
  * @throws {ApacuanaAPIError} Si los datos del firmante son inválidos, la llamada a la API falla, o el tipo de integración no es soportado.
33822
33851
  */
33823
- /**
33824
- * @typedef {object} SignaturePosition
33825
- * @property {number} page - The page number for the signature.
33826
- * @property {number} x - The x-coordinate for the signature's position (from 0 to 1).
33827
- * @property {number} y - The y-coordinate for the signature's position (from 0 to 1).
33828
- */
33829
-
33830
- /**
33831
- * @typedef {object} OnboardingSignerData
33832
- * @property {string} name - The name of the document.
33833
- * @property {string} reference - An external reference for the document.
33834
- * @property {string} typedoc - The type of document of the signer (e.g., "V", "E", "J").
33835
- * @property {string} doc - The document number of the signer.
33836
- * @property {SignaturePosition[]} signature - An array of signature positions.
33837
- */
33838
-
33839
- /**
33840
- * Adds a new signer to the signature process.
33841
- * This function acts as a dispatcher, delegating to the appropriate implementation
33842
- * based on the configured integration type.
33843
- *
33844
- * @param {OnboardingSignerData | object} signerData - The signer's data. The structure depends on the integration type.
33845
- * @returns {Promise<object>} The result from the API.
33846
- * @throws {ApacuanaAPIError} If signerData is invalid or if the integration type is not supported.
33847
- */
33848
33852
  var addSigner = /*#__PURE__*/function () {
33849
33853
  var _ref16 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(signerData) {
33850
33854
  var _getConfig5, integrationType;
@@ -34043,6 +34047,210 @@ var deleteSignatureVariant = /*#__PURE__*/function () {
34043
34047
  };
34044
34048
  }();
34045
34049
 
34050
+ var createFaceLivenessSessionOnBoarding = /*#__PURE__*/function () {
34051
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
34052
+ var response, _t;
34053
+ return _regenerator().w(function (_context) {
34054
+ while (1) switch (_context.p = _context.n) {
34055
+ case 0:
34056
+ _context.p = 0;
34057
+ _context.n = 1;
34058
+ return httpRequest("services/api/faceliveness/create", {}, "POST");
34059
+ case 1:
34060
+ response = _context.v;
34061
+ if (response.sessionId) {
34062
+ _context.n = 2;
34063
+ break;
34064
+ }
34065
+ throw new ApacuanaAPIError("The API response does not contain the session ID.", response.status, "INVALID_API_RESPONSE");
34066
+ case 2:
34067
+ return _context.a(2, new ApacuanaSuccess({
34068
+ sessionId: response.sessionId
34069
+ }));
34070
+ case 3:
34071
+ _context.p = 3;
34072
+ _t = _context.v;
34073
+ if (!(_t instanceof ApacuanaAPIError)) {
34074
+ _context.n = 4;
34075
+ break;
34076
+ }
34077
+ throw _t;
34078
+ case 4:
34079
+ throw new Error("Failed to create Face Liveness session: ".concat(_t.message));
34080
+ case 5:
34081
+ return _context.a(2);
34082
+ }
34083
+ }, _callee, null, [[0, 3]]);
34084
+ }));
34085
+ return function createFaceLivenessSessionOnBoarding() {
34086
+ return _ref.apply(this, arguments);
34087
+ };
34088
+ }();
34089
+ var createFaceLivenessSessionOnPremise = /*#__PURE__*/function () {
34090
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
34091
+ return _regenerator().w(function (_context2) {
34092
+ while (1) switch (_context2.n) {
34093
+ case 0:
34094
+ throw new ApacuanaAPIError("Creating a Face Liveness session is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
34095
+ case 1:
34096
+ return _context2.a(2);
34097
+ }
34098
+ }, _callee2);
34099
+ }));
34100
+ return function createFaceLivenessSessionOnPremise() {
34101
+ return _ref2.apply(this, arguments);
34102
+ };
34103
+ }();
34104
+ var validateFaceLivenessOnBoarding = /*#__PURE__*/function () {
34105
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(sessionId) {
34106
+ var response, status, _t2, _t3;
34107
+ return _regenerator().w(function (_context3) {
34108
+ while (1) switch (_context3.p = _context3.n) {
34109
+ case 0:
34110
+ _context3.p = 0;
34111
+ _context3.n = 1;
34112
+ return httpRequest("services/api/faceliveness/validate", {
34113
+ sessionid: sessionId
34114
+ }, "POST");
34115
+ case 1:
34116
+ response = _context3.v;
34117
+ return _context3.a(2, new ApacuanaSuccess(_objectSpread2({
34118
+ status: "verified"
34119
+ }, response)));
34120
+ case 2:
34121
+ _context3.p = 2;
34122
+ _t2 = _context3.v;
34123
+ if (!(_t2 instanceof ApacuanaAPIError)) {
34124
+ _context3.n = 9;
34125
+ break;
34126
+ }
34127
+ _t3 = _t2.statusCode;
34128
+ _context3.n = _t3 === 402 ? 3 : _t3 === 403 ? 4 : _t3 === 406 ? 5 : _t3 === 408 ? 6 : 7;
34129
+ break;
34130
+ case 3:
34131
+ status = "waitingForScan";
34132
+ return _context3.a(3, 8);
34133
+ case 4:
34134
+ status = "rejected";
34135
+ return _context3.a(3, 8);
34136
+ case 5:
34137
+ status = "processing";
34138
+ return _context3.a(3, 8);
34139
+ case 6:
34140
+ status = "expired";
34141
+ return _context3.a(3, 8);
34142
+ case 7:
34143
+ throw _t2;
34144
+ case 8:
34145
+ return _context3.a(2, new ApacuanaSuccess({
34146
+ status: status
34147
+ }));
34148
+ case 9:
34149
+ throw _t2;
34150
+ case 10:
34151
+ return _context3.a(2);
34152
+ }
34153
+ }, _callee3, null, [[0, 2]]);
34154
+ }));
34155
+ return function validateFaceLivenessOnBoarding(_x) {
34156
+ return _ref3.apply(this, arguments);
34157
+ };
34158
+ }();
34159
+ var validateFaceLivenessOnPremise = /*#__PURE__*/function () {
34160
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
34161
+ return _regenerator().w(function (_context4) {
34162
+ while (1) switch (_context4.n) {
34163
+ case 0:
34164
+ throw new ApacuanaAPIError("Validating a Face Liveness session is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
34165
+ case 1:
34166
+ return _context4.a(2);
34167
+ }
34168
+ }, _callee4);
34169
+ }));
34170
+ return function validateFaceLivenessOnPremise() {
34171
+ return _ref4.apply(this, arguments);
34172
+ };
34173
+ }();
34174
+
34175
+ /**
34176
+ * Creates a new Face Liveness session.
34177
+ * @returns {Promise<CreateFaceLivenessSessionResponse>} Object with the session ID and a success indicator.
34178
+ * @throws {ApacuanaAPIError} If the API response is invalid or the integration type is not supported.
34179
+ * @throws {Error} If the request fails for another reason.
34180
+ */
34181
+ var createFaceLivenessSession = /*#__PURE__*/function () {
34182
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
34183
+ var _getConfig, integrationType;
34184
+ return _regenerator().w(function (_context5) {
34185
+ while (1) switch (_context5.n) {
34186
+ case 0:
34187
+ _getConfig = getConfig(), integrationType = _getConfig.integrationType;
34188
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34189
+ _context5.n = 1;
34190
+ break;
34191
+ }
34192
+ return _context5.a(2, createFaceLivenessSessionOnBoarding());
34193
+ case 1:
34194
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34195
+ _context5.n = 2;
34196
+ break;
34197
+ }
34198
+ return _context5.a(2, createFaceLivenessSessionOnPremise());
34199
+ case 2:
34200
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34201
+ case 3:
34202
+ return _context5.a(2);
34203
+ }
34204
+ }, _callee5);
34205
+ }));
34206
+ return function createFaceLivenessSession() {
34207
+ return _ref5.apply(this, arguments);
34208
+ };
34209
+ }();
34210
+
34211
+ /**
34212
+ * Validates a Face Liveness session and returns its status.
34213
+ * @param {{sessionId: string}} params - Object containing the session ID.
34214
+ * @returns {Promise<ApacuanaSuccess>} Object with the validation status.
34215
+ * @throws {ApacuanaAPIError} If the API response is invalid or the integration type is not supported.
34216
+ */
34217
+ var validateFaceLiveness = /*#__PURE__*/function () {
34218
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(_ref6) {
34219
+ var sessionId, _getConfig2, integrationType;
34220
+ return _regenerator().w(function (_context6) {
34221
+ while (1) switch (_context6.n) {
34222
+ case 0:
34223
+ sessionId = _ref6.sessionId;
34224
+ if (sessionId) {
34225
+ _context6.n = 1;
34226
+ break;
34227
+ }
34228
+ throw new ApacuanaAPIError("sessionId is a required parameter.", 400, "INVALID_PARAMETER");
34229
+ case 1:
34230
+ _getConfig2 = getConfig(), integrationType = _getConfig2.integrationType;
34231
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34232
+ _context6.n = 2;
34233
+ break;
34234
+ }
34235
+ return _context6.a(2, validateFaceLivenessOnBoarding(sessionId));
34236
+ case 2:
34237
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34238
+ _context6.n = 3;
34239
+ break;
34240
+ }
34241
+ return _context6.a(2, validateFaceLivenessOnPremise());
34242
+ case 3:
34243
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34244
+ case 4:
34245
+ return _context6.a(2);
34246
+ }
34247
+ }, _callee6);
34248
+ }));
34249
+ return function validateFaceLiveness(_x2) {
34250
+ return _ref7.apply(this, arguments);
34251
+ };
34252
+ }();
34253
+
34046
34254
  var apacuana = {
34047
34255
  /**
34048
34256
  * Inicializa el Apacuana SDK con la configuración necesaria y obtiene
@@ -34117,7 +34325,10 @@ var apacuana = {
34117
34325
  getSignatureVariant: getSignatureVariant,
34118
34326
  deleteSignatureVariant: deleteSignatureVariant,
34119
34327
  getCertTypes: getCertTypes,
34120
- getRequerimentsByTypeUser: getRequerimentsByTypeUser
34328
+ getRequerimentsByTypeUser: getRequerimentsByTypeUser,
34329
+ createFaceLivenessSession: createFaceLivenessSession,
34330
+ validateFaceLiveness: validateFaceLiveness,
34331
+ requestCertificate: requestCertificate
34121
34332
  };
34122
34333
 
34123
34334
  export { apacuana as default };