apacuana-sdk-core 0.3.0 → 0.4.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/coverage/clover.xml +12 -12
- package/coverage/coverage-final.json +2 -2
- package/coverage/lcov-report/block-navigation.js +1 -1
- package/coverage/lcov-report/index.html +1 -1
- package/coverage/lcov-report/sorter.js +21 -7
- package/coverage/lcov-report/src/api/certs.js.html +2 -2
- package/coverage/lcov-report/src/api/index.html +1 -1
- package/coverage/lcov-report/src/api/revocations.js.html +12 -15
- package/coverage/lcov-report/src/api/signatures.js.html +1 -1
- package/coverage/lcov-report/src/api/users.js.html +1 -1
- package/coverage/lcov-report/src/config/index.html +1 -1
- package/coverage/lcov-report/src/config/index.js.html +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 +6 -3
- package/coverage/lcov-report/src/utils/constant.js.html +1 -1
- package/coverage/lcov-report/src/utils/helpers.js.html +1 -1
- package/coverage/lcov-report/src/utils/httpClient.js.html +1 -1
- package/coverage/lcov-report/src/utils/index.html +1 -1
- package/coverage/lcov.info +16 -16
- package/dist/api/certs.d.ts +8 -0
- package/dist/api/revocations.d.ts +7 -0
- package/dist/api/signatures.d.ts +16 -0
- package/dist/api/users.d.ts +15 -0
- package/dist/config/index.d.ts +11 -0
- package/dist/errors/index.d.ts +10 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +116 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +116 -9
- package/dist/index.mjs.map +1 -1
- package/dist/utils/constant.d.ts +18 -0
- package/dist/utils/helpers.d.ts +21 -0
- package/dist/utils/httpClient.d.ts +3 -0
- package/package.json +9 -4
- package/src/api/certs.js +1 -1
- package/src/api/revocations.js +10 -11
- package/src/index.js +2 -1
- package/tsconfig.json +15 -0
package/dist/index.mjs
CHANGED
|
@@ -588,32 +588,32 @@ var requestRevocation = /*#__PURE__*/function () {
|
|
|
588
588
|
return _regenerator().w(function (_context) {
|
|
589
589
|
while (1) switch (_context.p = _context.n) {
|
|
590
590
|
case 0:
|
|
591
|
-
console.log(
|
|
592
|
-
console.log(
|
|
591
|
+
console.log("-> Función 'requestRevocation' ejecutada.");
|
|
592
|
+
console.log("Parámetros recibidos para solicitud de revocación:", {
|
|
593
593
|
reasonCode: reasonCode
|
|
594
594
|
});
|
|
595
595
|
if (reasonCode) {
|
|
596
596
|
_context.n = 1;
|
|
597
597
|
break;
|
|
598
598
|
}
|
|
599
|
-
throw new Error(
|
|
599
|
+
throw new Error("ID de certificado y motivo son requeridos para requestRevocation.");
|
|
600
600
|
case 1:
|
|
601
601
|
_context.p = 1;
|
|
602
602
|
_context.n = 2;
|
|
603
|
-
return httpRequest(
|
|
603
|
+
return httpRequest("users/api/customers/requestcert", {
|
|
604
604
|
reason: reasonCode
|
|
605
|
-
},
|
|
605
|
+
}, "POST");
|
|
606
606
|
case 2:
|
|
607
607
|
response = _context.v;
|
|
608
|
-
console.log(
|
|
608
|
+
console.log("Respuesta del servidor", response);
|
|
609
609
|
if (response.success) {
|
|
610
610
|
_context.n = 3;
|
|
611
611
|
break;
|
|
612
612
|
}
|
|
613
|
-
throw new ApacuanaAPIError(response.message ||
|
|
613
|
+
throw new ApacuanaAPIError(response.message || "Error desconocido al solicitar revocación.");
|
|
614
614
|
case 3:
|
|
615
615
|
return _context.a(2, {
|
|
616
|
-
revocationStatus: response.status ||
|
|
616
|
+
revocationStatus: response.status || "pending",
|
|
617
617
|
requestId: response.id
|
|
618
618
|
});
|
|
619
619
|
case 4:
|
|
@@ -32769,6 +32769,112 @@ var helpers = {
|
|
|
32769
32769
|
validateGetDigestData: validateGetDigestData
|
|
32770
32770
|
};
|
|
32771
32771
|
|
|
32772
|
+
var generateCertOnBoarding = /*#__PURE__*/function () {
|
|
32773
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
32774
|
+
var csr,
|
|
32775
|
+
encryptedCSR,
|
|
32776
|
+
response,
|
|
32777
|
+
cert,
|
|
32778
|
+
_args = arguments,
|
|
32779
|
+
_t;
|
|
32780
|
+
return _regenerator().w(function (_context) {
|
|
32781
|
+
while (1) switch (_context.p = _context.n) {
|
|
32782
|
+
case 0:
|
|
32783
|
+
csr = _args.length > 0 && _args[0] !== undefined ? _args[0] : undefined;
|
|
32784
|
+
_context.p = 1;
|
|
32785
|
+
encryptedCSR = helpers.encryptedCsr(csr);
|
|
32786
|
+
_context.n = 2;
|
|
32787
|
+
return httpRequest("services/api/register/certificate", encryptedCSR, "POST");
|
|
32788
|
+
case 2:
|
|
32789
|
+
response = _context.v;
|
|
32790
|
+
cert = response.cert;
|
|
32791
|
+
if (cert) {
|
|
32792
|
+
_context.n = 3;
|
|
32793
|
+
break;
|
|
32794
|
+
}
|
|
32795
|
+
throw new ApacuanaAPIError("The API response does not contain the certificate.", response.status, "INVALID_API_RESPONSE");
|
|
32796
|
+
case 3:
|
|
32797
|
+
return _context.a(2, {
|
|
32798
|
+
cert: cert,
|
|
32799
|
+
success: true
|
|
32800
|
+
});
|
|
32801
|
+
case 4:
|
|
32802
|
+
_context.p = 4;
|
|
32803
|
+
_t = _context.v;
|
|
32804
|
+
if (!(_t instanceof ApacuanaAPIError)) {
|
|
32805
|
+
_context.n = 5;
|
|
32806
|
+
break;
|
|
32807
|
+
}
|
|
32808
|
+
throw _t;
|
|
32809
|
+
case 5:
|
|
32810
|
+
throw new Error("Certificate generation failed: ".concat(_t.message));
|
|
32811
|
+
case 6:
|
|
32812
|
+
return _context.a(2);
|
|
32813
|
+
}
|
|
32814
|
+
}, _callee, null, [[1, 4]]);
|
|
32815
|
+
}));
|
|
32816
|
+
return function generateCertOnBoarding() {
|
|
32817
|
+
return _ref.apply(this, arguments);
|
|
32818
|
+
};
|
|
32819
|
+
}();
|
|
32820
|
+
var generateCertOnPremise = /*#__PURE__*/function () {
|
|
32821
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
32822
|
+
return _regenerator().w(function (_context2) {
|
|
32823
|
+
while (1) switch (_context2.n) {
|
|
32824
|
+
case 0:
|
|
32825
|
+
throw new ApacuanaAPIError("Certificate generation is not supported for integration type: ONPREMISE", 501, "NOT_IMPLEMENTED");
|
|
32826
|
+
case 1:
|
|
32827
|
+
return _context2.a(2);
|
|
32828
|
+
}
|
|
32829
|
+
}, _callee2);
|
|
32830
|
+
}));
|
|
32831
|
+
return function generateCertOnPremise() {
|
|
32832
|
+
return _ref2.apply(this, arguments);
|
|
32833
|
+
};
|
|
32834
|
+
}();
|
|
32835
|
+
|
|
32836
|
+
/**
|
|
32837
|
+
* Generates a digital certificate.
|
|
32838
|
+
* @param {string} [csr] - Certificate Signing Request (CSR).
|
|
32839
|
+
* @returns {Promise<{cert: string, success: boolean}>} Object with the generated certificate and a success indicator.
|
|
32840
|
+
* @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
|
+
* @throws {Error} If certificate generation fails for another reason.
|
|
32842
|
+
*/
|
|
32843
|
+
var generateCert = /*#__PURE__*/function () {
|
|
32844
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
|
|
32845
|
+
var csr,
|
|
32846
|
+
_getConfig,
|
|
32847
|
+
integrationType,
|
|
32848
|
+
_args3 = arguments;
|
|
32849
|
+
return _regenerator().w(function (_context3) {
|
|
32850
|
+
while (1) switch (_context3.n) {
|
|
32851
|
+
case 0:
|
|
32852
|
+
csr = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : undefined;
|
|
32853
|
+
_getConfig = getConfig(), integrationType = _getConfig.integrationType;
|
|
32854
|
+
helpers.validateCsr(csr);
|
|
32855
|
+
if (!(integrationType === INTEGRATION_TYPE.ONBOARDING)) {
|
|
32856
|
+
_context3.n = 1;
|
|
32857
|
+
break;
|
|
32858
|
+
}
|
|
32859
|
+
return _context3.a(2, generateCertOnBoarding(csr));
|
|
32860
|
+
case 1:
|
|
32861
|
+
if (!(integrationType === INTEGRATION_TYPE.ONPREMISE)) {
|
|
32862
|
+
_context3.n = 2;
|
|
32863
|
+
break;
|
|
32864
|
+
}
|
|
32865
|
+
return _context3.a(2, generateCertOnPremise());
|
|
32866
|
+
case 2:
|
|
32867
|
+
throw new ApacuanaAPIError("Unsupported integration type: ".concat(integrationType), 400, "UNSUPPORTED_INTEGRATION_TYPE");
|
|
32868
|
+
case 3:
|
|
32869
|
+
return _context3.a(2);
|
|
32870
|
+
}
|
|
32871
|
+
}, _callee3);
|
|
32872
|
+
}));
|
|
32873
|
+
return function generateCert() {
|
|
32874
|
+
return _ref3.apply(this, arguments);
|
|
32875
|
+
};
|
|
32876
|
+
}();
|
|
32877
|
+
|
|
32772
32878
|
/**
|
|
32773
32879
|
* Gets the user's certificate status.
|
|
32774
32880
|
* @param {boolean} [isCertificateInDevice=false] - Indicates if the certificate is already on the device.
|
|
@@ -33052,7 +33158,8 @@ var apacuana = {
|
|
|
33052
33158
|
getCertStatus: getCertStatus,
|
|
33053
33159
|
getCustomer: getCustomer,
|
|
33054
33160
|
addSigner: addSigner,
|
|
33055
|
-
getDocs: getDocs
|
|
33161
|
+
getDocs: getDocs,
|
|
33162
|
+
generateCert: generateCert
|
|
33056
33163
|
};
|
|
33057
33164
|
|
|
33058
33165
|
export { apacuana as default };
|