oro-sdk-apis 1.7.1 → 1.8.2
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/dist/models/diagnosis.d.ts +4 -0
- package/dist/models/guard.d.ts +2 -2
- package/dist/models/practice.d.ts +16 -2
- package/dist/oro-sdk-apis.cjs.development.js +6 -20
- package/dist/oro-sdk-apis.cjs.development.js.map +1 -1
- package/dist/oro-sdk-apis.cjs.production.min.js +1 -1
- package/dist/oro-sdk-apis.cjs.production.min.js.map +1 -1
- package/dist/oro-sdk-apis.esm.js +6 -20
- package/dist/oro-sdk-apis.esm.js.map +1 -1
- package/dist/services/guard.d.ts +0 -1
- package/package.json +1 -1
- package/src/models/diagnosis.ts +4 -0
- package/src/models/guard.ts +2 -3
- package/src/models/practice.ts +13 -0
- package/src/services/guard.ts +38 -47
package/dist/services/guard.d.ts
CHANGED
package/package.json
CHANGED
package/src/models/diagnosis.ts
CHANGED
|
@@ -94,6 +94,8 @@ export interface TreatmentPlan {
|
|
|
94
94
|
uuidTreatment?: string
|
|
95
95
|
notes?: string
|
|
96
96
|
status: PlanStatus
|
|
97
|
+
decidedAt: string
|
|
98
|
+
createdAt: string
|
|
97
99
|
}
|
|
98
100
|
|
|
99
101
|
export interface DrugPrescription {
|
|
@@ -107,6 +109,8 @@ export interface TreatmentAndDrugPrescription {
|
|
|
107
109
|
notes?: string
|
|
108
110
|
status: PlanStatus
|
|
109
111
|
uuidTreatmentPlan: string
|
|
112
|
+
decidedAt: string
|
|
113
|
+
createdAt: string
|
|
110
114
|
}
|
|
111
115
|
export interface TreatmentPlans {
|
|
112
116
|
uuidConsult: string
|
package/src/models/guard.ts
CHANGED
|
@@ -68,12 +68,11 @@ export interface IdentityResponse {
|
|
|
68
68
|
publicKey: Base64String
|
|
69
69
|
recoveryLogin?: Uuid
|
|
70
70
|
recoveryPassword: Base64String
|
|
71
|
-
recoveryMasterKey
|
|
72
|
-
recoverySecurityQuestions
|
|
71
|
+
recoveryMasterKey?: Base64String
|
|
72
|
+
recoverySecurityQuestions?: SecretShard[]
|
|
73
73
|
legal?: LegalData
|
|
74
74
|
createdAt?: string
|
|
75
75
|
updatedAt?: string
|
|
76
|
-
//TODO: remove me when https://github.com/OROHealth/oro-guard/pull/72 is merged
|
|
77
76
|
refreshToken?: string
|
|
78
77
|
}
|
|
79
78
|
|
package/src/models/practice.ts
CHANGED
|
@@ -119,6 +119,7 @@ export enum PracticeConfigKind {
|
|
|
119
119
|
PracticeTheme = 'PracticeTheme',
|
|
120
120
|
PracticeLocaleSwitcher = 'PracticeLocaleSwitcher',
|
|
121
121
|
PracticeCookieBanner = 'PracticeCookieBanner',
|
|
122
|
+
PracticePharmacyPicker = 'PracticePharmacyPicker',
|
|
122
123
|
}
|
|
123
124
|
|
|
124
125
|
export interface PracticeConfig<K, T> {
|
|
@@ -151,6 +152,17 @@ export type PracticeConfigPractitionerChatbox = PracticeConfig<
|
|
|
151
152
|
}
|
|
152
153
|
>
|
|
153
154
|
|
|
155
|
+
export type PracticeConfigPracticeOnlinePharmacy = PracticeConfig<
|
|
156
|
+
PracticeConfigKind.PracticePharmacyPicker,
|
|
157
|
+
{
|
|
158
|
+
onlinePharmacy?: {
|
|
159
|
+
name: string,
|
|
160
|
+
id: string,
|
|
161
|
+
phones: { countryCode: string, number: string, extension: string | null, type: string, isTollFree: boolean }[]
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
>
|
|
165
|
+
|
|
154
166
|
export type PracticeConfigPracticeCookieBanner = PracticeConfig<
|
|
155
167
|
PracticeConfigKind.PracticeCookieBanner,
|
|
156
168
|
{
|
|
@@ -168,6 +180,7 @@ export type PracticeConfigs =
|
|
|
168
180
|
| PracticeConfigPractitionerChatbox
|
|
169
181
|
| PracticeConfigPracticeLocaleSwitcher
|
|
170
182
|
| PracticeConfigPracticeCookieBanner
|
|
183
|
+
| PracticeConfigPracticeOnlinePharmacy
|
|
171
184
|
| PracticeConfigPracticeTheme // Here for demonstration only
|
|
172
185
|
|
|
173
186
|
export interface PracticeWorkflow {
|
package/src/services/guard.ts
CHANGED
|
@@ -2,24 +2,36 @@ import { AxiosError } from 'axios'
|
|
|
2
2
|
import type { AxiosAuthRefreshRequestConfig } from 'axios-auth-refresh'
|
|
3
3
|
import {
|
|
4
4
|
AuthenticationBadRequest,
|
|
5
|
-
AuthenticationFailed,
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
AuthenticationFailed,
|
|
6
|
+
AuthenticationServerError,
|
|
7
|
+
AuthenticationUnconfirmedEmail,
|
|
8
|
+
AuthRecoverRequest,
|
|
9
|
+
AuthTokenRequest,
|
|
10
|
+
AuthTokenResponse,
|
|
11
|
+
Base64String,
|
|
12
|
+
IdentityCreateRequest,
|
|
13
|
+
IdentityCreationBadRequest,
|
|
14
|
+
IdentityCreationConflict,
|
|
15
|
+
IdentityCreationFailed,
|
|
16
|
+
IdentityResendConfirmEmailRequest,
|
|
17
|
+
IdentityResponse,
|
|
18
|
+
IdentityUpdateRequest,
|
|
19
|
+
QRCodeRequest,
|
|
20
|
+
QRCodeResponse,
|
|
21
|
+
Tokens,
|
|
22
|
+
Uuid,
|
|
23
|
+
WhoAmIResponse,
|
|
10
24
|
} from '../models'
|
|
11
25
|
import { APIService } from './api'
|
|
12
26
|
|
|
13
27
|
export interface GuardRequestConfig extends AxiosAuthRefreshRequestConfig {
|
|
14
|
-
useRefreshToken
|
|
28
|
+
useRefreshToken: boolean
|
|
15
29
|
}
|
|
16
30
|
export class GuardService {
|
|
17
|
-
private identityCache: Record<string, IdentityResponse>
|
|
18
31
|
private whoAmICache: Record<string, WhoAmIResponse>
|
|
19
32
|
|
|
20
33
|
constructor(private api: APIService, private baseURL: string) {
|
|
21
34
|
this.api.setAuthRefreshFn(this.authRefresh.bind(this))
|
|
22
|
-
this.identityCache = {}
|
|
23
35
|
this.whoAmICache = {}
|
|
24
36
|
}
|
|
25
37
|
|
|
@@ -35,7 +47,7 @@ export class GuardService {
|
|
|
35
47
|
* @param tokens
|
|
36
48
|
*/
|
|
37
49
|
public setTokens(tokens: Tokens) {
|
|
38
|
-
this.api.setTokens({...this.api.getTokens()
|
|
50
|
+
this.api.setTokens({ ...this.api.getTokens(), ...tokens })
|
|
39
51
|
}
|
|
40
52
|
|
|
41
53
|
/**
|
|
@@ -46,21 +58,21 @@ export class GuardService {
|
|
|
46
58
|
* @returns AuthTokenResponse
|
|
47
59
|
*/
|
|
48
60
|
public async authToken(req: AuthTokenRequest): Promise<AuthTokenResponse> {
|
|
49
|
-
let resp
|
|
61
|
+
let resp: AuthTokenResponse
|
|
50
62
|
|
|
51
63
|
try {
|
|
52
64
|
let config: AxiosAuthRefreshRequestConfig = {
|
|
53
|
-
skipAuthRefresh: true
|
|
65
|
+
skipAuthRefresh: true,
|
|
54
66
|
}
|
|
55
67
|
|
|
56
68
|
resp = await this.api.post<AuthTokenResponse>(`${this.baseURL}/v1/auth/token`, req, config)
|
|
57
69
|
|
|
58
70
|
this.api.setTokens({
|
|
59
71
|
accessToken: resp.accessToken,
|
|
60
|
-
refreshToken: resp.refreshToken
|
|
72
|
+
refreshToken: resp.refreshToken,
|
|
61
73
|
})
|
|
62
|
-
} catch(e) {
|
|
63
|
-
if((e as any).isAxiosError){
|
|
74
|
+
} catch (e) {
|
|
75
|
+
if ((e as any).isAxiosError) {
|
|
64
76
|
const code = (e as AxiosError).response?.status
|
|
65
77
|
switch (code) {
|
|
66
78
|
case 400:
|
|
@@ -75,7 +87,6 @@ export class GuardService {
|
|
|
75
87
|
}
|
|
76
88
|
}
|
|
77
89
|
throw new AuthenticationFailed()
|
|
78
|
-
|
|
79
90
|
}
|
|
80
91
|
return resp
|
|
81
92
|
}
|
|
@@ -88,12 +99,11 @@ export class GuardService {
|
|
|
88
99
|
public async authRefresh(refreshToken?: string): Promise<AuthTokenResponse> {
|
|
89
100
|
let config: GuardRequestConfig = {
|
|
90
101
|
skipAuthRefresh: true,
|
|
91
|
-
useRefreshToken: true
|
|
102
|
+
useRefreshToken: true,
|
|
92
103
|
}
|
|
93
104
|
return this.api.put<AuthTokenResponse>(`${this.baseURL}/v1/auth/token`, null, config)
|
|
94
105
|
}
|
|
95
106
|
|
|
96
|
-
|
|
97
107
|
/**
|
|
98
108
|
* Call guard to overwrite existing refresh token cookie
|
|
99
109
|
*
|
|
@@ -103,7 +113,6 @@ export class GuardService {
|
|
|
103
113
|
return this.api.get<void>(`${this.baseURL}/v1/auth/logout`)
|
|
104
114
|
}
|
|
105
115
|
|
|
106
|
-
|
|
107
116
|
/**
|
|
108
117
|
* Call guard to attempt account recovery
|
|
109
118
|
*
|
|
@@ -114,7 +123,6 @@ export class GuardService {
|
|
|
114
123
|
return this.api.post<void>(`${this.baseURL}/v1/auth/recover`, req)
|
|
115
124
|
}
|
|
116
125
|
|
|
117
|
-
|
|
118
126
|
/**
|
|
119
127
|
* Allow to create a new identity. The identity will then need to be confirmed
|
|
120
128
|
* via an email link
|
|
@@ -123,15 +131,15 @@ export class GuardService {
|
|
|
123
131
|
* @returns IdentityResponse
|
|
124
132
|
*/
|
|
125
133
|
public async identityCreate(req: IdentityCreateRequest): Promise<IdentityResponse> {
|
|
126
|
-
let resp
|
|
134
|
+
let resp: IdentityResponse
|
|
127
135
|
|
|
128
136
|
try {
|
|
129
137
|
resp = await this.api.post<IdentityResponse>(`${this.baseURL}/v1/identities`, req)
|
|
130
138
|
this.api.setTokens({
|
|
131
|
-
refreshToken: resp.refreshToken
|
|
139
|
+
refreshToken: resp.refreshToken,
|
|
132
140
|
})
|
|
133
141
|
} catch (e) {
|
|
134
|
-
if((e as any).isAxiosError){
|
|
142
|
+
if ((e as any).isAxiosError) {
|
|
135
143
|
const code = (e as AxiosError).response?.status
|
|
136
144
|
switch (code) {
|
|
137
145
|
case 400:
|
|
@@ -148,7 +156,6 @@ export class GuardService {
|
|
|
148
156
|
return resp
|
|
149
157
|
}
|
|
150
158
|
|
|
151
|
-
|
|
152
159
|
/**
|
|
153
160
|
* Retrieve an identity. Will return public fields only when requested
|
|
154
161
|
* without authentication
|
|
@@ -156,21 +163,10 @@ export class GuardService {
|
|
|
156
163
|
* @param identityID Unique id of the identity to retrieve
|
|
157
164
|
* @returns IdentityResponse
|
|
158
165
|
*/
|
|
159
|
-
public async identityGet(
|
|
160
|
-
identityID
|
|
161
|
-
): Promise<IdentityResponse> {
|
|
162
|
-
const tokens = this.api.getTokens()
|
|
163
|
-
const cacheKey = (tokens.accessToken ?? '') + (tokens.refreshToken ?? '') + identityID
|
|
164
|
-
|
|
165
|
-
if (!tokens.accessToken || !this.identityCache[cacheKey]) {
|
|
166
|
-
this.identityCache[cacheKey] = await this.api.get<IdentityResponse>(
|
|
167
|
-
`${this.baseURL}/v1/identities/${identityID}`
|
|
168
|
-
)
|
|
169
|
-
}
|
|
170
|
-
return this.identityCache[cacheKey]
|
|
166
|
+
public async identityGet(identityID: Uuid): Promise<IdentityResponse> {
|
|
167
|
+
return await this.api.get<IdentityResponse>(`${this.baseURL}/v1/identities/${identityID}`)
|
|
171
168
|
}
|
|
172
169
|
|
|
173
|
-
|
|
174
170
|
/**
|
|
175
171
|
* Get information about the current authenticated user
|
|
176
172
|
*
|
|
@@ -192,10 +188,7 @@ export class GuardService {
|
|
|
192
188
|
* @param req update request
|
|
193
189
|
* @returns IdentityResponse
|
|
194
190
|
*/
|
|
195
|
-
public async identityUpdate(
|
|
196
|
-
identityID: Uuid,
|
|
197
|
-
req: IdentityUpdateRequest
|
|
198
|
-
): Promise<IdentityResponse> {
|
|
191
|
+
public async identityUpdate(identityID: Uuid, req: IdentityUpdateRequest): Promise<IdentityResponse> {
|
|
199
192
|
return this.api.put<IdentityResponse>(`${this.baseURL}/v1/identities/${identityID}`, req)
|
|
200
193
|
}
|
|
201
194
|
|
|
@@ -207,12 +200,11 @@ export class GuardService {
|
|
|
207
200
|
* @param password the identity password (already hashed and in base64)
|
|
208
201
|
* @returns QRCodeResponse
|
|
209
202
|
*/
|
|
210
|
-
public async identityMFAQRCode(
|
|
211
|
-
identityID: Uuid,
|
|
212
|
-
password: Base64String
|
|
213
|
-
): Promise<QRCodeResponse> {
|
|
203
|
+
public async identityMFAQRCode(identityID: Uuid, password: Base64String): Promise<QRCodeResponse> {
|
|
214
204
|
const req: QRCodeRequest = { password }
|
|
215
|
-
return this.api.post<QRCodeResponse>(`${this.baseURL}/v1/identities/${identityID}/mfa`, req, {
|
|
205
|
+
return this.api.post<QRCodeResponse>(`${this.baseURL}/v1/identities/${identityID}/mfa`, req, {
|
|
206
|
+
headers: { Accept: 'application/json' },
|
|
207
|
+
})
|
|
216
208
|
}
|
|
217
209
|
|
|
218
210
|
/**
|
|
@@ -221,8 +213,7 @@ export class GuardService {
|
|
|
221
213
|
* @param req IdentityResendConfirmEmailRequest
|
|
222
214
|
* @return void
|
|
223
215
|
*/
|
|
224
|
-
public async identitySendConfirmEmail(req
|
|
216
|
+
public async identitySendConfirmEmail(req: IdentityResendConfirmEmailRequest): Promise<void> {
|
|
225
217
|
return this.api.post<void>(`${this.baseURL}/v1/identity/confirm`, req)
|
|
226
218
|
}
|
|
227
219
|
}
|
|
228
|
-
|