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