apacuana-sdk-core 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +85 -0
- package/coverage/clover.xml +196 -128
- package/coverage/coverage-final.json +7 -7
- package/coverage/lcov-report/index.html +29 -29
- 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 +1 -1
- package/coverage/lcov-report/src/config/index.js.html +6 -6
- 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 +36 -3
- 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 +352 -220
- package/dist/api/signatures.d.ts +5 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +374 -79
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +374 -79
- 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/index.js +12 -1
- 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.d.ts
CHANGED
|
@@ -19,6 +19,9 @@ declare namespace apacuana {
|
|
|
19
19
|
export { signDocument };
|
|
20
20
|
export { getDigest };
|
|
21
21
|
export { getRevocationReasons };
|
|
22
|
+
export { uploadSignatureVariant };
|
|
23
|
+
export { getSignatureVariant };
|
|
24
|
+
export { deleteSignatureVariant };
|
|
22
25
|
}
|
|
23
26
|
import { getConfig } from "./config/index";
|
|
24
27
|
import { requestRevocation } from "./api/revocations";
|
|
@@ -30,3 +33,6 @@ import { generateCert } from "./api/certs";
|
|
|
30
33
|
import { signDocument } from "./api/signatures";
|
|
31
34
|
import { getDigest } from "./api/signatures";
|
|
32
35
|
import { getRevocationReasons } from "./api/revocations";
|
|
36
|
+
import { uploadSignatureVariant } from "./api/signatures";
|
|
37
|
+
import { getSignatureVariant } from "./api/signatures";
|
|
38
|
+
import { deleteSignatureVariant } from "./api/signatures";
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
466
|
-
|
|
467
|
-
|
|
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
|
-
|
|
672
|
-
|
|
673
|
-
|
|
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 =
|
|
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.
|
|
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 =
|
|
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, [[
|
|
715
|
+
}, _callee2, null, [[1, 4]]);
|
|
697
716
|
}));
|
|
698
717
|
return function getRevocationReasons() {
|
|
699
718
|
return _ref2.apply(this, arguments);
|
|
@@ -33367,6 +33386,154 @@ var getDocsOnBoarding = /*#__PURE__*/function () {
|
|
|
33367
33386
|
return _ref8.apply(this, arguments);
|
|
33368
33387
|
};
|
|
33369
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
|
+
}();
|
|
33370
33537
|
|
|
33371
33538
|
// =================================================================
|
|
33372
33539
|
// Exported Functions
|
|
@@ -33380,32 +33547,32 @@ var getDocsOnBoarding = /*#__PURE__*/function () {
|
|
|
33380
33547
|
* @throws {ApacuanaAPIError} Arroja un error 'NOT_IMPLEMENTED' para cualquier tipo de integración.
|
|
33381
33548
|
*/
|
|
33382
33549
|
var signDocument = /*#__PURE__*/function () {
|
|
33383
|
-
var
|
|
33384
|
-
var
|
|
33385
|
-
return _regenerator().w(function (
|
|
33386
|
-
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) {
|
|
33387
33554
|
case 0:
|
|
33388
|
-
|
|
33555
|
+
_getConfig3 = getConfig(), integrationType = _getConfig3.integrationType;
|
|
33389
33556
|
if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
|
|
33390
|
-
|
|
33557
|
+
_context13.n = 1;
|
|
33391
33558
|
break;
|
|
33392
33559
|
}
|
|
33393
|
-
return
|
|
33560
|
+
return _context13.a(2, signDocumentOnBoarding(signData));
|
|
33394
33561
|
case 1:
|
|
33395
33562
|
if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
|
|
33396
|
-
|
|
33563
|
+
_context13.n = 2;
|
|
33397
33564
|
break;
|
|
33398
33565
|
}
|
|
33399
|
-
return
|
|
33566
|
+
return _context13.a(2, signDocumentOnPremise());
|
|
33400
33567
|
case 2:
|
|
33401
33568
|
throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
|
|
33402
33569
|
case 3:
|
|
33403
|
-
return
|
|
33570
|
+
return _context13.a(2);
|
|
33404
33571
|
}
|
|
33405
|
-
},
|
|
33572
|
+
}, _callee13);
|
|
33406
33573
|
}));
|
|
33407
|
-
return function signDocument(
|
|
33408
|
-
return
|
|
33574
|
+
return function signDocument(_x6) {
|
|
33575
|
+
return _ref14.apply(this, arguments);
|
|
33409
33576
|
};
|
|
33410
33577
|
}();
|
|
33411
33578
|
|
|
@@ -33416,33 +33583,33 @@ var signDocument = /*#__PURE__*/function () {
|
|
|
33416
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.
|
|
33417
33584
|
*/
|
|
33418
33585
|
var getDigest = /*#__PURE__*/function () {
|
|
33419
|
-
var
|
|
33420
|
-
var
|
|
33421
|
-
return _regenerator().w(function (
|
|
33422
|
-
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) {
|
|
33423
33590
|
case 0:
|
|
33424
33591
|
helpers.validateGetDigestData(signData);
|
|
33425
|
-
|
|
33592
|
+
_getConfig4 = getConfig(), integrationType = _getConfig4.integrationType;
|
|
33426
33593
|
if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
|
|
33427
|
-
|
|
33594
|
+
_context14.n = 1;
|
|
33428
33595
|
break;
|
|
33429
33596
|
}
|
|
33430
|
-
return
|
|
33597
|
+
return _context14.a(2, getDigestToSignOnBoarding(signData));
|
|
33431
33598
|
case 1:
|
|
33432
33599
|
if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
|
|
33433
|
-
|
|
33600
|
+
_context14.n = 2;
|
|
33434
33601
|
break;
|
|
33435
33602
|
}
|
|
33436
|
-
return
|
|
33603
|
+
return _context14.a(2, getDigestToSignOnPremise());
|
|
33437
33604
|
case 2:
|
|
33438
33605
|
throw new ApacuanaAPIError("Document retrieval is not supported for an unknown integration type: ".concat(integrationType), 501, "NOT_IMPLEMENTED");
|
|
33439
33606
|
case 3:
|
|
33440
|
-
return
|
|
33607
|
+
return _context14.a(2);
|
|
33441
33608
|
}
|
|
33442
|
-
},
|
|
33609
|
+
}, _callee14);
|
|
33443
33610
|
}));
|
|
33444
|
-
return function getDigest(
|
|
33445
|
-
return
|
|
33611
|
+
return function getDigest(_x7) {
|
|
33612
|
+
return _ref15.apply(this, arguments);
|
|
33446
33613
|
};
|
|
33447
33614
|
}();
|
|
33448
33615
|
|
|
@@ -33478,38 +33645,38 @@ var getDigest = /*#__PURE__*/function () {
|
|
|
33478
33645
|
* @throws {ApacuanaAPIError} If signerData is invalid or if the integration type is not supported.
|
|
33479
33646
|
*/
|
|
33480
33647
|
var addSigner = /*#__PURE__*/function () {
|
|
33481
|
-
var
|
|
33482
|
-
var
|
|
33483
|
-
return _regenerator().w(function (
|
|
33484
|
-
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) {
|
|
33485
33652
|
case 0:
|
|
33486
33653
|
if (!(!signerData || _typeof(signerData) !== "object" || Object.keys(signerData).length === 0)) {
|
|
33487
|
-
|
|
33654
|
+
_context15.n = 1;
|
|
33488
33655
|
break;
|
|
33489
33656
|
}
|
|
33490
33657
|
throw new ApacuanaAPIError("Signer data (signerData) is required and must be a non-empty object.", 400, "INVALID_PARAMETER");
|
|
33491
33658
|
case 1:
|
|
33492
|
-
|
|
33659
|
+
_getConfig5 = getConfig(), integrationType = _getConfig5.integrationType;
|
|
33493
33660
|
if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
|
|
33494
|
-
|
|
33661
|
+
_context15.n = 2;
|
|
33495
33662
|
break;
|
|
33496
33663
|
}
|
|
33497
|
-
return
|
|
33664
|
+
return _context15.a(2, addSignerOnBoarding(signerData));
|
|
33498
33665
|
case 2:
|
|
33499
33666
|
if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
|
|
33500
|
-
|
|
33667
|
+
_context15.n = 3;
|
|
33501
33668
|
break;
|
|
33502
33669
|
}
|
|
33503
|
-
return
|
|
33670
|
+
return _context15.a(2, addSignerOnPremise());
|
|
33504
33671
|
case 3:
|
|
33505
33672
|
throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
|
|
33506
33673
|
case 4:
|
|
33507
|
-
return
|
|
33674
|
+
return _context15.a(2);
|
|
33508
33675
|
}
|
|
33509
|
-
},
|
|
33676
|
+
}, _callee15);
|
|
33510
33677
|
}));
|
|
33511
|
-
return function addSigner(
|
|
33512
|
-
return
|
|
33678
|
+
return function addSigner(_x8) {
|
|
33679
|
+
return _ref16.apply(this, arguments);
|
|
33513
33680
|
};
|
|
33514
33681
|
}();
|
|
33515
33682
|
|
|
@@ -33520,33 +33687,158 @@ var addSigner = /*#__PURE__*/function () {
|
|
|
33520
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.
|
|
33521
33688
|
*/
|
|
33522
33689
|
var getDocs = /*#__PURE__*/function () {
|
|
33523
|
-
var
|
|
33524
|
-
var
|
|
33525
|
-
return _regenerator().w(function (
|
|
33526
|
-
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) {
|
|
33527
33694
|
case 0:
|
|
33528
33695
|
helpers.validateGetDocsData(data);
|
|
33529
|
-
|
|
33696
|
+
_getConfig6 = getConfig(), integrationType = _getConfig6.integrationType;
|
|
33530
33697
|
if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
|
|
33531
|
-
|
|
33698
|
+
_context16.n = 1;
|
|
33532
33699
|
break;
|
|
33533
33700
|
}
|
|
33534
|
-
return
|
|
33701
|
+
return _context16.a(2, getDocsOnBoarding(data));
|
|
33535
33702
|
case 1:
|
|
33536
33703
|
if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
|
|
33537
|
-
|
|
33704
|
+
_context16.n = 2;
|
|
33538
33705
|
break;
|
|
33539
33706
|
}
|
|
33540
|
-
return
|
|
33707
|
+
return _context16.a(2, getDocsOnPremise());
|
|
33541
33708
|
case 2:
|
|
33542
33709
|
throw new ApacuanaAPIError("Document retrieval is not supported for an unknown integration type: ".concat(integrationType), 501, "NOT_IMPLEMENTED");
|
|
33543
33710
|
case 3:
|
|
33544
|
-
return
|
|
33711
|
+
return _context16.a(2);
|
|
33545
33712
|
}
|
|
33546
|
-
},
|
|
33713
|
+
}, _callee16);
|
|
33547
33714
|
}));
|
|
33548
|
-
return function getDocs(
|
|
33549
|
-
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);
|
|
33550
33842
|
};
|
|
33551
33843
|
}();
|
|
33552
33844
|
|
|
@@ -33619,7 +33911,10 @@ var apacuana = {
|
|
|
33619
33911
|
generateCert: generateCert,
|
|
33620
33912
|
signDocument: signDocument,
|
|
33621
33913
|
getDigest: getDigest,
|
|
33622
|
-
getRevocationReasons: getRevocationReasons
|
|
33914
|
+
getRevocationReasons: getRevocationReasons,
|
|
33915
|
+
uploadSignatureVariant: uploadSignatureVariant,
|
|
33916
|
+
getSignatureVariant: getSignatureVariant,
|
|
33917
|
+
deleteSignatureVariant: deleteSignatureVariant
|
|
33623
33918
|
};
|
|
33624
33919
|
|
|
33625
33920
|
module.exports = apacuana;
|