apacuana-sdk-core 0.4.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 +140 -119
- 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 +433 -148
- 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 +250 -202
- package/dist/api/certs.d.ts +17 -3
- package/dist/api/revocations.d.ts +17 -2
- package/dist/api/signatures.d.ts +120 -12
- package/dist/api/users.d.ts +22 -6
- package/dist/index.d.ts +4 -0
- package/dist/index.js +405 -92
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +405 -92
- 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 +195 -100
- 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/tests/api/signatures.test.js +11 -4
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,169 +32938,434 @@ 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
|
-
var
|
|
32897
|
-
var
|
|
32898
|
-
return _regenerator().w(function (
|
|
32899
|
-
while (1) switch (
|
|
33129
|
+
var _ref5 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(signerData) {
|
|
33130
|
+
var _t3;
|
|
33131
|
+
return _regenerator().w(function (_context5) {
|
|
33132
|
+
while (1) switch (_context5.p = _context5.n) {
|
|
32900
33133
|
case 0:
|
|
32901
33134
|
helpers.validateOnBoardingSignerData(signerData);
|
|
32902
|
-
|
|
32903
|
-
|
|
33135
|
+
_context5.p = 1;
|
|
33136
|
+
_context5.n = 2;
|
|
32904
33137
|
return httpRequest("services/api/documents/signing", signerData, "POST");
|
|
32905
33138
|
case 2:
|
|
32906
|
-
return
|
|
33139
|
+
return _context5.a(2, {
|
|
32907
33140
|
signer: signerData.typedoc + signerData.doc,
|
|
32908
33141
|
success: true
|
|
32909
33142
|
});
|
|
32910
33143
|
case 3:
|
|
32911
|
-
|
|
32912
|
-
|
|
32913
|
-
if (!(
|
|
32914
|
-
|
|
33144
|
+
_context5.p = 3;
|
|
33145
|
+
_t3 = _context5.v;
|
|
33146
|
+
if (!(_t3 instanceof ApacuanaAPIError)) {
|
|
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
|
-
return
|
|
33154
|
+
return _context5.a(2);
|
|
32922
33155
|
}
|
|
32923
|
-
},
|
|
33156
|
+
}, _callee5, null, [[1, 3]]);
|
|
32924
33157
|
}));
|
|
32925
33158
|
return function addSignerOnBoarding(_x3) {
|
|
32926
|
-
return
|
|
33159
|
+
return _ref5.apply(this, arguments);
|
|
32927
33160
|
};
|
|
32928
33161
|
}();
|
|
32929
33162
|
var addSignerOnPremise = /*#__PURE__*/function () {
|
|
32930
|
-
var
|
|
32931
|
-
return _regenerator().w(function (
|
|
32932
|
-
while (1) switch (
|
|
33163
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
|
|
33164
|
+
return _regenerator().w(function (_context6) {
|
|
33165
|
+
while (1) switch (_context6.n) {
|
|
32933
33166
|
case 0:
|
|
32934
33167
|
throw new ApacuanaAPIError("Adding signers is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
|
|
32935
33168
|
case 1:
|
|
32936
|
-
return
|
|
33169
|
+
return _context6.a(2);
|
|
32937
33170
|
}
|
|
32938
|
-
},
|
|
33171
|
+
}, _callee6);
|
|
32939
33172
|
}));
|
|
32940
33173
|
return function addSignerOnPremise() {
|
|
33174
|
+
return _ref6.apply(this, arguments);
|
|
33175
|
+
};
|
|
33176
|
+
}();
|
|
33177
|
+
var getDocsOnPremise = /*#__PURE__*/function () {
|
|
33178
|
+
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7() {
|
|
33179
|
+
return _regenerator().w(function (_context7) {
|
|
33180
|
+
while (1) switch (_context7.n) {
|
|
33181
|
+
case 0:
|
|
33182
|
+
throw new ApacuanaAPIError("Document retrieval is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
|
|
33183
|
+
case 1:
|
|
33184
|
+
return _context7.a(2);
|
|
33185
|
+
}
|
|
33186
|
+
}, _callee7);
|
|
33187
|
+
}));
|
|
33188
|
+
return function getDocsOnPremise() {
|
|
33189
|
+
return _ref7.apply(this, arguments);
|
|
33190
|
+
};
|
|
33191
|
+
}();
|
|
33192
|
+
var getDocsOnBoarding = /*#__PURE__*/function () {
|
|
33193
|
+
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(data) {
|
|
33194
|
+
var _getConfig, customerId, params, apiUrl, response, _t4;
|
|
33195
|
+
return _regenerator().w(function (_context8) {
|
|
33196
|
+
while (1) switch (_context8.p = _context8.n) {
|
|
33197
|
+
case 0:
|
|
33198
|
+
_getConfig = getConfig(), customerId = _getConfig.customerId;
|
|
33199
|
+
if (customerId) {
|
|
33200
|
+
_context8.n = 1;
|
|
33201
|
+
break;
|
|
33202
|
+
}
|
|
33203
|
+
throw new ApacuanaAPIError("'customerId' is not configured. Please configure the SDK.", 400, "CONFIGURATION_ERROR");
|
|
33204
|
+
case 1:
|
|
33205
|
+
_context8.p = 1;
|
|
33206
|
+
params = new URLSearchParams({
|
|
33207
|
+
page: data.page,
|
|
33208
|
+
customerid: customerId,
|
|
33209
|
+
size: data.size
|
|
33210
|
+
});
|
|
33211
|
+
if (typeof data.status !== "undefined") {
|
|
33212
|
+
params.append("status", data.status);
|
|
33213
|
+
}
|
|
33214
|
+
apiUrl = "services/api/documents/listcustomer?".concat(params.toString());
|
|
33215
|
+
_context8.n = 2;
|
|
33216
|
+
return httpRequest(apiUrl, {}, "GET");
|
|
33217
|
+
case 2:
|
|
33218
|
+
response = _context8.v;
|
|
33219
|
+
return _context8.a(2, {
|
|
33220
|
+
totalRecords: response.numofrecords,
|
|
33221
|
+
records: response.records,
|
|
33222
|
+
success: true
|
|
33223
|
+
});
|
|
33224
|
+
case 3:
|
|
33225
|
+
_context8.p = 3;
|
|
33226
|
+
_t4 = _context8.v;
|
|
33227
|
+
if (!(_t4.name === "ApacuanaAPIError")) {
|
|
33228
|
+
_context8.n = 4;
|
|
33229
|
+
break;
|
|
33230
|
+
}
|
|
33231
|
+
throw _t4;
|
|
33232
|
+
case 4:
|
|
33233
|
+
throw new ApacuanaAPIError("Failed to get document list (on-boarding): ".concat(_t4.message));
|
|
33234
|
+
case 5:
|
|
33235
|
+
return _context8.a(2);
|
|
33236
|
+
}
|
|
33237
|
+
}, _callee8, null, [[1, 3]]);
|
|
33238
|
+
}));
|
|
33239
|
+
return function getDocsOnBoarding(_x4) {
|
|
32941
33240
|
return _ref8.apply(this, arguments);
|
|
32942
33241
|
};
|
|
32943
33242
|
}();
|
|
32944
33243
|
|
|
33244
|
+
// =================================================================
|
|
33245
|
+
// Exported Functions
|
|
33246
|
+
// =================================================================
|
|
33247
|
+
|
|
32945
33248
|
/**
|
|
32946
|
-
*
|
|
32947
|
-
*
|
|
32948
|
-
* @
|
|
32949
|
-
* @
|
|
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.
|
|
32950
33254
|
*/
|
|
32951
|
-
var
|
|
32952
|
-
var _ref9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(
|
|
32953
|
-
var
|
|
33255
|
+
var signDocument = /*#__PURE__*/function () {
|
|
33256
|
+
var _ref9 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(signData) {
|
|
33257
|
+
var _getConfig2, integrationType;
|
|
32954
33258
|
return _regenerator().w(function (_context9) {
|
|
32955
33259
|
while (1) switch (_context9.n) {
|
|
32956
33260
|
case 0:
|
|
32957
|
-
|
|
33261
|
+
_getConfig2 = getConfig(), integrationType = _getConfig2.integrationType;
|
|
33262
|
+
if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
|
|
32958
33263
|
_context9.n = 1;
|
|
32959
33264
|
break;
|
|
32960
33265
|
}
|
|
32961
|
-
|
|
33266
|
+
return _context9.a(2, signDocumentOnBoarding(signData));
|
|
32962
33267
|
case 1:
|
|
32963
|
-
|
|
32964
|
-
if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
|
|
33268
|
+
if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
|
|
32965
33269
|
_context9.n = 2;
|
|
32966
33270
|
break;
|
|
32967
33271
|
}
|
|
32968
|
-
return _context9.a(2,
|
|
33272
|
+
return _context9.a(2, signDocumentOnPremise());
|
|
32969
33273
|
case 2:
|
|
32970
|
-
if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
|
|
32971
|
-
_context9.n = 3;
|
|
32972
|
-
break;
|
|
32973
|
-
}
|
|
32974
|
-
return _context9.a(2, addSignerOnPremise(signerData));
|
|
32975
|
-
case 3:
|
|
32976
33274
|
throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
|
|
32977
|
-
case
|
|
33275
|
+
case 3:
|
|
32978
33276
|
return _context9.a(2);
|
|
32979
33277
|
}
|
|
32980
33278
|
}, _callee9);
|
|
32981
33279
|
}));
|
|
32982
|
-
return function
|
|
33280
|
+
return function signDocument(_x5) {
|
|
32983
33281
|
return _ref9.apply(this, arguments);
|
|
32984
33282
|
};
|
|
32985
33283
|
}();
|
|
32986
|
-
|
|
32987
|
-
|
|
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;
|
|
32988
33294
|
return _regenerator().w(function (_context0) {
|
|
32989
33295
|
while (1) switch (_context0.n) {
|
|
32990
33296
|
case 0:
|
|
32991
|
-
|
|
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));
|
|
32992
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:
|
|
32993
33313
|
return _context0.a(2);
|
|
32994
33314
|
}
|
|
32995
33315
|
}, _callee0);
|
|
32996
33316
|
}));
|
|
32997
|
-
return function
|
|
33317
|
+
return function getDigest(_x6) {
|
|
32998
33318
|
return _ref0.apply(this, arguments);
|
|
32999
33319
|
};
|
|
33000
33320
|
}();
|
|
33001
|
-
|
|
33002
|
-
|
|
33003
|
-
|
|
33321
|
+
|
|
33322
|
+
/**
|
|
33323
|
+
* Añade un firmante a un documento.
|
|
33324
|
+
* @param {SignerData} signerData - Los datos del firmante que se va a añadir.
|
|
33325
|
+
* @returns {Promise<AddSignerResponse>} Una promesa que resuelve a un objeto con el resultado de la operación.
|
|
33326
|
+
* @throws {ApacuanaAPIError} Si los datos del firmante son inválidos, la llamada a la API falla, o el tipo de integración no es soportado.
|
|
33327
|
+
*/
|
|
33328
|
+
var addSigner = /*#__PURE__*/function () {
|
|
33329
|
+
var _ref1 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(signerData) {
|
|
33330
|
+
var _getConfig4, integrationType;
|
|
33004
33331
|
return _regenerator().w(function (_context1) {
|
|
33005
|
-
while (1) switch (_context1.
|
|
33332
|
+
while (1) switch (_context1.n) {
|
|
33006
33333
|
case 0:
|
|
33007
|
-
|
|
33008
|
-
if (customerId) {
|
|
33334
|
+
if (!(!signerData || _typeof(signerData) !== "object" || Object.keys(signerData).length === 0)) {
|
|
33009
33335
|
_context1.n = 1;
|
|
33010
33336
|
break;
|
|
33011
33337
|
}
|
|
33012
|
-
throw new ApacuanaAPIError("
|
|
33338
|
+
throw new ApacuanaAPIError("Signer data (signerData) is required and must be a non-empty object.", 400, "INVALID_PARAMETER");
|
|
33013
33339
|
case 1:
|
|
33014
|
-
|
|
33015
|
-
|
|
33016
|
-
|
|
33017
|
-
|
|
33018
|
-
size: data.size
|
|
33019
|
-
});
|
|
33020
|
-
if (typeof data.status !== "undefined") {
|
|
33021
|
-
params.append("status", data.status);
|
|
33340
|
+
_getConfig4 = getConfig(), integrationType = _getConfig4.integrationType;
|
|
33341
|
+
if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
|
|
33342
|
+
_context1.n = 2;
|
|
33343
|
+
break;
|
|
33022
33344
|
}
|
|
33023
|
-
|
|
33024
|
-
_context1.n = 2;
|
|
33025
|
-
return httpRequest(apiUrl, {}, "GET");
|
|
33345
|
+
return _context1.a(2, addSignerOnBoarding(signerData));
|
|
33026
33346
|
case 2:
|
|
33027
|
-
|
|
33028
|
-
|
|
33029
|
-
totalRecords: response.numofrecords,
|
|
33030
|
-
records: response.records,
|
|
33031
|
-
success: true
|
|
33032
|
-
});
|
|
33033
|
-
case 3:
|
|
33034
|
-
_context1.p = 3;
|
|
33035
|
-
_t3 = _context1.v;
|
|
33036
|
-
if (!(_t3.name === "ApacuanaAPIError")) {
|
|
33037
|
-
_context1.n = 4;
|
|
33347
|
+
if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
|
|
33348
|
+
_context1.n = 3;
|
|
33038
33349
|
break;
|
|
33039
33350
|
}
|
|
33040
|
-
|
|
33351
|
+
return _context1.a(2, addSignerOnPremise());
|
|
33352
|
+
case 3:
|
|
33353
|
+
throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
|
|
33041
33354
|
case 4:
|
|
33042
|
-
throw new ApacuanaAPIError("Failed to get document list (on-premise): ".concat(_t3.message));
|
|
33043
|
-
case 5:
|
|
33044
33355
|
return _context1.a(2);
|
|
33045
33356
|
}
|
|
33046
|
-
}, _callee1
|
|
33357
|
+
}, _callee1);
|
|
33047
33358
|
}));
|
|
33048
|
-
return function
|
|
33359
|
+
return function addSigner(_x7) {
|
|
33049
33360
|
return _ref1.apply(this, arguments);
|
|
33050
33361
|
};
|
|
33051
33362
|
}();
|
|
33052
33363
|
|
|
33053
33364
|
/**
|
|
33054
|
-
*
|
|
33055
|
-
* @param {
|
|
33056
|
-
* @returns {Promise<
|
|
33057
|
-
* @throws {ApacuanaAPIError}
|
|
33365
|
+
* Obtiene una lista de documentos basada en los filtros especificados.
|
|
33366
|
+
* @param {GetDocsParams} data - Objeto con parámetros de paginación y filtros.
|
|
33367
|
+
* @returns {Promise<GetDocsResponse>} Una promesa que resuelve a un objeto con la lista de documentos.
|
|
33368
|
+
* @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.
|
|
33058
33369
|
*/
|
|
33059
33370
|
var getDocs = /*#__PURE__*/function () {
|
|
33060
33371
|
var _ref10 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(data) {
|
|
@@ -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;
|