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.js CHANGED
@@ -379,7 +379,6 @@ var initHttpClient = function initHttpClient() {
379
379
  axiosInstance = axios.create({
380
380
  baseURL: config.apiUrl,
381
381
  headers: {
382
- "Content-Type": "application/json",
383
382
  "APACUANA-API-Key": config.apiKey,
384
383
  "APACUANA-SECRET-Key": config.secretKey
385
384
  // La cabecera Authorization se deja vacía al inicio.
@@ -392,7 +391,9 @@ var initHttpClient = function initHttpClient() {
392
391
  axiosInstance.interceptors.response.use(function (response) {
393
392
  // Maneja errores lógicos de la API (si el backend devuelve status 2xx con { success: false })
394
393
  if (response.data && response.data.success === false) {
395
- 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");
394
+ var _response$data, _response$data2;
395
+ 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.";
396
+ throw new ApacuanaAPIError(errorMessage, response.status, response.data.code || "LOGICAL_API_ERROR");
396
397
  }
397
398
  return response;
398
399
  }, function (error) {
@@ -403,7 +404,8 @@ var initHttpClient = function initHttpClient() {
403
404
  var _error$response = error.response,
404
405
  status = _error$response.status,
405
406
  data = _error$response.data;
406
- throw new ApacuanaAPIError(data.message || "Error en la API: ".concat(status), status, data.code || "API_ERROR");
407
+ 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.";
408
+ throw new ApacuanaAPIError(errorMessage, status, (data === null || data === void 0 ? void 0 : data.code) || "API_ERROR");
407
409
  }
408
410
  if (error.request) {
409
411
  // La petición fue hecha, pero no se recibió respuesta (red caída, CORS, timeout)
@@ -447,6 +449,9 @@ var httpRequest = /*#__PURE__*/function () {
447
449
  var data,
448
450
  method,
449
451
  dataToSend,
452
+ requestConfig,
453
+ hasFile,
454
+ formData,
450
455
  response,
451
456
  _args = arguments,
452
457
  _t,
@@ -462,9 +467,19 @@ var httpRequest = /*#__PURE__*/function () {
462
467
  }
463
468
  throw new Error("Apacuana SDK: Cliente HTTP no inicializado. " + "Llama a apacuana.init() primero.");
464
469
  case 1:
465
- // Creamos el cuerpo de la petición fusionando los datos de la llamada
466
- // con los parámetros de inicialización.
467
- dataToSend = _objectSpread2({}, data);
470
+ requestConfig = {};
471
+ hasFile = Object.values(data).some(function (value) {
472
+ return typeof File !== "undefined" && value instanceof File;
473
+ });
474
+ if (hasFile) {
475
+ formData = new FormData();
476
+ Object.keys(data).forEach(function (key) {
477
+ formData.append(key, data[key]);
478
+ });
479
+ dataToSend = formData;
480
+ } else {
481
+ dataToSend = _objectSpread2({}, data);
482
+ }
468
483
  _context.p = 2;
469
484
  _t = method.toUpperCase();
470
485
  _context.n = _t === "GET" ? 3 : _t === "POST" ? 5 : _t === "PUT" ? 7 : _t === "DELETE" ? 9 : 11;
@@ -479,21 +494,21 @@ var httpRequest = /*#__PURE__*/function () {
479
494
  return _context.a(3, 12);
480
495
  case 5:
481
496
  _context.n = 6;
482
- return axiosInstance.post(path, dataToSend);
497
+ return axiosInstance.post(path, dataToSend, requestConfig);
483
498
  case 6:
484
499
  response = _context.v;
485
500
  return _context.a(3, 12);
486
501
  case 7:
487
502
  _context.n = 8;
488
- return axiosInstance.put(path, dataToSend);
503
+ return axiosInstance.put(path, dataToSend, requestConfig);
489
504
  case 8:
490
505
  response = _context.v;
491
506
  return _context.a(3, 12);
492
507
  case 9:
493
508
  _context.n = 10;
494
- return axiosInstance["delete"](path, {
509
+ return axiosInstance["delete"](path, _objectSpread2({
495
510
  data: dataToSend
496
- });
511
+ }, requestConfig));
497
512
  case 10:
498
513
  response = _context.v;
499
514
  return _context.a(3, 12);
@@ -504,9 +519,6 @@ var httpRequest = /*#__PURE__*/function () {
504
519
  case 13:
505
520
  _context.p = 13;
506
521
  _t2 = _context.v;
507
- // Si la petición falla, el interceptor ya procesó el error.
508
- // Simplemente relanzamos el error para que sea capturado por la función de API.
509
- // eslint-disable-next-line no-console
510
522
  console.error("[HTTP Client] Fallo en la petici\xF3n a ".concat(path, ":"), _t2);
511
523
  throw _t2;
512
524
  case 14:
@@ -664,36 +676,43 @@ var requestRevocation = /*#__PURE__*/function () {
664
676
  */
665
677
  var getRevocationReasons = /*#__PURE__*/function () {
666
678
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
667
- var response, _t2;
679
+ var _getConfig, integrationType, response, _t2;
668
680
  return _regenerator().w(function (_context2) {
669
681
  while (1) switch (_context2.p = _context2.n) {
670
682
  case 0:
671
- _context2.p = 0;
672
- _context2.n = 1;
673
- return httpRequest("config/api/revocation/reasonsonboarding", {}, "GET");
683
+ _getConfig = getConfig(), integrationType = _getConfig.integrationType;
684
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
685
+ _context2.n = 1;
686
+ break;
687
+ }
688
+ throw new ApacuanaAPIError("Get revocation reasons is not supported for integration type: ".concat(integrationType), 501, "NOT_IMPLEMENTED");
674
689
  case 1:
690
+ _context2.p = 1;
691
+ _context2.n = 2;
692
+ return httpRequest("GET", "config/api/revocation/reasonsonboarding", {});
693
+ case 2:
675
694
  response = _context2.v;
676
695
  if (response.records) {
677
- _context2.n = 2;
696
+ _context2.n = 3;
678
697
  break;
679
698
  }
680
699
  throw new ApacuanaAPIError("Failed to fetch revocation reasons.");
681
- case 2:
682
- return _context2.a(2, response.records);
683
700
  case 3:
684
- _context2.p = 3;
701
+ return _context2.a(2, response.records);
702
+ case 4:
703
+ _context2.p = 4;
685
704
  _t2 = _context2.v;
686
705
  if (!(_t2 instanceof ApacuanaAPIError)) {
687
- _context2.n = 4;
706
+ _context2.n = 5;
688
707
  break;
689
708
  }
690
709
  throw _t2;
691
- case 4:
692
- throw new Error("Failed to get revocation reasons. Please try again later.");
693
710
  case 5:
711
+ throw new Error("Failed to get revocation reasons. Please try again later.");
712
+ case 6:
694
713
  return _context2.a(2);
695
714
  }
696
- }, _callee2, null, [[0, 3]]);
715
+ }, _callee2, null, [[1, 4]]);
697
716
  }));
698
717
  return function getRevocationReasons() {
699
718
  return _ref2.apply(this, arguments);
@@ -33066,6 +33085,209 @@ var getCertStatus = function getCertStatus() {
33066
33085
  };
33067
33086
  };
33068
33087
 
33088
+ /**
33089
+ * @typedef {object} CertType
33090
+ * @property {string} id - The ID of the certificate type.
33091
+ * @property {string} name - The name of the certificate type.
33092
+ */
33093
+
33094
+ /**
33095
+ * @typedef {object} GetCertTypesResponse
33096
+ * @property {Array<CertType>} types - A list of available certificate types.
33097
+ * @property {boolean} success - Indicates if the operation was successful.
33098
+ */
33099
+
33100
+ var getCertTypesOnBoarding = /*#__PURE__*/function () {
33101
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
33102
+ var response, _t2;
33103
+ return _regenerator().w(function (_context4) {
33104
+ while (1) switch (_context4.p = _context4.n) {
33105
+ case 0:
33106
+ _context4.p = 0;
33107
+ _context4.n = 1;
33108
+ return httpRequest("services/api/customer/typeusers", {}, "GET");
33109
+ case 1:
33110
+ response = _context4.v;
33111
+ return _context4.a(2, _objectSpread2(_objectSpread2({}, response), {}, {
33112
+ success: true
33113
+ }));
33114
+ case 2:
33115
+ _context4.p = 2;
33116
+ _t2 = _context4.v;
33117
+ if (!(_t2 instanceof ApacuanaAPIError)) {
33118
+ _context4.n = 3;
33119
+ break;
33120
+ }
33121
+ throw _t2;
33122
+ case 3:
33123
+ throw new Error("Failed to get certificate types: ".concat(_t2.message));
33124
+ case 4:
33125
+ return _context4.a(2);
33126
+ }
33127
+ }, _callee4, null, [[0, 2]]);
33128
+ }));
33129
+ return function getCertTypesOnBoarding() {
33130
+ return _ref4.apply(this, arguments);
33131
+ };
33132
+ }();
33133
+ var getCertTypesOnPremise = /*#__PURE__*/function () {
33134
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
33135
+ return _regenerator().w(function (_context5) {
33136
+ while (1) switch (_context5.n) {
33137
+ case 0:
33138
+ throw new ApacuanaAPIError("Getting certificate types is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
33139
+ case 1:
33140
+ return _context5.a(2);
33141
+ }
33142
+ }, _callee5);
33143
+ }));
33144
+ return function getCertTypesOnPremise() {
33145
+ return _ref5.apply(this, arguments);
33146
+ };
33147
+ }();
33148
+
33149
+ /**
33150
+ * Gets the available certificate types.
33151
+ * @returns {Promise<GetCertTypesResponse>} Object with the list of certificate types and a success indicator.
33152
+ * @throws {ApacuanaAPIError} If the API response is invalid or the integration type is not supported.
33153
+ * @throws {Error} If the request fails for another reason.
33154
+ */
33155
+ var getCertTypes = /*#__PURE__*/function () {
33156
+ var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
33157
+ var _getConfig2, integrationType;
33158
+ return _regenerator().w(function (_context6) {
33159
+ while (1) switch (_context6.n) {
33160
+ case 0:
33161
+ _getConfig2 = getConfig(), integrationType = _getConfig2.integrationType;
33162
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33163
+ _context6.n = 1;
33164
+ break;
33165
+ }
33166
+ return _context6.a(2, getCertTypesOnBoarding());
33167
+ case 1:
33168
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33169
+ _context6.n = 2;
33170
+ break;
33171
+ }
33172
+ return _context6.a(2, getCertTypesOnPremise());
33173
+ case 2:
33174
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
33175
+ case 3:
33176
+ return _context6.a(2);
33177
+ }
33178
+ }, _callee6);
33179
+ }));
33180
+ return function getCertTypes() {
33181
+ return _ref6.apply(this, arguments);
33182
+ };
33183
+ }();
33184
+
33185
+ /**
33186
+ * @typedef {object} Requirement
33187
+ * @property {string} id - The ID of the requirement.
33188
+ * @property {string} description - The description of the requirement.
33189
+ */
33190
+
33191
+ /**
33192
+ * @typedef {object} GetRequirementsResponse
33193
+ * @property {Array<Requirement>} requirements - A list of requirements for the user type.
33194
+ * @property {boolean} success - Indicates if the operation was successful.
33195
+ */
33196
+
33197
+ var getRequerimentsByTypeUserOnBoarding = /*#__PURE__*/function () {
33198
+ var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(type) {
33199
+ var response, _t3;
33200
+ return _regenerator().w(function (_context7) {
33201
+ while (1) switch (_context7.p = _context7.n) {
33202
+ case 0:
33203
+ _context7.p = 0;
33204
+ _context7.n = 1;
33205
+ return httpRequest("services/api/customer/documentspref?typeuser=".concat(type), {}, "GET");
33206
+ case 1:
33207
+ response = _context7.v;
33208
+ return _context7.a(2, _objectSpread2(_objectSpread2({}, response), {}, {
33209
+ success: true
33210
+ }));
33211
+ case 2:
33212
+ _context7.p = 2;
33213
+ _t3 = _context7.v;
33214
+ if (!(_t3 instanceof ApacuanaAPIError)) {
33215
+ _context7.n = 3;
33216
+ break;
33217
+ }
33218
+ throw _t3;
33219
+ case 3:
33220
+ throw new Error("Failed to get requirements: ".concat(_t3.message));
33221
+ case 4:
33222
+ return _context7.a(2);
33223
+ }
33224
+ }, _callee7, null, [[0, 2]]);
33225
+ }));
33226
+ return function getRequerimentsByTypeUserOnBoarding(_x3) {
33227
+ return _ref7.apply(this, arguments);
33228
+ };
33229
+ }();
33230
+ var getRequerimentsByTypeUserOnPremise = /*#__PURE__*/function () {
33231
+ var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8() {
33232
+ return _regenerator().w(function (_context8) {
33233
+ while (1) switch (_context8.n) {
33234
+ case 0:
33235
+ throw new ApacuanaAPIError("Getting requirements by user type is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
33236
+ case 1:
33237
+ return _context8.a(2);
33238
+ }
33239
+ }, _callee8);
33240
+ }));
33241
+ return function getRequerimentsByTypeUserOnPremise() {
33242
+ return _ref8.apply(this, arguments);
33243
+ };
33244
+ }();
33245
+
33246
+ /**
33247
+ * Gets the requirements for a given user type.
33248
+ * @param {object} params - The parameters.
33249
+ * @param {number} params.type - The user type to get requirements for.
33250
+ * @returns {Promise<GetRequirementsResponse>} Object with the list of requirements and a success indicator.
33251
+ * @throws {ApacuanaAPIError} If the API response is invalid or the integration type is not supported.
33252
+ * @throws {Error} If the request fails for another reason or the type is invalid.
33253
+ */
33254
+ var getRequerimentsByTypeUser = /*#__PURE__*/function () {
33255
+ var _ref9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(params) {
33256
+ var type, _getConfig3, integrationType;
33257
+ return _regenerator().w(function (_context9) {
33258
+ while (1) switch (_context9.n) {
33259
+ case 0:
33260
+ if (!(!params || typeof params.type !== "number")) {
33261
+ _context9.n = 1;
33262
+ break;
33263
+ }
33264
+ throw new Error('The "params" object with a numeric "type" property is required.');
33265
+ case 1:
33266
+ type = params.type;
33267
+ _getConfig3 = getConfig(), integrationType = _getConfig3.integrationType;
33268
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33269
+ _context9.n = 2;
33270
+ break;
33271
+ }
33272
+ return _context9.a(2, getRequerimentsByTypeUserOnBoarding(type));
33273
+ case 2:
33274
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33275
+ _context9.n = 3;
33276
+ break;
33277
+ }
33278
+ return _context9.a(2, getRequerimentsByTypeUserOnPremise());
33279
+ case 3:
33280
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
33281
+ case 4:
33282
+ return _context9.a(2);
33283
+ }
33284
+ }, _callee9);
33285
+ }));
33286
+ return function getRequerimentsByTypeUser(_x4) {
33287
+ return _ref9.apply(this, arguments);
33288
+ };
33289
+ }();
33290
+
33069
33291
  // =================================================================
33070
33292
  // Type Definitions
33071
33293
  // =================================================================
@@ -33367,6 +33589,154 @@ var getDocsOnBoarding = /*#__PURE__*/function () {
33367
33589
  return _ref8.apply(this, arguments);
33368
33590
  };
33369
33591
  }();
33592
+ var uploadSignatureVariantOnBoarding = /*#__PURE__*/function () {
33593
+ var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(_ref9) {
33594
+ var file, response, _t5;
33595
+ return _regenerator().w(function (_context9) {
33596
+ while (1) switch (_context9.p = _context9.n) {
33597
+ case 0:
33598
+ file = _ref9.file;
33599
+ _context9.p = 1;
33600
+ _context9.n = 2;
33601
+ return httpRequest("services/api/customer/signaturephoto", {
33602
+ file: file
33603
+ }, "POST");
33604
+ case 2:
33605
+ response = _context9.v;
33606
+ return _context9.a(2, _objectSpread2(_objectSpread2({}, response), {}, {
33607
+ success: true
33608
+ }));
33609
+ case 3:
33610
+ _context9.p = 3;
33611
+ _t5 = _context9.v;
33612
+ if (!(_t5 instanceof ApacuanaAPIError)) {
33613
+ _context9.n = 4;
33614
+ break;
33615
+ }
33616
+ throw _t5;
33617
+ case 4:
33618
+ throw new ApacuanaAPIError("Failed to upload signature variant: ".concat(_t5.message || "Unknown error"));
33619
+ case 5:
33620
+ return _context9.a(2);
33621
+ }
33622
+ }, _callee9, null, [[1, 3]]);
33623
+ }));
33624
+ return function uploadSignatureVariantOnBoarding(_x5) {
33625
+ return _ref0.apply(this, arguments);
33626
+ };
33627
+ }();
33628
+ var uploadSignatureVariantOnPremise = /*#__PURE__*/function () {
33629
+ var _ref1 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0() {
33630
+ return _regenerator().w(function (_context0) {
33631
+ while (1) switch (_context0.n) {
33632
+ case 0:
33633
+ throw new ApacuanaAPIError("Uploading signature variants is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
33634
+ case 1:
33635
+ return _context0.a(2);
33636
+ }
33637
+ }, _callee0);
33638
+ }));
33639
+ return function uploadSignatureVariantOnPremise() {
33640
+ return _ref1.apply(this, arguments);
33641
+ };
33642
+ }();
33643
+ var getSignatureVariantOnBoarding = /*#__PURE__*/function () {
33644
+ var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1() {
33645
+ var _getConfig2, customerId, response, _t6;
33646
+ return _regenerator().w(function (_context1) {
33647
+ while (1) switch (_context1.p = _context1.n) {
33648
+ case 0:
33649
+ _getConfig2 = getConfig(), customerId = _getConfig2.customerId;
33650
+ _context1.p = 1;
33651
+ _context1.n = 2;
33652
+ return httpRequest("services/api/customer/getsignaturephotosdk/".concat(customerId), {}, "GET");
33653
+ case 2:
33654
+ response = _context1.v;
33655
+ return _context1.a(2, _objectSpread2(_objectSpread2({}, response), {}, {
33656
+ success: true
33657
+ }));
33658
+ case 3:
33659
+ _context1.p = 3;
33660
+ _t6 = _context1.v;
33661
+ if (!(_t6 instanceof ApacuanaAPIError)) {
33662
+ _context1.n = 4;
33663
+ break;
33664
+ }
33665
+ throw _t6;
33666
+ case 4:
33667
+ throw new ApacuanaAPIError("Failed to get signature variant: ".concat(_t6.message || "Unknown error"));
33668
+ case 5:
33669
+ return _context1.a(2);
33670
+ }
33671
+ }, _callee1, null, [[1, 3]]);
33672
+ }));
33673
+ return function getSignatureVariantOnBoarding() {
33674
+ return _ref10.apply(this, arguments);
33675
+ };
33676
+ }();
33677
+ var getSignatureVariantOnPremise = /*#__PURE__*/function () {
33678
+ var _ref11 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10() {
33679
+ return _regenerator().w(function (_context10) {
33680
+ while (1) switch (_context10.n) {
33681
+ case 0:
33682
+ throw new ApacuanaAPIError("Getting signature variants is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
33683
+ case 1:
33684
+ return _context10.a(2);
33685
+ }
33686
+ }, _callee10);
33687
+ }));
33688
+ return function getSignatureVariantOnPremise() {
33689
+ return _ref11.apply(this, arguments);
33690
+ };
33691
+ }();
33692
+ var deleteSignatureVariantOnBoarding = /*#__PURE__*/function () {
33693
+ var _ref12 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee11() {
33694
+ var response, _t7;
33695
+ return _regenerator().w(function (_context11) {
33696
+ while (1) switch (_context11.p = _context11.n) {
33697
+ case 0:
33698
+ _context11.p = 0;
33699
+ _context11.n = 1;
33700
+ return httpRequest("services/api/customer/cleansignaturephoto", {}, "DELETE");
33701
+ case 1:
33702
+ response = _context11.v;
33703
+ return _context11.a(2, _objectSpread2(_objectSpread2({}, response), {}, {
33704
+ success: true
33705
+ }));
33706
+ case 2:
33707
+ _context11.p = 2;
33708
+ _t7 = _context11.v;
33709
+ if (!(_t7 instanceof ApacuanaAPIError)) {
33710
+ _context11.n = 3;
33711
+ break;
33712
+ }
33713
+ throw _t7;
33714
+ case 3:
33715
+ throw new ApacuanaAPIError("Failed to delete signature variant: ".concat(_t7.message || "Unknown error"));
33716
+ case 4:
33717
+ return _context11.a(2);
33718
+ }
33719
+ }, _callee11, null, [[0, 2]]);
33720
+ }));
33721
+ return function deleteSignatureVariantOnBoarding() {
33722
+ return _ref12.apply(this, arguments);
33723
+ };
33724
+ }();
33725
+ var deleteSignatureVariantOnPremise = /*#__PURE__*/function () {
33726
+ var _ref13 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee12() {
33727
+ return _regenerator().w(function (_context12) {
33728
+ while (1) switch (_context12.n) {
33729
+ case 0:
33730
+ throw new ApacuanaAPIError("Deleting signature variants is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
33731
+ case 1:
33732
+ return _context12.a(2);
33733
+ }
33734
+ }, _callee12);
33735
+ }));
33736
+ return function deleteSignatureVariantOnPremise() {
33737
+ return _ref13.apply(this, arguments);
33738
+ };
33739
+ }();
33370
33740
 
33371
33741
  // =================================================================
33372
33742
  // Exported Functions
@@ -33380,32 +33750,32 @@ var getDocsOnBoarding = /*#__PURE__*/function () {
33380
33750
  * @throws {ApacuanaAPIError} Arroja un error 'NOT_IMPLEMENTED' para cualquier tipo de integración.
33381
33751
  */
33382
33752
  var signDocument = /*#__PURE__*/function () {
33383
- var _ref9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(signData) {
33384
- var _getConfig2, integrationType;
33385
- return _regenerator().w(function (_context9) {
33386
- while (1) switch (_context9.n) {
33753
+ var _ref14 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee13(signData) {
33754
+ var _getConfig3, integrationType;
33755
+ return _regenerator().w(function (_context13) {
33756
+ while (1) switch (_context13.n) {
33387
33757
  case 0:
33388
- _getConfig2 = getConfig(), integrationType = _getConfig2.integrationType;
33758
+ _getConfig3 = getConfig(), integrationType = _getConfig3.integrationType;
33389
33759
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33390
- _context9.n = 1;
33760
+ _context13.n = 1;
33391
33761
  break;
33392
33762
  }
33393
- return _context9.a(2, signDocumentOnBoarding(signData));
33763
+ return _context13.a(2, signDocumentOnBoarding(signData));
33394
33764
  case 1:
33395
33765
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33396
- _context9.n = 2;
33766
+ _context13.n = 2;
33397
33767
  break;
33398
33768
  }
33399
- return _context9.a(2, signDocumentOnPremise());
33769
+ return _context13.a(2, signDocumentOnPremise());
33400
33770
  case 2:
33401
33771
  throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
33402
33772
  case 3:
33403
- return _context9.a(2);
33773
+ return _context13.a(2);
33404
33774
  }
33405
- }, _callee9);
33775
+ }, _callee13);
33406
33776
  }));
33407
- return function signDocument(_x5) {
33408
- return _ref9.apply(this, arguments);
33777
+ return function signDocument(_x6) {
33778
+ return _ref14.apply(this, arguments);
33409
33779
  };
33410
33780
  }();
33411
33781
 
@@ -33416,33 +33786,33 @@ var signDocument = /*#__PURE__*/function () {
33416
33786
  * @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.
33417
33787
  */
33418
33788
  var getDigest = /*#__PURE__*/function () {
33419
- var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(signData) {
33420
- var _getConfig3, integrationType;
33421
- return _regenerator().w(function (_context0) {
33422
- while (1) switch (_context0.n) {
33789
+ var _ref15 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee14(signData) {
33790
+ var _getConfig4, integrationType;
33791
+ return _regenerator().w(function (_context14) {
33792
+ while (1) switch (_context14.n) {
33423
33793
  case 0:
33424
33794
  helpers.validateGetDigestData(signData);
33425
- _getConfig3 = getConfig(), integrationType = _getConfig3.integrationType;
33795
+ _getConfig4 = getConfig(), integrationType = _getConfig4.integrationType;
33426
33796
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33427
- _context0.n = 1;
33797
+ _context14.n = 1;
33428
33798
  break;
33429
33799
  }
33430
- return _context0.a(2, getDigestToSignOnBoarding(signData));
33800
+ return _context14.a(2, getDigestToSignOnBoarding(signData));
33431
33801
  case 1:
33432
33802
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33433
- _context0.n = 2;
33803
+ _context14.n = 2;
33434
33804
  break;
33435
33805
  }
33436
- return _context0.a(2, getDigestToSignOnPremise());
33806
+ return _context14.a(2, getDigestToSignOnPremise());
33437
33807
  case 2:
33438
33808
  throw new ApacuanaAPIError("Document retrieval is not supported for an unknown integration type: ".concat(integrationType), 501, "NOT_IMPLEMENTED");
33439
33809
  case 3:
33440
- return _context0.a(2);
33810
+ return _context14.a(2);
33441
33811
  }
33442
- }, _callee0);
33812
+ }, _callee14);
33443
33813
  }));
33444
- return function getDigest(_x6) {
33445
- return _ref0.apply(this, arguments);
33814
+ return function getDigest(_x7) {
33815
+ return _ref15.apply(this, arguments);
33446
33816
  };
33447
33817
  }();
33448
33818
 
@@ -33478,38 +33848,38 @@ var getDigest = /*#__PURE__*/function () {
33478
33848
  * @throws {ApacuanaAPIError} If signerData is invalid or if the integration type is not supported.
33479
33849
  */
33480
33850
  var addSigner = /*#__PURE__*/function () {
33481
- var _ref1 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(signerData) {
33482
- var _getConfig4, integrationType;
33483
- return _regenerator().w(function (_context1) {
33484
- while (1) switch (_context1.n) {
33851
+ var _ref16 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee15(signerData) {
33852
+ var _getConfig5, integrationType;
33853
+ return _regenerator().w(function (_context15) {
33854
+ while (1) switch (_context15.n) {
33485
33855
  case 0:
33486
33856
  if (!(!signerData || _typeof(signerData) !== "object" || Object.keys(signerData).length === 0)) {
33487
- _context1.n = 1;
33857
+ _context15.n = 1;
33488
33858
  break;
33489
33859
  }
33490
33860
  throw new ApacuanaAPIError("Signer data (signerData) is required and must be a non-empty object.", 400, "INVALID_PARAMETER");
33491
33861
  case 1:
33492
- _getConfig4 = getConfig(), integrationType = _getConfig4.integrationType;
33862
+ _getConfig5 = getConfig(), integrationType = _getConfig5.integrationType;
33493
33863
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33494
- _context1.n = 2;
33864
+ _context15.n = 2;
33495
33865
  break;
33496
33866
  }
33497
- return _context1.a(2, addSignerOnBoarding(signerData));
33867
+ return _context15.a(2, addSignerOnBoarding(signerData));
33498
33868
  case 2:
33499
33869
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33500
- _context1.n = 3;
33870
+ _context15.n = 3;
33501
33871
  break;
33502
33872
  }
33503
- return _context1.a(2, addSignerOnPremise());
33873
+ return _context15.a(2, addSignerOnPremise());
33504
33874
  case 3:
33505
33875
  throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
33506
33876
  case 4:
33507
- return _context1.a(2);
33877
+ return _context15.a(2);
33508
33878
  }
33509
- }, _callee1);
33879
+ }, _callee15);
33510
33880
  }));
33511
- return function addSigner(_x7) {
33512
- return _ref1.apply(this, arguments);
33881
+ return function addSigner(_x8) {
33882
+ return _ref16.apply(this, arguments);
33513
33883
  };
33514
33884
  }();
33515
33885
 
@@ -33520,33 +33890,158 @@ var addSigner = /*#__PURE__*/function () {
33520
33890
  * @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.
33521
33891
  */
33522
33892
  var getDocs = /*#__PURE__*/function () {
33523
- var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(data) {
33524
- var _getConfig5, integrationType;
33525
- return _regenerator().w(function (_context10) {
33526
- while (1) switch (_context10.n) {
33893
+ var _ref17 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee16(data) {
33894
+ var _getConfig6, integrationType;
33895
+ return _regenerator().w(function (_context16) {
33896
+ while (1) switch (_context16.n) {
33527
33897
  case 0:
33528
33898
  helpers.validateGetDocsData(data);
33529
- _getConfig5 = getConfig(), integrationType = _getConfig5.integrationType;
33899
+ _getConfig6 = getConfig(), integrationType = _getConfig6.integrationType;
33530
33900
  if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33531
- _context10.n = 1;
33901
+ _context16.n = 1;
33532
33902
  break;
33533
33903
  }
33534
- return _context10.a(2, getDocsOnBoarding(data));
33904
+ return _context16.a(2, getDocsOnBoarding(data));
33535
33905
  case 1:
33536
33906
  if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33537
- _context10.n = 2;
33907
+ _context16.n = 2;
33538
33908
  break;
33539
33909
  }
33540
- return _context10.a(2, getDocsOnPremise());
33910
+ return _context16.a(2, getDocsOnPremise());
33541
33911
  case 2:
33542
33912
  throw new ApacuanaAPIError("Document retrieval is not supported for an unknown integration type: ".concat(integrationType), 501, "NOT_IMPLEMENTED");
33543
33913
  case 3:
33544
- return _context10.a(2);
33914
+ return _context16.a(2);
33545
33915
  }
33546
- }, _callee10);
33916
+ }, _callee16);
33547
33917
  }));
33548
- return function getDocs(_x8) {
33549
- return _ref10.apply(this, arguments);
33918
+ return function getDocs(_x9) {
33919
+ return _ref17.apply(this, arguments);
33920
+ };
33921
+ }();
33922
+
33923
+ /**
33924
+ * Sube una variante de firma para un firmante.
33925
+ * @param {object} data - Datos para la subida.
33926
+ * @param {File} data.file - El archivo de la variante de firma (debe ser PNG).
33927
+ * @returns {Promise<object>} Una promesa que resuelve a un objeto con el resultado de la operación.
33928
+ * @throws {ApacuanaAPIError} Si los datos son inválidos o la llamada a la API falla.
33929
+ */
33930
+ var uploadSignatureVariant = /*#__PURE__*/function () {
33931
+ var _ref18 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee17(data) {
33932
+ var _getConfig7, integrationType;
33933
+ return _regenerator().w(function (_context17) {
33934
+ while (1) switch (_context17.n) {
33935
+ case 0:
33936
+ if (!(!data || !data.file)) {
33937
+ _context17.n = 1;
33938
+ break;
33939
+ }
33940
+ throw new ApacuanaAPIError("El parámetro 'file' es requerido.", 400, "INVALID_PARAMETER");
33941
+ case 1:
33942
+ if (!(typeof File === "undefined" || !(data.file instanceof File))) {
33943
+ _context17.n = 2;
33944
+ break;
33945
+ }
33946
+ throw new ApacuanaAPIError("El parámetro 'file' debe ser una instancia de 'File'.", 400, "INVALID_PARAMETER");
33947
+ case 2:
33948
+ if (!(data.file.type !== "image/png")) {
33949
+ _context17.n = 3;
33950
+ break;
33951
+ }
33952
+ throw new ApacuanaAPIError("El archivo debe ser de tipo PNG (image/png).", 400, "INVALID_PARAMETER");
33953
+ case 3:
33954
+ _getConfig7 = getConfig(), integrationType = _getConfig7.integrationType;
33955
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33956
+ _context17.n = 4;
33957
+ break;
33958
+ }
33959
+ return _context17.a(2, uploadSignatureVariantOnBoarding(data));
33960
+ case 4:
33961
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33962
+ _context17.n = 5;
33963
+ break;
33964
+ }
33965
+ return _context17.a(2, uploadSignatureVariantOnPremise());
33966
+ case 5:
33967
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
33968
+ case 6:
33969
+ return _context17.a(2);
33970
+ }
33971
+ }, _callee17);
33972
+ }));
33973
+ return function uploadSignatureVariant(_x0) {
33974
+ return _ref18.apply(this, arguments);
33975
+ };
33976
+ }();
33977
+
33978
+ /**
33979
+ * Obtiene la variante de firma del firmante.
33980
+ * @returns {Promise<object>} Una promesa que resuelve a un objeto con los datos de la variante de firma.
33981
+ * @throws {ApacuanaAPIError} Si la llamada a la API falla o el tipo de integración no es soportado.
33982
+ */
33983
+ var getSignatureVariant = /*#__PURE__*/function () {
33984
+ var _ref19 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee18() {
33985
+ var _getConfig8, integrationType;
33986
+ return _regenerator().w(function (_context18) {
33987
+ while (1) switch (_context18.n) {
33988
+ case 0:
33989
+ _getConfig8 = getConfig(), integrationType = _getConfig8.integrationType;
33990
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
33991
+ _context18.n = 1;
33992
+ break;
33993
+ }
33994
+ return _context18.a(2, getSignatureVariantOnBoarding());
33995
+ case 1:
33996
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
33997
+ _context18.n = 2;
33998
+ break;
33999
+ }
34000
+ return _context18.a(2, getSignatureVariantOnPremise());
34001
+ case 2:
34002
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34003
+ case 3:
34004
+ return _context18.a(2);
34005
+ }
34006
+ }, _callee18);
34007
+ }));
34008
+ return function getSignatureVariant() {
34009
+ return _ref19.apply(this, arguments);
34010
+ };
34011
+ }();
34012
+
34013
+ /**
34014
+ * Elimina la variante de firma del firmante.
34015
+ * @returns {Promise<object>} Una promesa que resuelve a un objeto con el resultado de la operación.
34016
+ * @throws {ApacuanaAPIError} Si la llamada a la API falla o el tipo de integración no es soportado.
34017
+ */
34018
+ var deleteSignatureVariant = /*#__PURE__*/function () {
34019
+ var _ref20 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee19() {
34020
+ var _getConfig9, integrationType;
34021
+ return _regenerator().w(function (_context19) {
34022
+ while (1) switch (_context19.n) {
34023
+ case 0:
34024
+ _getConfig9 = getConfig(), integrationType = _getConfig9.integrationType;
34025
+ if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
34026
+ _context19.n = 1;
34027
+ break;
34028
+ }
34029
+ return _context19.a(2, deleteSignatureVariantOnBoarding());
34030
+ case 1:
34031
+ if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
34032
+ _context19.n = 2;
34033
+ break;
34034
+ }
34035
+ return _context19.a(2, deleteSignatureVariantOnPremise());
34036
+ case 2:
34037
+ throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
34038
+ case 3:
34039
+ return _context19.a(2);
34040
+ }
34041
+ }, _callee19);
34042
+ }));
34043
+ return function deleteSignatureVariant() {
34044
+ return _ref20.apply(this, arguments);
33550
34045
  };
33551
34046
  }();
33552
34047
 
@@ -33619,7 +34114,12 @@ var apacuana = {
33619
34114
  generateCert: generateCert,
33620
34115
  signDocument: signDocument,
33621
34116
  getDigest: getDigest,
33622
- getRevocationReasons: getRevocationReasons
34117
+ getRevocationReasons: getRevocationReasons,
34118
+ uploadSignatureVariant: uploadSignatureVariant,
34119
+ getSignatureVariant: getSignatureVariant,
34120
+ deleteSignatureVariant: deleteSignatureVariant,
34121
+ getCertTypes: getCertTypes,
34122
+ getRequerimentsByTypeUser: getRequerimentsByTypeUser
33623
34123
  };
33624
34124
 
33625
34125
  module.exports = apacuana;