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