@medplum/core 0.2.0 → 0.4.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.
- package/README.md +32 -26
- package/dist/cjs/index.js +1769 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/index.min.js +16 -0
- package/dist/cjs/index.min.js.map +1 -0
- package/dist/esm/index.js +1721 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/index.min.js +16 -0
- package/dist/esm/index.min.js.map +1 -0
- package/dist/{cache.d.ts → types/cache.d.ts} +1 -0
- package/dist/{client.d.ts → types/client.d.ts} +115 -61
- package/dist/{crypto.d.ts → types/crypto.d.ts} +0 -0
- package/dist/{eventtarget.d.ts → types/eventtarget.d.ts} +0 -0
- package/dist/{format.d.ts → types/format.d.ts} +1 -1
- package/dist/{index.d.ts → types/index.d.ts} +0 -2
- package/dist/types/jwt.d.ts +5 -0
- package/dist/{outcomes.d.ts → types/outcomes.d.ts} +7 -2
- package/dist/{search.d.ts → types/search.d.ts} +3 -0
- package/dist/{searchparams.d.ts → types/searchparams.d.ts} +2 -1
- package/dist/{storage.d.ts → types/storage.d.ts} +0 -0
- package/dist/{types.d.ts → types/types.d.ts} +18 -4
- package/dist/{utils.d.ts → types/utils.d.ts} +1 -1
- package/package.json +14 -9
- package/rollup.config.js +36 -0
- package/dist/cache.js +0 -38
- package/dist/cache.js.map +0 -1
- package/dist/cache.test.d.ts +0 -1
- package/dist/cache.test.js +0 -29
- package/dist/cache.test.js.map +0 -1
- package/dist/client.js +0 -530
- package/dist/client.js.map +0 -1
- package/dist/client.test.d.ts +0 -1
- package/dist/client.test.js +0 -382
- package/dist/client.test.js.map +0 -1
- package/dist/crypto.js +0 -22
- package/dist/crypto.js.map +0 -1
- package/dist/eventtarget.js +0 -39
- package/dist/eventtarget.js.map +0 -1
- package/dist/eventtarget.test.d.ts +0 -1
- package/dist/eventtarget.test.js +0 -44
- package/dist/eventtarget.test.js.map +0 -1
- package/dist/fhir/AccessPolicy.d.ts +0 -75
- package/dist/fhir/AccessPolicy.js +0 -7
- package/dist/fhir/AccessPolicy.js.map +0 -1
- package/dist/fhir/Account.d.ts +0 -247
- package/dist/fhir/Account.js +0 -7
- package/dist/fhir/Account.js.map +0 -1
- package/dist/fhir/ActivityDefinition.d.ts +0 -500
- package/dist/fhir/ActivityDefinition.js +0 -7
- package/dist/fhir/ActivityDefinition.js.map +0 -1
- package/dist/fhir/Address.d.ts +0 -75
- package/dist/fhir/Address.js +0 -7
- package/dist/fhir/Address.js.map +0 -1
- package/dist/fhir/AdverseEvent.d.ts +0 -303
- package/dist/fhir/AdverseEvent.js +0 -7
- package/dist/fhir/AdverseEvent.js.map +0 -1
- package/dist/fhir/Age.d.ts +0 -47
- package/dist/fhir/Age.js +0 -7
- package/dist/fhir/Age.js.map +0 -1
- package/dist/fhir/AllergyIntolerance.d.ts +0 -283
- package/dist/fhir/AllergyIntolerance.js +0 -7
- package/dist/fhir/AllergyIntolerance.js.map +0 -1
- package/dist/fhir/Annotation.d.ts +0 -42
- package/dist/fhir/Annotation.js +0 -7
- package/dist/fhir/Annotation.js.map +0 -1
- package/dist/fhir/Appointment.d.ts +0 -284
- package/dist/fhir/Appointment.js +0 -7
- package/dist/fhir/Appointment.js.map +0 -1
- package/dist/fhir/AppointmentResponse.d.ts +0 -131
- package/dist/fhir/AppointmentResponse.js +0 -7
- package/dist/fhir/AppointmentResponse.js.map +0 -1
- package/dist/fhir/Attachment.d.ts +0 -58
- package/dist/fhir/Attachment.js +0 -7
- package/dist/fhir/Attachment.js.map +0 -1
- package/dist/fhir/AuditEvent.d.ts +0 -458
- package/dist/fhir/AuditEvent.js +0 -7
- package/dist/fhir/AuditEvent.js.map +0 -1
- package/dist/fhir/Basic.d.ts +0 -110
- package/dist/fhir/Basic.js +0 -7
- package/dist/fhir/Basic.js.map +0 -1
- package/dist/fhir/Binary.d.ts +0 -59
- package/dist/fhir/Binary.js +0 -7
- package/dist/fhir/Binary.js.map +0 -1
- package/dist/fhir/BiologicallyDerivedProduct.d.ts +0 -358
- package/dist/fhir/BiologicallyDerivedProduct.js +0 -7
- package/dist/fhir/BiologicallyDerivedProduct.js.map +0 -1
- package/dist/fhir/BodyStructure.d.ts +0 -119
- package/dist/fhir/BodyStructure.js +0 -7
- package/dist/fhir/BodyStructure.js.map +0 -1
- package/dist/fhir/Bot.d.ts +0 -49
- package/dist/fhir/Bot.js +0 -7
- package/dist/fhir/Bot.js.map +0 -1
- package/dist/fhir/Bundle.d.ts +0 -379
- package/dist/fhir/Bundle.js +0 -7
- package/dist/fhir/Bundle.js.map +0 -1
- package/dist/fhir/CapabilityStatement.d.ts +0 -1044
- package/dist/fhir/CapabilityStatement.js +0 -7
- package/dist/fhir/CapabilityStatement.js.map +0 -1
- package/dist/fhir/CarePlan.d.ts +0 -446
- package/dist/fhir/CarePlan.js +0 -7
- package/dist/fhir/CarePlan.js.map +0 -1
- package/dist/fhir/CareTeam.d.ts +0 -211
- package/dist/fhir/CareTeam.js +0 -7
- package/dist/fhir/CareTeam.js.map +0 -1
- package/dist/fhir/CatalogEntry.d.ts +0 -195
- package/dist/fhir/CatalogEntry.js +0 -7
- package/dist/fhir/CatalogEntry.js.map +0 -1
- package/dist/fhir/ChargeItem.d.ts +0 -287
- package/dist/fhir/ChargeItem.js +0 -7
- package/dist/fhir/ChargeItem.js.map +0 -1
- package/dist/fhir/ChargeItemDefinition.d.ts +0 -401
- package/dist/fhir/ChargeItemDefinition.js +0 -7
- package/dist/fhir/ChargeItemDefinition.js.map +0 -1
- package/dist/fhir/Claim.d.ts +0 -1092
- package/dist/fhir/Claim.js +0 -7
- package/dist/fhir/Claim.js.map +0 -1
- package/dist/fhir/ClaimResponse.d.ts +0 -1040
- package/dist/fhir/ClaimResponse.js +0 -7
- package/dist/fhir/ClaimResponse.js.map +0 -1
- package/dist/fhir/ClientApplication.d.ts +0 -46
- package/dist/fhir/ClientApplication.js +0 -7
- package/dist/fhir/ClientApplication.js.map +0 -1
- package/dist/fhir/ClinicalImpression.d.ts +0 -306
- package/dist/fhir/ClinicalImpression.js +0 -7
- package/dist/fhir/ClinicalImpression.js.map +0 -1
- package/dist/fhir/CodeSystem.d.ts +0 -541
- package/dist/fhir/CodeSystem.js +0 -7
- package/dist/fhir/CodeSystem.js.map +0 -1
- package/dist/fhir/CodeableConcept.d.ts +0 -33
- package/dist/fhir/CodeableConcept.js +0 -7
- package/dist/fhir/CodeableConcept.js.map +0 -1
- package/dist/fhir/Coding.d.ts +0 -50
- package/dist/fhir/Coding.js +0 -7
- package/dist/fhir/Coding.js.map +0 -1
- package/dist/fhir/Communication.d.ts +0 -264
- package/dist/fhir/Communication.js +0 -7
- package/dist/fhir/Communication.js.map +0 -1
- package/dist/fhir/CommunicationRequest.d.ts +0 -261
- package/dist/fhir/CommunicationRequest.js +0 -7
- package/dist/fhir/CommunicationRequest.js.map +0 -1
- package/dist/fhir/CompartmentDefinition.d.ts +0 -217
- package/dist/fhir/CompartmentDefinition.js +0 -7
- package/dist/fhir/CompartmentDefinition.js.map +0 -1
- package/dist/fhir/Composition.d.ts +0 -429
- package/dist/fhir/Composition.js +0 -7
- package/dist/fhir/Composition.js.map +0 -1
- package/dist/fhir/ConceptMap.d.ts +0 -518
- package/dist/fhir/ConceptMap.js +0 -7
- package/dist/fhir/ConceptMap.js.map +0 -1
- package/dist/fhir/Condition.d.ts +0 -326
- package/dist/fhir/Condition.js +0 -7
- package/dist/fhir/Condition.js.map +0 -1
- package/dist/fhir/Consent.d.ts +0 -460
- package/dist/fhir/Consent.js +0 -7
- package/dist/fhir/Consent.js.map +0 -1
- package/dist/fhir/ContactDetail.d.ts +0 -31
- package/dist/fhir/ContactDetail.js +0 -7
- package/dist/fhir/ContactDetail.js.map +0 -1
- package/dist/fhir/ContactPoint.d.ts +0 -47
- package/dist/fhir/ContactPoint.js +0 -7
- package/dist/fhir/ContactPoint.js.map +0 -1
- package/dist/fhir/Contract.d.ts +0 -1452
- package/dist/fhir/Contract.js +0 -7
- package/dist/fhir/Contract.js.map +0 -1
- package/dist/fhir/Contributor.d.ts +0 -37
- package/dist/fhir/Contributor.js +0 -7
- package/dist/fhir/Contributor.js.map +0 -1
- package/dist/fhir/Count.d.ts +0 -49
- package/dist/fhir/Count.js +0 -7
- package/dist/fhir/Count.js.map +0 -1
- package/dist/fhir/Coverage.d.ts +0 -327
- package/dist/fhir/Coverage.js +0 -7
- package/dist/fhir/Coverage.js.map +0 -1
- package/dist/fhir/CoverageEligibilityRequest.d.ts +0 -404
- package/dist/fhir/CoverageEligibilityRequest.js +0 -7
- package/dist/fhir/CoverageEligibilityRequest.js.map +0 -1
- package/dist/fhir/CoverageEligibilityResponse.d.ts +0 -434
- package/dist/fhir/CoverageEligibilityResponse.js +0 -7
- package/dist/fhir/CoverageEligibilityResponse.js.map +0 -1
- package/dist/fhir/DataRequirement.d.ts +0 -239
- package/dist/fhir/DataRequirement.js +0 -7
- package/dist/fhir/DataRequirement.js.map +0 -1
- package/dist/fhir/DetectedIssue.d.ts +0 -252
- package/dist/fhir/DetectedIssue.js +0 -7
- package/dist/fhir/DetectedIssue.js.map +0 -1
- package/dist/fhir/Device.d.ts +0 -493
- package/dist/fhir/Device.js +0 -7
- package/dist/fhir/Device.js.map +0 -1
- package/dist/fhir/DeviceDefinition.d.ts +0 -486
- package/dist/fhir/DeviceDefinition.js +0 -7
- package/dist/fhir/DeviceDefinition.js.map +0 -1
- package/dist/fhir/DeviceMetric.d.ts +0 -199
- package/dist/fhir/DeviceMetric.js +0 -7
- package/dist/fhir/DeviceMetric.js.map +0 -1
- package/dist/fhir/DeviceRequest.d.ts +0 -296
- package/dist/fhir/DeviceRequest.js +0 -7
- package/dist/fhir/DeviceRequest.js.map +0 -1
- package/dist/fhir/DeviceUseStatement.d.ts +0 -168
- package/dist/fhir/DeviceUseStatement.js +0 -7
- package/dist/fhir/DeviceUseStatement.js.map +0 -1
- package/dist/fhir/DiagnosticReport.d.ts +0 -254
- package/dist/fhir/DiagnosticReport.js +0 -7
- package/dist/fhir/DiagnosticReport.js.map +0 -1
- package/dist/fhir/Distance.d.ts +0 -47
- package/dist/fhir/Distance.js +0 -7
- package/dist/fhir/Distance.js.map +0 -1
- package/dist/fhir/DocumentManifest.d.ts +0 -196
- package/dist/fhir/DocumentManifest.js +0 -7
- package/dist/fhir/DocumentManifest.js.map +0 -1
- package/dist/fhir/DocumentReference.d.ts +0 -349
- package/dist/fhir/DocumentReference.js +0 -7
- package/dist/fhir/DocumentReference.js.map +0 -1
- package/dist/fhir/Dosage.d.ts +0 -152
- package/dist/fhir/Dosage.js +0 -7
- package/dist/fhir/Dosage.js.map +0 -1
- package/dist/fhir/Duration.d.ts +0 -46
- package/dist/fhir/Duration.js +0 -7
- package/dist/fhir/Duration.js.map +0 -1
- package/dist/fhir/EffectEvidenceSynthesis.d.ts +0 -591
- package/dist/fhir/EffectEvidenceSynthesis.js +0 -7
- package/dist/fhir/EffectEvidenceSynthesis.js.map +0 -1
- package/dist/fhir/Element.d.ts +0 -21
- package/dist/fhir/Element.js +0 -7
- package/dist/fhir/Element.js.map +0 -1
- package/dist/fhir/ElementDefinition.d.ts +0 -2701
- package/dist/fhir/ElementDefinition.js +0 -7
- package/dist/fhir/ElementDefinition.js.map +0 -1
- package/dist/fhir/Encounter.d.ts +0 -558
- package/dist/fhir/Encounter.js +0 -7
- package/dist/fhir/Encounter.js.map +0 -1
- package/dist/fhir/Endpoint.d.ts +0 -140
- package/dist/fhir/Endpoint.js +0 -7
- package/dist/fhir/Endpoint.js.map +0 -1
- package/dist/fhir/EnrollmentRequest.d.ts +0 -113
- package/dist/fhir/EnrollmentRequest.js +0 -7
- package/dist/fhir/EnrollmentRequest.js.map +0 -1
- package/dist/fhir/EnrollmentResponse.d.ts +0 -117
- package/dist/fhir/EnrollmentResponse.js +0 -7
- package/dist/fhir/EnrollmentResponse.js.map +0 -1
- package/dist/fhir/EpisodeOfCare.d.ts +0 -246
- package/dist/fhir/EpisodeOfCare.js +0 -7
- package/dist/fhir/EpisodeOfCare.js.map +0 -1
- package/dist/fhir/EventDefinition.d.ts +0 -253
- package/dist/fhir/EventDefinition.js +0 -7
- package/dist/fhir/EventDefinition.js.map +0 -1
- package/dist/fhir/Evidence.d.ts +0 -252
- package/dist/fhir/Evidence.js +0 -7
- package/dist/fhir/Evidence.js.map +0 -1
- package/dist/fhir/EvidenceVariable.d.ts +0 -370
- package/dist/fhir/EvidenceVariable.js +0 -7
- package/dist/fhir/EvidenceVariable.js.map +0 -1
- package/dist/fhir/ExampleScenario.d.ts +0 -628
- package/dist/fhir/ExampleScenario.js +0 -7
- package/dist/fhir/ExampleScenario.js.map +0 -1
- package/dist/fhir/ExplanationOfBenefit.d.ts +0 -1841
- package/dist/fhir/ExplanationOfBenefit.js +0 -7
- package/dist/fhir/ExplanationOfBenefit.js.map +0 -1
- package/dist/fhir/Expression.d.ts +0 -45
- package/dist/fhir/Expression.js +0 -7
- package/dist/fhir/Expression.js.map +0 -1
- package/dist/fhir/Extension.d.ts +0 -306
- package/dist/fhir/Extension.js +0 -7
- package/dist/fhir/Extension.js.map +0 -1
- package/dist/fhir/FamilyMemberHistory.d.ts +0 -306
- package/dist/fhir/FamilyMemberHistory.js +0 -7
- package/dist/fhir/FamilyMemberHistory.js.map +0 -1
- package/dist/fhir/Flag.d.ts +0 -132
- package/dist/fhir/Flag.js +0 -7
- package/dist/fhir/Flag.js.map +0 -1
- package/dist/fhir/Goal.d.ts +0 -299
- package/dist/fhir/Goal.js +0 -7
- package/dist/fhir/Goal.js.map +0 -1
- package/dist/fhir/GraphDefinition.d.ts +0 -350
- package/dist/fhir/GraphDefinition.js +0 -7
- package/dist/fhir/GraphDefinition.js.map +0 -1
- package/dist/fhir/Group.d.ts +0 -271
- package/dist/fhir/Group.js +0 -7
- package/dist/fhir/Group.js.map +0 -1
- package/dist/fhir/GuidanceResponse.d.ts +0 -196
- package/dist/fhir/GuidanceResponse.js +0 -7
- package/dist/fhir/GuidanceResponse.js.map +0 -1
- package/dist/fhir/HealthcareService.d.ts +0 -356
- package/dist/fhir/HealthcareService.js +0 -7
- package/dist/fhir/HealthcareService.js.map +0 -1
- package/dist/fhir/HumanName.d.ts +0 -58
- package/dist/fhir/HumanName.js +0 -7
- package/dist/fhir/HumanName.js.map +0 -1
- package/dist/fhir/Identifier.d.ts +0 -53
- package/dist/fhir/Identifier.js +0 -7
- package/dist/fhir/Identifier.js.map +0 -1
- package/dist/fhir/ImagingStudy.d.ts +0 -407
- package/dist/fhir/ImagingStudy.js +0 -7
- package/dist/fhir/ImagingStudy.js.map +0 -1
- package/dist/fhir/Immunization.d.ts +0 -444
- package/dist/fhir/Immunization.js +0 -7
- package/dist/fhir/Immunization.js.map +0 -1
- package/dist/fhir/ImmunizationEvaluation.d.ts +0 -149
- package/dist/fhir/ImmunizationEvaluation.js +0 -7
- package/dist/fhir/ImmunizationEvaluation.js.map +0 -1
- package/dist/fhir/ImmunizationRecommendation.d.ts +0 -254
- package/dist/fhir/ImmunizationRecommendation.js +0 -7
- package/dist/fhir/ImmunizationRecommendation.js.map +0 -1
- package/dist/fhir/ImplementationGuide.d.ts +0 -824
- package/dist/fhir/ImplementationGuide.js +0 -7
- package/dist/fhir/ImplementationGuide.js.map +0 -1
- package/dist/fhir/InsurancePlan.d.ts +0 -624
- package/dist/fhir/InsurancePlan.js +0 -7
- package/dist/fhir/InsurancePlan.js.map +0 -1
- package/dist/fhir/Invoice.d.ts +0 -346
- package/dist/fhir/Invoice.js +0 -7
- package/dist/fhir/Invoice.js.map +0 -1
- package/dist/fhir/JsonWebKey.d.ts +0 -99
- package/dist/fhir/JsonWebKey.js +0 -7
- package/dist/fhir/JsonWebKey.js.map +0 -1
- package/dist/fhir/Library.d.ts +0 -277
- package/dist/fhir/Library.js +0 -7
- package/dist/fhir/Library.js.map +0 -1
- package/dist/fhir/Linkage.d.ts +0 -146
- package/dist/fhir/Linkage.js +0 -7
- package/dist/fhir/Linkage.js.map +0 -1
- package/dist/fhir/List.d.ts +0 -200
- package/dist/fhir/List.js +0 -7
- package/dist/fhir/List.js.map +0 -1
- package/dist/fhir/Location.d.ts +0 -277
- package/dist/fhir/Location.js +0 -7
- package/dist/fhir/Location.js.map +0 -1
- package/dist/fhir/Login.d.ts +0 -119
- package/dist/fhir/Login.js +0 -7
- package/dist/fhir/Login.js.map +0 -1
- package/dist/fhir/MarketingStatus.d.ts +0 -82
- package/dist/fhir/MarketingStatus.js +0 -7
- package/dist/fhir/MarketingStatus.js.map +0 -1
- package/dist/fhir/Measure.d.ts +0 -620
- package/dist/fhir/Measure.js +0 -7
- package/dist/fhir/Measure.js.map +0 -1
- package/dist/fhir/MeasureReport.d.ts +0 -463
- package/dist/fhir/MeasureReport.js +0 -7
- package/dist/fhir/MeasureReport.js.map +0 -1
- package/dist/fhir/Media.d.ts +0 -205
- package/dist/fhir/Media.js +0 -7
- package/dist/fhir/Media.js.map +0 -1
- package/dist/fhir/Medication.d.ts +0 -230
- package/dist/fhir/Medication.js +0 -7
- package/dist/fhir/Medication.js.map +0 -1
- package/dist/fhir/MedicationAdministration.d.ts +0 -352
- package/dist/fhir/MedicationAdministration.js +0 -7
- package/dist/fhir/MedicationAdministration.js.map +0 -1
- package/dist/fhir/MedicationDispense.d.ts +0 -343
- package/dist/fhir/MedicationDispense.js +0 -7
- package/dist/fhir/MedicationDispense.js.map +0 -1
- package/dist/fhir/MedicationKnowledge.d.ts +0 -992
- package/dist/fhir/MedicationKnowledge.js +0 -7
- package/dist/fhir/MedicationKnowledge.js.map +0 -1
- package/dist/fhir/MedicationRequest.d.ts +0 -481
- package/dist/fhir/MedicationRequest.js +0 -7
- package/dist/fhir/MedicationRequest.js.map +0 -1
- package/dist/fhir/MedicationStatement.d.ts +0 -228
- package/dist/fhir/MedicationStatement.js +0 -7
- package/dist/fhir/MedicationStatement.js.map +0 -1
- package/dist/fhir/MedicinalProduct.d.ts +0 -453
- package/dist/fhir/MedicinalProduct.js +0 -7
- package/dist/fhir/MedicinalProduct.js.map +0 -1
- package/dist/fhir/MedicinalProductAuthorization.d.ts +0 -271
- package/dist/fhir/MedicinalProductAuthorization.js +0 -7
- package/dist/fhir/MedicinalProductAuthorization.js.map +0 -1
- package/dist/fhir/MedicinalProductContraindication.d.ts +0 -170
- package/dist/fhir/MedicinalProductContraindication.js +0 -7
- package/dist/fhir/MedicinalProductContraindication.js.map +0 -1
- package/dist/fhir/MedicinalProductIndication.d.ts +0 -179
- package/dist/fhir/MedicinalProductIndication.js +0 -7
- package/dist/fhir/MedicinalProductIndication.js.map +0 -1
- package/dist/fhir/MedicinalProductIngredient.d.ts +0 -336
- package/dist/fhir/MedicinalProductIngredient.js +0 -7
- package/dist/fhir/MedicinalProductIngredient.js.map +0 -1
- package/dist/fhir/MedicinalProductInteraction.d.ts +0 -158
- package/dist/fhir/MedicinalProductInteraction.js +0 -7
- package/dist/fhir/MedicinalProductInteraction.js.map +0 -1
- package/dist/fhir/MedicinalProductManufactured.d.ts +0 -113
- package/dist/fhir/MedicinalProductManufactured.js +0 -7
- package/dist/fhir/MedicinalProductManufactured.js.map +0 -1
- package/dist/fhir/MedicinalProductPackaged.d.ts +0 -259
- package/dist/fhir/MedicinalProductPackaged.js +0 -7
- package/dist/fhir/MedicinalProductPackaged.js.map +0 -1
- package/dist/fhir/MedicinalProductPharmaceutical.d.ts +0 -331
- package/dist/fhir/MedicinalProductPharmaceutical.js +0 -7
- package/dist/fhir/MedicinalProductPharmaceutical.js.map +0 -1
- package/dist/fhir/MedicinalProductUndesirableEffect.d.ts +0 -101
- package/dist/fhir/MedicinalProductUndesirableEffect.js +0 -7
- package/dist/fhir/MedicinalProductUndesirableEffect.js.map +0 -1
- package/dist/fhir/MessageDefinition.d.ts +0 -330
- package/dist/fhir/MessageDefinition.js +0 -7
- package/dist/fhir/MessageDefinition.js.map +0 -1
- package/dist/fhir/MessageHeader.d.ts +0 -323
- package/dist/fhir/MessageHeader.js +0 -7
- package/dist/fhir/MessageHeader.js.map +0 -1
- package/dist/fhir/Meta.d.ts +0 -75
- package/dist/fhir/Meta.js +0 -7
- package/dist/fhir/Meta.js.map +0 -1
- package/dist/fhir/MolecularSequence.d.ts +0 -760
- package/dist/fhir/MolecularSequence.js +0 -7
- package/dist/fhir/MolecularSequence.js.map +0 -1
- package/dist/fhir/Money.d.ts +0 -29
- package/dist/fhir/Money.js +0 -7
- package/dist/fhir/Money.js.map +0 -1
- package/dist/fhir/NamingSystem.d.ts +0 -218
- package/dist/fhir/NamingSystem.js +0 -7
- package/dist/fhir/NamingSystem.js.map +0 -1
- package/dist/fhir/Narrative.d.ts +0 -32
- package/dist/fhir/Narrative.js +0 -7
- package/dist/fhir/Narrative.js.map +0 -1
- package/dist/fhir/NutritionOrder.d.ts +0 -566
- package/dist/fhir/NutritionOrder.js +0 -7
- package/dist/fhir/NutritionOrder.js.map +0 -1
- package/dist/fhir/Observation.d.ts +0 -520
- package/dist/fhir/Observation.js +0 -7
- package/dist/fhir/Observation.js.map +0 -1
- package/dist/fhir/ObservationDefinition.d.ts +0 -278
- package/dist/fhir/ObservationDefinition.js +0 -7
- package/dist/fhir/ObservationDefinition.js.map +0 -1
- package/dist/fhir/OperationDefinition.d.ts +0 -468
- package/dist/fhir/OperationDefinition.js +0 -7
- package/dist/fhir/OperationDefinition.js.map +0 -1
- package/dist/fhir/OperationOutcome.d.ts +0 -160
- package/dist/fhir/OperationOutcome.js +0 -7
- package/dist/fhir/OperationOutcome.js.map +0 -1
- package/dist/fhir/Organization.d.ts +0 -184
- package/dist/fhir/Organization.js +0 -7
- package/dist/fhir/Organization.js.map +0 -1
- package/dist/fhir/OrganizationAffiliation.d.ts +0 -145
- package/dist/fhir/OrganizationAffiliation.js +0 -7
- package/dist/fhir/OrganizationAffiliation.js.map +0 -1
- package/dist/fhir/ParameterDefinition.d.ts +0 -57
- package/dist/fhir/ParameterDefinition.js +0 -7
- package/dist/fhir/ParameterDefinition.js.map +0 -1
- package/dist/fhir/Parameters.d.ts +0 -319
- package/dist/fhir/Parameters.js +0 -7
- package/dist/fhir/Parameters.js.map +0 -1
- package/dist/fhir/PasswordChangeRequest.d.ts +0 -51
- package/dist/fhir/PasswordChangeRequest.js +0 -7
- package/dist/fhir/PasswordChangeRequest.js.map +0 -1
- package/dist/fhir/Patient.d.ts +0 -342
- package/dist/fhir/Patient.js +0 -7
- package/dist/fhir/Patient.js.map +0 -1
- package/dist/fhir/PaymentNotice.d.ts +0 -135
- package/dist/fhir/PaymentNotice.js +0 -7
- package/dist/fhir/PaymentNotice.js.map +0 -1
- package/dist/fhir/PaymentReconciliation.d.ts +0 -280
- package/dist/fhir/PaymentReconciliation.js +0 -7
- package/dist/fhir/PaymentReconciliation.js.map +0 -1
- package/dist/fhir/Period.d.ts +0 -32
- package/dist/fhir/Period.js +0 -7
- package/dist/fhir/Period.js.map +0 -1
- package/dist/fhir/Person.d.ts +0 -175
- package/dist/fhir/Person.js +0 -7
- package/dist/fhir/Person.js.map +0 -1
- package/dist/fhir/PlanDefinition.d.ts +0 -837
- package/dist/fhir/PlanDefinition.js +0 -7
- package/dist/fhir/PlanDefinition.js.map +0 -1
- package/dist/fhir/Population.d.ts +0 -62
- package/dist/fhir/Population.js +0 -7
- package/dist/fhir/Population.js.map +0 -1
- package/dist/fhir/Practitioner.d.ts +0 -191
- package/dist/fhir/Practitioner.js +0 -7
- package/dist/fhir/Practitioner.js.map +0 -1
- package/dist/fhir/PractitionerRole.d.ts +0 -259
- package/dist/fhir/PractitionerRole.js +0 -7
- package/dist/fhir/PractitionerRole.js.map +0 -1
- package/dist/fhir/Procedure.d.ts +0 -372
- package/dist/fhir/Procedure.js +0 -7
- package/dist/fhir/Procedure.js.map +0 -1
- package/dist/fhir/ProdCharacteristic.d.ts +0 -112
- package/dist/fhir/ProdCharacteristic.js +0 -7
- package/dist/fhir/ProdCharacteristic.js.map +0 -1
- package/dist/fhir/ProductShelfLife.d.ts +0 -70
- package/dist/fhir/ProductShelfLife.js +0 -7
- package/dist/fhir/ProductShelfLife.js.map +0 -1
- package/dist/fhir/Project.d.ts +0 -43
- package/dist/fhir/Project.js +0 -7
- package/dist/fhir/Project.js.map +0 -1
- package/dist/fhir/ProjectMembership.d.ts +0 -66
- package/dist/fhir/ProjectMembership.js +0 -7
- package/dist/fhir/ProjectMembership.js.map +0 -1
- package/dist/fhir/Provenance.d.ts +0 -258
- package/dist/fhir/Provenance.js +0 -7
- package/dist/fhir/Provenance.js.map +0 -1
- package/dist/fhir/Quantity.d.ts +0 -46
- package/dist/fhir/Quantity.js +0 -7
- package/dist/fhir/Quantity.js.map +0 -1
- package/dist/fhir/Questionnaire.d.ts +0 -603
- package/dist/fhir/Questionnaire.js +0 -7
- package/dist/fhir/Questionnaire.js.map +0 -1
- package/dist/fhir/QuestionnaireResponse.d.ts +0 -313
- package/dist/fhir/QuestionnaireResponse.js +0 -7
- package/dist/fhir/QuestionnaireResponse.js.map +0 -1
- package/dist/fhir/Range.d.ts +0 -30
- package/dist/fhir/Range.js +0 -7
- package/dist/fhir/Range.js.map +0 -1
- package/dist/fhir/Ratio.d.ts +0 -30
- package/dist/fhir/Ratio.js +0 -7
- package/dist/fhir/Ratio.js.map +0 -1
- package/dist/fhir/Reference.d.ts +0 -67
- package/dist/fhir/Reference.js +0 -7
- package/dist/fhir/Reference.js.map +0 -1
- package/dist/fhir/RefreshToken.d.ts +0 -45
- package/dist/fhir/RefreshToken.js +0 -7
- package/dist/fhir/RefreshToken.js.map +0 -1
- package/dist/fhir/RelatedArtifact.d.ts +0 -57
- package/dist/fhir/RelatedArtifact.js +0 -7
- package/dist/fhir/RelatedArtifact.js.map +0 -1
- package/dist/fhir/RelatedPerson.d.ts +0 -190
- package/dist/fhir/RelatedPerson.js +0 -7
- package/dist/fhir/RelatedPerson.js.map +0 -1
- package/dist/fhir/RequestGroup.d.ts +0 -434
- package/dist/fhir/RequestGroup.js +0 -7
- package/dist/fhir/RequestGroup.js.map +0 -1
- package/dist/fhir/ResearchDefinition.d.ts +0 -291
- package/dist/fhir/ResearchDefinition.js +0 -7
- package/dist/fhir/ResearchDefinition.js.map +0 -1
- package/dist/fhir/ResearchElementDefinition.d.ts +0 -431
- package/dist/fhir/ResearchElementDefinition.js +0 -7
- package/dist/fhir/ResearchElementDefinition.js.map +0 -1
- package/dist/fhir/ResearchStudy.d.ts +0 -318
- package/dist/fhir/ResearchStudy.js +0 -7
- package/dist/fhir/ResearchStudy.js.map +0 -1
- package/dist/fhir/ResearchSubject.d.ts +0 -119
- package/dist/fhir/ResearchSubject.js +0 -7
- package/dist/fhir/ResearchSubject.js.map +0 -1
- package/dist/fhir/Resource.d.ts +0 -156
- package/dist/fhir/Resource.js +0 -7
- package/dist/fhir/Resource.js.map +0 -1
- package/dist/fhir/RiskAssessment.d.ts +0 -246
- package/dist/fhir/RiskAssessment.js +0 -7
- package/dist/fhir/RiskAssessment.js.map +0 -1
- package/dist/fhir/RiskEvidenceSynthesis.d.ts +0 -530
- package/dist/fhir/RiskEvidenceSynthesis.js +0 -7
- package/dist/fhir/RiskEvidenceSynthesis.js.map +0 -1
- package/dist/fhir/SampledData.d.ts +0 -62
- package/dist/fhir/SampledData.js +0 -7
- package/dist/fhir/SampledData.js.map +0 -1
- package/dist/fhir/Schedule.d.ts +0 -129
- package/dist/fhir/Schedule.js +0 -7
- package/dist/fhir/Schedule.js.map +0 -1
- package/dist/fhir/SearchParameter.d.ts +0 -277
- package/dist/fhir/SearchParameter.js +0 -7
- package/dist/fhir/SearchParameter.js.map +0 -1
- package/dist/fhir/ServiceRequest.d.ts +0 -309
- package/dist/fhir/ServiceRequest.js +0 -7
- package/dist/fhir/ServiceRequest.js.map +0 -1
- package/dist/fhir/Signature.d.ts +0 -71
- package/dist/fhir/Signature.js +0 -7
- package/dist/fhir/Signature.js.map +0 -1
- package/dist/fhir/Slot.d.ts +0 -134
- package/dist/fhir/Slot.js +0 -7
- package/dist/fhir/Slot.js.map +0 -1
- package/dist/fhir/Specimen.d.ts +0 -366
- package/dist/fhir/Specimen.js +0 -7
- package/dist/fhir/Specimen.js.map +0 -1
- package/dist/fhir/SpecimenDefinition.d.ts +0 -363
- package/dist/fhir/SpecimenDefinition.js +0 -7
- package/dist/fhir/SpecimenDefinition.js.map +0 -1
- package/dist/fhir/StructureDefinition.d.ts +0 -438
- package/dist/fhir/StructureDefinition.js +0 -7
- package/dist/fhir/StructureDefinition.js.map +0 -1
- package/dist/fhir/StructureMap.d.ts +0 -904
- package/dist/fhir/StructureMap.js +0 -7
- package/dist/fhir/StructureMap.js.map +0 -1
- package/dist/fhir/Subscription.d.ts +0 -172
- package/dist/fhir/Subscription.js +0 -7
- package/dist/fhir/Subscription.js.map +0 -1
- package/dist/fhir/Substance.d.ts +0 -213
- package/dist/fhir/Substance.js +0 -7
- package/dist/fhir/Substance.js.map +0 -1
- package/dist/fhir/SubstanceAmount.d.ts +0 -115
- package/dist/fhir/SubstanceAmount.js +0 -7
- package/dist/fhir/SubstanceAmount.js.map +0 -1
- package/dist/fhir/SubstanceNucleicAcid.d.ts +0 -309
- package/dist/fhir/SubstanceNucleicAcid.js +0 -7
- package/dist/fhir/SubstanceNucleicAcid.js.map +0 -1
- package/dist/fhir/SubstancePolymer.d.ts +0 -405
- package/dist/fhir/SubstancePolymer.js +0 -7
- package/dist/fhir/SubstancePolymer.js.map +0 -1
- package/dist/fhir/SubstanceProtein.d.ts +0 -218
- package/dist/fhir/SubstanceProtein.js +0 -7
- package/dist/fhir/SubstanceProtein.js.map +0 -1
- package/dist/fhir/SubstanceReferenceInformation.d.ts +0 -330
- package/dist/fhir/SubstanceReferenceInformation.js +0 -7
- package/dist/fhir/SubstanceReferenceInformation.js.map +0 -1
- package/dist/fhir/SubstanceSourceMaterial.d.ts +0 -521
- package/dist/fhir/SubstanceSourceMaterial.js +0 -7
- package/dist/fhir/SubstanceSourceMaterial.js.map +0 -1
- package/dist/fhir/SubstanceSpecification.d.ts +0 -827
- package/dist/fhir/SubstanceSpecification.js +0 -7
- package/dist/fhir/SubstanceSpecification.js.map +0 -1
- package/dist/fhir/SupplyDelivery.d.ts +0 -205
- package/dist/fhir/SupplyDelivery.js +0 -7
- package/dist/fhir/SupplyDelivery.js.map +0 -1
- package/dist/fhir/SupplyRequest.d.ts +0 -237
- package/dist/fhir/SupplyRequest.js +0 -7
- package/dist/fhir/SupplyRequest.js.map +0 -1
- package/dist/fhir/Task.d.ts +0 -807
- package/dist/fhir/Task.js +0 -7
- package/dist/fhir/Task.js.map +0 -1
- package/dist/fhir/TerminologyCapabilities.d.ts +0 -716
- package/dist/fhir/TerminologyCapabilities.js +0 -7
- package/dist/fhir/TerminologyCapabilities.js.map +0 -1
- package/dist/fhir/TestReport.d.ts +0 -549
- package/dist/fhir/TestReport.js +0 -7
- package/dist/fhir/TestReport.js.map +0 -1
- package/dist/fhir/TestScript.d.ts +0 -1184
- package/dist/fhir/TestScript.js +0 -7
- package/dist/fhir/TestScript.js.map +0 -1
- package/dist/fhir/Timing.d.ts +0 -178
- package/dist/fhir/Timing.js +0 -7
- package/dist/fhir/Timing.js.map +0 -1
- package/dist/fhir/TriggerDefinition.d.ts +0 -65
- package/dist/fhir/TriggerDefinition.js +0 -7
- package/dist/fhir/TriggerDefinition.js.map +0 -1
- package/dist/fhir/UsageContext.d.ts +0 -61
- package/dist/fhir/UsageContext.js +0 -7
- package/dist/fhir/UsageContext.js.map +0 -1
- package/dist/fhir/User.d.ts +0 -45
- package/dist/fhir/User.js +0 -7
- package/dist/fhir/User.js.map +0 -1
- package/dist/fhir/ValueSet.d.ts +0 -725
- package/dist/fhir/ValueSet.js +0 -7
- package/dist/fhir/ValueSet.js.map +0 -1
- package/dist/fhir/VerificationResult.d.ts +0 -340
- package/dist/fhir/VerificationResult.js +0 -7
- package/dist/fhir/VerificationResult.js.map +0 -1
- package/dist/fhir/VisionPrescription.d.ts +0 -264
- package/dist/fhir/VisionPrescription.js +0 -7
- package/dist/fhir/VisionPrescription.js.map +0 -1
- package/dist/fhir/index.d.ts +0 -196
- package/dist/fhir/index.js +0 -213
- package/dist/fhir/index.js.map +0 -1
- package/dist/fhirpath/functions.d.ts +0 -6
- package/dist/fhirpath/functions.js +0 -349
- package/dist/fhirpath/functions.js.map +0 -1
- package/dist/fhirpath/functions.test.d.ts +0 -1
- package/dist/fhirpath/functions.test.js +0 -162
- package/dist/fhirpath/functions.test.js.map +0 -1
- package/dist/fhirpath/index.d.ts +0 -2
- package/dist/fhirpath/index.js +0 -15
- package/dist/fhirpath/index.js.map +0 -1
- package/dist/fhirpath/parse.d.ts +0 -10
- package/dist/fhirpath/parse.js +0 -285
- package/dist/fhirpath/parse.js.map +0 -1
- package/dist/fhirpath/parse.test.d.ts +0 -1
- package/dist/fhirpath/parse.test.js +0 -239
- package/dist/fhirpath/parse.test.js.map +0 -1
- package/dist/fhirpath/tokenize.d.ts +0 -13
- package/dist/fhirpath/tokenize.js +0 -43
- package/dist/fhirpath/tokenize.js.map +0 -1
- package/dist/fhirpath/tokenize.test.d.ts +0 -1
- package/dist/fhirpath/tokenize.test.js +0 -69
- package/dist/fhirpath/tokenize.test.js.map +0 -1
- package/dist/fhirpath/utils.d.ts +0 -13
- package/dist/fhirpath/utils.js +0 -34
- package/dist/fhirpath/utils.js.map +0 -1
- package/dist/fhirpath/utils.test.d.ts +0 -1
- package/dist/fhirpath/utils.test.js +0 -22
- package/dist/fhirpath/utils.test.js.map +0 -1
- package/dist/format.js +0 -56
- package/dist/format.js.map +0 -1
- package/dist/format.test.d.ts +0 -1
- package/dist/format.test.js +0 -127
- package/dist/format.test.js.map +0 -1
- package/dist/index.js +0 -22
- package/dist/index.js.map +0 -1
- package/dist/index.test.d.ts +0 -1
- package/dist/index.test.js +0 -11
- package/dist/index.test.js.map +0 -1
- package/dist/jwt.d.ts +0 -5
- package/dist/jwt.js +0 -28
- package/dist/jwt.js.map +0 -1
- package/dist/outcomes.js +0 -140
- package/dist/outcomes.js.map +0 -1
- package/dist/outcomes.test.d.ts +0 -1
- package/dist/outcomes.test.js +0 -38
- package/dist/outcomes.test.js.map +0 -1
- package/dist/search.js +0 -120
- package/dist/search.js.map +0 -1
- package/dist/search.test.d.ts +0 -1
- package/dist/search.test.js +0 -72
- package/dist/search.test.js.map +0 -1
- package/dist/searchparams.js +0 -127
- package/dist/searchparams.js.map +0 -1
- package/dist/searchparams.test.d.ts +0 -1
- package/dist/searchparams.test.js +0 -129
- package/dist/searchparams.test.js.map +0 -1
- package/dist/storage.js +0 -91
- package/dist/storage.js.map +0 -1
- package/dist/storage.test.d.ts +0 -1
- package/dist/storage.test.js +0 -50
- package/dist/storage.test.js.map +0 -1
- package/dist/types.js +0 -169
- package/dist/types.js.map +0 -1
- package/dist/utils.js +0 -234
- package/dist/utils.js.map +0 -1
- package/dist/utils.test.d.ts +0 -1
- package/dist/utils.test.js +0 -148
- package/dist/utils.test.js.map +0 -1
package/dist/client.js
DELETED
|
@@ -1,530 +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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.MedplumClient = void 0;
|
|
6
|
-
const cache_1 = require("./cache");
|
|
7
|
-
const crypto_1 = require("./crypto");
|
|
8
|
-
const eventtarget_1 = require("./eventtarget");
|
|
9
|
-
const jwt_1 = require("./jwt");
|
|
10
|
-
const outcomes_1 = require("./outcomes");
|
|
11
|
-
const search_1 = require("./search");
|
|
12
|
-
const storage_1 = require("./storage");
|
|
13
|
-
const types_1 = require("./types");
|
|
14
|
-
const utils_1 = require("./utils");
|
|
15
|
-
const DEFAULT_BASE_URL = 'https://api.medplum.com/';
|
|
16
|
-
const DEFAULT_RESOURCE_CACHE_SIZE = 1000;
|
|
17
|
-
const DEFAULT_BLOB_CACHE_SIZE = 100;
|
|
18
|
-
const JSON_CONTENT_TYPE = 'application/json';
|
|
19
|
-
const FHIR_CONTENT_TYPE = 'application/fhir+json';
|
|
20
|
-
const PATCH_CONTENT_TYPE = 'application/json-patch+json';
|
|
21
|
-
class MedplumClient extends eventtarget_1.EventTarget {
|
|
22
|
-
fetch;
|
|
23
|
-
storage;
|
|
24
|
-
schema;
|
|
25
|
-
resourceCache;
|
|
26
|
-
blobUrlCache;
|
|
27
|
-
baseUrl;
|
|
28
|
-
clientId;
|
|
29
|
-
authorizeUrl;
|
|
30
|
-
tokenUrl;
|
|
31
|
-
logoutUrl;
|
|
32
|
-
onUnauthenticated;
|
|
33
|
-
activeLogin;
|
|
34
|
-
constructor(options) {
|
|
35
|
-
super();
|
|
36
|
-
if (options.baseUrl) {
|
|
37
|
-
if (!options.baseUrl.startsWith('http')) {
|
|
38
|
-
throw new Error('Base URL must start with http or https');
|
|
39
|
-
}
|
|
40
|
-
if (!options.baseUrl.endsWith('/')) {
|
|
41
|
-
throw new Error('Base URL must end with a trailing slash');
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
if (!options.clientId) {
|
|
45
|
-
throw new Error('Client ID cannot be empty');
|
|
46
|
-
}
|
|
47
|
-
this.fetch = options.fetch || window.fetch.bind(window);
|
|
48
|
-
this.storage = new storage_1.ClientStorage();
|
|
49
|
-
this.schema = new Map();
|
|
50
|
-
this.resourceCache = new cache_1.LRUCache(options.resourceCacheSize ?? DEFAULT_RESOURCE_CACHE_SIZE);
|
|
51
|
-
this.blobUrlCache = new cache_1.LRUCache(options.blobCacheSize ?? DEFAULT_BLOB_CACHE_SIZE);
|
|
52
|
-
this.baseUrl = options.baseUrl || DEFAULT_BASE_URL;
|
|
53
|
-
this.clientId = options.clientId;
|
|
54
|
-
this.authorizeUrl = options.authorizeUrl || this.baseUrl + 'oauth2/authorize';
|
|
55
|
-
this.tokenUrl = options.tokenUrl || this.baseUrl + 'oauth2/token';
|
|
56
|
-
this.logoutUrl = options.logoutUrl || this.baseUrl + 'oauth2/logout';
|
|
57
|
-
this.onUnauthenticated = options.onUnauthenticated;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Clears all auth state including local storage and session storage.
|
|
61
|
-
*/
|
|
62
|
-
clear() {
|
|
63
|
-
this.storage.clear();
|
|
64
|
-
this.activeLogin = undefined;
|
|
65
|
-
this.dispatchEvent({ type: 'change' });
|
|
66
|
-
}
|
|
67
|
-
get(url, blob) {
|
|
68
|
-
return this.request('GET', url, undefined, undefined, blob);
|
|
69
|
-
}
|
|
70
|
-
post(url, body, contentType) {
|
|
71
|
-
return this.request('POST', url, contentType, body);
|
|
72
|
-
}
|
|
73
|
-
put(url, body, contentType) {
|
|
74
|
-
return this.request('PUT', url, contentType, body);
|
|
75
|
-
}
|
|
76
|
-
/**
|
|
77
|
-
* Tries to register a new user.
|
|
78
|
-
* @param request The registration request.
|
|
79
|
-
* @returns Promise to the user profile resource.
|
|
80
|
-
*/
|
|
81
|
-
register(request) {
|
|
82
|
-
return this.post('auth/register', request)
|
|
83
|
-
.then((response) => this.handleLoginResponse(response));
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Tries to sign in with email and password.
|
|
87
|
-
* @param email The user email address.
|
|
88
|
-
* @param password The user password.
|
|
89
|
-
* @param role The login role.
|
|
90
|
-
* @param scope The OAuth2 login scope.
|
|
91
|
-
* @param remember Optional flag to "remember" to generate a refresh token and persist in local storage.
|
|
92
|
-
* @returns Promise to the user profile resource.
|
|
93
|
-
*/
|
|
94
|
-
signIn(email, password, role, scope, remember) {
|
|
95
|
-
return this.post('auth/login', {
|
|
96
|
-
clientId: this.clientId,
|
|
97
|
-
email,
|
|
98
|
-
password,
|
|
99
|
-
role,
|
|
100
|
-
scope,
|
|
101
|
-
remember: !!remember
|
|
102
|
-
}).then((response) => this.handleLoginResponse(response));
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Tries to sign in with Google authentication.
|
|
106
|
-
* The response parameter is the result of a Google authentication.
|
|
107
|
-
* See: https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions
|
|
108
|
-
* @param googleResponse The Google credential response.
|
|
109
|
-
* @returns Promise to the user profile resource.
|
|
110
|
-
*/
|
|
111
|
-
signInWithGoogle(googleResponse) {
|
|
112
|
-
return this.post('auth/google', googleResponse)
|
|
113
|
-
.then((loginResponse) => this.handleLoginResponse(loginResponse));
|
|
114
|
-
}
|
|
115
|
-
/**
|
|
116
|
-
* Handles a login response.
|
|
117
|
-
* This can be used for both "register" and "signIn".
|
|
118
|
-
* @param response The login response.
|
|
119
|
-
* @returns The user profile.
|
|
120
|
-
*/
|
|
121
|
-
handleLoginResponse(response) {
|
|
122
|
-
this.setActiveLogin(response);
|
|
123
|
-
return response.profile;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Signs out locally.
|
|
127
|
-
* Does not invalidate tokens with the server.
|
|
128
|
-
*/
|
|
129
|
-
signOut() {
|
|
130
|
-
this.clear();
|
|
131
|
-
return Promise.resolve();
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Tries to sign in the user.
|
|
135
|
-
* Returns true if the user is signed in.
|
|
136
|
-
* This may result in navigating away to the sign in page.
|
|
137
|
-
*/
|
|
138
|
-
signInWithRedirect() {
|
|
139
|
-
const urlParams = new URLSearchParams(window.location.search);
|
|
140
|
-
const code = urlParams.get('code');
|
|
141
|
-
if (!code) {
|
|
142
|
-
this.requestAuthorization();
|
|
143
|
-
return undefined;
|
|
144
|
-
}
|
|
145
|
-
else {
|
|
146
|
-
return this.processCode(code);
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Tries to sign out the user.
|
|
151
|
-
* See: https://docs.aws.amazon.com/cognito/latest/developerguide/logout-endpoint.html
|
|
152
|
-
*/
|
|
153
|
-
signOutWithRedirect() {
|
|
154
|
-
window.location.assign(this.logoutUrl);
|
|
155
|
-
}
|
|
156
|
-
fhirUrl(...path) {
|
|
157
|
-
const builder = [this.baseUrl, 'fhir/R4'];
|
|
158
|
-
path.forEach(p => builder.push('/', encodeURIComponent(p)));
|
|
159
|
-
return builder.join('');
|
|
160
|
-
}
|
|
161
|
-
search(search) {
|
|
162
|
-
if (typeof search === 'string') {
|
|
163
|
-
return this.get('fhir/R4/' + search);
|
|
164
|
-
}
|
|
165
|
-
else {
|
|
166
|
-
return this.get(this.fhirUrl(search.resourceType) + (0, search_1.formatSearchQuery)(search));
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Searches a ValueSet resource using the "expand" operation.
|
|
171
|
-
* See: https://www.hl7.org/fhir/operation-valueset-expand.html
|
|
172
|
-
* @param system The ValueSet system url.
|
|
173
|
-
* @param filter The search string.
|
|
174
|
-
* @returns Promise to expanded ValueSet.
|
|
175
|
-
*/
|
|
176
|
-
searchValueSet(system, filter) {
|
|
177
|
-
return this.get(this.fhirUrl('ValueSet', '$expand') +
|
|
178
|
-
`?url=${encodeURIComponent(system)}` +
|
|
179
|
-
`&filter=${encodeURIComponent(filter)}`);
|
|
180
|
-
}
|
|
181
|
-
read(resourceType, id) {
|
|
182
|
-
const cacheKey = resourceType + '/' + id;
|
|
183
|
-
const promise = this.get(this.fhirUrl(resourceType, id))
|
|
184
|
-
.then((resource) => {
|
|
185
|
-
this.resourceCache.set(cacheKey, resource);
|
|
186
|
-
return resource;
|
|
187
|
-
});
|
|
188
|
-
this.resourceCache.set(cacheKey, promise);
|
|
189
|
-
return promise;
|
|
190
|
-
}
|
|
191
|
-
readCached(resourceType, id) {
|
|
192
|
-
const cached = this.resourceCache.get(resourceType + '/' + id);
|
|
193
|
-
return cached ? Promise.resolve(cached) : this.read(resourceType, id);
|
|
194
|
-
}
|
|
195
|
-
readReference(reference) {
|
|
196
|
-
const refString = reference?.reference;
|
|
197
|
-
if (!refString) {
|
|
198
|
-
return Promise.reject('Missing reference');
|
|
199
|
-
}
|
|
200
|
-
const [resourceType, id] = refString.split('/');
|
|
201
|
-
return this.read(resourceType, id);
|
|
202
|
-
}
|
|
203
|
-
readCachedReference(reference) {
|
|
204
|
-
const refString = reference?.reference;
|
|
205
|
-
if (!refString) {
|
|
206
|
-
return Promise.reject('Missing reference');
|
|
207
|
-
}
|
|
208
|
-
const [resourceType, id] = refString.split('/');
|
|
209
|
-
return this.readCached(resourceType, id);
|
|
210
|
-
}
|
|
211
|
-
getTypeDefinition(resourceType) {
|
|
212
|
-
if (!resourceType) {
|
|
213
|
-
return Promise.reject('Missing resourceType');
|
|
214
|
-
}
|
|
215
|
-
const cached = this.schema.get(resourceType);
|
|
216
|
-
if (cached) {
|
|
217
|
-
return Promise.resolve(cached);
|
|
218
|
-
}
|
|
219
|
-
let typeDef;
|
|
220
|
-
return this.search('StructureDefinition?name:exact=' + encodeURIComponent(resourceType))
|
|
221
|
-
.then((result) => {
|
|
222
|
-
if (!result.entry?.length) {
|
|
223
|
-
throw new Error('StructureDefinition not found');
|
|
224
|
-
}
|
|
225
|
-
const resource = result.entry[0].resource;
|
|
226
|
-
if (!resource) {
|
|
227
|
-
throw new Error('StructureDefinition not found');
|
|
228
|
-
}
|
|
229
|
-
typeDef = (0, types_1.indexStructureDefinition)(resource);
|
|
230
|
-
})
|
|
231
|
-
.then(() => this.search({
|
|
232
|
-
resourceType: 'SearchParameter',
|
|
233
|
-
count: 100,
|
|
234
|
-
filters: [{
|
|
235
|
-
code: 'base',
|
|
236
|
-
operator: search_1.Operator.EQUALS,
|
|
237
|
-
value: resourceType
|
|
238
|
-
}]
|
|
239
|
-
}))
|
|
240
|
-
.then((result) => {
|
|
241
|
-
const entries = result.entry;
|
|
242
|
-
if (entries) {
|
|
243
|
-
typeDef.types[resourceType].searchParams = entries
|
|
244
|
-
.map(e => e.resource)
|
|
245
|
-
.sort((a, b) => a.name?.localeCompare(b.name) ?? 0);
|
|
246
|
-
}
|
|
247
|
-
this.schema.set(resourceType, typeDef);
|
|
248
|
-
return typeDef;
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
readHistory(resourceType, id) {
|
|
252
|
-
return this.get(this.fhirUrl(resourceType, id, '_history'));
|
|
253
|
-
}
|
|
254
|
-
readPatientEverything(id) {
|
|
255
|
-
return this.get(this.fhirUrl('Patient', id, '$everything'));
|
|
256
|
-
}
|
|
257
|
-
readBlob(url) {
|
|
258
|
-
return this.get(url, true);
|
|
259
|
-
}
|
|
260
|
-
readBlobAsObjectUrl(url) {
|
|
261
|
-
const promise = this.readBlob(url)
|
|
262
|
-
.then(imageBlob => {
|
|
263
|
-
const imageUrl = URL.createObjectURL(imageBlob);
|
|
264
|
-
this.blobUrlCache.set(url, imageUrl);
|
|
265
|
-
return imageUrl;
|
|
266
|
-
});
|
|
267
|
-
this.blobUrlCache.set(url, promise);
|
|
268
|
-
return promise;
|
|
269
|
-
}
|
|
270
|
-
readCachedBlobAsObjectUrl(url) {
|
|
271
|
-
const cached = this.blobUrlCache.get(url);
|
|
272
|
-
return cached ? Promise.resolve(cached) : this.readBlobAsObjectUrl(url);
|
|
273
|
-
}
|
|
274
|
-
readBinary(id) {
|
|
275
|
-
return this.readBlob(this.fhirUrl('Binary', id));
|
|
276
|
-
}
|
|
277
|
-
create(resource) {
|
|
278
|
-
if (!resource.resourceType) {
|
|
279
|
-
throw new Error('Missing resourceType');
|
|
280
|
-
}
|
|
281
|
-
return this.post(this.fhirUrl(resource.resourceType), resource);
|
|
282
|
-
}
|
|
283
|
-
createBinary(data, contentType) {
|
|
284
|
-
return this.post(this.fhirUrl('Binary'), data, contentType);
|
|
285
|
-
}
|
|
286
|
-
update(resource) {
|
|
287
|
-
if (!resource.resourceType) {
|
|
288
|
-
throw new Error('Missing resourceType');
|
|
289
|
-
}
|
|
290
|
-
if (!resource.id) {
|
|
291
|
-
throw new Error('Missing id');
|
|
292
|
-
}
|
|
293
|
-
return this.put(this.fhirUrl(resource.resourceType, resource.id), resource);
|
|
294
|
-
}
|
|
295
|
-
patch(resourceType, id, operations) {
|
|
296
|
-
return this.request('PATCH', this.fhirUrl(resourceType, id), PATCH_CONTENT_TYPE, operations);
|
|
297
|
-
}
|
|
298
|
-
graphql(gql) {
|
|
299
|
-
return this.post(this.fhirUrl('$graphql'), gql, JSON_CONTENT_TYPE);
|
|
300
|
-
}
|
|
301
|
-
subscribe(criteria, handler) {
|
|
302
|
-
return this.create({
|
|
303
|
-
resourceType: 'Subscription',
|
|
304
|
-
status: 'active',
|
|
305
|
-
criteria: criteria,
|
|
306
|
-
channel: {
|
|
307
|
-
type: 'sse'
|
|
308
|
-
}
|
|
309
|
-
}).then((sub) => {
|
|
310
|
-
const eventSource = new EventSource(this.baseUrl + 'sse?subscription=' + encodeURIComponent(sub.id), {
|
|
311
|
-
withCredentials: true
|
|
312
|
-
});
|
|
313
|
-
eventSource.onmessage = (e) => {
|
|
314
|
-
handler(JSON.parse(e.data));
|
|
315
|
-
};
|
|
316
|
-
return eventSource;
|
|
317
|
-
});
|
|
318
|
-
}
|
|
319
|
-
getActiveLogin() {
|
|
320
|
-
if (!this.activeLogin) {
|
|
321
|
-
this.activeLogin = this.storage.getObject('activeLogin');
|
|
322
|
-
}
|
|
323
|
-
return this.activeLogin;
|
|
324
|
-
}
|
|
325
|
-
setActiveLogin(login) {
|
|
326
|
-
this.activeLogin = login;
|
|
327
|
-
this.storage.setObject('activeLogin', login);
|
|
328
|
-
this.addLogin(login);
|
|
329
|
-
this.dispatchEvent({ type: 'change' });
|
|
330
|
-
}
|
|
331
|
-
getLogins() {
|
|
332
|
-
return this.storage.getObject('logins') ?? [];
|
|
333
|
-
}
|
|
334
|
-
addLogin(newLogin) {
|
|
335
|
-
const logins = this.getLogins().filter(login => login.profile?.id !== newLogin.profile?.id);
|
|
336
|
-
logins.push(newLogin);
|
|
337
|
-
this.storage.setObject('logins', logins);
|
|
338
|
-
}
|
|
339
|
-
getProfile() {
|
|
340
|
-
return this.getActiveLogin()?.profile;
|
|
341
|
-
}
|
|
342
|
-
/**
|
|
343
|
-
* Makes an HTTP request.
|
|
344
|
-
* @param {string} method
|
|
345
|
-
* @param {string} url
|
|
346
|
-
* @param {string=} contentType
|
|
347
|
-
* @param {Object=} body
|
|
348
|
-
* @param {boolean=} blob
|
|
349
|
-
*/
|
|
350
|
-
async request(method, url, contentType, body, blob) {
|
|
351
|
-
if (!url.startsWith('http')) {
|
|
352
|
-
url = this.baseUrl + url;
|
|
353
|
-
}
|
|
354
|
-
const headers = {
|
|
355
|
-
'Content-Type': contentType || FHIR_CONTENT_TYPE
|
|
356
|
-
};
|
|
357
|
-
const accessToken = this.getActiveLogin()?.accessToken;
|
|
358
|
-
if (accessToken) {
|
|
359
|
-
headers['Authorization'] = 'Bearer ' + accessToken;
|
|
360
|
-
}
|
|
361
|
-
const options = {
|
|
362
|
-
method: method,
|
|
363
|
-
cache: 'no-cache',
|
|
364
|
-
credentials: 'include',
|
|
365
|
-
headers
|
|
366
|
-
};
|
|
367
|
-
if (body) {
|
|
368
|
-
if (typeof body === 'string' || (typeof File !== 'undefined' && body instanceof File)) {
|
|
369
|
-
options.body = body;
|
|
370
|
-
}
|
|
371
|
-
else {
|
|
372
|
-
options.body = (0, utils_1.stringify)(body);
|
|
373
|
-
}
|
|
374
|
-
}
|
|
375
|
-
const response = await this.fetch(url, options);
|
|
376
|
-
if (response.status === 401) {
|
|
377
|
-
// Refresh and try again
|
|
378
|
-
return this.handleUnauthenticated(method, url, contentType, body, blob);
|
|
379
|
-
}
|
|
380
|
-
if (response.status === 304) {
|
|
381
|
-
// No change
|
|
382
|
-
return undefined;
|
|
383
|
-
}
|
|
384
|
-
const obj = blob ? await response.blob() : await response.json();
|
|
385
|
-
if (obj.resourceType === 'OperationOutcome' && !(0, outcomes_1.isOk)(obj)) {
|
|
386
|
-
return Promise.reject(new outcomes_1.OperationOutcomeError(obj));
|
|
387
|
-
}
|
|
388
|
-
return obj;
|
|
389
|
-
}
|
|
390
|
-
/**
|
|
391
|
-
* Handles an unauthenticated response from the server.
|
|
392
|
-
* First, tries to refresh the access token and retry the request.
|
|
393
|
-
* Otherwise, calls unauthenticated callbacks and rejects.
|
|
394
|
-
* @param method The HTTP method of the original request.
|
|
395
|
-
* @param url The URL of the original request.
|
|
396
|
-
* @param contentType The content type of the original request.
|
|
397
|
-
* @param body The body of the original request.
|
|
398
|
-
* @param blob Optional blob flag of the original request.
|
|
399
|
-
*/
|
|
400
|
-
async handleUnauthenticated(method, url, contentType, body, blob) {
|
|
401
|
-
return this.refresh()
|
|
402
|
-
.then(() => this.request(method, url, contentType, body, blob))
|
|
403
|
-
.catch(error => {
|
|
404
|
-
this.clear();
|
|
405
|
-
if (this.onUnauthenticated) {
|
|
406
|
-
this.onUnauthenticated();
|
|
407
|
-
}
|
|
408
|
-
return Promise.reject(error);
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* Redirects the user to the login screen for authorization.
|
|
413
|
-
* Clears all auth state including local storage and session storage.
|
|
414
|
-
* See: https://openid.net/specs/openid-connect-core-1_0.html#AuthorizationEndpoint
|
|
415
|
-
*/
|
|
416
|
-
async requestAuthorization() {
|
|
417
|
-
if (!this.authorizeUrl) {
|
|
418
|
-
throw new Error('Missing authorize URL');
|
|
419
|
-
}
|
|
420
|
-
this.clear();
|
|
421
|
-
const pkceState = (0, crypto_1.getRandomString)();
|
|
422
|
-
this.storage.setString('pkceState', pkceState);
|
|
423
|
-
const codeVerifier = (0, crypto_1.getRandomString)();
|
|
424
|
-
this.storage.setString('codeVerifier', codeVerifier);
|
|
425
|
-
const arrayHash = await (0, crypto_1.encryptSHA256)(codeVerifier);
|
|
426
|
-
const codeChallenge = (0, utils_1.arrayBufferToBase64)(arrayHash);
|
|
427
|
-
this.storage.setString('codeChallenge', codeChallenge);
|
|
428
|
-
const scope = 'launch/patient openid fhirUser offline_access user/*.*';
|
|
429
|
-
window.location.assign(this.authorizeUrl +
|
|
430
|
-
'?response_type=code' +
|
|
431
|
-
'&state=' + encodeURIComponent(pkceState) +
|
|
432
|
-
'&client_id=' + encodeURIComponent(this.clientId) +
|
|
433
|
-
'&redirect_uri=' + encodeURIComponent(getBaseUrl()) +
|
|
434
|
-
'&scope=' + encodeURIComponent(scope) +
|
|
435
|
-
'&code_challenge_method=S256' +
|
|
436
|
-
'&code_challenge=' + encodeURIComponent(codeChallenge));
|
|
437
|
-
}
|
|
438
|
-
/**
|
|
439
|
-
* Processes an OAuth authorization code.
|
|
440
|
-
* See: https://openid.net/specs/openid-connect-core-1_0.html#TokenRequest
|
|
441
|
-
* @param code The authorization code received by URL parameter.
|
|
442
|
-
*/
|
|
443
|
-
processCode(code) {
|
|
444
|
-
const pkceState = this.storage.getString('pkceState');
|
|
445
|
-
if (!pkceState) {
|
|
446
|
-
this.clear();
|
|
447
|
-
throw new Error('Invalid PCKE state');
|
|
448
|
-
}
|
|
449
|
-
const codeVerifier = this.storage.getString('codeVerifier');
|
|
450
|
-
if (!codeVerifier) {
|
|
451
|
-
this.clear();
|
|
452
|
-
throw new Error('Invalid PCKE code verifier');
|
|
453
|
-
}
|
|
454
|
-
return this.fetchTokens('grant_type=authorization_code' +
|
|
455
|
-
'&client_id=' + encodeURIComponent(this.clientId) +
|
|
456
|
-
'&code_verifier=' + encodeURIComponent(codeVerifier) +
|
|
457
|
-
'&redirect_uri=' + encodeURIComponent(getBaseUrl()) +
|
|
458
|
-
'&code=' + encodeURIComponent(code));
|
|
459
|
-
}
|
|
460
|
-
/**
|
|
461
|
-
* Tries to refresh the auth tokens.
|
|
462
|
-
* See: https://openid.net/specs/openid-connect-core-1_0.html#RefreshTokens
|
|
463
|
-
*/
|
|
464
|
-
async refresh() {
|
|
465
|
-
const refreshToken = this.getActiveLogin()?.refreshToken;
|
|
466
|
-
if (!refreshToken) {
|
|
467
|
-
this.clear();
|
|
468
|
-
return Promise.reject('Invalid refresh token');
|
|
469
|
-
}
|
|
470
|
-
await this.fetchTokens('grant_type=refresh_token' +
|
|
471
|
-
'&client_id=' + encodeURIComponent(this.clientId) +
|
|
472
|
-
'&refresh_token=' + encodeURIComponent(refreshToken));
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* Makes a POST request to the tokens endpoint.
|
|
476
|
-
* See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint
|
|
477
|
-
* @param formBody Token parameters in URL encoded format.
|
|
478
|
-
*/
|
|
479
|
-
async fetchTokens(formBody) {
|
|
480
|
-
if (!this.tokenUrl) {
|
|
481
|
-
throw new Error('Missing token URL');
|
|
482
|
-
}
|
|
483
|
-
return this.fetch(this.tokenUrl, {
|
|
484
|
-
method: 'POST',
|
|
485
|
-
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
486
|
-
body: formBody
|
|
487
|
-
})
|
|
488
|
-
.then(response => {
|
|
489
|
-
if (!response.ok) {
|
|
490
|
-
return Promise.reject('Failed to fetch tokens');
|
|
491
|
-
}
|
|
492
|
-
return response.json();
|
|
493
|
-
})
|
|
494
|
-
.then(tokens => this.verifyTokens(tokens))
|
|
495
|
-
.then(() => this.getActiveLogin()?.profile);
|
|
496
|
-
}
|
|
497
|
-
/**
|
|
498
|
-
* Verifies the tokens received from the auth server.
|
|
499
|
-
* Validates the JWT against the JWKS.
|
|
500
|
-
* See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint
|
|
501
|
-
* @param tokens
|
|
502
|
-
*/
|
|
503
|
-
async verifyTokens(tokens) {
|
|
504
|
-
const token = tokens.access_token;
|
|
505
|
-
// Verify token has not expired
|
|
506
|
-
const tokenPayload = (0, jwt_1.parseJWTPayload)(token);
|
|
507
|
-
if (Date.now() >= tokenPayload.exp * 1000) {
|
|
508
|
-
this.clear();
|
|
509
|
-
return Promise.reject('Token expired');
|
|
510
|
-
}
|
|
511
|
-
// Verify app_client_id
|
|
512
|
-
if (tokenPayload.client_id !== this.clientId) {
|
|
513
|
-
this.clear();
|
|
514
|
-
return Promise.reject('Token was not issued for this audience');
|
|
515
|
-
}
|
|
516
|
-
this.setActiveLogin({
|
|
517
|
-
...this.getActiveLogin(),
|
|
518
|
-
accessToken: token,
|
|
519
|
-
refreshToken: tokens.refresh_token
|
|
520
|
-
});
|
|
521
|
-
}
|
|
522
|
-
}
|
|
523
|
-
exports.MedplumClient = MedplumClient;
|
|
524
|
-
/**
|
|
525
|
-
* Returns the base URL for the current page.
|
|
526
|
-
*/
|
|
527
|
-
function getBaseUrl() {
|
|
528
|
-
return window.location.protocol + '//' + window.location.host + '/';
|
|
529
|
-
}
|
|
530
|
-
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
DELETED
|
@@ -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,SAAQ,yBAAW;IAC3B,KAAK,CAAY;IACjB,OAAO,CAAgB;IACvB,MAAM,CAA0C;IAChD,aAAa,CAAyC;IACtD,YAAY,CAAqC;IACjD,OAAO,CAAS;IAChB,QAAQ,CAAS;IACjB,YAAY,CAAS;IACrB,QAAQ,CAAS;IACjB,SAAS,CAAS;IAClB,iBAAiB,CAAc;IACxC,WAAW,CAAiB;IAEpC,YAAY,OAA6B;QACvC,KAAK,EAAE,CAAC;QAER,IAAI,OAAO,CAAC,OAAO,EAAE;YACnB,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;gBACvC,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;aAC3D;YACD,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;gBAClC,MA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AM,KAAK,GAAG,MAAM,CAAC,YAAY,CAAC;QAElC,+BAA+B;QAC/B,MAAM,YAAY,GAAG,IAAA,qBAAe,EAAC,KAAK,CAAC,CAAC;QAC5C,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,YAAY,CAAC,GAAG,GAAG,IAAI,EAAE;YACzC,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,OAAO,OAAO,CAAC,MAAM,CAAC,eAAe,CAAC,CAAC;SACxC;QAED,uBAAuB;QACvB,IAAI,YAAY,CAAC,SAAS,KAAK,IAAI,CAAC,QAAQ,EAAE;YAC5C,IAAI,CAAC,KAAK,EAAE,CAAC;YACb,OAAO,OAAO,CAAC,MAAM,CAAC,wCAAwC,CAAC,CAAC;SACjE;QAED,IAAI,CAAC,cAAc,CAAC;YAClB,GAAI,IAAI,CAAC,cAAc,EAAoB;YAC3C,WAAW,EAAE,KAAK;YAClB,YAAY,EAAE,MAAM,CAAC,aAAa;SACnC,CAAC,CAAC;IACL,CAAC;CACF;AA7kBD,sCA6kBC;AAED;;GAEG;AACH,SAAS,UAAU;IACjB,OAAO,MAAM,CAAC,QAAQ,CAAC,QAAQ,GAAG,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/client.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|