apacuana-sdk-core 0.4.0 → 0.6.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 (39) hide show
  1. package/README.md +90 -55
  2. package/coverage/clover.xml +140 -119
  3. package/coverage/coverage-final.json +6 -6
  4. package/coverage/lcov-report/index.html +27 -27
  5. package/coverage/lcov-report/src/api/certs.js.html +40 -4
  6. package/coverage/lcov-report/src/api/index.html +19 -19
  7. package/coverage/lcov-report/src/api/revocations.js.html +21 -3
  8. package/coverage/lcov-report/src/api/signatures.js.html +433 -148
  9. package/coverage/lcov-report/src/api/users.js.html +24 -3
  10. package/coverage/lcov-report/src/config/index.html +1 -1
  11. package/coverage/lcov-report/src/config/index.js.html +1 -1
  12. package/coverage/lcov-report/src/errors/index.html +1 -1
  13. package/coverage/lcov-report/src/errors/index.js.html +1 -1
  14. package/coverage/lcov-report/src/index.html +1 -1
  15. package/coverage/lcov-report/src/index.js.html +9 -3
  16. package/coverage/lcov-report/src/utils/constant.js.html +3 -3
  17. package/coverage/lcov-report/src/utils/helpers.js.html +143 -8
  18. package/coverage/lcov-report/src/utils/httpClient.js.html +1 -1
  19. package/coverage/lcov-report/src/utils/index.html +15 -15
  20. package/coverage/lcov.info +250 -202
  21. package/dist/api/certs.d.ts +17 -3
  22. package/dist/api/revocations.d.ts +17 -2
  23. package/dist/api/signatures.d.ts +120 -12
  24. package/dist/api/users.d.ts +22 -6
  25. package/dist/index.d.ts +4 -0
  26. package/dist/index.js +405 -92
  27. package/dist/index.js.map +1 -1
  28. package/dist/index.mjs +405 -92
  29. package/dist/index.mjs.map +1 -1
  30. package/dist/utils/helpers.d.ts +2 -0
  31. package/package.json +1 -1
  32. package/src/api/certs.js +14 -2
  33. package/src/api/revocations.js +7 -1
  34. package/src/api/signatures.js +195 -100
  35. package/src/api/users.js +8 -1
  36. package/src/index.js +3 -1
  37. package/src/utils/constant.js +2 -2
  38. package/src/utils/helpers.js +45 -0
  39. package/tests/api/signatures.test.js +11 -4
@@ -7,6 +7,7 @@ declare namespace _default {
7
7
  export { validateCsr };
8
8
  export { validateGetDocsData };
9
9
  export { validateGetDigestData };
10
+ export { validateOnBoardingSignDocumentData };
10
11
  }
11
12
  export default _default;
12
13
  declare function getCertificateStatus(userData: any, certificateInDevice: any): string;
@@ -19,3 +20,4 @@ declare function validateOnBoardingSignerData(signerData: any): void;
19
20
  declare function validateCsr(csr: any): void;
20
21
  declare function validateGetDocsData(data: any): void;
21
22
  declare function validateGetDigestData(signData: any): void;
23
+ declare function validateOnBoardingSignDocumentData(signData: any): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apacuana-sdk-core",
3
- "version": "0.4.0",
3
+ "version": "0.6.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
@@ -4,6 +4,18 @@ import helpers from "../utils/helpers";
4
4
  import { ApacuanaAPIError } from "../errors";
5
5
  import { INTEGRATION_TYPE } from "../utils/constant";
6
6
 
7
+ /**
8
+ * @typedef {object} GenerateCertResponse
9
+ * @property {string} cert - El certificado generado en formato string.
10
+ * @property {boolean} success - Indica si la operación fue exitosa.
11
+ */
12
+
13
+ /**
14
+ * @typedef {object} GetCertStatusResponse
15
+ * @property {string} status - El estado actual del certificado del usuario.
16
+ * @property {boolean} success - Indica si la operación fue exitosa.
17
+ */
18
+
7
19
  const generateCertOnBoarding = async (csr = undefined) => {
8
20
  try {
9
21
  const encryptedCSR = helpers.encryptedCsr(csr);
@@ -43,7 +55,7 @@ const generateCertOnPremise = async () => {
43
55
  /**
44
56
  * Generates a digital certificate.
45
57
  * @param {string} [csr] - Certificate Signing Request (CSR).
46
- * @returns {Promise<{cert: string, success: boolean}>} Object with the generated certificate and a success indicator.
58
+ * @returns {Promise<GenerateCertResponse>} Object with the generated certificate and a success indicator.
47
59
  * @throws {ApacuanaAPIError} If the CSR is invalid, if the API response does not contain the certificate, or if the integration type is not supported.
48
60
  * @throws {Error} If certificate generation fails for another reason.
49
61
  */
@@ -67,7 +79,7 @@ export const generateCert = async (csr = undefined) => {
67
79
  /**
68
80
  * Gets the user's certificate status.
69
81
  * @param {boolean} [isCertificateInDevice=false] - Indicates if the certificate is already on the device.
70
- * @returns {{status: string, success: boolean}} Object with the certificate status and a success indicator.
82
+ * @returns {GetCertStatusResponse} Object with the certificate status and a success indicator.
71
83
  */
72
84
  export const getCertStatus = (isCertificateInDevice = false) => {
73
85
  const config = getConfig();
@@ -1,10 +1,16 @@
1
1
  import { httpRequest } from "../utils/httpClient";
2
2
  import { ApacuanaAPIError } from "../errors/index";
3
3
 
4
+ /**
5
+ * @typedef {object} RequestRevocationResponse
6
+ * @property {string} revocationStatus - El estado de la solicitud de revocación (e.g., "pending").
7
+ * @property {string|number} requestId - El ID de la solicitud de revocación.
8
+ */
9
+
4
10
  /**
5
11
  * Simula la solicitud de revocación de un certificado.
6
12
  * @param {string} reasonCode - Código o descripción del motivo de la revocación.
7
- * @returns {Promise<object>} Objeto con el estado de la solicitud de revocación.
13
+ * @returns {Promise<RequestRevocationResponse>} Objeto con el estado de la solicitud de revocación.
8
14
  */
9
15
  const requestRevocation = async (reasonCode) => {
10
16
  console.log("-> Función 'requestRevocation' ejecutada.");
@@ -5,43 +5,113 @@ import { ApacuanaAPIError } from "../errors";
5
5
  import helpers from "../utils/helpers";
6
6
  import { INTEGRATION_TYPE } from "../utils/constant";
7
7
 
8
- const signDocumentOnBoarding = async () => {
9
- throw new ApacuanaAPIError(
10
- "Document signing is not supported for integration type: ONBOARDING",
11
- 501,
12
- "NOT_IMPLEMENTED"
13
- );
14
- };
8
+ // =================================================================
9
+ // Type Definitions
10
+ // =================================================================
15
11
 
16
- const signDocumentOnPremise = async () => {
17
- throw new ApacuanaAPIError(
18
- "Document signing is not supported for integration type: ONPREMISE",
19
- 501,
20
- "NOT_IMPLEMENTED"
21
- );
22
- };
12
+ /**
13
+ * Define la estructura de un objeto Firmante.
14
+ * @typedef {object} Signer
15
+ * @property {string} name - Nombre completo del firmante.
16
+ * @property {string} email - Correo electrónico del firmante.
17
+ * @property {string} document - Documento de identidad del firmante.
18
+ */
23
19
 
24
20
  /**
25
- * Signs a PDF document with a digital certificate.
26
- * @param {object} data - Data for the signature. For 'on-boarding', it must contain {documentData, signatureData}. For 'on-premise', it must contain {signature, cert, privateKey}.
27
- * @returns {Promise<{digest: string}>} Object with the document's digest.
28
- * @throws {ApacuanaAPIError} If the integration type is not supported or the function is not implemented for the integration type.
21
+ * Define la estructura de datos para añadir un firmante.
22
+ * @typedef {object} SignerData
23
+ * @property {string} docId - Identificador único del documento.
24
+ * @property {Signer} signer - Objeto con la información del firmante.
29
25
  */
30
- export const signDocument = async () => {
31
- const { integrationType } = getConfig();
32
26
 
33
- if (integrationType === INTEGRATION_TYPE.ONBOARDING) {
34
- return signDocumentOnBoarding();
35
- }
27
+ /**
28
+ * Define la estructura de la respuesta al añadir un firmante.
29
+ * @typedef {object} AddSignerResponse
30
+ * @property {string} signer - Identificador de confirmación del firmante añadido.
31
+ * @property {boolean} success - Indica si la operación fue exitosa.
32
+ */
36
33
 
37
- if (integrationType === INTEGRATION_TYPE.ONPREMISE) {
38
- return signDocumentOnPremise();
34
+ /**
35
+ * Define la estructura de datos para obtener el digest de un documento.
36
+ * @typedef {object} GetDigestData
37
+ * @property {string} cert - Certificado del firmante en formato base64.
38
+ * @property {string} signatureId - Identificador único del proceso de firma.
39
+ */
40
+
41
+ /**
42
+ * Define la estructura de la respuesta al obtener el digest.
43
+ * @typedef {object} GetDigestResponse
44
+ * @property {string} digest - El digest del documento que se va a firmar.
45
+ * @property {boolean} success - Indica si la operación fue exitosa.
46
+ */
47
+
48
+ /**
49
+ * Define la estructura de los parámetros para obtener documentos.
50
+ * @typedef {object} GetDocsParams
51
+ * @property {number} page - Número de página para la paginación.
52
+ * @property {number} size - Cantidad de registros por página.
53
+ * @property {string} [status] - (Opcional) Estado para filtrar los documentos.
54
+ */
55
+
56
+ /**
57
+ * Define la estructura de la respuesta al obtener documentos.
58
+ * @typedef {object} GetDocsResponse
59
+ * @property {number} totalRecords - El número total de registros encontrados.
60
+ * @property {Array<object>} records - Un arreglo con los registros de los documentos.
61
+ * @property {boolean} success - Indica si la operación fue exitosa.
62
+ */
63
+
64
+ /**
65
+ * @typedef {object} SignDocumentData
66
+ * @property {object} signature - Objeto con información de la firma.
67
+ * @property {string} signature.id - ID de la firma.
68
+ * @property {Array<object>} signature.positions - Posiciones de la firma.
69
+ * @property {string} cert - Certificado en base64.
70
+ * @property {string} signedDigest - Digest firmado.
71
+ */
72
+
73
+ // =================================================================
74
+ // Internal Functions
75
+ // =================================================================
76
+
77
+ const signDocumentOnBoarding = async (signData) => {
78
+ helpers.validateOnBoardingSignDocumentData(signData);
79
+ const { signature, cert, signedDigest } = signData;
80
+ try {
81
+ const signBody = {
82
+ positions: JSON.stringify(
83
+ signature.positions.map((p) => ({
84
+ x: p.x,
85
+ y: p.y,
86
+ page: p.page,
87
+ status: 1,
88
+ }))
89
+ ),
90
+ publickey: cert,
91
+ signeddigest: signedDigest,
92
+ };
93
+
94
+ const response = await httpRequest(
95
+ `services/api/documents/sign/${signature.id}`,
96
+ signBody,
97
+ "PUT"
98
+ );
99
+ return response;
100
+ } catch (error) {
101
+ if (error instanceof ApacuanaAPIError) {
102
+ throw error;
103
+ }
104
+ throw new ApacuanaAPIError(
105
+ `Failed to sign document: ${error.message || "Unknown error"}`
106
+ );
39
107
  }
108
+ };
40
109
 
110
+ const signDocumentOnPremise = async () => {
41
111
  throw new ApacuanaAPIError(
42
- `Unsupported integration type: ${integrationType}`,
43
- 400,
44
- "UNSUPPORTED_INTEGRATION_TYPE"
112
+ "Document signing is not supported for integration type: ONPREMISE",
113
+ 501,
114
+ "NOT_IMPLEMENTED"
45
115
  );
46
116
  };
47
117
 
@@ -82,45 +152,16 @@ const getDigestToSignOnPremise = async () => {
82
152
  );
83
153
  };
84
154
 
85
- /**
86
- * Gets the digest of a document to be signed.
87
- * @param {object} signData - Data for the signature. Must contain { cert, signatureId }.
88
- * @returns {Promise<{digest: string, success: boolean}>} Object with the document's digest.
89
- * @throws {ApacuanaAPIError} If the input data is invalid, if the API call fails, or if the integration type is not supported.
90
- */
91
- export const getDigest = async (signData) => {
92
- helpers.validateGetDigestData(signData);
93
-
94
- const { integrationType } = getConfig();
95
-
96
- if (integrationType === INTEGRATION_TYPE.ONBOARDING) {
97
- return getDigestToSignOnBoarding(signData);
98
- }
99
-
100
- if (integrationType === INTEGRATION_TYPE.ONPREMISE) {
101
- return getDigestToSignOnPremise();
102
- }
103
-
104
- throw new ApacuanaAPIError(
105
- `Document retrieval is not supported for an unknown integration type: ${integrationType}`,
106
- 501,
107
- "NOT_IMPLEMENTED"
108
- );
109
- };
110
-
111
155
  const addSignerOnBoarding = async (signerData) => {
112
156
  helpers.validateOnBoardingSignerData(signerData);
113
157
  try {
114
- // Current httpRequest logic is moved here
115
158
  await httpRequest("services/api/documents/signing", signerData, "POST");
116
159
  return { signer: signerData.typedoc + signerData.doc, success: true };
117
160
  } catch (error) {
118
161
  if (error instanceof ApacuanaAPIError) {
119
162
  throw error;
120
163
  }
121
- throw new Error(
122
- `Failed to add signer in On-Boarding: ${error.message}`
123
- );
164
+ throw new Error(`Failed to add signer in On-Boarding: ${error.message}`);
124
165
  }
125
166
  };
126
167
 
@@ -132,45 +173,9 @@ const addSignerOnPremise = async () => {
132
173
  );
133
174
  };
134
175
 
135
- /**
136
- * Adds a signer to a document, handling different integration types.
137
- * @param {object} signerData - Data of the signer to be added.
138
- * @returns {Promise<{signer: string, success: boolean}>} Object with the result of adding the signer.
139
- * @throws {ApacuanaAPIError} If the signer data is invalid, if the API call fails, or if the integration type is not supported.
140
- */
141
- export const addSigner = async (signerData) => {
142
- if (
143
- !signerData ||
144
- typeof signerData !== "object" ||
145
- Object.keys(signerData).length === 0
146
- ) {
147
- throw new ApacuanaAPIError(
148
- "Signer data (signerData) is required and must be a non-empty object.",
149
- 400,
150
- "INVALID_PARAMETER"
151
- );
152
- }
153
-
154
- const { integrationType } = getConfig();
155
-
156
- if (integrationType === INTEGRATION_TYPE.ONBOARDING) {
157
- return addSignerOnBoarding(signerData);
158
- }
159
-
160
- if (integrationType === INTEGRATION_TYPE.ONPREMISE) {
161
- return addSignerOnPremise(signerData);
162
- }
163
-
164
- throw new ApacuanaAPIError(
165
- `Unsupported integration type: ${integrationType}`,
166
- 400,
167
- "UNSUPPORTED_INTEGRATION_TYPE"
168
- );
169
- };
170
-
171
176
  const getDocsOnPremise = async () => {
172
177
  throw new ApacuanaAPIError(
173
- "Document retrieval is not supported for integration type: ONBOARDING",
178
+ "Document retrieval is not supported for integration type: ONPREMISE",
174
179
  501,
175
180
  "NOT_IMPLEMENTED"
176
181
  );
@@ -209,16 +214,106 @@ const getDocsOnBoarding = async (data) => {
209
214
  throw error;
210
215
  }
211
216
  throw new ApacuanaAPIError(
212
- `Failed to get document list (on-premise): ${error.message}`
217
+ `Failed to get document list (on-boarding): ${error.message}`
218
+ );
219
+ }
220
+ };
221
+
222
+ // =================================================================
223
+ // Exported Functions
224
+ // =================================================================
225
+
226
+ /**
227
+ * Firma un documento PDF con un certificado digital.
228
+ * NOTA: Esta función no está implementada actualmente para ningún tipo de integración.
229
+ * @param {SignDocumentData} signData - Datos necesarios para la firma.
230
+ * @returns {Promise<object>}
231
+ * @throws {ApacuanaAPIError} Arroja un error 'NOT_IMPLEMENTED' para cualquier tipo de integración.
232
+ */
233
+ export const signDocument = async (signData) => {
234
+ const { integrationType } = getConfig();
235
+
236
+ if (integrationType === INTEGRATION_TYPE.ONBOARDING) {
237
+ return signDocumentOnBoarding(signData);
238
+ }
239
+
240
+ if (integrationType === INTEGRATION_TYPE.ONPREMISE) {
241
+ return signDocumentOnPremise();
242
+ }
243
+
244
+ throw new ApacuanaAPIError(
245
+ `Unsupported integration type: ${integrationType}`,
246
+ 400,
247
+ "UNSUPPORTED_INTEGRATION_TYPE"
248
+ );
249
+ };
250
+
251
+ /**
252
+ * Obtiene el digest de un documento para ser firmado.
253
+ * @param {GetDigestData} signData - Datos requeridos para obtener el digest.
254
+ * @returns {Promise<GetDigestResponse>} Una promesa que resuelve a un objeto con el digest del documento.
255
+ * @throws {ApacuanaAPIError} Si los datos de entrada son inválidos, la llamada a la API falla, o el tipo de integración no es soportado.
256
+ */
257
+ export const getDigest = async (signData) => {
258
+ helpers.validateGetDigestData(signData);
259
+
260
+ const { integrationType } = getConfig();
261
+
262
+ if (integrationType === INTEGRATION_TYPE.ONBOARDING) {
263
+ return getDigestToSignOnBoarding(signData);
264
+ }
265
+
266
+ if (integrationType === INTEGRATION_TYPE.ONPREMISE) {
267
+ return getDigestToSignOnPremise();
268
+ }
269
+
270
+ throw new ApacuanaAPIError(
271
+ `Document retrieval is not supported for an unknown integration type: ${integrationType}`,
272
+ 501,
273
+ "NOT_IMPLEMENTED"
274
+ );
275
+ };
276
+
277
+ /**
278
+ * Añade un firmante a un documento.
279
+ * @param {SignerData} signerData - Los datos del firmante que se va a añadir.
280
+ * @returns {Promise<AddSignerResponse>} Una promesa que resuelve a un objeto con el resultado de la operación.
281
+ * @throws {ApacuanaAPIError} Si los datos del firmante son inválidos, la llamada a la API falla, o el tipo de integración no es soportado.
282
+ */
283
+ export const addSigner = async (signerData) => {
284
+ if (
285
+ !signerData ||
286
+ typeof signerData !== "object" ||
287
+ Object.keys(signerData).length === 0
288
+ ) {
289
+ throw new ApacuanaAPIError(
290
+ "Signer data (signerData) is required and must be a non-empty object.",
291
+ 400,
292
+ "INVALID_PARAMETER"
213
293
  );
214
294
  }
295
+ const { integrationType } = getConfig();
296
+
297
+ if (integrationType === INTEGRATION_TYPE.ONBOARDING) {
298
+ return addSignerOnBoarding(signerData);
299
+ }
300
+
301
+ if (integrationType === INTEGRATION_TYPE.ONPREMISE) {
302
+ return addSignerOnPremise();
303
+ }
304
+
305
+ throw new ApacuanaAPIError(
306
+ `Unsupported integration type: ${integrationType}`,
307
+ 400,
308
+ "UNSUPPORTED_INTEGRATION_TYPE"
309
+ );
215
310
  };
216
311
 
217
312
  /**
218
- * Gets a list of documents.
219
- * @param {object} data - Object with pagination parameters. Must contain {page, size}.
220
- * @returns {Promise<{totalRecords: number, records:any[], success: boolean}>} Object with the list of documents.
221
- * @throws {ApacuanaAPIError} If pagination parameters are invalid, if 'customerId' is not configured, if the API call fails, or if the integration type is not supported.
313
+ * Obtiene una lista de documentos basada en los filtros especificados.
314
+ * @param {GetDocsParams} data - Objeto con parámetros de paginación y filtros.
315
+ * @returns {Promise<GetDocsResponse>} Una promesa que resuelve a un objeto con la lista de documentos.
316
+ * @throws {ApacuanaAPIError} Si los parámetros de paginación son inválidos, 'customerId' no está configurado, la llamada a la API falla, o el tipo de integración no es soportado.
222
317
  */
223
318
  export const getDocs = async (data) => {
224
319
  helpers.validateGetDocsData(data);
package/src/api/users.js CHANGED
@@ -2,12 +2,19 @@ import { httpRequest } from "../utils/httpClient";
2
2
  import { ApacuanaAPIError } from "../errors/index";
3
3
  import { getConfig } from "../config/index";
4
4
 
5
+ /**
6
+ * @typedef {object} GetCustomerResponse
7
+ * @property {string} token - El token de sesión del usuario.
8
+ * @property {object} userData - Los datos del usuario obtenidos.
9
+ * @property {boolean} success - Indica si la operación fue exitosa.
10
+ */
11
+
5
12
  /**
6
13
  * Obtiene el token de un usuario a través de una petición POST.
7
14
  * Este método es útil para endpoints que requieren datos en el cuerpo de la petición
8
15
  * para buscar un usuario, como un ID de sesión o un token de acceso.
9
16
  *
10
- * @returns {Promise<{token: string, userData: object, success: boolean}>} Objeto con el token de sesión, los datos del usuario y un indicador de éxito.
17
+ * @returns {Promise<GetCustomerResponse>} Objeto con el token de sesión, los datos del usuario y un indicador de éxito.
11
18
  * @throws {Error} Si los parámetros de entrada son inválidos.
12
19
  * @throws {ApacuanaAPIError} Si ocurre un error en la API de Apacuana.
13
20
  */
package/src/index.js CHANGED
@@ -3,7 +3,7 @@ import { initHttpClient, setAuthToken } from "./utils/httpClient";
3
3
  import getCustomer from "./api/users";
4
4
  import requestRevocation from "./api/revocations";
5
5
  import { generateCert, getCertStatus } from "./api/certs";
6
- import { addSigner, getDocs } from "./api/signatures";
6
+ import { addSigner, getDigest, getDocs, signDocument } from "./api/signatures";
7
7
 
8
8
  const apacuana = {
9
9
  /**
@@ -66,6 +66,8 @@ const apacuana = {
66
66
  addSigner,
67
67
  getDocs,
68
68
  generateCert,
69
+ signDocument,
70
+ getDigest,
69
71
  };
70
72
 
71
73
  export default apacuana;
@@ -15,6 +15,6 @@ export const VERIFICATION_STATUS = {
15
15
  };
16
16
 
17
17
  export const INTEGRATION_TYPE = {
18
- ONBOARDING: 'onboarding',
19
- ONPREMISE: 'onpremise',
18
+ ONBOARDING: "ONBOARDING",
19
+ ONPREMISE: "ONPREMISE",
20
20
  };
@@ -212,6 +212,50 @@ const validateGetDigestData = (signData) => {
212
212
  }
213
213
  };
214
214
 
215
+ const validateOnBoardingSignDocumentData = (signData) => {
216
+ if (!signData || typeof signData !== "object") {
217
+ throw new ApacuanaAPIError(
218
+ "Sign data is required and must be an object.",
219
+ 400,
220
+ "INVALID_PARAMETER"
221
+ );
222
+ }
223
+
224
+ const { signature, cert, signedDigest } = signData;
225
+
226
+ if (!signature || typeof signature !== "object" || !signature.id) {
227
+ throw new ApacuanaAPIError(
228
+ "Signature object with an 'id' property is required.",
229
+ 400,
230
+ "INVALID_PARAMETER"
231
+ );
232
+ }
233
+
234
+ if (!Array.isArray(signature.positions)) {
235
+ throw new ApacuanaAPIError(
236
+ "Signature 'positions' must be an array.",
237
+ 400,
238
+ "INVALID_PARAMETER"
239
+ );
240
+ }
241
+
242
+ if (!cert || typeof cert !== "string") {
243
+ throw new ApacuanaAPIError(
244
+ "Certificate 'cert' is required and must be a string.",
245
+ 400,
246
+ "INVALID_PARAMETER"
247
+ );
248
+ }
249
+
250
+ if (!signedDigest || typeof signedDigest !== "string") {
251
+ throw new ApacuanaAPIError(
252
+ "Signed digest 'signedDigest' is required and must be a string.",
253
+ 400,
254
+ "INVALID_PARAMETER"
255
+ );
256
+ }
257
+ };
258
+
215
259
  export default {
216
260
  getCertificateStatus,
217
261
  exportPrivateKey,
@@ -221,4 +265,5 @@ export default {
221
265
  validateCsr,
222
266
  validateGetDocsData,
223
267
  validateGetDigestData,
268
+ validateOnBoardingSignDocumentData,
224
269
  };
@@ -1,7 +1,12 @@
1
1
  import { getConfig } from "../../src/config";
2
2
  import { httpRequest } from "../../src/utils/httpClient";
3
3
  import { ApacuanaAPIError } from "../../src/errors";
4
- import { addSigner, getDocs, getDigest, signDocument } from "../../src/api/signatures";
4
+ import {
5
+ addSigner,
6
+ getDocs,
7
+ getDigest,
8
+ signDocument,
9
+ } from "../../src/api/signatures";
5
10
  import helpers from "../../src/utils/helpers";
6
11
  import { INTEGRATION_TYPE } from "../../src/utils/constant";
7
12
 
@@ -23,7 +28,9 @@ describe("API - Signatures", () => {
23
28
 
24
29
  describe("addSigner", () => {
25
30
  it("should call addSignerOnBoarding for ONBOARDING integration", async () => {
26
- getConfig.mockReturnValue({ integrationType: INTEGRATION_TYPE.ONBOARDING });
31
+ getConfig.mockReturnValue({
32
+ integrationType: INTEGRATION_TYPE.ONBOARDING,
33
+ });
27
34
  const signerData = { typedoc: "V", doc: "12345678" };
28
35
  httpRequest.mockResolvedValue({ success: true });
29
36
 
@@ -106,7 +113,7 @@ describe("API - Signatures", () => {
106
113
  httpRequest.mockResolvedValue({ docs: [] });
107
114
 
108
115
  await expect(getDocs(paginationData)).rejects.toThrow(
109
- "Document retrieval is not supported for integration type: ONBOARDING"
116
+ "Document retrieval is not supported for integration type: ONPREMISE"
110
117
  );
111
118
  });
112
119
 
@@ -151,4 +158,4 @@ describe("API - Signatures", () => {
151
158
  );
152
159
  });
153
160
  });
154
- });
161
+ });