oro-sdk 2.1.4-dev1.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 (72) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +72 -0
  3. package/dist/client.d.ts +464 -0
  4. package/dist/helpers/client.d.ts +23 -0
  5. package/dist/helpers/index.d.ts +4 -0
  6. package/dist/helpers/patient-registration.d.ts +16 -0
  7. package/dist/helpers/vault-grants.d.ts +20 -0
  8. package/dist/helpers/workflow.d.ts +23 -0
  9. package/dist/index.d.ts +11 -0
  10. package/dist/index.js +8 -0
  11. package/dist/models/client.d.ts +28 -0
  12. package/dist/models/consult.d.ts +102 -0
  13. package/dist/models/diagnosis.d.ts +122 -0
  14. package/dist/models/error.d.ts +26 -0
  15. package/dist/models/guard.d.ts +119 -0
  16. package/dist/models/index.d.ts +9 -0
  17. package/dist/models/practice.d.ts +353 -0
  18. package/dist/models/shared.d.ts +8 -0
  19. package/dist/models/vault.d.ts +124 -0
  20. package/dist/models/workflow.d.ts +106 -0
  21. package/dist/oro-sdk.cjs.development.js +7685 -0
  22. package/dist/oro-sdk.cjs.development.js.map +1 -0
  23. package/dist/oro-sdk.cjs.production.min.js +2 -0
  24. package/dist/oro-sdk.cjs.production.min.js.map +1 -0
  25. package/dist/oro-sdk.esm.js +7692 -0
  26. package/dist/oro-sdk.esm.js.map +1 -0
  27. package/dist/sdk-revision/client.d.ts +21 -0
  28. package/dist/sdk-revision/index.d.ts +1 -0
  29. package/dist/services/api.d.ts +11 -0
  30. package/dist/services/axios.d.ts +14 -0
  31. package/dist/services/consult.d.ts +54 -0
  32. package/dist/services/diagnosis.d.ts +44 -0
  33. package/dist/services/external/clinia.d.ts +82 -0
  34. package/dist/services/external/index.d.ts +1 -0
  35. package/dist/services/guard.d.ts +92 -0
  36. package/dist/services/index.d.ts +10 -0
  37. package/dist/services/practice.d.ts +100 -0
  38. package/dist/services/teller.d.ts +9 -0
  39. package/dist/services/vault.d.ts +54 -0
  40. package/dist/services/workflow.d.ts +21 -0
  41. package/package.json +63 -0
  42. package/src/client.ts +1843 -0
  43. package/src/helpers/client.ts +199 -0
  44. package/src/helpers/index.ts +4 -0
  45. package/src/helpers/patient-registration.ts +490 -0
  46. package/src/helpers/vault-grants.ts +51 -0
  47. package/src/helpers/workflow.ts +261 -0
  48. package/src/index.ts +61 -0
  49. package/src/models/client.ts +33 -0
  50. package/src/models/consult.ts +110 -0
  51. package/src/models/diagnosis.ts +141 -0
  52. package/src/models/error.ts +13 -0
  53. package/src/models/guard.ts +136 -0
  54. package/src/models/index.ts +9 -0
  55. package/src/models/practice.ts +411 -0
  56. package/src/models/shared.ts +6 -0
  57. package/src/models/vault.ts +158 -0
  58. package/src/models/workflow.ts +142 -0
  59. package/src/sdk-revision/client.ts +62 -0
  60. package/src/sdk-revision/index.ts +1 -0
  61. package/src/services/api.ts +77 -0
  62. package/src/services/axios.ts +91 -0
  63. package/src/services/consult.ts +265 -0
  64. package/src/services/diagnosis.ts +144 -0
  65. package/src/services/external/clinia.ts +133 -0
  66. package/src/services/external/index.ts +1 -0
  67. package/src/services/guard.ts +228 -0
  68. package/src/services/index.ts +10 -0
  69. package/src/services/practice.ts +537 -0
  70. package/src/services/teller.ts +39 -0
  71. package/src/services/vault.ts +178 -0
  72. package/src/services/workflow.ts +36 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 ORO Health Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,72 @@
1
+ # oro-sdk
2
+
3
+ ORO SDK package is intended to be run in browser only. It contains everything needed to interact with backend services, especially the vault.
4
+
5
+ ## Requirements
6
+
7
+ - npm 6.14.11
8
+
9
+ > Powered by [tsdx](https://github.com/formium/tsdx)
10
+
11
+ ## Local development
12
+
13
+ > If you cannot see Jest types try opening this folder in a seperate VSCode window.
14
+ ### Set up project
15
+
16
+ ```bash
17
+ npm install
18
+ ```
19
+
20
+ Then, it's possible to either build/watch component by using
21
+
22
+ ```bash
23
+ npm start # watch
24
+ npm build # build
25
+ ```
26
+
27
+ ### Linking the SDK locally:
28
+
29
+ Ensure that you are running `node v14.17.0` and `npm v6.14.13`, you can use nvm to quickly install and use different versions of node via the commandline https://github.com/nvm-sh/nvm
30
+ ```
31
+ ❯ npm -v
32
+ 6.14.13
33
+
34
+ ❯ node -v
35
+ v14.17.0
36
+ ```
37
+ In **`oro-apis/sdk/js`**:
38
+
39
+ Use [npm link](https://docs.npmjs.com/cli/v7/commands/npm-link)
40
+
41
+ ```bash
42
+ npm install
43
+ npm run link:watch
44
+ ```
45
+
46
+ In **`oro-apps/web`**:
47
+
48
+ ```bash
49
+ npm uninstall oro-sdk-ts
50
+ npm link oro-sdk-ts
51
+ ```
52
+
53
+ in `/web/src/services/oro-client.ts` set the correct module, at line 15 comment out the module definition and use the already written local definition, don't forget to change PATH_TO_oro-apis to what it is on your machine. When done it should look like this:
54
+
55
+ ```js
56
+ const module = await import('PATH_TO_oro-apis/sdk/js/node_modules/oro-toolbox')
57
+ //const module = await import('oro-toolbox')
58
+ ```
59
+
60
+ Do the same for `/web/src/server.ts` uncomment line 94 and update the path to match your machine:
61
+
62
+ ```js
63
+ sirv('PATH_TO_oro-apis/sdk/js/node_modules/oro-toolbox', { dev }),
64
+ ```
65
+
66
+ You can then run the app locally:
67
+
68
+ ```bash
69
+ npm run dev
70
+ ```
71
+
72
+ > Caveat: There is some caveat using `npm link` please see [doc](https://docs.npmjs.com/cli/v7/commands/npm-link#caveat)
@@ -0,0 +1,464 @@
1
+ import * as OroToolbox from 'oro-toolbox';
2
+ import { Consult, ConsultRequest, DataCreateResponse, Document, DocumentType, Grant, IdentityResponse, LocalEncryptedData, LocalizedData, LockboxManifest, Meta, Metadata, MetadataCategory, PopulatedWorkflowData, Practice, RecoveryData, RegisterPatientOutput, TokenData, TosAndCpAcceptanceRequest, UserPreference, Uuid, VaultIndex, WorkflowData } from './models';
3
+ import { ConsultService, DiagnosisService, GuardService, PracticeService, TellerService, VaultService, WorkflowService } from './services';
4
+ export declare class OroClient {
5
+ private toolbox;
6
+ tellerClient: TellerService;
7
+ vaultClient: VaultService;
8
+ guardClient: GuardService;
9
+ practiceClient: PracticeService;
10
+ consultClient: ConsultService;
11
+ workflowClient: WorkflowService;
12
+ diagnosisClient: DiagnosisService;
13
+ private authenticationCallback?;
14
+ private rsa?;
15
+ private secrets;
16
+ private cachedMetadataGrants;
17
+ private cachedManifest;
18
+ private vaultIndex?;
19
+ constructor(toolbox: typeof OroToolbox, tellerClient: TellerService, vaultClient: VaultService, guardClient: GuardService, practiceClient: PracticeService, consultClient: ConsultService, workflowClient: WorkflowService, diagnosisClient: DiagnosisService, authenticationCallback?: ((err: Error) => void) | undefined);
20
+ /**
21
+ * clears the vaultIndex and cached metadata grants
22
+ */
23
+ cleanIndex(): Promise<void>;
24
+ /**
25
+ * Generates an RSA key pair and password payload (rsa private key encrypted with the password)
26
+ * Calls Guard to sign up with the email address, password, practice, legal and token data
27
+ *
28
+ * @param email
29
+ * @param password
30
+ * @param practice
31
+ * @param legal
32
+ * @param tokenData
33
+ * @returns
34
+ */
35
+ signUp(email: string, password: string, practice: Practice, tosAndCpAcceptance: TosAndCpAcceptanceRequest, tokenData?: TokenData, subscription?: boolean): Promise<IdentityResponse>;
36
+ /**
37
+ * Parse the given accessToken claims by calling guard whoami and update theidentity to set it's emailConfirmed flag
38
+ * @param accessToken
39
+ * @returns The identity related to confirmedEmail
40
+ */
41
+ confirmEmail(accessToken: string): Promise<IdentityResponse>;
42
+ /**
43
+ * Calls Guard to sign in with the email address, password and one time password (if MFA is enabled)
44
+ * Then recover's the rsa private key from the recovery payload
45
+ *
46
+ * @param practiceUuid
47
+ * @param email
48
+ * @param password
49
+ * @param otp
50
+ * @returns the user identity
51
+ */
52
+ signIn(practiceUuid: Uuid, email: string, password: string, otp?: string): Promise<IdentityResponse>;
53
+ /**
54
+ * Will attempt to recover an existing login session and set back
55
+ * the private key in scope
56
+ */
57
+ resumeSession(): Promise<void>;
58
+ /**
59
+ * This function let's you encrypt locally an Object
60
+ * @param value the Object to encrypt
61
+ * @returns a LocalEncryptedData Object
62
+ * @throws IncompleteAuthentication if rsa is not set
63
+ * @calls authenticationCallback if rsa is not set
64
+ */
65
+ localEncryptToJsonPayload(value: any): LocalEncryptedData;
66
+ /**
67
+ * This function let's you decrypt a LocalEncryptedData object
68
+ * @param value a LocalEncryptedData object
69
+ * @returns a decrypted Object
70
+ * @throws IncompleteAuthentication if rsa is not set
71
+ * @calls authenticationCallback if rsa is not set
72
+ */
73
+ localDecryptJsonPayload({ encryptedKey, encryptedData, }: LocalEncryptedData): any;
74
+ /**
75
+ * Effectively kills your "session"
76
+ */
77
+ signOut(): Promise<void>;
78
+ /**
79
+ * @name registerPatient
80
+ * @description The complete flow to register a patient
81
+ *
82
+ * Steps:
83
+ * 1. Create a consult (checks if payment has been done)
84
+ * 2. Creates a lockbox
85
+ * 3. Grants lockbox access to all practice personnel
86
+ * 4. Creates secure identification, medical, onboarding data
87
+ * 5. Generates and stores the rsa key pair and recovery payloads
88
+ *
89
+ * @param patientUuid
90
+ * @param consult
91
+ * @param workflow
92
+ * @param recoveryQA
93
+ * @returns
94
+ */
95
+ registerPatient(patientUuid: Uuid, consult: ConsultRequest, workflow: WorkflowData, recoveryQA?: {
96
+ recoverySecurityQuestions: string[];
97
+ recoverySecurityAnswers: string[];
98
+ }): Promise<RegisterPatientOutput>;
99
+ /**
100
+ * Builds the vault index for the logged user
101
+ *
102
+ * Steps:
103
+ * 1. Retrieves, decrypts and sets the lockbox IndexSnapshot
104
+ * 2. Retrieves, decrypts and adds all other index entries starting at the snapshot timestamp
105
+ * 3. Updates the IndexSnapshot if changed
106
+ * @deprecated
107
+ * @returns the latest vault index
108
+ */
109
+ buildVaultIndex(forceRefresh?: boolean): Promise<void>;
110
+ /**
111
+ * Setter for the vault index
112
+ * @param index
113
+ */
114
+ setVaultIndex(index: VaultIndex): void;
115
+ /**
116
+ * Fetches all grants, and consultations that exist in each lockbox
117
+ * Then updates the index for the current user with the lockbox consult relationship
118
+ */
119
+ forceUpdateIndexEntries(): Promise<void>;
120
+ /**
121
+ * Generates, encrypts and adds entries to vault index for a given index owner
122
+ *
123
+ * @param entries
124
+ * @param indexOwnerUuid
125
+ */
126
+ vaultIndexAdd(entries: VaultIndex, indexOwnerUuid?: Uuid): Promise<void>;
127
+ /**
128
+ * adds or updates the index snapshot for the logged user
129
+ * @param index
130
+ */
131
+ indexSnapshotAdd(index: VaultIndex): Promise<void>;
132
+ /**
133
+ * @name grantLockbox
134
+ * @description Grants a lockbox by retrieving the shared secret of the lockbox and encrypting it with the grantees public key
135
+ * @param granteeUuid
136
+ * @param lockboxUuid
137
+ * @param lockboxOwnerUuid the lockbox owner (ignored if lockbox is owned by self)
138
+ */
139
+ grantLockbox(granteeUuid: Uuid, lockboxUuid: Uuid, lockboxOwnerUuid?: Uuid): Promise<void>;
140
+ /**
141
+ * @name createMessageData
142
+ * @description Creates a Base64 encrypted Payload to send and store in the vault from a message string
143
+ * @param lockboxUuid
144
+ * @param message
145
+ * @param consultationId the consultation for which this message is sent
146
+ * @param lockboxOwnerUuid the lockbox owner (ignored if lockbox is owned by self)
147
+ * @param previousDataUuid if it's a revision of existing file, specify the previous data uuid
148
+ * @returns the data uuid
149
+ */
150
+ createMessageData(lockboxUuid: Uuid, message: string, consultationId: string, lockboxOwnerUuid?: Uuid, previousDataUuid?: Uuid): Promise<DataCreateResponse>;
151
+ /**
152
+ * @name createMessageAttachmentData
153
+ * @description Creates a Base64 encrypted Payload to send and store in the vault from a file
154
+ * @param lockboxUuid
155
+ * @param data the file stored
156
+ * @param consultationId the consultation for which this message is sent
157
+ * @param lockboxOwnerUuid the lockbox owner (ignored if lockbox is owned by self)
158
+ * @param previousDataUuid if it's a revision of existing file, specify the previous data uuid
159
+ * @returns the data uuid
160
+ */
161
+ createMessageAttachmentData(lockboxUuid: Uuid, data: File, consultationId: string, lockboxOwnerUuid?: Uuid, previousDataUuid?: Uuid): Promise<DataCreateResponse>;
162
+ /**
163
+ * @name createAttachmentData
164
+ * @description Creates a Base64 encrypted Payload to send and store in the vault from a file
165
+ * @param lockboxUuid
166
+ * @param data the file stored
167
+ * @param consultationId the consultation for which this message is sent
168
+ * @param category the category for the attachment data
169
+ * @param lockboxOwnerUuid the lockbox owner (ignored if lockbox is owned by self)
170
+ * @param previousDataUuid if it's a revision of existing file, specify the previous data uuid
171
+ * @returns the data uuid
172
+ */
173
+ createConsultationAttachmentData(lockboxUuid: Uuid, data: File, consultationId: string, documentType: DocumentType, lockboxOwnerUuid?: Uuid, previousDataUuid?: Uuid): Promise<DataCreateResponse>;
174
+ /**
175
+ * @name createJsonData
176
+ * @description Creates a Base64 encrypted Payload to send and store in the vault. With the data input as a JSON
177
+ * @param lockboxUuid
178
+ * @param data
179
+ * @param meta
180
+ * @param privateMeta the metadata that will be secured in the vault
181
+ * @param lockboxOwnerUuid the lockbox owner (ignored if lockbox is owned by self)
182
+ * @param previousDataUuid if it's a revision of existing data, specify the previous data uuid
183
+ * @returns the data uuid
184
+ */
185
+ createJsonData<T = Meta>(lockboxUuid: Uuid, data: any, meta?: T, privateMeta?: {
186
+ [val: string]: any;
187
+ }, lockboxOwnerUuid?: Uuid, previousDataUuid?: Uuid): Promise<DataCreateResponse>;
188
+ /**
189
+ * Get or upsert a data in lockbox
190
+ * @param lockboxUuid the lockbox uuid
191
+ * @param data the data to insert
192
+ * @param publicMetadata the public Metadata
193
+ * @param privateMetadata the private Metadata
194
+ * @param forceReplace set true when the insertion of data requires to replace the data when it exists already
195
+ * @returns the data uuid
196
+ */
197
+ getOrInsertJsonData<M = Metadata>(lockboxUuid: Uuid, data: any, publicMetadata: M, privateMetadata: Metadata, forceReplace?: boolean): Promise<Uuid>;
198
+ /**
199
+ * @name createBytesData
200
+ * @description Creates a Base64 encrypted Payload to send and store in the vault. With the data input as a Bytes
201
+ * @param lockboxUuid
202
+ * @param data
203
+ * @param meta
204
+ * @param privateMeta the metadata that will be secured in the vault
205
+ * @param lockboxOwnerUuid the lockbox owner (ignored if lockbox is owned by self)
206
+ * @param previousDataUuid if it's a revision of existing data, specify the previous data uuid
207
+ * @returns the data uuid
208
+ */
209
+ createBytesData<T = Meta>(lockboxUuid: Uuid, data: Uint8Array, meta: T, privateMeta: {
210
+ [val: string]: any;
211
+ }, lockboxOwnerUuid?: Uuid, previousDataUuid?: Uuid): Promise<DataCreateResponse>;
212
+ /**
213
+ * @name getJsonData
214
+ * @description Fetches and decrypts the lockbox data with the cached shared secret.
215
+ * Decrypts the data to a valid JSON object. If this is impossible, the call to the WASM binary will fail
216
+ *
217
+ * @type T is the generic type specifying the return type object of the function
218
+ * @param lockboxUuid
219
+ * @param dataUuid
220
+ * @param lockboxOwnerUuid the lockbox owner (ignored if lockbox is owned by self)
221
+ * @returns the data specified by the generic type <T>
222
+ */
223
+ getJsonData<T = any>(lockboxUuid: Uuid, dataUuid: Uuid, lockboxOwnerUuid?: Uuid): Promise<T>;
224
+ /**
225
+ * @description Fetches and decrypts the lockbox data with the cached shared secret.
226
+ * @param lockboxUuid
227
+ * @param dataUuid
228
+ * @param lockboxOwnerUuid the lockbox owner (ignored if lockbox is owned by self)
229
+ * @returns the bytes data
230
+ */
231
+ getBytesData(lockboxUuid: Uuid, dataUuid: Uuid, lockboxOwnerUuid?: Uuid): Promise<Uint8Array>;
232
+ /**
233
+ * @name getGrants
234
+ * @description Get all lockboxes granted to user with the applied filter
235
+ * @note this function returns cached grants and will not update unless the page is refreshed
236
+ * @todo some versions of lockboxes do not make use of lockbox metadata
237
+ * in this case, all lockboxes need to be filtered one-by-one to find the correct one
238
+ * Remove if this is no longer the case
239
+ * @param filter: the consultationId in which the grant exists
240
+ * @returns decrypted lockboxes granted to user
241
+ */
242
+ getGrants(filter?: {
243
+ consultationId: Uuid;
244
+ }, forceRefresh?: boolean): Promise<Grant[]>;
245
+ /**
246
+ * @name getCachedSecretCryptor
247
+ * @description Retrieves the cached lockbox secret or fetches the secret from vault, then creates the symmetric cryptor and stores it in memory
248
+ * @param lockboxUuid
249
+ * @param lockboxOwnerUuid the lockbox owner (ignored if lockbox is owned by self)
250
+ * @returns
251
+ */
252
+ getCachedSecretCryptor(lockboxUuid: string, lockboxOwnerUuid?: string): Promise<OroToolbox.CryptoChaCha>;
253
+ /**
254
+ * Retrieves the patient personal information associated to the `consultationId`
255
+ * The `consultationId` only helps to retrieve the patient lockboxes
256
+ * Note: it is possible to have several personal informations data
257
+ * @param consultationId The consultation Id
258
+ * @param category The personal MetadataCategory to fetch
259
+ * @param forceRefresh force data refresh (default to false)
260
+ * @returns the personal data
261
+ */
262
+ getPersonalInformationsFromConsultId(consultationId: Uuid, category: MetadataCategory.Personal | MetadataCategory.ChildPersonal | MetadataCategory.OtherPersonal, forceRefresh?: boolean): Promise<LocalizedData<PopulatedWorkflowData>[]>;
263
+ /**
264
+ * Retrieves the patient medical data associated to the `consultationId`
265
+ * The `consultationId` only helps to retrieve the patient lockboxes
266
+ * Note: it is possible to have several medical data
267
+ * @param consultationId The consultation Id
268
+ * @param forceRefresh force data refresh (default to false)
269
+ * @returns the medical data
270
+ */
271
+ getMedicalDataFromConsultId(consultationId: Uuid, forceRefresh?: boolean): Promise<LocalizedData<PopulatedWorkflowData>[]>;
272
+ private getMetaCategoryFromConsultId;
273
+ /**
274
+ * @description retrieves the personal information stored in the first owned lockbox
275
+ * @param userId The user Id
276
+ * @returns the personal data
277
+ */
278
+ getPersonalInformations(userId: Uuid): Promise<LocalizedData<PopulatedWorkflowData>>;
279
+ /**
280
+ * Retrieves the grant associated to a consultationId
281
+ * @note returns the first grant only
282
+ * @param consultationId The consultationId
283
+ * @returns the grant
284
+ */
285
+ getGrantFromConsultId(consultationId: Uuid): Promise<Grant | undefined>;
286
+ /**
287
+ * retrieves the identity associated to the `consultationId`
288
+ * @param consultationId The consultation Id
289
+ * @returns the identity
290
+ */
291
+ getIdentityFromConsultId(consultationId: Uuid): Promise<IdentityResponse | undefined>;
292
+ /**
293
+ * retrieves the lockbox manifest for a given lockbox and add's its private metadata
294
+ * @note the lockbox manifest will retrieved the cached manifest first unless force refresh is enabled
295
+ * @param lockboxUuid
296
+ * @param filter
297
+ * @param expandPrivateMetadata
298
+ * @param lockboxOwnerUuid
299
+ * @param forceRefresh
300
+ * @returns the lockbox manifest
301
+ */
302
+ getLockboxManifest(lockboxUuid: Uuid, filter: Metadata, expandPrivateMetadata: boolean, lockboxOwnerUuid?: Uuid, forceRefresh?: boolean): Promise<LockboxManifest>;
303
+ /**
304
+ * @description Create or update the personal information and store it in the first owned lockbox
305
+ * @param identity The identity to use
306
+ * @param data The personal data to store
307
+ * @param dataUuid (optional) The dataUuid to update
308
+ * @returns
309
+ */
310
+ createPersonalInformations(identity: IdentityResponse, data: PopulatedWorkflowData, dataUuid?: string): Promise<DataCreateResponse>;
311
+ /**
312
+ * Create or update user Preference
313
+ * @param identity
314
+ * @param preference
315
+ * @param dataUuid
316
+ * @returns
317
+ */
318
+ createUserPreference(identity: IdentityResponse, preference: UserPreference, dataUuid?: string): Promise<DataCreateResponse>;
319
+ /**
320
+ * retrieves the user preference from a grant
321
+ * @param grant The grant
322
+ * @returns the user preference
323
+ */
324
+ getDataFromGrant<T = any>(grant: Grant, filter: Metadata): Promise<LocalizedData<T>>;
325
+ /**
326
+ * retrieves the user preference from a consultation id
327
+ * @param consultationId The related consultationId
328
+ * @returns the user preference
329
+ */
330
+ getUserPreferenceFromConsultId(consultationId: string): Promise<LocalizedData<UserPreference>>;
331
+ /**
332
+ * retrieves the user preference stored in the first owned lockbox from identity
333
+ * @param identity The identity to use
334
+ * @returns the user preference
335
+ */
336
+ getUserPreference(identity: IdentityResponse): Promise<LocalizedData<UserPreference>>;
337
+ /**
338
+ * retrieves the user preference from a consultation id
339
+ * @param consultationId The related consultationId
340
+ * @returns the user preference
341
+ */
342
+ getRecoveryDataFromConsultId(consultationId: string): Promise<LocalizedData<RecoveryData>>;
343
+ /**
344
+ * retrieves the user preference stored in the first owned lockbox from identity
345
+ * @param identity The identity to use
346
+ * @returns the user preference
347
+ */
348
+ getRecoveryData(identity: IdentityResponse): Promise<LocalizedData<RecoveryData>>;
349
+ /**
350
+ * @name getAssignedConsultations
351
+ * @description finds all assigned or owned consultations for the logged user
352
+ * Steps:
353
+ * - Retrieves all granted lockboxes given to the logged user
354
+ * - for each lockbox, find all consultation ids
355
+ * - for each consultation id, retrieve the consult information
356
+ * @param practiceUuid the uuid of the practice to look consult into
357
+ * @returns the list of consults
358
+ */
359
+ getAssignedConsultations(practiceUuid: Uuid, forceRefresh?: boolean): Promise<Consult[]>;
360
+ /**
361
+ * Gets the past consultations of the patient as well as his relatives if any
362
+ * @param consultationId any consultation uuid from which we will fetch all the other consultations of the same patient as the owner of this consultation id
363
+ * @param practiceUuid
364
+ */
365
+ getPastConsultationsFromConsultId(consultationId: string, practiceUuid: string): Promise<Consult[] | undefined>;
366
+ /**
367
+ * @name getPatientConsultationData
368
+ * @description retrieves the consultation data
369
+ * @param consultationId
370
+ * @returns
371
+ */
372
+ getPatientConsultationData(consultationId: Uuid, forceRefresh?: boolean): Promise<PopulatedWorkflowData[]>;
373
+ /**
374
+ * This function returns the patient prescriptions
375
+ * @param consultationId
376
+ * @returns
377
+ */
378
+ getPatientPrescriptionsList(consultationId: Uuid): Promise<Document[]>;
379
+ /**
380
+ * This function returns the patient results
381
+ * @param consultationId
382
+ * @returns
383
+ */
384
+ getPatientResultsList(consultationId: Uuid): Promise<Document[]>;
385
+ /**
386
+ * returns the patient treatment plan options
387
+ * @param consultationId
388
+ * @returns Document[] corresponding to the patient treatment plan options
389
+ */
390
+ getPatientTreatmentPlans(consultationId: Uuid): Promise<Document[]>;
391
+ /**
392
+ * returns a specific patient treatment plan option
393
+ * @param consultationId
394
+ * @param treatmentPlanId
395
+ * @returns
396
+ */
397
+ getPatientTreatmentPlanByUuid(consultationId: Uuid, treatmentPlanId: Uuid): Promise<Document[]>;
398
+ /**
399
+ * @name getPatientDocumentsList
400
+ * @description applies the provided filter to the vault to only find those documents
401
+ * @param filters the applied filters (e.g. type of documents)
402
+ * @param expandPrivateMetadata whether or not, the private metadata needs to be retrieved
403
+ * (more computationally expensive)
404
+ * @param consultationId
405
+ * @returns the filtered document list
406
+ */
407
+ getPatientDocumentsList(filters: Object, expandPrivateMetadata: boolean, consultationId: Uuid): Promise<Document[]>;
408
+ /****************************************************************************************************************
409
+ * RECOVERY *
410
+ ****************************************************************************************************************/
411
+ /**
412
+ * @name recoverPrivateKeyFromSecurityQuestions
413
+ * @description Recovers and sets the rsa private key from the answered security questions
414
+ * @param id
415
+ * @param recoverySecurityQuestions
416
+ * @param recoverySecurityAnswers
417
+ * @param threshold the number of answers needed to recover the key
418
+ */
419
+ recoverPrivateKeyFromSecurityQuestions(id: Uuid, recoverySecurityQuestions: string[], recoverySecurityAnswers: string[], threshold: number): Promise<void>;
420
+ /**
421
+ * @name recoverPrivateKeyFromPassword
422
+ * @description Recovers and sets the rsa private key from the password
423
+ * @param id
424
+ * @param password
425
+ */
426
+ recoverPrivateKeyFromPassword(id: Uuid, password: string): Promise<void>;
427
+ /**
428
+ * @name recoverPrivateKeyFromMasterKey
429
+ * @description Recovers and sets the rsa private key from the master key
430
+ * @param id
431
+ * @param masterKey
432
+ */
433
+ recoverPrivateKeyFromMasterKey(id: Uuid, masterKey: string): Promise<void>;
434
+ /**
435
+ * @description Generates and updates the security questions and answers payload using new recovery questions and answers
436
+ * Important: Since the security questions generate a payload for the private key, they will never be stored on the device as they must remain secret!!!
437
+ * @param id
438
+ * @param recoverySecurityQuestions
439
+ * @param recoverySecurityAnswers
440
+ * @param threshold the number of answers needed to rebuild the secret
441
+ */
442
+ updateSecurityQuestions(id: Uuid, recoverySecurityQuestions: string[], recoverySecurityAnswers: string[], threshold: number): Promise<IdentityResponse>;
443
+ /**
444
+ * @description Generates and stores the payload encrypted payload and updates the password itself (double hash)
445
+ * @important
446
+ * the recovery payload uses a singly hashed password and the password stored is doubly hashed so
447
+ * the stored password cannot derive the decryption key in the payload
448
+ * @note
449
+ * the old password must be provided when not performing an account recovery
450
+ * @param id
451
+ * @param newPassword
452
+ * @param oldPassword
453
+ */
454
+ updatePassword(id: Uuid, newPassword: string, oldPassword?: string): Promise<IdentityResponse>;
455
+ /**
456
+ * @description Generates and stores the master key encrypted payload
457
+ * Important
458
+ * Since the master key is used to generate a payload for the private key, it will never be stored on the device as it must remain secret!
459
+ * @param id
460
+ * @param masterKey
461
+ * @param lockboxUuid
462
+ */
463
+ updateMasterKey(id: Uuid, masterKey: string, lockboxUuid: Uuid): Promise<IdentityResponse>;
464
+ }
@@ -0,0 +1,23 @@
1
+ import { PopulatedWorkflowData, MetadataCategory, SelectedAnswersData } from '../models';
2
+ import { PersonalInformations } from '../models/client';
3
+ /**
4
+ * This function extract PersonalInformations from data input object coming from workflow
5
+ * @param data extracted from WorkflowData
6
+ * @returns PersonalInformations of a patient
7
+ */
8
+ export declare function identificationToPersonalInformations(data: any, category: MetadataCategory.Personal | MetadataCategory.ChildPersonal | MetadataCategory.OtherPersonal): PersonalInformations;
9
+ export declare function toActualObject(data: PopulatedWorkflowData): any;
10
+ /**
11
+ * This function update a PopulatedWorkflowData with PersonalInformations
12
+ * @param infos the personal informations
13
+ * @param data the PopulatedWorkflowData
14
+ * @returns an updated PopulatedWorkflowData
15
+ */
16
+ export declare function updatePersonalIntoPopulatedWorkflowData(infos: PersonalInformations, data: PopulatedWorkflowData, category: MetadataCategory.Personal | MetadataCategory.ChildPersonal | MetadataCategory.OtherPersonal): any;
17
+ /**
18
+ * This function extract an ISO 3166-1 alpha-2 country and subdivision code from data input object coming from workflow
19
+ * @param answers answers from the WorkflowData
20
+ * @returns an ISO 3166 alpha-2 code or undefined
21
+ */
22
+ export declare function extractISOLocalityForConsult(answers?: SelectedAnswersData): string | undefined;
23
+ export declare function sessionStorePrivateKeyName(id: string): string;
@@ -0,0 +1,4 @@
1
+ export * from './client';
2
+ export * from './workflow';
3
+ export * from './patient-registration';
4
+ export * from './vault-grants';
@@ -0,0 +1,16 @@
1
+ import { OroClient, RegisterPatientOutput } from '..';
2
+ import { ConsultRequest, MetadataCategory, Uuid, WorkflowData } from '../models';
3
+ export declare function registerPatient(patientUuid: Uuid, consultRequest: ConsultRequest, workflow: WorkflowData, oroClient: OroClient, masterKey?: Uuid, recoveryQA?: {
4
+ recoverySecurityQuestions: string[];
5
+ recoverySecurityAnswers: string[];
6
+ }): Promise<RegisterPatientOutput>;
7
+ /**
8
+ * Extracts the workflow MetadataCategory for Personal, ChildPersonal and OtherPersonal
9
+ * then stores it in the vault
10
+ *
11
+ * @param workflow
12
+ * @param lockboxUuid
13
+ * @param category
14
+ * @returns The data uuid
15
+ */
16
+ export declare function extractAndStorePersonalWorkflowData(workflow: WorkflowData, lockboxUuid: Uuid, consultationId: Uuid, category: MetadataCategory.Personal | MetadataCategory.ChildPersonal | MetadataCategory.OtherPersonal, oroClient: OroClient): Promise<Uuid | void>;
@@ -0,0 +1,20 @@
1
+ import { CryptoRSA } from "oro-toolbox";
2
+ import { EncryptedIndexEntry, Grant } from "..";
3
+ /**
4
+ * Decrypts and returns the encrypted grants
5
+ * If something went wrong during decryption, that grant will be removed from the list
6
+ *
7
+ * @param encryptedGrants: an array of encrypted grants
8
+ * @param rsaKey: the rsa key used to decrypt the encrypted grants
9
+ * @returns an array of grants
10
+ */
11
+ export declare function decryptGrants(encryptedGrants: Grant[], rsaKey: CryptoRSA): Grant[];
12
+ /**
13
+ * Decrypts the encrypted consult lockboxes and returns their grants
14
+ * If something went wrong during decryption, that grant will be removed from the list
15
+ *
16
+ * @param encryptedConsultLockboxes: an array of encrypted entries
17
+ * @param rsaKey: the rsa key used to decrypt the encrypted entries
18
+ * @returns an array of grants
19
+ */
20
+ export declare function decryptConsultLockboxGrants(encryptedConsultLockboxes: EncryptedIndexEntry[], rsaKey: CryptoRSA): Grant[];
@@ -0,0 +1,23 @@
1
+ import { MetadataCategory, PopulatedWorkflowData, SelectedAnswerData, SelectedAnswersData, WorkflowData, WorkflowUploadedImage } from '../models';
2
+ export declare function filterTriggeredAnsweredWithKind(workflowData: WorkflowData, kind: 'text' | 'date' | 'number' | 'images' | 'images-alias' | 'body-parts' | 'pharmacy-picker'): Promise<SelectedAnswerData[]>;
3
+ /**
4
+ * Filters and Populates the `selectedAnswers` from the workflow by
5
+ * Cross-referencing the `MetaCategory` of the answer's respective question
6
+ * Populates the fields labels and values that are of radio, dropdown and checkbox types
7
+ *
8
+ * @param workflowData
9
+ * @param category
10
+ * @returns An array of record key, value pairs
11
+ */
12
+ export declare function getWorkflowDataByCategory(workflowData: WorkflowData, category: MetadataCategory): Promise<PopulatedWorkflowData>;
13
+ export declare function getImagesFromIndexDb(answer: SelectedAnswerData): Promise<WorkflowUploadedImage[]>;
14
+ export declare function isTriggered(triggers: string[], answers: string[]): boolean;
15
+ export declare function flattenSelectedAnswers(answers: SelectedAnswersData): string[];
16
+ /**
17
+ * This function helps you to get a valid workflow selectedAnswers structure
18
+ * @param workflow the workflow data to use to initialize selectedAnswers
19
+ * @param useDefault use workflow default values or not (this is used to avoid having unset values to appear in summaries)
20
+ * @returns a valid selectedAnswers structure
21
+ */
22
+ export declare function getInitialisedSelectedAnswers(workflow: WorkflowData, useDefault?: boolean): any[];
23
+ export declare function fillWorkflowFromPopulatedWorkflow(workflow: WorkflowData, populatedWorkflow: PopulatedWorkflowData): any;
@@ -0,0 +1,11 @@
1
+ import { OroClient } from './client';
2
+ import * as OroToolboxNamespace from 'oro-toolbox';
3
+ export declare type OroToolbox = typeof OroToolboxNamespace;
4
+ export declare let wasmPath: string;
5
+ declare const init: (toolbox: OroToolbox, tellerBaseURL: string, vaultBaseURL: string, guardBaseURL: string, practiceBaseURL: string, consultBaseURL: string, workflowBaseURL: string, diagnosisBaseUrl: string, authenticationCallback?: ((err: Error) => void) | undefined) => OroClient;
6
+ export { OroClient } from './client';
7
+ export * from './models';
8
+ export * from './helpers';
9
+ export * from './services';
10
+ export { OroToolboxNamespace };
11
+ export default init;
package/dist/index.js ADDED
@@ -0,0 +1,8 @@
1
+
2
+ 'use strict'
3
+
4
+ if (process.env.NODE_ENV === 'production') {
5
+ module.exports = require('./oro-sdk.cjs.production.min.js')
6
+ } else {
7
+ module.exports = require('./oro-sdk.cjs.development.js')
8
+ }