@integraciones_doc24/sdk 0.34.3 → 0.35.1
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/index.js +5 -0
- package/lib/index.d.ts +4 -0
- package/lib/lib/baseSdk/diagnostica.d.ts +11 -0
- package/lib/lib/baseSdk/diagnostica.js +79 -0
- package/lib/lib/baseSdk/index.d.ts +161 -0
- package/lib/lib/baseSdk/index.js +66 -0
- package/lib/lib/baseSdk/user.d.ts +41 -0
- package/lib/lib/baseSdk/user.js +130 -0
- package/lib/lib/index.d.ts +182 -0
- package/lib/lib/index.js +22 -0
- package/lib/lib/lib/baseSdk/diagnostica.d.ts +6 -0
- package/lib/lib/lib/baseSdk/diagnostica.js +79 -0
- package/lib/lib/lib/baseSdk/index.d.ts +51 -0
- package/lib/lib/lib/baseSdk/index.js +66 -0
- package/lib/lib/lib/baseSdk/user.d.ts +9 -0
- package/lib/lib/lib/baseSdk/user.js +130 -0
- package/lib/lib/lib/index.d.ts +168 -0
- package/lib/lib/lib/index.js +22 -0
- package/lib/lib/lib/lib/baseSdk/diagnostica.d.ts +6 -0
- package/lib/lib/lib/lib/baseSdk/diagnostica.js +79 -0
- package/lib/lib/lib/lib/baseSdk/index.d.ts +14 -0
- package/lib/lib/lib/lib/baseSdk/index.js +66 -0
- package/lib/lib/lib/lib/baseSdk/user.d.ts +9 -0
- package/lib/lib/lib/lib/baseSdk/user.js +130 -0
- package/lib/lib/lib/lib/index.d.ts +58 -0
- package/lib/lib/lib/lib/index.js +22 -0
- package/lib/lib/lib/lib/request/index.d.ts +2 -0
- package/lib/lib/lib/lib/request/index.js +26 -0
- package/lib/lib/lib/lib/request/token.d.ts +2 -0
- package/lib/lib/lib/lib/request/token.js +34 -0
- package/lib/lib/lib/lib/request/validation.d.ts +10 -0
- package/lib/lib/lib/lib/request/validation.js +28 -0
- package/lib/lib/lib/lib/schemas.d.ts +1334 -0
- package/lib/lib/lib/lib/schemas.js +325 -0
- package/lib/lib/lib/lib/test.d.ts +1 -0
- package/lib/lib/lib/lib/test.js +55 -0
- package/lib/lib/lib/lib/types.d.ts +1 -0
- package/lib/lib/lib/lib/types.js +2 -0
- package/lib/lib/lib/lib/userSdk/chat.d.ts +9 -0
- package/lib/lib/lib/lib/userSdk/chat.js +98 -0
- package/lib/lib/lib/lib/userSdk/index.d.ts +24 -0
- package/lib/lib/lib/lib/userSdk/index.js +27 -0
- package/lib/lib/lib/lib/userSdk/patients.d.ts +5 -0
- package/lib/lib/lib/lib/userSdk/patients.js +55 -0
- package/lib/lib/lib/lib/userSdk/schedule.d.ts +7 -0
- package/lib/lib/lib/lib/userSdk/schedule.js +76 -0
- package/lib/lib/lib/lib/userSdk/specialties.d.ts +4 -0
- package/lib/lib/lib/lib/userSdk/specialties.js +19 -0
- package/lib/lib/lib/lib/userSdk/videoVisit.d.ts +10 -0
- package/lib/lib/lib/lib/userSdk/videoVisit.js +147 -0
- package/lib/lib/lib/lib/utils.d.ts +4 -0
- package/lib/lib/lib/lib/utils.js +19 -0
- package/lib/lib/lib/lib/webhook/index.d.ts +8 -0
- package/lib/lib/lib/lib/webhook/index.js +55 -0
- package/lib/lib/lib/lib/webhook/responses.d.ts +36 -0
- package/lib/lib/lib/lib/webhook/responses.js +42 -0
- package/lib/lib/lib/lib/webhook/token.d.ts +2 -0
- package/lib/lib/lib/lib/webhook/token.js +23 -0
- package/lib/lib/lib/request/index.d.ts +2 -0
- package/lib/lib/lib/request/index.js +26 -0
- package/lib/lib/lib/request/token.d.ts +2 -0
- package/lib/lib/lib/request/token.js +34 -0
- package/lib/lib/lib/request/validation.d.ts +10 -0
- package/lib/lib/lib/request/validation.js +28 -0
- package/lib/lib/lib/schemas.d.ts +1334 -0
- package/lib/lib/lib/schemas.js +325 -0
- package/lib/lib/lib/src/baseSdk/diagnostica.d.ts +6 -0
- package/lib/lib/lib/src/baseSdk/diagnostica.js +79 -0
- package/lib/lib/lib/src/baseSdk/index.d.ts +51 -0
- package/lib/lib/lib/src/baseSdk/index.js +66 -0
- package/lib/lib/lib/src/baseSdk/user.d.ts +9 -0
- package/lib/lib/lib/src/baseSdk/user.js +130 -0
- package/lib/lib/lib/src/index.d.ts +169 -0
- package/lib/lib/lib/src/index.js +22 -0
- package/lib/lib/lib/src/request/index.d.ts +2 -0
- package/lib/lib/lib/src/request/index.js +26 -0
- package/lib/lib/lib/src/request/token.d.ts +2 -0
- package/lib/lib/lib/src/request/token.js +34 -0
- package/lib/lib/lib/src/request/validation.d.ts +10 -0
- package/lib/lib/lib/src/request/validation.js +28 -0
- package/lib/lib/lib/src/schemas.d.ts +1340 -0
- package/lib/lib/lib/src/schemas.js +325 -0
- package/lib/lib/lib/src/types.d.ts +1 -0
- package/lib/lib/lib/src/types.js +2 -0
- package/lib/lib/lib/src/userSdk/chat.d.ts +9 -0
- package/lib/lib/lib/src/userSdk/chat.js +98 -0
- package/lib/lib/lib/src/userSdk/index.d.ts +102 -0
- package/lib/lib/lib/src/userSdk/index.js +27 -0
- package/lib/lib/lib/src/userSdk/patients.d.ts +5 -0
- package/lib/lib/lib/src/userSdk/patients.js +55 -0
- package/lib/lib/lib/src/userSdk/schedule.d.ts +7 -0
- package/lib/lib/lib/src/userSdk/schedule.js +76 -0
- package/lib/lib/lib/src/userSdk/specialties.d.ts +4 -0
- package/lib/lib/lib/src/userSdk/specialties.js +19 -0
- package/lib/lib/lib/src/userSdk/videoVisit.d.ts +10 -0
- package/lib/lib/lib/src/userSdk/videoVisit.js +147 -0
- package/lib/lib/lib/src/utils.d.ts +4 -0
- package/lib/lib/lib/src/utils.js +19 -0
- package/lib/lib/lib/src/webhook/index.d.ts +8 -0
- package/lib/lib/lib/src/webhook/index.js +55 -0
- package/lib/lib/lib/src/webhook/responses.d.ts +36 -0
- package/lib/lib/lib/src/webhook/responses.js +42 -0
- package/lib/lib/lib/src/webhook/token.d.ts +2 -0
- package/lib/lib/lib/src/webhook/token.js +23 -0
- package/lib/lib/lib/test.d.ts +1 -0
- package/lib/lib/lib/test.js +55 -0
- package/lib/lib/lib/types.d.ts +1 -0
- package/lib/lib/lib/types.js +2 -0
- package/lib/lib/lib/userSdk/chat.d.ts +9 -0
- package/lib/lib/lib/userSdk/chat.js +98 -0
- package/lib/lib/lib/userSdk/index.d.ts +102 -0
- package/lib/lib/lib/userSdk/index.js +27 -0
- package/lib/lib/lib/userSdk/patients.d.ts +5 -0
- package/lib/lib/lib/userSdk/patients.js +55 -0
- package/lib/lib/lib/userSdk/schedule.d.ts +7 -0
- package/lib/lib/lib/userSdk/schedule.js +76 -0
- package/lib/lib/lib/userSdk/specialties.d.ts +4 -0
- package/lib/lib/lib/userSdk/specialties.js +19 -0
- package/lib/lib/lib/userSdk/videoVisit.d.ts +10 -0
- package/lib/lib/lib/userSdk/videoVisit.js +147 -0
- package/lib/lib/lib/utils.d.ts +4 -0
- package/lib/lib/lib/utils.js +19 -0
- package/lib/lib/lib/webhook/index.d.ts +8 -0
- package/lib/lib/lib/webhook/index.js +55 -0
- package/lib/lib/lib/webhook/responses.d.ts +36 -0
- package/lib/lib/lib/webhook/responses.js +42 -0
- package/lib/lib/lib/webhook/token.d.ts +2 -0
- package/lib/lib/lib/webhook/token.js +23 -0
- package/lib/lib/request/index.d.ts +2 -0
- package/lib/lib/request/index.js +26 -0
- package/lib/lib/request/token.d.ts +2 -0
- package/lib/lib/request/token.js +34 -0
- package/lib/lib/request/validation.d.ts +10 -0
- package/lib/lib/request/validation.js +28 -0
- package/lib/lib/schemas.d.ts +1334 -0
- package/lib/lib/schemas.js +325 -0
- package/lib/lib/src/baseSdk/diagnostica.d.ts +11 -0
- package/lib/lib/src/baseSdk/diagnostica.js +79 -0
- package/lib/lib/src/baseSdk/index.d.ts +162 -0
- package/lib/lib/src/baseSdk/index.js +66 -0
- package/lib/lib/src/baseSdk/user.d.ts +41 -0
- package/lib/lib/src/baseSdk/user.js +130 -0
- package/lib/lib/src/index.d.ts +183 -0
- package/lib/lib/src/index.js +22 -0
- package/lib/lib/src/request/index.d.ts +2 -0
- package/lib/lib/src/request/index.js +26 -0
- package/lib/lib/src/request/token.d.ts +2 -0
- package/lib/lib/src/request/token.js +34 -0
- package/lib/lib/src/request/validation.d.ts +10 -0
- package/lib/lib/src/request/validation.js +28 -0
- package/lib/lib/src/schemas.d.ts +1340 -0
- package/lib/lib/src/schemas.js +325 -0
- package/lib/lib/src/types.d.ts +1 -0
- package/lib/lib/src/types.js +2 -0
- package/lib/lib/src/userSdk/chat.d.ts +9 -0
- package/lib/lib/src/userSdk/chat.js +98 -0
- package/lib/lib/src/userSdk/index.d.ts +241 -0
- package/lib/lib/src/userSdk/index.js +27 -0
- package/lib/lib/src/userSdk/patients.d.ts +13 -0
- package/lib/lib/src/userSdk/patients.js +55 -0
- package/lib/lib/src/userSdk/schedule.d.ts +15 -0
- package/lib/lib/src/userSdk/schedule.js +76 -0
- package/lib/lib/src/userSdk/specialties.d.ts +4 -0
- package/lib/lib/src/userSdk/specialties.js +19 -0
- package/lib/lib/src/userSdk/videoVisit.d.ts +72 -0
- package/lib/lib/src/userSdk/videoVisit.js +147 -0
- package/lib/lib/src/utils.d.ts +4 -0
- package/lib/lib/src/utils.js +19 -0
- package/lib/lib/src/webhook/index.d.ts +8 -0
- package/lib/lib/src/webhook/index.js +55 -0
- package/lib/lib/src/webhook/responses.d.ts +36 -0
- package/lib/lib/src/webhook/responses.js +42 -0
- package/lib/lib/src/webhook/token.d.ts +2 -0
- package/lib/lib/src/webhook/token.js +23 -0
- package/lib/lib/test.d.ts +1 -0
- package/lib/lib/test.js +55 -0
- package/lib/lib/types.d.ts +1 -0
- package/lib/lib/types.js +2 -0
- package/lib/lib/userSdk/chat.d.ts +9 -0
- package/lib/lib/userSdk/chat.js +98 -0
- package/lib/lib/userSdk/index.d.ts +240 -0
- package/lib/lib/userSdk/index.js +27 -0
- package/lib/lib/userSdk/patients.d.ts +13 -0
- package/lib/lib/userSdk/patients.js +55 -0
- package/lib/lib/userSdk/schedule.d.ts +15 -0
- package/lib/lib/userSdk/schedule.js +76 -0
- package/lib/lib/userSdk/specialties.d.ts +4 -0
- package/lib/lib/userSdk/specialties.js +19 -0
- package/lib/lib/userSdk/videoVisit.d.ts +72 -0
- package/lib/lib/userSdk/videoVisit.js +147 -0
- package/lib/lib/utils.d.ts +4 -0
- package/lib/lib/utils.js +19 -0
- package/lib/lib/webhook/index.d.ts +8 -0
- package/lib/lib/webhook/index.js +55 -0
- package/lib/lib/webhook/responses.d.ts +36 -0
- package/lib/lib/webhook/responses.js +42 -0
- package/lib/lib/webhook/token.d.ts +2 -0
- package/lib/lib/webhook/token.js +23 -0
- package/lib/schemas.d.ts +18 -0
- package/lib/schemas.js +1 -0
- package/lib/src/baseSdk/diagnostica.d.ts +54 -0
- package/lib/src/baseSdk/diagnostica.js +79 -0
- package/lib/src/baseSdk/index.d.ts +2 -0
- package/lib/src/baseSdk/index.js +66 -0
- package/lib/src/baseSdk/user.d.ts +89 -0
- package/lib/src/baseSdk/user.js +130 -0
- package/lib/src/index.d.ts +188 -0
- package/lib/src/index.js +22 -0
- package/lib/src/request/index.d.ts +3 -0
- package/lib/src/request/index.js +26 -0
- package/lib/src/request/token.d.ts +2 -0
- package/lib/src/request/token.js +34 -0
- package/lib/src/request/validation.d.ts +10 -0
- package/lib/src/request/validation.js +28 -0
- package/lib/src/schemas.d.ts +1311 -0
- package/lib/src/schemas.js +325 -0
- package/lib/src/types.d.ts +124 -0
- package/lib/src/types.js +2 -0
- package/lib/src/userSdk/chat.d.ts +57 -0
- package/lib/src/userSdk/chat.js +98 -0
- package/lib/src/userSdk/index.d.ts +2 -0
- package/lib/src/userSdk/index.js +27 -0
- package/lib/src/userSdk/patients.d.ts +33 -0
- package/lib/src/userSdk/patients.js +55 -0
- package/lib/src/userSdk/schedule.d.ts +44 -0
- package/lib/src/userSdk/schedule.js +76 -0
- package/lib/src/userSdk/specialties.d.ts +7 -0
- package/lib/src/userSdk/specialties.js +19 -0
- package/lib/src/userSdk/videoVisit.d.ts +111 -0
- package/lib/src/userSdk/videoVisit.js +147 -0
- package/lib/src/utils.d.ts +4 -0
- package/lib/src/utils.js +19 -0
- package/lib/src/webhook/index.d.ts +2 -0
- package/lib/src/webhook/index.js +55 -0
- package/lib/src/webhook/responses.d.ts +35 -0
- package/lib/src/webhook/responses.js +42 -0
- package/lib/src/webhook/token.d.ts +2 -0
- package/lib/src/webhook/token.js +23 -0
- package/lib/test.js +15 -8
- package/package.json +4 -1
- package/lib/baseSdk/external.d.ts +0 -28
- package/lib/baseSdk/external.js +0 -73
- package/lib/userSdk/sarasas.d.ts +0 -6
- package/lib/userSdk/sarasas.js +0 -13
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
export var __esModule: boolean;
|
|
2
|
+
export function doc24Sdk(params: any): Promise<{
|
|
3
|
+
getRequestHandler: (params: any) => Promise<(request: any) => Promise<{
|
|
4
|
+
status: {
|
|
5
|
+
code: number;
|
|
6
|
+
message: string;
|
|
7
|
+
};
|
|
8
|
+
data: unknown;
|
|
9
|
+
}>>;
|
|
10
|
+
getProfessional: (...params: any) => Promise<{
|
|
11
|
+
id: any;
|
|
12
|
+
firstName: any;
|
|
13
|
+
lastName: any;
|
|
14
|
+
birthdate: Date;
|
|
15
|
+
gender: any;
|
|
16
|
+
email: any;
|
|
17
|
+
phone: any;
|
|
18
|
+
logoUrl: any;
|
|
19
|
+
matriculation: any;
|
|
20
|
+
specialties: any;
|
|
21
|
+
degree: any;
|
|
22
|
+
languages: any;
|
|
23
|
+
resume: {
|
|
24
|
+
link: any;
|
|
25
|
+
brief: any;
|
|
26
|
+
};
|
|
27
|
+
}>;
|
|
28
|
+
getAvailableScheduleClinics: () => Promise<{
|
|
29
|
+
specialties: any;
|
|
30
|
+
specialtiesER: any;
|
|
31
|
+
professionals: any;
|
|
32
|
+
}>;
|
|
33
|
+
declareUser: (params: {
|
|
34
|
+
user: {
|
|
35
|
+
firstName: string;
|
|
36
|
+
lastName: string;
|
|
37
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
38
|
+
identificationValue: string;
|
|
39
|
+
countryId: string;
|
|
40
|
+
birthdate: Date;
|
|
41
|
+
gender: "m" | "f";
|
|
42
|
+
phone: string;
|
|
43
|
+
email: string;
|
|
44
|
+
};
|
|
45
|
+
} & {
|
|
46
|
+
code?: string | undefined;
|
|
47
|
+
channel?: "1" | "2" | undefined;
|
|
48
|
+
}) => Promise<{
|
|
49
|
+
patientId: number | null;
|
|
50
|
+
userInfo: {
|
|
51
|
+
phone: string;
|
|
52
|
+
email: string;
|
|
53
|
+
};
|
|
54
|
+
askCode: boolean;
|
|
55
|
+
userId: number;
|
|
56
|
+
}>;
|
|
57
|
+
getUserId: (user: {
|
|
58
|
+
firstName: string;
|
|
59
|
+
lastName: string;
|
|
60
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
61
|
+
identificationValue: string;
|
|
62
|
+
countryId: string;
|
|
63
|
+
birthdate: Date;
|
|
64
|
+
gender: "m" | "f";
|
|
65
|
+
phone: string;
|
|
66
|
+
email: string;
|
|
67
|
+
}) => Promise<number>;
|
|
68
|
+
sendVerificationCode: (params: {
|
|
69
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
70
|
+
identificationValue: string;
|
|
71
|
+
channel: "1" | "2";
|
|
72
|
+
}) => Promise<any>;
|
|
73
|
+
getUserInstance: (user: number | {
|
|
74
|
+
firstName: string;
|
|
75
|
+
lastName: string;
|
|
76
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
77
|
+
identificationValue: string;
|
|
78
|
+
countryId: string;
|
|
79
|
+
birthdate: Date;
|
|
80
|
+
gender: "m" | "f";
|
|
81
|
+
phone: string;
|
|
82
|
+
email: string;
|
|
83
|
+
}) => Promise<any>;
|
|
84
|
+
enroll: (params: {
|
|
85
|
+
firstName: string;
|
|
86
|
+
lastName: string;
|
|
87
|
+
birthdate: Date;
|
|
88
|
+
gender: "m" | "f";
|
|
89
|
+
email: string;
|
|
90
|
+
startDate: Date;
|
|
91
|
+
identificationNumber: string;
|
|
92
|
+
plan: string;
|
|
93
|
+
}) => Promise<void>;
|
|
94
|
+
getConverageInfo: (identificationValue: string) => Promise<{
|
|
95
|
+
firstName: string | null;
|
|
96
|
+
lastName: string | null;
|
|
97
|
+
birthdate: Date;
|
|
98
|
+
gender: "m" | "f";
|
|
99
|
+
email: string | null;
|
|
100
|
+
identificationNumber: string;
|
|
101
|
+
plan: string | null;
|
|
102
|
+
financerId: number | null;
|
|
103
|
+
defaultAffiliationId: number | null;
|
|
104
|
+
credentialNumber: string | null;
|
|
105
|
+
financerPlanId: number | null;
|
|
106
|
+
brand: number | null;
|
|
107
|
+
holderIdentificationNumber: string | null;
|
|
108
|
+
copaymentValue: number | null;
|
|
109
|
+
mobilePhone: string | null;
|
|
110
|
+
company: string | null;
|
|
111
|
+
dischargeDate: Date | null;
|
|
112
|
+
leavingDate: Date | null;
|
|
113
|
+
identificacion_tributaria: string | null;
|
|
114
|
+
deregistrationDate: Date | null;
|
|
115
|
+
authorizationCode: string | null;
|
|
116
|
+
authorizationCodeExpiration: Date | null;
|
|
117
|
+
} | null>;
|
|
118
|
+
getDiagnosticaHistory: (patient: {
|
|
119
|
+
identificationType: "ndi" | "passport" | "credential";
|
|
120
|
+
identificationValue: string;
|
|
121
|
+
gender: "m" | "f";
|
|
122
|
+
}, from: Date, to: Date) => Promise<{
|
|
123
|
+
date: Date;
|
|
124
|
+
location: string;
|
|
125
|
+
exams: string[];
|
|
126
|
+
deepLink: string;
|
|
127
|
+
}[]>;
|
|
128
|
+
getDiagnosticaDeepLink: (kiosk: string, user: {
|
|
129
|
+
firstName: string;
|
|
130
|
+
lastName: string;
|
|
131
|
+
identificationType: "dni";
|
|
132
|
+
identificationValue: string;
|
|
133
|
+
gender: "m" | "f";
|
|
134
|
+
phone: string;
|
|
135
|
+
email: string;
|
|
136
|
+
language: string;
|
|
137
|
+
birthday: Date;
|
|
138
|
+
}, patient: {
|
|
139
|
+
firstName: string;
|
|
140
|
+
lastName: string;
|
|
141
|
+
identificationType: "dni";
|
|
142
|
+
identificationValue: string;
|
|
143
|
+
gender: "m" | "f";
|
|
144
|
+
birthday: Date;
|
|
145
|
+
}) => Promise<{
|
|
146
|
+
forwardingRequired: true;
|
|
147
|
+
deepLink: string;
|
|
148
|
+
} | {
|
|
149
|
+
forwardingRequired: false;
|
|
150
|
+
}>;
|
|
151
|
+
getDiagnosticaAccess: (kiosk: string, user: {
|
|
152
|
+
firstName: string;
|
|
153
|
+
lastName: string;
|
|
154
|
+
identificationType: "dni";
|
|
155
|
+
identificationValue: string;
|
|
156
|
+
gender: "m" | "f";
|
|
157
|
+
phone: string;
|
|
158
|
+
email: string;
|
|
159
|
+
language: string;
|
|
160
|
+
birthday: Date;
|
|
161
|
+
}, patient: {
|
|
162
|
+
firstName: string;
|
|
163
|
+
lastName: string;
|
|
164
|
+
identificationType: "dni";
|
|
165
|
+
identificationValue: string;
|
|
166
|
+
gender: "m" | "f";
|
|
167
|
+
birthday: Date;
|
|
168
|
+
}) => Promise<void>;
|
|
169
|
+
}>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.doc24Sdk = void 0;
|
|
4
|
+
const webhook_1 = require("./webhook");
|
|
5
|
+
const baseSdk_1 = require("./baseSdk");
|
|
6
|
+
const request_1 = require("./request");
|
|
7
|
+
const doc24Sdk = async (params) => {
|
|
8
|
+
const baseSdk = await baseSdk_1.getBaseSdk(params.url, params.credentials);
|
|
9
|
+
const makeRequest = await request_1.getRequestFactory(params.url, params.credentials);
|
|
10
|
+
return {
|
|
11
|
+
...baseSdk,
|
|
12
|
+
getRequestHandler: async (params) => {
|
|
13
|
+
await makeRequest('PUT', '/webhook', {
|
|
14
|
+
url: params.baseAddress,
|
|
15
|
+
issuer: params.credentials.iss,
|
|
16
|
+
secret: params.credentials.key,
|
|
17
|
+
});
|
|
18
|
+
return webhook_1.getRequestHandler(params.credentials, baseSdk, params.eventHandlers);
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
exports.doc24Sdk = doc24Sdk;
|
|
@@ -0,0 +1,26 @@
|
|
|
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.getRequestFactory = void 0;
|
|
7
|
+
const axios_1 = __importDefault(require("axios"));
|
|
8
|
+
const token_1 = require("./token");
|
|
9
|
+
const debug_1 = __importDefault(require("debug"));
|
|
10
|
+
const debugRequest = debug_1.default('doc24Sdk:request');
|
|
11
|
+
const getRequestFactory = async (url, credentials, userId) => {
|
|
12
|
+
const makeRequest = async (method, path, body) => {
|
|
13
|
+
const token = await token_1.getToken(credentials, body ? JSON.stringify(body) : undefined, userId);
|
|
14
|
+
const fullUrl = url + path;
|
|
15
|
+
const result = await axios_1.default({
|
|
16
|
+
method,
|
|
17
|
+
url: fullUrl,
|
|
18
|
+
headers: { Authentication: token },
|
|
19
|
+
data: body,
|
|
20
|
+
});
|
|
21
|
+
debugRequest({ url: fullUrl, response: result.data, body });
|
|
22
|
+
return result.data;
|
|
23
|
+
};
|
|
24
|
+
return makeRequest;
|
|
25
|
+
};
|
|
26
|
+
exports.getRequestFactory = getRequestFactory;
|
|
@@ -0,0 +1,34 @@
|
|
|
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.getToken = void 0;
|
|
7
|
+
const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
8
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
9
|
+
const tokenLifeTimeInSeconds = 500 * 60;
|
|
10
|
+
const getToken = async (credentials, bodyAsJson, userId) => {
|
|
11
|
+
const tokenData = {
|
|
12
|
+
msg_sig: createSignature(credentials.key, bodyAsJson),
|
|
13
|
+
user_id: userId,
|
|
14
|
+
};
|
|
15
|
+
const encodedToken = await makeJwt(tokenData, credentials.key, {
|
|
16
|
+
expiresIn: tokenLifeTimeInSeconds,
|
|
17
|
+
issuer: credentials.iss,
|
|
18
|
+
});
|
|
19
|
+
return encodedToken;
|
|
20
|
+
};
|
|
21
|
+
exports.getToken = getToken;
|
|
22
|
+
const makeJwt = (payload, key, options = {}) => new Promise((resolve, reject) => jsonwebtoken_1.default.sign(payload, key, options, (err, token) => {
|
|
23
|
+
if (err || !token)
|
|
24
|
+
return reject(err);
|
|
25
|
+
resolve(token);
|
|
26
|
+
}));
|
|
27
|
+
const createSignature = (secret, bodyAsJson) => {
|
|
28
|
+
//TODO: verify this, seems wrong
|
|
29
|
+
const realSecret = bodyAsJson ? secret : 'true';
|
|
30
|
+
const realBody = bodyAsJson !== null && bodyAsJson !== void 0 ? bodyAsJson : secret;
|
|
31
|
+
const hmac = crypto_1.default.createHmac('sha256', realSecret);
|
|
32
|
+
hmac.update(realBody);
|
|
33
|
+
return hmac.digest('base64');
|
|
34
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export var __esModule: boolean;
|
|
2
|
+
export class ParametersValidationError extends Error {
|
|
3
|
+
constructor(details: any);
|
|
4
|
+
details: any;
|
|
5
|
+
}
|
|
6
|
+
export class ResponseValidationError extends Error {
|
|
7
|
+
constructor(details: any);
|
|
8
|
+
details: any;
|
|
9
|
+
}
|
|
10
|
+
export function validateFunction(inValidation: any, outValidation: any, fn: any): (...params: any[]) => Promise<any>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.validateFunction = exports.ResponseValidationError = exports.ParametersValidationError = void 0;
|
|
4
|
+
class ParametersValidationError extends Error {
|
|
5
|
+
constructor(details) {
|
|
6
|
+
super('Invalid parameters supplied to function');
|
|
7
|
+
this.details = details;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.ParametersValidationError = ParametersValidationError;
|
|
11
|
+
class ResponseValidationError extends Error {
|
|
12
|
+
constructor(details) {
|
|
13
|
+
super('Invalid response returned from function');
|
|
14
|
+
this.details = details;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.ResponseValidationError = ResponseValidationError;
|
|
18
|
+
const validateFunction = (inValidation, outValidation, fn) => async (...params) => {
|
|
19
|
+
const validationResult = inValidation.safeParse(params);
|
|
20
|
+
if (!validationResult.success)
|
|
21
|
+
throw new ParametersValidationError(validationResult.error);
|
|
22
|
+
const out = await fn(...validationResult.data);
|
|
23
|
+
const responseValidationResult = outValidation.safeParse(out);
|
|
24
|
+
if (!responseValidationResult.success)
|
|
25
|
+
throw new ResponseValidationError(responseValidationResult.error);
|
|
26
|
+
return responseValidationResult.data;
|
|
27
|
+
};
|
|
28
|
+
exports.validateFunction = validateFunction;
|