@integraciones_doc24/sdk 0.39.5 → 0.39.6

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 (41) hide show
  1. package/lib/baseSdk/consultation.d.ts +99 -0
  2. package/lib/baseSdk/consultation.js +23 -0
  3. package/lib/baseSdk/diagnostica.d.ts +54 -0
  4. package/lib/baseSdk/diagnostica.js +79 -0
  5. package/lib/baseSdk/index.d.ts +2 -0
  6. package/lib/baseSdk/index.js +73 -0
  7. package/lib/baseSdk/user.d.ts +41 -0
  8. package/lib/baseSdk/user.js +88 -0
  9. package/lib/index.d.ts +255 -0
  10. package/lib/index.js +22 -0
  11. package/lib/request/index.d.ts +3 -0
  12. package/lib/request/index.js +26 -0
  13. package/lib/request/token.d.ts +2 -0
  14. package/lib/request/token.js +34 -0
  15. package/lib/request/validation.d.ts +10 -0
  16. package/lib/request/validation.js +28 -0
  17. package/lib/schemas.d.ts +1451 -0
  18. package/lib/schemas.js +404 -0
  19. package/lib/types.d.ts +120 -0
  20. package/lib/types.js +2 -0
  21. package/lib/userSdk/chat.d.ts +57 -0
  22. package/lib/userSdk/chat.js +98 -0
  23. package/lib/userSdk/index.d.ts +2 -0
  24. package/lib/userSdk/index.js +27 -0
  25. package/lib/userSdk/patients.d.ts +24 -0
  26. package/lib/userSdk/patients.js +46 -0
  27. package/lib/userSdk/schedule.d.ts +44 -0
  28. package/lib/userSdk/schedule.js +76 -0
  29. package/lib/userSdk/specialties.d.ts +7 -0
  30. package/lib/userSdk/specialties.js +19 -0
  31. package/lib/userSdk/videoVisit.d.ts +111 -0
  32. package/lib/userSdk/videoVisit.js +147 -0
  33. package/lib/utils.d.ts +4 -0
  34. package/lib/utils.js +27 -0
  35. package/lib/webhook/index.d.ts +2 -0
  36. package/lib/webhook/index.js +55 -0
  37. package/lib/webhook/responses.d.ts +35 -0
  38. package/lib/webhook/responses.js +42 -0
  39. package/lib/webhook/token.d.ts +2 -0
  40. package/lib/webhook/token.js +23 -0
  41. package/package.json +1 -1
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.successResponse = exports.unexpectedErrorResponse = exports.unauthorizedErrorResponse = exports.notFoundErrorResponse = void 0;
4
+ const notFoundErrorResponse = () => ({
5
+ status: {
6
+ code: 404,
7
+ message: 'Not Found',
8
+ },
9
+ data: {
10
+ error: 'not_found',
11
+ },
12
+ });
13
+ exports.notFoundErrorResponse = notFoundErrorResponse;
14
+ const unauthorizedErrorResponse = () => ({
15
+ status: {
16
+ code: 401,
17
+ message: 'Unauthorized',
18
+ },
19
+ data: {
20
+ error: 'unauthorized',
21
+ },
22
+ });
23
+ exports.unauthorizedErrorResponse = unauthorizedErrorResponse;
24
+ const unexpectedErrorResponse = (details) => ({
25
+ status: {
26
+ code: 500,
27
+ message: 'Unhandled Error',
28
+ },
29
+ data: {
30
+ error: 'unhandled_error',
31
+ details,
32
+ },
33
+ });
34
+ exports.unexpectedErrorResponse = unexpectedErrorResponse;
35
+ const successResponse = (data) => ({
36
+ status: {
37
+ code: 200,
38
+ message: 'Success',
39
+ },
40
+ data,
41
+ });
42
+ exports.successResponse = successResponse;
@@ -0,0 +1,2 @@
1
+ import { Doc24 } from '../types';
2
+ export declare const getWebhookToken: (request: Doc24.Webhook.Request, credentials: Doc24.SdkCredentials) => Promise<Record<string, unknown> | undefined>;
@@ -0,0 +1,23 @@
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.getWebhookToken = void 0;
7
+ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
8
+ const getWebhookToken = async (request, credentials) => {
9
+ if (request.headers.authentication === undefined)
10
+ return;
11
+ const decoded = await decodeJwt(request.headers.authentication, credentials.key);
12
+ if (!decoded || decoded.iss !== credentials.iss)
13
+ return;
14
+ return decoded;
15
+ };
16
+ exports.getWebhookToken = getWebhookToken;
17
+ const decodeJwt = (token, key) => new Promise((resolve, reject) => {
18
+ jsonwebtoken_1.default.verify(token, key, (err, result) => {
19
+ if (!result || err)
20
+ return reject(err);
21
+ resolve(result);
22
+ });
23
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integraciones_doc24/sdk",
3
- "version": "0.39.5",
3
+ "version": "0.39.6",
4
4
  "publishConfig": {
5
5
  "tag": "0.x"
6
6
  },