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