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