apacuana-sdk-core 0.5.0 → 0.6.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 +90 -55
- package/coverage/clover.xml +144 -123
- package/coverage/coverage-final.json +6 -6
- package/coverage/lcov-report/index.html +27 -27
- package/coverage/lcov-report/src/api/certs.js.html +40 -4
- package/coverage/lcov-report/src/api/index.html +19 -19
- package/coverage/lcov-report/src/api/revocations.js.html +21 -3
- package/coverage/lcov-report/src/api/signatures.js.html +123 -18
- package/coverage/lcov-report/src/api/users.js.html +24 -3
- package/coverage/lcov-report/src/config/index.html +1 -1
- package/coverage/lcov-report/src/config/index.js.html +1 -1
- package/coverage/lcov-report/src/errors/index.html +1 -1
- package/coverage/lcov-report/src/errors/index.js.html +1 -1
- package/coverage/lcov-report/src/index.html +1 -1
- package/coverage/lcov-report/src/index.js.html +9 -3
- package/coverage/lcov-report/src/utils/constant.js.html +3 -3
- package/coverage/lcov-report/src/utils/helpers.js.html +143 -8
- package/coverage/lcov-report/src/utils/httpClient.js.html +1 -1
- package/coverage/lcov-report/src/utils/index.html +15 -15
- package/coverage/lcov.info +252 -204
- package/dist/api/certs.d.ts +17 -3
- package/dist/api/revocations.d.ts +17 -2
- package/dist/api/signatures.d.ts +18 -1
- package/dist/api/users.d.ts +22 -6
- package/dist/index.d.ts +4 -0
- package/dist/index.js +335 -22
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +335 -22
- package/dist/index.mjs.map +1 -1
- package/dist/utils/helpers.d.ts +2 -0
- package/package.json +1 -1
- package/src/api/certs.js +14 -2
- package/src/api/revocations.js +7 -1
- package/src/api/signatures.js +43 -8
- package/src/api/users.js +8 -1
- package/src/index.js +3 -1
- package/src/utils/constant.js +2 -2
- package/src/utils/helpers.js +45 -0
package/dist/index.mjs
CHANGED
|
@@ -283,8 +283,8 @@ var VERIFICATION_STATUS = {
|
|
|
283
283
|
APPROVED: 1
|
|
284
284
|
};
|
|
285
285
|
var INTEGRATION_TYPE = {
|
|
286
|
-
ONBOARDING:
|
|
287
|
-
ONPREMISE:
|
|
286
|
+
ONBOARDING: "ONBOARDING",
|
|
287
|
+
ONPREMISE: "ONPREMISE"
|
|
288
288
|
};
|
|
289
289
|
|
|
290
290
|
var config = {
|
|
@@ -515,12 +515,19 @@ var httpRequest = /*#__PURE__*/function () {
|
|
|
515
515
|
};
|
|
516
516
|
}();
|
|
517
517
|
|
|
518
|
+
/**
|
|
519
|
+
* @typedef {object} GetCustomerResponse
|
|
520
|
+
* @property {string} token - El token de sesión del usuario.
|
|
521
|
+
* @property {object} userData - Los datos del usuario obtenidos.
|
|
522
|
+
* @property {boolean} success - Indica si la operación fue exitosa.
|
|
523
|
+
*/
|
|
524
|
+
|
|
518
525
|
/**
|
|
519
526
|
* Obtiene el token de un usuario a través de una petición POST.
|
|
520
527
|
* Este método es útil para endpoints que requieren datos en el cuerpo de la petición
|
|
521
528
|
* para buscar un usuario, como un ID de sesión o un token de acceso.
|
|
522
529
|
*
|
|
523
|
-
* @returns {Promise<
|
|
530
|
+
* @returns {Promise<GetCustomerResponse>} Objeto con el token de sesión, los datos del usuario y un indicador de éxito.
|
|
524
531
|
* @throws {Error} Si los parámetros de entrada son inválidos.
|
|
525
532
|
* @throws {ApacuanaAPIError} Si ocurre un error en la API de Apacuana.
|
|
526
533
|
*/
|
|
@@ -577,10 +584,16 @@ var getCustomer = /*#__PURE__*/function () {
|
|
|
577
584
|
};
|
|
578
585
|
}();
|
|
579
586
|
|
|
587
|
+
/**
|
|
588
|
+
* @typedef {object} RequestRevocationResponse
|
|
589
|
+
* @property {string} revocationStatus - El estado de la solicitud de revocación (e.g., "pending").
|
|
590
|
+
* @property {string|number} requestId - El ID de la solicitud de revocación.
|
|
591
|
+
*/
|
|
592
|
+
|
|
580
593
|
/**
|
|
581
594
|
* Simula la solicitud de revocación de un certificado.
|
|
582
595
|
* @param {string} reasonCode - Código o descripción del motivo de la revocación.
|
|
583
|
-
* @returns {Promise<
|
|
596
|
+
* @returns {Promise<RequestRevocationResponse>} Objeto con el estado de la solicitud de revocación.
|
|
584
597
|
*/
|
|
585
598
|
var requestRevocation = /*#__PURE__*/function () {
|
|
586
599
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(reasonCode) {
|
|
@@ -32758,6 +32771,26 @@ var validateGetDigestData = function validateGetDigestData(signData) {
|
|
|
32758
32771
|
throw new ApacuanaAPIError("Los parámetros 'cert' y 'signatureId' son requeridos y deben ser cadenas de texto.", 400, "INVALID_PARAMETER");
|
|
32759
32772
|
}
|
|
32760
32773
|
};
|
|
32774
|
+
var validateOnBoardingSignDocumentData = function validateOnBoardingSignDocumentData(signData) {
|
|
32775
|
+
if (!signData || _typeof(signData) !== "object") {
|
|
32776
|
+
throw new ApacuanaAPIError("Sign data is required and must be an object.", 400, "INVALID_PARAMETER");
|
|
32777
|
+
}
|
|
32778
|
+
var signature = signData.signature,
|
|
32779
|
+
cert = signData.cert,
|
|
32780
|
+
signedDigest = signData.signedDigest;
|
|
32781
|
+
if (!signature || _typeof(signature) !== "object" || !signature.id) {
|
|
32782
|
+
throw new ApacuanaAPIError("Signature object with an 'id' property is required.", 400, "INVALID_PARAMETER");
|
|
32783
|
+
}
|
|
32784
|
+
if (!Array.isArray(signature.positions)) {
|
|
32785
|
+
throw new ApacuanaAPIError("Signature 'positions' must be an array.", 400, "INVALID_PARAMETER");
|
|
32786
|
+
}
|
|
32787
|
+
if (!cert || typeof cert !== "string") {
|
|
32788
|
+
throw new ApacuanaAPIError("Certificate 'cert' is required and must be a string.", 400, "INVALID_PARAMETER");
|
|
32789
|
+
}
|
|
32790
|
+
if (!signedDigest || typeof signedDigest !== "string") {
|
|
32791
|
+
throw new ApacuanaAPIError("Signed digest 'signedDigest' is required and must be a string.", 400, "INVALID_PARAMETER");
|
|
32792
|
+
}
|
|
32793
|
+
};
|
|
32761
32794
|
var helpers = {
|
|
32762
32795
|
getCertificateStatus: getCertificateStatus,
|
|
32763
32796
|
exportPrivateKey: exportPrivateKey,
|
|
@@ -32766,9 +32799,22 @@ var helpers = {
|
|
|
32766
32799
|
validateOnBoardingSignerData: validateOnBoardingSignerData,
|
|
32767
32800
|
validateCsr: validateCsr,
|
|
32768
32801
|
validateGetDocsData: validateGetDocsData,
|
|
32769
|
-
validateGetDigestData: validateGetDigestData
|
|
32802
|
+
validateGetDigestData: validateGetDigestData,
|
|
32803
|
+
validateOnBoardingSignDocumentData: validateOnBoardingSignDocumentData
|
|
32770
32804
|
};
|
|
32771
32805
|
|
|
32806
|
+
/**
|
|
32807
|
+
* @typedef {object} GenerateCertResponse
|
|
32808
|
+
* @property {string} cert - El certificado generado en formato string.
|
|
32809
|
+
* @property {boolean} success - Indica si la operación fue exitosa.
|
|
32810
|
+
*/
|
|
32811
|
+
|
|
32812
|
+
/**
|
|
32813
|
+
* @typedef {object} GetCertStatusResponse
|
|
32814
|
+
* @property {string} status - El estado actual del certificado del usuario.
|
|
32815
|
+
* @property {boolean} success - Indica si la operación fue exitosa.
|
|
32816
|
+
*/
|
|
32817
|
+
|
|
32772
32818
|
var generateCertOnBoarding = /*#__PURE__*/function () {
|
|
32773
32819
|
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
32774
32820
|
var csr,
|
|
@@ -32836,7 +32882,7 @@ var generateCertOnPremise = /*#__PURE__*/function () {
|
|
|
32836
32882
|
/**
|
|
32837
32883
|
* Generates a digital certificate.
|
|
32838
32884
|
* @param {string} [csr] - Certificate Signing Request (CSR).
|
|
32839
|
-
* @returns {Promise<
|
|
32885
|
+
* @returns {Promise<GenerateCertResponse>} Object with the generated certificate and a success indicator.
|
|
32840
32886
|
* @throws {ApacuanaAPIError} If the CSR is invalid, if the API response does not contain the certificate, or if the integration type is not supported.
|
|
32841
32887
|
* @throws {Error} If certificate generation fails for another reason.
|
|
32842
32888
|
*/
|
|
@@ -32878,7 +32924,7 @@ var generateCert = /*#__PURE__*/function () {
|
|
|
32878
32924
|
/**
|
|
32879
32925
|
* Gets the user's certificate status.
|
|
32880
32926
|
* @param {boolean} [isCertificateInDevice=false] - Indicates if the certificate is already on the device.
|
|
32881
|
-
* @returns {
|
|
32927
|
+
* @returns {GetCertStatusResponse} Object with the certificate status and a success indicator.
|
|
32882
32928
|
*/
|
|
32883
32929
|
var getCertStatus = function getCertStatus() {
|
|
32884
32930
|
var isCertificateInDevice = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
@@ -32890,9 +32936,196 @@ var getCertStatus = function getCertStatus() {
|
|
|
32890
32936
|
};
|
|
32891
32937
|
};
|
|
32892
32938
|
|
|
32939
|
+
// =================================================================
|
|
32940
|
+
// Type Definitions
|
|
32941
|
+
// =================================================================
|
|
32942
|
+
|
|
32943
|
+
/**
|
|
32944
|
+
* Define la estructura de un objeto Firmante.
|
|
32945
|
+
* @typedef {object} Signer
|
|
32946
|
+
* @property {string} name - Nombre completo del firmante.
|
|
32947
|
+
* @property {string} email - Correo electrónico del firmante.
|
|
32948
|
+
* @property {string} document - Documento de identidad del firmante.
|
|
32949
|
+
*/
|
|
32950
|
+
|
|
32951
|
+
/**
|
|
32952
|
+
* Define la estructura de datos para añadir un firmante.
|
|
32953
|
+
* @typedef {object} SignerData
|
|
32954
|
+
* @property {string} docId - Identificador único del documento.
|
|
32955
|
+
* @property {Signer} signer - Objeto con la información del firmante.
|
|
32956
|
+
*/
|
|
32957
|
+
|
|
32958
|
+
/**
|
|
32959
|
+
* Define la estructura de la respuesta al añadir un firmante.
|
|
32960
|
+
* @typedef {object} AddSignerResponse
|
|
32961
|
+
* @property {string} signer - Identificador de confirmación del firmante añadido.
|
|
32962
|
+
* @property {boolean} success - Indica si la operación fue exitosa.
|
|
32963
|
+
*/
|
|
32964
|
+
|
|
32965
|
+
/**
|
|
32966
|
+
* Define la estructura de datos para obtener el digest de un documento.
|
|
32967
|
+
* @typedef {object} GetDigestData
|
|
32968
|
+
* @property {string} cert - Certificado del firmante en formato base64.
|
|
32969
|
+
* @property {string} signatureId - Identificador único del proceso de firma.
|
|
32970
|
+
*/
|
|
32971
|
+
|
|
32972
|
+
/**
|
|
32973
|
+
* Define la estructura de la respuesta al obtener el digest.
|
|
32974
|
+
* @typedef {object} GetDigestResponse
|
|
32975
|
+
* @property {string} digest - El digest del documento que se va a firmar.
|
|
32976
|
+
* @property {boolean} success - Indica si la operación fue exitosa.
|
|
32977
|
+
*/
|
|
32978
|
+
|
|
32979
|
+
/**
|
|
32980
|
+
* Define la estructura de los parámetros para obtener documentos.
|
|
32981
|
+
* @typedef {object} GetDocsParams
|
|
32982
|
+
* @property {number} page - Número de página para la paginación.
|
|
32983
|
+
* @property {number} size - Cantidad de registros por página.
|
|
32984
|
+
* @property {string} [status] - (Opcional) Estado para filtrar los documentos.
|
|
32985
|
+
*/
|
|
32986
|
+
|
|
32987
|
+
/**
|
|
32988
|
+
* Define la estructura de la respuesta al obtener documentos.
|
|
32989
|
+
* @typedef {object} GetDocsResponse
|
|
32990
|
+
* @property {number} totalRecords - El número total de registros encontrados.
|
|
32991
|
+
* @property {Array<object>} records - Un arreglo con los registros de los documentos.
|
|
32992
|
+
* @property {boolean} success - Indica si la operación fue exitosa.
|
|
32993
|
+
*/
|
|
32994
|
+
|
|
32995
|
+
/**
|
|
32996
|
+
* @typedef {object} SignDocumentData
|
|
32997
|
+
* @property {object} signature - Objeto con información de la firma.
|
|
32998
|
+
* @property {string} signature.id - ID de la firma.
|
|
32999
|
+
* @property {Array<object>} signature.positions - Posiciones de la firma.
|
|
33000
|
+
* @property {string} cert - Certificado en base64.
|
|
33001
|
+
* @property {string} signedDigest - Digest firmado.
|
|
33002
|
+
*/
|
|
33003
|
+
|
|
33004
|
+
// =================================================================
|
|
33005
|
+
// Internal Functions
|
|
33006
|
+
// =================================================================
|
|
33007
|
+
|
|
33008
|
+
var signDocumentOnBoarding = /*#__PURE__*/function () {
|
|
33009
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(signData) {
|
|
33010
|
+
var signature, cert, signedDigest, signBody, response, _t;
|
|
33011
|
+
return _regenerator().w(function (_context) {
|
|
33012
|
+
while (1) switch (_context.p = _context.n) {
|
|
33013
|
+
case 0:
|
|
33014
|
+
helpers.validateOnBoardingSignDocumentData(signData);
|
|
33015
|
+
signature = signData.signature, cert = signData.cert, signedDigest = signData.signedDigest;
|
|
33016
|
+
_context.p = 1;
|
|
33017
|
+
signBody = {
|
|
33018
|
+
positions: JSON.stringify(signature.positions.map(function (p) {
|
|
33019
|
+
return {
|
|
33020
|
+
x: p.x,
|
|
33021
|
+
y: p.y,
|
|
33022
|
+
page: p.page,
|
|
33023
|
+
status: 1
|
|
33024
|
+
};
|
|
33025
|
+
})),
|
|
33026
|
+
publickey: cert,
|
|
33027
|
+
signeddigest: signedDigest
|
|
33028
|
+
};
|
|
33029
|
+
_context.n = 2;
|
|
33030
|
+
return httpRequest("services/api/documents/sign/".concat(signature.id), signBody, "PUT");
|
|
33031
|
+
case 2:
|
|
33032
|
+
response = _context.v;
|
|
33033
|
+
return _context.a(2, response);
|
|
33034
|
+
case 3:
|
|
33035
|
+
_context.p = 3;
|
|
33036
|
+
_t = _context.v;
|
|
33037
|
+
if (!(_t instanceof ApacuanaAPIError)) {
|
|
33038
|
+
_context.n = 4;
|
|
33039
|
+
break;
|
|
33040
|
+
}
|
|
33041
|
+
throw _t;
|
|
33042
|
+
case 4:
|
|
33043
|
+
throw new ApacuanaAPIError("Failed to sign document: ".concat(_t.message || "Unknown error"));
|
|
33044
|
+
case 5:
|
|
33045
|
+
return _context.a(2);
|
|
33046
|
+
}
|
|
33047
|
+
}, _callee, null, [[1, 3]]);
|
|
33048
|
+
}));
|
|
33049
|
+
return function signDocumentOnBoarding(_x) {
|
|
33050
|
+
return _ref.apply(this, arguments);
|
|
33051
|
+
};
|
|
33052
|
+
}();
|
|
33053
|
+
var signDocumentOnPremise = /*#__PURE__*/function () {
|
|
33054
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
33055
|
+
return _regenerator().w(function (_context2) {
|
|
33056
|
+
while (1) switch (_context2.n) {
|
|
33057
|
+
case 0:
|
|
33058
|
+
throw new ApacuanaAPIError("Document signing is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
|
|
33059
|
+
case 1:
|
|
33060
|
+
return _context2.a(2);
|
|
33061
|
+
}
|
|
33062
|
+
}, _callee2);
|
|
33063
|
+
}));
|
|
33064
|
+
return function signDocumentOnPremise() {
|
|
33065
|
+
return _ref2.apply(this, arguments);
|
|
33066
|
+
};
|
|
33067
|
+
}();
|
|
33068
|
+
var getDigestToSignOnBoarding = /*#__PURE__*/function () {
|
|
33069
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(signData) {
|
|
33070
|
+
var _response$data, response, digest, _t2;
|
|
33071
|
+
return _regenerator().w(function (_context3) {
|
|
33072
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
33073
|
+
case 0:
|
|
33074
|
+
_context3.p = 0;
|
|
33075
|
+
_context3.n = 1;
|
|
33076
|
+
return httpRequest("services/api/documents/getdigest/".concat(signData.signatureId), {
|
|
33077
|
+
publickey: signData.cert
|
|
33078
|
+
}, "POST");
|
|
33079
|
+
case 1:
|
|
33080
|
+
response = _context3.v;
|
|
33081
|
+
digest = ((_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.digest) || response.digest;
|
|
33082
|
+
if (digest) {
|
|
33083
|
+
_context3.n = 2;
|
|
33084
|
+
break;
|
|
33085
|
+
}
|
|
33086
|
+
throw new ApacuanaAPIError("Signature generation failed: digest not found in the response.", 500, "API_RESPONSE_ERROR");
|
|
33087
|
+
case 2:
|
|
33088
|
+
return _context3.a(2, {
|
|
33089
|
+
digest: digest,
|
|
33090
|
+
success: true
|
|
33091
|
+
});
|
|
33092
|
+
case 3:
|
|
33093
|
+
_context3.p = 3;
|
|
33094
|
+
_t2 = _context3.v;
|
|
33095
|
+
if (!(_t2.name === "ApacuanaAPIError")) {
|
|
33096
|
+
_context3.n = 4;
|
|
33097
|
+
break;
|
|
33098
|
+
}
|
|
33099
|
+
throw _t2;
|
|
33100
|
+
case 4:
|
|
33101
|
+
throw new ApacuanaAPIError("Failed to sign document (on-boarding): ".concat(_t2.message));
|
|
33102
|
+
case 5:
|
|
33103
|
+
return _context3.a(2);
|
|
33104
|
+
}
|
|
33105
|
+
}, _callee3, null, [[0, 3]]);
|
|
33106
|
+
}));
|
|
33107
|
+
return function getDigestToSignOnBoarding(_x2) {
|
|
33108
|
+
return _ref3.apply(this, arguments);
|
|
33109
|
+
};
|
|
33110
|
+
}();
|
|
33111
|
+
var getDigestToSignOnPremise = /*#__PURE__*/function () {
|
|
33112
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
|
|
33113
|
+
return _regenerator().w(function (_context4) {
|
|
33114
|
+
while (1) switch (_context4.n) {
|
|
33115
|
+
case 0:
|
|
33116
|
+
throw new ApacuanaAPIError("Digest retrieval is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
|
|
33117
|
+
case 1:
|
|
33118
|
+
return _context4.a(2);
|
|
33119
|
+
}
|
|
33120
|
+
}, _callee4);
|
|
33121
|
+
}));
|
|
33122
|
+
return function getDigestToSignOnPremise() {
|
|
33123
|
+
return _ref4.apply(this, arguments);
|
|
33124
|
+
};
|
|
33125
|
+
}();
|
|
32893
33126
|
var addSignerOnBoarding = /*#__PURE__*/function () {
|
|
32894
33127
|
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(signerData) {
|
|
32895
|
-
var
|
|
33128
|
+
var _t3;
|
|
32896
33129
|
return _regenerator().w(function (_context5) {
|
|
32897
33130
|
while (1) switch (_context5.p = _context5.n) {
|
|
32898
33131
|
case 0:
|
|
@@ -32907,20 +33140,20 @@ var addSignerOnBoarding = /*#__PURE__*/function () {
|
|
|
32907
33140
|
});
|
|
32908
33141
|
case 3:
|
|
32909
33142
|
_context5.p = 3;
|
|
32910
|
-
|
|
32911
|
-
if (!(
|
|
33143
|
+
_t3 = _context5.v;
|
|
33144
|
+
if (!(_t3 instanceof ApacuanaAPIError)) {
|
|
32912
33145
|
_context5.n = 4;
|
|
32913
33146
|
break;
|
|
32914
33147
|
}
|
|
32915
|
-
throw
|
|
33148
|
+
throw _t3;
|
|
32916
33149
|
case 4:
|
|
32917
|
-
throw new Error("Failed to add signer in On-Boarding: ".concat(
|
|
33150
|
+
throw new Error("Failed to add signer in On-Boarding: ".concat(_t3.message));
|
|
32918
33151
|
case 5:
|
|
32919
33152
|
return _context5.a(2);
|
|
32920
33153
|
}
|
|
32921
33154
|
}, _callee5, null, [[1, 3]]);
|
|
32922
33155
|
}));
|
|
32923
|
-
return function addSignerOnBoarding(
|
|
33156
|
+
return function addSignerOnBoarding(_x3) {
|
|
32924
33157
|
return _ref5.apply(this, arguments);
|
|
32925
33158
|
};
|
|
32926
33159
|
}();
|
|
@@ -32956,7 +33189,7 @@ var getDocsOnPremise = /*#__PURE__*/function () {
|
|
|
32956
33189
|
}();
|
|
32957
33190
|
var getDocsOnBoarding = /*#__PURE__*/function () {
|
|
32958
33191
|
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(data) {
|
|
32959
|
-
var _getConfig, customerId, params, apiUrl, response,
|
|
33192
|
+
var _getConfig, customerId, params, apiUrl, response, _t4;
|
|
32960
33193
|
return _regenerator().w(function (_context8) {
|
|
32961
33194
|
while (1) switch (_context8.p = _context8.n) {
|
|
32962
33195
|
case 0:
|
|
@@ -32988,24 +33221,102 @@ var getDocsOnBoarding = /*#__PURE__*/function () {
|
|
|
32988
33221
|
});
|
|
32989
33222
|
case 3:
|
|
32990
33223
|
_context8.p = 3;
|
|
32991
|
-
|
|
32992
|
-
if (!(
|
|
33224
|
+
_t4 = _context8.v;
|
|
33225
|
+
if (!(_t4.name === "ApacuanaAPIError")) {
|
|
32993
33226
|
_context8.n = 4;
|
|
32994
33227
|
break;
|
|
32995
33228
|
}
|
|
32996
|
-
throw
|
|
33229
|
+
throw _t4;
|
|
32997
33230
|
case 4:
|
|
32998
|
-
throw new ApacuanaAPIError("Failed to get document list (on-boarding): ".concat(
|
|
33231
|
+
throw new ApacuanaAPIError("Failed to get document list (on-boarding): ".concat(_t4.message));
|
|
32999
33232
|
case 5:
|
|
33000
33233
|
return _context8.a(2);
|
|
33001
33234
|
}
|
|
33002
33235
|
}, _callee8, null, [[1, 3]]);
|
|
33003
33236
|
}));
|
|
33004
|
-
return function getDocsOnBoarding(
|
|
33237
|
+
return function getDocsOnBoarding(_x4) {
|
|
33005
33238
|
return _ref8.apply(this, arguments);
|
|
33006
33239
|
};
|
|
33007
33240
|
}();
|
|
33008
33241
|
|
|
33242
|
+
// =================================================================
|
|
33243
|
+
// Exported Functions
|
|
33244
|
+
// =================================================================
|
|
33245
|
+
|
|
33246
|
+
/**
|
|
33247
|
+
* Firma un documento PDF con un certificado digital.
|
|
33248
|
+
* NOTA: Esta función no está implementada actualmente para ningún tipo de integración.
|
|
33249
|
+
* @param {SignDocumentData} signData - Datos necesarios para la firma.
|
|
33250
|
+
* @returns {Promise<object>}
|
|
33251
|
+
* @throws {ApacuanaAPIError} Arroja un error 'NOT_IMPLEMENTED' para cualquier tipo de integración.
|
|
33252
|
+
*/
|
|
33253
|
+
var signDocument = /*#__PURE__*/function () {
|
|
33254
|
+
var _ref9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(signData) {
|
|
33255
|
+
var _getConfig2, integrationType;
|
|
33256
|
+
return _regenerator().w(function (_context9) {
|
|
33257
|
+
while (1) switch (_context9.n) {
|
|
33258
|
+
case 0:
|
|
33259
|
+
_getConfig2 = getConfig(), integrationType = _getConfig2.integrationType;
|
|
33260
|
+
if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
|
|
33261
|
+
_context9.n = 1;
|
|
33262
|
+
break;
|
|
33263
|
+
}
|
|
33264
|
+
return _context9.a(2, signDocumentOnBoarding(signData));
|
|
33265
|
+
case 1:
|
|
33266
|
+
if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
|
|
33267
|
+
_context9.n = 2;
|
|
33268
|
+
break;
|
|
33269
|
+
}
|
|
33270
|
+
return _context9.a(2, signDocumentOnPremise());
|
|
33271
|
+
case 2:
|
|
33272
|
+
throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
|
|
33273
|
+
case 3:
|
|
33274
|
+
return _context9.a(2);
|
|
33275
|
+
}
|
|
33276
|
+
}, _callee9);
|
|
33277
|
+
}));
|
|
33278
|
+
return function signDocument(_x5) {
|
|
33279
|
+
return _ref9.apply(this, arguments);
|
|
33280
|
+
};
|
|
33281
|
+
}();
|
|
33282
|
+
|
|
33283
|
+
/**
|
|
33284
|
+
* Obtiene el digest de un documento para ser firmado.
|
|
33285
|
+
* @param {GetDigestData} signData - Datos requeridos para obtener el digest.
|
|
33286
|
+
* @returns {Promise<GetDigestResponse>} Una promesa que resuelve a un objeto con el digest del documento.
|
|
33287
|
+
* @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.
|
|
33288
|
+
*/
|
|
33289
|
+
var getDigest = /*#__PURE__*/function () {
|
|
33290
|
+
var _ref0 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(signData) {
|
|
33291
|
+
var _getConfig3, integrationType;
|
|
33292
|
+
return _regenerator().w(function (_context0) {
|
|
33293
|
+
while (1) switch (_context0.n) {
|
|
33294
|
+
case 0:
|
|
33295
|
+
helpers.validateGetDigestData(signData);
|
|
33296
|
+
_getConfig3 = getConfig(), integrationType = _getConfig3.integrationType;
|
|
33297
|
+
if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
|
|
33298
|
+
_context0.n = 1;
|
|
33299
|
+
break;
|
|
33300
|
+
}
|
|
33301
|
+
return _context0.a(2, getDigestToSignOnBoarding(signData));
|
|
33302
|
+
case 1:
|
|
33303
|
+
if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
|
|
33304
|
+
_context0.n = 2;
|
|
33305
|
+
break;
|
|
33306
|
+
}
|
|
33307
|
+
return _context0.a(2, getDigestToSignOnPremise());
|
|
33308
|
+
case 2:
|
|
33309
|
+
throw new ApacuanaAPIError("Document retrieval is not supported for an unknown integration type: ".concat(integrationType), 501, "NOT_IMPLEMENTED");
|
|
33310
|
+
case 3:
|
|
33311
|
+
return _context0.a(2);
|
|
33312
|
+
}
|
|
33313
|
+
}, _callee0);
|
|
33314
|
+
}));
|
|
33315
|
+
return function getDigest(_x6) {
|
|
33316
|
+
return _ref0.apply(this, arguments);
|
|
33317
|
+
};
|
|
33318
|
+
}();
|
|
33319
|
+
|
|
33009
33320
|
/**
|
|
33010
33321
|
* Añade un firmante a un documento.
|
|
33011
33322
|
* @param {SignerData} signerData - Los datos del firmante que se va a añadir.
|
|
@@ -33043,7 +33354,7 @@ var addSigner = /*#__PURE__*/function () {
|
|
|
33043
33354
|
}
|
|
33044
33355
|
}, _callee1);
|
|
33045
33356
|
}));
|
|
33046
|
-
return function addSigner(
|
|
33357
|
+
return function addSigner(_x7) {
|
|
33047
33358
|
return _ref1.apply(this, arguments);
|
|
33048
33359
|
};
|
|
33049
33360
|
}();
|
|
@@ -33080,7 +33391,7 @@ var getDocs = /*#__PURE__*/function () {
|
|
|
33080
33391
|
}
|
|
33081
33392
|
}, _callee10);
|
|
33082
33393
|
}));
|
|
33083
|
-
return function getDocs(
|
|
33394
|
+
return function getDocs(_x8) {
|
|
33084
33395
|
return _ref10.apply(this, arguments);
|
|
33085
33396
|
};
|
|
33086
33397
|
}();
|
|
@@ -33159,7 +33470,9 @@ var apacuana = {
|
|
|
33159
33470
|
getCustomer: getCustomer,
|
|
33160
33471
|
addSigner: addSigner,
|
|
33161
33472
|
getDocs: getDocs,
|
|
33162
|
-
generateCert: generateCert
|
|
33473
|
+
generateCert: generateCert,
|
|
33474
|
+
signDocument: signDocument,
|
|
33475
|
+
getDigest: getDigest
|
|
33163
33476
|
};
|
|
33164
33477
|
|
|
33165
33478
|
export { apacuana as default };
|