oro-sdk 2.1.4 → 2.3.0

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 (64) hide show
  1. package/README.md +26 -34
  2. package/dist/client.d.ts +4 -4
  3. package/dist/helpers/client.d.ts +1 -1
  4. package/dist/helpers/patient-registration.d.ts +1 -1
  5. package/dist/helpers/vault-grants.d.ts +1 -1
  6. package/dist/helpers/workflow.d.ts +1 -1
  7. package/dist/index.d.ts +15 -1
  8. package/dist/models/client.d.ts +1 -1
  9. package/dist/models/error.d.ts +0 -14
  10. package/dist/models/index.d.ts +0 -7
  11. package/dist/oro-sdk.cjs.development.js +313 -2357
  12. package/dist/oro-sdk.cjs.development.js.map +1 -1
  13. package/dist/oro-sdk.cjs.production.min.js +1 -1
  14. package/dist/oro-sdk.cjs.production.min.js.map +1 -1
  15. package/dist/oro-sdk.esm.js +246 -2334
  16. package/dist/oro-sdk.esm.js.map +1 -1
  17. package/dist/sdk-revision/client.d.ts +2 -2
  18. package/dist/services/index.d.ts +0 -9
  19. package/package.json +4 -1
  20. package/src/client.ts +161 -435
  21. package/src/helpers/client.ts +1 -1
  22. package/src/helpers/patient-registration.ts +85 -166
  23. package/src/helpers/vault-grants.ts +1 -1
  24. package/src/helpers/workflow.ts +21 -59
  25. package/src/index.ts +42 -28
  26. package/src/models/client.ts +1 -1
  27. package/src/models/error.ts +6 -13
  28. package/src/models/index.ts +0 -7
  29. package/src/sdk-revision/client.ts +25 -20
  30. package/src/services/external/clinia.ts +1 -1
  31. package/src/services/index.ts +0 -9
  32. package/LICENSE +0 -21
  33. package/dist/models/consult.d.ts +0 -102
  34. package/dist/models/diagnosis.d.ts +0 -122
  35. package/dist/models/guard.d.ts +0 -119
  36. package/dist/models/practice.d.ts +0 -353
  37. package/dist/models/shared.d.ts +0 -8
  38. package/dist/models/vault.d.ts +0 -124
  39. package/dist/models/workflow.d.ts +0 -106
  40. package/dist/services/api.d.ts +0 -11
  41. package/dist/services/axios.d.ts +0 -14
  42. package/dist/services/consult.d.ts +0 -54
  43. package/dist/services/diagnosis.d.ts +0 -38
  44. package/dist/services/guard.d.ts +0 -92
  45. package/dist/services/practice.d.ts +0 -100
  46. package/dist/services/teller.d.ts +0 -9
  47. package/dist/services/vault.d.ts +0 -54
  48. package/dist/services/workflow.d.ts +0 -21
  49. package/src/models/consult.ts +0 -110
  50. package/src/models/diagnosis.ts +0 -141
  51. package/src/models/guard.ts +0 -136
  52. package/src/models/practice.ts +0 -411
  53. package/src/models/shared.ts +0 -6
  54. package/src/models/vault.ts +0 -158
  55. package/src/models/workflow.ts +0 -142
  56. package/src/services/api.ts +0 -77
  57. package/src/services/axios.ts +0 -91
  58. package/src/services/consult.ts +0 -265
  59. package/src/services/diagnosis.ts +0 -132
  60. package/src/services/guard.ts +0 -228
  61. package/src/services/practice.ts +0 -537
  62. package/src/services/teller.ts +0 -39
  63. package/src/services/vault.ts +0 -178
  64. package/src/services/workflow.ts +0 -36
@@ -1,228 +0,0 @@
1
- import { APIService } from './api'
2
- import type { AxiosAuthRefreshRequestConfig } from 'axios-auth-refresh'
3
- import {
4
- AuthTokenRequest,
5
- AuthTokenResponse,
6
- AuthRecoverRequest,
7
- IdentityCreateRequest,
8
- IdentityUpdateRequest,
9
- IdentityResponse,
10
- QRCodeRequest,
11
- QRCodeResponse,
12
- Uuid,
13
- WhoAmIResponse,
14
- Base64String,
15
- AuthenticationFailed,
16
- IdentityCreationFailed,
17
- AuthenticationBadRequest,
18
- AuthenticationServerError,
19
- IdentityCreationBadRequest,
20
- IdentityCreationConflict,
21
- Tokens
22
- } from '../models'
23
- import { AxiosError } from 'axios'
24
-
25
- export interface GuardRequestConfig extends AxiosAuthRefreshRequestConfig {
26
- useRefreshToken : boolean
27
- }
28
- export class GuardService {
29
- private identityCache: Record<string, IdentityResponse>
30
- private whoAmICache: Record<string, WhoAmIResponse>
31
-
32
- constructor(private api: APIService, private baseURL: string) {
33
- this.api.setAuthRefreshFn(this.authRefresh.bind(this))
34
- this.identityCache = {}
35
- this.whoAmICache = {}
36
- }
37
-
38
- /**
39
- * Will replace access and refresh tokens with `tokens`
40
- *
41
- * Note:
42
- * ```typescript
43
- * setTokens({accessToken: undefined, refreshToken: 'aTokenValue'}) // will erase accessToken and set refreshToken with 'aTokenValue'
44
- * setTokens({refreshToken: 'aTokenValue'}) // will keep actual value of accessToken and set refreshToken with 'aTokenValue'
45
- *
46
- * ```
47
- * @param tokens
48
- */
49
- public setTokens(tokens: Tokens) {
50
- this.api.setTokens({...this.api.getTokens() , ...tokens })
51
- }
52
-
53
- /**
54
- * Allow to retrieve an access token and a refresh token in order
55
- * to do authenticated request afterward
56
- *
57
- * @param req The credentials required to get an access token
58
- * @returns AuthTokenResponse
59
- */
60
- public async authToken(req: AuthTokenRequest): Promise<AuthTokenResponse> {
61
- let resp : AuthTokenResponse
62
-
63
- try {
64
- let config: AxiosAuthRefreshRequestConfig = {
65
- skipAuthRefresh: true
66
- }
67
-
68
- resp = await this.api.post<AuthTokenResponse>(`${this.baseURL}/v1/auth/token`, req, config)
69
-
70
- this.api.setTokens({
71
- accessToken: resp.accessToken,
72
- refreshToken: resp.refreshToken
73
- })
74
- } catch(e) {
75
- if((e as any).isAxiosError){
76
- const code = (e as AxiosError).response?.status
77
- switch (code) {
78
- case 400:
79
- throw new AuthenticationBadRequest()
80
- case 500:
81
- throw new AuthenticationServerError()
82
- case 401:
83
- default:
84
- throw new AuthenticationFailed()
85
- }
86
- }
87
- throw new AuthenticationFailed()
88
-
89
- }
90
- return resp
91
- }
92
-
93
- /**
94
- * Get new access and refresh token
95
- *
96
- * @returns AuthTokenResponse
97
- */
98
- public async authRefresh(refreshToken?: string): Promise<AuthTokenResponse> {
99
- let config: GuardRequestConfig = {
100
- skipAuthRefresh: true,
101
- useRefreshToken: true
102
- }
103
- return this.api.put<AuthTokenResponse>(`${this.baseURL}/v1/auth/token`, null, config)
104
- }
105
-
106
-
107
- /**
108
- * Call guard to overwrite existing refresh token cookie
109
- *
110
- * @returns void
111
- */
112
- public async authLogout(): Promise<void> {
113
- return this.api.get<void>(`${this.baseURL}/v1/auth/logout`)
114
- }
115
-
116
-
117
- /**
118
- * Call guard to attempt account recovery
119
- *
120
- * @param req The email address / practice of the account to recover
121
- * @returns void
122
- */
123
- public async authRecover(req: AuthRecoverRequest): Promise<void> {
124
- return this.api.post<void>(`${this.baseURL}/v1/auth/recover`, req)
125
- }
126
-
127
-
128
- /**
129
- * Allow to create a new identity. The identity will then need to be confirmed
130
- * via an email link
131
- *
132
- * @param req the information about the new identity to create
133
- * @returns IdentityResponse
134
- */
135
- public async identityCreate(req: IdentityCreateRequest): Promise<IdentityResponse> {
136
- let resp : IdentityResponse
137
-
138
- try {
139
- resp = await this.api.post<IdentityResponse>(`${this.baseURL}/v1/identities`, req)
140
- this.api.setTokens({
141
- refreshToken: resp.refreshToken
142
- })
143
- } catch (e) {
144
- if((e as any).isAxiosError){
145
- const code = (e as AxiosError).response?.status
146
- switch (code) {
147
- case 400:
148
- throw new IdentityCreationBadRequest()
149
- case 409:
150
- throw new IdentityCreationConflict()
151
- case 500:
152
- default:
153
- throw new IdentityCreationFailed()
154
- }
155
- }
156
- throw new IdentityCreationFailed()
157
- }
158
- return resp
159
- }
160
-
161
-
162
- /**
163
- * Retrieve an identity. Will return public fields only when requested
164
- * without authentication
165
- *
166
- * @param identityID Unique id of the identity to retrieve
167
- * @returns IdentityResponse
168
- */
169
- public async identityGet(
170
- identityID: Uuid
171
- ): Promise<IdentityResponse> {
172
- const tokens = this.api.getTokens()
173
- const cacheKey = (tokens.accessToken ?? '') + (tokens.refreshToken ?? '') + identityID
174
-
175
- if (!tokens.accessToken || !this.identityCache[cacheKey]) {
176
- this.identityCache[cacheKey] = await this.api.get<IdentityResponse>(
177
- `${this.baseURL}/v1/identities/${identityID}`
178
- )
179
- }
180
- return this.identityCache[cacheKey]
181
- }
182
-
183
-
184
- /**
185
- * Get information about the current authenticated user
186
- *
187
- * @param refreshCache if true it will refresh the whoAmI cache (default: false)
188
- * @returns WhoAmIResponse
189
- */
190
- public async whoAmI(refreshCache: boolean = false): Promise<WhoAmIResponse> {
191
- const cacheKey = this.api.getTokens().accessToken ?? ''
192
- if (!this.whoAmICache[cacheKey] || refreshCache) {
193
- this.whoAmICache[cacheKey] = await this.api.get<WhoAmIResponse>(`${this.baseURL}/v1/auth/whoami`)
194
- }
195
- return this.whoAmICache[cacheKey]
196
- }
197
-
198
- /**
199
- * Update an existing identity
200
- *
201
- * @param identityID unique id of identity to update
202
- * @param req update request
203
- * @returns IdentityResponse
204
- */
205
- public async identityUpdate(
206
- identityID: Uuid,
207
- req: IdentityUpdateRequest
208
- ): Promise<IdentityResponse> {
209
- return this.api.put<IdentityResponse>(`${this.baseURL}/v1/identities/${identityID}`, req)
210
- }
211
-
212
- /**
213
- * Return base64 data representing a QR code that the
214
- * current identity need in order to use MFA
215
- *
216
- * @param identityID unique id of the identity
217
- * @param password the identity password (already hashed and in base64)
218
- * @returns QRCodeResponse
219
- */
220
- public async identityMFAQRCode(
221
- identityID: Uuid,
222
- password: Base64String
223
- ): Promise<QRCodeResponse> {
224
- const req: QRCodeRequest = { password }
225
- return this.api.post<QRCodeResponse>(`${this.baseURL}/v1/identities/${identityID}/mfa`, req, { headers: { 'Accept': 'application/json' } })
226
- }
227
- }
228
-