apacuana-sdk-core 0.11.0 → 0.13.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 +131 -164
- package/coverage/clover.xml +338 -302
- package/coverage/coverage-final.json +9 -9
- package/coverage/lcov-report/index.html +31 -31
- package/coverage/lcov-report/src/api/certs.js.html +1 -1
- package/coverage/lcov-report/src/api/faceLiveness.js.html +34 -7
- package/coverage/lcov-report/src/api/index.html +13 -13
- package/coverage/lcov-report/src/api/revocations.js.html +50 -5
- package/coverage/lcov-report/src/api/signatures.js.html +17 -56
- package/coverage/lcov-report/src/api/users.js.html +20 -5
- 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 +8 -8
- package/coverage/lcov-report/src/index.html +13 -13
- package/coverage/lcov-report/src/index.js.html +59 -14
- package/coverage/lcov-report/src/success/index.html +1 -1
- package/coverage/lcov-report/src/success/index.js.html +5 -5
- package/coverage/lcov-report/src/utils/constant.js.html +1 -1
- package/coverage/lcov-report/src/utils/helpers.js.html +277 -16
- package/coverage/lcov-report/src/utils/httpClient.js.html +32 -17
- package/coverage/lcov-report/src/utils/index.html +22 -22
- package/coverage/lcov.info +641 -561
- package/dist/api/revocations.d.ts +6 -3
- package/dist/api/users.d.ts +16 -6
- package/dist/index.d.ts +0 -2
- package/dist/index.js +149 -147
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +149 -147
- package/dist/index.mjs.map +1 -1
- package/dist/types/faceLiveness.d.ts +6 -5
- package/dist/types/revocations.d.ts +26 -15
- package/dist/types/signatures.d.ts +73 -63
- package/dist/utils/helpers.d.ts +4 -2
- package/package.json +1 -1
- package/src/api/faceLiveness.js +13 -4
- package/src/api/revocations.js +18 -3
- package/src/api/signatures.js +8 -21
- package/src/api/users.js +8 -3
- package/src/index.js +22 -7
- package/src/types/faceLiveness.js +11 -2
- package/src/types/revocations.js +29 -9
- package/src/types/signatures.js +47 -28
- package/src/utils/helpers.js +95 -8
- package/src/utils/httpClient.js +15 -10
- package/tests/api/faceLiveness.test.js +28 -30
- package/tests/api/revocations.test.js +4 -4
- package/tests/api/signatures.test.js +73 -16
- package/tests/index.test.js +16 -8
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type ApacuanaSuccess = import("../success").ApacuanaSuccess;
|
|
2
|
+
export type CreateFaceLivenessSessionData = {
|
|
2
3
|
/**
|
|
3
4
|
* - The session ID for the face liveness check.
|
|
4
5
|
*/
|
|
5
6
|
sessionId: string;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
};
|
|
8
|
+
export type CreateFaceLivenessSessionResponse = {
|
|
9
|
+
success: true;
|
|
10
|
+
data: CreateFaceLivenessSessionData;
|
|
10
11
|
};
|
|
@@ -1,32 +1,43 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export type ApacuanaSuccess = import("../success").ApacuanaSuccess;
|
|
2
|
+
export type RevocationReason = {
|
|
2
3
|
/**
|
|
3
|
-
* -
|
|
4
|
+
* - The code for the revocation reason.
|
|
4
5
|
*/
|
|
5
|
-
|
|
6
|
+
code: string;
|
|
6
7
|
/**
|
|
7
|
-
* -
|
|
8
|
+
* - The description of the revocation reason.
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
+
description: string;
|
|
10
11
|
};
|
|
11
|
-
export type
|
|
12
|
+
export type RequestRevocationData = {
|
|
12
13
|
/**
|
|
13
|
-
* -
|
|
14
|
+
* - A message providing details about the outcome.
|
|
14
15
|
*/
|
|
15
|
-
|
|
16
|
+
message: string;
|
|
17
|
+
};
|
|
18
|
+
export type RequestRevocationResponse = {
|
|
19
|
+
success: true;
|
|
20
|
+
data: RequestRevocationData;
|
|
21
|
+
};
|
|
22
|
+
export type GetRevocationReasonsData = {
|
|
16
23
|
/**
|
|
17
|
-
* - A
|
|
24
|
+
* - A list of revocation reasons.
|
|
18
25
|
*/
|
|
19
|
-
|
|
26
|
+
reasons: RevocationReason[];
|
|
20
27
|
};
|
|
21
|
-
export type
|
|
28
|
+
export type GetRevocationReasonsResponse = {
|
|
29
|
+
success: true;
|
|
30
|
+
data: GetRevocationReasonsData;
|
|
31
|
+
};
|
|
32
|
+
export type RevocationResponse = {
|
|
22
33
|
/**
|
|
23
|
-
* -
|
|
34
|
+
* - Indicates if the revocation request was successful.
|
|
24
35
|
*/
|
|
25
|
-
|
|
36
|
+
success: boolean;
|
|
26
37
|
/**
|
|
27
|
-
* -
|
|
38
|
+
* - A message providing details about the outcome.
|
|
28
39
|
*/
|
|
29
|
-
|
|
40
|
+
message?: string | undefined;
|
|
30
41
|
};
|
|
31
42
|
export type RevocationReasonsResponse = {
|
|
32
43
|
/**
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export type ApacuanaSuccess = import("../success").ApacuanaSuccess;
|
|
1
2
|
/**
|
|
2
3
|
* Define la estructura de un objeto Firmante.
|
|
3
4
|
*/
|
|
@@ -15,27 +16,18 @@ export type Signer = {
|
|
|
15
16
|
*/
|
|
16
17
|
document: string;
|
|
17
18
|
};
|
|
18
|
-
|
|
19
|
-
* Define la estructura de datos para añadir un firmante.
|
|
20
|
-
*/
|
|
21
|
-
export type SignerData = {
|
|
19
|
+
export type AddSignerData = {
|
|
22
20
|
/**
|
|
23
|
-
* - Identificador
|
|
21
|
+
* - Identificador de confirmación del firmante añadido.
|
|
24
22
|
*/
|
|
25
|
-
|
|
23
|
+
signer: string;
|
|
26
24
|
};
|
|
27
25
|
/**
|
|
28
26
|
* Define la estructura de la respuesta al añadir un firmante.
|
|
29
27
|
*/
|
|
30
28
|
export type AddSignerResponse = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*/
|
|
34
|
-
signer: string;
|
|
35
|
-
/**
|
|
36
|
-
* - Indica si la operación fue exitosa.
|
|
37
|
-
*/
|
|
38
|
-
success: boolean;
|
|
29
|
+
success: true;
|
|
30
|
+
data: AddSignerData;
|
|
39
31
|
};
|
|
40
32
|
/**
|
|
41
33
|
* Define la estructura de datos para obtener el digest de un documento.
|
|
@@ -46,22 +38,72 @@ export type GetDigestData = {
|
|
|
46
38
|
*/
|
|
47
39
|
cert: string;
|
|
48
40
|
/**
|
|
49
|
-
* - Identificador único
|
|
41
|
+
* - Identificador único de la firma.
|
|
50
42
|
*/
|
|
51
43
|
signatureId: string;
|
|
44
|
+
/**
|
|
45
|
+
* - Documento a firmar en formato de archivo. Este campo es opcional.
|
|
46
|
+
*/
|
|
47
|
+
document?: File | undefined;
|
|
48
|
+
};
|
|
49
|
+
export type SignaturePlacement = {
|
|
50
|
+
/**
|
|
51
|
+
* - Página donde se estampará la firma.
|
|
52
|
+
*/
|
|
53
|
+
page: number;
|
|
54
|
+
/**
|
|
55
|
+
* - Coordenada X de la firma.
|
|
56
|
+
*/
|
|
57
|
+
x: number;
|
|
58
|
+
/**
|
|
59
|
+
* - Coordenada Y de la firma.
|
|
60
|
+
*/
|
|
61
|
+
y: number;
|
|
52
62
|
};
|
|
53
63
|
/**
|
|
54
|
-
* Define la estructura de
|
|
64
|
+
* Define la estructura de datos para añadir un firmante.
|
|
55
65
|
*/
|
|
56
|
-
export type
|
|
66
|
+
export type SignerData = {
|
|
57
67
|
/**
|
|
58
|
-
* -
|
|
68
|
+
* - Nombre del firmante.
|
|
59
69
|
*/
|
|
60
|
-
|
|
70
|
+
name: string;
|
|
71
|
+
/**
|
|
72
|
+
* - Tipo de documento de identidad del firmante.
|
|
73
|
+
*/
|
|
74
|
+
typedoc: string;
|
|
75
|
+
/**
|
|
76
|
+
* - Número de documento de identidad del firmante.
|
|
77
|
+
*/
|
|
78
|
+
doc: string;
|
|
79
|
+
/**
|
|
80
|
+
* - Array con las coordenadas donde se estampará la firma.
|
|
81
|
+
*/
|
|
82
|
+
signature: Array<SignaturePlacement>;
|
|
83
|
+
/**
|
|
84
|
+
* - Referencia a un documento pre-cargado. Se debe proporcionar 'reference' o 'file', pero no ambos.
|
|
85
|
+
*/
|
|
86
|
+
reference?: string | undefined;
|
|
87
|
+
/**
|
|
88
|
+
* - Archivo del documento a firmar. Se debe proporcionar 'reference' o 'file', pero no ambos.
|
|
89
|
+
*/
|
|
90
|
+
file?: File | undefined;
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Define la estructura de datos para la respuesta de la creación de una firma.
|
|
94
|
+
*/
|
|
95
|
+
export type GetDigestResponseData = {
|
|
61
96
|
/**
|
|
62
|
-
* -
|
|
97
|
+
* - El digest del documento que se va a firmar.
|
|
63
98
|
*/
|
|
64
|
-
|
|
99
|
+
digest: string;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* Define la estructura de la respuesta al obtener el digest.
|
|
103
|
+
*/
|
|
104
|
+
export type GetDigestResponse = {
|
|
105
|
+
success: true;
|
|
106
|
+
data: GetDigestResponseData;
|
|
65
107
|
};
|
|
66
108
|
/**
|
|
67
109
|
* Define la estructura de los parámetros para obtener documentos.
|
|
@@ -80,10 +122,7 @@ export type GetDocsParams = {
|
|
|
80
122
|
*/
|
|
81
123
|
status?: string | undefined;
|
|
82
124
|
};
|
|
83
|
-
|
|
84
|
-
* Define la estructura de la respuesta al obtener documentos.
|
|
85
|
-
*/
|
|
86
|
-
export type GetDocsResponse = {
|
|
125
|
+
export type GetDocsResponseData = {
|
|
87
126
|
/**
|
|
88
127
|
* - El número total de registros encontrados.
|
|
89
128
|
*/
|
|
@@ -92,10 +131,13 @@ export type GetDocsResponse = {
|
|
|
92
131
|
* - Un arreglo con los registros de los documentos.
|
|
93
132
|
*/
|
|
94
133
|
records: Array<object>;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Define la estructura de la respuesta al obtener documentos.
|
|
137
|
+
*/
|
|
138
|
+
export type GetDocsResponse = {
|
|
139
|
+
success: true;
|
|
140
|
+
data: GetDocsResponseData;
|
|
99
141
|
};
|
|
100
142
|
export type SignDocumentData = {
|
|
101
143
|
/**
|
|
@@ -113,40 +155,8 @@ export type SignDocumentData = {
|
|
|
113
155
|
* - Digest firmado.
|
|
114
156
|
*/
|
|
115
157
|
signedDigest: string;
|
|
116
|
-
};
|
|
117
|
-
export type SignaturePosition = {
|
|
118
|
-
/**
|
|
119
|
-
* - The page number for the signature.
|
|
120
|
-
*/
|
|
121
|
-
page: number;
|
|
122
|
-
/**
|
|
123
|
-
* - The x-coordinate for the signature's position (from 0 to 1).
|
|
124
|
-
*/
|
|
125
|
-
x: number;
|
|
126
|
-
/**
|
|
127
|
-
* - The y-coordinate for the signature's position (from 0 to 1).
|
|
128
|
-
*/
|
|
129
|
-
y: number;
|
|
130
|
-
};
|
|
131
|
-
export type OnboardingSignerData = {
|
|
132
|
-
/**
|
|
133
|
-
* - The name of the document.
|
|
134
|
-
*/
|
|
135
|
-
name: string;
|
|
136
|
-
/**
|
|
137
|
-
* - An external reference for the document.
|
|
138
|
-
*/
|
|
139
|
-
reference: string;
|
|
140
|
-
/**
|
|
141
|
-
* - The type of document of the signer (e.g., "V", "E", "J").
|
|
142
|
-
*/
|
|
143
|
-
typedoc: string;
|
|
144
|
-
/**
|
|
145
|
-
* - The document number of the signer.
|
|
146
|
-
*/
|
|
147
|
-
doc: string;
|
|
148
158
|
/**
|
|
149
|
-
* -
|
|
159
|
+
* - Documento a firmar en formato de archivo. Este campo es opcional.
|
|
150
160
|
*/
|
|
151
|
-
|
|
161
|
+
document?: File | undefined;
|
|
152
162
|
};
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ declare namespace _default {
|
|
|
8
8
|
export { validateGetDocsData };
|
|
9
9
|
export { validateGetDigestData };
|
|
10
10
|
export { validateOnBoardingSignDocumentData };
|
|
11
|
+
export { createPayloadGetDigest };
|
|
11
12
|
}
|
|
12
13
|
export default _default;
|
|
13
14
|
declare function getCertificateStatus(userData: any, certificateInDevice: any): string;
|
|
@@ -16,8 +17,9 @@ declare function arrayBufferToBase64(buffer: any): string;
|
|
|
16
17
|
declare function encryptedCsr(csr: any, encryptKey?: string): {
|
|
17
18
|
csr: any;
|
|
18
19
|
};
|
|
19
|
-
declare function validateOnBoardingSignerData(signerData: any):
|
|
20
|
+
declare function validateOnBoardingSignerData(signerData: any): FormData;
|
|
20
21
|
declare function validateCsr(encryptedCSR: any): void;
|
|
21
22
|
declare function validateGetDocsData(data: any): void;
|
|
22
23
|
declare function validateGetDigestData(signData: any): void;
|
|
23
|
-
declare function validateOnBoardingSignDocumentData(signData: any):
|
|
24
|
+
declare function validateOnBoardingSignDocumentData(signData: any): FormData;
|
|
25
|
+
declare function createPayloadGetDigest(signData: any): FormData;
|
package/package.json
CHANGED
package/src/api/faceLiveness.js
CHANGED
|
@@ -8,6 +8,12 @@ import { ApacuanaAPIError } from "../errors";
|
|
|
8
8
|
import ApacuanaSuccess from "../success";
|
|
9
9
|
import { INTEGRATION_TYPE } from "../utils/constant";
|
|
10
10
|
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new Face Liveness session.
|
|
13
|
+
* @returns {Promise<CreateFaceLivenessSessionResponse>} Object with the session ID and a success indicator.
|
|
14
|
+
* @throws {ApacuanaAPIError} If the API response is invalid or the integration type is not supported.
|
|
15
|
+
* @throws {Error} If the request fails for another reason.
|
|
16
|
+
*/
|
|
11
17
|
const createFaceLivenessSessionOnBoarding = async () => {
|
|
12
18
|
try {
|
|
13
19
|
const response = await httpRequest(
|
|
@@ -15,8 +21,7 @@ const createFaceLivenessSessionOnBoarding = async () => {
|
|
|
15
21
|
{},
|
|
16
22
|
"POST"
|
|
17
23
|
);
|
|
18
|
-
|
|
19
|
-
if (!response.sessionId) {
|
|
24
|
+
if (!response.sessionid) {
|
|
20
25
|
throw new ApacuanaAPIError(
|
|
21
26
|
"The API response does not contain the session ID.",
|
|
22
27
|
response.status,
|
|
@@ -24,12 +29,16 @@ const createFaceLivenessSessionOnBoarding = async () => {
|
|
|
24
29
|
);
|
|
25
30
|
}
|
|
26
31
|
|
|
27
|
-
return new ApacuanaSuccess({
|
|
32
|
+
return new ApacuanaSuccess({
|
|
33
|
+
sessionId: response.sessionid,
|
|
34
|
+
});
|
|
28
35
|
} catch (error) {
|
|
29
36
|
if (error instanceof ApacuanaAPIError) {
|
|
30
37
|
throw error;
|
|
31
38
|
}
|
|
32
|
-
throw new
|
|
39
|
+
throw new ApacuanaAPIError(
|
|
40
|
+
`Failed to create Face Liveness session: ${error.message}`
|
|
41
|
+
);
|
|
33
42
|
}
|
|
34
43
|
};
|
|
35
44
|
|
package/src/api/revocations.js
CHANGED
|
@@ -4,10 +4,13 @@ import { INTEGRATION_TYPE } from "../utils/constant";
|
|
|
4
4
|
import { ApacuanaAPIError } from "../errors";
|
|
5
5
|
import ApacuanaSuccess from "../success";
|
|
6
6
|
|
|
7
|
+
/** @typedef {import("../types/revocations").RequestRevocationResponse} RequestRevocationResponse */
|
|
8
|
+
/** @typedef {import("../types/revocations").GetRevocationReasonsResponse} GetRevocationReasonsResponse */
|
|
9
|
+
|
|
7
10
|
const requestRevocationOnBoarding = async (params) => {
|
|
8
11
|
try {
|
|
9
12
|
const response = await httpRequest(
|
|
10
|
-
"services/api/
|
|
13
|
+
"services/api/onboardingclient/requestcert",
|
|
11
14
|
params,
|
|
12
15
|
"POST"
|
|
13
16
|
);
|
|
@@ -28,6 +31,13 @@ const requestRevocationOnPremise = async () => {
|
|
|
28
31
|
);
|
|
29
32
|
};
|
|
30
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Solicita la revocación de un certificado.
|
|
36
|
+
* @param {object} params - Parámetros para la solicitud.
|
|
37
|
+
* @param {number} params.reasonCode - El código de la razón de la revocación.
|
|
38
|
+
* @returns {Promise<RequestRevocationResponse>} Una promesa que resuelve con la confirmación de la solicitud.
|
|
39
|
+
* @throws {Error} Si los parámetros son inválidos.
|
|
40
|
+
*/
|
|
31
41
|
export const requestRevocation = async (params) => {
|
|
32
42
|
if (!params || typeof params.reasonCode !== "number") {
|
|
33
43
|
throw new Error(
|
|
@@ -53,14 +63,14 @@ export const requestRevocation = async (params) => {
|
|
|
53
63
|
const getRevocationReasonsOnBoarding = async () => {
|
|
54
64
|
try {
|
|
55
65
|
const response = await httpRequest(
|
|
56
|
-
"
|
|
66
|
+
"config/api/revocation/reasonsonboarding",
|
|
57
67
|
{},
|
|
58
68
|
"GET"
|
|
59
69
|
);
|
|
60
70
|
if (!response || !response.records) {
|
|
61
71
|
throw new ApacuanaAPIError("Failed to fetch revocation reasons.");
|
|
62
72
|
}
|
|
63
|
-
return new ApacuanaSuccess(response.records);
|
|
73
|
+
return new ApacuanaSuccess({ reasons: response.records });
|
|
64
74
|
} catch (error) {
|
|
65
75
|
if (error instanceof ApacuanaAPIError) {
|
|
66
76
|
throw error;
|
|
@@ -77,6 +87,11 @@ const getRevocationReasonsOnPremise = async () => {
|
|
|
77
87
|
);
|
|
78
88
|
};
|
|
79
89
|
|
|
90
|
+
/**
|
|
91
|
+
* Obtiene la lista de razones de revocación de certificados.
|
|
92
|
+
* @returns {Promise<GetRevocationReasonsResponse>} Una promesa que resuelve con la lista de razones de revocación.
|
|
93
|
+
* @throws {ApacuanaAPIError} Si la llamada a la API falla o el tipo de integración no es soportado.
|
|
94
|
+
*/
|
|
80
95
|
export const getRevocationReasons = async () => {
|
|
81
96
|
const { integrationType } = getConfig();
|
|
82
97
|
|
package/src/api/signatures.js
CHANGED
|
@@ -22,25 +22,13 @@ import { INTEGRATION_TYPE } from "../utils/constant";
|
|
|
22
22
|
// =================================================================
|
|
23
23
|
|
|
24
24
|
const signDocumentOnBoarding = async (signData) => {
|
|
25
|
-
helpers.validateOnBoardingSignDocumentData(signData);
|
|
26
|
-
const { signature, cert, signedDigest } = signData;
|
|
27
|
-
try {
|
|
28
|
-
const signBody = {
|
|
29
|
-
positions: JSON.stringify(
|
|
30
|
-
signature.positions.map((p) => ({
|
|
31
|
-
x: p.x,
|
|
32
|
-
y: p.y,
|
|
33
|
-
page: p.page,
|
|
34
|
-
status: 1,
|
|
35
|
-
}))
|
|
36
|
-
),
|
|
37
|
-
publickey: cert,
|
|
38
|
-
signeddigest: signedDigest,
|
|
39
|
-
};
|
|
25
|
+
const payload = helpers.validateOnBoardingSignDocumentData(signData);
|
|
40
26
|
|
|
27
|
+
const { signature } = signData;
|
|
28
|
+
try {
|
|
41
29
|
const response = await httpRequest(
|
|
42
30
|
`services/api/documents/sign/${signature.id}`,
|
|
43
|
-
|
|
31
|
+
payload,
|
|
44
32
|
"PUT"
|
|
45
33
|
);
|
|
46
34
|
return new ApacuanaSuccess(response);
|
|
@@ -64,11 +52,10 @@ const signDocumentOnPremise = async () => {
|
|
|
64
52
|
|
|
65
53
|
const getDigestToSignOnBoarding = async (signData) => {
|
|
66
54
|
try {
|
|
55
|
+
const formData = helpers.createPayloadGetDigest(signData);
|
|
67
56
|
const response = await httpRequest(
|
|
68
57
|
`services/api/documents/getdigest/${signData.signatureId}`,
|
|
69
|
-
|
|
70
|
-
publickey: signData.cert,
|
|
71
|
-
},
|
|
58
|
+
formData,
|
|
72
59
|
"POST"
|
|
73
60
|
);
|
|
74
61
|
const digest = response.data?.digest || response.digest;
|
|
@@ -100,9 +87,9 @@ const getDigestToSignOnPremise = async () => {
|
|
|
100
87
|
};
|
|
101
88
|
|
|
102
89
|
const addSignerOnBoarding = async (signerData) => {
|
|
103
|
-
helpers.validateOnBoardingSignerData(signerData);
|
|
90
|
+
const payload = helpers.validateOnBoardingSignerData(signerData);
|
|
104
91
|
try {
|
|
105
|
-
await httpRequest("services/api/documents/
|
|
92
|
+
await httpRequest("services/api/documents/signingsdk", payload, "POST");
|
|
106
93
|
return new ApacuanaSuccess({
|
|
107
94
|
signer: signerData.typedoc + signerData.doc,
|
|
108
95
|
});
|
package/src/api/users.js
CHANGED
|
@@ -4,10 +4,15 @@ import { getConfig } from "../config/index";
|
|
|
4
4
|
import ApacuanaSuccess from "../success";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* @typedef {object}
|
|
7
|
+
* @typedef {object} GetCustomerData
|
|
8
8
|
* @property {string} token - El token de sesión del usuario.
|
|
9
9
|
* @property {object} userData - Los datos del usuario obtenidos.
|
|
10
|
-
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {object} GetCustomerResponse
|
|
14
|
+
* @property {true} success - Indica que la operación fue exitosa.
|
|
15
|
+
* @property {GetCustomerData} data - El payload de la respuesta.
|
|
11
16
|
*/
|
|
12
17
|
|
|
13
18
|
/**
|
|
@@ -15,7 +20,7 @@ import ApacuanaSuccess from "../success";
|
|
|
15
20
|
* Este método es útil para endpoints que requieren datos en el cuerpo de la petición
|
|
16
21
|
* para buscar un usuario, como un ID de sesión o un token de acceso.
|
|
17
22
|
*
|
|
18
|
-
* @returns {Promise<GetCustomerResponse>}
|
|
23
|
+
* @returns {Promise<GetCustomerResponse>} Una promesa que resuelve a un objeto con la respuesta exitosa.
|
|
19
24
|
* @throws {Error} Si los parámetros de entrada son inválidos.
|
|
20
25
|
* @throws {ApacuanaAPIError} Si ocurre un error en la API de Apacuana.
|
|
21
26
|
*/
|
package/src/index.js
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
getCertStatus,
|
|
8
8
|
getCertTypes,
|
|
9
9
|
getRequerimentsByTypeUser,
|
|
10
|
-
requestCertificate,
|
|
11
10
|
} from "./api/certs";
|
|
12
11
|
import {
|
|
13
12
|
addSigner,
|
|
@@ -22,6 +21,8 @@ import {
|
|
|
22
21
|
createFaceLivenessSession,
|
|
23
22
|
validateFaceLiveness,
|
|
24
23
|
} from "./api/faceLiveness";
|
|
24
|
+
import ApacuanaSuccess from "./success/index";
|
|
25
|
+
import { ApacuanaAPIError } from "./errors/index";
|
|
25
26
|
|
|
26
27
|
const apacuana = {
|
|
27
28
|
/**
|
|
@@ -42,19 +43,33 @@ const apacuana = {
|
|
|
42
43
|
initHttpClient();
|
|
43
44
|
const currentConfig = getConfig();
|
|
44
45
|
if (!currentConfig.customerId) {
|
|
45
|
-
throw new
|
|
46
|
+
throw new ApacuanaAPIError(
|
|
46
47
|
"Apacuana SDK: La configuración de CustomerId no se ha guardado" +
|
|
47
|
-
" correctamente."
|
|
48
|
+
" correctamente.",
|
|
49
|
+
400,
|
|
50
|
+
{ code: "CONFIG_ERROR" }
|
|
48
51
|
);
|
|
49
52
|
}
|
|
50
|
-
|
|
53
|
+
|
|
54
|
+
const customer = await getCustomer();
|
|
55
|
+
const { token, userData } = customer.data;
|
|
51
56
|
setConfig({ ...currentConfig, token, userData });
|
|
52
57
|
setAuthToken(token);
|
|
53
|
-
return
|
|
58
|
+
return new ApacuanaSuccess({
|
|
59
|
+
initialized: true,
|
|
60
|
+
message: "SDK inicializado correctamente.",
|
|
61
|
+
});
|
|
54
62
|
} catch (error) {
|
|
55
63
|
// eslint-disable-next-line no-console
|
|
56
64
|
console.error("Error durante la inicialización del SDK:", error);
|
|
57
|
-
|
|
65
|
+
if (error instanceof ApacuanaAPIError) {
|
|
66
|
+
throw error;
|
|
67
|
+
}
|
|
68
|
+
throw new ApacuanaAPIError(
|
|
69
|
+
error.message || "Error desconocido durante la inicialización.",
|
|
70
|
+
500,
|
|
71
|
+
error
|
|
72
|
+
);
|
|
58
73
|
}
|
|
59
74
|
},
|
|
60
75
|
close: () => close(),
|
|
@@ -75,7 +90,7 @@ const apacuana = {
|
|
|
75
90
|
getRequerimentsByTypeUser,
|
|
76
91
|
createFaceLivenessSession,
|
|
77
92
|
validateFaceLiveness,
|
|
78
|
-
requestCertificate,
|
|
93
|
+
// requestCertificate,
|
|
79
94
|
};
|
|
80
95
|
|
|
81
96
|
export default apacuana;
|
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* @typedef {
|
|
2
|
+
* @typedef {import('../success').ApacuanaSuccess} ApacuanaSuccess
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {object} CreateFaceLivenessSessionData
|
|
3
7
|
* @property {string} sessionId - The session ID for the face liveness check.
|
|
4
|
-
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* @typedef {object} CreateFaceLivenessSessionResponse
|
|
12
|
+
* @property {true} success
|
|
13
|
+
* @property {CreateFaceLivenessSessionData} data
|
|
5
14
|
*/
|
|
6
15
|
|
|
7
16
|
export {};
|
package/src/types/revocations.js
CHANGED
|
@@ -1,19 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {import('../success').ApacuanaSuccess} ApacuanaSuccess
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @typedef {object} RevocationReason
|
|
7
|
+
* @property {string} code - The code for the revocation reason.
|
|
8
|
+
* @property {string} description - The description of the revocation reason.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @typedef {object} RequestRevocationData
|
|
13
|
+
* @property {string} message - A message providing details about the outcome.
|
|
14
|
+
*/
|
|
15
|
+
|
|
1
16
|
/**
|
|
2
17
|
* @typedef {object} RequestRevocationResponse
|
|
3
|
-
* @property {
|
|
4
|
-
* @property {
|
|
18
|
+
* @property {true} success
|
|
19
|
+
* @property {RequestRevocationData} data
|
|
5
20
|
*/
|
|
6
21
|
|
|
7
22
|
/**
|
|
8
|
-
* @typedef {object}
|
|
9
|
-
* @property {
|
|
10
|
-
* @property {string} [message] - A message providing details about the outcome.
|
|
23
|
+
* @typedef {object} GetRevocationReasonsData
|
|
24
|
+
* @property {RevocationReason[]} reasons - A list of revocation reasons.
|
|
11
25
|
*/
|
|
12
26
|
|
|
13
27
|
/**
|
|
14
|
-
* @typedef {object}
|
|
15
|
-
* @property {
|
|
16
|
-
* @property {
|
|
28
|
+
* @typedef {object} GetRevocationReasonsResponse
|
|
29
|
+
* @property {true} success
|
|
30
|
+
* @property {GetRevocationReasonsData} data
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @typedef {object} RevocationResponse
|
|
35
|
+
* @property {boolean} success - Indicates if the revocation request was successful.
|
|
36
|
+
* @property {string} [message] - A message providing details about the outcome.
|
|
17
37
|
*/
|
|
18
38
|
|
|
19
39
|
/**
|
|
@@ -22,4 +42,4 @@
|
|
|
22
42
|
* @property {RevocationReason[]} reasons - A list of revocation reasons.
|
|
23
43
|
*/
|
|
24
44
|
|
|
25
|
-
export {};
|
|
45
|
+
export {};
|