apacuana-sdk-core 0.8.0 → 0.9.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 (33) hide show
  1. package/README.md +85 -0
  2. package/coverage/clover.xml +196 -128
  3. package/coverage/coverage-final.json +7 -7
  4. package/coverage/lcov-report/index.html +29 -29
  5. package/coverage/lcov-report/src/api/certs.js.html +1 -1
  6. package/coverage/lcov-report/src/api/index.html +32 -32
  7. package/coverage/lcov-report/src/api/revocations.js.html +79 -43
  8. package/coverage/lcov-report/src/api/signatures.js.html +595 -73
  9. package/coverage/lcov-report/src/api/users.js.html +1 -1
  10. package/coverage/lcov-report/src/config/index.html +1 -1
  11. package/coverage/lcov-report/src/config/index.js.html +6 -6
  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 +1 -1
  15. package/coverage/lcov-report/src/index.js.html +36 -3
  16. package/coverage/lcov-report/src/utils/constant.js.html +4 -4
  17. package/coverage/lcov-report/src/utils/helpers.js.html +1 -1
  18. package/coverage/lcov-report/src/utils/httpClient.js.html +65 -35
  19. package/coverage/lcov-report/src/utils/index.html +15 -15
  20. package/coverage/lcov.info +352 -220
  21. package/dist/api/signatures.d.ts +5 -0
  22. package/dist/index.d.ts +6 -0
  23. package/dist/index.js +374 -79
  24. package/dist/index.js.map +1 -1
  25. package/dist/index.mjs +374 -79
  26. package/dist/index.mjs.map +1 -1
  27. package/package.json +1 -1
  28. package/src/api/revocations.js +14 -2
  29. package/src/api/signatures.js +174 -0
  30. package/src/index.js +12 -1
  31. package/src/utils/httpClient.js +29 -19
  32. package/tests/api/revocations.test.js +118 -5
  33. package/tests/api/signatures.test.js +306 -0
package/dist/index.mjs CHANGED
@@ -377,7 +377,6 @@ var initHttpClient = function initHttpClient() {
377
377
  axiosInstance = axios.create({
378
378
  baseURL: config.apiUrl,
379
379
  headers: {
380
- "Content-Type": "application/json",
381
380
  "APACUANA-API-Key": config.apiKey,
382
381
  "APACUANA-SECRET-Key": config.secretKey
383
382
  // La cabecera Authorization se deja vacía al inicio.
@@ -390,7 +389,9 @@ var initHttpClient = function initHttpClient() {
390
389
  axiosInstance.interceptors.response.use(function (response) {
391
390
  // Maneja errores lógicos de la API (si el backend devuelve status 2xx con { success: false })
392
391
  if (response.data && response.data.success === false) {
393
- throw new ApacuanaAPIError(response.data.message || "Error lógico en la respuesta de la API (status 2xx)", response.status, response.data.code || "LOGICAL_API_ERROR");
392
+ var _response$data, _response$data2;
393
+ var errorMessage = ((_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.msg) || ((_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.message) || "Error lógico desconocido desde la API.";
394
+ throw new ApacuanaAPIError(errorMessage, response.status, response.data.code || "LOGICAL_API_ERROR");
394
395
  }
395
396
  return response;
396
397
  }, function (error) {
@@ -401,7 +402,8 @@ var initHttpClient = function initHttpClient() {
401
402
  var _error$response = error.response,
402
403
  status = _error$response.status,
403
404
  data = _error$response.data;
404
- throw new ApacuanaAPIError(data.message || "Error en la API: ".concat(status), status, data.code || "API_ERROR");
405
+ var errorMessage = (data === null || data === void 0 ? void 0 : data.msg) || (data === null || data === void 0 ? void 0 : data.message) || "Error desconocido desde la API.";
406
+ throw new ApacuanaAPIError(errorMessage, status, (data === null || data === void 0 ? void 0 : data.code) || "API_ERROR");
405
407
  }
406
408
  if (error.request) {
407
409
  // La petición fue hecha, pero no se recibió respuesta (red caída, CORS, timeout)
@@ -445,6 +447,9 @@ var httpRequest = /*#__PURE__*/function () {
445
447
  var data,
446
448
  method,
447
449
  dataToSend,
450
+ requestConfig,
451
+ hasFile,
452
+ formData,
448
453
  response,
449
454
  _args = arguments,
450
455
  _t,
@@ -460,9 +465,19 @@ var httpRequest = /*#__PURE__*/function () {
460
465
  }
461
466
  throw new Error("Apacuana SDK: Cliente HTTP no inicializado. " + "Llama a apacuana.init() primero.");
462
467
  case 1:
463
- // Creamos el cuerpo de la petición fusionando los datos de la llamada
464
- // con los parámetros de inicialización.
465
- dataToSend = _objectSpread2({}, data);
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;
478
+ } else {
479
+ dataToSend = _objectSpread2({}, data);
480
+ }
466
481
  _context.p = 2;
467
482
  _t = method.toUpperCase();
468
483
  _context.n = _t === "GET" ? 3 : _t === "POST" ? 5 : _t === "PUT" ? 7 : _t === "DELETE" ? 9 : 11;
@@ -477,21 +492,21 @@ var httpRequest = /*#__PURE__*/function () {
477
492
  return _context.a(3, 12);
478
493
  case 5:
479
494
  _context.n = 6;
480
- return axiosInstance.post(path, dataToSend);
495
+ return axiosInstance.post(path, dataToSend, requestConfig);
481
496
  case 6:
482
497
  response = _context.v;
483
498
  return _context.a(3, 12);
484
499
  case 7:
485
500
  _context.n = 8;
486
- return axiosInstance.put(path, dataToSend);
501
+ return axiosInstance.put(path, dataToSend, requestConfig);
487
502
  case 8:
488
503
  response = _context.v;
489
504
  return _context.a(3, 12);
490
505
  case 9:
491
506
  _context.n = 10;
492
- return axiosInstance["delete"](path, {
507
+ return axiosInstance["delete"](path, _objectSpread2({
493
508
  data: dataToSend
494
- });
509
+ }, requestConfig));
495
510
  case 10:
496
511
  response = _context.v;
497
512
  return _context.a(3, 12);
@@ -502,9 +517,6 @@ var httpRequest = /*#__PURE__*/function () {
502
517
  case 13:
503
518
  _context.p = 13;
504
519
  _t2 = _context.v;
505
- // Si la petición falla, el interceptor ya procesó el error.
506
- // Simplemente relanzamos el error para que sea capturado por la función de API.
507
- // eslint-disable-next-line no-console
508
520
  console.error("[HTTP Client] Fallo en la petici\xF3n a ".concat(path, ":"), _t2);
509
521
  throw _t2;
510
522
  case 14:
@@ -662,36 +674,43 @@ var requestRevocation = /*#__PURE__*/function () {
662
674
  */
663
675
  var getRevocationReasons = /*#__PURE__*/function () {
664
676
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
665
- var response, _t2;
677
+ var _getConfig, integrationType, response, _t2;
666
678
  return _regenerator().w(function (_context2) {
667
679
  while (1) switch (_context2.p = _context2.n) {
668
680
  case 0:
669
- _context2.p = 0;
670
- _context2.n = 1;
671
- return httpRequest("config/api/revocation/reasonsonboarding", {}, "GET");
681
+ _getConfig = getConfig(), integrationType = _getConfig.integrationType;
682
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
683
+ _context2.n = 1;
684
+ break;
685
+ }
686
+ throw new ApacuanaAPIError("Get revocation reasons is not supported for integration type: ".concat(integrationType), 501, "NOT_IMPLEMENTED");
672
687
  case 1:
688
+ _context2.p = 1;
689
+ _context2.n = 2;
690
+ return httpRequest("GET", "config/api/revocation/reasonsonboarding", {});
691
+ case 2:
673
692
  response = _context2.v;
674
693
  if (response.records) {
675
- _context2.n = 2;
694
+ _context2.n = 3;
676
695
  break;
677
696
  }
678
697
  throw new ApacuanaAPIError("Failed to fetch revocation reasons.");
679
- case 2:
680
- return _context2.a(2, response.records);
681
698
  case 3:
682
- _context2.p = 3;
699
+ return _context2.a(2, response.records);
700
+ case 4:
701
+ _context2.p = 4;
683
702
  _t2 = _context2.v;
684
703
  if (!(_t2 instanceof ApacuanaAPIError)) {
685
- _context2.n = 4;
704
+ _context2.n = 5;
686
705
  break;
687
706
  }
688
707
  throw _t2;
689
- case 4:
690
- throw new Error("Failed to get revocation reasons. Please try again later.");
691
708
  case 5:
709
+ throw new Error("Failed to get revocation reasons. Please try again later.");
710
+ case 6:
692
711
  return _context2.a(2);
693
712
  }
694
- }, _callee2, null, [[0, 3]]);
713
+ }, _callee2, null, [[1, 4]]);
695
714
  }));
696
715
  return function getRevocationReasons() {
697
716
  return _ref2.apply(this, arguments);
@@ -33365,6 +33384,154 @@ var getDocsOnBoarding = /*#__PURE__*/function () {
33365
33384
  return _ref8.apply(this, arguments);
33366
33385
  };
33367
33386
  }();
33387
+ var uploadSignatureVariantOnBoarding = /*#__PURE__*/function () {
33388
+ var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(_ref9) {
33389
+ var file, response, _t5;
33390
+ return _regenerator().w(function (_context9) {
33391
+ while (1) switch (_context9.p = _context9.n) {
33392
+ case 0:
33393
+ file = _ref9.file;
33394
+ _context9.p = 1;
33395
+ _context9.n = 2;
33396
+ return httpRequest("services/api/customer/signaturephoto", {
33397
+ file: file
33398
+ }, "POST");
33399
+ case 2:
33400
+ response = _context9.v;
33401
+ return _context9.a(2, _objectSpread2(_objectSpread2({}, response), {}, {
33402
+ success: true
33403
+ }));
33404
+ case 3:
33405
+ _context9.p = 3;
33406
+ _t5 = _context9.v;
33407
+ if (!(_t5 instanceof ApacuanaAPIError)) {
33408
+ _context9.n = 4;
33409
+ break;
33410
+ }
33411
+ throw _t5;
33412
+ case 4:
33413
+ throw new ApacuanaAPIError("Failed to upload signature variant: ".concat(_t5.message || "Unknown error"));
33414
+ case 5:
33415
+ return _context9.a(2);
33416
+ }
33417
+ }, _callee9, null, [[1, 3]]);
33418
+ }));
33419
+ return function uploadSignatureVariantOnBoarding(_x5) {
33420
+ return _ref0.apply(this, arguments);
33421
+ };
33422
+ }();
33423
+ var uploadSignatureVariantOnPremise = /*#__PURE__*/function () {
33424
+ var _ref1 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
33425
+ return _regenerator().w(function (_context0) {
33426
+ while (1) switch (_context0.n) {
33427
+ case 0:
33428
+ throw new ApacuanaAPIError("Uploading signature variants is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
33429
+ case 1:
33430
+ return _context0.a(2);
33431
+ }
33432
+ }, _callee0);
33433
+ }));
33434
+ return function uploadSignatureVariantOnPremise() {
33435
+ return _ref1.apply(this, arguments);
33436
+ };
33437
+ }();
33438
+ var getSignatureVariantOnBoarding = /*#__PURE__*/function () {
33439
+ var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
33440
+ var _getConfig2, customerId, response, _t6;
33441
+ return _regenerator().w(function (_context1) {
33442
+ while (1) switch (_context1.p = _context1.n) {
33443
+ case 0:
33444
+ _getConfig2 = getConfig(), customerId = _getConfig2.customerId;
33445
+ _context1.p = 1;
33446
+ _context1.n = 2;
33447
+ return httpRequest("services/api/customer/getsignaturephotosdk/".concat(customerId), {}, "GET");
33448
+ case 2:
33449
+ response = _context1.v;
33450
+ return _context1.a(2, _objectSpread2(_objectSpread2({}, response), {}, {
33451
+ success: true
33452
+ }));
33453
+ case 3:
33454
+ _context1.p = 3;
33455
+ _t6 = _context1.v;
33456
+ if (!(_t6 instanceof ApacuanaAPIError)) {
33457
+ _context1.n = 4;
33458
+ break;
33459
+ }
33460
+ throw _t6;
33461
+ case 4:
33462
+ throw new ApacuanaAPIError("Failed to get signature variant: ".concat(_t6.message || "Unknown error"));
33463
+ case 5:
33464
+ return _context1.a(2);
33465
+ }
33466
+ }, _callee1, null, [[1, 3]]);
33467
+ }));
33468
+ return function getSignatureVariantOnBoarding() {
33469
+ return _ref10.apply(this, arguments);
33470
+ };
33471
+ }();
33472
+ var getSignatureVariantOnPremise = /*#__PURE__*/function () {
33473
+ var _ref11 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
33474
+ return _regenerator().w(function (_context10) {
33475
+ while (1) switch (_context10.n) {
33476
+ case 0:
33477
+ throw new ApacuanaAPIError("Getting signature variants is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
33478
+ case 1:
33479
+ return _context10.a(2);
33480
+ }
33481
+ }, _callee10);
33482
+ }));
33483
+ return function getSignatureVariantOnPremise() {
33484
+ return _ref11.apply(this, arguments);
33485
+ };
33486
+ }();
33487
+ var deleteSignatureVariantOnBoarding = /*#__PURE__*/function () {
33488
+ var _ref12 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
33489
+ var response, _t7;
33490
+ return _regenerator().w(function (_context11) {
33491
+ while (1) switch (_context11.p = _context11.n) {
33492
+ case 0:
33493
+ _context11.p = 0;
33494
+ _context11.n = 1;
33495
+ return httpRequest("services/api/customer/cleansignaturephoto", {}, "DELETE");
33496
+ case 1:
33497
+ response = _context11.v;
33498
+ return _context11.a(2, _objectSpread2(_objectSpread2({}, response), {}, {
33499
+ success: true
33500
+ }));
33501
+ case 2:
33502
+ _context11.p = 2;
33503
+ _t7 = _context11.v;
33504
+ if (!(_t7 instanceof ApacuanaAPIError)) {
33505
+ _context11.n = 3;
33506
+ break;
33507
+ }
33508
+ throw _t7;
33509
+ case 3:
33510
+ throw new ApacuanaAPIError("Failed to delete signature variant: ".concat(_t7.message || "Unknown error"));
33511
+ case 4:
33512
+ return _context11.a(2);
33513
+ }
33514
+ }, _callee11, null, [[0, 2]]);
33515
+ }));
33516
+ return function deleteSignatureVariantOnBoarding() {
33517
+ return _ref12.apply(this, arguments);
33518
+ };
33519
+ }();
33520
+ var deleteSignatureVariantOnPremise = /*#__PURE__*/function () {
33521
+ var _ref13 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
33522
+ return _regenerator().w(function (_context12) {
33523
+ while (1) switch (_context12.n) {
33524
+ case 0:
33525
+ throw new ApacuanaAPIError("Deleting signature variants is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
33526
+ case 1:
33527
+ return _context12.a(2);
33528
+ }
33529
+ }, _callee12);
33530
+ }));
33531
+ return function deleteSignatureVariantOnPremise() {
33532
+ return _ref13.apply(this, arguments);
33533
+ };
33534
+ }();
33368
33535
 
33369
33536
  // =================================================================
33370
33537
  // Exported Functions
@@ -33378,32 +33545,32 @@ var getDocsOnBoarding = /*#__PURE__*/function () {
33378
33545
  * @throws {ApacuanaAPIError} Arroja un error 'NOT_IMPLEMENTED' para cualquier tipo de integración.
33379
33546
  */
33380
33547
  var signDocument = /*#__PURE__*/function () {
33381
- var _ref9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(signData) {
33382
- var _getConfig2, integrationType;
33383
- return _regenerator().w(function (_context9) {
33384
- while (1) switch (_context9.n) {
33548
+ var _ref14 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(signData) {
33549
+ var _getConfig3, integrationType;
33550
+ return _regenerator().w(function (_context13) {
33551
+ while (1) switch (_context13.n) {
33385
33552
  case 0:
33386
- _getConfig2 = getConfig(), integrationType = _getConfig2.integrationType;
33553
+ _getConfig3 = getConfig(), integrationType = _getConfig3.integrationType;
33387
33554
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33388
- _context9.n = 1;
33555
+ _context13.n = 1;
33389
33556
  break;
33390
33557
  }
33391
- return _context9.a(2, signDocumentOnBoarding(signData));
33558
+ return _context13.a(2, signDocumentOnBoarding(signData));
33392
33559
  case 1:
33393
33560
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33394
- _context9.n = 2;
33561
+ _context13.n = 2;
33395
33562
  break;
33396
33563
  }
33397
- return _context9.a(2, signDocumentOnPremise());
33564
+ return _context13.a(2, signDocumentOnPremise());
33398
33565
  case 2:
33399
33566
  throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
33400
33567
  case 3:
33401
- return _context9.a(2);
33568
+ return _context13.a(2);
33402
33569
  }
33403
- }, _callee9);
33570
+ }, _callee13);
33404
33571
  }));
33405
- return function signDocument(_x5) {
33406
- return _ref9.apply(this, arguments);
33572
+ return function signDocument(_x6) {
33573
+ return _ref14.apply(this, arguments);
33407
33574
  };
33408
33575
  }();
33409
33576
 
@@ -33414,33 +33581,33 @@ var signDocument = /*#__PURE__*/function () {
33414
33581
  * @throws {ApacuanaAPIError} Si los datos de entrada son inválidos, la llamada a la API falla, o el tipo de integración no es soportado.
33415
33582
  */
33416
33583
  var getDigest = /*#__PURE__*/function () {
33417
- var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(signData) {
33418
- var _getConfig3, integrationType;
33419
- return _regenerator().w(function (_context0) {
33420
- while (1) switch (_context0.n) {
33584
+ var _ref15 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(signData) {
33585
+ var _getConfig4, integrationType;
33586
+ return _regenerator().w(function (_context14) {
33587
+ while (1) switch (_context14.n) {
33421
33588
  case 0:
33422
33589
  helpers.validateGetDigestData(signData);
33423
- _getConfig3 = getConfig(), integrationType = _getConfig3.integrationType;
33590
+ _getConfig4 = getConfig(), integrationType = _getConfig4.integrationType;
33424
33591
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33425
- _context0.n = 1;
33592
+ _context14.n = 1;
33426
33593
  break;
33427
33594
  }
33428
- return _context0.a(2, getDigestToSignOnBoarding(signData));
33595
+ return _context14.a(2, getDigestToSignOnBoarding(signData));
33429
33596
  case 1:
33430
33597
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33431
- _context0.n = 2;
33598
+ _context14.n = 2;
33432
33599
  break;
33433
33600
  }
33434
- return _context0.a(2, getDigestToSignOnPremise());
33601
+ return _context14.a(2, getDigestToSignOnPremise());
33435
33602
  case 2:
33436
33603
  throw new ApacuanaAPIError("Document retrieval is not supported for an unknown integration type: ".concat(integrationType), 501, "NOT_IMPLEMENTED");
33437
33604
  case 3:
33438
- return _context0.a(2);
33605
+ return _context14.a(2);
33439
33606
  }
33440
- }, _callee0);
33607
+ }, _callee14);
33441
33608
  }));
33442
- return function getDigest(_x6) {
33443
- return _ref0.apply(this, arguments);
33609
+ return function getDigest(_x7) {
33610
+ return _ref15.apply(this, arguments);
33444
33611
  };
33445
33612
  }();
33446
33613
 
@@ -33476,38 +33643,38 @@ var getDigest = /*#__PURE__*/function () {
33476
33643
  * @throws {ApacuanaAPIError} If signerData is invalid or if the integration type is not supported.
33477
33644
  */
33478
33645
  var addSigner = /*#__PURE__*/function () {
33479
- var _ref1 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(signerData) {
33480
- var _getConfig4, integrationType;
33481
- return _regenerator().w(function (_context1) {
33482
- while (1) switch (_context1.n) {
33646
+ var _ref16 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(signerData) {
33647
+ var _getConfig5, integrationType;
33648
+ return _regenerator().w(function (_context15) {
33649
+ while (1) switch (_context15.n) {
33483
33650
  case 0:
33484
33651
  if (!(!signerData || _typeof(signerData) !== "object" || Object.keys(signerData).length === 0)) {
33485
- _context1.n = 1;
33652
+ _context15.n = 1;
33486
33653
  break;
33487
33654
  }
33488
33655
  throw new ApacuanaAPIError("Signer data (signerData) is required and must be a non-empty object.", 400, "INVALID_PARAMETER");
33489
33656
  case 1:
33490
- _getConfig4 = getConfig(), integrationType = _getConfig4.integrationType;
33657
+ _getConfig5 = getConfig(), integrationType = _getConfig5.integrationType;
33491
33658
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33492
- _context1.n = 2;
33659
+ _context15.n = 2;
33493
33660
  break;
33494
33661
  }
33495
- return _context1.a(2, addSignerOnBoarding(signerData));
33662
+ return _context15.a(2, addSignerOnBoarding(signerData));
33496
33663
  case 2:
33497
33664
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33498
- _context1.n = 3;
33665
+ _context15.n = 3;
33499
33666
  break;
33500
33667
  }
33501
- return _context1.a(2, addSignerOnPremise());
33668
+ return _context15.a(2, addSignerOnPremise());
33502
33669
  case 3:
33503
33670
  throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
33504
33671
  case 4:
33505
- return _context1.a(2);
33672
+ return _context15.a(2);
33506
33673
  }
33507
- }, _callee1);
33674
+ }, _callee15);
33508
33675
  }));
33509
- return function addSigner(_x7) {
33510
- return _ref1.apply(this, arguments);
33676
+ return function addSigner(_x8) {
33677
+ return _ref16.apply(this, arguments);
33511
33678
  };
33512
33679
  }();
33513
33680
 
@@ -33518,33 +33685,158 @@ var addSigner = /*#__PURE__*/function () {
33518
33685
  * @throws {ApacuanaAPIError} Si los parámetros de paginación son inválidos, 'customerId' no está configurado, la llamada a la API falla, o el tipo de integración no es soportado.
33519
33686
  */
33520
33687
  var getDocs = /*#__PURE__*/function () {
33521
- var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(data) {
33522
- var _getConfig5, integrationType;
33523
- return _regenerator().w(function (_context10) {
33524
- while (1) switch (_context10.n) {
33688
+ var _ref17 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(data) {
33689
+ var _getConfig6, integrationType;
33690
+ return _regenerator().w(function (_context16) {
33691
+ while (1) switch (_context16.n) {
33525
33692
  case 0:
33526
33693
  helpers.validateGetDocsData(data);
33527
- _getConfig5 = getConfig(), integrationType = _getConfig5.integrationType;
33694
+ _getConfig6 = getConfig(), integrationType = _getConfig6.integrationType;
33528
33695
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33529
- _context10.n = 1;
33696
+ _context16.n = 1;
33530
33697
  break;
33531
33698
  }
33532
- return _context10.a(2, getDocsOnBoarding(data));
33699
+ return _context16.a(2, getDocsOnBoarding(data));
33533
33700
  case 1:
33534
33701
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33535
- _context10.n = 2;
33702
+ _context16.n = 2;
33536
33703
  break;
33537
33704
  }
33538
- return _context10.a(2, getDocsOnPremise());
33705
+ return _context16.a(2, getDocsOnPremise());
33539
33706
  case 2:
33540
33707
  throw new ApacuanaAPIError("Document retrieval is not supported for an unknown integration type: ".concat(integrationType), 501, "NOT_IMPLEMENTED");
33541
33708
  case 3:
33542
- return _context10.a(2);
33709
+ return _context16.a(2);
33543
33710
  }
33544
- }, _callee10);
33711
+ }, _callee16);
33545
33712
  }));
33546
- return function getDocs(_x8) {
33547
- return _ref10.apply(this, arguments);
33713
+ return function getDocs(_x9) {
33714
+ return _ref17.apply(this, arguments);
33715
+ };
33716
+ }();
33717
+
33718
+ /**
33719
+ * Sube una variante de firma para un firmante.
33720
+ * @param {object} data - Datos para la subida.
33721
+ * @param {File} data.file - El archivo de la variante de firma (debe ser PNG).
33722
+ * @returns {Promise<object>} Una promesa que resuelve a un objeto con el resultado de la operación.
33723
+ * @throws {ApacuanaAPIError} Si los datos son inválidos o la llamada a la API falla.
33724
+ */
33725
+ var uploadSignatureVariant = /*#__PURE__*/function () {
33726
+ var _ref18 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(data) {
33727
+ var _getConfig7, integrationType;
33728
+ return _regenerator().w(function (_context17) {
33729
+ while (1) switch (_context17.n) {
33730
+ case 0:
33731
+ if (!(!data || !data.file)) {
33732
+ _context17.n = 1;
33733
+ break;
33734
+ }
33735
+ throw new ApacuanaAPIError("El parámetro 'file' es requerido.", 400, "INVALID_PARAMETER");
33736
+ case 1:
33737
+ if (!(typeof File === "undefined" || !(data.file instanceof File))) {
33738
+ _context17.n = 2;
33739
+ break;
33740
+ }
33741
+ throw new ApacuanaAPIError("El parámetro 'file' debe ser una instancia de 'File'.", 400, "INVALID_PARAMETER");
33742
+ case 2:
33743
+ if (!(data.file.type !== "image/png")) {
33744
+ _context17.n = 3;
33745
+ break;
33746
+ }
33747
+ throw new ApacuanaAPIError("El archivo debe ser de tipo PNG (image/png).", 400, "INVALID_PARAMETER");
33748
+ case 3:
33749
+ _getConfig7 = getConfig(), integrationType = _getConfig7.integrationType;
33750
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33751
+ _context17.n = 4;
33752
+ break;
33753
+ }
33754
+ return _context17.a(2, uploadSignatureVariantOnBoarding(data));
33755
+ case 4:
33756
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33757
+ _context17.n = 5;
33758
+ break;
33759
+ }
33760
+ return _context17.a(2, uploadSignatureVariantOnPremise());
33761
+ case 5:
33762
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
33763
+ case 6:
33764
+ return _context17.a(2);
33765
+ }
33766
+ }, _callee17);
33767
+ }));
33768
+ return function uploadSignatureVariant(_x0) {
33769
+ return _ref18.apply(this, arguments);
33770
+ };
33771
+ }();
33772
+
33773
+ /**
33774
+ * Obtiene la variante de firma del firmante.
33775
+ * @returns {Promise<object>} Una promesa que resuelve a un objeto con los datos de la variante de firma.
33776
+ * @throws {ApacuanaAPIError} Si la llamada a la API falla o el tipo de integración no es soportado.
33777
+ */
33778
+ var getSignatureVariant = /*#__PURE__*/function () {
33779
+ var _ref19 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
33780
+ var _getConfig8, integrationType;
33781
+ return _regenerator().w(function (_context18) {
33782
+ while (1) switch (_context18.n) {
33783
+ case 0:
33784
+ _getConfig8 = getConfig(), integrationType = _getConfig8.integrationType;
33785
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33786
+ _context18.n = 1;
33787
+ break;
33788
+ }
33789
+ return _context18.a(2, getSignatureVariantOnBoarding());
33790
+ case 1:
33791
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33792
+ _context18.n = 2;
33793
+ break;
33794
+ }
33795
+ return _context18.a(2, getSignatureVariantOnPremise());
33796
+ case 2:
33797
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
33798
+ case 3:
33799
+ return _context18.a(2);
33800
+ }
33801
+ }, _callee18);
33802
+ }));
33803
+ return function getSignatureVariant() {
33804
+ return _ref19.apply(this, arguments);
33805
+ };
33806
+ }();
33807
+
33808
+ /**
33809
+ * Elimina la variante de firma del firmante.
33810
+ * @returns {Promise<object>} Una promesa que resuelve a un objeto con el resultado de la operación.
33811
+ * @throws {ApacuanaAPIError} Si la llamada a la API falla o el tipo de integración no es soportado.
33812
+ */
33813
+ var deleteSignatureVariant = /*#__PURE__*/function () {
33814
+ var _ref20 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19() {
33815
+ var _getConfig9, integrationType;
33816
+ return _regenerator().w(function (_context19) {
33817
+ while (1) switch (_context19.n) {
33818
+ case 0:
33819
+ _getConfig9 = getConfig(), integrationType = _getConfig9.integrationType;
33820
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33821
+ _context19.n = 1;
33822
+ break;
33823
+ }
33824
+ return _context19.a(2, deleteSignatureVariantOnBoarding());
33825
+ case 1:
33826
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33827
+ _context19.n = 2;
33828
+ break;
33829
+ }
33830
+ return _context19.a(2, deleteSignatureVariantOnPremise());
33831
+ case 2:
33832
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
33833
+ case 3:
33834
+ return _context19.a(2);
33835
+ }
33836
+ }, _callee19);
33837
+ }));
33838
+ return function deleteSignatureVariant() {
33839
+ return _ref20.apply(this, arguments);
33548
33840
  };
33549
33841
  }();
33550
33842
 
@@ -33617,7 +33909,10 @@ var apacuana = {
33617
33909
  generateCert: generateCert,
33618
33910
  signDocument: signDocument,
33619
33911
  getDigest: getDigest,
33620
- getRevocationReasons: getRevocationReasons
33912
+ getRevocationReasons: getRevocationReasons,
33913
+ uploadSignatureVariant: uploadSignatureVariant,
33914
+ getSignatureVariant: getSignatureVariant,
33915
+ deleteSignatureVariant: deleteSignatureVariant
33621
33916
  };
33622
33917
 
33623
33918
  export { apacuana as default };