apacuana-sdk-core 0.11.0 → 0.13.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 (49) hide show
  1. package/README.md +131 -164
  2. package/coverage/clover.xml +338 -302
  3. package/coverage/coverage-final.json +9 -9
  4. package/coverage/lcov-report/index.html +31 -31
  5. package/coverage/lcov-report/src/api/certs.js.html +1 -1
  6. package/coverage/lcov-report/src/api/faceLiveness.js.html +34 -7
  7. package/coverage/lcov-report/src/api/index.html +13 -13
  8. package/coverage/lcov-report/src/api/revocations.js.html +50 -5
  9. package/coverage/lcov-report/src/api/signatures.js.html +17 -56
  10. package/coverage/lcov-report/src/api/users.js.html +20 -5
  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 +13 -13
  16. package/coverage/lcov-report/src/index.js.html +59 -14
  17. package/coverage/lcov-report/src/success/index.html +1 -1
  18. package/coverage/lcov-report/src/success/index.js.html +5 -5
  19. package/coverage/lcov-report/src/utils/constant.js.html +1 -1
  20. package/coverage/lcov-report/src/utils/helpers.js.html +277 -16
  21. package/coverage/lcov-report/src/utils/httpClient.js.html +32 -17
  22. package/coverage/lcov-report/src/utils/index.html +22 -22
  23. package/coverage/lcov.info +641 -561
  24. package/dist/api/revocations.d.ts +6 -3
  25. package/dist/api/users.d.ts +16 -6
  26. package/dist/index.d.ts +0 -2
  27. package/dist/index.js +149 -147
  28. package/dist/index.js.map +1 -1
  29. package/dist/index.mjs +149 -147
  30. package/dist/index.mjs.map +1 -1
  31. package/dist/types/faceLiveness.d.ts +6 -5
  32. package/dist/types/revocations.d.ts +26 -15
  33. package/dist/types/signatures.d.ts +73 -63
  34. package/dist/utils/helpers.d.ts +4 -2
  35. package/package.json +1 -1
  36. package/src/api/faceLiveness.js +13 -4
  37. package/src/api/revocations.js +18 -3
  38. package/src/api/signatures.js +8 -21
  39. package/src/api/users.js +8 -3
  40. package/src/index.js +22 -7
  41. package/src/types/faceLiveness.js +11 -2
  42. package/src/types/revocations.js +29 -9
  43. package/src/types/signatures.js +47 -28
  44. package/src/utils/helpers.js +95 -8
  45. package/src/utils/httpClient.js +15 -10
  46. package/tests/api/faceLiveness.test.js +28 -30
  47. package/tests/api/revocations.test.js +4 -4
  48. package/tests/api/signatures.test.js +73 -16
  49. package/tests/index.test.js +16 -8
package/dist/index.mjs CHANGED
@@ -466,17 +466,21 @@ var httpRequest = /*#__PURE__*/function () {
466
466
  throw new Error("Apacuana SDK: Cliente HTTP no inicializado. " + "Llama a apacuana.init() primero.");
467
467
  case 1:
468
468
  requestConfig = {};
469
- hasFile = Object.values(data).some(function (value) {
470
- return typeof File !== "undefined" && value instanceof File;
471
- });
472
- if (hasFile) {
473
- formData = new FormData();
474
- Object.keys(data).forEach(function (key) {
475
- formData.append(key, data[key]);
476
- });
477
- dataToSend = formData;
469
+ if (typeof FormData !== "undefined" && data instanceof FormData) {
470
+ dataToSend = data;
478
471
  } else {
479
- dataToSend = _objectSpread2({}, data);
472
+ hasFile = Object.values(data).some(function (value) {
473
+ return typeof File !== "undefined" && value instanceof File;
474
+ });
475
+ if (hasFile) {
476
+ formData = new FormData();
477
+ Object.keys(data).forEach(function (key) {
478
+ formData.append(key, data[key]);
479
+ });
480
+ dataToSend = formData;
481
+ } else {
482
+ dataToSend = _objectSpread2({}, data);
483
+ }
480
484
  }
481
485
  _context.p = 2;
482
486
  _t = method.toUpperCase();
@@ -539,10 +543,15 @@ var ApacuanaSuccess = /*#__PURE__*/_createClass(function ApacuanaSuccess(data) {
539
543
  });
540
544
 
541
545
  /**
542
- * @typedef {object} GetCustomerResponse
546
+ * @typedef {object} GetCustomerData
543
547
  * @property {string} token - El token de sesión del usuario.
544
548
  * @property {object} userData - Los datos del usuario obtenidos.
545
- * @property {boolean} success - Indica si la operación fue exitosa.
549
+ */
550
+
551
+ /**
552
+ * @typedef {object} GetCustomerResponse
553
+ * @property {true} success - Indica que la operación fue exitosa.
554
+ * @property {GetCustomerData} data - El payload de la respuesta.
546
555
  */
547
556
 
548
557
  /**
@@ -550,7 +559,7 @@ var ApacuanaSuccess = /*#__PURE__*/_createClass(function ApacuanaSuccess(data) {
550
559
  * Este método es útil para endpoints que requieren datos en el cuerpo de la petición
551
560
  * para buscar un usuario, como un ID de sesión o un token de acceso.
552
561
  *
553
- * @returns {Promise<GetCustomerResponse>} Objeto con el token de sesión, los datos del usuario y un indicador de éxito.
562
+ * @returns {Promise<GetCustomerResponse>} Una promesa que resuelve a un objeto con la respuesta exitosa.
554
563
  * @throws {Error} Si los parámetros de entrada son inválidos.
555
564
  * @throws {ApacuanaAPIError} Si ocurre un error en la API de Apacuana.
556
565
  */
@@ -606,6 +615,9 @@ var getCustomer = /*#__PURE__*/function () {
606
615
  };
607
616
  }();
608
617
 
618
+ /** @typedef {import("../types/revocations").RequestRevocationResponse} RequestRevocationResponse */
619
+ /** @typedef {import("../types/revocations").GetRevocationReasonsResponse} GetRevocationReasonsResponse */
620
+
609
621
  var requestRevocationOnBoarding = /*#__PURE__*/function () {
610
622
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(params) {
611
623
  var response, _t;
@@ -614,7 +626,7 @@ var requestRevocationOnBoarding = /*#__PURE__*/function () {
614
626
  case 0:
615
627
  _context.p = 0;
616
628
  _context.n = 1;
617
- return httpRequest("services/api/certificate/revocation", params, "POST");
629
+ return httpRequest("services/api/onboardingclient/requestcert", params, "POST");
618
630
  case 1:
619
631
  response = _context.v;
620
632
  return _context.a(2, new ApacuanaSuccess(response));
@@ -652,6 +664,14 @@ var requestRevocationOnPremise = /*#__PURE__*/function () {
652
664
  return _ref2.apply(this, arguments);
653
665
  };
654
666
  }();
667
+
668
+ /**
669
+ * Solicita la revocación de un certificado.
670
+ * @param {object} params - Parámetros para la solicitud.
671
+ * @param {number} params.reasonCode - El código de la razón de la revocación.
672
+ * @returns {Promise<RequestRevocationResponse>} Una promesa que resuelve con la confirmación de la solicitud.
673
+ * @throws {Error} Si los parámetros son inválidos.
674
+ */
655
675
  var requestRevocation = /*#__PURE__*/function () {
656
676
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(params) {
657
677
  var _getConfig, integrationType;
@@ -695,7 +715,7 @@ var getRevocationReasonsOnBoarding = /*#__PURE__*/function () {
695
715
  case 0:
696
716
  _context4.p = 0;
697
717
  _context4.n = 1;
698
- return httpRequest("services/api/certificate/revocation-reasons", {}, "GET");
718
+ return httpRequest("config/api/revocation/reasonsonboarding", {}, "GET");
699
719
  case 1:
700
720
  response = _context4.v;
701
721
  if (!(!response || !response.records)) {
@@ -704,7 +724,9 @@ var getRevocationReasonsOnBoarding = /*#__PURE__*/function () {
704
724
  }
705
725
  throw new ApacuanaAPIError("Failed to fetch revocation reasons.");
706
726
  case 2:
707
- return _context4.a(2, new ApacuanaSuccess(response.records));
727
+ return _context4.a(2, new ApacuanaSuccess({
728
+ reasons: response.records
729
+ }));
708
730
  case 3:
709
731
  _context4.p = 3;
710
732
  _t2 = _context4.v;
@@ -739,6 +761,12 @@ var getRevocationReasonsOnPremise = /*#__PURE__*/function () {
739
761
  return _ref5.apply(this, arguments);
740
762
  };
741
763
  }();
764
+
765
+ /**
766
+ * Obtiene la lista de razones de revocación de certificados.
767
+ * @returns {Promise<GetRevocationReasonsResponse>} Una promesa que resuelve con la lista de razones de revocación.
768
+ * @throws {ApacuanaAPIError} Si la llamada a la API falla o el tipo de integración no es soportado.
769
+ */
742
770
  var getRevocationReasons = /*#__PURE__*/function () {
743
771
  var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
744
772
  var _getConfig2, integrationType;
@@ -32922,24 +32950,57 @@ var encryptedCsr = function encryptedCsr(csr) {
32922
32950
  };
32923
32951
  return body;
32924
32952
  };
32953
+ var createPayloadGetDigest = function createPayloadGetDigest(signData) {
32954
+ var formData = new FormData();
32955
+
32956
+ // Iterate over the object's own properties
32957
+ Object.keys(signData).forEach(function (key) {
32958
+ // Conditionally handle the 'document' field
32959
+
32960
+ if (key === "document" && signData[key] instanceof File) {
32961
+ // Append the file directly
32962
+ formData.append(key, signData[key]);
32963
+ } else if (key === "cert") {
32964
+ formData.append("publickey", signData[key]);
32965
+ }
32966
+ });
32967
+ return formData;
32968
+ };
32925
32969
  var validateOnBoardingSignerData = function validateOnBoardingSignerData(signerData) {
32926
- if (!signerData.name || typeof signerData.name !== "string") {
32970
+ // Create a copy of the original object to avoid modifying the function parameter
32971
+ var validatedSignerData = _objectSpread2({}, signerData);
32972
+ if (!validatedSignerData.name || typeof validatedSignerData.name !== "string") {
32927
32973
  throw new ApacuanaAPIError('El campo "name" es requerido y debe ser una cadena de texto.', 400, "INVALID_PARAMETER_FORMAT");
32928
32974
  }
32929
- if (!signerData.reference || typeof signerData.reference !== "string") {
32930
- throw new ApacuanaAPIError('El campo "reference" es requerido y debe ser una cadena de texto.', 400, "INVALID_PARAMETER_FORMAT");
32975
+
32976
+ // Limpia 'reference' si es inválido o está vacío.
32977
+ if (!validatedSignerData.reference || typeof validatedSignerData.reference !== "string" || validatedSignerData.reference.trim() === "") {
32978
+ delete validatedSignerData.reference;
32979
+ }
32980
+
32981
+ // Limpia 'file' si no es una instancia de File.
32982
+ if (typeof File === "undefined" || !validatedSignerData.file || !(validatedSignerData.file instanceof File)) {
32983
+ delete validatedSignerData.file;
32984
+ }
32985
+
32986
+ // Valida que solo uno de los dos campos exista después de la limpieza.
32987
+ if (validatedSignerData.reference && validatedSignerData.file) {
32988
+ throw new ApacuanaAPIError("No se pueden proporcionar 'reference' y 'file' simultáneamente.", 400, "INVALID_PARAMETER_FORMAT");
32989
+ }
32990
+ if (!validatedSignerData.reference && !validatedSignerData.file) {
32991
+ throw new ApacuanaAPIError("Se debe proporcionar un campo 'reference' o 'file' válido.", 400, "INVALID_PARAMETER_FORMAT");
32931
32992
  }
32932
32993
  var validDocTypes = ["V", "P", "E"];
32933
- if (!signerData.typedoc || !validDocTypes.includes(signerData.typedoc)) {
32994
+ if (!validatedSignerData.typedoc || !validDocTypes.includes(validatedSignerData.typedoc)) {
32934
32995
  throw new ApacuanaAPIError('El campo "typedoc" es requerido y debe ser uno de los siguientes valores: V, P, E.', 400, "INVALID_PARAMETER_FORMAT");
32935
32996
  }
32936
- if (!signerData.doc || typeof signerData.doc !== "string") {
32997
+ if (!validatedSignerData.doc || typeof validatedSignerData.doc !== "string") {
32937
32998
  throw new ApacuanaAPIError('El campo "doc" es requerido y debe ser una cadena de texto.', 400, "INVALID_PARAMETER_FORMAT");
32938
32999
  }
32939
- if (!Array.isArray(signerData.signature) || signerData.signature.length === 0) {
33000
+ if (!Array.isArray(validatedSignerData.signature) || validatedSignerData.signature.length === 0) {
32940
33001
  throw new ApacuanaAPIError('El campo "signature" es requerido y debe ser un array no vacío.', 400, "INVALID_PARAMETER_FORMAT");
32941
33002
  }
32942
- signerData.signature.forEach(function (sig, index) {
33003
+ validatedSignerData.signature.forEach(function (sig, index) {
32943
33004
  if (!Number.isInteger(sig.page) || sig.page < 1) {
32944
33005
  throw new ApacuanaAPIError("La p\xE1gina de la firma ".concat(index + 1, " debe ser un n\xFAmero entero positivo."), 400, "INVALID_PARAMETER_FORMAT");
32945
33006
  }
@@ -32950,6 +33011,17 @@ var validateOnBoardingSignerData = function validateOnBoardingSignerData(signerD
32950
33011
  throw new ApacuanaAPIError("La coordenada Y de la firma ".concat(index + 1, " debe ser un n\xFAmero entre 0 y 1."), 400, "INVALID_PARAMETER_FORMAT");
32951
33012
  }
32952
33013
  });
33014
+ var formData = new FormData();
33015
+ Object.keys(validatedSignerData).forEach(function (key) {
33016
+ if (key === "signature") {
33017
+ formData.append(key, JSON.stringify(validatedSignerData[key]));
33018
+ } else if (key === "file") {
33019
+ formData.append("document", validatedSignerData[key]);
33020
+ } else if (validatedSignerData[key] !== undefined) {
33021
+ formData.append(key, validatedSignerData[key]);
33022
+ }
33023
+ });
33024
+ return formData;
32953
33025
  };
32954
33026
  var validateCsr = function validateCsr(encryptedCSR) {
32955
33027
  if (!encryptedCSR || _typeof(encryptedCSR) !== "object" || !encryptedCSR.csr || typeof encryptedCSR.csr !== "string" || encryptedCSR.csr.trim() === "") {
@@ -32990,6 +33062,21 @@ var validateOnBoardingSignDocumentData = function validateOnBoardingSignDocument
32990
33062
  if (!signedDigest || typeof signedDigest !== "string") {
32991
33063
  throw new ApacuanaAPIError("Signed digest 'signedDigest' is required and must be a string.", 400, "INVALID_PARAMETER");
32992
33064
  }
33065
+ var formData = new FormData();
33066
+ formData.append("positions", JSON.stringify(signature.positions.map(function (p) {
33067
+ return {
33068
+ x: p.x,
33069
+ y: p.y,
33070
+ page: p.page,
33071
+ status: 1
33072
+ };
33073
+ })));
33074
+ formData.append("publickey", cert);
33075
+ formData.append("signeddigest", signedDigest);
33076
+ if (signData.document && signData.document instanceof File) {
33077
+ formData.append("document", signData.document);
33078
+ }
33079
+ return formData;
32993
33080
  };
32994
33081
  var helpers = {
32995
33082
  getCertificateStatus: getCertificateStatus,
@@ -33000,7 +33087,8 @@ var helpers = {
33000
33087
  validateCsr: validateCsr,
33001
33088
  validateGetDocsData: validateGetDocsData,
33002
33089
  validateGetDigestData: validateGetDigestData,
33003
- validateOnBoardingSignDocumentData: validateOnBoardingSignDocumentData
33090
+ validateOnBoardingSignDocumentData: validateOnBoardingSignDocumentData,
33091
+ createPayloadGetDigest: createPayloadGetDigest
33004
33092
  };
33005
33093
 
33006
33094
  /**
@@ -33287,95 +33375,6 @@ var getRequerimentsByTypeUser = /*#__PURE__*/function () {
33287
33375
  return _ref9.apply(this, arguments);
33288
33376
  };
33289
33377
  }();
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
- }();
33336
-
33337
- /**
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.
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
- }();
33379
33378
 
33380
33379
  /** @typedef {import("../types/signatures").Signer} Signer */
33381
33380
  /** @typedef {import("../types/signatures").SignerData} SignerData */
@@ -33394,27 +33393,15 @@ var requestCertificate = /*#__PURE__*/function () {
33394
33393
 
33395
33394
  var signDocumentOnBoarding = /*#__PURE__*/function () {
33396
33395
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(signData) {
33397
- var signature, cert, signedDigest, signBody, response, _t;
33396
+ var payload, signature, response, _t;
33398
33397
  return _regenerator().w(function (_context) {
33399
33398
  while (1) switch (_context.p = _context.n) {
33400
33399
  case 0:
33401
- helpers.validateOnBoardingSignDocumentData(signData);
33402
- signature = signData.signature, cert = signData.cert, signedDigest = signData.signedDigest;
33400
+ payload = helpers.validateOnBoardingSignDocumentData(signData);
33401
+ signature = signData.signature;
33403
33402
  _context.p = 1;
33404
- signBody = {
33405
- positions: JSON.stringify(signature.positions.map(function (p) {
33406
- return {
33407
- x: p.x,
33408
- y: p.y,
33409
- page: p.page,
33410
- status: 1
33411
- };
33412
- })),
33413
- publickey: cert,
33414
- signeddigest: signedDigest
33415
- };
33416
33403
  _context.n = 2;
33417
- return httpRequest("services/api/documents/sign/".concat(signature.id), signBody, "PUT");
33404
+ return httpRequest("services/api/documents/sign/".concat(signature.id), payload, "PUT");
33418
33405
  case 2:
33419
33406
  response = _context.v;
33420
33407
  return _context.a(2, new ApacuanaSuccess(response));
@@ -33454,15 +33441,14 @@ var signDocumentOnPremise = /*#__PURE__*/function () {
33454
33441
  }();
33455
33442
  var getDigestToSignOnBoarding = /*#__PURE__*/function () {
33456
33443
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(signData) {
33457
- var _response$data, response, digest, _t2;
33444
+ var _response$data, formData, response, digest, _t2;
33458
33445
  return _regenerator().w(function (_context3) {
33459
33446
  while (1) switch (_context3.p = _context3.n) {
33460
33447
  case 0:
33461
33448
  _context3.p = 0;
33449
+ formData = helpers.createPayloadGetDigest(signData);
33462
33450
  _context3.n = 1;
33463
- return httpRequest("services/api/documents/getdigest/".concat(signData.signatureId), {
33464
- publickey: signData.cert
33465
- }, "POST");
33451
+ return httpRequest("services/api/documents/getdigest/".concat(signData.signatureId), formData, "POST");
33466
33452
  case 1:
33467
33453
  response = _context3.v;
33468
33454
  digest = ((_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.digest) || response.digest;
@@ -33511,14 +33497,14 @@ var getDigestToSignOnPremise = /*#__PURE__*/function () {
33511
33497
  }();
33512
33498
  var addSignerOnBoarding = /*#__PURE__*/function () {
33513
33499
  var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(signerData) {
33514
- var _t3;
33500
+ var payload, _t3;
33515
33501
  return _regenerator().w(function (_context5) {
33516
33502
  while (1) switch (_context5.p = _context5.n) {
33517
33503
  case 0:
33518
- helpers.validateOnBoardingSignerData(signerData);
33504
+ payload = helpers.validateOnBoardingSignerData(signerData);
33519
33505
  _context5.p = 1;
33520
33506
  _context5.n = 2;
33521
- return httpRequest("services/api/documents/signing", signerData, "POST");
33507
+ return httpRequest("services/api/documents/signingsdk", payload, "POST");
33522
33508
  case 2:
33523
33509
  return _context5.a(2, new ApacuanaSuccess({
33524
33510
  signer: signerData.typedoc + signerData.doc
@@ -34047,6 +34033,12 @@ var deleteSignatureVariant = /*#__PURE__*/function () {
34047
34033
  };
34048
34034
  }();
34049
34035
 
34036
+ /**
34037
+ * Creates a new Face Liveness session.
34038
+ * @returns {Promise<CreateFaceLivenessSessionResponse>} Object with the session ID and a success indicator.
34039
+ * @throws {ApacuanaAPIError} If the API response is invalid or the integration type is not supported.
34040
+ * @throws {Error} If the request fails for another reason.
34041
+ */
34050
34042
  var createFaceLivenessSessionOnBoarding = /*#__PURE__*/function () {
34051
34043
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
34052
34044
  var response, _t;
@@ -34058,14 +34050,14 @@ var createFaceLivenessSessionOnBoarding = /*#__PURE__*/function () {
34058
34050
  return httpRequest("services/api/faceliveness/create", {}, "POST");
34059
34051
  case 1:
34060
34052
  response = _context.v;
34061
- if (response.sessionId) {
34053
+ if (response.sessionid) {
34062
34054
  _context.n = 2;
34063
34055
  break;
34064
34056
  }
34065
34057
  throw new ApacuanaAPIError("The API response does not contain the session ID.", response.status, "INVALID_API_RESPONSE");
34066
34058
  case 2:
34067
34059
  return _context.a(2, new ApacuanaSuccess({
34068
- sessionId: response.sessionId
34060
+ sessionId: response.sessionid
34069
34061
  }));
34070
34062
  case 3:
34071
34063
  _context.p = 3;
@@ -34076,7 +34068,7 @@ var createFaceLivenessSessionOnBoarding = /*#__PURE__*/function () {
34076
34068
  }
34077
34069
  throw _t;
34078
34070
  case 4:
34079
- throw new Error("Failed to create Face Liveness session: ".concat(_t.message));
34071
+ throw new ApacuanaAPIError("Failed to create Face Liveness session: ".concat(_t.message));
34080
34072
  case 5:
34081
34073
  return _context.a(2);
34082
34074
  }
@@ -34266,7 +34258,7 @@ var apacuana = {
34266
34258
  */
34267
34259
  init: function () {
34268
34260
  var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config) {
34269
- var currentConfig, _yield$getCustomer, token, userData, _t;
34261
+ var currentConfig, customer, _customer$data, token, userData, _t;
34270
34262
  return _regenerator().w(function (_context) {
34271
34263
  while (1) switch (_context.p = _context.n) {
34272
34264
  case 0:
@@ -34278,27 +34270,37 @@ var apacuana = {
34278
34270
  _context.n = 1;
34279
34271
  break;
34280
34272
  }
34281
- throw new Error("Apacuana SDK: La configuración de CustomerId no se ha guardado" + " correctamente.");
34273
+ throw new ApacuanaAPIError("Apacuana SDK: La configuración de CustomerId no se ha guardado" + " correctamente.", 400, {
34274
+ code: "CONFIG_ERROR"
34275
+ });
34282
34276
  case 1:
34283
34277
  _context.n = 2;
34284
34278
  return getCustomer();
34285
34279
  case 2:
34286
- _yield$getCustomer = _context.v;
34287
- token = _yield$getCustomer.token;
34288
- userData = _yield$getCustomer.userData;
34280
+ customer = _context.v;
34281
+ _customer$data = customer.data, token = _customer$data.token, userData = _customer$data.userData;
34289
34282
  setConfig(_objectSpread2(_objectSpread2({}, currentConfig), {}, {
34290
34283
  token: token,
34291
34284
  userData: userData
34292
34285
  }));
34293
34286
  setAuthToken(token);
34294
- return _context.a(2, true);
34287
+ return _context.a(2, new ApacuanaSuccess({
34288
+ initialized: true,
34289
+ message: "SDK inicializado correctamente."
34290
+ }));
34295
34291
  case 3:
34296
34292
  _context.p = 3;
34297
34293
  _t = _context.v;
34298
34294
  // eslint-disable-next-line no-console
34299
34295
  console.error("Error durante la inicialización del SDK:", _t);
34296
+ if (!(_t instanceof ApacuanaAPIError)) {
34297
+ _context.n = 4;
34298
+ break;
34299
+ }
34300
34300
  throw _t;
34301
34301
  case 4:
34302
+ throw new ApacuanaAPIError(_t.message || "Error desconocido durante la inicialización.", 500, _t);
34303
+ case 5:
34302
34304
  return _context.a(2);
34303
34305
  }
34304
34306
  }, _callee, null, [[0, 3]]);
@@ -34327,8 +34329,8 @@ var apacuana = {
34327
34329
  getCertTypes: getCertTypes,
34328
34330
  getRequerimentsByTypeUser: getRequerimentsByTypeUser,
34329
34331
  createFaceLivenessSession: createFaceLivenessSession,
34330
- validateFaceLiveness: validateFaceLiveness,
34331
- requestCertificate: requestCertificate
34332
+ validateFaceLiveness: validateFaceLiveness
34333
+ // requestCertificate,
34332
34334
  };
34333
34335
 
34334
34336
  export { apacuana as default };