apacuana-sdk-core 0.16.0 → 0.17.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 +149 -146
- package/coverage/coverage-final.json +2 -2
- package/coverage/lcov-report/index.html +10 -10
- package/coverage/lcov-report/src/api/certs.js.html +6 -3
- package/coverage/lcov-report/src/api/faceLiveness.js.html +1 -1
- package/coverage/lcov-report/src/api/index.html +1 -1
- package/coverage/lcov-report/src/api/revocations.js.html +1 -1
- package/coverage/lcov-report/src/api/signatures.js.html +1 -1
- package/coverage/lcov-report/src/api/users.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/src/index.js.html +1 -1
- 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 +1 -1
- package/coverage/lcov-report/src/utils/helpers.js.html +111 -39
- package/coverage/lcov-report/src/utils/httpClient.js.html +1 -1
- package/coverage/lcov-report/src/utils/index.html +10 -10
- package/coverage/lcov.info +311 -308
- package/dist/index.js +18 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -13
- package/dist/index.mjs.map +1 -1
- package/dist/utils/helpers.d.ts +1 -1
- package/package.json +1 -1
- package/src/api/certs.js +2 -1
- package/src/utils/helpers.js +54 -30
- package/tests/api/certs.test.js +6 -2
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -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):
|
|
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
package/src/api/certs.js
CHANGED
|
@@ -86,7 +86,8 @@ export const getCertStatus = (isCertificateInDevice = false) => {
|
|
|
86
86
|
const config = getConfig();
|
|
87
87
|
const status = helpers.getCertificateStatus(
|
|
88
88
|
config.userData,
|
|
89
|
-
isCertificateInDevice
|
|
89
|
+
isCertificateInDevice,
|
|
90
|
+
config.integrationType
|
|
90
91
|
);
|
|
91
92
|
const parseStatus = PARSE_STATUS[status];
|
|
92
93
|
|
package/src/utils/helpers.js
CHANGED
|
@@ -1,46 +1,70 @@
|
|
|
1
1
|
import CryptoJS from "crypto-js";
|
|
2
2
|
import { getCrypto } from "pkijs";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
INTEGRATION_TYPE,
|
|
5
|
+
STATUS_CERTIFICATE,
|
|
6
|
+
VERIFICATION_STATUS,
|
|
7
|
+
} from "./constant";
|
|
4
8
|
import { ApacuanaAPIError } from "../errors/index";
|
|
5
9
|
|
|
6
10
|
const KEY_HEX = "dRgUkXp2s5v8y/B?";
|
|
7
11
|
|
|
8
|
-
const getCertificateStatus = (
|
|
12
|
+
const getCertificateStatus = (
|
|
13
|
+
userData,
|
|
14
|
+
certificateInDevice,
|
|
15
|
+
integrationType
|
|
16
|
+
) => {
|
|
9
17
|
if (!userData) {
|
|
10
|
-
throw new
|
|
18
|
+
throw new ApacuanaAPIError(
|
|
19
|
+
"El parámetro userData es requerido.",
|
|
20
|
+
404,
|
|
21
|
+
"INVALID_USER_DATA"
|
|
22
|
+
);
|
|
11
23
|
}
|
|
12
24
|
if (typeof certificateInDevice !== "boolean") {
|
|
13
|
-
throw new
|
|
14
|
-
"El parámetro certificateInDevice es requerido y debe ser un valor booleano."
|
|
25
|
+
throw new ApacuanaAPIError(
|
|
26
|
+
"El parámetro certificateInDevice es requerido y debe ser un valor booleano.",
|
|
27
|
+
404,
|
|
28
|
+
"INVALID_CERTIFICATE_IN_DEVICE"
|
|
15
29
|
);
|
|
16
30
|
}
|
|
17
31
|
|
|
18
|
-
if (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
return STATUS_CERTIFICATE.revoque;
|
|
40
|
-
if (userData?.cangenerate) return STATUS_CERTIFICATE.generate;
|
|
41
|
-
if (userData?.certificationId) return STATUS_CERTIFICATE.current;
|
|
32
|
+
if (integrationType === INTEGRATION_TYPE.ONBOARDING) {
|
|
33
|
+
if (userData?.verificationstatus?.id !== VERIFICATION_STATUS.APPROVED)
|
|
34
|
+
return STATUS_CERTIFICATE.request;
|
|
35
|
+
if (
|
|
36
|
+
userData?.certifiedid &&
|
|
37
|
+
!userData?.certificatestatus?.cangenerate &&
|
|
38
|
+
!userData?.requestscert?.pending &&
|
|
39
|
+
!certificateInDevice &&
|
|
40
|
+
userData?.certificatestatus !== STATUS_CERTIFICATE.revoque
|
|
41
|
+
)
|
|
42
|
+
return STATUS_CERTIFICATE.certificate_another_device;
|
|
43
|
+
if (userData?.requestscert?.pending)
|
|
44
|
+
return STATUS_CERTIFICATE.request_revoque;
|
|
45
|
+
if (
|
|
46
|
+
!userData?.certificatestatus?.cangenerate &&
|
|
47
|
+
userData?.certificatestatus === STATUS_CERTIFICATE.revoque
|
|
48
|
+
)
|
|
49
|
+
return STATUS_CERTIFICATE.revoque;
|
|
50
|
+
if (userData?.certificatestatus?.cangenerate)
|
|
51
|
+
return STATUS_CERTIFICATE.generate;
|
|
52
|
+
if (userData?.certifiedid) return STATUS_CERTIFICATE.current;
|
|
42
53
|
|
|
43
|
-
|
|
54
|
+
return STATUS_CERTIFICATE.revoque;
|
|
55
|
+
}
|
|
56
|
+
if (integrationType === INTEGRATION_TYPE.ONPREMISE) {
|
|
57
|
+
throw new ApacuanaAPIError(
|
|
58
|
+
"Getting certificate status is not supported for integration type: ONPREMISE",
|
|
59
|
+
501,
|
|
60
|
+
"NOT_IMPLEMENTED"
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
throw new ApacuanaAPIError(
|
|
64
|
+
`Unsupported integration type: ${integrationType}`,
|
|
65
|
+
400,
|
|
66
|
+
"UNSUPPORTED_INTEGRATION_TYPE"
|
|
67
|
+
);
|
|
44
68
|
};
|
|
45
69
|
|
|
46
70
|
// Función para convertir ArrayBuffer a Base64
|
package/tests/api/certs.test.js
CHANGED
|
@@ -86,14 +86,18 @@ describe("Certificate API - certs.js", () => {
|
|
|
86
86
|
describe("getCertStatus", () => {
|
|
87
87
|
it("should return the certificate status from helpers", () => {
|
|
88
88
|
const mockUserData = { certStatus: "SOLICITUD" };
|
|
89
|
-
getConfig.mockReturnValue({
|
|
89
|
+
getConfig.mockReturnValue({
|
|
90
|
+
userData: mockUserData,
|
|
91
|
+
integrationType: INTEGRATION_TYPE.ONBOARDING,
|
|
92
|
+
});
|
|
90
93
|
helpers.getCertificateStatus.mockReturnValue("SOLICITUD");
|
|
91
94
|
|
|
92
95
|
const result = getCertStatus(true);
|
|
93
96
|
|
|
94
97
|
expect(helpers.getCertificateStatus).toHaveBeenCalledWith(
|
|
95
98
|
mockUserData,
|
|
96
|
-
true
|
|
99
|
+
true,
|
|
100
|
+
INTEGRATION_TYPE.ONBOARDING
|
|
97
101
|
);
|
|
98
102
|
expect(result).toBeInstanceOf(ApacuanaSuccess);
|
|
99
103
|
|