apacuana-sdk-core 0.12.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.
Files changed (49) hide show
  1. package/README.md +131 -164
  2. package/coverage/clover.xml +386 -296
  3. package/coverage/coverage-final.json +7 -7
  4. package/coverage/lcov-report/index.html +38 -38
  5. package/coverage/lcov-report/src/api/certs.js.html +14 -8
  6. package/coverage/lcov-report/src/api/faceLiveness.js.html +1 -1
  7. package/coverage/lcov-report/src/api/index.html +31 -31
  8. package/coverage/lcov-report/src/api/revocations.js.html +2 -2
  9. package/coverage/lcov-report/src/api/signatures.js.html +17 -56
  10. package/coverage/lcov-report/src/api/users.js.html +160 -13
  11. package/coverage/lcov-report/src/config/index.html +1 -1
  12. package/coverage/lcov-report/src/config/index.js.html +1 -1
  13. package/coverage/lcov-report/src/errors/index.html +1 -1
  14. package/coverage/lcov-report/src/errors/index.js.html +1 -1
  15. package/coverage/lcov-report/src/index.html +21 -21
  16. package/coverage/lcov-report/src/index.js.html +267 -63
  17. package/coverage/lcov-report/src/success/index.html +1 -1
  18. package/coverage/lcov-report/src/success/index.js.html +1 -1
  19. package/coverage/lcov-report/src/utils/constant.js.html +115 -4
  20. package/coverage/lcov-report/src/utils/helpers.js.html +286 -22
  21. package/coverage/lcov-report/src/utils/httpClient.js.html +32 -20
  22. package/coverage/lcov-report/src/utils/index.html +24 -24
  23. package/coverage/lcov.info +776 -586
  24. package/dist/api/users.d.ts +27 -21
  25. package/dist/index.d.ts +19 -42
  26. package/dist/index.js +357 -251
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +357 -251
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/types/certs.d.ts +20 -34
  31. package/dist/types/signatures.d.ts +19 -4
  32. package/dist/utils/constant.d.ts +31 -0
  33. package/dist/utils/helpers.d.ts +5 -3
  34. package/package.json +1 -1
  35. package/src/api/certs.js +4 -2
  36. package/src/api/revocations.js +1 -1
  37. package/src/api/signatures.js +8 -21
  38. package/src/api/users.js +51 -2
  39. package/src/index.js +113 -45
  40. package/src/types/certs.js +36 -25
  41. package/src/types/signatures.js +6 -1
  42. package/src/utils/constant.js +37 -0
  43. package/src/utils/helpers.js +100 -12
  44. package/src/utils/httpClient.js +16 -12
  45. package/tests/api/certs.test.js +11 -3
  46. package/tests/api/revocations.test.js +1 -1
  47. package/tests/api/signatures.test.js +73 -16
  48. package/tests/api/users.test.js +1 -1
  49. package/tests/index.test.js +3 -2
@@ -1,4 +1,5 @@
1
- export type GenerateCertResponse = {
1
+ export type ApacuanaSuccess = import("../success").ApacuanaSuccess;
2
+ export type GenerateCertResponseData = {
2
3
  /**
3
4
  * - El certificado generado en formato string.
4
5
  */
@@ -7,26 +8,12 @@ export type GenerateCertResponse = {
7
8
  * - El ID del certificado generado.
8
9
  */
9
10
  certifiedid: string;
10
- /**
11
- * - Indica si la operación fue exitosa.
12
- */
13
- success: boolean;
14
11
  };
15
- export type GetCertStatusResponse = {
12
+ export type GetCertStatusResponseData = {
16
13
  /**
17
14
  * - El estado actual del certificado del usuario.
18
15
  */
19
16
  status: string;
20
- /**
21
- * - Indica si la operación fue exitosa.
22
- */
23
- success: boolean;
24
- };
25
- export type EncryptedCSRObject = {
26
- /**
27
- * - The encrypted Certificate Signing Request.
28
- */
29
- csr: string;
30
17
  };
31
18
  export type CertType = {
32
19
  /**
@@ -38,15 +25,11 @@ export type CertType = {
38
25
  */
39
26
  name: string;
40
27
  };
41
- export type GetCertTypesResponse = {
28
+ export type GetCertTypesResponseData = {
42
29
  /**
43
30
  * - A list of available certificate types.
44
31
  */
45
32
  types: Array<CertType>;
46
- /**
47
- * - Indicates if the operation was successful.
48
- */
49
- success: boolean;
50
33
  };
51
34
  export type Requirement = {
52
35
  /**
@@ -58,15 +41,28 @@ export type Requirement = {
58
41
  */
59
42
  description: string;
60
43
  };
61
- export type GetRequirementsResponse = {
44
+ export type GetRequirementsResponseData = {
62
45
  /**
63
46
  * - A list of requirements for the user type.
64
47
  */
65
48
  requirements: Array<Requirement>;
49
+ };
50
+ export type RequestCertificateResponseData = {
51
+ /**
52
+ * - A message confirming the request.
53
+ */
54
+ message: string;
55
+ };
56
+ export type GenerateCertResponse = GenerateCertResponseData & ApacuanaSuccess;
57
+ export type GetCertStatusResponse = GetCertStatusResponseData & ApacuanaSuccess;
58
+ export type GetCertTypesResponse = GetCertTypesResponseData & ApacuanaSuccess;
59
+ export type GetRequirementsResponse = GetRequirementsResponseData & ApacuanaSuccess;
60
+ export type RequestCertificateResponse = RequestCertificateResponseData & ApacuanaSuccess;
61
+ export type EncryptedCSRObject = {
66
62
  /**
67
- * - Indicates if the operation was successful.
63
+ * - The encrypted Certificate Signing Request.
68
64
  */
69
- success: boolean;
65
+ csr: string;
70
66
  };
71
67
  export type CertificateRequestParams = {
72
68
  /**
@@ -85,13 +81,3 @@ export type CertificateRequestParams = {
85
81
  file: string;
86
82
  }>;
87
83
  };
88
- export type RequestCertificateResponse = {
89
- /**
90
- * - A message confirming the request.
91
- */
92
- message: string;
93
- /**
94
- * - Indicates if the operation was successful.
95
- */
96
- success: boolean;
97
- };
@@ -41,6 +41,10 @@ export type GetDigestData = {
41
41
  * - Identificador único de la firma.
42
42
  */
43
43
  signatureId: string;
44
+ /**
45
+ * - Documento a firmar en formato de archivo. Este campo es opcional.
46
+ */
47
+ document?: File | undefined;
44
48
  };
45
49
  export type SignaturePlacement = {
46
50
  /**
@@ -64,10 +68,6 @@ export type SignerData = {
64
68
  * - Nombre del firmante.
65
69
  */
66
70
  name: string;
67
- /**
68
- * - Referencia o identificador del firmante.
69
- */
70
- reference: string;
71
71
  /**
72
72
  * - Tipo de documento de identidad del firmante.
73
73
  */
@@ -80,7 +80,18 @@ export type SignerData = {
80
80
  * - Array con las coordenadas donde se estampará la firma.
81
81
  */
82
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;
83
91
  };
92
+ /**
93
+ * Define la estructura de datos para la respuesta de la creación de una firma.
94
+ */
84
95
  export type GetDigestResponseData = {
85
96
  /**
86
97
  * - El digest del documento que se va a firmar.
@@ -144,4 +155,8 @@ export type SignDocumentData = {
144
155
  * - Digest firmado.
145
156
  */
146
157
  signedDigest: string;
158
+ /**
159
+ * - Documento a firmar en formato de archivo. Este campo es opcional.
160
+ */
161
+ document?: File | undefined;
147
162
  };
@@ -8,6 +8,37 @@ export namespace STATUS_CERTIFICATE {
8
8
  let certificate_another_device: string;
9
9
  let sign_pending: string;
10
10
  }
11
+ export const PARSE_STATUS: {
12
+ [STATUS_CERTIFICATE.certificate_another_device]: {
13
+ text: string;
14
+ descriptionText: undefined;
15
+ };
16
+ [STATUS_CERTIFICATE.request]: {
17
+ text: string;
18
+ descriptionText: string;
19
+ };
20
+ [STATUS_CERTIFICATE.generate]: {
21
+ text: string;
22
+ descriptionText: string;
23
+ };
24
+ [STATUS_CERTIFICATE.current]: {
25
+ text: string;
26
+ descriptionText: undefined;
27
+ };
28
+ [STATUS_CERTIFICATE.expire]: string;
29
+ [STATUS_CERTIFICATE.request_revoque]: {
30
+ text: string;
31
+ descriptionText: string;
32
+ };
33
+ [STATUS_CERTIFICATE.revoque]: {
34
+ text: string;
35
+ descriptionText: string;
36
+ };
37
+ [STATUS_CERTIFICATE.request_cert]: {
38
+ text: string;
39
+ descriptionText: string;
40
+ };
41
+ };
11
42
  export namespace VERIFICATION_STATUS {
12
43
  let IN_REGISTER: number;
13
44
  let APPROVED: number;
@@ -8,16 +8,18 @@ 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
- declare function getCertificateStatus(userData: any, certificateInDevice: any): string;
14
+ declare function getCertificateStatus(userData: any, certificateInDevice: any): any;
14
15
  declare function exportPrivateKey(key: any): Promise<string>;
15
16
  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): void;
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): void;
24
+ declare function validateOnBoardingSignDocumentData(signData: any): FormData;
25
+ declare function createPayloadGetDigest(signData: any): FormData;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apacuana-sdk-core",
3
- "version": "0.12.0",
3
+ "version": "0.14.0",
4
4
  "description": "Core SDK para interacciones con las APIs de Apacuana.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/src/api/certs.js CHANGED
@@ -14,7 +14,7 @@ import { httpRequest } from "../utils/httpClient";
14
14
  import helpers from "../utils/helpers";
15
15
  import { ApacuanaAPIError } from "../errors";
16
16
  import ApacuanaSuccess from "../success";
17
- import { INTEGRATION_TYPE } from "../utils/constant";
17
+ import { INTEGRATION_TYPE, PARSE_STATUS } from "../utils/constant";
18
18
 
19
19
  /**
20
20
  * @param {EncryptedCSRObject} encryptedCSR
@@ -88,7 +88,9 @@ export const getCertStatus = (isCertificateInDevice = false) => {
88
88
  config.userData,
89
89
  isCertificateInDevice
90
90
  );
91
- return new ApacuanaSuccess({ status });
91
+ const parseStatus = PARSE_STATUS[status];
92
+
93
+ return new ApacuanaSuccess({ status: parseStatus });
92
94
  };
93
95
 
94
96
  const getCertTypesOnBoarding = async () => {
@@ -11,7 +11,7 @@ const requestRevocationOnBoarding = async (params) => {
11
11
  try {
12
12
  const response = await httpRequest(
13
13
  "services/api/onboardingclient/requestcert",
14
- params,
14
+ { reason: params.reasonCode },
15
15
  "POST"
16
16
  );
17
17
  return new ApacuanaSuccess(response);
@@ -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
- signBody,
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/signing", signerData, "POST");
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
@@ -24,7 +24,7 @@ import ApacuanaSuccess from "../success";
24
24
  * @throws {Error} Si los parámetros de entrada son inválidos.
25
25
  * @throws {ApacuanaAPIError} Si ocurre un error en la API de Apacuana.
26
26
  */
27
- const getCustomer = async () => {
27
+ export const getCustomer = async () => {
28
28
  const { verificationId, customerId } = getConfig();
29
29
 
30
30
  if (!verificationId || !customerId) {
@@ -69,4 +69,53 @@ const getCustomer = async () => {
69
69
  }
70
70
  };
71
71
 
72
- export default getCustomer;
72
+ /**
73
+ * @typedef {object} CreateUserPayload
74
+ * @property {string} usr - Correo electrónico del usuario.
75
+ * @property {string} pwd - Contraseña del usuario.
76
+ * @property {string} kinddoc - Tipo de documento de identidad (ej. 'V', 'P', 'E').
77
+ * @property {string} doc - Número de documento de identidad.
78
+ */
79
+
80
+ /**
81
+ * @typedef {object} CreateUserResponse
82
+ * @property {string} message - Mensaje de confirmación de la creación del usuario.
83
+ */
84
+
85
+ /**
86
+ * Crea un nuevo usuario en la plataforma de Apacuana.
87
+ * @param {CreateUserPayload} userData - Objeto con los datos del usuario a crear.
88
+ * @returns {Promise<ApacuanaSuccess>} Una promesa que resuelve a un objeto con la respuesta exitosa.
89
+ * @throws {ApacuanaAPIError} Si los datos de entrada son inválidos o si ocurre un error en la API.
90
+ */
91
+
92
+ export const createApacuanaUser = async (userData) => {
93
+ try {
94
+ const formData = new FormData();
95
+ Object.keys(userData).forEach((key) => {
96
+ const value = userData[key];
97
+ if (value instanceof File) {
98
+ formData.append(key, value);
99
+ } else if (value !== null && value !== undefined) {
100
+ formData.append(key, String(value));
101
+ }
102
+ });
103
+
104
+ const response = await httpRequest(
105
+ "services/api/register/initial",
106
+ formData,
107
+ "POST"
108
+ );
109
+
110
+ return new ApacuanaSuccess({
111
+ ...response,
112
+ });
113
+ } catch (error) {
114
+ if (error instanceof ApacuanaAPIError) {
115
+ throw error;
116
+ }
117
+ throw new ApacuanaAPIError(
118
+ `Unexpected failure creating user: ${error.message || "Unknown error"}`
119
+ );
120
+ }
121
+ };
package/src/index.js CHANGED
@@ -1,13 +1,11 @@
1
1
  import { setConfig, getConfig, close } from "./config/index";
2
2
  import { initHttpClient, setAuthToken } from "./utils/httpClient";
3
- import getCustomer from "./api/users";
4
3
  import { requestRevocation, getRevocationReasons } from "./api/revocations";
5
4
  import {
6
5
  generateCert,
7
6
  getCertStatus,
8
7
  getCertTypes,
9
8
  getRequerimentsByTypeUser,
10
- requestCertificate,
11
9
  } from "./api/certs";
12
10
  import {
13
11
  addSigner,
@@ -24,44 +22,59 @@ import {
24
22
  } from "./api/faceLiveness";
25
23
  import ApacuanaSuccess from "./success/index";
26
24
  import { ApacuanaAPIError } from "./errors/index";
25
+ import { createApacuanaUser, getCustomer } from "./api/users";
26
+
27
+ /**
28
+ * Valida si el SDK está inicializado y si se dispone de un customerId.
29
+ * @param {boolean} requiresCustomerId - Indica si la operación necesita un customerId.
30
+ * @throws {ApacuanaAPIError} Si el SDK no está inicializado o el customerId es requerido y no está presente.
31
+ */
32
+ const checkSdk = (requiresCustomerId = true) => {
33
+ const config = getConfig();
34
+
35
+ if (!config || !config.apiUrl) {
36
+ throw new ApacuanaAPIError(
37
+ "El SDK no está inicializado. Llama a apacuana.init() primero.",
38
+ 400,
39
+ "NOT_INITIALIZED_ERROR"
40
+ );
41
+ }
42
+
43
+ if (requiresCustomerId && !config.customerId) {
44
+ throw new ApacuanaAPIError(
45
+ "Se requiere un CustomerId para esta operación. Por favor, inicia sesión.",
46
+ 403,
47
+ "CUSTOMER_ID_REQUIRED"
48
+ );
49
+ }
50
+ };
27
51
 
28
52
  const apacuana = {
29
53
  /**
30
- * Inicializa el Apacuana SDK con la configuración necesaria y obtiene
31
- * los detalles del usuario.
32
- * @param {object} config - Objeto de configuración.
33
- * @param {string} config.apiUrl - La URL base de la API de Apacuana.
34
- * @param {string} config.secretKey - La clave secreta para la autenticación.
35
- * @param {string} config.apiKey - La clave de API para la autenticación.
36
- * @param {string} config.verificationId - El ID de verificación del usuario.
37
- * @param {string} config.customerId - El ID del cliente.
38
- * @param {string} config.integrationType - El tipo de integración ('onpremise' o 'onboarding').
39
- * @returns {Promise<object>} retorna los detalles del usuario si la inicialización es exitosa.
54
+ * Inicializa el Apacuana SDK con la configuración necesaria.
40
55
  */
41
56
  init: async (config) => {
42
57
  try {
43
58
  setConfig(config);
44
59
  initHttpClient();
45
60
  const currentConfig = getConfig();
46
- if (!currentConfig.customerId) {
47
- throw new ApacuanaAPIError(
48
- "Apacuana SDK: La configuración de CustomerId no se ha guardado" +
49
- " correctamente.",
50
- 400,
51
- { code: "CONFIG_ERROR" }
52
- );
61
+
62
+ if (currentConfig.customerId) {
63
+ const customer = await getCustomer();
64
+ const { token, userData } = customer.data;
65
+ setConfig({ ...currentConfig, token, userData });
66
+ setAuthToken(token);
67
+ return new ApacuanaSuccess({
68
+ initialized: true,
69
+ message: "SDK inicializado con sesión de usuario.",
70
+ });
53
71
  }
54
72
 
55
- const customer = await getCustomer();
56
- const { token, userData } = customer.data;
57
- setConfig({ ...currentConfig, token, userData });
58
- setAuthToken(token);
59
73
  return new ApacuanaSuccess({
60
74
  initialized: true,
61
- message: "SDK inicializado correctamente.",
75
+ message: "SDK inicializado para operaciones públicas (sin customerId).",
62
76
  });
63
77
  } catch (error) {
64
- // eslint-disable-next-line no-console
65
78
  console.error("Error durante la inicialización del SDK:", error);
66
79
  if (error instanceof ApacuanaAPIError) {
67
80
  throw error;
@@ -74,28 +87,83 @@ const apacuana = {
74
87
  }
75
88
  },
76
89
 
77
- /**
78
- * Permite obtener la configuración actual del SDK.
79
- */
90
+ // --- Métodos de Revocación ---
91
+ requestRevocation: (data) => {
92
+ checkSdk(true);
93
+ return requestRevocation(data);
94
+ },
95
+ getRevocationReasons: () => {
96
+ checkSdk(true);
97
+ return getRevocationReasons();
98
+ },
99
+
100
+ // --- Métodos de Certificados ---
101
+ generateCert: (data) => {
102
+ checkSdk(true);
103
+ return generateCert(data);
104
+ },
105
+ getCertStatus: (isCertificateInDevice) => {
106
+ checkSdk(true);
107
+ return getCertStatus(isCertificateInDevice);
108
+ },
109
+ getCertTypes: () => {
110
+ checkSdk(false);
111
+ return getCertTypes();
112
+ },
113
+ getRequerimentsByTypeUser: (data) => {
114
+ checkSdk(false);
115
+ return getRequerimentsByTypeUser(data);
116
+ },
117
+
118
+ // --- Métodos de Firmas y Documentos ---
119
+ addSigner: (data) => {
120
+ checkSdk(true);
121
+ return addSigner(data);
122
+ },
123
+ deleteSignatureVariant: () => {
124
+ checkSdk(true);
125
+ return deleteSignatureVariant();
126
+ },
127
+ getDigest: (data) => {
128
+ checkSdk(true);
129
+ return getDigest(data);
130
+ },
131
+ getDocs: (data) => {
132
+ checkSdk(true);
133
+ return getDocs(data);
134
+ },
135
+ getSignatureVariant: () => {
136
+ checkSdk(true);
137
+ return getSignatureVariant();
138
+ },
139
+ signDocument: (data) => {
140
+ checkSdk(true);
141
+ return signDocument(data);
142
+ },
143
+ uploadSignatureVariant: (data) => {
144
+ checkSdk(true);
145
+ return uploadSignatureVariant(data);
146
+ },
147
+
148
+ getCustomer: () => {
149
+ checkSdk(true);
150
+ return getCustomer();
151
+ },
152
+ createFaceLivenessSession: () => {
153
+ checkSdk(true);
154
+ return createFaceLivenessSession();
155
+ },
156
+ createApacuanaUser: (data) => {
157
+ checkSdk(false);
158
+ return createApacuanaUser(data);
159
+ },
160
+ validateFaceLiveness: (data) => {
161
+ checkSdk(true);
162
+ return validateFaceLiveness(data);
163
+ },
164
+
80
165
  close: () => close(),
81
166
  getConfig,
82
- requestRevocation,
83
- getCertStatus,
84
- getCustomer,
85
- addSigner,
86
- getDocs,
87
- generateCert,
88
- signDocument,
89
- getDigest,
90
- getRevocationReasons,
91
- uploadSignatureVariant,
92
- getSignatureVariant,
93
- deleteSignatureVariant,
94
- getCertTypes,
95
- getRequerimentsByTypeUser,
96
- createFaceLivenessSession,
97
- validateFaceLiveness,
98
- requestCertificate,
99
167
  };
100
168
 
101
169
  export default apacuana;
@@ -1,45 +1,62 @@
1
1
  /**
2
- * @typedef {object} GenerateCertResponse
3
- * @property {string} cert - El certificado generado en formato string.
4
- * @property {string} certifiedid - El ID del certificado generado.
5
- * @property {boolean} success - Indica si la operación fue exitosa.
2
+ * @typedef {import('../success').ApacuanaSuccess} ApacuanaSuccess
6
3
  */
7
4
 
5
+ // Tipos de datos para las respuestas
8
6
  /**
9
- * @typedef {object} GetCertStatusResponse
10
- * @property {string} status - El estado actual del certificado del usuario.
11
- * @property {boolean} success - Indica si la operación fue exitosa.
7
+ * @typedef {object} GenerateCertResponseData
8
+ * @property {string} cert - El certificado generado en formato string.
9
+ * @property {string} certifiedid - El ID del certificado generado.
12
10
  */
13
-
14
11
  /**
15
- * @typedef {object} EncryptedCSRObject
16
- * @property {string} csr - The encrypted Certificate Signing Request.
12
+ * @typedef {object} GetCertStatusResponseData
13
+ * @property {string} status - El estado actual del certificado del usuario.
17
14
  */
18
-
19
15
  /**
20
16
  * @typedef {object} CertType
21
17
  * @property {string} id - The ID of the certificate type.
22
18
  * @property {string} name - The name of the certificate type.
23
19
  */
24
-
25
20
  /**
26
- * @typedef {object} GetCertTypesResponse
21
+ * @typedef {object} GetCertTypesResponseData
27
22
  * @property {Array<CertType>} types - A list of available certificate types.
28
- * @property {boolean} success - Indicates if the operation was successful.
29
23
  */
30
-
31
24
  /**
32
25
  * @typedef {object} Requirement
33
26
  * @property {string} id - The ID of the requirement.
34
27
  * @property {string} description - The description of the requirement.
35
28
  */
36
-
37
29
  /**
38
- * @typedef {object} GetRequirementsResponse
30
+ * @typedef {object} GetRequirementsResponseData
39
31
  * @property {Array<Requirement>} requirements - A list of requirements for the user type.
40
- * @property {boolean} success - Indicates if the operation was successful.
32
+ */
33
+ /**
34
+ * @typedef {object} RequestCertificateResponseData
35
+ * @property {string} message - A message confirming the request.
41
36
  */
42
37
 
38
+ // Tipos de respuesta combinados con ApacuanaSuccess
39
+ /**
40
+ * @typedef {GenerateCertResponseData & ApacuanaSuccess} GenerateCertResponse
41
+ */
42
+ /**
43
+ * @typedef {GetCertStatusResponseData & ApacuanaSuccess} GetCertStatusResponse
44
+ */
45
+ /**
46
+ * @typedef {GetCertTypesResponseData & ApacuanaSuccess} GetCertTypesResponse
47
+ */
48
+ /**
49
+ * @typedef {GetRequirementsResponseData & ApacuanaSuccess} GetRequirementsResponse
50
+ */
51
+ /**
52
+ * @typedef {RequestCertificateResponseData & ApacuanaSuccess} RequestCertificateResponse
53
+ */
54
+
55
+ // Otros tipos de datos
56
+ /**
57
+ * @typedef {object} EncryptedCSRObject
58
+ * @property {string} csr - The encrypted Certificate Signing Request.
59
+ */
43
60
  /**
44
61
  * @typedef {object} CertificateRequestParams
45
62
  * @property {number} type - The user type to get requirements for.
@@ -47,10 +64,4 @@
47
64
  * @property {Array<{id: string, file: string}>} documents - The documents required for the certificate.
48
65
  */
49
66
 
50
- /**
51
- * @typedef {object} RequestCertificateResponse
52
- * @property {string} message - A message confirming the request.
53
- * @property {boolean} success - Indicates if the operation was successful.
54
- */
55
-
56
- export {};
67
+ export {};
@@ -27,6 +27,7 @@
27
27
  * @typedef {object} GetDigestData
28
28
  * @property {string} cert - Certificado del firmante en formato base64.
29
29
  * @property {string} signatureId - Identificador único de la firma.
30
+ * @property {File} [document] - Documento a firmar en formato de archivo. Este campo es opcional.
30
31
  */
31
32
 
32
33
  /**
@@ -40,13 +41,15 @@
40
41
  * Define la estructura de datos para añadir un firmante.
41
42
  * @typedef {object} SignerData
42
43
  * @property {string} name - Nombre del firmante.
43
- * @property {string} reference - Referencia o identificador del firmante.
44
44
  * @property {string} typedoc - Tipo de documento de identidad del firmante.
45
45
  * @property {string} doc - Número de documento de identidad del firmante.
46
46
  * @property {Array<SignaturePlacement>} signature - Array con las coordenadas donde se estampará la firma.
47
+ * @property {string} [reference] - Referencia a un documento pre-cargado. Se debe proporcionar 'reference' o 'file', pero no ambos.
48
+ * @property {File} [file] - Archivo del documento a firmar. Se debe proporcionar 'reference' o 'file', pero no ambos.
47
49
  */
48
50
 
49
51
  /**
52
+ * Define la estructura de datos para la respuesta de la creación de una firma.
50
53
  * @typedef {object} GetDigestResponseData
51
54
  * @property {string} digest - El digest del documento que se va a firmar.
52
55
  */
@@ -86,6 +89,8 @@
86
89
  * @property {Array<object>} signature.positions - Posiciones de la firma.
87
90
  * @property {string} cert - Certificado en base64.
88
91
  * @property {string} signedDigest - Digest firmado.
92
+ * @property {File} [document] - Documento a firmar en formato de archivo. Este campo es opcional.
93
+
89
94
  */
90
95
 
91
96
  export {};