apacuana-sdk-core 0.8.0 → 0.10.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 (36) hide show
  1. package/README.md +150 -0
  2. package/coverage/clover.xml +233 -130
  3. package/coverage/coverage-final.json +8 -8
  4. package/coverage/lcov-report/index.html +29 -29
  5. package/coverage/lcov-report/src/api/certs.js.html +390 -9
  6. package/coverage/lcov-report/src/api/index.html +40 -40
  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 +58 -4
  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 +422 -227
  21. package/dist/api/certs.d.ts +44 -0
  22. package/dist/api/signatures.d.ts +5 -0
  23. package/dist/index.d.ts +10 -0
  24. package/dist/index.js +579 -79
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +579 -79
  27. package/dist/index.mjs.map +1 -1
  28. package/package.json +1 -1
  29. package/src/api/certs.js +127 -0
  30. package/src/api/revocations.js +14 -2
  31. package/src/api/signatures.js +174 -0
  32. package/src/index.js +20 -2
  33. package/src/utils/httpClient.js +29 -19
  34. package/tests/api/certs.test.js +113 -1
  35. package/tests/api/revocations.test.js +118 -5
  36. 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);
@@ -33064,6 +33083,209 @@ var getCertStatus = function getCertStatus() {
33064
33083
  };
33065
33084
  };
33066
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
+ var getCertTypesOnBoarding = /*#__PURE__*/function () {
33099
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
33100
+ var response, _t2;
33101
+ return _regenerator().w(function (_context4) {
33102
+ while (1) switch (_context4.p = _context4.n) {
33103
+ case 0:
33104
+ _context4.p = 0;
33105
+ _context4.n = 1;
33106
+ return httpRequest("services/api/customer/typeusers", {}, "GET");
33107
+ case 1:
33108
+ response = _context4.v;
33109
+ return _context4.a(2, _objectSpread2(_objectSpread2({}, response), {}, {
33110
+ success: true
33111
+ }));
33112
+ case 2:
33113
+ _context4.p = 2;
33114
+ _t2 = _context4.v;
33115
+ if (!(_t2 instanceof ApacuanaAPIError)) {
33116
+ _context4.n = 3;
33117
+ break;
33118
+ }
33119
+ throw _t2;
33120
+ case 3:
33121
+ throw new Error("Failed to get certificate types: ".concat(_t2.message));
33122
+ case 4:
33123
+ return _context4.a(2);
33124
+ }
33125
+ }, _callee4, null, [[0, 2]]);
33126
+ }));
33127
+ return function getCertTypesOnBoarding() {
33128
+ return _ref4.apply(this, arguments);
33129
+ };
33130
+ }();
33131
+ var getCertTypesOnPremise = /*#__PURE__*/function () {
33132
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
33133
+ return _regenerator().w(function (_context5) {
33134
+ while (1) switch (_context5.n) {
33135
+ case 0:
33136
+ throw new ApacuanaAPIError("Getting certificate types is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
33137
+ case 1:
33138
+ return _context5.a(2);
33139
+ }
33140
+ }, _callee5);
33141
+ }));
33142
+ return function getCertTypesOnPremise() {
33143
+ return _ref5.apply(this, arguments);
33144
+ };
33145
+ }();
33146
+
33147
+ /**
33148
+ * Gets the available certificate types.
33149
+ * @returns {Promise<GetCertTypesResponse>} Object with the list of certificate types and a success indicator.
33150
+ * @throws {ApacuanaAPIError} If the API response is invalid or the integration type is not supported.
33151
+ * @throws {Error} If the request fails for another reason.
33152
+ */
33153
+ var getCertTypes = /*#__PURE__*/function () {
33154
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
33155
+ var _getConfig2, integrationType;
33156
+ return _regenerator().w(function (_context6) {
33157
+ while (1) switch (_context6.n) {
33158
+ case 0:
33159
+ _getConfig2 = getConfig(), integrationType = _getConfig2.integrationType;
33160
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33161
+ _context6.n = 1;
33162
+ break;
33163
+ }
33164
+ return _context6.a(2, getCertTypesOnBoarding());
33165
+ case 1:
33166
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33167
+ _context6.n = 2;
33168
+ break;
33169
+ }
33170
+ return _context6.a(2, getCertTypesOnPremise());
33171
+ case 2:
33172
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
33173
+ case 3:
33174
+ return _context6.a(2);
33175
+ }
33176
+ }, _callee6);
33177
+ }));
33178
+ return function getCertTypes() {
33179
+ return _ref6.apply(this, arguments);
33180
+ };
33181
+ }();
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
+ var getRequerimentsByTypeUserOnBoarding = /*#__PURE__*/function () {
33196
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(type) {
33197
+ var response, _t3;
33198
+ return _regenerator().w(function (_context7) {
33199
+ while (1) switch (_context7.p = _context7.n) {
33200
+ case 0:
33201
+ _context7.p = 0;
33202
+ _context7.n = 1;
33203
+ return httpRequest("services/api/customer/documentspref?typeuser=".concat(type), {}, "GET");
33204
+ case 1:
33205
+ response = _context7.v;
33206
+ return _context7.a(2, _objectSpread2(_objectSpread2({}, response), {}, {
33207
+ success: true
33208
+ }));
33209
+ case 2:
33210
+ _context7.p = 2;
33211
+ _t3 = _context7.v;
33212
+ if (!(_t3 instanceof ApacuanaAPIError)) {
33213
+ _context7.n = 3;
33214
+ break;
33215
+ }
33216
+ throw _t3;
33217
+ case 3:
33218
+ throw new Error("Failed to get requirements: ".concat(_t3.message));
33219
+ case 4:
33220
+ return _context7.a(2);
33221
+ }
33222
+ }, _callee7, null, [[0, 2]]);
33223
+ }));
33224
+ return function getRequerimentsByTypeUserOnBoarding(_x3) {
33225
+ return _ref7.apply(this, arguments);
33226
+ };
33227
+ }();
33228
+ var getRequerimentsByTypeUserOnPremise = /*#__PURE__*/function () {
33229
+ var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
33230
+ return _regenerator().w(function (_context8) {
33231
+ while (1) switch (_context8.n) {
33232
+ case 0:
33233
+ throw new ApacuanaAPIError("Getting requirements by user type is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
33234
+ case 1:
33235
+ return _context8.a(2);
33236
+ }
33237
+ }, _callee8);
33238
+ }));
33239
+ return function getRequerimentsByTypeUserOnPremise() {
33240
+ return _ref8.apply(this, arguments);
33241
+ };
33242
+ }();
33243
+
33244
+ /**
33245
+ * Gets the requirements for a given user type.
33246
+ * @param {object} params - The parameters.
33247
+ * @param {number} params.type - The user type to get requirements for.
33248
+ * @returns {Promise<GetRequirementsResponse>} Object with the list of requirements and a success indicator.
33249
+ * @throws {ApacuanaAPIError} If the API response is invalid or the integration type is not supported.
33250
+ * @throws {Error} If the request fails for another reason or the type is invalid.
33251
+ */
33252
+ var getRequerimentsByTypeUser = /*#__PURE__*/function () {
33253
+ var _ref9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(params) {
33254
+ var type, _getConfig3, integrationType;
33255
+ return _regenerator().w(function (_context9) {
33256
+ while (1) switch (_context9.n) {
33257
+ case 0:
33258
+ if (!(!params || typeof params.type !== "number")) {
33259
+ _context9.n = 1;
33260
+ break;
33261
+ }
33262
+ throw new Error('The "params" object with a numeric "type" property is required.');
33263
+ case 1:
33264
+ type = params.type;
33265
+ _getConfig3 = getConfig(), integrationType = _getConfig3.integrationType;
33266
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33267
+ _context9.n = 2;
33268
+ break;
33269
+ }
33270
+ return _context9.a(2, getRequerimentsByTypeUserOnBoarding(type));
33271
+ case 2:
33272
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33273
+ _context9.n = 3;
33274
+ break;
33275
+ }
33276
+ return _context9.a(2, getRequerimentsByTypeUserOnPremise());
33277
+ case 3:
33278
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
33279
+ case 4:
33280
+ return _context9.a(2);
33281
+ }
33282
+ }, _callee9);
33283
+ }));
33284
+ return function getRequerimentsByTypeUser(_x4) {
33285
+ return _ref9.apply(this, arguments);
33286
+ };
33287
+ }();
33288
+
33067
33289
  // =================================================================
33068
33290
  // Type Definitions
33069
33291
  // =================================================================
@@ -33365,6 +33587,154 @@ var getDocsOnBoarding = /*#__PURE__*/function () {
33365
33587
  return _ref8.apply(this, arguments);
33366
33588
  };
33367
33589
  }();
33590
+ var uploadSignatureVariantOnBoarding = /*#__PURE__*/function () {
33591
+ var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(_ref9) {
33592
+ var file, response, _t5;
33593
+ return _regenerator().w(function (_context9) {
33594
+ while (1) switch (_context9.p = _context9.n) {
33595
+ case 0:
33596
+ file = _ref9.file;
33597
+ _context9.p = 1;
33598
+ _context9.n = 2;
33599
+ return httpRequest("services/api/customer/signaturephoto", {
33600
+ file: file
33601
+ }, "POST");
33602
+ case 2:
33603
+ response = _context9.v;
33604
+ return _context9.a(2, _objectSpread2(_objectSpread2({}, response), {}, {
33605
+ success: true
33606
+ }));
33607
+ case 3:
33608
+ _context9.p = 3;
33609
+ _t5 = _context9.v;
33610
+ if (!(_t5 instanceof ApacuanaAPIError)) {
33611
+ _context9.n = 4;
33612
+ break;
33613
+ }
33614
+ throw _t5;
33615
+ case 4:
33616
+ throw new ApacuanaAPIError("Failed to upload signature variant: ".concat(_t5.message || "Unknown error"));
33617
+ case 5:
33618
+ return _context9.a(2);
33619
+ }
33620
+ }, _callee9, null, [[1, 3]]);
33621
+ }));
33622
+ return function uploadSignatureVariantOnBoarding(_x5) {
33623
+ return _ref0.apply(this, arguments);
33624
+ };
33625
+ }();
33626
+ var uploadSignatureVariantOnPremise = /*#__PURE__*/function () {
33627
+ var _ref1 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
33628
+ return _regenerator().w(function (_context0) {
33629
+ while (1) switch (_context0.n) {
33630
+ case 0:
33631
+ throw new ApacuanaAPIError("Uploading signature variants is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
33632
+ case 1:
33633
+ return _context0.a(2);
33634
+ }
33635
+ }, _callee0);
33636
+ }));
33637
+ return function uploadSignatureVariantOnPremise() {
33638
+ return _ref1.apply(this, arguments);
33639
+ };
33640
+ }();
33641
+ var getSignatureVariantOnBoarding = /*#__PURE__*/function () {
33642
+ var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
33643
+ var _getConfig2, customerId, response, _t6;
33644
+ return _regenerator().w(function (_context1) {
33645
+ while (1) switch (_context1.p = _context1.n) {
33646
+ case 0:
33647
+ _getConfig2 = getConfig(), customerId = _getConfig2.customerId;
33648
+ _context1.p = 1;
33649
+ _context1.n = 2;
33650
+ return httpRequest("services/api/customer/getsignaturephotosdk/".concat(customerId), {}, "GET");
33651
+ case 2:
33652
+ response = _context1.v;
33653
+ return _context1.a(2, _objectSpread2(_objectSpread2({}, response), {}, {
33654
+ success: true
33655
+ }));
33656
+ case 3:
33657
+ _context1.p = 3;
33658
+ _t6 = _context1.v;
33659
+ if (!(_t6 instanceof ApacuanaAPIError)) {
33660
+ _context1.n = 4;
33661
+ break;
33662
+ }
33663
+ throw _t6;
33664
+ case 4:
33665
+ throw new ApacuanaAPIError("Failed to get signature variant: ".concat(_t6.message || "Unknown error"));
33666
+ case 5:
33667
+ return _context1.a(2);
33668
+ }
33669
+ }, _callee1, null, [[1, 3]]);
33670
+ }));
33671
+ return function getSignatureVariantOnBoarding() {
33672
+ return _ref10.apply(this, arguments);
33673
+ };
33674
+ }();
33675
+ var getSignatureVariantOnPremise = /*#__PURE__*/function () {
33676
+ var _ref11 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
33677
+ return _regenerator().w(function (_context10) {
33678
+ while (1) switch (_context10.n) {
33679
+ case 0:
33680
+ throw new ApacuanaAPIError("Getting signature variants is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
33681
+ case 1:
33682
+ return _context10.a(2);
33683
+ }
33684
+ }, _callee10);
33685
+ }));
33686
+ return function getSignatureVariantOnPremise() {
33687
+ return _ref11.apply(this, arguments);
33688
+ };
33689
+ }();
33690
+ var deleteSignatureVariantOnBoarding = /*#__PURE__*/function () {
33691
+ var _ref12 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
33692
+ var response, _t7;
33693
+ return _regenerator().w(function (_context11) {
33694
+ while (1) switch (_context11.p = _context11.n) {
33695
+ case 0:
33696
+ _context11.p = 0;
33697
+ _context11.n = 1;
33698
+ return httpRequest("services/api/customer/cleansignaturephoto", {}, "DELETE");
33699
+ case 1:
33700
+ response = _context11.v;
33701
+ return _context11.a(2, _objectSpread2(_objectSpread2({}, response), {}, {
33702
+ success: true
33703
+ }));
33704
+ case 2:
33705
+ _context11.p = 2;
33706
+ _t7 = _context11.v;
33707
+ if (!(_t7 instanceof ApacuanaAPIError)) {
33708
+ _context11.n = 3;
33709
+ break;
33710
+ }
33711
+ throw _t7;
33712
+ case 3:
33713
+ throw new ApacuanaAPIError("Failed to delete signature variant: ".concat(_t7.message || "Unknown error"));
33714
+ case 4:
33715
+ return _context11.a(2);
33716
+ }
33717
+ }, _callee11, null, [[0, 2]]);
33718
+ }));
33719
+ return function deleteSignatureVariantOnBoarding() {
33720
+ return _ref12.apply(this, arguments);
33721
+ };
33722
+ }();
33723
+ var deleteSignatureVariantOnPremise = /*#__PURE__*/function () {
33724
+ var _ref13 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
33725
+ return _regenerator().w(function (_context12) {
33726
+ while (1) switch (_context12.n) {
33727
+ case 0:
33728
+ throw new ApacuanaAPIError("Deleting signature variants is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
33729
+ case 1:
33730
+ return _context12.a(2);
33731
+ }
33732
+ }, _callee12);
33733
+ }));
33734
+ return function deleteSignatureVariantOnPremise() {
33735
+ return _ref13.apply(this, arguments);
33736
+ };
33737
+ }();
33368
33738
 
33369
33739
  // =================================================================
33370
33740
  // Exported Functions
@@ -33378,32 +33748,32 @@ var getDocsOnBoarding = /*#__PURE__*/function () {
33378
33748
  * @throws {ApacuanaAPIError} Arroja un error 'NOT_IMPLEMENTED' para cualquier tipo de integración.
33379
33749
  */
33380
33750
  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) {
33751
+ var _ref14 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(signData) {
33752
+ var _getConfig3, integrationType;
33753
+ return _regenerator().w(function (_context13) {
33754
+ while (1) switch (_context13.n) {
33385
33755
  case 0:
33386
- _getConfig2 = getConfig(), integrationType = _getConfig2.integrationType;
33756
+ _getConfig3 = getConfig(), integrationType = _getConfig3.integrationType;
33387
33757
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33388
- _context9.n = 1;
33758
+ _context13.n = 1;
33389
33759
  break;
33390
33760
  }
33391
- return _context9.a(2, signDocumentOnBoarding(signData));
33761
+ return _context13.a(2, signDocumentOnBoarding(signData));
33392
33762
  case 1:
33393
33763
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33394
- _context9.n = 2;
33764
+ _context13.n = 2;
33395
33765
  break;
33396
33766
  }
33397
- return _context9.a(2, signDocumentOnPremise());
33767
+ return _context13.a(2, signDocumentOnPremise());
33398
33768
  case 2:
33399
33769
  throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
33400
33770
  case 3:
33401
- return _context9.a(2);
33771
+ return _context13.a(2);
33402
33772
  }
33403
- }, _callee9);
33773
+ }, _callee13);
33404
33774
  }));
33405
- return function signDocument(_x5) {
33406
- return _ref9.apply(this, arguments);
33775
+ return function signDocument(_x6) {
33776
+ return _ref14.apply(this, arguments);
33407
33777
  };
33408
33778
  }();
33409
33779
 
@@ -33414,33 +33784,33 @@ var signDocument = /*#__PURE__*/function () {
33414
33784
  * @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
33785
  */
33416
33786
  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) {
33787
+ var _ref15 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(signData) {
33788
+ var _getConfig4, integrationType;
33789
+ return _regenerator().w(function (_context14) {
33790
+ while (1) switch (_context14.n) {
33421
33791
  case 0:
33422
33792
  helpers.validateGetDigestData(signData);
33423
- _getConfig3 = getConfig(), integrationType = _getConfig3.integrationType;
33793
+ _getConfig4 = getConfig(), integrationType = _getConfig4.integrationType;
33424
33794
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33425
- _context0.n = 1;
33795
+ _context14.n = 1;
33426
33796
  break;
33427
33797
  }
33428
- return _context0.a(2, getDigestToSignOnBoarding(signData));
33798
+ return _context14.a(2, getDigestToSignOnBoarding(signData));
33429
33799
  case 1:
33430
33800
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33431
- _context0.n = 2;
33801
+ _context14.n = 2;
33432
33802
  break;
33433
33803
  }
33434
- return _context0.a(2, getDigestToSignOnPremise());
33804
+ return _context14.a(2, getDigestToSignOnPremise());
33435
33805
  case 2:
33436
33806
  throw new ApacuanaAPIError("Document retrieval is not supported for an unknown integration type: ".concat(integrationType), 501, "NOT_IMPLEMENTED");
33437
33807
  case 3:
33438
- return _context0.a(2);
33808
+ return _context14.a(2);
33439
33809
  }
33440
- }, _callee0);
33810
+ }, _callee14);
33441
33811
  }));
33442
- return function getDigest(_x6) {
33443
- return _ref0.apply(this, arguments);
33812
+ return function getDigest(_x7) {
33813
+ return _ref15.apply(this, arguments);
33444
33814
  };
33445
33815
  }();
33446
33816
 
@@ -33476,38 +33846,38 @@ var getDigest = /*#__PURE__*/function () {
33476
33846
  * @throws {ApacuanaAPIError} If signerData is invalid or if the integration type is not supported.
33477
33847
  */
33478
33848
  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) {
33849
+ var _ref16 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(signerData) {
33850
+ var _getConfig5, integrationType;
33851
+ return _regenerator().w(function (_context15) {
33852
+ while (1) switch (_context15.n) {
33483
33853
  case 0:
33484
33854
  if (!(!signerData || _typeof(signerData) !== "object" || Object.keys(signerData).length === 0)) {
33485
- _context1.n = 1;
33855
+ _context15.n = 1;
33486
33856
  break;
33487
33857
  }
33488
33858
  throw new ApacuanaAPIError("Signer data (signerData) is required and must be a non-empty object.", 400, "INVALID_PARAMETER");
33489
33859
  case 1:
33490
- _getConfig4 = getConfig(), integrationType = _getConfig4.integrationType;
33860
+ _getConfig5 = getConfig(), integrationType = _getConfig5.integrationType;
33491
33861
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33492
- _context1.n = 2;
33862
+ _context15.n = 2;
33493
33863
  break;
33494
33864
  }
33495
- return _context1.a(2, addSignerOnBoarding(signerData));
33865
+ return _context15.a(2, addSignerOnBoarding(signerData));
33496
33866
  case 2:
33497
33867
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33498
- _context1.n = 3;
33868
+ _context15.n = 3;
33499
33869
  break;
33500
33870
  }
33501
- return _context1.a(2, addSignerOnPremise());
33871
+ return _context15.a(2, addSignerOnPremise());
33502
33872
  case 3:
33503
33873
  throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
33504
33874
  case 4:
33505
- return _context1.a(2);
33875
+ return _context15.a(2);
33506
33876
  }
33507
- }, _callee1);
33877
+ }, _callee15);
33508
33878
  }));
33509
- return function addSigner(_x7) {
33510
- return _ref1.apply(this, arguments);
33879
+ return function addSigner(_x8) {
33880
+ return _ref16.apply(this, arguments);
33511
33881
  };
33512
33882
  }();
33513
33883
 
@@ -33518,33 +33888,158 @@ var addSigner = /*#__PURE__*/function () {
33518
33888
  * @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
33889
  */
33520
33890
  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) {
33891
+ var _ref17 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(data) {
33892
+ var _getConfig6, integrationType;
33893
+ return _regenerator().w(function (_context16) {
33894
+ while (1) switch (_context16.n) {
33525
33895
  case 0:
33526
33896
  helpers.validateGetDocsData(data);
33527
- _getConfig5 = getConfig(), integrationType = _getConfig5.integrationType;
33897
+ _getConfig6 = getConfig(), integrationType = _getConfig6.integrationType;
33528
33898
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33529
- _context10.n = 1;
33899
+ _context16.n = 1;
33530
33900
  break;
33531
33901
  }
33532
- return _context10.a(2, getDocsOnBoarding(data));
33902
+ return _context16.a(2, getDocsOnBoarding(data));
33533
33903
  case 1:
33534
33904
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33535
- _context10.n = 2;
33905
+ _context16.n = 2;
33536
33906
  break;
33537
33907
  }
33538
- return _context10.a(2, getDocsOnPremise());
33908
+ return _context16.a(2, getDocsOnPremise());
33539
33909
  case 2:
33540
33910
  throw new ApacuanaAPIError("Document retrieval is not supported for an unknown integration type: ".concat(integrationType), 501, "NOT_IMPLEMENTED");
33541
33911
  case 3:
33542
- return _context10.a(2);
33912
+ return _context16.a(2);
33543
33913
  }
33544
- }, _callee10);
33914
+ }, _callee16);
33545
33915
  }));
33546
- return function getDocs(_x8) {
33547
- return _ref10.apply(this, arguments);
33916
+ return function getDocs(_x9) {
33917
+ return _ref17.apply(this, arguments);
33918
+ };
33919
+ }();
33920
+
33921
+ /**
33922
+ * Sube una variante de firma para un firmante.
33923
+ * @param {object} data - Datos para la subida.
33924
+ * @param {File} data.file - El archivo de la variante de firma (debe ser PNG).
33925
+ * @returns {Promise<object>} Una promesa que resuelve a un objeto con el resultado de la operación.
33926
+ * @throws {ApacuanaAPIError} Si los datos son inválidos o la llamada a la API falla.
33927
+ */
33928
+ var uploadSignatureVariant = /*#__PURE__*/function () {
33929
+ var _ref18 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(data) {
33930
+ var _getConfig7, integrationType;
33931
+ return _regenerator().w(function (_context17) {
33932
+ while (1) switch (_context17.n) {
33933
+ case 0:
33934
+ if (!(!data || !data.file)) {
33935
+ _context17.n = 1;
33936
+ break;
33937
+ }
33938
+ throw new ApacuanaAPIError("El parámetro 'file' es requerido.", 400, "INVALID_PARAMETER");
33939
+ case 1:
33940
+ if (!(typeof File === "undefined" || !(data.file instanceof File))) {
33941
+ _context17.n = 2;
33942
+ break;
33943
+ }
33944
+ throw new ApacuanaAPIError("El parámetro 'file' debe ser una instancia de 'File'.", 400, "INVALID_PARAMETER");
33945
+ case 2:
33946
+ if (!(data.file.type !== "image/png")) {
33947
+ _context17.n = 3;
33948
+ break;
33949
+ }
33950
+ throw new ApacuanaAPIError("El archivo debe ser de tipo PNG (image/png).", 400, "INVALID_PARAMETER");
33951
+ case 3:
33952
+ _getConfig7 = getConfig(), integrationType = _getConfig7.integrationType;
33953
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33954
+ _context17.n = 4;
33955
+ break;
33956
+ }
33957
+ return _context17.a(2, uploadSignatureVariantOnBoarding(data));
33958
+ case 4:
33959
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33960
+ _context17.n = 5;
33961
+ break;
33962
+ }
33963
+ return _context17.a(2, uploadSignatureVariantOnPremise());
33964
+ case 5:
33965
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
33966
+ case 6:
33967
+ return _context17.a(2);
33968
+ }
33969
+ }, _callee17);
33970
+ }));
33971
+ return function uploadSignatureVariant(_x0) {
33972
+ return _ref18.apply(this, arguments);
33973
+ };
33974
+ }();
33975
+
33976
+ /**
33977
+ * Obtiene la variante de firma del firmante.
33978
+ * @returns {Promise<object>} Una promesa que resuelve a un objeto con los datos de la variante de firma.
33979
+ * @throws {ApacuanaAPIError} Si la llamada a la API falla o el tipo de integración no es soportado.
33980
+ */
33981
+ var getSignatureVariant = /*#__PURE__*/function () {
33982
+ var _ref19 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
33983
+ var _getConfig8, integrationType;
33984
+ return _regenerator().w(function (_context18) {
33985
+ while (1) switch (_context18.n) {
33986
+ case 0:
33987
+ _getConfig8 = getConfig(), integrationType = _getConfig8.integrationType;
33988
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33989
+ _context18.n = 1;
33990
+ break;
33991
+ }
33992
+ return _context18.a(2, getSignatureVariantOnBoarding());
33993
+ case 1:
33994
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33995
+ _context18.n = 2;
33996
+ break;
33997
+ }
33998
+ return _context18.a(2, getSignatureVariantOnPremise());
33999
+ case 2:
34000
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34001
+ case 3:
34002
+ return _context18.a(2);
34003
+ }
34004
+ }, _callee18);
34005
+ }));
34006
+ return function getSignatureVariant() {
34007
+ return _ref19.apply(this, arguments);
34008
+ };
34009
+ }();
34010
+
34011
+ /**
34012
+ * Elimina la variante de firma del firmante.
34013
+ * @returns {Promise<object>} Una promesa que resuelve a un objeto con el resultado de la operación.
34014
+ * @throws {ApacuanaAPIError} Si la llamada a la API falla o el tipo de integración no es soportado.
34015
+ */
34016
+ var deleteSignatureVariant = /*#__PURE__*/function () {
34017
+ var _ref20 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19() {
34018
+ var _getConfig9, integrationType;
34019
+ return _regenerator().w(function (_context19) {
34020
+ while (1) switch (_context19.n) {
34021
+ case 0:
34022
+ _getConfig9 = getConfig(), integrationType = _getConfig9.integrationType;
34023
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34024
+ _context19.n = 1;
34025
+ break;
34026
+ }
34027
+ return _context19.a(2, deleteSignatureVariantOnBoarding());
34028
+ case 1:
34029
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34030
+ _context19.n = 2;
34031
+ break;
34032
+ }
34033
+ return _context19.a(2, deleteSignatureVariantOnPremise());
34034
+ case 2:
34035
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34036
+ case 3:
34037
+ return _context19.a(2);
34038
+ }
34039
+ }, _callee19);
34040
+ }));
34041
+ return function deleteSignatureVariant() {
34042
+ return _ref20.apply(this, arguments);
33548
34043
  };
33549
34044
  }();
33550
34045
 
@@ -33617,7 +34112,12 @@ var apacuana = {
33617
34112
  generateCert: generateCert,
33618
34113
  signDocument: signDocument,
33619
34114
  getDigest: getDigest,
33620
- getRevocationReasons: getRevocationReasons
34115
+ getRevocationReasons: getRevocationReasons,
34116
+ uploadSignatureVariant: uploadSignatureVariant,
34117
+ getSignatureVariant: getSignatureVariant,
34118
+ deleteSignatureVariant: deleteSignatureVariant,
34119
+ getCertTypes: getCertTypes,
34120
+ getRequerimentsByTypeUser: getRequerimentsByTypeUser
33621
34121
  };
33622
34122
 
33623
34123
  export { apacuana as default };