@ovok/core 0.2.47

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 (202) hide show
  1. package/README.md +40 -0
  2. package/dist/client/ai-fhir/methods/AIFhirResources.d.ts +14 -0
  3. package/dist/client/ai-fhir/methods/AIFhirResources.js +16 -0
  4. package/dist/client/ai-fhir/methods/index.d.ts +1 -0
  5. package/dist/client/ai-fhir/methods/index.js +17 -0
  6. package/dist/client/ai-fhir/types/AIFhirPlan.d.ts +6 -0
  7. package/dist/client/ai-fhir/types/AIFhirPlan.js +2 -0
  8. package/dist/client/ai-fhir/types/AIFhirPlanRequest.d.ts +5 -0
  9. package/dist/client/ai-fhir/types/AIFhirPlanRequest.js +2 -0
  10. package/dist/client/ai-fhir/types/AIFhirRequest.d.ts +7 -0
  11. package/dist/client/ai-fhir/types/AIFhirRequest.js +2 -0
  12. package/dist/client/ai-fhir/types/AIFhirResponse.d.ts +18 -0
  13. package/dist/client/ai-fhir/types/AIFhirResponse.js +2 -0
  14. package/dist/client/ai-fhir/types/index.d.ts +4 -0
  15. package/dist/client/ai-fhir/types/index.js +20 -0
  16. package/dist/client/auth/methods/appleLogin.d.ts +4 -0
  17. package/dist/client/auth/methods/appleLogin.js +11 -0
  18. package/dist/client/auth/methods/changePassword.d.ts +4 -0
  19. package/dist/client/auth/methods/changePassword.js +6 -0
  20. package/dist/client/auth/methods/googleLogin.d.ts +4 -0
  21. package/dist/client/auth/methods/googleLogin.js +11 -0
  22. package/dist/client/auth/methods/index.d.ts +8 -0
  23. package/dist/client/auth/methods/index.js +24 -0
  24. package/dist/client/auth/methods/login.d.ts +4 -0
  25. package/dist/client/auth/methods/login.js +38 -0
  26. package/dist/client/auth/methods/refetchProfile.d.ts +2 -0
  27. package/dist/client/auth/methods/refetchProfile.js +9 -0
  28. package/dist/client/auth/methods/register.d.ts +4 -0
  29. package/dist/client/auth/methods/register.js +15 -0
  30. package/dist/client/auth/methods/requestDeleteUser.d.ts +11 -0
  31. package/dist/client/auth/methods/requestDeleteUser.js +13 -0
  32. package/dist/client/auth/methods/resetPassword.d.ts +13 -0
  33. package/dist/client/auth/methods/resetPassword.js +19 -0
  34. package/dist/client/auth/types/AppleLoginBody.d.ts +68 -0
  35. package/dist/client/auth/types/AppleLoginBody.js +17 -0
  36. package/dist/client/auth/types/AuthResponse.d.ts +15 -0
  37. package/dist/client/auth/types/AuthResponse.js +2 -0
  38. package/dist/client/auth/types/ChangePasswordBody.d.ts +5 -0
  39. package/dist/client/auth/types/ChangePasswordBody.js +2 -0
  40. package/dist/client/auth/types/GoogleLoginBody.d.ts +26 -0
  41. package/dist/client/auth/types/GoogleLoginBody.js +2 -0
  42. package/dist/client/auth/types/LoginBody.d.ts +26 -0
  43. package/dist/client/auth/types/LoginBody.js +2 -0
  44. package/dist/client/auth/types/RegisterBody.d.ts +8 -0
  45. package/dist/client/auth/types/RegisterBody.js +2 -0
  46. package/dist/client/auth/types/RequestDeleteUserBody.d.ts +11 -0
  47. package/dist/client/auth/types/RequestDeleteUserBody.js +2 -0
  48. package/dist/client/auth/types/RequestDeleteUserResponse.d.ts +12 -0
  49. package/dist/client/auth/types/RequestDeleteUserResponse.js +2 -0
  50. package/dist/client/auth/types/ResetPasswordBody.d.ts +14 -0
  51. package/dist/client/auth/types/ResetPasswordBody.js +2 -0
  52. package/dist/client/auth/types/StartLoginResponse.d.ts +34 -0
  53. package/dist/client/auth/types/StartLoginResponse.js +2 -0
  54. package/dist/client/bot/methods/executeBot.d.ts +10 -0
  55. package/dist/client/bot/methods/executeBot.js +14 -0
  56. package/dist/client/bot/methods/index.d.ts +1 -0
  57. package/dist/client/bot/methods/index.js +17 -0
  58. package/dist/client/chat/ai/methods/createAiSession.d.ts +4 -0
  59. package/dist/client/chat/ai/methods/createAiSession.js +17 -0
  60. package/dist/client/chat/ai/methods/index.d.ts +1 -0
  61. package/dist/client/chat/ai/methods/index.js +17 -0
  62. package/dist/client/chat/ai/types/CreateAiSessionProps.d.ts +51 -0
  63. package/dist/client/chat/ai/types/CreateAiSessionProps.js +2 -0
  64. package/dist/client/chat/ai/types/CreateAiSessionResponse.d.ts +21 -0
  65. package/dist/client/chat/ai/types/CreateAiSessionResponse.js +2 -0
  66. package/dist/client/chat/ai/types/SessionMessagesResponse.d.ts +9 -0
  67. package/dist/client/chat/ai/types/SessionMessagesResponse.js +2 -0
  68. package/dist/client/observation/methods/generateObservationBodiesByMeasurement.d.ts +4 -0
  69. package/dist/client/observation/methods/generateObservationBodiesByMeasurement.js +40 -0
  70. package/dist/client/observation/methods/getLatestObservationsByCodes.d.ts +4 -0
  71. package/dist/client/observation/methods/getLatestObservationsByCodes.js +19 -0
  72. package/dist/client/observation/methods/index.d.ts +2 -0
  73. package/dist/client/observation/methods/index.js +18 -0
  74. package/dist/client/observation/services/base-observation-service.d.ts +22 -0
  75. package/dist/client/observation/services/base-observation-service.js +70 -0
  76. package/dist/client/observation/services/blood-glucose.d.ts +12 -0
  77. package/dist/client/observation/services/blood-glucose.js +36 -0
  78. package/dist/client/observation/services/blood-oxygen.d.ts +14 -0
  79. package/dist/client/observation/services/blood-oxygen.js +57 -0
  80. package/dist/client/observation/services/blood-pressure.d.ts +15 -0
  81. package/dist/client/observation/services/blood-pressure.js +72 -0
  82. package/dist/client/observation/services/body-temperature.d.ts +13 -0
  83. package/dist/client/observation/services/body-temperature.js +36 -0
  84. package/dist/client/observation/services/body-weight.d.ts +13 -0
  85. package/dist/client/observation/services/body-weight.js +36 -0
  86. package/dist/client/observation/services/creator.d.ts +10 -0
  87. package/dist/client/observation/services/creator.js +54 -0
  88. package/dist/client/observation/services/ecg.d.ts +16 -0
  89. package/dist/client/observation/services/ecg.js +110 -0
  90. package/dist/client/observation/services/heart-rate-variability.d.ts +13 -0
  91. package/dist/client/observation/services/heart-rate-variability.js +38 -0
  92. package/dist/client/observation/services/heart-rate.d.ts +13 -0
  93. package/dist/client/observation/services/heart-rate.js +39 -0
  94. package/dist/client/observation/services/index.d.ts +1 -0
  95. package/dist/client/observation/services/index.js +17 -0
  96. package/dist/client/observation/services/respiratory-rate.d.ts +13 -0
  97. package/dist/client/observation/services/respiratory-rate.js +38 -0
  98. package/dist/client/observation/services/resting-heart-rate.d.ts +13 -0
  99. package/dist/client/observation/services/resting-heart-rate.js +38 -0
  100. package/dist/client/observation/services/step-count.d.ts +15 -0
  101. package/dist/client/observation/services/step-count.js +55 -0
  102. package/dist/client/observation/services/uric-acid-service.d.ts +21 -0
  103. package/dist/client/observation/services/uric-acid-service.js +120 -0
  104. package/dist/client/observation/services/vo2-max.d.ts +13 -0
  105. package/dist/client/observation/services/vo2-max.js +38 -0
  106. package/dist/client/observation/services/walking-heart-rate-average.d.ts +12 -0
  107. package/dist/client/observation/services/walking-heart-rate-average.js +38 -0
  108. package/dist/client/observation/types/GetLatestObservationsByCodeParams.d.ts +9 -0
  109. package/dist/client/observation/types/GetLatestObservationsByCodeParams.js +2 -0
  110. package/dist/client/observation/types/IObservationService.d.ts +15 -0
  111. package/dist/client/observation/types/IObservationService.js +2 -0
  112. package/dist/client/observation/types/MeasurementTypeKey.d.ts +20 -0
  113. package/dist/client/observation/types/MeasurementTypeKey.js +24 -0
  114. package/dist/client/observation/types/ObservationCode.d.ts +37 -0
  115. package/dist/client/observation/types/ObservationCode.js +41 -0
  116. package/dist/client/observation/types/generate-measurement/HealthConnectTypes.d.ts +641 -0
  117. package/dist/client/observation/types/generate-measurement/HealthConnectTypes.js +45 -0
  118. package/dist/client/observation/types/generate-measurement/Sample.d.ts +32 -0
  119. package/dist/client/observation/types/generate-measurement/Sample.js +2 -0
  120. package/dist/client/observation/types/generate-observation-body/BodyWeightValueParams.d.ts +1 -0
  121. package/dist/client/observation/types/generate-observation-body/BodyWeightValueParams.js +2 -0
  122. package/dist/client/observation/types/generate-observation-body/GenerateObservationBodyParams.d.ts +7 -0
  123. package/dist/client/observation/types/generate-observation-body/GenerateObservationBodyParams.js +2 -0
  124. package/dist/client/observation/types/generate-observation-body/ObservationValue.d.ts +14 -0
  125. package/dist/client/observation/types/generate-observation-body/ObservationValue.js +2 -0
  126. package/dist/client/observation/types/measurement/BloodGlucoseMeasurement.d.ts +6 -0
  127. package/dist/client/observation/types/measurement/BloodGlucoseMeasurement.js +2 -0
  128. package/dist/client/observation/types/measurement/BloodPressureMeasurement.d.ts +10 -0
  129. package/dist/client/observation/types/measurement/BloodPressureMeasurement.js +2 -0
  130. package/dist/client/observation/types/measurement/BloodPressureStates.d.ts +7 -0
  131. package/dist/client/observation/types/measurement/BloodPressureStates.js +11 -0
  132. package/dist/client/observation/types/measurement/BodyTemperatureMeasurement.d.ts +6 -0
  133. package/dist/client/observation/types/measurement/BodyTemperatureMeasurement.js +2 -0
  134. package/dist/client/observation/types/measurement/BodyWeightMeasurmement.d.ts +7 -0
  135. package/dist/client/observation/types/measurement/BodyWeightMeasurmement.js +2 -0
  136. package/dist/client/observation/types/measurement/EcgDiagnosticFlag.d.ts +15 -0
  137. package/dist/client/observation/types/measurement/EcgDiagnosticFlag.js +19 -0
  138. package/dist/client/observation/types/measurement/EcgMeasurement.d.ts +13 -0
  139. package/dist/client/observation/types/measurement/EcgMeasurement.js +2 -0
  140. package/dist/client/observation/types/measurement/HeartRateMeasurement.d.ts +6 -0
  141. package/dist/client/observation/types/measurement/HeartRateMeasurement.js +2 -0
  142. package/dist/client/observation/types/measurement/HeartRateVariabilityMeasurement.d.ts +6 -0
  143. package/dist/client/observation/types/measurement/HeartRateVariabilityMeasurement.js +2 -0
  144. package/dist/client/observation/types/measurement/Measurement.d.ts +4 -0
  145. package/dist/client/observation/types/measurement/Measurement.js +2 -0
  146. package/dist/client/observation/types/measurement/MeasurementDevice.d.ts +7 -0
  147. package/dist/client/observation/types/measurement/MeasurementDevice.js +2 -0
  148. package/dist/client/observation/types/measurement/PulseOximeterMeasurement.d.ts +9 -0
  149. package/dist/client/observation/types/measurement/PulseOximeterMeasurement.js +2 -0
  150. package/dist/client/observation/types/measurement/RespiratoryRateMeasurement.d.ts +6 -0
  151. package/dist/client/observation/types/measurement/RespiratoryRateMeasurement.js +2 -0
  152. package/dist/client/observation/types/measurement/RestingHeartRateMeasurement.d.ts +6 -0
  153. package/dist/client/observation/types/measurement/RestingHeartRateMeasurement.js +2 -0
  154. package/dist/client/observation/types/measurement/SpirometryMeasurement.d.ts +21 -0
  155. package/dist/client/observation/types/measurement/SpirometryMeasurement.js +2 -0
  156. package/dist/client/observation/types/measurement/StepCountMeasurement.d.ts +8 -0
  157. package/dist/client/observation/types/measurement/StepCountMeasurement.js +2 -0
  158. package/dist/client/observation/types/measurement/UrineAnalyzeMeasurement.d.ts +23 -0
  159. package/dist/client/observation/types/measurement/UrineAnalyzeMeasurement.js +2 -0
  160. package/dist/client/observation/types/measurement/Vo2MaxMeasurement.d.ts +6 -0
  161. package/dist/client/observation/types/measurement/Vo2MaxMeasurement.js +2 -0
  162. package/dist/client/observation/types/measurement/WalkingHeartRateAverageMeasurement.d.ts +6 -0
  163. package/dist/client/observation/types/measurement/WalkingHeartRateAverageMeasurement.js +2 -0
  164. package/dist/client/observation/types/measurement/index.d.ts +11 -0
  165. package/dist/client/observation/types/measurement/index.js +27 -0
  166. package/dist/client/observation/types/service/ObservationMetadata.d.ts +8 -0
  167. package/dist/client/observation/types/service/ObservationMetadata.js +2 -0
  168. package/dist/client/observation/utils/getDeviceObject.d.ts +3 -0
  169. package/dist/client/observation/utils/getDeviceObject.js +34 -0
  170. package/dist/client/observation/utils/getObservationValueDisplay.d.ts +15 -0
  171. package/dist/client/observation/utils/getObservationValueDisplay.js +25 -0
  172. package/dist/client/observation/utils/index.d.ts +1 -0
  173. package/dist/client/observation/utils/index.js +17 -0
  174. package/dist/client/ovok-client.d.ts +35 -0
  175. package/dist/client/ovok-client.js +85 -0
  176. package/dist/client/questionnaire-response/methods/createQuestionnaireResponseWithObservations.d.ts +3 -0
  177. package/dist/client/questionnaire-response/methods/createQuestionnaireResponseWithObservations.js +28 -0
  178. package/dist/client/questionnaire-response/methods/index.d.ts +1 -0
  179. package/dist/client/questionnaire-response/methods/index.js +17 -0
  180. package/dist/hooks/index.d.ts +7 -0
  181. package/dist/hooks/index.js +58 -0
  182. package/dist/index.d.ts +666 -0
  183. package/dist/index.js +49 -0
  184. package/dist/types/ValidationError.d.ts +6 -0
  185. package/dist/types/ValidationError.js +2 -0
  186. package/dist/types/index.d.ts +17 -0
  187. package/dist/types/index.js +38 -0
  188. package/dist/utils/auth/exchange-code.d.ts +14 -0
  189. package/dist/utils/auth/exchange-code.js +17 -0
  190. package/dist/utils/auth/generate-code-challenge-and-verifier.d.ts +6 -0
  191. package/dist/utils/auth/generate-code-challenge-and-verifier.js +45 -0
  192. package/dist/utils/auth/handle-tenant-code.d.ts +6 -0
  193. package/dist/utils/auth/handle-tenant-code.js +21 -0
  194. package/dist/utils/auth/sha256.d.ts +8 -0
  195. package/dist/utils/auth/sha256.js +300 -0
  196. package/dist/utils/auth/start-login.d.ts +10 -0
  197. package/dist/utils/auth/start-login.js +19 -0
  198. package/dist/utils/index.d.ts +2 -0
  199. package/dist/utils/index.js +18 -0
  200. package/dist/utils/patch/getPatchOperationType.d.ts +2 -0
  201. package/dist/utils/patch/getPatchOperationType.js +16 -0
  202. package/package.json +83 -0
package/dist/index.js ADDED
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.OvokClient = exports.Medplum = void 0;
40
+ const MedplumCore = __importStar(require("@medplum/core"));
41
+ __exportStar(require("./types"), exports);
42
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
43
+ const { MedplumClient, ...Medplum } = MedplumCore;
44
+ exports.Medplum = Medplum;
45
+ var ovok_client_1 = require("./client/ovok-client");
46
+ Object.defineProperty(exports, "OvokClient", { enumerable: true, get: function () { return ovok_client_1.OvokClient; } });
47
+ __exportStar(require("./hooks"), exports);
48
+ __exportStar(require("./utils"), exports);
49
+ __exportStar(require("./client/observation/services"), exports);
@@ -0,0 +1,6 @@
1
+ export type ValidationError = {
2
+ code: string;
3
+ message: string;
4
+ path: string[];
5
+ validation: string;
6
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,17 @@
1
+ export * from "../client/auth/types/AuthResponse";
2
+ export * from "../client/auth/types/LoginBody";
3
+ export * from "../client/auth/types/RegisterBody";
4
+ export * from "../client/auth/types/ChangePasswordBody";
5
+ export * from "../client/auth/types/RequestDeleteUserBody";
6
+ export * from "../client/auth/types/ResetPasswordBody";
7
+ export * from "../client/observation/types/MeasurementTypeKey";
8
+ export * from "../client/observation/types/ObservationCode";
9
+ export * from "../client/observation/types/measurement";
10
+ export * from "../client/observation/types/generate-measurement/Sample";
11
+ export * from "../client/observation/types/GetLatestObservationsByCodeParams";
12
+ export * from "../client/chat/ai/types/CreateAiSessionProps";
13
+ export * from "../client/chat/ai/types/SessionMessagesResponse";
14
+ export * from "../client/chat/ai/types/CreateAiSessionResponse";
15
+ export * from "../client/ai-fhir/types";
16
+ export * from "./ValidationError";
17
+ export * from "@medplum/core";
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ // Auth types
18
+ __exportStar(require("../client/auth/types/AuthResponse"), exports);
19
+ __exportStar(require("../client/auth/types/LoginBody"), exports);
20
+ __exportStar(require("../client/auth/types/RegisterBody"), exports);
21
+ __exportStar(require("../client/auth/types/ChangePasswordBody"), exports);
22
+ __exportStar(require("../client/auth/types/RequestDeleteUserBody"), exports);
23
+ __exportStar(require("../client/auth/types/ResetPasswordBody"), exports);
24
+ // Measurement types
25
+ __exportStar(require("../client/observation/types/MeasurementTypeKey"), exports);
26
+ __exportStar(require("../client/observation/types/ObservationCode"), exports);
27
+ __exportStar(require("../client/observation/types/measurement"), exports);
28
+ __exportStar(require("../client/observation/types/generate-measurement/Sample"), exports);
29
+ // Observation types
30
+ __exportStar(require("../client/observation/types/GetLatestObservationsByCodeParams"), exports);
31
+ // Chat types
32
+ __exportStar(require("../client/chat/ai/types/CreateAiSessionProps"), exports);
33
+ __exportStar(require("../client/chat/ai/types/SessionMessagesResponse"), exports);
34
+ __exportStar(require("../client/chat/ai/types/CreateAiSessionResponse"), exports);
35
+ __exportStar(require("../client/ai-fhir/types"), exports);
36
+ // Common types
37
+ __exportStar(require("./ValidationError"), exports);
38
+ __exportStar(require("@medplum/core"), exports);
@@ -0,0 +1,14 @@
1
+ import { OvokClient } from "../../client/ovok-client";
2
+ import { AuthResponse } from "../../types";
3
+ type ExchangeCodeProps = {
4
+ client: OvokClient;
5
+ sessionCode: string;
6
+ codeVerifier: string;
7
+ } & ({
8
+ type: "Patient";
9
+ } | {
10
+ type: "Practitioner";
11
+ tenantCode: string;
12
+ });
13
+ export declare const exchangeCode: ({ ...props }: ExchangeCodeProps) => Promise<AuthResponse>;
14
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.exchangeCode = void 0;
4
+ const exchangeCode = async ({ ...props }) => {
5
+ if (props.type === "Practitioner") {
6
+ return props.client.post("auth/tenant/Practitioner/login/token", {
7
+ sessionCode: props.sessionCode,
8
+ codeVerifier: props.codeVerifier,
9
+ tenantCode: props.tenantCode,
10
+ });
11
+ }
12
+ return props.client.post("auth/tenant/Patient/login/token", {
13
+ sessionCode: props.sessionCode,
14
+ codeVerifier: props.codeVerifier,
15
+ });
16
+ };
17
+ exports.exchangeCode = exchangeCode;
@@ -0,0 +1,6 @@
1
+ interface PKCEPair {
2
+ codeVerifier: string;
3
+ codeChallenge: string;
4
+ }
5
+ export declare function generateCodeChallengeAndVerifier(): PKCEPair;
6
+ export {};
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateCodeChallengeAndVerifier = generateCodeChallengeAndVerifier;
4
+ const sha256_1 = require("./sha256");
5
+ function generateRandomString(length) {
6
+ const charset = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~";
7
+ let result = "";
8
+ const randomValues = new Uint8Array(length);
9
+ if (typeof crypto !== "undefined" && crypto.getRandomValues) {
10
+ crypto.getRandomValues(randomValues);
11
+ }
12
+ else {
13
+ for (let i = 0; i < length; i++) {
14
+ randomValues[i] = Math.floor(Math.random() * 256);
15
+ }
16
+ }
17
+ for (let i = 0; i < length; i++) {
18
+ result += charset[randomValues[i] % charset.length];
19
+ }
20
+ return result;
21
+ }
22
+ function hexToUint8Array(hex) {
23
+ const bytes = new Uint8Array(hex.length / 2);
24
+ for (let i = 0; i < hex.length; i += 2) {
25
+ bytes[i / 2] = parseInt(hex.substring(i, i + 2), 16);
26
+ }
27
+ return bytes;
28
+ }
29
+ function base64URLEncode(data) {
30
+ let binary = "";
31
+ for (let i = 0; i < data.length; i++) {
32
+ binary += String.fromCharCode(data[i]);
33
+ }
34
+ return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
35
+ }
36
+ function generateCodeChallengeAndVerifier() {
37
+ const codeVerifier = generateRandomString(128);
38
+ const hexHash = sha256_1.sha256.hex(codeVerifier);
39
+ const hashBytes = hexToUint8Array(hexHash);
40
+ const codeChallenge = base64URLEncode(hashBytes);
41
+ return {
42
+ codeVerifier,
43
+ codeChallenge,
44
+ };
45
+ }
@@ -0,0 +1,6 @@
1
+ import { StartLoginResponse } from "../../client/auth/types/StartLoginResponse";
2
+ export declare const handleTenantCode: ({ profiles, tenantCode, type, }: {
3
+ profiles: StartLoginResponse["profiles"];
4
+ tenantCode?: string;
5
+ type: "Practitioner" | "Patient";
6
+ }) => string | undefined;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.handleTenantCode = void 0;
4
+ const handleTenantCode = ({ profiles, tenantCode, type, }) => {
5
+ var _a;
6
+ if (type !== "Practitioner") {
7
+ return tenantCode;
8
+ }
9
+ if (!profiles || !(profiles === null || profiles === void 0 ? void 0 : profiles.length)) {
10
+ throw new Error("No profiles found");
11
+ }
12
+ if (!tenantCode) {
13
+ return (_a = profiles === null || profiles === void 0 ? void 0 : profiles[0]) === null || _a === void 0 ? void 0 : _a.tenantCode;
14
+ }
15
+ const matchingProfile = profiles.find((profile) => profile.tenantCode === tenantCode);
16
+ if (!matchingProfile) {
17
+ throw new Error("No matching profile found");
18
+ }
19
+ return matchingProfile.tenantCode;
20
+ };
21
+ exports.handleTenantCode = handleTenantCode;
@@ -0,0 +1,8 @@
1
+ export declare const sha256: {
2
+ hex: (s: string) => string;
3
+ b64: (k: string, d: string) => string;
4
+ any: (k: string, d: string, e: string) => string;
5
+ hex_hmac: (k: string, d: string) => string;
6
+ b64_hmac: (k: string, d: string) => string;
7
+ any_hmac: (k: string, d: string, e: string) => string;
8
+ };
@@ -0,0 +1,300 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sha256 = void 0;
4
+ /* eslint-disable max-lines */
5
+ exports.sha256 = (function () {
6
+ /*
7
+ * Configurable variables. You may need to tweak these to be compatible with
8
+ * the server-side, but the defaults work in most cases.
9
+ */
10
+ let hexcase = 0; /* hex output format. 0 - lowercase; 1 - uppercase */
11
+ let b64pad = ""; /* base-64 pad character. "=" for strict RFC compliance */
12
+ /*
13
+ * These are the functions you'll usually want to call
14
+ * They take string arguments and return either hex or base-64 encoded strings
15
+ */
16
+ function hex_sha256(s) {
17
+ return rstr2hex(rstr_sha256(str2rstr_utf8(s)));
18
+ }
19
+ function hex_hmac_sha256(k, d) {
20
+ return rstr2hex(rstr_hmac_sha256(str2rstr_utf8(k), str2rstr_utf8(d)));
21
+ }
22
+ function b64_hmac_sha256(k, d) {
23
+ return rstr2b64(rstr_hmac_sha256(str2rstr_utf8(k), str2rstr_utf8(d)));
24
+ }
25
+ function any_hmac_sha256(k, d, e) {
26
+ return rstr2any(rstr_hmac_sha256(str2rstr_utf8(k), str2rstr_utf8(d)), e);
27
+ }
28
+ /*
29
+ * Calculate the sha256 of a raw string
30
+ */
31
+ function rstr_sha256(s) {
32
+ return binb2rstr(binb_sha256(rstr2binb(s), s.length * 8));
33
+ }
34
+ /*
35
+ * Calculate the HMAC-sha256 of a key and some data (raw strings)
36
+ */
37
+ function rstr_hmac_sha256(key, data) {
38
+ let bkey = rstr2binb(key);
39
+ if (bkey.length > 16) {
40
+ bkey = binb_sha256(bkey, key.length * 8);
41
+ }
42
+ const ipad = Array(16), opad = Array(16);
43
+ for (let i = 0; i < 16; i++) {
44
+ ipad[i] = bkey[i] ^ 0x36363636;
45
+ opad[i] = bkey[i] ^ 0x5c5c5c5c;
46
+ }
47
+ const hash = binb_sha256(ipad.concat(rstr2binb(data)), 512 + data.length * 8);
48
+ return binb2rstr(binb_sha256(opad.concat(hash), 512 + 256));
49
+ }
50
+ /*
51
+ * Convert a raw string to a hex string
52
+ */
53
+ function rstr2hex(input) {
54
+ try {
55
+ hexcase;
56
+ }
57
+ catch (_a) {
58
+ hexcase = 0;
59
+ }
60
+ const hex_tab = hexcase ? "0123456789ABCDEF" : "0123456789abcdef";
61
+ let output = "";
62
+ let x;
63
+ for (let i = 0; i < input.length; i++) {
64
+ x = input.charCodeAt(i);
65
+ output += hex_tab.charAt((x >>> 4) & 0x0f) + hex_tab.charAt(x & 0x0f);
66
+ }
67
+ return output;
68
+ }
69
+ /*
70
+ * Convert a raw string to a base-64 string
71
+ */
72
+ function rstr2b64(input) {
73
+ try {
74
+ b64pad;
75
+ }
76
+ catch (_a) {
77
+ b64pad = "";
78
+ }
79
+ const tab = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
80
+ let output = "";
81
+ const len = input.length;
82
+ for (let i = 0; i < len; i += 3) {
83
+ const triplet = (input.charCodeAt(i) << 16) |
84
+ (i + 1 < len ? input.charCodeAt(i + 1) << 8 : 0) |
85
+ (i + 2 < len ? input.charCodeAt(i + 2) : 0);
86
+ for (let j = 0; j < 4; j++) {
87
+ if (i * 8 + j * 6 > input.length * 8) {
88
+ output += b64pad;
89
+ }
90
+ else {
91
+ output += tab.charAt((triplet >>> (6 * (3 - j))) & 0x3f);
92
+ }
93
+ }
94
+ }
95
+ return output;
96
+ }
97
+ /*
98
+ * Convert a raw string to an arbitrary string encoding
99
+ */
100
+ function rstr2any(input, encoding) {
101
+ const divisor = encoding.length;
102
+ const remainders = [];
103
+ let i, q, x, quotient;
104
+ /* Convert to an array of 16-bit big-endian values, forming the dividend */
105
+ let dividend = Array(Math.ceil(input.length / 2));
106
+ for (i = 0; i < dividend.length; i++) {
107
+ dividend[i] =
108
+ (input.charCodeAt(i * 2) << 8) | input.charCodeAt(i * 2 + 1);
109
+ }
110
+ /*
111
+ * Repeatedly perform a long division. The binary array forms the dividend,
112
+ * the length of the encoding is the divisor. Once computed, the quotient
113
+ * forms the dividend for the next step. We stop when the dividend is zero.
114
+ * All remainders are stored for later use.
115
+ */
116
+ while (dividend.length > 0) {
117
+ quotient = [];
118
+ x = 0;
119
+ for (i = 0; i < dividend.length; i++) {
120
+ x = (x << 16) + dividend[i];
121
+ q = Math.floor(x / divisor);
122
+ x -= q * divisor;
123
+ if (quotient.length > 0 || q > 0) {
124
+ quotient[quotient.length] = q;
125
+ }
126
+ }
127
+ remainders[remainders.length] = x;
128
+ dividend = quotient;
129
+ }
130
+ /* Convert the remainders to the output string */
131
+ let output = "";
132
+ for (i = remainders.length - 1; i >= 0; i--) {
133
+ output += encoding.charAt(remainders[i]);
134
+ }
135
+ /* Append leading zero equivalents */
136
+ const full_length = Math.ceil((input.length * 8) / (Math.log(encoding.length) / Math.log(2)));
137
+ for (i = output.length; i < full_length; i++) {
138
+ output = encoding[0] + output;
139
+ }
140
+ return output;
141
+ }
142
+ /*
143
+ * Encode a string as utf-8.
144
+ * For efficiency, this assumes the input is valid utf-16.
145
+ */
146
+ function str2rstr_utf8(input) {
147
+ let output = "";
148
+ let i = -1;
149
+ let x, y;
150
+ while (++i < input.length) {
151
+ /* Decode utf-16 surrogate pairs */
152
+ x = input.charCodeAt(i);
153
+ y = i + 1 < input.length ? input.charCodeAt(i + 1) : 0;
154
+ if (0xd800 <= x && x <= 0xdbff && 0xdc00 <= y && y <= 0xdfff) {
155
+ x = 0x10000 + ((x & 0x03ff) << 10) + (y & 0x03ff);
156
+ i++;
157
+ }
158
+ /* Encode output as utf-8 */
159
+ if (x <= 0x7f) {
160
+ output += String.fromCharCode(x);
161
+ }
162
+ else if (x <= 0x7ff) {
163
+ output += String.fromCharCode(0xc0 | ((x >>> 6) & 0x1f), 0x80 | (x & 0x3f));
164
+ }
165
+ else if (x <= 0xffff) {
166
+ output += String.fromCharCode(0xe0 | ((x >>> 12) & 0x0f), 0x80 | ((x >>> 6) & 0x3f), 0x80 | (x & 0x3f));
167
+ }
168
+ else if (x <= 0x1fffff) {
169
+ output += String.fromCharCode(0xf0 | ((x >>> 18) & 0x07), 0x80 | ((x >>> 12) & 0x3f), 0x80 | ((x >>> 6) & 0x3f), 0x80 | (x & 0x3f));
170
+ }
171
+ }
172
+ return output;
173
+ }
174
+ /*
175
+ * Convert a raw string to an array of big-endian words
176
+ * Characters >255 have their high-byte silently ignored.
177
+ */
178
+ function rstr2binb(input) {
179
+ const output = Array(input.length >> 2);
180
+ for (let i = 0; i < output.length; i++) {
181
+ output[i] = 0;
182
+ }
183
+ for (let i = 0; i < input.length * 8; i += 8) {
184
+ output[i >> 5] |= (input.charCodeAt(i / 8) & 0xff) << (24 - (i % 32));
185
+ }
186
+ return output;
187
+ }
188
+ /*
189
+ * Convert an array of big-endian words to a string
190
+ */
191
+ function binb2rstr(input) {
192
+ let output = "";
193
+ for (let i = 0; i < input.length * 32; i += 8) {
194
+ output += String.fromCharCode((input[i >> 5] >>> (24 - (i % 32))) & 0xff);
195
+ }
196
+ return output;
197
+ }
198
+ /*
199
+ * Main sha256 function, with its support functions
200
+ */
201
+ function sha256_S(X, n) {
202
+ return (X >>> n) | (X << (32 - n));
203
+ }
204
+ function sha256_R(X, n) {
205
+ return X >>> n;
206
+ }
207
+ function sha256_Ch(x, y, z) {
208
+ return (x & y) ^ (~x & z);
209
+ }
210
+ function sha256_Maj(x, y, z) {
211
+ return (x & y) ^ (x & z) ^ (y & z);
212
+ }
213
+ function sha256_Sigma0256(x) {
214
+ return sha256_S(x, 2) ^ sha256_S(x, 13) ^ sha256_S(x, 22);
215
+ }
216
+ function sha256_Sigma1256(x) {
217
+ return sha256_S(x, 6) ^ sha256_S(x, 11) ^ sha256_S(x, 25);
218
+ }
219
+ function sha256_Gamma0256(x) {
220
+ return sha256_S(x, 7) ^ sha256_S(x, 18) ^ sha256_R(x, 3);
221
+ }
222
+ function sha256_Gamma1256(x) {
223
+ return sha256_S(x, 17) ^ sha256_S(x, 19) ^ sha256_R(x, 10);
224
+ }
225
+ const sha256_K = [
226
+ 1116352408, 1899447441, -1245643825, -373957723, 961987163, 1508970993,
227
+ -1841331548, -1424204075, -670586216, 310598401, 607225278, 1426881987,
228
+ 1925078388, -2132889090, -1680079193, -1046744716, -459576895, -272742522,
229
+ 264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986,
230
+ -1740746414, -1473132947, -1341970488, -1084653625, -958395405, -710438585,
231
+ 113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291,
232
+ 1695183700, 1986661051, -2117940946, -1838011259, -1564481375, -1474664885,
233
+ -1035236496, -949202525, -778901479, -694614492, -200395387, 275423344,
234
+ 430227734, 506948616, 659060556, 883997877, 958139571, 1322822218,
235
+ 1537002063, 1747873779, 1955562222, 2024104815, -2067236844, -1933114872,
236
+ -1866530822, -1538233109, -1090935817, -965641998,
237
+ ];
238
+ function binb_sha256(m, l) {
239
+ const HASH = [
240
+ 1779033703, -1150833019, 1013904242, -1521486534, 1359893119, -1694144372,
241
+ 528734635, 1541459225,
242
+ ];
243
+ const W = new Array(64);
244
+ let a, b, c, d, e, f, g, h;
245
+ let i, j, T1, T2;
246
+ /* append padding */
247
+ m[l >> 5] |= 0x80 << (24 - (l % 32));
248
+ m[(((l + 64) >> 9) << 4) + 15] = l;
249
+ for (i = 0; i < m.length; i += 16) {
250
+ a = HASH[0];
251
+ b = HASH[1];
252
+ c = HASH[2];
253
+ d = HASH[3];
254
+ e = HASH[4];
255
+ f = HASH[5];
256
+ g = HASH[6];
257
+ h = HASH[7];
258
+ for (j = 0; j < 64; j++) {
259
+ if (j < 16) {
260
+ W[j] = m[j + i];
261
+ }
262
+ else {
263
+ W[j] = safe_add(safe_add(safe_add(sha256_Gamma1256(W[j - 2]), W[j - 7]), sha256_Gamma0256(W[j - 15])), W[j - 16]);
264
+ }
265
+ T1 = safe_add(safe_add(safe_add(safe_add(h, sha256_Sigma1256(e)), sha256_Ch(e, f, g)), sha256_K[j]), W[j]);
266
+ T2 = safe_add(sha256_Sigma0256(a), sha256_Maj(a, b, c));
267
+ h = g;
268
+ g = f;
269
+ f = e;
270
+ e = safe_add(d, T1);
271
+ d = c;
272
+ c = b;
273
+ b = a;
274
+ a = safe_add(T1, T2);
275
+ }
276
+ HASH[0] = safe_add(a, HASH[0]);
277
+ HASH[1] = safe_add(b, HASH[1]);
278
+ HASH[2] = safe_add(c, HASH[2]);
279
+ HASH[3] = safe_add(d, HASH[3]);
280
+ HASH[4] = safe_add(e, HASH[4]);
281
+ HASH[5] = safe_add(f, HASH[5]);
282
+ HASH[6] = safe_add(g, HASH[6]);
283
+ HASH[7] = safe_add(h, HASH[7]);
284
+ }
285
+ return HASH;
286
+ }
287
+ function safe_add(x, y) {
288
+ const lsw = (x & 0xffff) + (y & 0xffff);
289
+ const msw = (x >> 16) + (y >> 16) + (lsw >> 16);
290
+ return (msw << 16) | (lsw & 0xffff);
291
+ }
292
+ return {
293
+ hex: hex_sha256,
294
+ b64: b64_hmac_sha256,
295
+ any: any_hmac_sha256,
296
+ hex_hmac: hex_hmac_sha256,
297
+ b64_hmac: b64_hmac_sha256,
298
+ any_hmac: any_hmac_sha256,
299
+ };
300
+ })();
@@ -0,0 +1,10 @@
1
+ import { StartLoginResponse } from "../../client/auth/types/StartLoginResponse";
2
+ import { OvokClient } from "../../client/ovok-client";
3
+ import { LoginBody } from "../../types";
4
+ type StartLoginProps = {
5
+ client: OvokClient;
6
+ body: LoginBody;
7
+ codeChallenge: string;
8
+ };
9
+ export declare const startLogin: ({ client, body, codeChallenge, }: StartLoginProps) => Promise<StartLoginResponse>;
10
+ export {};
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startLogin = void 0;
4
+ const startLogin = async ({ client, body, codeChallenge, }) => {
5
+ if (body.type === "Patient") {
6
+ return client.post("auth/tenant/Patient/login/start", {
7
+ email: body.email,
8
+ password: body.password,
9
+ codeChallenge,
10
+ tenantCode: body.tenantCode,
11
+ }, "application/json");
12
+ }
13
+ return client.post("auth/tenant/Practitioner/login/start", {
14
+ email: body.email,
15
+ password: body.password,
16
+ codeChallenge,
17
+ }, "application/json");
18
+ };
19
+ exports.startLogin = startLogin;
@@ -0,0 +1,2 @@
1
+ export * from "./patch/getPatchOperationType";
2
+ export * from "../client/observation/utils";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./patch/getPatchOperationType"), exports);
18
+ __exportStar(require("../client/observation/utils"), exports);
@@ -0,0 +1,2 @@
1
+ import { PatchOperation } from "@medplum/core";
2
+ export declare const getPatchOperationType: (oldValue: any, newValue: any) => PatchOperation["op"] | undefined;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPatchOperationType = void 0;
4
+ const getPatchOperationType = (oldValue, newValue) => {
5
+ if (oldValue === newValue) {
6
+ return undefined;
7
+ }
8
+ if (!newValue) {
9
+ return "remove";
10
+ }
11
+ if (!oldValue) {
12
+ return "add";
13
+ }
14
+ return "replace";
15
+ };
16
+ exports.getPatchOperationType = getPatchOperationType;