@integraciones_doc24/sdk 1.16.42 → 1.16.43
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/lib/baseSdk/diagnostica.d.ts +54 -54
- package/lib/baseSdk/diagnostica.js +82 -82
- package/lib/baseSdk/external.d.ts +177 -177
- package/lib/baseSdk/external.js +96 -96
- package/lib/baseSdk/index.d.ts +2 -2
- package/lib/baseSdk/index.js +80 -80
- package/lib/baseSdk/integrationError.d.ts +16 -16
- package/lib/baseSdk/integrationError.js +33 -33
- package/lib/baseSdk/user.d.ts +115 -115
- package/lib/baseSdk/user.js +136 -136
- package/lib/index.d.ts +416 -417
- package/lib/index.js +22 -24
- package/lib/request/index.d.ts +4 -4
- package/lib/request/index.js +32 -32
- package/lib/request/token.d.ts +2 -2
- package/lib/request/token.js +34 -34
- package/lib/request/validation.d.ts +10 -10
- package/lib/request/validation.js +28 -28
- package/lib/schemas.d.ts +2813 -2930
- package/lib/schemas.js +601 -640
- package/lib/types.d.ts +178 -183
- package/lib/types.js +2 -2
- package/lib/userSdk/binah.d.ts +21 -21
- package/lib/userSdk/binah.js +20 -20
- package/lib/userSdk/chat.d.ts +57 -57
- package/lib/userSdk/chat.js +98 -98
- package/lib/userSdk/external.d.ts +34 -34
- package/lib/userSdk/external.js +72 -72
- package/lib/userSdk/index.d.ts +2 -2
- package/lib/userSdk/index.js +33 -36
- package/lib/userSdk/patients.d.ts +62 -62
- package/lib/userSdk/patients.js +93 -93
- package/lib/userSdk/schedule.d.ts +59 -59
- package/lib/userSdk/schedule.js +90 -90
- package/lib/userSdk/specialties.d.ts +19 -19
- package/lib/userSdk/specialties.js +48 -48
- package/lib/userSdk/videoVisit.d.ts +225 -229
- package/lib/userSdk/videoVisit.js +283 -288
- package/lib/utils.d.ts +4 -4
- package/lib/utils.js +68 -68
- package/lib/webhook/index.d.ts +2 -2
- package/lib/webhook/index.js +67 -67
- package/lib/webhook/responses.d.ts +35 -35
- package/lib/webhook/responses.js +42 -42
- package/lib/webhook/token.d.ts +2 -2
- package/lib/webhook/token.js +23 -23
- package/package.json +37 -37
- package/lib/userSdk/eligibility.d.ts +0 -29
- package/lib/userSdk/eligibility.js +0 -81
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getEligibilityMethods = exports.isValidResponseSignature = exports.signResponseData = exports.ResponseSignatureError = void 0;
|
|
7
|
-
const crypto_1 = __importDefault(require("crypto"));
|
|
8
|
-
const zod_1 = require("zod");
|
|
9
|
-
const validation_1 = require("../request/validation");
|
|
10
|
-
const schemas_1 = require("../schemas");
|
|
11
|
-
const utils_1 = require("../utils");
|
|
12
|
-
class ResponseSignatureError extends Error {
|
|
13
|
-
constructor() {
|
|
14
|
-
super('Invalid signature in Doc24 response');
|
|
15
|
-
this.name = 'ResponseSignatureError';
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
exports.ResponseSignatureError = ResponseSignatureError;
|
|
19
|
-
// Doc24 signs `data` as serialized by PHP's json_encode: compact, `/` escaped
|
|
20
|
-
// as `\/` and non-ASCII characters as `\uXXXX`. Key order is the one received.
|
|
21
|
-
const phpJsonEncode = (value) => JSON.stringify(value)
|
|
22
|
-
.replace(/\//g, '\\/')
|
|
23
|
-
.replace(/[\u0080-]/g, (char) => '\\u' + char.charCodeAt(0).toString(16).padStart(4, '0'));
|
|
24
|
-
// base64(HMAC-SHA256(json(data), key)) with `+` → `-`, `/` → `_`, `=` → `,`
|
|
25
|
-
const signResponseData = (data, key) => crypto_1.default
|
|
26
|
-
.createHmac('sha256', key)
|
|
27
|
-
.update(phpJsonEncode(data))
|
|
28
|
-
.digest('base64')
|
|
29
|
-
.replace(/\+/g, '-')
|
|
30
|
-
.replace(/\//g, '_')
|
|
31
|
-
.replace(/=/g, ',');
|
|
32
|
-
exports.signResponseData = signResponseData;
|
|
33
|
-
const isValidResponseSignature = (data, signature, key) => {
|
|
34
|
-
if (typeof signature !== 'string')
|
|
35
|
-
return false;
|
|
36
|
-
const expected = Buffer.from(exports.signResponseData(data, key));
|
|
37
|
-
const received = Buffer.from(signature);
|
|
38
|
-
return (expected.length === received.length &&
|
|
39
|
-
crypto_1.default.timingSafeEqual(expected, received));
|
|
40
|
-
};
|
|
41
|
-
exports.isValidResponseSignature = isValidResponseSignature;
|
|
42
|
-
const getEligibilityMethods = (makeRequest, key) => {
|
|
43
|
-
// Errors (4xx) are thrown by axios; `error.response.data.mensaje` carries
|
|
44
|
-
// INVALID PARAMS, INVALID PATIENT, SERVICE DISABLED or INSSSEP_UNAVAILABLE.
|
|
45
|
-
const checkEligibility = async (params) => {
|
|
46
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
47
|
-
const response = await makeRequest('POST', '/eligibility', {
|
|
48
|
-
patient_id: params.patientId,
|
|
49
|
-
identification_type: params.identificationType,
|
|
50
|
-
identification_value: params.identificationValue,
|
|
51
|
-
credential_token: params.credentialToken,
|
|
52
|
-
credential: params.credential,
|
|
53
|
-
});
|
|
54
|
-
if (!exports.isValidResponseSignature(response.data, response.signature, key))
|
|
55
|
-
throw new ResponseSignatureError();
|
|
56
|
-
const data = response.data;
|
|
57
|
-
const affiliate = data.affiliate;
|
|
58
|
-
return {
|
|
59
|
-
eligible: data.eligible,
|
|
60
|
-
code: data.code,
|
|
61
|
-
message: data.message,
|
|
62
|
-
affiliate: affiliate
|
|
63
|
-
? {
|
|
64
|
-
name: (_a = affiliate.name) !== null && _a !== void 0 ? _a : undefined,
|
|
65
|
-
holder: (_b = affiliate.holder) !== null && _b !== void 0 ? _b : undefined,
|
|
66
|
-
gender: (_c = affiliate.gender) !== null && _c !== void 0 ? _c : undefined,
|
|
67
|
-
age: (_d = affiliate.age) !== null && _d !== void 0 ? _d : undefined,
|
|
68
|
-
affiliateNumber: (_e = affiliate.affiliate_number) !== null && _e !== void 0 ? _e : undefined,
|
|
69
|
-
plan: (_f = affiliate.plan) !== null && _f !== void 0 ? _f : undefined,
|
|
70
|
-
}
|
|
71
|
-
: null,
|
|
72
|
-
notices: (_g = data.notices) !== null && _g !== void 0 ? _g : [],
|
|
73
|
-
// UTC
|
|
74
|
-
timestamp: utils_1.parseDateTime(data.timestamp, '+00'),
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
return {
|
|
78
|
-
checkEligibility: validation_1.validateFunction(zod_1.tuple([schemas_1.doc24Schemas.eligibilityParams]), schemas_1.doc24Schemas.eligibilityResponse, checkEligibility),
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
exports.getEligibilityMethods = getEligibilityMethods;
|