@medplum/core 0.2.1 → 0.4.1

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 (660) hide show
  1. package/README.md +32 -26
  2. package/dist/cjs/index.js +1818 -0
  3. package/dist/cjs/index.js.map +1 -0
  4. package/dist/cjs/index.min.js +16 -0
  5. package/dist/cjs/index.min.js.map +1 -0
  6. package/dist/esm/index.js +1769 -0
  7. package/dist/esm/index.js.map +1 -0
  8. package/dist/esm/index.min.js +16 -0
  9. package/dist/esm/index.min.js.map +1 -0
  10. package/dist/{cache.d.ts → types/cache.d.ts} +2 -3
  11. package/dist/types/client.d.ts +230 -0
  12. package/dist/{crypto.d.ts → types/crypto.d.ts} +0 -0
  13. package/dist/{eventtarget.d.ts → types/eventtarget.d.ts} +3 -3
  14. package/dist/{format.d.ts → types/format.d.ts} +1 -1
  15. package/dist/{index.d.ts → types/index.d.ts} +0 -2
  16. package/dist/types/jwt.d.ts +5 -0
  17. package/dist/{outcomes.d.ts → types/outcomes.d.ts} +7 -2
  18. package/dist/{search.d.ts → types/search.d.ts} +4 -0
  19. package/dist/{searchparams.d.ts → types/searchparams.d.ts} +1 -1
  20. package/dist/{storage.d.ts → types/storage.d.ts} +2 -2
  21. package/dist/{types.d.ts → types/types.d.ts} +18 -4
  22. package/dist/{utils.d.ts → types/utils.d.ts} +7 -1
  23. package/package.json +14 -9
  24. package/dist/cache.js +0 -36
  25. package/dist/cache.js.map +0 -1
  26. package/dist/client.d.ts +0 -233
  27. package/dist/client.js +0 -541
  28. package/dist/client.js.map +0 -1
  29. package/dist/crypto.js +0 -33
  30. package/dist/crypto.js.map +0 -1
  31. package/dist/eventtarget.js +0 -38
  32. package/dist/eventtarget.js.map +0 -1
  33. package/dist/fhir/AccessPolicy.d.ts +0 -75
  34. package/dist/fhir/AccessPolicy.js +0 -7
  35. package/dist/fhir/AccessPolicy.js.map +0 -1
  36. package/dist/fhir/Account.d.ts +0 -247
  37. package/dist/fhir/Account.js +0 -7
  38. package/dist/fhir/Account.js.map +0 -1
  39. package/dist/fhir/ActivityDefinition.d.ts +0 -500
  40. package/dist/fhir/ActivityDefinition.js +0 -7
  41. package/dist/fhir/ActivityDefinition.js.map +0 -1
  42. package/dist/fhir/Address.d.ts +0 -75
  43. package/dist/fhir/Address.js +0 -7
  44. package/dist/fhir/Address.js.map +0 -1
  45. package/dist/fhir/AdverseEvent.d.ts +0 -303
  46. package/dist/fhir/AdverseEvent.js +0 -7
  47. package/dist/fhir/AdverseEvent.js.map +0 -1
  48. package/dist/fhir/Age.d.ts +0 -47
  49. package/dist/fhir/Age.js +0 -7
  50. package/dist/fhir/Age.js.map +0 -1
  51. package/dist/fhir/AllergyIntolerance.d.ts +0 -283
  52. package/dist/fhir/AllergyIntolerance.js +0 -7
  53. package/dist/fhir/AllergyIntolerance.js.map +0 -1
  54. package/dist/fhir/Annotation.d.ts +0 -42
  55. package/dist/fhir/Annotation.js +0 -7
  56. package/dist/fhir/Annotation.js.map +0 -1
  57. package/dist/fhir/Appointment.d.ts +0 -284
  58. package/dist/fhir/Appointment.js +0 -7
  59. package/dist/fhir/Appointment.js.map +0 -1
  60. package/dist/fhir/AppointmentResponse.d.ts +0 -131
  61. package/dist/fhir/AppointmentResponse.js +0 -7
  62. package/dist/fhir/AppointmentResponse.js.map +0 -1
  63. package/dist/fhir/Attachment.d.ts +0 -58
  64. package/dist/fhir/Attachment.js +0 -7
  65. package/dist/fhir/Attachment.js.map +0 -1
  66. package/dist/fhir/AuditEvent.d.ts +0 -458
  67. package/dist/fhir/AuditEvent.js +0 -7
  68. package/dist/fhir/AuditEvent.js.map +0 -1
  69. package/dist/fhir/Basic.d.ts +0 -110
  70. package/dist/fhir/Basic.js +0 -7
  71. package/dist/fhir/Basic.js.map +0 -1
  72. package/dist/fhir/Binary.d.ts +0 -59
  73. package/dist/fhir/Binary.js +0 -7
  74. package/dist/fhir/Binary.js.map +0 -1
  75. package/dist/fhir/BiologicallyDerivedProduct.d.ts +0 -358
  76. package/dist/fhir/BiologicallyDerivedProduct.js +0 -7
  77. package/dist/fhir/BiologicallyDerivedProduct.js.map +0 -1
  78. package/dist/fhir/BodyStructure.d.ts +0 -119
  79. package/dist/fhir/BodyStructure.js +0 -7
  80. package/dist/fhir/BodyStructure.js.map +0 -1
  81. package/dist/fhir/Bot.d.ts +0 -49
  82. package/dist/fhir/Bot.js +0 -7
  83. package/dist/fhir/Bot.js.map +0 -1
  84. package/dist/fhir/Bundle.d.ts +0 -379
  85. package/dist/fhir/Bundle.js +0 -7
  86. package/dist/fhir/Bundle.js.map +0 -1
  87. package/dist/fhir/CapabilityStatement.d.ts +0 -1044
  88. package/dist/fhir/CapabilityStatement.js +0 -7
  89. package/dist/fhir/CapabilityStatement.js.map +0 -1
  90. package/dist/fhir/CarePlan.d.ts +0 -446
  91. package/dist/fhir/CarePlan.js +0 -7
  92. package/dist/fhir/CarePlan.js.map +0 -1
  93. package/dist/fhir/CareTeam.d.ts +0 -211
  94. package/dist/fhir/CareTeam.js +0 -7
  95. package/dist/fhir/CareTeam.js.map +0 -1
  96. package/dist/fhir/CatalogEntry.d.ts +0 -195
  97. package/dist/fhir/CatalogEntry.js +0 -7
  98. package/dist/fhir/CatalogEntry.js.map +0 -1
  99. package/dist/fhir/ChargeItem.d.ts +0 -287
  100. package/dist/fhir/ChargeItem.js +0 -7
  101. package/dist/fhir/ChargeItem.js.map +0 -1
  102. package/dist/fhir/ChargeItemDefinition.d.ts +0 -401
  103. package/dist/fhir/ChargeItemDefinition.js +0 -7
  104. package/dist/fhir/ChargeItemDefinition.js.map +0 -1
  105. package/dist/fhir/Claim.d.ts +0 -1092
  106. package/dist/fhir/Claim.js +0 -7
  107. package/dist/fhir/Claim.js.map +0 -1
  108. package/dist/fhir/ClaimResponse.d.ts +0 -1040
  109. package/dist/fhir/ClaimResponse.js +0 -7
  110. package/dist/fhir/ClaimResponse.js.map +0 -1
  111. package/dist/fhir/ClientApplication.d.ts +0 -46
  112. package/dist/fhir/ClientApplication.js +0 -7
  113. package/dist/fhir/ClientApplication.js.map +0 -1
  114. package/dist/fhir/ClinicalImpression.d.ts +0 -306
  115. package/dist/fhir/ClinicalImpression.js +0 -7
  116. package/dist/fhir/ClinicalImpression.js.map +0 -1
  117. package/dist/fhir/CodeSystem.d.ts +0 -541
  118. package/dist/fhir/CodeSystem.js +0 -7
  119. package/dist/fhir/CodeSystem.js.map +0 -1
  120. package/dist/fhir/CodeableConcept.d.ts +0 -33
  121. package/dist/fhir/CodeableConcept.js +0 -7
  122. package/dist/fhir/CodeableConcept.js.map +0 -1
  123. package/dist/fhir/Coding.d.ts +0 -50
  124. package/dist/fhir/Coding.js +0 -7
  125. package/dist/fhir/Coding.js.map +0 -1
  126. package/dist/fhir/Communication.d.ts +0 -264
  127. package/dist/fhir/Communication.js +0 -7
  128. package/dist/fhir/Communication.js.map +0 -1
  129. package/dist/fhir/CommunicationRequest.d.ts +0 -261
  130. package/dist/fhir/CommunicationRequest.js +0 -7
  131. package/dist/fhir/CommunicationRequest.js.map +0 -1
  132. package/dist/fhir/CompartmentDefinition.d.ts +0 -217
  133. package/dist/fhir/CompartmentDefinition.js +0 -7
  134. package/dist/fhir/CompartmentDefinition.js.map +0 -1
  135. package/dist/fhir/Composition.d.ts +0 -429
  136. package/dist/fhir/Composition.js +0 -7
  137. package/dist/fhir/Composition.js.map +0 -1
  138. package/dist/fhir/ConceptMap.d.ts +0 -518
  139. package/dist/fhir/ConceptMap.js +0 -7
  140. package/dist/fhir/ConceptMap.js.map +0 -1
  141. package/dist/fhir/Condition.d.ts +0 -326
  142. package/dist/fhir/Condition.js +0 -7
  143. package/dist/fhir/Condition.js.map +0 -1
  144. package/dist/fhir/Consent.d.ts +0 -460
  145. package/dist/fhir/Consent.js +0 -7
  146. package/dist/fhir/Consent.js.map +0 -1
  147. package/dist/fhir/ContactDetail.d.ts +0 -31
  148. package/dist/fhir/ContactDetail.js +0 -7
  149. package/dist/fhir/ContactDetail.js.map +0 -1
  150. package/dist/fhir/ContactPoint.d.ts +0 -47
  151. package/dist/fhir/ContactPoint.js +0 -7
  152. package/dist/fhir/ContactPoint.js.map +0 -1
  153. package/dist/fhir/Contract.d.ts +0 -1452
  154. package/dist/fhir/Contract.js +0 -7
  155. package/dist/fhir/Contract.js.map +0 -1
  156. package/dist/fhir/Contributor.d.ts +0 -37
  157. package/dist/fhir/Contributor.js +0 -7
  158. package/dist/fhir/Contributor.js.map +0 -1
  159. package/dist/fhir/Count.d.ts +0 -49
  160. package/dist/fhir/Count.js +0 -7
  161. package/dist/fhir/Count.js.map +0 -1
  162. package/dist/fhir/Coverage.d.ts +0 -327
  163. package/dist/fhir/Coverage.js +0 -7
  164. package/dist/fhir/Coverage.js.map +0 -1
  165. package/dist/fhir/CoverageEligibilityRequest.d.ts +0 -404
  166. package/dist/fhir/CoverageEligibilityRequest.js +0 -7
  167. package/dist/fhir/CoverageEligibilityRequest.js.map +0 -1
  168. package/dist/fhir/CoverageEligibilityResponse.d.ts +0 -434
  169. package/dist/fhir/CoverageEligibilityResponse.js +0 -7
  170. package/dist/fhir/CoverageEligibilityResponse.js.map +0 -1
  171. package/dist/fhir/DataRequirement.d.ts +0 -239
  172. package/dist/fhir/DataRequirement.js +0 -7
  173. package/dist/fhir/DataRequirement.js.map +0 -1
  174. package/dist/fhir/DetectedIssue.d.ts +0 -252
  175. package/dist/fhir/DetectedIssue.js +0 -7
  176. package/dist/fhir/DetectedIssue.js.map +0 -1
  177. package/dist/fhir/Device.d.ts +0 -493
  178. package/dist/fhir/Device.js +0 -7
  179. package/dist/fhir/Device.js.map +0 -1
  180. package/dist/fhir/DeviceDefinition.d.ts +0 -486
  181. package/dist/fhir/DeviceDefinition.js +0 -7
  182. package/dist/fhir/DeviceDefinition.js.map +0 -1
  183. package/dist/fhir/DeviceMetric.d.ts +0 -199
  184. package/dist/fhir/DeviceMetric.js +0 -7
  185. package/dist/fhir/DeviceMetric.js.map +0 -1
  186. package/dist/fhir/DeviceRequest.d.ts +0 -296
  187. package/dist/fhir/DeviceRequest.js +0 -7
  188. package/dist/fhir/DeviceRequest.js.map +0 -1
  189. package/dist/fhir/DeviceUseStatement.d.ts +0 -168
  190. package/dist/fhir/DeviceUseStatement.js +0 -7
  191. package/dist/fhir/DeviceUseStatement.js.map +0 -1
  192. package/dist/fhir/DiagnosticReport.d.ts +0 -254
  193. package/dist/fhir/DiagnosticReport.js +0 -7
  194. package/dist/fhir/DiagnosticReport.js.map +0 -1
  195. package/dist/fhir/Distance.d.ts +0 -47
  196. package/dist/fhir/Distance.js +0 -7
  197. package/dist/fhir/Distance.js.map +0 -1
  198. package/dist/fhir/DocumentManifest.d.ts +0 -196
  199. package/dist/fhir/DocumentManifest.js +0 -7
  200. package/dist/fhir/DocumentManifest.js.map +0 -1
  201. package/dist/fhir/DocumentReference.d.ts +0 -349
  202. package/dist/fhir/DocumentReference.js +0 -7
  203. package/dist/fhir/DocumentReference.js.map +0 -1
  204. package/dist/fhir/Dosage.d.ts +0 -152
  205. package/dist/fhir/Dosage.js +0 -7
  206. package/dist/fhir/Dosage.js.map +0 -1
  207. package/dist/fhir/Duration.d.ts +0 -46
  208. package/dist/fhir/Duration.js +0 -7
  209. package/dist/fhir/Duration.js.map +0 -1
  210. package/dist/fhir/EffectEvidenceSynthesis.d.ts +0 -591
  211. package/dist/fhir/EffectEvidenceSynthesis.js +0 -7
  212. package/dist/fhir/EffectEvidenceSynthesis.js.map +0 -1
  213. package/dist/fhir/Element.d.ts +0 -21
  214. package/dist/fhir/Element.js +0 -7
  215. package/dist/fhir/Element.js.map +0 -1
  216. package/dist/fhir/ElementDefinition.d.ts +0 -2701
  217. package/dist/fhir/ElementDefinition.js +0 -7
  218. package/dist/fhir/ElementDefinition.js.map +0 -1
  219. package/dist/fhir/Encounter.d.ts +0 -558
  220. package/dist/fhir/Encounter.js +0 -7
  221. package/dist/fhir/Encounter.js.map +0 -1
  222. package/dist/fhir/Endpoint.d.ts +0 -140
  223. package/dist/fhir/Endpoint.js +0 -7
  224. package/dist/fhir/Endpoint.js.map +0 -1
  225. package/dist/fhir/EnrollmentRequest.d.ts +0 -113
  226. package/dist/fhir/EnrollmentRequest.js +0 -7
  227. package/dist/fhir/EnrollmentRequest.js.map +0 -1
  228. package/dist/fhir/EnrollmentResponse.d.ts +0 -117
  229. package/dist/fhir/EnrollmentResponse.js +0 -7
  230. package/dist/fhir/EnrollmentResponse.js.map +0 -1
  231. package/dist/fhir/EpisodeOfCare.d.ts +0 -246
  232. package/dist/fhir/EpisodeOfCare.js +0 -7
  233. package/dist/fhir/EpisodeOfCare.js.map +0 -1
  234. package/dist/fhir/EventDefinition.d.ts +0 -253
  235. package/dist/fhir/EventDefinition.js +0 -7
  236. package/dist/fhir/EventDefinition.js.map +0 -1
  237. package/dist/fhir/Evidence.d.ts +0 -252
  238. package/dist/fhir/Evidence.js +0 -7
  239. package/dist/fhir/Evidence.js.map +0 -1
  240. package/dist/fhir/EvidenceVariable.d.ts +0 -370
  241. package/dist/fhir/EvidenceVariable.js +0 -7
  242. package/dist/fhir/EvidenceVariable.js.map +0 -1
  243. package/dist/fhir/ExampleScenario.d.ts +0 -628
  244. package/dist/fhir/ExampleScenario.js +0 -7
  245. package/dist/fhir/ExampleScenario.js.map +0 -1
  246. package/dist/fhir/ExplanationOfBenefit.d.ts +0 -1841
  247. package/dist/fhir/ExplanationOfBenefit.js +0 -7
  248. package/dist/fhir/ExplanationOfBenefit.js.map +0 -1
  249. package/dist/fhir/Expression.d.ts +0 -45
  250. package/dist/fhir/Expression.js +0 -7
  251. package/dist/fhir/Expression.js.map +0 -1
  252. package/dist/fhir/Extension.d.ts +0 -306
  253. package/dist/fhir/Extension.js +0 -7
  254. package/dist/fhir/Extension.js.map +0 -1
  255. package/dist/fhir/FamilyMemberHistory.d.ts +0 -306
  256. package/dist/fhir/FamilyMemberHistory.js +0 -7
  257. package/dist/fhir/FamilyMemberHistory.js.map +0 -1
  258. package/dist/fhir/Flag.d.ts +0 -132
  259. package/dist/fhir/Flag.js +0 -7
  260. package/dist/fhir/Flag.js.map +0 -1
  261. package/dist/fhir/Goal.d.ts +0 -299
  262. package/dist/fhir/Goal.js +0 -7
  263. package/dist/fhir/Goal.js.map +0 -1
  264. package/dist/fhir/GraphDefinition.d.ts +0 -350
  265. package/dist/fhir/GraphDefinition.js +0 -7
  266. package/dist/fhir/GraphDefinition.js.map +0 -1
  267. package/dist/fhir/Group.d.ts +0 -271
  268. package/dist/fhir/Group.js +0 -7
  269. package/dist/fhir/Group.js.map +0 -1
  270. package/dist/fhir/GuidanceResponse.d.ts +0 -196
  271. package/dist/fhir/GuidanceResponse.js +0 -7
  272. package/dist/fhir/GuidanceResponse.js.map +0 -1
  273. package/dist/fhir/HealthcareService.d.ts +0 -356
  274. package/dist/fhir/HealthcareService.js +0 -7
  275. package/dist/fhir/HealthcareService.js.map +0 -1
  276. package/dist/fhir/HumanName.d.ts +0 -58
  277. package/dist/fhir/HumanName.js +0 -7
  278. package/dist/fhir/HumanName.js.map +0 -1
  279. package/dist/fhir/Identifier.d.ts +0 -53
  280. package/dist/fhir/Identifier.js +0 -7
  281. package/dist/fhir/Identifier.js.map +0 -1
  282. package/dist/fhir/ImagingStudy.d.ts +0 -407
  283. package/dist/fhir/ImagingStudy.js +0 -7
  284. package/dist/fhir/ImagingStudy.js.map +0 -1
  285. package/dist/fhir/Immunization.d.ts +0 -444
  286. package/dist/fhir/Immunization.js +0 -7
  287. package/dist/fhir/Immunization.js.map +0 -1
  288. package/dist/fhir/ImmunizationEvaluation.d.ts +0 -149
  289. package/dist/fhir/ImmunizationEvaluation.js +0 -7
  290. package/dist/fhir/ImmunizationEvaluation.js.map +0 -1
  291. package/dist/fhir/ImmunizationRecommendation.d.ts +0 -254
  292. package/dist/fhir/ImmunizationRecommendation.js +0 -7
  293. package/dist/fhir/ImmunizationRecommendation.js.map +0 -1
  294. package/dist/fhir/ImplementationGuide.d.ts +0 -824
  295. package/dist/fhir/ImplementationGuide.js +0 -7
  296. package/dist/fhir/ImplementationGuide.js.map +0 -1
  297. package/dist/fhir/InsurancePlan.d.ts +0 -624
  298. package/dist/fhir/InsurancePlan.js +0 -7
  299. package/dist/fhir/InsurancePlan.js.map +0 -1
  300. package/dist/fhir/Invoice.d.ts +0 -346
  301. package/dist/fhir/Invoice.js +0 -7
  302. package/dist/fhir/Invoice.js.map +0 -1
  303. package/dist/fhir/JsonWebKey.d.ts +0 -99
  304. package/dist/fhir/JsonWebKey.js +0 -7
  305. package/dist/fhir/JsonWebKey.js.map +0 -1
  306. package/dist/fhir/Library.d.ts +0 -277
  307. package/dist/fhir/Library.js +0 -7
  308. package/dist/fhir/Library.js.map +0 -1
  309. package/dist/fhir/Linkage.d.ts +0 -146
  310. package/dist/fhir/Linkage.js +0 -7
  311. package/dist/fhir/Linkage.js.map +0 -1
  312. package/dist/fhir/List.d.ts +0 -200
  313. package/dist/fhir/List.js +0 -7
  314. package/dist/fhir/List.js.map +0 -1
  315. package/dist/fhir/Location.d.ts +0 -277
  316. package/dist/fhir/Location.js +0 -7
  317. package/dist/fhir/Location.js.map +0 -1
  318. package/dist/fhir/Login.d.ts +0 -119
  319. package/dist/fhir/Login.js +0 -7
  320. package/dist/fhir/Login.js.map +0 -1
  321. package/dist/fhir/MarketingStatus.d.ts +0 -82
  322. package/dist/fhir/MarketingStatus.js +0 -7
  323. package/dist/fhir/MarketingStatus.js.map +0 -1
  324. package/dist/fhir/Measure.d.ts +0 -620
  325. package/dist/fhir/Measure.js +0 -7
  326. package/dist/fhir/Measure.js.map +0 -1
  327. package/dist/fhir/MeasureReport.d.ts +0 -463
  328. package/dist/fhir/MeasureReport.js +0 -7
  329. package/dist/fhir/MeasureReport.js.map +0 -1
  330. package/dist/fhir/Media.d.ts +0 -205
  331. package/dist/fhir/Media.js +0 -7
  332. package/dist/fhir/Media.js.map +0 -1
  333. package/dist/fhir/Medication.d.ts +0 -230
  334. package/dist/fhir/Medication.js +0 -7
  335. package/dist/fhir/Medication.js.map +0 -1
  336. package/dist/fhir/MedicationAdministration.d.ts +0 -352
  337. package/dist/fhir/MedicationAdministration.js +0 -7
  338. package/dist/fhir/MedicationAdministration.js.map +0 -1
  339. package/dist/fhir/MedicationDispense.d.ts +0 -343
  340. package/dist/fhir/MedicationDispense.js +0 -7
  341. package/dist/fhir/MedicationDispense.js.map +0 -1
  342. package/dist/fhir/MedicationKnowledge.d.ts +0 -992
  343. package/dist/fhir/MedicationKnowledge.js +0 -7
  344. package/dist/fhir/MedicationKnowledge.js.map +0 -1
  345. package/dist/fhir/MedicationRequest.d.ts +0 -481
  346. package/dist/fhir/MedicationRequest.js +0 -7
  347. package/dist/fhir/MedicationRequest.js.map +0 -1
  348. package/dist/fhir/MedicationStatement.d.ts +0 -228
  349. package/dist/fhir/MedicationStatement.js +0 -7
  350. package/dist/fhir/MedicationStatement.js.map +0 -1
  351. package/dist/fhir/MedicinalProduct.d.ts +0 -453
  352. package/dist/fhir/MedicinalProduct.js +0 -7
  353. package/dist/fhir/MedicinalProduct.js.map +0 -1
  354. package/dist/fhir/MedicinalProductAuthorization.d.ts +0 -271
  355. package/dist/fhir/MedicinalProductAuthorization.js +0 -7
  356. package/dist/fhir/MedicinalProductAuthorization.js.map +0 -1
  357. package/dist/fhir/MedicinalProductContraindication.d.ts +0 -170
  358. package/dist/fhir/MedicinalProductContraindication.js +0 -7
  359. package/dist/fhir/MedicinalProductContraindication.js.map +0 -1
  360. package/dist/fhir/MedicinalProductIndication.d.ts +0 -179
  361. package/dist/fhir/MedicinalProductIndication.js +0 -7
  362. package/dist/fhir/MedicinalProductIndication.js.map +0 -1
  363. package/dist/fhir/MedicinalProductIngredient.d.ts +0 -336
  364. package/dist/fhir/MedicinalProductIngredient.js +0 -7
  365. package/dist/fhir/MedicinalProductIngredient.js.map +0 -1
  366. package/dist/fhir/MedicinalProductInteraction.d.ts +0 -158
  367. package/dist/fhir/MedicinalProductInteraction.js +0 -7
  368. package/dist/fhir/MedicinalProductInteraction.js.map +0 -1
  369. package/dist/fhir/MedicinalProductManufactured.d.ts +0 -113
  370. package/dist/fhir/MedicinalProductManufactured.js +0 -7
  371. package/dist/fhir/MedicinalProductManufactured.js.map +0 -1
  372. package/dist/fhir/MedicinalProductPackaged.d.ts +0 -259
  373. package/dist/fhir/MedicinalProductPackaged.js +0 -7
  374. package/dist/fhir/MedicinalProductPackaged.js.map +0 -1
  375. package/dist/fhir/MedicinalProductPharmaceutical.d.ts +0 -331
  376. package/dist/fhir/MedicinalProductPharmaceutical.js +0 -7
  377. package/dist/fhir/MedicinalProductPharmaceutical.js.map +0 -1
  378. package/dist/fhir/MedicinalProductUndesirableEffect.d.ts +0 -101
  379. package/dist/fhir/MedicinalProductUndesirableEffect.js +0 -7
  380. package/dist/fhir/MedicinalProductUndesirableEffect.js.map +0 -1
  381. package/dist/fhir/MessageDefinition.d.ts +0 -330
  382. package/dist/fhir/MessageDefinition.js +0 -7
  383. package/dist/fhir/MessageDefinition.js.map +0 -1
  384. package/dist/fhir/MessageHeader.d.ts +0 -323
  385. package/dist/fhir/MessageHeader.js +0 -7
  386. package/dist/fhir/MessageHeader.js.map +0 -1
  387. package/dist/fhir/Meta.d.ts +0 -75
  388. package/dist/fhir/Meta.js +0 -7
  389. package/dist/fhir/Meta.js.map +0 -1
  390. package/dist/fhir/MolecularSequence.d.ts +0 -760
  391. package/dist/fhir/MolecularSequence.js +0 -7
  392. package/dist/fhir/MolecularSequence.js.map +0 -1
  393. package/dist/fhir/Money.d.ts +0 -29
  394. package/dist/fhir/Money.js +0 -7
  395. package/dist/fhir/Money.js.map +0 -1
  396. package/dist/fhir/NamingSystem.d.ts +0 -218
  397. package/dist/fhir/NamingSystem.js +0 -7
  398. package/dist/fhir/NamingSystem.js.map +0 -1
  399. package/dist/fhir/Narrative.d.ts +0 -32
  400. package/dist/fhir/Narrative.js +0 -7
  401. package/dist/fhir/Narrative.js.map +0 -1
  402. package/dist/fhir/NutritionOrder.d.ts +0 -566
  403. package/dist/fhir/NutritionOrder.js +0 -7
  404. package/dist/fhir/NutritionOrder.js.map +0 -1
  405. package/dist/fhir/Observation.d.ts +0 -520
  406. package/dist/fhir/Observation.js +0 -7
  407. package/dist/fhir/Observation.js.map +0 -1
  408. package/dist/fhir/ObservationDefinition.d.ts +0 -278
  409. package/dist/fhir/ObservationDefinition.js +0 -7
  410. package/dist/fhir/ObservationDefinition.js.map +0 -1
  411. package/dist/fhir/OperationDefinition.d.ts +0 -468
  412. package/dist/fhir/OperationDefinition.js +0 -7
  413. package/dist/fhir/OperationDefinition.js.map +0 -1
  414. package/dist/fhir/OperationOutcome.d.ts +0 -160
  415. package/dist/fhir/OperationOutcome.js +0 -7
  416. package/dist/fhir/OperationOutcome.js.map +0 -1
  417. package/dist/fhir/Organization.d.ts +0 -184
  418. package/dist/fhir/Organization.js +0 -7
  419. package/dist/fhir/Organization.js.map +0 -1
  420. package/dist/fhir/OrganizationAffiliation.d.ts +0 -145
  421. package/dist/fhir/OrganizationAffiliation.js +0 -7
  422. package/dist/fhir/OrganizationAffiliation.js.map +0 -1
  423. package/dist/fhir/ParameterDefinition.d.ts +0 -57
  424. package/dist/fhir/ParameterDefinition.js +0 -7
  425. package/dist/fhir/ParameterDefinition.js.map +0 -1
  426. package/dist/fhir/Parameters.d.ts +0 -319
  427. package/dist/fhir/Parameters.js +0 -7
  428. package/dist/fhir/Parameters.js.map +0 -1
  429. package/dist/fhir/PasswordChangeRequest.d.ts +0 -51
  430. package/dist/fhir/PasswordChangeRequest.js +0 -7
  431. package/dist/fhir/PasswordChangeRequest.js.map +0 -1
  432. package/dist/fhir/Patient.d.ts +0 -342
  433. package/dist/fhir/Patient.js +0 -7
  434. package/dist/fhir/Patient.js.map +0 -1
  435. package/dist/fhir/PaymentNotice.d.ts +0 -135
  436. package/dist/fhir/PaymentNotice.js +0 -7
  437. package/dist/fhir/PaymentNotice.js.map +0 -1
  438. package/dist/fhir/PaymentReconciliation.d.ts +0 -280
  439. package/dist/fhir/PaymentReconciliation.js +0 -7
  440. package/dist/fhir/PaymentReconciliation.js.map +0 -1
  441. package/dist/fhir/Period.d.ts +0 -32
  442. package/dist/fhir/Period.js +0 -7
  443. package/dist/fhir/Period.js.map +0 -1
  444. package/dist/fhir/Person.d.ts +0 -175
  445. package/dist/fhir/Person.js +0 -7
  446. package/dist/fhir/Person.js.map +0 -1
  447. package/dist/fhir/PlanDefinition.d.ts +0 -837
  448. package/dist/fhir/PlanDefinition.js +0 -7
  449. package/dist/fhir/PlanDefinition.js.map +0 -1
  450. package/dist/fhir/Population.d.ts +0 -62
  451. package/dist/fhir/Population.js +0 -7
  452. package/dist/fhir/Population.js.map +0 -1
  453. package/dist/fhir/Practitioner.d.ts +0 -191
  454. package/dist/fhir/Practitioner.js +0 -7
  455. package/dist/fhir/Practitioner.js.map +0 -1
  456. package/dist/fhir/PractitionerRole.d.ts +0 -259
  457. package/dist/fhir/PractitionerRole.js +0 -7
  458. package/dist/fhir/PractitionerRole.js.map +0 -1
  459. package/dist/fhir/Procedure.d.ts +0 -372
  460. package/dist/fhir/Procedure.js +0 -7
  461. package/dist/fhir/Procedure.js.map +0 -1
  462. package/dist/fhir/ProdCharacteristic.d.ts +0 -112
  463. package/dist/fhir/ProdCharacteristic.js +0 -7
  464. package/dist/fhir/ProdCharacteristic.js.map +0 -1
  465. package/dist/fhir/ProductShelfLife.d.ts +0 -70
  466. package/dist/fhir/ProductShelfLife.js +0 -7
  467. package/dist/fhir/ProductShelfLife.js.map +0 -1
  468. package/dist/fhir/Project.d.ts +0 -43
  469. package/dist/fhir/Project.js +0 -7
  470. package/dist/fhir/Project.js.map +0 -1
  471. package/dist/fhir/ProjectMembership.d.ts +0 -66
  472. package/dist/fhir/ProjectMembership.js +0 -7
  473. package/dist/fhir/ProjectMembership.js.map +0 -1
  474. package/dist/fhir/Provenance.d.ts +0 -258
  475. package/dist/fhir/Provenance.js +0 -7
  476. package/dist/fhir/Provenance.js.map +0 -1
  477. package/dist/fhir/Quantity.d.ts +0 -46
  478. package/dist/fhir/Quantity.js +0 -7
  479. package/dist/fhir/Quantity.js.map +0 -1
  480. package/dist/fhir/Questionnaire.d.ts +0 -603
  481. package/dist/fhir/Questionnaire.js +0 -7
  482. package/dist/fhir/Questionnaire.js.map +0 -1
  483. package/dist/fhir/QuestionnaireResponse.d.ts +0 -313
  484. package/dist/fhir/QuestionnaireResponse.js +0 -7
  485. package/dist/fhir/QuestionnaireResponse.js.map +0 -1
  486. package/dist/fhir/Range.d.ts +0 -30
  487. package/dist/fhir/Range.js +0 -7
  488. package/dist/fhir/Range.js.map +0 -1
  489. package/dist/fhir/Ratio.d.ts +0 -30
  490. package/dist/fhir/Ratio.js +0 -7
  491. package/dist/fhir/Ratio.js.map +0 -1
  492. package/dist/fhir/Reference.d.ts +0 -67
  493. package/dist/fhir/Reference.js +0 -7
  494. package/dist/fhir/Reference.js.map +0 -1
  495. package/dist/fhir/RefreshToken.d.ts +0 -45
  496. package/dist/fhir/RefreshToken.js +0 -7
  497. package/dist/fhir/RefreshToken.js.map +0 -1
  498. package/dist/fhir/RelatedArtifact.d.ts +0 -57
  499. package/dist/fhir/RelatedArtifact.js +0 -7
  500. package/dist/fhir/RelatedArtifact.js.map +0 -1
  501. package/dist/fhir/RelatedPerson.d.ts +0 -190
  502. package/dist/fhir/RelatedPerson.js +0 -7
  503. package/dist/fhir/RelatedPerson.js.map +0 -1
  504. package/dist/fhir/RequestGroup.d.ts +0 -434
  505. package/dist/fhir/RequestGroup.js +0 -7
  506. package/dist/fhir/RequestGroup.js.map +0 -1
  507. package/dist/fhir/ResearchDefinition.d.ts +0 -291
  508. package/dist/fhir/ResearchDefinition.js +0 -7
  509. package/dist/fhir/ResearchDefinition.js.map +0 -1
  510. package/dist/fhir/ResearchElementDefinition.d.ts +0 -431
  511. package/dist/fhir/ResearchElementDefinition.js +0 -7
  512. package/dist/fhir/ResearchElementDefinition.js.map +0 -1
  513. package/dist/fhir/ResearchStudy.d.ts +0 -318
  514. package/dist/fhir/ResearchStudy.js +0 -7
  515. package/dist/fhir/ResearchStudy.js.map +0 -1
  516. package/dist/fhir/ResearchSubject.d.ts +0 -119
  517. package/dist/fhir/ResearchSubject.js +0 -7
  518. package/dist/fhir/ResearchSubject.js.map +0 -1
  519. package/dist/fhir/Resource.d.ts +0 -156
  520. package/dist/fhir/Resource.js +0 -7
  521. package/dist/fhir/Resource.js.map +0 -1
  522. package/dist/fhir/RiskAssessment.d.ts +0 -246
  523. package/dist/fhir/RiskAssessment.js +0 -7
  524. package/dist/fhir/RiskAssessment.js.map +0 -1
  525. package/dist/fhir/RiskEvidenceSynthesis.d.ts +0 -530
  526. package/dist/fhir/RiskEvidenceSynthesis.js +0 -7
  527. package/dist/fhir/RiskEvidenceSynthesis.js.map +0 -1
  528. package/dist/fhir/SampledData.d.ts +0 -62
  529. package/dist/fhir/SampledData.js +0 -7
  530. package/dist/fhir/SampledData.js.map +0 -1
  531. package/dist/fhir/Schedule.d.ts +0 -129
  532. package/dist/fhir/Schedule.js +0 -7
  533. package/dist/fhir/Schedule.js.map +0 -1
  534. package/dist/fhir/SearchParameter.d.ts +0 -277
  535. package/dist/fhir/SearchParameter.js +0 -7
  536. package/dist/fhir/SearchParameter.js.map +0 -1
  537. package/dist/fhir/ServiceRequest.d.ts +0 -309
  538. package/dist/fhir/ServiceRequest.js +0 -7
  539. package/dist/fhir/ServiceRequest.js.map +0 -1
  540. package/dist/fhir/Signature.d.ts +0 -71
  541. package/dist/fhir/Signature.js +0 -7
  542. package/dist/fhir/Signature.js.map +0 -1
  543. package/dist/fhir/Slot.d.ts +0 -134
  544. package/dist/fhir/Slot.js +0 -7
  545. package/dist/fhir/Slot.js.map +0 -1
  546. package/dist/fhir/Specimen.d.ts +0 -366
  547. package/dist/fhir/Specimen.js +0 -7
  548. package/dist/fhir/Specimen.js.map +0 -1
  549. package/dist/fhir/SpecimenDefinition.d.ts +0 -363
  550. package/dist/fhir/SpecimenDefinition.js +0 -7
  551. package/dist/fhir/SpecimenDefinition.js.map +0 -1
  552. package/dist/fhir/StructureDefinition.d.ts +0 -438
  553. package/dist/fhir/StructureDefinition.js +0 -7
  554. package/dist/fhir/StructureDefinition.js.map +0 -1
  555. package/dist/fhir/StructureMap.d.ts +0 -904
  556. package/dist/fhir/StructureMap.js +0 -7
  557. package/dist/fhir/StructureMap.js.map +0 -1
  558. package/dist/fhir/Subscription.d.ts +0 -172
  559. package/dist/fhir/Subscription.js +0 -7
  560. package/dist/fhir/Subscription.js.map +0 -1
  561. package/dist/fhir/Substance.d.ts +0 -213
  562. package/dist/fhir/Substance.js +0 -7
  563. package/dist/fhir/Substance.js.map +0 -1
  564. package/dist/fhir/SubstanceAmount.d.ts +0 -115
  565. package/dist/fhir/SubstanceAmount.js +0 -7
  566. package/dist/fhir/SubstanceAmount.js.map +0 -1
  567. package/dist/fhir/SubstanceNucleicAcid.d.ts +0 -309
  568. package/dist/fhir/SubstanceNucleicAcid.js +0 -7
  569. package/dist/fhir/SubstanceNucleicAcid.js.map +0 -1
  570. package/dist/fhir/SubstancePolymer.d.ts +0 -405
  571. package/dist/fhir/SubstancePolymer.js +0 -7
  572. package/dist/fhir/SubstancePolymer.js.map +0 -1
  573. package/dist/fhir/SubstanceProtein.d.ts +0 -218
  574. package/dist/fhir/SubstanceProtein.js +0 -7
  575. package/dist/fhir/SubstanceProtein.js.map +0 -1
  576. package/dist/fhir/SubstanceReferenceInformation.d.ts +0 -330
  577. package/dist/fhir/SubstanceReferenceInformation.js +0 -7
  578. package/dist/fhir/SubstanceReferenceInformation.js.map +0 -1
  579. package/dist/fhir/SubstanceSourceMaterial.d.ts +0 -521
  580. package/dist/fhir/SubstanceSourceMaterial.js +0 -7
  581. package/dist/fhir/SubstanceSourceMaterial.js.map +0 -1
  582. package/dist/fhir/SubstanceSpecification.d.ts +0 -827
  583. package/dist/fhir/SubstanceSpecification.js +0 -7
  584. package/dist/fhir/SubstanceSpecification.js.map +0 -1
  585. package/dist/fhir/SupplyDelivery.d.ts +0 -205
  586. package/dist/fhir/SupplyDelivery.js +0 -7
  587. package/dist/fhir/SupplyDelivery.js.map +0 -1
  588. package/dist/fhir/SupplyRequest.d.ts +0 -237
  589. package/dist/fhir/SupplyRequest.js +0 -7
  590. package/dist/fhir/SupplyRequest.js.map +0 -1
  591. package/dist/fhir/Task.d.ts +0 -807
  592. package/dist/fhir/Task.js +0 -7
  593. package/dist/fhir/Task.js.map +0 -1
  594. package/dist/fhir/TerminologyCapabilities.d.ts +0 -716
  595. package/dist/fhir/TerminologyCapabilities.js +0 -7
  596. package/dist/fhir/TerminologyCapabilities.js.map +0 -1
  597. package/dist/fhir/TestReport.d.ts +0 -549
  598. package/dist/fhir/TestReport.js +0 -7
  599. package/dist/fhir/TestReport.js.map +0 -1
  600. package/dist/fhir/TestScript.d.ts +0 -1184
  601. package/dist/fhir/TestScript.js +0 -7
  602. package/dist/fhir/TestScript.js.map +0 -1
  603. package/dist/fhir/Timing.d.ts +0 -178
  604. package/dist/fhir/Timing.js +0 -7
  605. package/dist/fhir/Timing.js.map +0 -1
  606. package/dist/fhir/TriggerDefinition.d.ts +0 -65
  607. package/dist/fhir/TriggerDefinition.js +0 -7
  608. package/dist/fhir/TriggerDefinition.js.map +0 -1
  609. package/dist/fhir/UsageContext.d.ts +0 -61
  610. package/dist/fhir/UsageContext.js +0 -7
  611. package/dist/fhir/UsageContext.js.map +0 -1
  612. package/dist/fhir/User.d.ts +0 -45
  613. package/dist/fhir/User.js +0 -7
  614. package/dist/fhir/User.js.map +0 -1
  615. package/dist/fhir/ValueSet.d.ts +0 -725
  616. package/dist/fhir/ValueSet.js +0 -7
  617. package/dist/fhir/ValueSet.js.map +0 -1
  618. package/dist/fhir/VerificationResult.d.ts +0 -340
  619. package/dist/fhir/VerificationResult.js +0 -7
  620. package/dist/fhir/VerificationResult.js.map +0 -1
  621. package/dist/fhir/VisionPrescription.d.ts +0 -264
  622. package/dist/fhir/VisionPrescription.js +0 -7
  623. package/dist/fhir/VisionPrescription.js.map +0 -1
  624. package/dist/fhir/index.d.ts +0 -196
  625. package/dist/fhir/index.js +0 -213
  626. package/dist/fhir/index.js.map +0 -1
  627. package/dist/fhirpath/functions.d.ts +0 -6
  628. package/dist/fhirpath/functions.js +0 -349
  629. package/dist/fhirpath/functions.js.map +0 -1
  630. package/dist/fhirpath/index.d.ts +0 -2
  631. package/dist/fhirpath/index.js +0 -15
  632. package/dist/fhirpath/index.js.map +0 -1
  633. package/dist/fhirpath/parse.d.ts +0 -10
  634. package/dist/fhirpath/parse.js +0 -266
  635. package/dist/fhirpath/parse.js.map +0 -1
  636. package/dist/fhirpath/tokenize.d.ts +0 -13
  637. package/dist/fhirpath/tokenize.js +0 -39
  638. package/dist/fhirpath/tokenize.js.map +0 -1
  639. package/dist/fhirpath/utils.d.ts +0 -13
  640. package/dist/fhirpath/utils.js +0 -34
  641. package/dist/fhirpath/utils.js.map +0 -1
  642. package/dist/format.js +0 -56
  643. package/dist/format.js.map +0 -1
  644. package/dist/index.js +0 -22
  645. package/dist/index.js.map +0 -1
  646. package/dist/jwt.d.ts +0 -5
  647. package/dist/jwt.js +0 -28
  648. package/dist/jwt.js.map +0 -1
  649. package/dist/outcomes.js +0 -140
  650. package/dist/outcomes.js.map +0 -1
  651. package/dist/search.js +0 -120
  652. package/dist/search.js.map +0 -1
  653. package/dist/searchparams.js +0 -129
  654. package/dist/searchparams.js.map +0 -1
  655. package/dist/storage.js +0 -90
  656. package/dist/storage.js.map +0 -1
  657. package/dist/types.js +0 -171
  658. package/dist/types.js.map +0 -1
  659. package/dist/utils.js +0 -234
  660. package/dist/utils.js.map +0 -1
package/dist/client.js DELETED
@@ -1,541 +0,0 @@
1
- "use strict";
2
- // PKCE auth ased on:
3
- // https://aws.amazon.com/blogs/security/how-to-add-authentication-single-page-web-application-with-amazon-cognito-oauth2-implementation/
4
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
5
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
6
- return new (P || (P = Promise))(function (resolve, reject) {
7
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
9
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
10
- step((generator = generator.apply(thisArg, _arguments || [])).next());
11
- });
12
- };
13
- Object.defineProperty(exports, "__esModule", { value: true });
14
- exports.MedplumClient = void 0;
15
- const cache_1 = require("./cache");
16
- const crypto_1 = require("./crypto");
17
- const eventtarget_1 = require("./eventtarget");
18
- const jwt_1 = require("./jwt");
19
- const outcomes_1 = require("./outcomes");
20
- const search_1 = require("./search");
21
- const storage_1 = require("./storage");
22
- const types_1 = require("./types");
23
- const utils_1 = require("./utils");
24
- const DEFAULT_BASE_URL = 'https://api.medplum.com/';
25
- const DEFAULT_RESOURCE_CACHE_SIZE = 1000;
26
- const DEFAULT_BLOB_CACHE_SIZE = 100;
27
- const JSON_CONTENT_TYPE = 'application/json';
28
- const FHIR_CONTENT_TYPE = 'application/fhir+json';
29
- const PATCH_CONTENT_TYPE = 'application/json-patch+json';
30
- class MedplumClient extends eventtarget_1.EventTarget {
31
- constructor(options) {
32
- var _a, _b;
33
- super();
34
- if (options.baseUrl) {
35
- if (!options.baseUrl.startsWith('http')) {
36
- throw new Error('Base URL must start with http or https');
37
- }
38
- if (!options.baseUrl.endsWith('/')) {
39
- throw new Error('Base URL must end with a trailing slash');
40
- }
41
- }
42
- if (!options.clientId) {
43
- throw new Error('Client ID cannot be empty');
44
- }
45
- this.fetch = options.fetch || window.fetch.bind(window);
46
- this.storage = new storage_1.ClientStorage();
47
- this.schema = new Map();
48
- this.resourceCache = new cache_1.LRUCache((_a = options.resourceCacheSize) !== null && _a !== void 0 ? _a : DEFAULT_RESOURCE_CACHE_SIZE);
49
- this.blobUrlCache = new cache_1.LRUCache((_b = options.blobCacheSize) !== null && _b !== void 0 ? _b : DEFAULT_BLOB_CACHE_SIZE);
50
- this.baseUrl = options.baseUrl || DEFAULT_BASE_URL;
51
- this.clientId = options.clientId;
52
- this.authorizeUrl = options.authorizeUrl || this.baseUrl + 'oauth2/authorize';
53
- this.tokenUrl = options.tokenUrl || this.baseUrl + 'oauth2/token';
54
- this.logoutUrl = options.logoutUrl || this.baseUrl + 'oauth2/logout';
55
- this.onUnauthenticated = options.onUnauthenticated;
56
- }
57
- /**
58
- * Clears all auth state including local storage and session storage.
59
- */
60
- clear() {
61
- this.storage.clear();
62
- this.activeLogin = undefined;
63
- this.dispatchEvent({ type: 'change' });
64
- }
65
- get(url, blob) {
66
- return this.request('GET', url, undefined, undefined, blob);
67
- }
68
- post(url, body, contentType) {
69
- return this.request('POST', url, contentType, body);
70
- }
71
- put(url, body, contentType) {
72
- return this.request('PUT', url, contentType, body);
73
- }
74
- /**
75
- * Tries to register a new user.
76
- * @param request The registration request.
77
- * @returns Promise to the user profile resource.
78
- */
79
- register(request) {
80
- return this.post('auth/register', request)
81
- .then((response) => this.handleLoginResponse(response));
82
- }
83
- /**
84
- * Tries to sign in with email and password.
85
- * @param email The user email address.
86
- * @param password The user password.
87
- * @param role The login role.
88
- * @param scope The OAuth2 login scope.
89
- * @param remember Optional flag to "remember" to generate a refresh token and persist in local storage.
90
- * @returns Promise to the user profile resource.
91
- */
92
- signIn(email, password, role, scope, remember) {
93
- return this.post('auth/login', {
94
- clientId: this.clientId,
95
- email,
96
- password,
97
- role,
98
- scope,
99
- remember: !!remember
100
- }).then((response) => this.handleLoginResponse(response));
101
- }
102
- /**
103
- * Tries to sign in with Google authentication.
104
- * The response parameter is the result of a Google authentication.
105
- * See: https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions
106
- * @param googleResponse The Google credential response.
107
- * @returns Promise to the user profile resource.
108
- */
109
- signInWithGoogle(googleResponse) {
110
- return this.post('auth/google', googleResponse)
111
- .then((loginResponse) => this.handleLoginResponse(loginResponse));
112
- }
113
- /**
114
- * Handles a login response.
115
- * This can be used for both "register" and "signIn".
116
- * @param response The login response.
117
- * @returns The user profile.
118
- */
119
- handleLoginResponse(response) {
120
- this.setActiveLogin(response);
121
- return response.profile;
122
- }
123
- /**
124
- * Signs out locally.
125
- * Does not invalidate tokens with the server.
126
- */
127
- signOut() {
128
- this.clear();
129
- return Promise.resolve();
130
- }
131
- /**
132
- * Tries to sign in the user.
133
- * Returns true if the user is signed in.
134
- * This may result in navigating away to the sign in page.
135
- */
136
- signInWithRedirect() {
137
- const urlParams = new URLSearchParams(window.location.search);
138
- const code = urlParams.get('code');
139
- if (!code) {
140
- this.requestAuthorization();
141
- return undefined;
142
- }
143
- else {
144
- return this.processCode(code);
145
- }
146
- }
147
- /**
148
- * Tries to sign out the user.
149
- * See: https://docs.aws.amazon.com/cognito/latest/developerguide/logout-endpoint.html
150
- */
151
- signOutWithRedirect() {
152
- window.location.assign(this.logoutUrl);
153
- }
154
- fhirUrl(...path) {
155
- const builder = [this.baseUrl, 'fhir/R4'];
156
- path.forEach(p => builder.push('/', encodeURIComponent(p)));
157
- return builder.join('');
158
- }
159
- search(search) {
160
- if (typeof search === 'string') {
161
- return this.get('fhir/R4/' + search);
162
- }
163
- else {
164
- return this.get(this.fhirUrl(search.resourceType) + (0, search_1.formatSearchQuery)(search));
165
- }
166
- }
167
- /**
168
- * Searches a ValueSet resource using the "expand" operation.
169
- * See: https://www.hl7.org/fhir/operation-valueset-expand.html
170
- * @param system The ValueSet system url.
171
- * @param filter The search string.
172
- * @returns Promise to expanded ValueSet.
173
- */
174
- searchValueSet(system, filter) {
175
- return this.get(this.fhirUrl('ValueSet', '$expand') +
176
- `?url=${encodeURIComponent(system)}` +
177
- `&filter=${encodeURIComponent(filter)}`);
178
- }
179
- read(resourceType, id) {
180
- const cacheKey = resourceType + '/' + id;
181
- const promise = this.get(this.fhirUrl(resourceType, id))
182
- .then((resource) => {
183
- this.resourceCache.set(cacheKey, resource);
184
- return resource;
185
- });
186
- this.resourceCache.set(cacheKey, promise);
187
- return promise;
188
- }
189
- readCached(resourceType, id) {
190
- const cached = this.resourceCache.get(resourceType + '/' + id);
191
- return cached ? Promise.resolve(cached) : this.read(resourceType, id);
192
- }
193
- readReference(reference) {
194
- const refString = reference === null || reference === void 0 ? void 0 : reference.reference;
195
- if (!refString) {
196
- return Promise.reject('Missing reference');
197
- }
198
- const [resourceType, id] = refString.split('/');
199
- return this.read(resourceType, id);
200
- }
201
- readCachedReference(reference) {
202
- const refString = reference === null || reference === void 0 ? void 0 : reference.reference;
203
- if (!refString) {
204
- return Promise.reject('Missing reference');
205
- }
206
- const [resourceType, id] = refString.split('/');
207
- return this.readCached(resourceType, id);
208
- }
209
- getTypeDefinition(resourceType) {
210
- if (!resourceType) {
211
- return Promise.reject('Missing resourceType');
212
- }
213
- const cached = this.schema.get(resourceType);
214
- if (cached) {
215
- return Promise.resolve(cached);
216
- }
217
- let typeDef;
218
- return this.search('StructureDefinition?name:exact=' + encodeURIComponent(resourceType))
219
- .then((result) => {
220
- var _a;
221
- if (!((_a = result.entry) === null || _a === void 0 ? void 0 : _a.length)) {
222
- throw new Error('StructureDefinition not found');
223
- }
224
- const resource = result.entry[0].resource;
225
- if (!resource) {
226
- throw new Error('StructureDefinition not found');
227
- }
228
- typeDef = (0, types_1.indexStructureDefinition)(resource);
229
- })
230
- .then(() => this.search({
231
- resourceType: 'SearchParameter',
232
- count: 100,
233
- filters: [{
234
- code: 'base',
235
- operator: search_1.Operator.EQUALS,
236
- value: resourceType
237
- }]
238
- }))
239
- .then((result) => {
240
- const entries = result.entry;
241
- if (entries) {
242
- typeDef.types[resourceType].searchParams = entries
243
- .map(e => e.resource)
244
- .sort((a, b) => { var _a, _b; return (_b = (_a = a.name) === null || _a === void 0 ? void 0 : _a.localeCompare(b.name)) !== null && _b !== void 0 ? _b : 0; });
245
- }
246
- this.schema.set(resourceType, typeDef);
247
- return typeDef;
248
- });
249
- }
250
- readHistory(resourceType, id) {
251
- return this.get(this.fhirUrl(resourceType, id, '_history'));
252
- }
253
- readPatientEverything(id) {
254
- return this.get(this.fhirUrl('Patient', id, '$everything'));
255
- }
256
- readBlob(url) {
257
- return this.get(url, true);
258
- }
259
- readBlobAsObjectUrl(url) {
260
- const promise = this.readBlob(url)
261
- .then(imageBlob => {
262
- const imageUrl = URL.createObjectURL(imageBlob);
263
- this.blobUrlCache.set(url, imageUrl);
264
- return imageUrl;
265
- });
266
- this.blobUrlCache.set(url, promise);
267
- return promise;
268
- }
269
- readCachedBlobAsObjectUrl(url) {
270
- const cached = this.blobUrlCache.get(url);
271
- return cached ? Promise.resolve(cached) : this.readBlobAsObjectUrl(url);
272
- }
273
- readBinary(id) {
274
- return this.readBlob(this.fhirUrl('Binary', id));
275
- }
276
- create(resource) {
277
- if (!resource.resourceType) {
278
- throw new Error('Missing resourceType');
279
- }
280
- return this.post(this.fhirUrl(resource.resourceType), resource);
281
- }
282
- createBinary(data, contentType) {
283
- return this.post(this.fhirUrl('Binary'), data, contentType);
284
- }
285
- update(resource) {
286
- if (!resource.resourceType) {
287
- throw new Error('Missing resourceType');
288
- }
289
- if (!resource.id) {
290
- throw new Error('Missing id');
291
- }
292
- return this.put(this.fhirUrl(resource.resourceType, resource.id), resource);
293
- }
294
- patch(resourceType, id, operations) {
295
- return this.request('PATCH', this.fhirUrl(resourceType, id), PATCH_CONTENT_TYPE, operations);
296
- }
297
- graphql(gql) {
298
- return this.post(this.fhirUrl('$graphql'), gql, JSON_CONTENT_TYPE);
299
- }
300
- subscribe(criteria, handler) {
301
- return this.create({
302
- resourceType: 'Subscription',
303
- status: 'active',
304
- criteria: criteria,
305
- channel: {
306
- type: 'sse'
307
- }
308
- }).then((sub) => {
309
- const eventSource = new EventSource(this.baseUrl + 'sse?subscription=' + encodeURIComponent(sub.id), {
310
- withCredentials: true
311
- });
312
- eventSource.onmessage = (e) => {
313
- handler(JSON.parse(e.data));
314
- };
315
- return eventSource;
316
- });
317
- }
318
- getActiveLogin() {
319
- if (!this.activeLogin) {
320
- this.activeLogin = this.storage.getObject('activeLogin');
321
- }
322
- return this.activeLogin;
323
- }
324
- setActiveLogin(login) {
325
- this.activeLogin = login;
326
- this.storage.setObject('activeLogin', login);
327
- this.addLogin(login);
328
- this.dispatchEvent({ type: 'change' });
329
- }
330
- getLogins() {
331
- var _a;
332
- return (_a = this.storage.getObject('logins')) !== null && _a !== void 0 ? _a : [];
333
- }
334
- addLogin(newLogin) {
335
- const logins = this.getLogins().filter(login => { var _a, _b; return ((_a = login.profile) === null || _a === void 0 ? void 0 : _a.id) !== ((_b = newLogin.profile) === null || _b === void 0 ? void 0 : _b.id); });
336
- logins.push(newLogin);
337
- this.storage.setObject('logins', logins);
338
- }
339
- getProfile() {
340
- var _a;
341
- return (_a = this.getActiveLogin()) === null || _a === void 0 ? void 0 : _a.profile;
342
- }
343
- /**
344
- * Makes an HTTP request.
345
- * @param {string} method
346
- * @param {string} url
347
- * @param {string=} contentType
348
- * @param {Object=} body
349
- * @param {boolean=} blob
350
- */
351
- request(method, url, contentType, body, blob) {
352
- var _a;
353
- return __awaiter(this, void 0, void 0, function* () {
354
- if (!url.startsWith('http')) {
355
- url = this.baseUrl + url;
356
- }
357
- const headers = {
358
- 'Content-Type': contentType || FHIR_CONTENT_TYPE
359
- };
360
- const accessToken = (_a = this.getActiveLogin()) === null || _a === void 0 ? void 0 : _a.accessToken;
361
- if (accessToken) {
362
- headers['Authorization'] = 'Bearer ' + accessToken;
363
- }
364
- const options = {
365
- method: method,
366
- cache: 'no-cache',
367
- credentials: 'include',
368
- headers
369
- };
370
- if (body) {
371
- if (typeof body === 'string' || (typeof File !== 'undefined' && body instanceof File)) {
372
- options.body = body;
373
- }
374
- else {
375
- options.body = (0, utils_1.stringify)(body);
376
- }
377
- }
378
- const response = yield this.fetch(url, options);
379
- if (response.status === 401) {
380
- // Refresh and try again
381
- return this.handleUnauthenticated(method, url, contentType, body, blob);
382
- }
383
- if (response.status === 304) {
384
- // No change
385
- return undefined;
386
- }
387
- const obj = blob ? yield response.blob() : yield response.json();
388
- if (obj.resourceType === 'OperationOutcome' && !(0, outcomes_1.isOk)(obj)) {
389
- return Promise.reject(new outcomes_1.OperationOutcomeError(obj));
390
- }
391
- return obj;
392
- });
393
- }
394
- /**
395
- * Handles an unauthenticated response from the server.
396
- * First, tries to refresh the access token and retry the request.
397
- * Otherwise, calls unauthenticated callbacks and rejects.
398
- * @param method The HTTP method of the original request.
399
- * @param url The URL of the original request.
400
- * @param contentType The content type of the original request.
401
- * @param body The body of the original request.
402
- * @param blob Optional blob flag of the original request.
403
- */
404
- handleUnauthenticated(method, url, contentType, body, blob) {
405
- return __awaiter(this, void 0, void 0, function* () {
406
- return this.refresh()
407
- .then(() => this.request(method, url, contentType, body, blob))
408
- .catch(error => {
409
- this.clear();
410
- if (this.onUnauthenticated) {
411
- this.onUnauthenticated();
412
- }
413
- return Promise.reject(error);
414
- });
415
- });
416
- }
417
- /**
418
- * Redirects the user to the login screen for authorization.
419
- * Clears all auth state including local storage and session storage.
420
- * See: https://openid.net/specs/openid-connect-core-1_0.html#AuthorizationEndpoint
421
- */
422
- requestAuthorization() {
423
- return __awaiter(this, void 0, void 0, function* () {
424
- if (!this.authorizeUrl) {
425
- throw new Error('Missing authorize URL');
426
- }
427
- this.clear();
428
- const pkceState = (0, crypto_1.getRandomString)();
429
- this.storage.setString('pkceState', pkceState);
430
- const codeVerifier = (0, crypto_1.getRandomString)();
431
- this.storage.setString('codeVerifier', codeVerifier);
432
- const arrayHash = yield (0, crypto_1.encryptSHA256)(codeVerifier);
433
- const codeChallenge = (0, utils_1.arrayBufferToBase64)(arrayHash);
434
- this.storage.setString('codeChallenge', codeChallenge);
435
- const scope = 'launch/patient openid fhirUser offline_access user/*.*';
436
- window.location.assign(this.authorizeUrl +
437
- '?response_type=code' +
438
- '&state=' + encodeURIComponent(pkceState) +
439
- '&client_id=' + encodeURIComponent(this.clientId) +
440
- '&redirect_uri=' + encodeURIComponent(getBaseUrl()) +
441
- '&scope=' + encodeURIComponent(scope) +
442
- '&code_challenge_method=S256' +
443
- '&code_challenge=' + encodeURIComponent(codeChallenge));
444
- });
445
- }
446
- /**
447
- * Processes an OAuth authorization code.
448
- * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenRequest
449
- * @param code The authorization code received by URL parameter.
450
- */
451
- processCode(code) {
452
- const pkceState = this.storage.getString('pkceState');
453
- if (!pkceState) {
454
- this.clear();
455
- throw new Error('Invalid PCKE state');
456
- }
457
- const codeVerifier = this.storage.getString('codeVerifier');
458
- if (!codeVerifier) {
459
- this.clear();
460
- throw new Error('Invalid PCKE code verifier');
461
- }
462
- return this.fetchTokens('grant_type=authorization_code' +
463
- '&client_id=' + encodeURIComponent(this.clientId) +
464
- '&code_verifier=' + encodeURIComponent(codeVerifier) +
465
- '&redirect_uri=' + encodeURIComponent(getBaseUrl()) +
466
- '&code=' + encodeURIComponent(code));
467
- }
468
- /**
469
- * Tries to refresh the auth tokens.
470
- * See: https://openid.net/specs/openid-connect-core-1_0.html#RefreshTokens
471
- */
472
- refresh() {
473
- var _a;
474
- return __awaiter(this, void 0, void 0, function* () {
475
- const refreshToken = (_a = this.getActiveLogin()) === null || _a === void 0 ? void 0 : _a.refreshToken;
476
- if (!refreshToken) {
477
- this.clear();
478
- return Promise.reject('Invalid refresh token');
479
- }
480
- yield this.fetchTokens('grant_type=refresh_token' +
481
- '&client_id=' + encodeURIComponent(this.clientId) +
482
- '&refresh_token=' + encodeURIComponent(refreshToken));
483
- });
484
- }
485
- /**
486
- * Makes a POST request to the tokens endpoint.
487
- * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint
488
- * @param formBody Token parameters in URL encoded format.
489
- */
490
- fetchTokens(formBody) {
491
- return __awaiter(this, void 0, void 0, function* () {
492
- if (!this.tokenUrl) {
493
- throw new Error('Missing token URL');
494
- }
495
- return this.fetch(this.tokenUrl, {
496
- method: 'POST',
497
- headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
498
- body: formBody
499
- })
500
- .then(response => {
501
- if (!response.ok) {
502
- return Promise.reject('Failed to fetch tokens');
503
- }
504
- return response.json();
505
- })
506
- .then(tokens => this.verifyTokens(tokens))
507
- .then(() => { var _a; return (_a = this.getActiveLogin()) === null || _a === void 0 ? void 0 : _a.profile; });
508
- });
509
- }
510
- /**
511
- * Verifies the tokens received from the auth server.
512
- * Validates the JWT against the JWKS.
513
- * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint
514
- * @param tokens
515
- */
516
- verifyTokens(tokens) {
517
- return __awaiter(this, void 0, void 0, function* () {
518
- const token = tokens.access_token;
519
- // Verify token has not expired
520
- const tokenPayload = (0, jwt_1.parseJWTPayload)(token);
521
- if (Date.now() >= tokenPayload.exp * 1000) {
522
- this.clear();
523
- return Promise.reject('Token expired');
524
- }
525
- // Verify app_client_id
526
- if (tokenPayload.client_id !== this.clientId) {
527
- this.clear();
528
- return Promise.reject('Token was not issued for this audience');
529
- }
530
- this.setActiveLogin(Object.assign(Object.assign({}, this.getActiveLogin()), { accessToken: token, refreshToken: tokens.refresh_token }));
531
- });
532
- }
533
- }
534
- exports.MedplumClient = MedplumClient;
535
- /**
536
- * Returns the base URL for the current page.
537
- */
538
- function getBaseUrl() {
539
- return window.location.protocol + '//' + window.location.host + '/';
540
- }
541
- //# sourceMappingURL=client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA,qBAAqB;AACrB,yIAAyI;;;;;;;;;;;;AAEzI,mCAAmC;AACnC,qCAA0D;AAC1D,+CAA4C;AAE5C,+BAAwC;AACxC,yCAAyD;AACzD,qCAAsE;AACtE,uCAA0C;AAC1C,mCAA+E;AAC/E,mCAA0E;AAE1E,MAAM,gBAAgB,GAAG,0BAA0B,CAAC;AACpD,MAAM,2BAA2B,GAAG,IAAI,CAAC;AACzC,MAAM,uBAAuB,GAAG,GAAG,CAAC;AACpC,MAAM,iBAAiB,GAAG,kBAAkB,CAAC;AAC7C,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AAClD,MAAM,kBAAkB,GAAG,6BAA6B,CAAC;AAmGzD,MAAa,aAAc,SAA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AAG,IAAI,GAAG,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC;AACtE,CAAC","sourcesContent":["// PKCE auth ased on:\n// https://aws.amazon.com/blogs/security/how-to-add-authentication-single-page-web-application-with-amazon-cognito-oauth2-implementation/\n\nimport { LRUCache } from './cache';\nimport { encryptSHA256, getRandomString } from './crypto';\nimport { EventTarget } from './eventtarget';\nimport { Binary, Bundle, Project, Reference, Resource, SearchParameter, StructureDefinition, Subscription, ValueSet } from './fhir';\nimport { parseJWTPayload } from './jwt';\nimport { isOk, OperationOutcomeError } from './outcomes';\nimport { formatSearchQuery, Operator, SearchRequest } from './search';\nimport { ClientStorage } from './storage';\nimport { IndexedStructureDefinition, indexStructureDefinition } from './types';\nimport { arrayBufferToBase64, ProfileResource, stringify } from './utils';\n\nconst DEFAULT_BASE_URL = 'https://api.medplum.com/';\nconst DEFAULT_RESOURCE_CACHE_SIZE = 1000;\nconst DEFAULT_BLOB_CACHE_SIZE = 100;\nconst JSON_CONTENT_TYPE = 'application/json';\nconst FHIR_CONTENT_TYPE = 'application/fhir+json';\nconst PATCH_CONTENT_TYPE = 'application/json-patch+json';\n\nexport interface MedplumClientOptions {\n /**\n * The client ID.\n * Required.\n */\n clientId: string;\n\n /**\n * Base server URL.\n * Optional. Default value is \"https://api.medplum.com/\".\n * Use this to point to a custom Medplum deployment.\n */\n baseUrl?: string;\n\n /**\n * OAuth2 authorize URL.\n * Optional. Default value is baseUrl + \"/oauth2/authorize\".\n * Use this if you want to use a separate OAuth server.\n */\n authorizeUrl?: string;\n\n /**\n * OAuth2 token URL.\n * Optional. Default value is baseUrl + \"/oauth2/token\".\n * Use this if you want to use a separate OAuth server.\n */\n tokenUrl?: string;\n\n /**\n * OAuth2 logout URL.\n * Optional. Default value is baseUrl + \"/oauth2/logout\".\n * Use this if you want to use a separate OAuth server.\n */\n logoutUrl?: string;\n\n /**\n * Number of resources to store in the cache.\n * Optional. Default value is 1000.\n * Consider using this for performance of displaying Patient or Practitioner resources.\n */\n resourceCacheSize?: number;\n\n /**\n * Number of blob URLs to store in the cache.\n * Optional. Default value is 100.\n * Consider using this for performance of displaying Patient or Practitioner resources.\n */\n blobCacheSize?: number;\n\n /**\n * Optional fetch implementation.\n * Optional. Default is window.fetch.\n * For nodejs applications, consider the 'node-fetch' package.\n */\n fetch?: FetchLike;\n\n /**\n * Optional callback for when the client is unauthenticated.\n * Default is do nothing.\n * For client side applications, consider redirecting to a sign in page.\n */\n onUnauthenticated?: () => void;\n}\n\nexport interface FetchLike {\n (url: string, options?: any): Promise<any>;\n}\n\ninterface LoginResponse {\n project: Project;\n profile: ProfileResource;\n accessToken: string;\n refreshToken: string;\n}\n\ninterface TokenResponse {\n token_type: string;\n id_token: string;\n access_token: string;\n refresh_token: string;\n expires_in: number;\n}\n\nexport interface RegisterRequest {\n firstName: string;\n lastName: string;\n projectName: string;\n email: string;\n password: string;\n remember?: boolean;\n}\n\nexport interface GoogleCredentialResponse {\n readonly clientId: string;\n readonly credential: string;\n}\n\nexport class MedplumClient extends EventTarget {\n private readonly fetch: FetchLike;\n private readonly storage: ClientStorage;\n private readonly schema: Map<string, IndexedStructureDefinition>;\n private readonly resourceCache: LRUCache<Resource | Promise<Resource>>;\n private readonly blobUrlCache: LRUCache<string | Promise<string>>;\n private readonly baseUrl: string;\n private readonly clientId: string;\n private readonly authorizeUrl: string;\n private readonly tokenUrl: string;\n private readonly logoutUrl: string;\n private readonly onUnauthenticated?: () => void;\n private activeLogin?: LoginResponse;\n\n constructor(options: MedplumClientOptions) {\n super();\n\n if (options.baseUrl) {\n if (!options.baseUrl.startsWith('http')) {\n throw new Error('Base URL must start with http or https');\n }\n if (!options.baseUrl.endsWith('/')) {\n throw new Error('Base URL must end with a trailing slash');\n }\n }\n\n if (!options.clientId) {\n throw new Error('Client ID cannot be empty');\n }\n\n this.fetch = options.fetch || window.fetch.bind(window);\n this.storage = new ClientStorage();\n this.schema = new Map();\n this.resourceCache = new LRUCache(options.resourceCacheSize ?? DEFAULT_RESOURCE_CACHE_SIZE);\n this.blobUrlCache = new LRUCache(options.blobCacheSize ?? DEFAULT_BLOB_CACHE_SIZE);\n this.baseUrl = options.baseUrl || DEFAULT_BASE_URL;\n this.clientId = options.clientId;\n this.authorizeUrl = options.authorizeUrl || this.baseUrl + 'oauth2/authorize';\n this.tokenUrl = options.tokenUrl || this.baseUrl + 'oauth2/token';\n this.logoutUrl = options.logoutUrl || this.baseUrl + 'oauth2/logout';\n this.onUnauthenticated = options.onUnauthenticated;\n }\n\n /**\n * Clears all auth state including local storage and session storage.\n */\n clear(): void {\n this.storage.clear();\n this.activeLogin = undefined;\n this.dispatchEvent({ type: 'change' });\n }\n\n get(url: string, blob?: boolean): Promise<any> {\n return this.request('GET', url, undefined, undefined, blob);\n }\n\n post(url: string, body: any, contentType?: string): Promise<any> {\n return this.request('POST', url, contentType, body);\n }\n\n put(url: string, body: any, contentType?: string): Promise<any> {\n return this.request('PUT', url, contentType, body);\n }\n\n /**\n * Tries to register a new user.\n * @param request The registration request.\n * @returns Promise to the user profile resource.\n */\n register(request: RegisterRequest): Promise<ProfileResource> {\n return this.post('auth/register', request)\n .then((response: LoginResponse) => this.handleLoginResponse(response));\n }\n\n /**\n * Tries to sign in with email and password.\n * @param email The user email address.\n * @param password The user password.\n * @param role The login role.\n * @param scope The OAuth2 login scope.\n * @param remember Optional flag to \"remember\" to generate a refresh token and persist in local storage.\n * @returns Promise to the user profile resource.\n */\n signIn(\n email: string,\n password: string,\n role: string,\n scope: string,\n remember?: boolean): Promise<ProfileResource> {\n\n return this.post('auth/login', {\n clientId: this.clientId,\n email,\n password,\n role,\n scope,\n remember: !!remember\n }).then((response: LoginResponse) => this.handleLoginResponse(response));\n }\n\n /**\n * Tries to sign in with Google authentication.\n * The response parameter is the result of a Google authentication.\n * See: https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions\n * @param googleResponse The Google credential response.\n * @returns Promise to the user profile resource.\n */\n signInWithGoogle(googleResponse: GoogleCredentialResponse): Promise<ProfileResource> {\n return this.post('auth/google', googleResponse)\n .then((loginResponse: LoginResponse) => this.handleLoginResponse(loginResponse));\n }\n\n /**\n * Handles a login response.\n * This can be used for both \"register\" and \"signIn\".\n * @param response The login response.\n * @returns The user profile.\n */\n private handleLoginResponse(response: LoginResponse): ProfileResource {\n this.setActiveLogin(response);\n return response.profile;\n }\n\n /**\n * Signs out locally.\n * Does not invalidate tokens with the server.\n */\n signOut(): Promise<void> {\n this.clear();\n return Promise.resolve();\n }\n\n /**\n * Tries to sign in the user.\n * Returns true if the user is signed in.\n * This may result in navigating away to the sign in page.\n */\n signInWithRedirect(): Promise<ProfileResource | void> | undefined {\n const urlParams = new URLSearchParams(window.location.search);\n const code = urlParams.get('code');\n if (!code) {\n this.requestAuthorization();\n return undefined;\n } else {\n return this.processCode(code);\n }\n }\n\n /**\n * Tries to sign out the user.\n * See: https://docs.aws.amazon.com/cognito/latest/developerguide/logout-endpoint.html\n */\n signOutWithRedirect(): void {\n window.location.assign(this.logoutUrl);\n }\n\n fhirUrl(...path: string[]): string {\n const builder = [this.baseUrl, 'fhir/R4'];\n path.forEach(p => builder.push('/', encodeURIComponent(p)))\n return builder.join('');\n }\n\n search<T extends Resource>(search: string | SearchRequest): Promise<Bundle<T>> {\n if (typeof search === 'string') {\n return this.get('fhir/R4/' + search);\n } else {\n return this.get(this.fhirUrl(search.resourceType) + formatSearchQuery(search));\n }\n }\n\n /**\n * Searches a ValueSet resource using the \"expand\" operation.\n * See: https://www.hl7.org/fhir/operation-valueset-expand.html\n * @param system The ValueSet system url.\n * @param filter The search string.\n * @returns Promise to expanded ValueSet.\n */\n searchValueSet(system: string, filter: string): Promise<ValueSet> {\n return this.get(\n this.fhirUrl('ValueSet', '$expand') +\n `?url=${encodeURIComponent(system)}` +\n `&filter=${encodeURIComponent(filter)}`);\n }\n\n read<T extends Resource>(resourceType: string, id: string): Promise<T> {\n const cacheKey = resourceType + '/' + id;\n const promise = this.get(this.fhirUrl(resourceType, id))\n .then((resource: T) => {\n this.resourceCache.set(cacheKey, resource);\n return resource;\n });\n this.resourceCache.set(cacheKey, promise);\n return promise;\n }\n\n readCached<T extends Resource>(resourceType: string, id: string): Promise<T> {\n const cached = this.resourceCache.get(resourceType + '/' + id) as T | Promise<T> | undefined;\n return cached ? Promise.resolve(cached) : this.read(resourceType, id);\n }\n\n readReference<T extends Resource>(reference: Reference<T>): Promise<T> {\n const refString = reference?.reference;\n if (!refString) {\n return Promise.reject('Missing reference');\n }\n const [resourceType, id] = refString.split('/');\n return this.read(resourceType, id);\n }\n\n readCachedReference<T extends Resource>(reference: Reference<T>): Promise<T> {\n const refString = reference?.reference;\n if (!refString) {\n return Promise.reject('Missing reference');\n }\n const [resourceType, id] = refString.split('/');\n return this.readCached(resourceType, id);\n }\n\n getTypeDefinition(resourceType: string): Promise<IndexedStructureDefinition> {\n if (!resourceType) {\n return Promise.reject('Missing resourceType');\n }\n const cached = this.schema.get(resourceType);\n if (cached) {\n return Promise.resolve(cached);\n }\n let typeDef: IndexedStructureDefinition;\n return this.search<StructureDefinition>('StructureDefinition?name:exact=' + encodeURIComponent(resourceType))\n .then((result: Bundle<StructureDefinition>) => {\n if (!result.entry?.length) {\n throw new Error('StructureDefinition not found');\n }\n const resource = result.entry[0].resource;\n if (!resource) {\n throw new Error('StructureDefinition not found');\n }\n typeDef = indexStructureDefinition(resource);\n })\n .then(() => this.search<SearchParameter>({\n resourceType: 'SearchParameter',\n count: 100,\n filters: [{\n code: 'base',\n operator: Operator.EQUALS,\n value: resourceType\n }]\n }))\n .then((result: Bundle<SearchParameter>) => {\n const entries = result.entry;\n if (entries) {\n typeDef.types[resourceType].searchParams = entries\n .map(e => e.resource as SearchParameter)\n .sort((a, b) => a.name?.localeCompare(b.name as string) ?? 0);\n }\n this.schema.set(resourceType, typeDef);\n return typeDef;\n });\n }\n\n readHistory<T extends Resource>(resourceType: string, id: string): Promise<Bundle<T>> {\n return this.get(this.fhirUrl(resourceType, id, '_history'));\n }\n\n readPatientEverything(id: string): Promise<Bundle> {\n return this.get(this.fhirUrl('Patient', id, '$everything'));\n }\n\n readBlob(url: string): Promise<Blob> {\n return this.get(url, true);\n }\n\n readBlobAsObjectUrl(url: string): Promise<string> {\n const promise = this.readBlob(url)\n .then(imageBlob => {\n const imageUrl = URL.createObjectURL(imageBlob);\n this.blobUrlCache.set(url, imageUrl);\n return imageUrl;\n });\n this.blobUrlCache.set(url, promise);\n return promise;\n }\n\n readCachedBlobAsObjectUrl(url: string): Promise<string> {\n const cached = this.blobUrlCache.get(url);\n return cached ? Promise.resolve(cached) : this.readBlobAsObjectUrl(url);\n }\n\n readBinary(id: string): Promise<Blob> {\n return this.readBlob(this.fhirUrl('Binary', id));\n }\n\n create<T extends Resource>(resource: T): Promise<T> {\n if (!resource.resourceType) {\n throw new Error('Missing resourceType');\n }\n return this.post(this.fhirUrl(resource.resourceType), resource);\n }\n\n createBinary(data: any, contentType: string): Promise<Binary> {\n return this.post(this.fhirUrl('Binary'), data, contentType);\n }\n\n update<T extends Resource>(resource: T): Promise<T> {\n if (!resource.resourceType) {\n throw new Error('Missing resourceType');\n }\n if (!resource.id) {\n throw new Error('Missing id');\n }\n return this.put(this.fhirUrl(resource.resourceType, resource.id), resource);\n }\n\n patch(resourceType: string, id: string, operations: any): Promise<any> {\n return this.request('PATCH', this.fhirUrl(resourceType, id), PATCH_CONTENT_TYPE, operations);\n }\n\n graphql(gql: any): Promise<any> {\n return this.post(this.fhirUrl('$graphql'), gql, JSON_CONTENT_TYPE);\n }\n\n subscribe(criteria: string, handler: (e: Resource) => void): Promise<EventSource> {\n return this.create({\n resourceType: 'Subscription',\n status: 'active',\n criteria: criteria,\n channel: {\n type: 'sse'\n }\n }).then((sub: Subscription) => {\n const eventSource = new EventSource(this.baseUrl + 'sse?subscription=' + encodeURIComponent(sub.id as string), {\n withCredentials: true\n });\n\n eventSource.onmessage = (e: MessageEvent) => {\n handler(JSON.parse(e.data) as Resource);\n };\n\n return eventSource;\n });\n }\n\n getActiveLogin(): LoginResponse | undefined {\n if (!this.activeLogin) {\n this.activeLogin = this.storage.getObject<LoginResponse>('activeLogin');\n }\n return this.activeLogin;\n }\n\n setActiveLogin(login: LoginResponse): void {\n this.activeLogin = login;\n this.storage.setObject('activeLogin', login);\n this.addLogin(login);\n this.dispatchEvent({ type: 'change' });\n }\n\n getLogins(): LoginResponse[] {\n return this.storage.getObject<LoginResponse[]>('logins') ?? [];\n }\n\n addLogin(newLogin: LoginResponse): void {\n const logins = this.getLogins().filter(login => login.profile?.id !== newLogin.profile?.id);\n logins.push(newLogin);\n this.storage.setObject('logins', logins);\n }\n\n getProfile(): ProfileResource | undefined {\n return this.getActiveLogin()?.profile;\n }\n\n /**\n * Makes an HTTP request.\n * @param {string} method\n * @param {string} url\n * @param {string=} contentType\n * @param {Object=} body\n * @param {boolean=} blob\n */\n private async request(\n method: string,\n url: string,\n contentType?: string,\n body?: any,\n blob?: boolean): Promise<any> {\n\n if (!url.startsWith('http')) {\n url = this.baseUrl + url;\n }\n\n const headers: Record<string, string> = {\n 'Content-Type': contentType || FHIR_CONTENT_TYPE\n };\n\n const accessToken = this.getActiveLogin()?.accessToken;\n if (accessToken) {\n headers['Authorization'] = 'Bearer ' + accessToken;\n }\n\n const options: RequestInit = {\n method: method,\n cache: 'no-cache',\n credentials: 'include',\n headers\n };\n\n if (body) {\n if (typeof body === 'string' || (typeof File !== 'undefined' && body instanceof File)) {\n options.body = body;\n } else {\n options.body = stringify(body);\n }\n }\n\n const response = await this.fetch(url, options);\n if (response.status === 401) {\n // Refresh and try again\n return this.handleUnauthenticated(method, url, contentType, body, blob);\n }\n\n if (response.status === 304) {\n // No change\n return undefined;\n }\n\n const obj = blob ? await response.blob() : await response.json();\n if (obj.resourceType === 'OperationOutcome' && !isOk(obj)) {\n return Promise.reject(new OperationOutcomeError(obj));\n }\n return obj;\n }\n\n /**\n * Handles an unauthenticated response from the server.\n * First, tries to refresh the access token and retry the request.\n * Otherwise, calls unauthenticated callbacks and rejects.\n * @param method The HTTP method of the original request.\n * @param url The URL of the original request.\n * @param contentType The content type of the original request.\n * @param body The body of the original request.\n * @param blob Optional blob flag of the original request.\n */\n private async handleUnauthenticated(\n method: string,\n url: string,\n contentType?: string,\n body?: any,\n blob?: boolean): Promise<any> {\n return this.refresh()\n .then(() => this.request(method, url, contentType, body, blob))\n .catch(error => {\n this.clear();\n if (this.onUnauthenticated) {\n this.onUnauthenticated();\n }\n return Promise.reject(error);\n });\n }\n\n /**\n * Redirects the user to the login screen for authorization.\n * Clears all auth state including local storage and session storage.\n * See: https://openid.net/specs/openid-connect-core-1_0.html#AuthorizationEndpoint\n */\n private async requestAuthorization() {\n if (!this.authorizeUrl) {\n throw new Error('Missing authorize URL');\n }\n\n this.clear();\n\n const pkceState = getRandomString();\n this.storage.setString('pkceState', pkceState);\n\n const codeVerifier = getRandomString();\n this.storage.setString('codeVerifier', codeVerifier);\n\n const arrayHash = await encryptSHA256(codeVerifier);\n const codeChallenge = arrayBufferToBase64(arrayHash);\n this.storage.setString('codeChallenge', codeChallenge);\n\n const scope = 'launch/patient openid fhirUser offline_access user/*.*';\n\n window.location.assign(this.authorizeUrl +\n '?response_type=code' +\n '&state=' + encodeURIComponent(pkceState) +\n '&client_id=' + encodeURIComponent(this.clientId) +\n '&redirect_uri=' + encodeURIComponent(getBaseUrl()) +\n '&scope=' + encodeURIComponent(scope) +\n '&code_challenge_method=S256' +\n '&code_challenge=' + encodeURIComponent(codeChallenge));\n }\n\n /**\n * Processes an OAuth authorization code.\n * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenRequest\n * @param code The authorization code received by URL parameter.\n */\n private processCode(code: string): Promise<ProfileResource> {\n const pkceState = this.storage.getString('pkceState');\n if (!pkceState) {\n this.clear();\n throw new Error('Invalid PCKE state');\n }\n\n const codeVerifier = this.storage.getString('codeVerifier');\n if (!codeVerifier) {\n this.clear();\n throw new Error('Invalid PCKE code verifier');\n }\n\n return this.fetchTokens(\n 'grant_type=authorization_code' +\n '&client_id=' + encodeURIComponent(this.clientId) +\n '&code_verifier=' + encodeURIComponent(codeVerifier) +\n '&redirect_uri=' + encodeURIComponent(getBaseUrl()) +\n '&code=' + encodeURIComponent(code));\n }\n\n /**\n * Tries to refresh the auth tokens.\n * See: https://openid.net/specs/openid-connect-core-1_0.html#RefreshTokens\n */\n private async refresh(): Promise<void> {\n const refreshToken = this.getActiveLogin()?.refreshToken;\n if (!refreshToken) {\n this.clear();\n return Promise.reject('Invalid refresh token');\n }\n\n await this.fetchTokens(\n 'grant_type=refresh_token' +\n '&client_id=' + encodeURIComponent(this.clientId) +\n '&refresh_token=' + encodeURIComponent(refreshToken));\n }\n\n /**\n * Makes a POST request to the tokens endpoint.\n * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint\n * @param formBody Token parameters in URL encoded format.\n */\n private async fetchTokens(formBody: string): Promise<ProfileResource> {\n if (!this.tokenUrl) {\n throw new Error('Missing token URL');\n }\n\n return this.fetch(\n this.tokenUrl,\n {\n method: 'POST',\n headers: { 'Content-Type': 'application/x-www-form-urlencoded' },\n body: formBody\n })\n .then(response => {\n if (!response.ok) {\n return Promise.reject('Failed to fetch tokens');\n }\n return response.json();\n })\n .then(tokens => this.verifyTokens(tokens))\n .then(() => this.getActiveLogin()?.profile as ProfileResource);\n }\n\n /**\n * Verifies the tokens received from the auth server.\n * Validates the JWT against the JWKS.\n * See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint\n * @param tokens\n */\n private async verifyTokens(tokens: TokenResponse): Promise<void> {\n const token = tokens.access_token;\n\n // Verify token has not expired\n const tokenPayload = parseJWTPayload(token);\n if (Date.now() >= tokenPayload.exp * 1000) {\n this.clear();\n return Promise.reject('Token expired');\n }\n\n // Verify app_client_id\n if (tokenPayload.client_id !== this.clientId) {\n this.clear();\n return Promise.reject('Token was not issued for this audience');\n }\n\n this.setActiveLogin({\n ...(this.getActiveLogin() as LoginResponse),\n accessToken: token,\n refreshToken: tokens.refresh_token\n });\n }\n}\n\n/**\n * Returns the base URL for the current page.\n */\nfunction getBaseUrl() {\n return window.location.protocol + '//' + window.location.host + '/';\n}\n"]}
package/dist/crypto.js DELETED
@@ -1,33 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.encryptSHA256 = exports.getRandomString = void 0;
13
- const utils_1 = require("./utils");
14
- /**
15
- * Returns a cryptographically secure random string.
16
- */
17
- function getRandomString() {
18
- const randomItems = new Uint32Array(28);
19
- crypto.getRandomValues(randomItems);
20
- return (0, utils_1.arrayBufferToHex)(randomItems.buffer);
21
- }
22
- exports.getRandomString = getRandomString;
23
- /**
24
- * Encrypts a string with SHA256 encryption.
25
- * @param str
26
- */
27
- function encryptSHA256(str) {
28
- return __awaiter(this, void 0, void 0, function* () {
29
- return crypto.subtle.digest('SHA-256', new TextEncoder().encode(str));
30
- });
31
- }
32
- exports.encryptSHA256 = encryptSHA256;
33
- //# sourceMappingURL=crypto.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"crypto.js","sourceRoot":"","sources":["../src/crypto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,mCAA2C;AAE3C;;GAEG;AACH,SAAgB,eAAe;IAC7B,MAAM,WAAW,GAAG,IAAI,WAAW,CAAC,EAAE,CAAC,CAAC;IACxC,MAAM,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC;IACpC,OAAO,IAAA,wBAAgB,EAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAC9C,CAAC;AAJD,0CAIC;AAED;;;GAGG;AACH,SAAsB,aAAa,CAAC,GAAW;;QAC7C,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC;IACxE,CAAC;CAAA;AAFD,sCAEC","sourcesContent":["import { arrayBufferToHex } from './utils';\n\n/**\n * Returns a cryptographically secure random string.\n */\nexport function getRandomString(): string {\n const randomItems = new Uint32Array(28);\n crypto.getRandomValues(randomItems);\n return arrayBufferToHex(randomItems.buffer);\n}\n\n/**\n * Encrypts a string with SHA256 encryption.\n * @param str\n */\nexport async function encryptSHA256(str: string): Promise<ArrayBuffer> {\n return crypto.subtle.digest('SHA-256', new TextEncoder().encode(str));\n}\n"]}