@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.
- package/README.md +40 -0
- package/dist/client/ai-fhir/methods/AIFhirResources.d.ts +14 -0
- package/dist/client/ai-fhir/methods/AIFhirResources.js +16 -0
- package/dist/client/ai-fhir/methods/index.d.ts +1 -0
- package/dist/client/ai-fhir/methods/index.js +17 -0
- package/dist/client/ai-fhir/types/AIFhirPlan.d.ts +6 -0
- package/dist/client/ai-fhir/types/AIFhirPlan.js +2 -0
- package/dist/client/ai-fhir/types/AIFhirPlanRequest.d.ts +5 -0
- package/dist/client/ai-fhir/types/AIFhirPlanRequest.js +2 -0
- package/dist/client/ai-fhir/types/AIFhirRequest.d.ts +7 -0
- package/dist/client/ai-fhir/types/AIFhirRequest.js +2 -0
- package/dist/client/ai-fhir/types/AIFhirResponse.d.ts +18 -0
- package/dist/client/ai-fhir/types/AIFhirResponse.js +2 -0
- package/dist/client/ai-fhir/types/index.d.ts +4 -0
- package/dist/client/ai-fhir/types/index.js +20 -0
- package/dist/client/auth/methods/appleLogin.d.ts +4 -0
- package/dist/client/auth/methods/appleLogin.js +11 -0
- package/dist/client/auth/methods/changePassword.d.ts +4 -0
- package/dist/client/auth/methods/changePassword.js +6 -0
- package/dist/client/auth/methods/googleLogin.d.ts +4 -0
- package/dist/client/auth/methods/googleLogin.js +11 -0
- package/dist/client/auth/methods/index.d.ts +8 -0
- package/dist/client/auth/methods/index.js +24 -0
- package/dist/client/auth/methods/login.d.ts +4 -0
- package/dist/client/auth/methods/login.js +38 -0
- package/dist/client/auth/methods/refetchProfile.d.ts +2 -0
- package/dist/client/auth/methods/refetchProfile.js +9 -0
- package/dist/client/auth/methods/register.d.ts +4 -0
- package/dist/client/auth/methods/register.js +15 -0
- package/dist/client/auth/methods/requestDeleteUser.d.ts +11 -0
- package/dist/client/auth/methods/requestDeleteUser.js +13 -0
- package/dist/client/auth/methods/resetPassword.d.ts +13 -0
- package/dist/client/auth/methods/resetPassword.js +19 -0
- package/dist/client/auth/types/AppleLoginBody.d.ts +68 -0
- package/dist/client/auth/types/AppleLoginBody.js +17 -0
- package/dist/client/auth/types/AuthResponse.d.ts +15 -0
- package/dist/client/auth/types/AuthResponse.js +2 -0
- package/dist/client/auth/types/ChangePasswordBody.d.ts +5 -0
- package/dist/client/auth/types/ChangePasswordBody.js +2 -0
- package/dist/client/auth/types/GoogleLoginBody.d.ts +26 -0
- package/dist/client/auth/types/GoogleLoginBody.js +2 -0
- package/dist/client/auth/types/LoginBody.d.ts +26 -0
- package/dist/client/auth/types/LoginBody.js +2 -0
- package/dist/client/auth/types/RegisterBody.d.ts +8 -0
- package/dist/client/auth/types/RegisterBody.js +2 -0
- package/dist/client/auth/types/RequestDeleteUserBody.d.ts +11 -0
- package/dist/client/auth/types/RequestDeleteUserBody.js +2 -0
- package/dist/client/auth/types/RequestDeleteUserResponse.d.ts +12 -0
- package/dist/client/auth/types/RequestDeleteUserResponse.js +2 -0
- package/dist/client/auth/types/ResetPasswordBody.d.ts +14 -0
- package/dist/client/auth/types/ResetPasswordBody.js +2 -0
- package/dist/client/auth/types/StartLoginResponse.d.ts +34 -0
- package/dist/client/auth/types/StartLoginResponse.js +2 -0
- package/dist/client/bot/methods/executeBot.d.ts +10 -0
- package/dist/client/bot/methods/executeBot.js +14 -0
- package/dist/client/bot/methods/index.d.ts +1 -0
- package/dist/client/bot/methods/index.js +17 -0
- package/dist/client/chat/ai/methods/createAiSession.d.ts +4 -0
- package/dist/client/chat/ai/methods/createAiSession.js +17 -0
- package/dist/client/chat/ai/methods/index.d.ts +1 -0
- package/dist/client/chat/ai/methods/index.js +17 -0
- package/dist/client/chat/ai/types/CreateAiSessionProps.d.ts +51 -0
- package/dist/client/chat/ai/types/CreateAiSessionProps.js +2 -0
- package/dist/client/chat/ai/types/CreateAiSessionResponse.d.ts +21 -0
- package/dist/client/chat/ai/types/CreateAiSessionResponse.js +2 -0
- package/dist/client/chat/ai/types/SessionMessagesResponse.d.ts +9 -0
- package/dist/client/chat/ai/types/SessionMessagesResponse.js +2 -0
- package/dist/client/observation/methods/generateObservationBodiesByMeasurement.d.ts +4 -0
- package/dist/client/observation/methods/generateObservationBodiesByMeasurement.js +40 -0
- package/dist/client/observation/methods/getLatestObservationsByCodes.d.ts +4 -0
- package/dist/client/observation/methods/getLatestObservationsByCodes.js +19 -0
- package/dist/client/observation/methods/index.d.ts +2 -0
- package/dist/client/observation/methods/index.js +18 -0
- package/dist/client/observation/services/base-observation-service.d.ts +22 -0
- package/dist/client/observation/services/base-observation-service.js +70 -0
- package/dist/client/observation/services/blood-glucose.d.ts +12 -0
- package/dist/client/observation/services/blood-glucose.js +36 -0
- package/dist/client/observation/services/blood-oxygen.d.ts +14 -0
- package/dist/client/observation/services/blood-oxygen.js +57 -0
- package/dist/client/observation/services/blood-pressure.d.ts +15 -0
- package/dist/client/observation/services/blood-pressure.js +72 -0
- package/dist/client/observation/services/body-temperature.d.ts +13 -0
- package/dist/client/observation/services/body-temperature.js +36 -0
- package/dist/client/observation/services/body-weight.d.ts +13 -0
- package/dist/client/observation/services/body-weight.js +36 -0
- package/dist/client/observation/services/creator.d.ts +10 -0
- package/dist/client/observation/services/creator.js +54 -0
- package/dist/client/observation/services/ecg.d.ts +16 -0
- package/dist/client/observation/services/ecg.js +110 -0
- package/dist/client/observation/services/heart-rate-variability.d.ts +13 -0
- package/dist/client/observation/services/heart-rate-variability.js +38 -0
- package/dist/client/observation/services/heart-rate.d.ts +13 -0
- package/dist/client/observation/services/heart-rate.js +39 -0
- package/dist/client/observation/services/index.d.ts +1 -0
- package/dist/client/observation/services/index.js +17 -0
- package/dist/client/observation/services/respiratory-rate.d.ts +13 -0
- package/dist/client/observation/services/respiratory-rate.js +38 -0
- package/dist/client/observation/services/resting-heart-rate.d.ts +13 -0
- package/dist/client/observation/services/resting-heart-rate.js +38 -0
- package/dist/client/observation/services/step-count.d.ts +15 -0
- package/dist/client/observation/services/step-count.js +55 -0
- package/dist/client/observation/services/uric-acid-service.d.ts +21 -0
- package/dist/client/observation/services/uric-acid-service.js +120 -0
- package/dist/client/observation/services/vo2-max.d.ts +13 -0
- package/dist/client/observation/services/vo2-max.js +38 -0
- package/dist/client/observation/services/walking-heart-rate-average.d.ts +12 -0
- package/dist/client/observation/services/walking-heart-rate-average.js +38 -0
- package/dist/client/observation/types/GetLatestObservationsByCodeParams.d.ts +9 -0
- package/dist/client/observation/types/GetLatestObservationsByCodeParams.js +2 -0
- package/dist/client/observation/types/IObservationService.d.ts +15 -0
- package/dist/client/observation/types/IObservationService.js +2 -0
- package/dist/client/observation/types/MeasurementTypeKey.d.ts +20 -0
- package/dist/client/observation/types/MeasurementTypeKey.js +24 -0
- package/dist/client/observation/types/ObservationCode.d.ts +37 -0
- package/dist/client/observation/types/ObservationCode.js +41 -0
- package/dist/client/observation/types/generate-measurement/HealthConnectTypes.d.ts +641 -0
- package/dist/client/observation/types/generate-measurement/HealthConnectTypes.js +45 -0
- package/dist/client/observation/types/generate-measurement/Sample.d.ts +32 -0
- package/dist/client/observation/types/generate-measurement/Sample.js +2 -0
- package/dist/client/observation/types/generate-observation-body/BodyWeightValueParams.d.ts +1 -0
- package/dist/client/observation/types/generate-observation-body/BodyWeightValueParams.js +2 -0
- package/dist/client/observation/types/generate-observation-body/GenerateObservationBodyParams.d.ts +7 -0
- package/dist/client/observation/types/generate-observation-body/GenerateObservationBodyParams.js +2 -0
- package/dist/client/observation/types/generate-observation-body/ObservationValue.d.ts +14 -0
- package/dist/client/observation/types/generate-observation-body/ObservationValue.js +2 -0
- package/dist/client/observation/types/measurement/BloodGlucoseMeasurement.d.ts +6 -0
- package/dist/client/observation/types/measurement/BloodGlucoseMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/BloodPressureMeasurement.d.ts +10 -0
- package/dist/client/observation/types/measurement/BloodPressureMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/BloodPressureStates.d.ts +7 -0
- package/dist/client/observation/types/measurement/BloodPressureStates.js +11 -0
- package/dist/client/observation/types/measurement/BodyTemperatureMeasurement.d.ts +6 -0
- package/dist/client/observation/types/measurement/BodyTemperatureMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/BodyWeightMeasurmement.d.ts +7 -0
- package/dist/client/observation/types/measurement/BodyWeightMeasurmement.js +2 -0
- package/dist/client/observation/types/measurement/EcgDiagnosticFlag.d.ts +15 -0
- package/dist/client/observation/types/measurement/EcgDiagnosticFlag.js +19 -0
- package/dist/client/observation/types/measurement/EcgMeasurement.d.ts +13 -0
- package/dist/client/observation/types/measurement/EcgMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/HeartRateMeasurement.d.ts +6 -0
- package/dist/client/observation/types/measurement/HeartRateMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/HeartRateVariabilityMeasurement.d.ts +6 -0
- package/dist/client/observation/types/measurement/HeartRateVariabilityMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/Measurement.d.ts +4 -0
- package/dist/client/observation/types/measurement/Measurement.js +2 -0
- package/dist/client/observation/types/measurement/MeasurementDevice.d.ts +7 -0
- package/dist/client/observation/types/measurement/MeasurementDevice.js +2 -0
- package/dist/client/observation/types/measurement/PulseOximeterMeasurement.d.ts +9 -0
- package/dist/client/observation/types/measurement/PulseOximeterMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/RespiratoryRateMeasurement.d.ts +6 -0
- package/dist/client/observation/types/measurement/RespiratoryRateMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/RestingHeartRateMeasurement.d.ts +6 -0
- package/dist/client/observation/types/measurement/RestingHeartRateMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/SpirometryMeasurement.d.ts +21 -0
- package/dist/client/observation/types/measurement/SpirometryMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/StepCountMeasurement.d.ts +8 -0
- package/dist/client/observation/types/measurement/StepCountMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/UrineAnalyzeMeasurement.d.ts +23 -0
- package/dist/client/observation/types/measurement/UrineAnalyzeMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/Vo2MaxMeasurement.d.ts +6 -0
- package/dist/client/observation/types/measurement/Vo2MaxMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/WalkingHeartRateAverageMeasurement.d.ts +6 -0
- package/dist/client/observation/types/measurement/WalkingHeartRateAverageMeasurement.js +2 -0
- package/dist/client/observation/types/measurement/index.d.ts +11 -0
- package/dist/client/observation/types/measurement/index.js +27 -0
- package/dist/client/observation/types/service/ObservationMetadata.d.ts +8 -0
- package/dist/client/observation/types/service/ObservationMetadata.js +2 -0
- package/dist/client/observation/utils/getDeviceObject.d.ts +3 -0
- package/dist/client/observation/utils/getDeviceObject.js +34 -0
- package/dist/client/observation/utils/getObservationValueDisplay.d.ts +15 -0
- package/dist/client/observation/utils/getObservationValueDisplay.js +25 -0
- package/dist/client/observation/utils/index.d.ts +1 -0
- package/dist/client/observation/utils/index.js +17 -0
- package/dist/client/ovok-client.d.ts +35 -0
- package/dist/client/ovok-client.js +85 -0
- package/dist/client/questionnaire-response/methods/createQuestionnaireResponseWithObservations.d.ts +3 -0
- package/dist/client/questionnaire-response/methods/createQuestionnaireResponseWithObservations.js +28 -0
- package/dist/client/questionnaire-response/methods/index.d.ts +1 -0
- package/dist/client/questionnaire-response/methods/index.js +17 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.js +58 -0
- package/dist/index.d.ts +666 -0
- package/dist/index.js +49 -0
- package/dist/types/ValidationError.d.ts +6 -0
- package/dist/types/ValidationError.js +2 -0
- package/dist/types/index.d.ts +17 -0
- package/dist/types/index.js +38 -0
- package/dist/utils/auth/exchange-code.d.ts +14 -0
- package/dist/utils/auth/exchange-code.js +17 -0
- package/dist/utils/auth/generate-code-challenge-and-verifier.d.ts +6 -0
- package/dist/utils/auth/generate-code-challenge-and-verifier.js +45 -0
- package/dist/utils/auth/handle-tenant-code.d.ts +6 -0
- package/dist/utils/auth/handle-tenant-code.js +21 -0
- package/dist/utils/auth/sha256.d.ts +8 -0
- package/dist/utils/auth/sha256.js +300 -0
- package/dist/utils/auth/start-login.d.ts +10 -0
- package/dist/utils/auth/start-login.js +19 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/patch/getPatchOperationType.d.ts +2 -0
- package/dist/utils/patch/getPatchOperationType.js +16 -0
- package/package.json +83 -0
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# Ovok Core
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/@actimi%2Fovok-core)
|
|
4
|
+
[](https://sdk.ovok.com/)
|
|
5
|
+
|
|
6
|
+
Core TypeScript SDK for healthcare applications. Provides authentication, AI-FHIR integration, observations, and healthcare data management.
|
|
7
|
+
|
|
8
|
+
## Features
|
|
9
|
+
|
|
10
|
+
- 🔐 Authentication & user management
|
|
11
|
+
- 🤖 AI-FHIR resources and planning
|
|
12
|
+
- 📊 Healthcare observations and measurements
|
|
13
|
+
- 💬 Chat AI integration
|
|
14
|
+
- 🤖 Bot execution framework
|
|
15
|
+
- 📋 Questionnaire responses
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install @actimi/ovok-core
|
|
21
|
+
# or
|
|
22
|
+
yarn add @actimi/ovok-core
|
|
23
|
+
# or
|
|
24
|
+
pnpm add @actimi/ovok-core
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Quick Start
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { OvokClient } from "@actimi/ovok-core";
|
|
31
|
+
|
|
32
|
+
const client = new OvokClient({
|
|
33
|
+
apiUrl: "your-api-url",
|
|
34
|
+
// configuration
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Documentation
|
|
39
|
+
|
|
40
|
+
Full documentation and examples available at **[sdk.ovok.com](https://sdk.ovok.com/)**
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { OvokClient } from "../../ovok-client";
|
|
2
|
+
import { AIFhirRequest } from "../types/AIFhirRequest";
|
|
3
|
+
import { AIFhirResponse } from "../types/AIFhirResponse";
|
|
4
|
+
/**
|
|
5
|
+
* AI FHIR Search uses LLMs for FHIR query planning and execution.
|
|
6
|
+
* After the LLM generates the FHIR query plan, it's executed against the server
|
|
7
|
+
* to generate the results, and then the results are used to create a summary response.
|
|
8
|
+
*
|
|
9
|
+
* @warning The search may fail or return hallucinated results due to the nature of LLMs.
|
|
10
|
+
*
|
|
11
|
+
* @param request - The search request containing the text to search for
|
|
12
|
+
* @returns Promise with the search response containing markdown, plan, and results
|
|
13
|
+
*/
|
|
14
|
+
export declare function AIFhirResources(this: OvokClient, request: AIFhirRequest): Promise<AIFhirResponse>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AIFhirResources = AIFhirResources;
|
|
4
|
+
/**
|
|
5
|
+
* AI FHIR Search uses LLMs for FHIR query planning and execution.
|
|
6
|
+
* After the LLM generates the FHIR query plan, it's executed against the server
|
|
7
|
+
* to generate the results, and then the results are used to create a summary response.
|
|
8
|
+
*
|
|
9
|
+
* @warning The search may fail or return hallucinated results due to the nature of LLMs.
|
|
10
|
+
*
|
|
11
|
+
* @param request - The search request containing the text to search for
|
|
12
|
+
* @returns Promise with the search response containing markdown, plan, and results
|
|
13
|
+
*/
|
|
14
|
+
async function AIFhirResources(request) {
|
|
15
|
+
return this.post("/ai/fhir/search", request);
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./AIFhirResources";
|
|
@@ -0,0 +1,17 @@
|
|
|
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("./AIFhirResources"), exports);
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { AIFhirPlan } from "./AIFhirPlan";
|
|
2
|
+
export interface AIFhirResponse {
|
|
3
|
+
/**
|
|
4
|
+
* Markdown formatted response summarizing the results
|
|
5
|
+
*/
|
|
6
|
+
markdown: string;
|
|
7
|
+
/**
|
|
8
|
+
* The FHIR query plan generated by the LLM
|
|
9
|
+
*/
|
|
10
|
+
plan: AIFhirPlan;
|
|
11
|
+
/**
|
|
12
|
+
* Results of the FHIR queries executed based on the plan
|
|
13
|
+
* Key is the identifier from the request, value is array of FHIR resources
|
|
14
|
+
*/
|
|
15
|
+
results: Record<string, Array<{
|
|
16
|
+
resource: unknown;
|
|
17
|
+
}>>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
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("./AIFhirRequest"), exports);
|
|
18
|
+
__exportStar(require("./AIFhirResponse"), exports);
|
|
19
|
+
__exportStar(require("./AIFhirPlan"), exports);
|
|
20
|
+
__exportStar(require("./AIFhirPlanRequest"), exports);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.appleLogin = appleLogin;
|
|
4
|
+
async function appleLogin(body) {
|
|
5
|
+
const { internalId, ...rest } = body;
|
|
6
|
+
const queryParams = new URLSearchParams({
|
|
7
|
+
client: `ClientApplication/${this.socialLoginClientId}`,
|
|
8
|
+
internalId,
|
|
9
|
+
});
|
|
10
|
+
return this.post(`auth/external/apple?${queryParams.toString()}`, rest, "application/json");
|
|
11
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { OvokClient } from "../../ovok-client";
|
|
2
|
+
import { AuthResponse } from "../types/AuthResponse";
|
|
3
|
+
import { ChangePasswordBody } from "../types/ChangePasswordBody";
|
|
4
|
+
export declare function changePassword(this: OvokClient, body: ChangePasswordBody): Promise<AuthResponse>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.googleLogin = googleLogin;
|
|
4
|
+
async function googleLogin(body) {
|
|
5
|
+
const { internalId, ...rest } = body;
|
|
6
|
+
const queryParams = new URLSearchParams({
|
|
7
|
+
client: `ClientApplication/${this.socialLoginClientId}`,
|
|
8
|
+
internalId,
|
|
9
|
+
});
|
|
10
|
+
return this.post(`auth/external/google?${queryParams.toString()}`, rest, "application/json");
|
|
11
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
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("./login"), exports);
|
|
18
|
+
__exportStar(require("./register"), exports);
|
|
19
|
+
__exportStar(require("./refetchProfile"), exports);
|
|
20
|
+
__exportStar(require("./changePassword"), exports);
|
|
21
|
+
__exportStar(require("./requestDeleteUser"), exports);
|
|
22
|
+
__exportStar(require("./googleLogin"), exports);
|
|
23
|
+
__exportStar(require("./appleLogin"), exports);
|
|
24
|
+
__exportStar(require("./resetPassword"), exports);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.login = login;
|
|
4
|
+
const exchange_code_1 = require("../../../utils/auth/exchange-code");
|
|
5
|
+
const generate_code_challenge_and_verifier_1 = require("../../../utils/auth/generate-code-challenge-and-verifier");
|
|
6
|
+
const handle_tenant_code_1 = require("../../../utils/auth/handle-tenant-code");
|
|
7
|
+
const start_login_1 = require("../../../utils/auth/start-login");
|
|
8
|
+
async function login(body) {
|
|
9
|
+
const { codeVerifier, codeChallenge } = (0, generate_code_challenge_and_verifier_1.generateCodeChallengeAndVerifier)();
|
|
10
|
+
const startResponse = await (0, start_login_1.startLogin)({
|
|
11
|
+
client: this,
|
|
12
|
+
body,
|
|
13
|
+
codeChallenge,
|
|
14
|
+
});
|
|
15
|
+
const tenantCode = (0, handle_tenant_code_1.handleTenantCode)({
|
|
16
|
+
profiles: startResponse.profiles,
|
|
17
|
+
tenantCode: body.tenantCode,
|
|
18
|
+
type: body.type,
|
|
19
|
+
});
|
|
20
|
+
if (!tenantCode) {
|
|
21
|
+
throw new Error("No tenant code found");
|
|
22
|
+
}
|
|
23
|
+
const exchangeCodeProps = body.type === "Practitioner"
|
|
24
|
+
? {
|
|
25
|
+
client: this,
|
|
26
|
+
type: "Practitioner",
|
|
27
|
+
sessionCode: startResponse.sessionCode,
|
|
28
|
+
codeVerifier,
|
|
29
|
+
tenantCode,
|
|
30
|
+
}
|
|
31
|
+
: {
|
|
32
|
+
client: this,
|
|
33
|
+
type: "Patient",
|
|
34
|
+
sessionCode: startResponse.sessionCode,
|
|
35
|
+
codeVerifier,
|
|
36
|
+
};
|
|
37
|
+
return (0, exchange_code_1.exchangeCode)(exchangeCodeProps);
|
|
38
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.refetchProfile = refetchProfile;
|
|
4
|
+
async function refetchProfile() {
|
|
5
|
+
// TODO: find a better way to do this.
|
|
6
|
+
// Right now this function is private and I have to call this to refresh profile after update it
|
|
7
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
8
|
+
return this.refreshProfile();
|
|
9
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.register = register;
|
|
4
|
+
async function register(body) {
|
|
5
|
+
if (body.password !== body.passwordConfirm) {
|
|
6
|
+
throw new Error("Password and password confirm do not match");
|
|
7
|
+
}
|
|
8
|
+
return this.post("auth/tenant/Patient/register", {
|
|
9
|
+
email: body.email,
|
|
10
|
+
password: body.password,
|
|
11
|
+
name: body.name,
|
|
12
|
+
surname: body.surname,
|
|
13
|
+
tenantCode: body.tenantCode,
|
|
14
|
+
}, "application/json");
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { OvokClient } from "../../ovok-client";
|
|
2
|
+
import { RequestDeleteUserBody } from "../types/RequestDeleteUserBody";
|
|
3
|
+
import { RequestDeleteUserResponse } from "../types/RequestDeleteUserResponse";
|
|
4
|
+
/**
|
|
5
|
+
* Schedules deletion of user account
|
|
6
|
+
* @param body - Configuration for user deletion
|
|
7
|
+
* @param {number} body.daysUntilDeletion - After how many days the user should be deleted
|
|
8
|
+
* @param {boolean} body.shouldPurgeAllMedicalData - If true, deletes all user's medical data
|
|
9
|
+
* @returns {Promise<RequestDeleteUserResponse>} Response containing scheduled deletion status and user information
|
|
10
|
+
*/
|
|
11
|
+
export declare function requestDeleteUser(this: OvokClient, body: RequestDeleteUserBody): Promise<RequestDeleteUserResponse>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requestDeleteUser = requestDeleteUser;
|
|
4
|
+
/**
|
|
5
|
+
* Schedules deletion of user account
|
|
6
|
+
* @param body - Configuration for user deletion
|
|
7
|
+
* @param {number} body.daysUntilDeletion - After how many days the user should be deleted
|
|
8
|
+
* @param {boolean} body.shouldPurgeAllMedicalData - If true, deletes all user's medical data
|
|
9
|
+
* @returns {Promise<RequestDeleteUserResponse>} Response containing scheduled deletion status and user information
|
|
10
|
+
*/
|
|
11
|
+
async function requestDeleteUser(body) {
|
|
12
|
+
return this.delete(`auth/delete?days=${body.days}&wipe=${body.wipe}`);
|
|
13
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { OperationOutcome } from "@medplum/fhirtypes";
|
|
2
|
+
import { OvokClient } from "../../ovok-client";
|
|
3
|
+
import { ResetPasswordBody } from "../types/ResetPasswordBody";
|
|
4
|
+
/**
|
|
5
|
+
* Resets a user's password by sending a reset password email
|
|
6
|
+
* Implementation based on https://ovok-internal.readme.io/reference/authresetpasswordcontroller_resetpassword_v2
|
|
7
|
+
*
|
|
8
|
+
* @param this OvokClient instance
|
|
9
|
+
* @param body Reset password request body containing email
|
|
10
|
+
* @returns Promise with the OperationOutcome
|
|
11
|
+
* @throws Reset password error response
|
|
12
|
+
*/
|
|
13
|
+
export declare function resetPassword(this: OvokClient, body: ResetPasswordBody): Promise<OperationOutcome>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.resetPassword = resetPassword;
|
|
4
|
+
/**
|
|
5
|
+
* Resets a user's password by sending a reset password email
|
|
6
|
+
* Implementation based on https://ovok-internal.readme.io/reference/authresetpasswordcontroller_resetpassword_v2
|
|
7
|
+
*
|
|
8
|
+
* @param this OvokClient instance
|
|
9
|
+
* @param body Reset password request body containing email
|
|
10
|
+
* @returns Promise with the OperationOutcome
|
|
11
|
+
* @throws Reset password error response
|
|
12
|
+
*/
|
|
13
|
+
async function resetPassword(body) {
|
|
14
|
+
var _a;
|
|
15
|
+
return this.post("v2/auth/reset-password", {
|
|
16
|
+
...body,
|
|
17
|
+
clientId: (_a = body.clientId) !== null && _a !== void 0 ? _a : this.socialLoginClientId,
|
|
18
|
+
}, "application/json");
|
|
19
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export interface AppleLoginBody {
|
|
2
|
+
/**
|
|
3
|
+
* The internal ID of the extension with url "https://api.ovok.com/StructureDefinition/external-auth-internal-id"
|
|
4
|
+
*/
|
|
5
|
+
internalId: string;
|
|
6
|
+
/**
|
|
7
|
+
* A JSON Web Token (JWT) that securely communicates information about the user to your app.
|
|
8
|
+
*/
|
|
9
|
+
identityToken: string;
|
|
10
|
+
/**
|
|
11
|
+
* An identifier associated with the authenticated user. You can use this to check if the user is
|
|
12
|
+
* still authenticated later. This is stable and can be shared across apps released under the same
|
|
13
|
+
* development team. The same user will have a different identifier for apps released by other
|
|
14
|
+
* developers.
|
|
15
|
+
*/
|
|
16
|
+
user: string;
|
|
17
|
+
/**
|
|
18
|
+
* An arbitrary string that your app provided as `state` in the request that generated the
|
|
19
|
+
* credential. Used to verify that the response was from the request you made. Can be used to
|
|
20
|
+
* avoid replay attacks. If you did not provide `state` when making the sign-in request, this field
|
|
21
|
+
* will be `null`.
|
|
22
|
+
*/
|
|
23
|
+
state: string | null;
|
|
24
|
+
/**
|
|
25
|
+
* The user's name. May be `null` or contain `null` values if you didn't request the `FULL_NAME`
|
|
26
|
+
* scope, if the user denied access, or if this is not the first time the user has signed into
|
|
27
|
+
* your app.
|
|
28
|
+
*/
|
|
29
|
+
fullName: {
|
|
30
|
+
namePrefix: string | null;
|
|
31
|
+
givenName: string | null;
|
|
32
|
+
middleName: string | null;
|
|
33
|
+
familyName: string | null;
|
|
34
|
+
nameSuffix: string | null;
|
|
35
|
+
nickname: string | null;
|
|
36
|
+
} | null;
|
|
37
|
+
/**
|
|
38
|
+
* The user's email address. Might not be present if you didn't request the `EMAIL` scope. May
|
|
39
|
+
* also be null if this is not the first time the user has signed into your app. If the user chose
|
|
40
|
+
* to withhold their email address, this field will instead contain an obscured email address with
|
|
41
|
+
* an Apple domain.
|
|
42
|
+
*/
|
|
43
|
+
email: string;
|
|
44
|
+
/**
|
|
45
|
+
* A value that indicates whether the user appears to the system to be a real person.
|
|
46
|
+
*/
|
|
47
|
+
realUserStatus: AppleAuthenticationUserDetectionStatus;
|
|
48
|
+
/**
|
|
49
|
+
* A short-lived session token used by your app for proof of authorization when interacting with
|
|
50
|
+
* the app's server counterpart. Unlike `user`, this is ephemeral and will change each session.
|
|
51
|
+
*/
|
|
52
|
+
authorizationCode: string | null;
|
|
53
|
+
}
|
|
54
|
+
declare enum AppleAuthenticationUserDetectionStatus {
|
|
55
|
+
/**
|
|
56
|
+
* The system does not support this determination and there is no data.
|
|
57
|
+
*/
|
|
58
|
+
UNSUPPORTED = 0,
|
|
59
|
+
/**
|
|
60
|
+
* The system has not determined whether the user might be a real person.
|
|
61
|
+
*/
|
|
62
|
+
UNKNOWN = 1,
|
|
63
|
+
/**
|
|
64
|
+
* The user appears to be a real person.
|
|
65
|
+
*/
|
|
66
|
+
LIKELY_REAL = 2
|
|
67
|
+
}
|
|
68
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
var AppleAuthenticationUserDetectionStatus;
|
|
4
|
+
(function (AppleAuthenticationUserDetectionStatus) {
|
|
5
|
+
/**
|
|
6
|
+
* The system does not support this determination and there is no data.
|
|
7
|
+
*/
|
|
8
|
+
AppleAuthenticationUserDetectionStatus[AppleAuthenticationUserDetectionStatus["UNSUPPORTED"] = 0] = "UNSUPPORTED";
|
|
9
|
+
/**
|
|
10
|
+
* The system has not determined whether the user might be a real person.
|
|
11
|
+
*/
|
|
12
|
+
AppleAuthenticationUserDetectionStatus[AppleAuthenticationUserDetectionStatus["UNKNOWN"] = 1] = "UNKNOWN";
|
|
13
|
+
/**
|
|
14
|
+
* The user appears to be a real person.
|
|
15
|
+
*/
|
|
16
|
+
AppleAuthenticationUserDetectionStatus[AppleAuthenticationUserDetectionStatus["LIKELY_REAL"] = 2] = "LIKELY_REAL";
|
|
17
|
+
})(AppleAuthenticationUserDetectionStatus || (AppleAuthenticationUserDetectionStatus = {}));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ProfileResource } from "@medplum/core";
|
|
2
|
+
import { Project, Reference } from "@medplum/fhirtypes";
|
|
3
|
+
export type AuthResponse = {
|
|
4
|
+
accessToken: string;
|
|
5
|
+
refreshToken: string;
|
|
6
|
+
expiresIn: number;
|
|
7
|
+
profile: {
|
|
8
|
+
reference: Reference<ProfileResource>;
|
|
9
|
+
display: string;
|
|
10
|
+
};
|
|
11
|
+
project: {
|
|
12
|
+
reference: Reference<Project>;
|
|
13
|
+
display: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface GoogleLoginBody {
|
|
2
|
+
/**
|
|
3
|
+
* The internal ID of the extension with url "https://api.ovok.com/StructureDefinition/external-auth-internal-id"
|
|
4
|
+
*/
|
|
5
|
+
internalId: string;
|
|
6
|
+
/**
|
|
7
|
+
* The ID token obtained from Google OAuth
|
|
8
|
+
*/
|
|
9
|
+
idToken: string;
|
|
10
|
+
/**
|
|
11
|
+
* The access token obtained from Google OAuth
|
|
12
|
+
*/
|
|
13
|
+
access_token?: string;
|
|
14
|
+
/**
|
|
15
|
+
* Token expiration time in seconds
|
|
16
|
+
*/
|
|
17
|
+
expires_in?: number;
|
|
18
|
+
/**
|
|
19
|
+
* OAuth scope (e.g. "openid")
|
|
20
|
+
*/
|
|
21
|
+
scope?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Type of token (e.g. "bearer")
|
|
24
|
+
*/
|
|
25
|
+
token_type?: string;
|
|
26
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type LoginBody = {
|
|
2
|
+
/**
|
|
3
|
+
* The email address of the patient
|
|
4
|
+
*/
|
|
5
|
+
email: string;
|
|
6
|
+
/**
|
|
7
|
+
* The password of the patient
|
|
8
|
+
*/
|
|
9
|
+
password: string;
|
|
10
|
+
/**
|
|
11
|
+
* The type of user to login
|
|
12
|
+
*/
|
|
13
|
+
type: "Patient" | "Practitioner";
|
|
14
|
+
} & ({
|
|
15
|
+
type: "Patient";
|
|
16
|
+
/**
|
|
17
|
+
* The tenant code to login to. This is required for patient login.
|
|
18
|
+
*/
|
|
19
|
+
tenantCode: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: "Practitioner";
|
|
22
|
+
/**
|
|
23
|
+
* The tenant code to login to. This is optional for practitioner login. If not provided, the first tenant code will be used.
|
|
24
|
+
*/
|
|
25
|
+
tenantCode?: string;
|
|
26
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface RequestDeleteUserBody {
|
|
2
|
+
/**
|
|
3
|
+
* @type {number} Between 1 and 30
|
|
4
|
+
* @description After how many days the user should be deleted.
|
|
5
|
+
*/
|
|
6
|
+
days: number;
|
|
7
|
+
/**
|
|
8
|
+
* @description Deletes all medical data related to the user. If true, all medical data of the user will be deleted at the time of deletion. By default, this is false.
|
|
9
|
+
*/
|
|
10
|
+
wipe: boolean;
|
|
11
|
+
}
|