apacuana-sdk-core 1.8.0 → 1.10.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 (36) hide show
  1. package/coverage/clover.xml +81 -80
  2. package/coverage/coverage-final.json +4 -4
  3. package/coverage/lcov-report/index.html +10 -10
  4. package/coverage/lcov-report/src/api/certs.js.html +190 -7
  5. package/coverage/lcov-report/src/api/faceLiveness.js.html +1 -1
  6. package/coverage/lcov-report/src/api/index.html +10 -10
  7. package/coverage/lcov-report/src/api/revocations.js.html +1 -1
  8. package/coverage/lcov-report/src/api/signatures.js.html +1 -1
  9. package/coverage/lcov-report/src/api/users.js.html +1 -1
  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 +14 -2
  16. package/coverage/lcov-report/src/success/index.html +1 -1
  17. package/coverage/lcov-report/src/success/index.js.html +1 -1
  18. package/coverage/lcov-report/src/utils/constant.js.html +5 -2
  19. package/coverage/lcov-report/src/utils/helpers.js.html +2 -2
  20. package/coverage/lcov-report/src/utils/httpClient.js.html +1 -1
  21. package/coverage/lcov-report/src/utils/index.html +1 -1
  22. package/coverage/lcov.info +128 -127
  23. package/dist/api/certs.d.ts +2 -0
  24. package/dist/index.js +67 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/index.mjs +67 -1
  27. package/dist/index.mjs.map +1 -1
  28. package/dist/types/certs.d.ts +16 -0
  29. package/dist/utils/constant.d.ts +5 -4
  30. package/dist/utils/helpers.d.ts +1 -1
  31. package/package.json +1 -1
  32. package/src/api/certs.js +62 -1
  33. package/src/index.js +4 -0
  34. package/src/types/certs.js +9 -0
  35. package/src/utils/constant.js +1 -0
  36. package/src/utils/helpers.js +1 -1
@@ -81,3 +81,19 @@ export type CertificateRequestParams = {
81
81
  file: string;
82
82
  }>;
83
83
  };
84
+ export type ValidateCertificateRequestParams = {
85
+ /**
86
+ * - An optional observation for the certificate request.
87
+ */
88
+ challenge?: string | undefined;
89
+ };
90
+ export type ValidateCertificateResponseData = {
91
+ /**
92
+ * - A message confirming the request.
93
+ */
94
+ message: string;
95
+ /**
96
+ * - A boolean confirming the request.
97
+ */
98
+ auth: boolean;
99
+ };
@@ -1,5 +1,6 @@
1
1
  export namespace STATUS_CERTIFICATE {
2
2
  let request: string;
3
+ let request_cert: string;
3
4
  let generate: string;
4
5
  let current: string;
5
6
  let revoque: string;
@@ -13,6 +14,10 @@ export const PARSE_STATUS: {
13
14
  text: string;
14
15
  descriptionText: undefined;
15
16
  };
17
+ [STATUS_CERTIFICATE.request_cert]: {
18
+ text: string;
19
+ descriptionText: string;
20
+ };
16
21
  [STATUS_CERTIFICATE.request]: {
17
22
  text: string;
18
23
  descriptionText: string;
@@ -34,10 +39,6 @@ export const PARSE_STATUS: {
34
39
  text: string;
35
40
  descriptionText: string;
36
41
  };
37
- [STATUS_CERTIFICATE.request_cert]: {
38
- text: string;
39
- descriptionText: string;
40
- };
41
42
  };
42
43
  export namespace VERIFICATION_STATUS {
43
44
  let IN_REGISTER: number;
@@ -11,7 +11,7 @@ declare namespace _default {
11
11
  export { createPayloadGetDigest };
12
12
  }
13
13
  export default _default;
14
- declare function getCertificateStatus(userData: any, certificateInDevice: any, integrationType: any): any;
14
+ declare function getCertificateStatus(userData: any, certificateInDevice: any, integrationType: any): string;
15
15
  declare function exportPrivateKey(key: any): Promise<string>;
16
16
  declare function arrayBufferToBase64(buffer: any): string;
17
17
  declare function encryptedCsr(csr: any, encryptKey?: string): {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apacuana-sdk-core",
3
- "version": "1.8.0",
3
+ "version": "1.10.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
@@ -7,6 +7,8 @@
7
7
  * @typedef {import('../types/certs').GetRequirementsResponse} GetRequirementsResponse
8
8
  * @typedef {import('../types/certs').CertificateRequestParams} CertificateRequestParams
9
9
  * @typedef {import('../types/certs').RequestCertificateResponse} RequestCertificateResponse
10
+ * @typedef {import('../types/certs').ValidateCertificateResponseData} ValidateCertificateResponseData
11
+ * @typedef {import('../types/certs').ValidateCertificateRequestParams} ValidateCertificateRequestParams
10
12
  */
11
13
 
12
14
  import { getConfig } from "../config/index";
@@ -93,7 +95,10 @@ export const getCertStatus = async (isCertificateInDevice = false) => {
93
95
  config.integrationType
94
96
  );
95
97
  const parseStatus = PARSE_STATUS[status];
96
-
98
+ console.log({
99
+ status,
100
+ parseStatus,
101
+ });
97
102
  return new ApacuanaSuccess({ status: parseStatus });
98
103
  };
99
104
 
@@ -257,3 +262,59 @@ export const requestCertificate = async (params) => {
257
262
  "UNSUPPORTED_INTEGRATION_TYPE"
258
263
  );
259
264
  };
265
+
266
+ // const validateCertificateOnBoarding = async (params) => {
267
+ // throw new ApacuanaAPIError(
268
+ // "Requesting a certificate is not supported for integration type: ONBOARDING",
269
+ // 501,
270
+ // "NOT_IMPLEMENTED"
271
+ // );
272
+ // // try {
273
+ // // const response = await httpRequest(
274
+ // // "services/api/customer/request-certificate",
275
+ // // params,
276
+ // // "POST"
277
+ // // );
278
+ // // return new ApacuanaSuccess(response);
279
+ // // } catch (error) {
280
+ // // if (error instanceof ApacuanaAPIError) {
281
+ // // throw error;
282
+ // // }
283
+ // // throw new Error(`Failed to request certificate: ${error.message}`);
284
+ // // }
285
+ // };
286
+
287
+ // const validateCertificateOnPremise = async () => {
288
+ // throw new ApacuanaAPIError(
289
+ // "Requesting a certificate is not supported for integration type: ONPREMISE",
290
+ // 501,
291
+ // "NOT_IMPLEMENTED"
292
+ // );
293
+ // };
294
+
295
+ // /**
296
+ // * Requests a certificate for the user.
297
+ // * @param {ValidateCertificateRequestParams} params - The parameters for the certificate request.
298
+ // * @returns {Promise<ValidateCertificateResponseData>} Object with a confirmation message and a success indicator.
299
+ // * @throws {ApacuanaAPIError} If the API response is invalid or the integration type is not supported.
300
+ // * @throws {Error} If the request fails for another reason or the params are invalid.
301
+ // */
302
+ // export const validateCertificate = async (params) => {
303
+ // if (!params || typeof params.challenge !== "string") {
304
+ // throw new Error("Invalid params.");
305
+ // }
306
+
307
+ // const { integrationType } = getConfig();
308
+ // if (integrationType === INTEGRATION_TYPE.ONBOARDING) {
309
+ // return requestCertificateOnBoarding(params);
310
+ // }
311
+ // if (integrationType === INTEGRATION_TYPE.ONPREMISE) {
312
+ // return requestCertificateOnPremise();
313
+ // }
314
+
315
+ // throw new ApacuanaAPIError(
316
+ // `Unsupported integration type: ${integrationType}`,
317
+ // 400,
318
+ // "UNSUPPORTED_INTEGRATION_TYPE"
319
+ // );
320
+ // };
package/src/index.js CHANGED
@@ -161,6 +161,10 @@ const apacuana = {
161
161
  checkSdk(true);
162
162
  return validateFaceLiveness(data);
163
163
  },
164
+ // validateCertificate: (data) => {
165
+ // checkSdk(true);
166
+ // validateCertificate(data);
167
+ // },
164
168
 
165
169
  close: () => close(),
166
170
  getConfig,
@@ -63,5 +63,14 @@
63
63
  * @property {string} [observation] - An optional observation for the certificate request.
64
64
  * @property {Array<{id: string, file: string}>} documents - The documents required for the certificate.
65
65
  */
66
+ /**
67
+ * @typedef {object} ValidateCertificateRequestParams
68
+ * @property {string} [challenge] - An optional observation for the certificate request.
69
+ */
70
+ /**
71
+ * @typedef {object} ValidateCertificateResponseData
72
+ * @property {string} message - A message confirming the request.
73
+ * @property {boolean} auth - A boolean confirming the request.
74
+ */
66
75
 
67
76
  export {};
@@ -1,5 +1,6 @@
1
1
  export const STATUS_CERTIFICATE = {
2
2
  request: "SOLICITUD",
3
+ request_cert: "REVISION",
3
4
  generate: "GENERAR",
4
5
  current: "VIGENTE",
5
6
  revoque: "REVOCADO",
@@ -33,7 +33,7 @@ const getCertificateStatus = (
33
33
  if (userData?.verificationstatus?.id !== VERIFICATION_STATUS.APPROVED)
34
34
  return STATUS_CERTIFICATE.request;
35
35
  if (
36
- !userData?.certificationId &&
36
+ !userData?.certifiedid &&
37
37
  userData?.requestscert?.requests.length === 0 &&
38
38
  !userData?.certificatestatus?.cangenerate
39
39
  )