apacuana-sdk-core 0.13.0 → 0.14.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 +263 -206
- package/coverage/coverage-final.json +6 -6
- package/coverage/lcov-report/index.html +36 -36
- package/coverage/lcov-report/src/api/certs.js.html +14 -8
- package/coverage/lcov-report/src/api/faceLiveness.js.html +1 -1
- package/coverage/lcov-report/src/api/index.html +25 -25
- package/coverage/lcov-report/src/api/revocations.js.html +2 -2
- package/coverage/lcov-report/src/api/signatures.js.html +1 -1
- package/coverage/lcov-report/src/api/users.js.html +160 -13
- 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 +21 -21
- package/coverage/lcov-report/src/index.js.html +278 -59
- package/coverage/lcov-report/src/success/index.html +1 -1
- package/coverage/lcov-report/src/success/index.js.html +1 -1
- package/coverage/lcov-report/src/utils/constant.js.html +115 -4
- package/coverage/lcov-report/src/utils/helpers.js.html +16 -13
- package/coverage/lcov-report/src/utils/httpClient.js.html +4 -7
- package/coverage/lcov-report/src/utils/index.html +12 -12
- package/coverage/lcov.info +504 -387
- package/dist/api/users.d.ts +27 -21
- package/dist/index.d.ts +19 -40
- package/dist/index.js +265 -118
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +265 -118
- package/dist/index.mjs.map +1 -1
- package/dist/types/certs.d.ts +20 -34
- package/dist/utils/constant.d.ts +31 -0
- package/dist/utils/helpers.d.ts +1 -1
- package/package.json +1 -1
- package/src/api/certs.js +4 -2
- package/src/api/revocations.js +1 -1
- package/src/api/users.js +51 -2
- package/src/index.js +114 -41
- package/src/types/certs.js +36 -25
- package/src/utils/constant.js +37 -0
- package/src/utils/helpers.js +5 -4
- package/src/utils/httpClient.js +1 -2
- package/tests/api/certs.test.js +11 -3
- package/tests/api/revocations.test.js +1 -1
- package/tests/api/users.test.js +1 -1
- package/tests/index.test.js +3 -2
package/dist/index.mjs
CHANGED
|
@@ -277,8 +277,31 @@ var STATUS_CERTIFICATE = {
|
|
|
277
277
|
generate: "GENERAR",
|
|
278
278
|
current: "VIGENTE",
|
|
279
279
|
revoque: "REVOCADO",
|
|
280
|
+
expire: "EXPIRADO",
|
|
280
281
|
request_revoque: "SOLICITUD_DE_REVOCACION",
|
|
281
282
|
certificate_another_device: "CERTIFICADO_EN_OTRO_DISPOSITIVO"};
|
|
283
|
+
var PARSE_STATUS = _defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, STATUS_CERTIFICATE.certificate_another_device, {
|
|
284
|
+
text: "Verificado",
|
|
285
|
+
descriptionText: undefined
|
|
286
|
+
}), STATUS_CERTIFICATE.request_cert, {
|
|
287
|
+
text: "En revisión",
|
|
288
|
+
descriptionText: "La información y documentos enviados están siendo certificados por la Autoridad de Certificación para confirmar su validez."
|
|
289
|
+
}), STATUS_CERTIFICATE.request, {
|
|
290
|
+
text: "Por verificar",
|
|
291
|
+
descriptionText: "La información y documentos enviados están siendo revisados por la Autoridad de Registro."
|
|
292
|
+
}), STATUS_CERTIFICATE.generate, {
|
|
293
|
+
text: "Por generar",
|
|
294
|
+
descriptionText: "Tu solicitud fue aprobada. Solo falta que generes tu certificado para comenzar a usarlo."
|
|
295
|
+
}), STATUS_CERTIFICATE.current, {
|
|
296
|
+
text: " ",
|
|
297
|
+
descriptionText: undefined
|
|
298
|
+
}), STATUS_CERTIFICATE.expire, "Certificado expirado."), STATUS_CERTIFICATE.request_revoque, {
|
|
299
|
+
text: "Por revocar",
|
|
300
|
+
descriptionText: "Recibimos tu solicitud de revocación y estamos procesándola. El certificado dejará de ser válido una vez finalice el trámite."
|
|
301
|
+
}), STATUS_CERTIFICATE.revoque, {
|
|
302
|
+
text: "Revocado",
|
|
303
|
+
descriptionText: "Este certificado ha sido revocado. Debes solicitar uno nuevo."
|
|
304
|
+
});
|
|
282
305
|
var VERIFICATION_STATUS = {
|
|
283
306
|
APPROVED: 1
|
|
284
307
|
};
|
|
@@ -371,7 +394,7 @@ var axiosInstance;
|
|
|
371
394
|
*/
|
|
372
395
|
var initHttpClient = function initHttpClient() {
|
|
373
396
|
var config = getConfig();
|
|
374
|
-
if (!config.apiUrl || !config.secretKey || !config.apiKey || !config.verificationId
|
|
397
|
+
if (!config.apiUrl || !config.secretKey || !config.apiKey || !config.verificationId) {
|
|
375
398
|
throw new Error("HttpClient: Configuración de inicialización incompleta. Llama a apacuana.init() primero.");
|
|
376
399
|
}
|
|
377
400
|
axiosInstance = axios.create({
|
|
@@ -542,79 +565,6 @@ var ApacuanaSuccess = /*#__PURE__*/_createClass(function ApacuanaSuccess(data) {
|
|
|
542
565
|
this.data = data;
|
|
543
566
|
});
|
|
544
567
|
|
|
545
|
-
/**
|
|
546
|
-
* @typedef {object} GetCustomerData
|
|
547
|
-
* @property {string} token - El token de sesión del usuario.
|
|
548
|
-
* @property {object} userData - Los datos del usuario obtenidos.
|
|
549
|
-
*/
|
|
550
|
-
|
|
551
|
-
/**
|
|
552
|
-
* @typedef {object} GetCustomerResponse
|
|
553
|
-
* @property {true} success - Indica que la operación fue exitosa.
|
|
554
|
-
* @property {GetCustomerData} data - El payload de la respuesta.
|
|
555
|
-
*/
|
|
556
|
-
|
|
557
|
-
/**
|
|
558
|
-
* Obtiene el token de un usuario a través de una petición POST.
|
|
559
|
-
* Este método es útil para endpoints que requieren datos en el cuerpo de la petición
|
|
560
|
-
* para buscar un usuario, como un ID de sesión o un token de acceso.
|
|
561
|
-
*
|
|
562
|
-
* @returns {Promise<GetCustomerResponse>} Una promesa que resuelve a un objeto con la respuesta exitosa.
|
|
563
|
-
* @throws {Error} Si los parámetros de entrada son inválidos.
|
|
564
|
-
* @throws {ApacuanaAPIError} Si ocurre un error en la API de Apacuana.
|
|
565
|
-
*/
|
|
566
|
-
var getCustomer = /*#__PURE__*/function () {
|
|
567
|
-
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
568
|
-
var _getConfig, verificationId, customerId, body, response, _t;
|
|
569
|
-
return _regenerator().w(function (_context) {
|
|
570
|
-
while (1) switch (_context.p = _context.n) {
|
|
571
|
-
case 0:
|
|
572
|
-
_getConfig = getConfig(), verificationId = _getConfig.verificationId, customerId = _getConfig.customerId;
|
|
573
|
-
if (!(!verificationId || !customerId)) {
|
|
574
|
-
_context.n = 1;
|
|
575
|
-
break;
|
|
576
|
-
}
|
|
577
|
-
throw new ApacuanaAPIError("Both 'verificationId' and 'customerId' must be configured.", 400, "CONFIGURATION_ERROR");
|
|
578
|
-
case 1:
|
|
579
|
-
body = {
|
|
580
|
-
verificationid: verificationId,
|
|
581
|
-
customerid: customerId
|
|
582
|
-
};
|
|
583
|
-
_context.p = 2;
|
|
584
|
-
_context.n = 3;
|
|
585
|
-
return httpRequest("services/api/register/init", body, "POST");
|
|
586
|
-
case 3:
|
|
587
|
-
response = _context.v;
|
|
588
|
-
if (!(!response.sessionid || !response.entry)) {
|
|
589
|
-
_context.n = 4;
|
|
590
|
-
break;
|
|
591
|
-
}
|
|
592
|
-
throw new ApacuanaAPIError("The API response does not contain the user.", 200, "INVALID_API_RESPONSE");
|
|
593
|
-
case 4:
|
|
594
|
-
return _context.a(2, new ApacuanaSuccess({
|
|
595
|
-
token: response.sessionid,
|
|
596
|
-
userData: response.entry
|
|
597
|
-
}));
|
|
598
|
-
case 5:
|
|
599
|
-
_context.p = 5;
|
|
600
|
-
_t = _context.v;
|
|
601
|
-
if (!(_t instanceof ApacuanaAPIError)) {
|
|
602
|
-
_context.n = 6;
|
|
603
|
-
break;
|
|
604
|
-
}
|
|
605
|
-
throw _t;
|
|
606
|
-
case 6:
|
|
607
|
-
throw new ApacuanaAPIError("Unexpected failure getting token: ".concat(_t.message || "Unknown error"));
|
|
608
|
-
case 7:
|
|
609
|
-
return _context.a(2);
|
|
610
|
-
}
|
|
611
|
-
}, _callee, null, [[2, 5]]);
|
|
612
|
-
}));
|
|
613
|
-
return function getCustomer() {
|
|
614
|
-
return _ref.apply(this, arguments);
|
|
615
|
-
};
|
|
616
|
-
}();
|
|
617
|
-
|
|
618
568
|
/** @typedef {import("../types/revocations").RequestRevocationResponse} RequestRevocationResponse */
|
|
619
569
|
/** @typedef {import("../types/revocations").GetRevocationReasonsResponse} GetRevocationReasonsResponse */
|
|
620
570
|
|
|
@@ -626,7 +576,9 @@ var requestRevocationOnBoarding = /*#__PURE__*/function () {
|
|
|
626
576
|
case 0:
|
|
627
577
|
_context.p = 0;
|
|
628
578
|
_context.n = 1;
|
|
629
|
-
return httpRequest("services/api/onboardingclient/requestcert",
|
|
579
|
+
return httpRequest("services/api/onboardingclient/requestcert", {
|
|
580
|
+
reason: params.reasonCode
|
|
581
|
+
}, "POST");
|
|
630
582
|
case 1:
|
|
631
583
|
response = _context.v;
|
|
632
584
|
return _context.a(2, new ApacuanaSuccess(response));
|
|
@@ -32897,7 +32849,7 @@ initCryptoEngine();
|
|
|
32897
32849
|
|
|
32898
32850
|
var KEY_HEX = "dRgUkXp2s5v8y/B?";
|
|
32899
32851
|
var getCertificateStatus = function getCertificateStatus(userData, certificateInDevice) {
|
|
32900
|
-
var _userData$verificatio, _userData$requestscer, _userData$requestscer2;
|
|
32852
|
+
var _userData$verificatio, _userData$requestscer, _userData$requestscer2, _userData$requestscer3;
|
|
32901
32853
|
if (!userData) {
|
|
32902
32854
|
throw new Error("El parámetro userData es requerido.");
|
|
32903
32855
|
}
|
|
@@ -32905,10 +32857,10 @@ var getCertificateStatus = function getCertificateStatus(userData, certificateIn
|
|
|
32905
32857
|
throw new Error("El parámetro certificateInDevice es requerido y debe ser un valor booleano.");
|
|
32906
32858
|
}
|
|
32907
32859
|
if ((userData === null || userData === void 0 || (_userData$verificatio = userData.verificationstatus) === null || _userData$verificatio === void 0 ? void 0 : _userData$verificatio.id) !== VERIFICATION_STATUS.APPROVED) return STATUS_CERTIFICATE.request;
|
|
32908
|
-
if (
|
|
32909
|
-
if (userData !== null && userData !== void 0 && (_userData$requestscer2 = userData.requestscert) !== null && _userData$requestscer2 !== void 0 && _userData$requestscer2.pending && userData
|
|
32860
|
+
if (!(userData !== null && userData !== void 0 && userData.certificationId) && (userData === null || userData === void 0 || (_userData$requestscer = userData.requestscert) === null || _userData$requestscer === void 0 ? void 0 : _userData$requestscer.requests.length) === 0) return STATUS_CERTIFICATE.request_cert;
|
|
32861
|
+
if (userData !== null && userData !== void 0 && userData.certificationId && !(userData !== null && userData !== void 0 && userData.cangenerate) && !(userData !== null && userData !== void 0 && (_userData$requestscer2 = userData.requestscert) !== null && _userData$requestscer2 !== void 0 && _userData$requestscer2.pending) && !certificateInDevice && (userData === null || userData === void 0 ? void 0 : userData.certificatestatus) !== STATUS_CERTIFICATE.revoque) return STATUS_CERTIFICATE.certificate_another_device;
|
|
32862
|
+
if (userData !== null && userData !== void 0 && (_userData$requestscer3 = userData.requestscert) !== null && _userData$requestscer3 !== void 0 && _userData$requestscer3.pending && userData !== null && userData !== void 0 && userData.certificationId) return STATUS_CERTIFICATE.request_revoque;
|
|
32910
32863
|
if (!(userData !== null && userData !== void 0 && userData.cangenerate) && (userData === null || userData === void 0 ? void 0 : userData.certificatestatus) === STATUS_CERTIFICATE.revoque) return STATUS_CERTIFICATE.revoque;
|
|
32911
|
-
if (!(userData !== null && userData !== void 0 && userData.approvedUser)) return STATUS_CERTIFICATE.request;
|
|
32912
32864
|
if (userData !== null && userData !== void 0 && userData.cangenerate) return STATUS_CERTIFICATE.generate;
|
|
32913
32865
|
if (userData !== null && userData !== void 0 && userData.certificationId) return STATUS_CERTIFICATE.current;
|
|
32914
32866
|
return STATUS_CERTIFICATE.revoque;
|
|
@@ -33198,8 +33150,9 @@ var getCertStatus = function getCertStatus() {
|
|
|
33198
33150
|
var isCertificateInDevice = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
33199
33151
|
var config = getConfig();
|
|
33200
33152
|
var status = helpers.getCertificateStatus(config.userData, isCertificateInDevice);
|
|
33153
|
+
var parseStatus = PARSE_STATUS[status];
|
|
33201
33154
|
return new ApacuanaSuccess({
|
|
33202
|
-
status:
|
|
33155
|
+
status: parseStatus
|
|
33203
33156
|
});
|
|
33204
33157
|
};
|
|
33205
33158
|
var getCertTypesOnBoarding = /*#__PURE__*/function () {
|
|
@@ -34243,18 +34196,158 @@ var validateFaceLiveness = /*#__PURE__*/function () {
|
|
|
34243
34196
|
};
|
|
34244
34197
|
}();
|
|
34245
34198
|
|
|
34199
|
+
/**
|
|
34200
|
+
* @typedef {object} GetCustomerData
|
|
34201
|
+
* @property {string} token - El token de sesión del usuario.
|
|
34202
|
+
* @property {object} userData - Los datos del usuario obtenidos.
|
|
34203
|
+
*/
|
|
34204
|
+
|
|
34205
|
+
/**
|
|
34206
|
+
* @typedef {object} GetCustomerResponse
|
|
34207
|
+
* @property {true} success - Indica que la operación fue exitosa.
|
|
34208
|
+
* @property {GetCustomerData} data - El payload de la respuesta.
|
|
34209
|
+
*/
|
|
34210
|
+
|
|
34211
|
+
/**
|
|
34212
|
+
* Obtiene el token de un usuario a través de una petición POST.
|
|
34213
|
+
* Este método es útil para endpoints que requieren datos en el cuerpo de la petición
|
|
34214
|
+
* para buscar un usuario, como un ID de sesión o un token de acceso.
|
|
34215
|
+
*
|
|
34216
|
+
* @returns {Promise<GetCustomerResponse>} Una promesa que resuelve a un objeto con la respuesta exitosa.
|
|
34217
|
+
* @throws {Error} Si los parámetros de entrada son inválidos.
|
|
34218
|
+
* @throws {ApacuanaAPIError} Si ocurre un error en la API de Apacuana.
|
|
34219
|
+
*/
|
|
34220
|
+
var getCustomer = /*#__PURE__*/function () {
|
|
34221
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
34222
|
+
var _getConfig, verificationId, customerId, body, response, _t;
|
|
34223
|
+
return _regenerator().w(function (_context) {
|
|
34224
|
+
while (1) switch (_context.p = _context.n) {
|
|
34225
|
+
case 0:
|
|
34226
|
+
_getConfig = getConfig(), verificationId = _getConfig.verificationId, customerId = _getConfig.customerId;
|
|
34227
|
+
if (!(!verificationId || !customerId)) {
|
|
34228
|
+
_context.n = 1;
|
|
34229
|
+
break;
|
|
34230
|
+
}
|
|
34231
|
+
throw new ApacuanaAPIError("Both 'verificationId' and 'customerId' must be configured.", 400, "CONFIGURATION_ERROR");
|
|
34232
|
+
case 1:
|
|
34233
|
+
body = {
|
|
34234
|
+
verificationid: verificationId,
|
|
34235
|
+
customerid: customerId
|
|
34236
|
+
};
|
|
34237
|
+
_context.p = 2;
|
|
34238
|
+
_context.n = 3;
|
|
34239
|
+
return httpRequest("services/api/register/init", body, "POST");
|
|
34240
|
+
case 3:
|
|
34241
|
+
response = _context.v;
|
|
34242
|
+
if (!(!response.sessionid || !response.entry)) {
|
|
34243
|
+
_context.n = 4;
|
|
34244
|
+
break;
|
|
34245
|
+
}
|
|
34246
|
+
throw new ApacuanaAPIError("The API response does not contain the user.", 200, "INVALID_API_RESPONSE");
|
|
34247
|
+
case 4:
|
|
34248
|
+
return _context.a(2, new ApacuanaSuccess({
|
|
34249
|
+
token: response.sessionid,
|
|
34250
|
+
userData: response.entry
|
|
34251
|
+
}));
|
|
34252
|
+
case 5:
|
|
34253
|
+
_context.p = 5;
|
|
34254
|
+
_t = _context.v;
|
|
34255
|
+
if (!(_t instanceof ApacuanaAPIError)) {
|
|
34256
|
+
_context.n = 6;
|
|
34257
|
+
break;
|
|
34258
|
+
}
|
|
34259
|
+
throw _t;
|
|
34260
|
+
case 6:
|
|
34261
|
+
throw new ApacuanaAPIError("Unexpected failure getting token: ".concat(_t.message || "Unknown error"));
|
|
34262
|
+
case 7:
|
|
34263
|
+
return _context.a(2);
|
|
34264
|
+
}
|
|
34265
|
+
}, _callee, null, [[2, 5]]);
|
|
34266
|
+
}));
|
|
34267
|
+
return function getCustomer() {
|
|
34268
|
+
return _ref.apply(this, arguments);
|
|
34269
|
+
};
|
|
34270
|
+
}();
|
|
34271
|
+
|
|
34272
|
+
/**
|
|
34273
|
+
* @typedef {object} CreateUserPayload
|
|
34274
|
+
* @property {string} usr - Correo electrónico del usuario.
|
|
34275
|
+
* @property {string} pwd - Contraseña del usuario.
|
|
34276
|
+
* @property {string} kinddoc - Tipo de documento de identidad (ej. 'V', 'P', 'E').
|
|
34277
|
+
* @property {string} doc - Número de documento de identidad.
|
|
34278
|
+
*/
|
|
34279
|
+
|
|
34280
|
+
/**
|
|
34281
|
+
* @typedef {object} CreateUserResponse
|
|
34282
|
+
* @property {string} message - Mensaje de confirmación de la creación del usuario.
|
|
34283
|
+
*/
|
|
34284
|
+
|
|
34285
|
+
/**
|
|
34286
|
+
* Crea un nuevo usuario en la plataforma de Apacuana.
|
|
34287
|
+
* @param {CreateUserPayload} userData - Objeto con los datos del usuario a crear.
|
|
34288
|
+
* @returns {Promise<ApacuanaSuccess>} Una promesa que resuelve a un objeto con la respuesta exitosa.
|
|
34289
|
+
* @throws {ApacuanaAPIError} Si los datos de entrada son inválidos o si ocurre un error en la API.
|
|
34290
|
+
*/
|
|
34291
|
+
|
|
34292
|
+
var createApacuanaUser = /*#__PURE__*/function () {
|
|
34293
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(userData) {
|
|
34294
|
+
var formData, response, _t2;
|
|
34295
|
+
return _regenerator().w(function (_context2) {
|
|
34296
|
+
while (1) switch (_context2.p = _context2.n) {
|
|
34297
|
+
case 0:
|
|
34298
|
+
_context2.p = 0;
|
|
34299
|
+
formData = new FormData();
|
|
34300
|
+
Object.keys(userData).forEach(function (key) {
|
|
34301
|
+
var value = userData[key];
|
|
34302
|
+
if (value instanceof File) {
|
|
34303
|
+
formData.append(key, value);
|
|
34304
|
+
} else if (value !== null && value !== undefined) {
|
|
34305
|
+
formData.append(key, String(value));
|
|
34306
|
+
}
|
|
34307
|
+
});
|
|
34308
|
+
_context2.n = 1;
|
|
34309
|
+
return httpRequest("services/api/register/initial", formData, "POST");
|
|
34310
|
+
case 1:
|
|
34311
|
+
response = _context2.v;
|
|
34312
|
+
return _context2.a(2, new ApacuanaSuccess(_objectSpread2({}, response)));
|
|
34313
|
+
case 2:
|
|
34314
|
+
_context2.p = 2;
|
|
34315
|
+
_t2 = _context2.v;
|
|
34316
|
+
if (!(_t2 instanceof ApacuanaAPIError)) {
|
|
34317
|
+
_context2.n = 3;
|
|
34318
|
+
break;
|
|
34319
|
+
}
|
|
34320
|
+
throw _t2;
|
|
34321
|
+
case 3:
|
|
34322
|
+
throw new ApacuanaAPIError("Unexpected failure creating user: ".concat(_t2.message || "Unknown error"));
|
|
34323
|
+
case 4:
|
|
34324
|
+
return _context2.a(2);
|
|
34325
|
+
}
|
|
34326
|
+
}, _callee2, null, [[0, 2]]);
|
|
34327
|
+
}));
|
|
34328
|
+
return function createApacuanaUser(_x) {
|
|
34329
|
+
return _ref2.apply(this, arguments);
|
|
34330
|
+
};
|
|
34331
|
+
}();
|
|
34332
|
+
|
|
34333
|
+
/**
|
|
34334
|
+
* Valida si el SDK está inicializado y si se dispone de un customerId.
|
|
34335
|
+
* @param {boolean} requiresCustomerId - Indica si la operación necesita un customerId.
|
|
34336
|
+
* @throws {ApacuanaAPIError} Si el SDK no está inicializado o el customerId es requerido y no está presente.
|
|
34337
|
+
*/
|
|
34338
|
+
var checkSdk = function checkSdk() {
|
|
34339
|
+
var requiresCustomerId = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
|
|
34340
|
+
var config = getConfig();
|
|
34341
|
+
if (!config || !config.apiUrl) {
|
|
34342
|
+
throw new ApacuanaAPIError("El SDK no está inicializado. Llama a apacuana.init() primero.", 400, "NOT_INITIALIZED_ERROR");
|
|
34343
|
+
}
|
|
34344
|
+
if (requiresCustomerId && !config.customerId) {
|
|
34345
|
+
throw new ApacuanaAPIError("Se requiere un CustomerId para esta operación. Por favor, inicia sesión.", 403, "CUSTOMER_ID_REQUIRED");
|
|
34346
|
+
}
|
|
34347
|
+
};
|
|
34246
34348
|
var apacuana = {
|
|
34247
34349
|
/**
|
|
34248
|
-
* Inicializa el Apacuana SDK con la configuración necesaria
|
|
34249
|
-
* los detalles del usuario.
|
|
34250
|
-
* @param {object} config - Objeto de configuración.
|
|
34251
|
-
* @param {string} config.apiUrl - La URL base de la API de Apacuana.
|
|
34252
|
-
* @param {string} config.secretKey - La clave secreta para la autenticación.
|
|
34253
|
-
* @param {string} config.apiKey - La clave de API para la autenticación.
|
|
34254
|
-
* @param {string} config.verificationId - El ID de verificación del usuario.
|
|
34255
|
-
* @param {string} config.customerId - El ID del cliente.
|
|
34256
|
-
* @param {string} config.integrationType - El tipo de integración ('onpremise' o 'onboarding').
|
|
34257
|
-
* @returns {Promise<object>} retorna los detalles del usuario si la inicialización es exitosa.
|
|
34350
|
+
* Inicializa el Apacuana SDK con la configuración necesaria.
|
|
34258
34351
|
*/
|
|
34259
34352
|
init: function () {
|
|
34260
34353
|
var _init = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(config) {
|
|
@@ -34266,17 +34359,13 @@ var apacuana = {
|
|
|
34266
34359
|
setConfig(config);
|
|
34267
34360
|
initHttpClient();
|
|
34268
34361
|
currentConfig = getConfig();
|
|
34269
|
-
if (currentConfig.customerId) {
|
|
34270
|
-
_context.n =
|
|
34362
|
+
if (!currentConfig.customerId) {
|
|
34363
|
+
_context.n = 2;
|
|
34271
34364
|
break;
|
|
34272
34365
|
}
|
|
34273
|
-
|
|
34274
|
-
code: "CONFIG_ERROR"
|
|
34275
|
-
});
|
|
34276
|
-
case 1:
|
|
34277
|
-
_context.n = 2;
|
|
34366
|
+
_context.n = 1;
|
|
34278
34367
|
return getCustomer();
|
|
34279
|
-
case
|
|
34368
|
+
case 1:
|
|
34280
34369
|
customer = _context.v;
|
|
34281
34370
|
_customer$data = customer.data, token = _customer$data.token, userData = _customer$data.userData;
|
|
34282
34371
|
setConfig(_objectSpread2(_objectSpread2({}, currentConfig), {}, {
|
|
@@ -34286,12 +34375,16 @@ var apacuana = {
|
|
|
34286
34375
|
setAuthToken(token);
|
|
34287
34376
|
return _context.a(2, new ApacuanaSuccess({
|
|
34288
34377
|
initialized: true,
|
|
34289
|
-
message: "SDK inicializado
|
|
34378
|
+
message: "SDK inicializado con sesión de usuario."
|
|
34379
|
+
}));
|
|
34380
|
+
case 2:
|
|
34381
|
+
return _context.a(2, new ApacuanaSuccess({
|
|
34382
|
+
initialized: true,
|
|
34383
|
+
message: "SDK inicializado para operaciones públicas (sin customerId)."
|
|
34290
34384
|
}));
|
|
34291
34385
|
case 3:
|
|
34292
34386
|
_context.p = 3;
|
|
34293
34387
|
_t = _context.v;
|
|
34294
|
-
// eslint-disable-next-line no-console
|
|
34295
34388
|
console.error("Error durante la inicialización del SDK:", _t);
|
|
34296
34389
|
if (!(_t instanceof ApacuanaAPIError)) {
|
|
34297
34390
|
_context.n = 4;
|
|
@@ -34310,27 +34403,81 @@ var apacuana = {
|
|
|
34310
34403
|
}
|
|
34311
34404
|
return init;
|
|
34312
34405
|
}(),
|
|
34406
|
+
// --- Métodos de Revocación ---
|
|
34407
|
+
requestRevocation: function requestRevocation$1(data) {
|
|
34408
|
+
checkSdk(true);
|
|
34409
|
+
return requestRevocation(data);
|
|
34410
|
+
},
|
|
34411
|
+
getRevocationReasons: function getRevocationReasons$1() {
|
|
34412
|
+
checkSdk(true);
|
|
34413
|
+
return getRevocationReasons();
|
|
34414
|
+
},
|
|
34415
|
+
// --- Métodos de Certificados ---
|
|
34416
|
+
generateCert: function generateCert$1(data) {
|
|
34417
|
+
checkSdk(true);
|
|
34418
|
+
return generateCert(data);
|
|
34419
|
+
},
|
|
34420
|
+
getCertStatus: function getCertStatus$1(isCertificateInDevice) {
|
|
34421
|
+
checkSdk(true);
|
|
34422
|
+
return getCertStatus(isCertificateInDevice);
|
|
34423
|
+
},
|
|
34424
|
+
getCertTypes: function getCertTypes$1() {
|
|
34425
|
+
checkSdk(false);
|
|
34426
|
+
return getCertTypes();
|
|
34427
|
+
},
|
|
34428
|
+
getRequerimentsByTypeUser: function getRequerimentsByTypeUser$1(data) {
|
|
34429
|
+
checkSdk(false);
|
|
34430
|
+
return getRequerimentsByTypeUser(data);
|
|
34431
|
+
},
|
|
34432
|
+
// --- Métodos de Firmas y Documentos ---
|
|
34433
|
+
addSigner: function addSigner$1(data) {
|
|
34434
|
+
checkSdk(true);
|
|
34435
|
+
return addSigner(data);
|
|
34436
|
+
},
|
|
34437
|
+
deleteSignatureVariant: function deleteSignatureVariant$1() {
|
|
34438
|
+
checkSdk(true);
|
|
34439
|
+
return deleteSignatureVariant();
|
|
34440
|
+
},
|
|
34441
|
+
getDigest: function getDigest$1(data) {
|
|
34442
|
+
checkSdk(true);
|
|
34443
|
+
return getDigest(data);
|
|
34444
|
+
},
|
|
34445
|
+
getDocs: function getDocs$1(data) {
|
|
34446
|
+
checkSdk(true);
|
|
34447
|
+
return getDocs(data);
|
|
34448
|
+
},
|
|
34449
|
+
getSignatureVariant: function getSignatureVariant$1() {
|
|
34450
|
+
checkSdk(true);
|
|
34451
|
+
return getSignatureVariant();
|
|
34452
|
+
},
|
|
34453
|
+
signDocument: function signDocument$1(data) {
|
|
34454
|
+
checkSdk(true);
|
|
34455
|
+
return signDocument(data);
|
|
34456
|
+
},
|
|
34457
|
+
uploadSignatureVariant: function uploadSignatureVariant$1(data) {
|
|
34458
|
+
checkSdk(true);
|
|
34459
|
+
return uploadSignatureVariant(data);
|
|
34460
|
+
},
|
|
34461
|
+
getCustomer: function getCustomer$1() {
|
|
34462
|
+
checkSdk(true);
|
|
34463
|
+
return getCustomer();
|
|
34464
|
+
},
|
|
34465
|
+
createFaceLivenessSession: function createFaceLivenessSession$1() {
|
|
34466
|
+
checkSdk(true);
|
|
34467
|
+
return createFaceLivenessSession();
|
|
34468
|
+
},
|
|
34469
|
+
createApacuanaUser: function createApacuanaUser$1(data) {
|
|
34470
|
+
checkSdk(false);
|
|
34471
|
+
return createApacuanaUser(data);
|
|
34472
|
+
},
|
|
34473
|
+
validateFaceLiveness: function validateFaceLiveness$1(data) {
|
|
34474
|
+
checkSdk(true);
|
|
34475
|
+
return validateFaceLiveness(data);
|
|
34476
|
+
},
|
|
34313
34477
|
close: function close$1() {
|
|
34314
34478
|
return close();
|
|
34315
34479
|
},
|
|
34316
|
-
getConfig: getConfig
|
|
34317
|
-
requestRevocation: requestRevocation,
|
|
34318
|
-
getCertStatus: getCertStatus,
|
|
34319
|
-
getCustomer: getCustomer,
|
|
34320
|
-
addSigner: addSigner,
|
|
34321
|
-
getDocs: getDocs,
|
|
34322
|
-
generateCert: generateCert,
|
|
34323
|
-
signDocument: signDocument,
|
|
34324
|
-
getDigest: getDigest,
|
|
34325
|
-
getRevocationReasons: getRevocationReasons,
|
|
34326
|
-
uploadSignatureVariant: uploadSignatureVariant,
|
|
34327
|
-
getSignatureVariant: getSignatureVariant,
|
|
34328
|
-
deleteSignatureVariant: deleteSignatureVariant,
|
|
34329
|
-
getCertTypes: getCertTypes,
|
|
34330
|
-
getRequerimentsByTypeUser: getRequerimentsByTypeUser,
|
|
34331
|
-
createFaceLivenessSession: createFaceLivenessSession,
|
|
34332
|
-
validateFaceLiveness: validateFaceLiveness
|
|
34333
|
-
// requestCertificate,
|
|
34480
|
+
getConfig: getConfig
|
|
34334
34481
|
};
|
|
34335
34482
|
|
|
34336
34483
|
export { apacuana as default };
|