@medplum/core 0.1.6 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -25
- package/dist/cache.d.ts +1 -0
- package/dist/cache.js +3 -2
- package/dist/cache.js.map +1 -1
- package/dist/client.d.ts +72 -54
- package/dist/client.js +267 -223
- package/dist/client.js.map +1 -1
- package/dist/crypto.js +13 -2
- package/dist/crypto.js.map +1 -1
- package/dist/eventtarget.js +1 -2
- package/dist/eventtarget.js.map +1 -1
- package/dist/format.d.ts +1 -1
- package/dist/format.js +4 -4
- package/dist/format.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/jwt.js.map +1 -1
- package/dist/outcomes.d.ts +4 -1
- package/dist/outcomes.js +71 -24
- package/dist/outcomes.js.map +1 -1
- package/dist/search.js +7 -9
- package/dist/search.js.map +1 -1
- package/dist/searchparams.d.ts +34 -0
- package/dist/searchparams.js +128 -0
- package/dist/searchparams.js.map +1 -0
- package/dist/storage.d.ts +36 -12
- package/dist/storage.js +55 -22
- package/dist/storage.js.map +1 -1
- package/dist/types.d.ts +3 -5
- package/dist/types.js +32 -18
- package/dist/types.js.map +1 -1
- package/dist/utils.d.ts +14 -3
- package/dist/utils.js +57 -12
- package/dist/utils.js.map +1 -1
- package/package.json +3 -16
- 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.test.d.ts +0 -1
- package/dist/client.test.js +0 -294
- package/dist/client.test.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/Account.d.ts +0 -240
- package/dist/fhir/Account.js +0 -7
- package/dist/fhir/Account.js.map +0 -1
- package/dist/fhir/ActivityDefinition.d.ts +0 -494
- package/dist/fhir/ActivityDefinition.js +0 -7
- package/dist/fhir/ActivityDefinition.js.map +0 -1
- package/dist/fhir/Address.d.ts +0 -74
- package/dist/fhir/Address.js +0 -7
- package/dist/fhir/Address.js.map +0 -1
- package/dist/fhir/AdverseEvent.d.ts +0 -287
- 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 -278
- package/dist/fhir/AllergyIntolerance.js +0 -7
- package/dist/fhir/AllergyIntolerance.js.map +0 -1
- package/dist/fhir/Annotation.d.ts +0 -38
- package/dist/fhir/Annotation.js +0 -7
- package/dist/fhir/Annotation.js.map +0 -1
- package/dist/fhir/Appointment.d.ts +0 -273
- package/dist/fhir/Appointment.js +0 -7
- package/dist/fhir/Appointment.js.map +0 -1
- package/dist/fhir/AppointmentResponse.d.ts +0 -123
- package/dist/fhir/AppointmentResponse.js +0 -7
- package/dist/fhir/AppointmentResponse.js.map +0 -1
- package/dist/fhir/Attachment.d.ts +0 -57
- 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 -105
- package/dist/fhir/Basic.js +0 -7
- package/dist/fhir/Basic.js.map +0 -1
- package/dist/fhir/Binary.d.ts +0 -58
- package/dist/fhir/Binary.js +0 -7
- package/dist/fhir/Binary.js.map +0 -1
- package/dist/fhir/BiologicallyDerivedProduct.d.ts +0 -356
- package/dist/fhir/BiologicallyDerivedProduct.js +0 -7
- package/dist/fhir/BiologicallyDerivedProduct.js.map +0 -1
- package/dist/fhir/BodyStructure.d.ts +0 -118
- package/dist/fhir/BodyStructure.js +0 -7
- package/dist/fhir/BodyStructure.js.map +0 -1
- package/dist/fhir/Bundle.d.ts +0 -373
- package/dist/fhir/Bundle.js +0 -7
- package/dist/fhir/Bundle.js.map +0 -1
- package/dist/fhir/CapabilityStatement.d.ts +0 -1068
- package/dist/fhir/CapabilityStatement.js +0 -7
- package/dist/fhir/CapabilityStatement.js.map +0 -1
- package/dist/fhir/CarePlan.d.ts +0 -421
- package/dist/fhir/CarePlan.js +0 -7
- package/dist/fhir/CarePlan.js.map +0 -1
- package/dist/fhir/CareTeam.d.ts +0 -203
- package/dist/fhir/CareTeam.js +0 -7
- package/dist/fhir/CareTeam.js.map +0 -1
- package/dist/fhir/CatalogEntry.d.ts +0 -184
- package/dist/fhir/CatalogEntry.js +0 -7
- package/dist/fhir/CatalogEntry.js.map +0 -1
- package/dist/fhir/ChargeItem.d.ts +0 -270
- package/dist/fhir/ChargeItem.js +0 -7
- package/dist/fhir/ChargeItem.js.map +0 -1
- package/dist/fhir/ChargeItemDefinition.d.ts +0 -402
- package/dist/fhir/ChargeItemDefinition.js +0 -7
- package/dist/fhir/ChargeItemDefinition.js.map +0 -1
- package/dist/fhir/Claim.d.ts +0 -1089
- package/dist/fhir/Claim.js +0 -7
- package/dist/fhir/Claim.js.map +0 -1
- package/dist/fhir/ClaimResponse.d.ts +0 -1037
- package/dist/fhir/ClaimResponse.js +0 -7
- package/dist/fhir/ClaimResponse.js.map +0 -1
- package/dist/fhir/ClientApplication.d.ts +0 -54
- package/dist/fhir/ClientApplication.js +0 -7
- package/dist/fhir/ClientApplication.js.map +0 -1
- package/dist/fhir/ClinicalImpression.d.ts +0 -301
- package/dist/fhir/ClinicalImpression.js +0 -7
- package/dist/fhir/ClinicalImpression.js.map +0 -1
- package/dist/fhir/CodeSystem.d.ts +0 -546
- package/dist/fhir/CodeSystem.js +0 -7
- package/dist/fhir/CodeSystem.js.map +0 -1
- package/dist/fhir/CodeableConcept.d.ts +0 -32
- package/dist/fhir/CodeableConcept.js +0 -7
- package/dist/fhir/CodeableConcept.js.map +0 -1
- package/dist/fhir/Coding.d.ts +0 -49
- package/dist/fhir/Coding.js +0 -7
- package/dist/fhir/Coding.js.map +0 -1
- package/dist/fhir/Communication.d.ts +0 -251
- package/dist/fhir/Communication.js +0 -7
- package/dist/fhir/Communication.js.map +0 -1
- package/dist/fhir/CommunicationRequest.d.ts +0 -248
- package/dist/fhir/CommunicationRequest.js +0 -7
- package/dist/fhir/CommunicationRequest.js.map +0 -1
- package/dist/fhir/CompartmentDefinition.d.ts +0 -218
- package/dist/fhir/CompartmentDefinition.js +0 -7
- package/dist/fhir/CompartmentDefinition.js.map +0 -1
- package/dist/fhir/Composition.d.ts +0 -455
- package/dist/fhir/Composition.js +0 -7
- package/dist/fhir/Composition.js.map +0 -1
- package/dist/fhir/ConceptMap.d.ts +0 -523
- package/dist/fhir/ConceptMap.js +0 -7
- package/dist/fhir/ConceptMap.js.map +0 -1
- package/dist/fhir/Condition.d.ts +0 -316
- package/dist/fhir/Condition.js +0 -7
- package/dist/fhir/Condition.js.map +0 -1
- package/dist/fhir/Consent.d.ts +0 -457
- package/dist/fhir/Consent.js +0 -7
- package/dist/fhir/Consent.js.map +0 -1
- package/dist/fhir/ContactDetail.d.ts +0 -30
- package/dist/fhir/ContactDetail.js +0 -7
- package/dist/fhir/ContactDetail.js.map +0 -1
- package/dist/fhir/ContactPoint.d.ts +0 -46
- package/dist/fhir/ContactPoint.js +0 -7
- package/dist/fhir/ContactPoint.js.map +0 -1
- package/dist/fhir/Contract.d.ts +0 -1431
- package/dist/fhir/Contract.js +0 -7
- package/dist/fhir/Contract.js.map +0 -1
- package/dist/fhir/Contributor.d.ts +0 -36
- 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 -323
- package/dist/fhir/Coverage.js +0 -7
- package/dist/fhir/Coverage.js.map +0 -1
- package/dist/fhir/CoverageEligibilityRequest.d.ts +0 -409
- package/dist/fhir/CoverageEligibilityRequest.js +0 -7
- package/dist/fhir/CoverageEligibilityRequest.js.map +0 -1
- package/dist/fhir/CoverageEligibilityResponse.d.ts +0 -430
- package/dist/fhir/CoverageEligibilityResponse.js +0 -7
- package/dist/fhir/CoverageEligibilityResponse.js.map +0 -1
- package/dist/fhir/DataRequirement.d.ts +0 -288
- package/dist/fhir/DataRequirement.js +0 -7
- package/dist/fhir/DataRequirement.js.map +0 -1
- package/dist/fhir/DetectedIssue.d.ts +0 -249
- package/dist/fhir/DetectedIssue.js +0 -7
- package/dist/fhir/DetectedIssue.js.map +0 -1
- package/dist/fhir/Device.d.ts +0 -488
- package/dist/fhir/Device.js +0 -7
- package/dist/fhir/Device.js.map +0 -1
- package/dist/fhir/DeviceDefinition.d.ts +0 -484
- package/dist/fhir/DeviceDefinition.js +0 -7
- package/dist/fhir/DeviceDefinition.js.map +0 -1
- package/dist/fhir/DeviceMetric.d.ts +0 -198
- package/dist/fhir/DeviceMetric.js +0 -7
- package/dist/fhir/DeviceMetric.js.map +0 -1
- package/dist/fhir/DeviceRequest.d.ts +0 -279
- package/dist/fhir/DeviceRequest.js +0 -7
- package/dist/fhir/DeviceRequest.js.map +0 -1
- package/dist/fhir/DeviceUseStatement.d.ts +0 -153
- package/dist/fhir/DeviceUseStatement.js +0 -7
- package/dist/fhir/DeviceUseStatement.js.map +0 -1
- package/dist/fhir/DiagnosticReport.d.ts +0 -239
- package/dist/fhir/DiagnosticReport.js +0 -7
- package/dist/fhir/DiagnosticReport.js.map +0 -1
- package/dist/fhir/Distance.d.ts +0 -46
- package/dist/fhir/Distance.js +0 -7
- package/dist/fhir/Distance.js.map +0 -1
- package/dist/fhir/DocumentManifest.d.ts +0 -190
- package/dist/fhir/DocumentManifest.js +0 -7
- package/dist/fhir/DocumentManifest.js.map +0 -1
- package/dist/fhir/DocumentReference.d.ts +0 -353
- package/dist/fhir/DocumentReference.js +0 -7
- package/dist/fhir/DocumentReference.js.map +0 -1
- package/dist/fhir/Dosage.d.ts +0 -171
- 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 -600
- package/dist/fhir/EffectEvidenceSynthesis.js +0 -7
- package/dist/fhir/EffectEvidenceSynthesis.js.map +0 -1
- package/dist/fhir/Element.d.ts +0 -20
- package/dist/fhir/Element.js +0 -7
- package/dist/fhir/Element.js.map +0 -1
- package/dist/fhir/ElementDefinition.d.ts +0 -2828
- package/dist/fhir/ElementDefinition.js +0 -7
- package/dist/fhir/ElementDefinition.js.map +0 -1
- package/dist/fhir/Encounter.d.ts +0 -546
- package/dist/fhir/Encounter.js +0 -7
- package/dist/fhir/Encounter.js.map +0 -1
- package/dist/fhir/Endpoint.d.ts +0 -139
- package/dist/fhir/Endpoint.js +0 -7
- package/dist/fhir/Endpoint.js.map +0 -1
- package/dist/fhir/EnrollmentRequest.d.ts +0 -108
- package/dist/fhir/EnrollmentRequest.js +0 -7
- package/dist/fhir/EnrollmentRequest.js.map +0 -1
- package/dist/fhir/EnrollmentResponse.d.ts +0 -113
- package/dist/fhir/EnrollmentResponse.js +0 -7
- package/dist/fhir/EnrollmentResponse.js.map +0 -1
- package/dist/fhir/EpisodeOfCare.d.ts +0 -243
- package/dist/fhir/EpisodeOfCare.js +0 -7
- package/dist/fhir/EpisodeOfCare.js.map +0 -1
- package/dist/fhir/EventDefinition.d.ts +0 -252
- package/dist/fhir/EventDefinition.js +0 -7
- package/dist/fhir/EventDefinition.js.map +0 -1
- package/dist/fhir/Evidence.d.ts +0 -251
- package/dist/fhir/Evidence.js +0 -7
- package/dist/fhir/Evidence.js.map +0 -1
- package/dist/fhir/EvidenceVariable.d.ts +0 -369
- package/dist/fhir/EvidenceVariable.js +0 -7
- package/dist/fhir/EvidenceVariable.js.map +0 -1
- package/dist/fhir/ExampleScenario.d.ts +0 -626
- package/dist/fhir/ExampleScenario.js +0 -7
- package/dist/fhir/ExampleScenario.js.map +0 -1
- package/dist/fhir/ExplanationOfBenefit.d.ts +0 -1854
- 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 -305
- package/dist/fhir/Extension.js +0 -7
- package/dist/fhir/Extension.js.map +0 -1
- package/dist/fhir/FamilyMemberHistory.d.ts +0 -297
- package/dist/fhir/FamilyMemberHistory.js +0 -7
- package/dist/fhir/FamilyMemberHistory.js.map +0 -1
- package/dist/fhir/Flag.d.ts +0 -121
- package/dist/fhir/Flag.js +0 -7
- package/dist/fhir/Flag.js.map +0 -1
- package/dist/fhir/Goal.d.ts +0 -290
- package/dist/fhir/Goal.js +0 -7
- package/dist/fhir/Goal.js.map +0 -1
- package/dist/fhir/GraphDefinition.d.ts +0 -359
- package/dist/fhir/GraphDefinition.js +0 -7
- package/dist/fhir/GraphDefinition.js.map +0 -1
- package/dist/fhir/Group.d.ts +0 -268
- package/dist/fhir/Group.js +0 -7
- package/dist/fhir/Group.js.map +0 -1
- package/dist/fhir/GuidanceResponse.d.ts +0 -184
- package/dist/fhir/GuidanceResponse.js +0 -7
- package/dist/fhir/GuidanceResponse.js.map +0 -1
- package/dist/fhir/HealthcareService.d.ts +0 -351
- package/dist/fhir/HealthcareService.js +0 -7
- package/dist/fhir/HealthcareService.js.map +0 -1
- package/dist/fhir/HumanName.d.ts +0 -57
- package/dist/fhir/HumanName.js +0 -7
- package/dist/fhir/HumanName.js.map +0 -1
- package/dist/fhir/Identifier.d.ts +0 -51
- package/dist/fhir/Identifier.js +0 -7
- package/dist/fhir/Identifier.js.map +0 -1
- package/dist/fhir/ImagingStudy.d.ts +0 -398
- package/dist/fhir/ImagingStudy.js +0 -7
- package/dist/fhir/ImagingStudy.js.map +0 -1
- package/dist/fhir/Immunization.d.ts +0 -440
- package/dist/fhir/Immunization.js +0 -7
- package/dist/fhir/Immunization.js.map +0 -1
- package/dist/fhir/ImmunizationEvaluation.d.ts +0 -146
- package/dist/fhir/ImmunizationEvaluation.js +0 -7
- package/dist/fhir/ImmunizationEvaluation.js.map +0 -1
- package/dist/fhir/ImmunizationRecommendation.d.ts +0 -253
- package/dist/fhir/ImmunizationRecommendation.js +0 -7
- package/dist/fhir/ImmunizationRecommendation.js.map +0 -1
- package/dist/fhir/ImplementationGuide.d.ts +0 -854
- package/dist/fhir/ImplementationGuide.js +0 -7
- package/dist/fhir/ImplementationGuide.js.map +0 -1
- package/dist/fhir/InsurancePlan.d.ts +0 -630
- package/dist/fhir/InsurancePlan.js +0 -7
- package/dist/fhir/InsurancePlan.js.map +0 -1
- package/dist/fhir/Invoice.d.ts +0 -331
- 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 -276
- package/dist/fhir/Library.js +0 -7
- package/dist/fhir/Library.js.map +0 -1
- package/dist/fhir/Linkage.d.ts +0 -142
- package/dist/fhir/Linkage.js +0 -7
- package/dist/fhir/Linkage.js.map +0 -1
- package/dist/fhir/List.d.ts +0 -193
- package/dist/fhir/List.js +0 -7
- package/dist/fhir/List.js.map +0 -1
- package/dist/fhir/Location.d.ts +0 -278
- package/dist/fhir/Location.js +0 -7
- package/dist/fhir/Location.js.map +0 -1
- package/dist/fhir/Login.d.ts +0 -108
- 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 -613
- package/dist/fhir/Measure.js +0 -7
- package/dist/fhir/Measure.js.map +0 -1
- package/dist/fhir/MeasureReport.d.ts +0 -460
- package/dist/fhir/MeasureReport.js +0 -7
- package/dist/fhir/MeasureReport.js.map +0 -1
- package/dist/fhir/Media.d.ts +0 -191
- package/dist/fhir/Media.js +0 -7
- package/dist/fhir/Media.js.map +0 -1
- package/dist/fhir/Medication.d.ts +0 -234
- package/dist/fhir/Medication.js +0 -7
- package/dist/fhir/Medication.js.map +0 -1
- package/dist/fhir/MedicationAdministration.d.ts +0 -343
- package/dist/fhir/MedicationAdministration.js +0 -7
- package/dist/fhir/MedicationAdministration.js.map +0 -1
- package/dist/fhir/MedicationDispense.d.ts +0 -332
- package/dist/fhir/MedicationDispense.js +0 -7
- package/dist/fhir/MedicationDispense.js.map +0 -1
- package/dist/fhir/MedicationKnowledge.d.ts +0 -979
- package/dist/fhir/MedicationKnowledge.js +0 -7
- package/dist/fhir/MedicationKnowledge.js.map +0 -1
- package/dist/fhir/MedicationRequest.d.ts +0 -468
- package/dist/fhir/MedicationRequest.js +0 -7
- package/dist/fhir/MedicationRequest.js.map +0 -1
- package/dist/fhir/MedicationStatement.d.ts +0 -210
- package/dist/fhir/MedicationStatement.js +0 -7
- package/dist/fhir/MedicationStatement.js.map +0 -1
- package/dist/fhir/MedicinalProduct.d.ts +0 -449
- package/dist/fhir/MedicinalProduct.js +0 -7
- package/dist/fhir/MedicinalProduct.js.map +0 -1
- package/dist/fhir/MedicinalProductAuthorization.d.ts +0 -267
- package/dist/fhir/MedicinalProductAuthorization.js +0 -7
- package/dist/fhir/MedicinalProductAuthorization.js.map +0 -1
- package/dist/fhir/MedicinalProductContraindication.d.ts +0 -165
- package/dist/fhir/MedicinalProductContraindication.js +0 -7
- package/dist/fhir/MedicinalProductContraindication.js.map +0 -1
- package/dist/fhir/MedicinalProductIndication.d.ts +0 -173
- package/dist/fhir/MedicinalProductIndication.js +0 -7
- package/dist/fhir/MedicinalProductIndication.js.map +0 -1
- package/dist/fhir/MedicinalProductIngredient.d.ts +0 -334
- package/dist/fhir/MedicinalProductIngredient.js +0 -7
- package/dist/fhir/MedicinalProductIngredient.js.map +0 -1
- package/dist/fhir/MedicinalProductInteraction.d.ts +0 -155
- package/dist/fhir/MedicinalProductInteraction.js +0 -7
- package/dist/fhir/MedicinalProductInteraction.js.map +0 -1
- package/dist/fhir/MedicinalProductManufactured.d.ts +0 -111
- package/dist/fhir/MedicinalProductManufactured.js +0 -7
- package/dist/fhir/MedicinalProductManufactured.js.map +0 -1
- package/dist/fhir/MedicinalProductPackaged.d.ts +0 -253
- 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 -99
- package/dist/fhir/MedicinalProductUndesirableEffect.js +0 -7
- package/dist/fhir/MedicinalProductUndesirableEffect.js.map +0 -1
- package/dist/fhir/MessageDefinition.d.ts +0 -331
- package/dist/fhir/MessageDefinition.js +0 -7
- package/dist/fhir/MessageDefinition.js.map +0 -1
- package/dist/fhir/MessageHeader.d.ts +0 -329
- package/dist/fhir/MessageHeader.js +0 -7
- package/dist/fhir/MessageHeader.js.map +0 -1
- package/dist/fhir/Meta.d.ts +0 -68
- package/dist/fhir/Meta.js +0 -7
- package/dist/fhir/Meta.js.map +0 -1
- package/dist/fhir/MolecularSequence.d.ts +0 -746
- package/dist/fhir/MolecularSequence.js +0 -7
- package/dist/fhir/MolecularSequence.js.map +0 -1
- package/dist/fhir/Money.d.ts +0 -28
- package/dist/fhir/Money.js +0 -7
- package/dist/fhir/Money.js.map +0 -1
- package/dist/fhir/NamingSystem.d.ts +0 -219
- package/dist/fhir/NamingSystem.js +0 -7
- package/dist/fhir/NamingSystem.js.map +0 -1
- package/dist/fhir/Narrative.d.ts +0 -31
- package/dist/fhir/Narrative.js +0 -7
- package/dist/fhir/Narrative.js.map +0 -1
- package/dist/fhir/NutritionOrder.d.ts +0 -558
- package/dist/fhir/NutritionOrder.js +0 -7
- package/dist/fhir/NutritionOrder.js.map +0 -1
- package/dist/fhir/Observation.d.ts +0 -487
- package/dist/fhir/Observation.js +0 -7
- package/dist/fhir/Observation.js.map +0 -1
- package/dist/fhir/ObservationDefinition.d.ts +0 -277
- 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 -168
- package/dist/fhir/OperationOutcome.js +0 -7
- package/dist/fhir/OperationOutcome.js.map +0 -1
- package/dist/fhir/Organization.d.ts +0 -187
- package/dist/fhir/Organization.js +0 -7
- package/dist/fhir/Organization.js.map +0 -1
- package/dist/fhir/OrganizationAffiliation.d.ts +0 -141
- package/dist/fhir/OrganizationAffiliation.js +0 -7
- package/dist/fhir/OrganizationAffiliation.js.map +0 -1
- package/dist/fhir/ParameterDefinition.d.ts +0 -56
- package/dist/fhir/ParameterDefinition.js +0 -7
- package/dist/fhir/ParameterDefinition.js.map +0 -1
- package/dist/fhir/Parameters.d.ts +0 -321
- package/dist/fhir/Parameters.js +0 -7
- package/dist/fhir/Parameters.js.map +0 -1
- package/dist/fhir/PasswordChangeRequest.d.ts +0 -50
- package/dist/fhir/PasswordChangeRequest.js +0 -7
- package/dist/fhir/PasswordChangeRequest.js.map +0 -1
- package/dist/fhir/Patient.d.ts +0 -339
- package/dist/fhir/Patient.js +0 -7
- package/dist/fhir/Patient.js.map +0 -1
- package/dist/fhir/PaymentNotice.d.ts +0 -131
- package/dist/fhir/PaymentNotice.js +0 -7
- package/dist/fhir/PaymentNotice.js.map +0 -1
- package/dist/fhir/PaymentReconciliation.d.ts +0 -276
- package/dist/fhir/PaymentReconciliation.js +0 -7
- package/dist/fhir/PaymentReconciliation.js.map +0 -1
- package/dist/fhir/Period.d.ts +0 -31
- package/dist/fhir/Period.js +0 -7
- package/dist/fhir/Period.js.map +0 -1
- package/dist/fhir/Person.d.ts +0 -172
- package/dist/fhir/Person.js +0 -7
- package/dist/fhir/Person.js.map +0 -1
- package/dist/fhir/PlanDefinition.d.ts +0 -855
- package/dist/fhir/PlanDefinition.js +0 -7
- package/dist/fhir/PlanDefinition.js.map +0 -1
- package/dist/fhir/Population.d.ts +0 -61
- package/dist/fhir/Population.js +0 -7
- package/dist/fhir/Population.js.map +0 -1
- package/dist/fhir/Practitioner.d.ts +0 -188
- package/dist/fhir/Practitioner.js +0 -7
- package/dist/fhir/Practitioner.js.map +0 -1
- package/dist/fhir/PractitionerRole.d.ts +0 -254
- package/dist/fhir/PractitionerRole.js +0 -7
- package/dist/fhir/PractitionerRole.js.map +0 -1
- package/dist/fhir/Procedure.d.ts +0 -355
- 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 -69
- package/dist/fhir/ProductShelfLife.js +0 -7
- package/dist/fhir/ProductShelfLife.js.map +0 -1
- package/dist/fhir/Project.d.ts +0 -46
- package/dist/fhir/Project.js +0 -7
- package/dist/fhir/Project.js.map +0 -1
- package/dist/fhir/ProjectMembership.d.ts +0 -54
- package/dist/fhir/ProjectMembership.js +0 -7
- package/dist/fhir/ProjectMembership.js.map +0 -1
- package/dist/fhir/Provenance.d.ts +0 -270
- package/dist/fhir/Provenance.js +0 -7
- package/dist/fhir/Provenance.js.map +0 -1
- package/dist/fhir/Quantity.d.ts +0 -49
- package/dist/fhir/Quantity.js +0 -7
- package/dist/fhir/Quantity.js.map +0 -1
- package/dist/fhir/Questionnaire.d.ts +0 -610
- package/dist/fhir/Questionnaire.js +0 -7
- package/dist/fhir/Questionnaire.js.map +0 -1
- package/dist/fhir/QuestionnaireResponse.d.ts +0 -305
- package/dist/fhir/QuestionnaireResponse.js +0 -7
- package/dist/fhir/QuestionnaireResponse.js.map +0 -1
- package/dist/fhir/Range.d.ts +0 -29
- 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 -66
- 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 -56
- 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 -427
- package/dist/fhir/RequestGroup.js +0 -7
- package/dist/fhir/RequestGroup.js.map +0 -1
- package/dist/fhir/ResearchDefinition.d.ts +0 -289
- package/dist/fhir/ResearchDefinition.js +0 -7
- package/dist/fhir/ResearchDefinition.js.map +0 -1
- package/dist/fhir/ResearchElementDefinition.d.ts +0 -430
- package/dist/fhir/ResearchElementDefinition.js +0 -7
- package/dist/fhir/ResearchElementDefinition.js.map +0 -1
- package/dist/fhir/ResearchStudy.d.ts +0 -320
- package/dist/fhir/ResearchStudy.js +0 -7
- package/dist/fhir/ResearchStudy.js.map +0 -1
- package/dist/fhir/ResearchSubject.d.ts +0 -116
- package/dist/fhir/ResearchSubject.js +0 -7
- package/dist/fhir/ResearchSubject.js.map +0 -1
- package/dist/fhir/Resource.d.ts +0 -154
- package/dist/fhir/Resource.js +0 -7
- package/dist/fhir/Resource.js.map +0 -1
- package/dist/fhir/RiskAssessment.d.ts +0 -237
- package/dist/fhir/RiskAssessment.js +0 -7
- package/dist/fhir/RiskAssessment.js.map +0 -1
- package/dist/fhir/RiskEvidenceSynthesis.d.ts +0 -539
- package/dist/fhir/RiskEvidenceSynthesis.js +0 -7
- package/dist/fhir/RiskEvidenceSynthesis.js.map +0 -1
- package/dist/fhir/SampledData.d.ts +0 -61
- package/dist/fhir/SampledData.js +0 -7
- package/dist/fhir/SampledData.js.map +0 -1
- package/dist/fhir/Schedule.d.ts +0 -122
- package/dist/fhir/Schedule.js +0 -7
- package/dist/fhir/Schedule.js.map +0 -1
- package/dist/fhir/SearchParameter.d.ts +0 -278
- package/dist/fhir/SearchParameter.js +0 -7
- package/dist/fhir/SearchParameter.js.map +0 -1
- package/dist/fhir/ServiceRequest.d.ts +0 -288
- package/dist/fhir/ServiceRequest.js +0 -7
- package/dist/fhir/ServiceRequest.js.map +0 -1
- package/dist/fhir/Signature.d.ts +0 -65
- package/dist/fhir/Signature.js +0 -7
- package/dist/fhir/Signature.js.map +0 -1
- package/dist/fhir/Slot.d.ts +0 -133
- package/dist/fhir/Slot.js +0 -7
- package/dist/fhir/Slot.js.map +0 -1
- package/dist/fhir/Specimen.d.ts +0 -357
- package/dist/fhir/Specimen.js +0 -7
- package/dist/fhir/Specimen.js.map +0 -1
- package/dist/fhir/SpecimenDefinition.d.ts +0 -359
- package/dist/fhir/SpecimenDefinition.js +0 -7
- package/dist/fhir/SpecimenDefinition.js.map +0 -1
- package/dist/fhir/StructureDefinition.d.ts +0 -443
- package/dist/fhir/StructureDefinition.js +0 -7
- package/dist/fhir/StructureDefinition.js.map +0 -1
- package/dist/fhir/StructureMap.d.ts +0 -908
- package/dist/fhir/StructureMap.js +0 -7
- package/dist/fhir/StructureMap.js.map +0 -1
- package/dist/fhir/Subscription.d.ts +0 -176
- package/dist/fhir/Subscription.js +0 -7
- package/dist/fhir/Subscription.js.map +0 -1
- package/dist/fhir/Substance.d.ts +0 -212
- package/dist/fhir/Substance.js +0 -7
- package/dist/fhir/Substance.js.map +0 -1
- package/dist/fhir/SubstanceAmount.d.ts +0 -138
- package/dist/fhir/SubstanceAmount.js +0 -7
- package/dist/fhir/SubstanceAmount.js.map +0 -1
- package/dist/fhir/SubstanceNucleicAcid.d.ts +0 -316
- 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 -217
- package/dist/fhir/SubstanceProtein.js +0 -7
- package/dist/fhir/SubstanceProtein.js.map +0 -1
- package/dist/fhir/SubstanceReferenceInformation.d.ts +0 -329
- package/dist/fhir/SubstanceReferenceInformation.js +0 -7
- package/dist/fhir/SubstanceReferenceInformation.js.map +0 -1
- package/dist/fhir/SubstanceSourceMaterial.d.ts +0 -594
- package/dist/fhir/SubstanceSourceMaterial.js +0 -7
- package/dist/fhir/SubstanceSourceMaterial.js.map +0 -1
- package/dist/fhir/SubstanceSpecification.d.ts +0 -826
- package/dist/fhir/SubstanceSpecification.js +0 -7
- package/dist/fhir/SubstanceSpecification.js.map +0 -1
- package/dist/fhir/SupplyDelivery.d.ts +0 -195
- package/dist/fhir/SupplyDelivery.js +0 -7
- package/dist/fhir/SupplyDelivery.js.map +0 -1
- package/dist/fhir/SupplyRequest.d.ts +0 -223
- package/dist/fhir/SupplyRequest.js +0 -7
- package/dist/fhir/SupplyRequest.js.map +0 -1
- package/dist/fhir/Task.d.ts +0 -789
- package/dist/fhir/Task.js +0 -7
- package/dist/fhir/Task.js.map +0 -1
- package/dist/fhir/TerminologyCapabilities.d.ts +0 -734
- package/dist/fhir/TerminologyCapabilities.js +0 -7
- package/dist/fhir/TerminologyCapabilities.js.map +0 -1
- package/dist/fhir/TestReport.d.ts +0 -554
- package/dist/fhir/TestReport.js +0 -7
- package/dist/fhir/TestReport.js.map +0 -1
- package/dist/fhir/TestScript.d.ts +0 -1192
- package/dist/fhir/TestScript.js +0 -7
- package/dist/fhir/TestScript.js.map +0 -1
- package/dist/fhir/Timing.d.ts +0 -201
- package/dist/fhir/Timing.js +0 -7
- package/dist/fhir/Timing.js.map +0 -1
- package/dist/fhir/TriggerDefinition.d.ts +0 -63
- package/dist/fhir/TriggerDefinition.js +0 -7
- package/dist/fhir/TriggerDefinition.js.map +0 -1
- package/dist/fhir/UsageContext.d.ts +0 -54
- package/dist/fhir/UsageContext.js +0 -7
- package/dist/fhir/UsageContext.js.map +0 -1
- package/dist/fhir/User.d.ts +0 -44
- package/dist/fhir/User.js +0 -7
- package/dist/fhir/User.js.map +0 -1
- package/dist/fhir/ValueSet.d.ts +0 -736
- 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 -261
- package/dist/fhir/VisionPrescription.js +0 -7
- package/dist/fhir/VisionPrescription.js.map +0 -1
- package/dist/fhir/index.d.ts +0 -194
- package/dist/fhir/index.js +0 -211
- 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.test.d.ts +0 -1
- package/dist/format.test.js +0 -127
- package/dist/format.test.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/outcomes.test.d.ts +0 -1
- package/dist/outcomes.test.js +0 -30
- package/dist/outcomes.test.js.map +0 -1
- package/dist/search.test.d.ts +0 -1
- package/dist/search.test.js +0 -70
- package/dist/search.test.js.map +0 -1
- package/dist/storage.test.d.ts +0 -1
- package/dist/storage.test.js +0 -19
- package/dist/storage.test.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/utils.test.d.ts +0 -1
- package/dist/utils.test.js +0 -90
- package/dist/utils.test.js.map +0 -1
package/dist/client.js
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
// PKCE auth ased on:
|
|
3
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
|
+
};
|
|
4
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
14
|
exports.MedplumClient = void 0;
|
|
6
15
|
const cache_1 = require("./cache");
|
|
@@ -13,25 +22,14 @@ const storage_1 = require("./storage");
|
|
|
13
22
|
const types_1 = require("./types");
|
|
14
23
|
const utils_1 = require("./utils");
|
|
15
24
|
const DEFAULT_BASE_URL = 'https://api.medplum.com/';
|
|
25
|
+
const DEFAULT_SCOPE = 'launch/patient openid fhirUser offline_access user/*.*';
|
|
16
26
|
const DEFAULT_RESOURCE_CACHE_SIZE = 1000;
|
|
17
|
-
const DEFAULT_BLOB_CACHE_SIZE = 100;
|
|
18
27
|
const JSON_CONTENT_TYPE = 'application/json';
|
|
19
28
|
const FHIR_CONTENT_TYPE = 'application/fhir+json';
|
|
20
29
|
const PATCH_CONTENT_TYPE = 'application/json-patch+json';
|
|
21
30
|
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
|
-
profile;
|
|
34
31
|
constructor(options) {
|
|
32
|
+
var _a, _b, _c;
|
|
35
33
|
super();
|
|
36
34
|
if (options.baseUrl) {
|
|
37
35
|
if (!options.baseUrl.startsWith('http')) {
|
|
@@ -41,31 +39,36 @@ class MedplumClient extends eventtarget_1.EventTarget {
|
|
|
41
39
|
throw new Error('Base URL must end with a trailing slash');
|
|
42
40
|
}
|
|
43
41
|
}
|
|
44
|
-
if (!options.clientId) {
|
|
45
|
-
throw new Error('Client ID cannot be empty');
|
|
46
|
-
}
|
|
47
42
|
this.fetch = options.fetch || window.fetch.bind(window);
|
|
48
|
-
this.storage =
|
|
43
|
+
this.storage = new storage_1.ClientStorage();
|
|
49
44
|
this.schema = new Map();
|
|
50
|
-
this.resourceCache = new cache_1.LRUCache(options.resourceCacheSize
|
|
51
|
-
this.blobUrlCache = new cache_1.LRUCache(options.blobCacheSize ?? DEFAULT_BLOB_CACHE_SIZE);
|
|
45
|
+
this.resourceCache = new cache_1.LRUCache((_a = options.resourceCacheSize) !== null && _a !== void 0 ? _a : DEFAULT_RESOURCE_CACHE_SIZE);
|
|
52
46
|
this.baseUrl = options.baseUrl || DEFAULT_BASE_URL;
|
|
53
|
-
this.clientId = options.clientId;
|
|
47
|
+
this.clientId = options.clientId || '';
|
|
54
48
|
this.authorizeUrl = options.authorizeUrl || this.baseUrl + 'oauth2/authorize';
|
|
55
49
|
this.tokenUrl = options.tokenUrl || this.baseUrl + 'oauth2/token';
|
|
56
50
|
this.logoutUrl = options.logoutUrl || this.baseUrl + 'oauth2/logout';
|
|
57
51
|
this.onUnauthenticated = options.onUnauthenticated;
|
|
52
|
+
this.activeLogin = this.storage.getObject('activeLogin');
|
|
53
|
+
if (!((_c = (_b = this.activeLogin) === null || _b === void 0 ? void 0 : _b.profile) === null || _c === void 0 ? void 0 : _c.reference)) {
|
|
54
|
+
this.clear();
|
|
55
|
+
}
|
|
56
|
+
this.loading = false;
|
|
57
|
+
this.refreshProfile().catch(console.log);
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
60
|
* Clears all auth state including local storage and session storage.
|
|
61
61
|
*/
|
|
62
62
|
clear() {
|
|
63
63
|
this.storage.clear();
|
|
64
|
+
this.schema.clear();
|
|
65
|
+
this.resourceCache.clear();
|
|
66
|
+
this.activeLogin = undefined;
|
|
64
67
|
this.profile = undefined;
|
|
65
68
|
this.dispatchEvent({ type: 'change' });
|
|
66
69
|
}
|
|
67
|
-
get(url
|
|
68
|
-
return this.request('GET', url
|
|
70
|
+
get(url) {
|
|
71
|
+
return this.request('GET', url);
|
|
69
72
|
}
|
|
70
73
|
post(url, body, contentType) {
|
|
71
74
|
return this.request('POST', url, contentType, body);
|
|
@@ -73,57 +76,53 @@ class MedplumClient extends eventtarget_1.EventTarget {
|
|
|
73
76
|
put(url, body, contentType) {
|
|
74
77
|
return this.request('PUT', url, contentType, body);
|
|
75
78
|
}
|
|
79
|
+
delete(url) {
|
|
80
|
+
return this.request('DELETE', url);
|
|
81
|
+
}
|
|
76
82
|
/**
|
|
77
83
|
* Tries to register a new user.
|
|
78
84
|
* @param request The registration request.
|
|
79
|
-
* @returns Promise to the
|
|
85
|
+
* @returns Promise to the authentication response.
|
|
80
86
|
*/
|
|
81
87
|
register(request) {
|
|
82
|
-
return this
|
|
83
|
-
|
|
88
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
89
|
+
const response = yield this.post('auth/register', request);
|
|
90
|
+
yield this.setActiveLogin(response);
|
|
91
|
+
});
|
|
84
92
|
}
|
|
85
93
|
/**
|
|
86
|
-
*
|
|
87
|
-
* @param email The
|
|
88
|
-
* @param password The user
|
|
89
|
-
* @param
|
|
90
|
-
* @
|
|
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.
|
|
94
|
+
* Initiates a user login flow.
|
|
95
|
+
* @param email The email address of the user.
|
|
96
|
+
* @param password The password of the user.
|
|
97
|
+
* @param remember Optional flag to remember the user.
|
|
98
|
+
* @returns Promise to the authentication response.
|
|
93
99
|
*/
|
|
94
|
-
|
|
95
|
-
return this
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
100
|
+
startLogin(email, password, remember) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
yield this.startPkce();
|
|
103
|
+
return this.post('auth/login', {
|
|
104
|
+
clientId: this.clientId,
|
|
105
|
+
scope: DEFAULT_SCOPE,
|
|
106
|
+
codeChallengeMethod: 'S256',
|
|
107
|
+
codeChallenge: this.storage.getString('codeChallenge'),
|
|
108
|
+
email,
|
|
109
|
+
password,
|
|
110
|
+
remember: !!remember,
|
|
111
|
+
});
|
|
112
|
+
});
|
|
103
113
|
}
|
|
104
114
|
/**
|
|
105
115
|
* Tries to sign in with Google authentication.
|
|
106
116
|
* The response parameter is the result of a Google authentication.
|
|
107
117
|
* See: https://developers.google.com/identity/gsi/web/guides/handle-credential-responses-js-functions
|
|
108
118
|
* @param googleResponse The Google credential response.
|
|
109
|
-
* @returns Promise to the
|
|
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.
|
|
119
|
+
* @returns Promise to the authentication response.
|
|
120
120
|
*/
|
|
121
|
-
|
|
122
|
-
this
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
return response.profile;
|
|
121
|
+
startGoogleLogin(googleResponse) {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
yield this.startPkce();
|
|
124
|
+
return this.post('auth/google', googleResponse);
|
|
125
|
+
});
|
|
127
126
|
}
|
|
128
127
|
/**
|
|
129
128
|
* Signs out locally.
|
|
@@ -154,14 +153,11 @@ class MedplumClient extends eventtarget_1.EventTarget {
|
|
|
154
153
|
* See: https://docs.aws.amazon.com/cognito/latest/developerguide/logout-endpoint.html
|
|
155
154
|
*/
|
|
156
155
|
signOutWithRedirect() {
|
|
157
|
-
if (!this.logoutUrl) {
|
|
158
|
-
throw new Error('Missing logout URL');
|
|
159
|
-
}
|
|
160
156
|
window.location.assign(this.logoutUrl);
|
|
161
157
|
}
|
|
162
158
|
fhirUrl(...path) {
|
|
163
159
|
const builder = [this.baseUrl, 'fhir/R4'];
|
|
164
|
-
path.forEach(p => builder.push('/', encodeURIComponent(p)));
|
|
160
|
+
path.forEach((p) => builder.push('/', encodeURIComponent(p)));
|
|
165
161
|
return builder.join('');
|
|
166
162
|
}
|
|
167
163
|
search(search) {
|
|
@@ -186,8 +182,7 @@ class MedplumClient extends eventtarget_1.EventTarget {
|
|
|
186
182
|
}
|
|
187
183
|
read(resourceType, id) {
|
|
188
184
|
const cacheKey = resourceType + '/' + id;
|
|
189
|
-
const promise = this.get(this.fhirUrl(resourceType, id))
|
|
190
|
-
.then((resource) => {
|
|
185
|
+
const promise = this.get(this.fhirUrl(resourceType, id)).then((resource) => {
|
|
191
186
|
this.resourceCache.set(cacheKey, resource);
|
|
192
187
|
return resource;
|
|
193
188
|
});
|
|
@@ -199,7 +194,7 @@ class MedplumClient extends eventtarget_1.EventTarget {
|
|
|
199
194
|
return cached ? Promise.resolve(cached) : this.read(resourceType, id);
|
|
200
195
|
}
|
|
201
196
|
readReference(reference) {
|
|
202
|
-
const refString = reference
|
|
197
|
+
const refString = reference === null || reference === void 0 ? void 0 : reference.reference;
|
|
203
198
|
if (!refString) {
|
|
204
199
|
return Promise.reject('Missing reference');
|
|
205
200
|
}
|
|
@@ -207,7 +202,7 @@ class MedplumClient extends eventtarget_1.EventTarget {
|
|
|
207
202
|
return this.read(resourceType, id);
|
|
208
203
|
}
|
|
209
204
|
readCachedReference(reference) {
|
|
210
|
-
const refString = reference
|
|
205
|
+
const refString = reference === null || reference === void 0 ? void 0 : reference.reference;
|
|
211
206
|
if (!refString) {
|
|
212
207
|
return Promise.reject('Missing reference');
|
|
213
208
|
}
|
|
@@ -216,7 +211,7 @@ class MedplumClient extends eventtarget_1.EventTarget {
|
|
|
216
211
|
}
|
|
217
212
|
getTypeDefinition(resourceType) {
|
|
218
213
|
if (!resourceType) {
|
|
219
|
-
|
|
214
|
+
return Promise.reject('Missing resourceType');
|
|
220
215
|
}
|
|
221
216
|
const cached = this.schema.get(resourceType);
|
|
222
217
|
if (cached) {
|
|
@@ -225,7 +220,8 @@ class MedplumClient extends eventtarget_1.EventTarget {
|
|
|
225
220
|
let typeDef;
|
|
226
221
|
return this.search('StructureDefinition?name:exact=' + encodeURIComponent(resourceType))
|
|
227
222
|
.then((result) => {
|
|
228
|
-
|
|
223
|
+
var _a;
|
|
224
|
+
if (!((_a = result.entry) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
229
225
|
throw new Error('StructureDefinition not found');
|
|
230
226
|
}
|
|
231
227
|
const resource = result.entry[0].resource;
|
|
@@ -237,18 +233,20 @@ class MedplumClient extends eventtarget_1.EventTarget {
|
|
|
237
233
|
.then(() => this.search({
|
|
238
234
|
resourceType: 'SearchParameter',
|
|
239
235
|
count: 100,
|
|
240
|
-
filters: [
|
|
236
|
+
filters: [
|
|
237
|
+
{
|
|
241
238
|
code: 'base',
|
|
242
239
|
operator: search_1.Operator.EQUALS,
|
|
243
|
-
value: resourceType
|
|
244
|
-
}
|
|
240
|
+
value: resourceType,
|
|
241
|
+
},
|
|
242
|
+
],
|
|
245
243
|
}))
|
|
246
244
|
.then((result) => {
|
|
247
245
|
const entries = result.entry;
|
|
248
246
|
if (entries) {
|
|
249
247
|
typeDef.types[resourceType].searchParams = entries
|
|
250
|
-
.map(e => e.resource)
|
|
251
|
-
.sort((a, b) => a.name
|
|
248
|
+
.map((e) => e.resource)
|
|
249
|
+
.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; });
|
|
252
250
|
}
|
|
253
251
|
this.schema.set(resourceType, typeDef);
|
|
254
252
|
return typeDef;
|
|
@@ -260,26 +258,6 @@ class MedplumClient extends eventtarget_1.EventTarget {
|
|
|
260
258
|
readPatientEverything(id) {
|
|
261
259
|
return this.get(this.fhirUrl('Patient', id, '$everything'));
|
|
262
260
|
}
|
|
263
|
-
readBlob(url) {
|
|
264
|
-
return this.get(url, true);
|
|
265
|
-
}
|
|
266
|
-
readBlobAsObjectUrl(url) {
|
|
267
|
-
const promise = this.readBlob(url)
|
|
268
|
-
.then(imageBlob => {
|
|
269
|
-
const imageUrl = URL.createObjectURL(imageBlob);
|
|
270
|
-
this.blobUrlCache.set(url, imageUrl);
|
|
271
|
-
return imageUrl;
|
|
272
|
-
});
|
|
273
|
-
this.blobUrlCache.set(url, promise);
|
|
274
|
-
return promise;
|
|
275
|
-
}
|
|
276
|
-
readCachedBlobAsObjectUrl(url) {
|
|
277
|
-
const cached = this.blobUrlCache.get(url);
|
|
278
|
-
return cached ? Promise.resolve(cached) : this.readBlobAsObjectUrl(url);
|
|
279
|
-
}
|
|
280
|
-
readBinary(id) {
|
|
281
|
-
return this.readBlob(this.fhirUrl('Binary', id));
|
|
282
|
-
}
|
|
283
261
|
create(resource) {
|
|
284
262
|
if (!resource.resourceType) {
|
|
285
263
|
throw new Error('Missing resourceType');
|
|
@@ -301,6 +279,9 @@ class MedplumClient extends eventtarget_1.EventTarget {
|
|
|
301
279
|
patch(resourceType, id, operations) {
|
|
302
280
|
return this.request('PATCH', this.fhirUrl(resourceType, id), PATCH_CONTENT_TYPE, operations);
|
|
303
281
|
}
|
|
282
|
+
deleteResource(resourceType, id) {
|
|
283
|
+
return this.delete(this.fhirUrl(resourceType, id));
|
|
284
|
+
}
|
|
304
285
|
graphql(gql) {
|
|
305
286
|
return this.post(this.fhirUrl('$graphql'), gql, JSON_CONTENT_TYPE);
|
|
306
287
|
}
|
|
@@ -310,11 +291,11 @@ class MedplumClient extends eventtarget_1.EventTarget {
|
|
|
310
291
|
status: 'active',
|
|
311
292
|
criteria: criteria,
|
|
312
293
|
channel: {
|
|
313
|
-
type: 'sse'
|
|
314
|
-
}
|
|
294
|
+
type: 'sse',
|
|
295
|
+
},
|
|
315
296
|
}).then((sub) => {
|
|
316
297
|
const eventSource = new EventSource(this.baseUrl + 'sse?subscription=' + encodeURIComponent(sub.id), {
|
|
317
|
-
withCredentials: true
|
|
298
|
+
withCredentials: true,
|
|
318
299
|
});
|
|
319
300
|
eventSource.onmessage = (e) => {
|
|
320
301
|
handler(JSON.parse(e.data));
|
|
@@ -322,27 +303,46 @@ class MedplumClient extends eventtarget_1.EventTarget {
|
|
|
322
303
|
return eventSource;
|
|
323
304
|
});
|
|
324
305
|
}
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
return this
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
306
|
+
getActiveLogin() {
|
|
307
|
+
return this.activeLogin;
|
|
308
|
+
}
|
|
309
|
+
setActiveLogin(login) {
|
|
310
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
311
|
+
this.activeLogin = login;
|
|
312
|
+
this.storage.setObject('activeLogin', login);
|
|
313
|
+
this.addLogin(login);
|
|
314
|
+
this.resourceCache.clear();
|
|
315
|
+
this.refreshPromise = undefined;
|
|
316
|
+
yield this.refreshProfile();
|
|
317
|
+
});
|
|
337
318
|
}
|
|
338
|
-
|
|
339
|
-
|
|
319
|
+
getLogins() {
|
|
320
|
+
var _a;
|
|
321
|
+
return (_a = this.storage.getObject('logins')) !== null && _a !== void 0 ? _a : [];
|
|
322
|
+
}
|
|
323
|
+
addLogin(newLogin) {
|
|
324
|
+
const logins = this.getLogins().filter((login) => { var _a, _b; return ((_a = login.profile) === null || _a === void 0 ? void 0 : _a.reference) !== ((_b = newLogin.profile) === null || _b === void 0 ? void 0 : _b.reference); });
|
|
325
|
+
logins.push(newLogin);
|
|
326
|
+
this.storage.setObject('logins', logins);
|
|
327
|
+
}
|
|
328
|
+
refreshProfile() {
|
|
329
|
+
var _a;
|
|
330
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
331
|
+
const reference = (_a = this.getActiveLogin()) === null || _a === void 0 ? void 0 : _a.profile;
|
|
332
|
+
if (reference === null || reference === void 0 ? void 0 : reference.reference) {
|
|
333
|
+
this.loading = true;
|
|
334
|
+
this.profile = yield this.readCachedReference(reference);
|
|
335
|
+
this.loading = false;
|
|
336
|
+
this.dispatchEvent({ type: 'change' });
|
|
337
|
+
}
|
|
338
|
+
return this.profile;
|
|
339
|
+
});
|
|
340
340
|
}
|
|
341
|
-
|
|
342
|
-
return this.
|
|
341
|
+
getProfile() {
|
|
342
|
+
return this.profile;
|
|
343
343
|
}
|
|
344
|
-
|
|
345
|
-
this.
|
|
344
|
+
isLoading() {
|
|
345
|
+
return this.loading;
|
|
346
346
|
}
|
|
347
347
|
/**
|
|
348
348
|
* Makes an HTTP request.
|
|
@@ -350,43 +350,52 @@ class MedplumClient extends eventtarget_1.EventTarget {
|
|
|
350
350
|
* @param {string} url
|
|
351
351
|
* @param {string=} contentType
|
|
352
352
|
* @param {Object=} body
|
|
353
|
-
* @param {boolean=} blob
|
|
354
353
|
*/
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
'Content-Type': contentType || FHIR_CONTENT_TYPE
|
|
361
|
-
};
|
|
362
|
-
const accessToken = this.getAccessToken();
|
|
363
|
-
if (accessToken) {
|
|
364
|
-
headers['Authorization'] = 'Bearer ' + accessToken;
|
|
365
|
-
}
|
|
366
|
-
const options = {
|
|
367
|
-
method: method,
|
|
368
|
-
cache: 'no-cache',
|
|
369
|
-
credentials: 'include',
|
|
370
|
-
headers
|
|
371
|
-
};
|
|
372
|
-
if (body) {
|
|
373
|
-
if (typeof body === 'string' || (typeof File !== 'undefined' && body instanceof File)) {
|
|
374
|
-
options.body = body;
|
|
354
|
+
request(method, url, contentType, body) {
|
|
355
|
+
var _a;
|
|
356
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
357
|
+
if (this.refreshPromise) {
|
|
358
|
+
yield this.refreshPromise;
|
|
375
359
|
}
|
|
376
|
-
|
|
377
|
-
|
|
360
|
+
if (!url.startsWith('http')) {
|
|
361
|
+
url = this.baseUrl + url;
|
|
378
362
|
}
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
363
|
+
const headers = {
|
|
364
|
+
'Content-Type': contentType || FHIR_CONTENT_TYPE,
|
|
365
|
+
};
|
|
366
|
+
const accessToken = (_a = this.getActiveLogin()) === null || _a === void 0 ? void 0 : _a.accessToken;
|
|
367
|
+
if (accessToken) {
|
|
368
|
+
headers['Authorization'] = 'Bearer ' + accessToken;
|
|
369
|
+
}
|
|
370
|
+
const options = {
|
|
371
|
+
method: method,
|
|
372
|
+
cache: 'no-cache',
|
|
373
|
+
credentials: 'include',
|
|
374
|
+
headers,
|
|
375
|
+
};
|
|
376
|
+
if (body) {
|
|
377
|
+
if (typeof body === 'string' || (typeof File !== 'undefined' && body instanceof File)) {
|
|
378
|
+
options.body = body;
|
|
379
|
+
}
|
|
380
|
+
else {
|
|
381
|
+
options.body = (0, utils_1.stringify)(body);
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
const response = yield this.fetch(url, options);
|
|
385
|
+
if (response.status === 401) {
|
|
386
|
+
// Refresh and try again
|
|
387
|
+
return this.handleUnauthenticated(method, url, contentType, body);
|
|
388
|
+
}
|
|
389
|
+
if (response.status === 204 || response.status === 304) {
|
|
390
|
+
// No content or change
|
|
391
|
+
return undefined;
|
|
392
|
+
}
|
|
393
|
+
const obj = yield response.json();
|
|
394
|
+
if (obj.resourceType === 'OperationOutcome' && !(0, outcomes_1.isOk)(obj)) {
|
|
395
|
+
return Promise.reject(new outcomes_1.OperationOutcomeError(obj));
|
|
396
|
+
}
|
|
397
|
+
return obj;
|
|
398
|
+
});
|
|
390
399
|
}
|
|
391
400
|
/**
|
|
392
401
|
* Handles an unauthenticated response from the server.
|
|
@@ -396,17 +405,33 @@ class MedplumClient extends eventtarget_1.EventTarget {
|
|
|
396
405
|
* @param url The URL of the original request.
|
|
397
406
|
* @param contentType The content type of the original request.
|
|
398
407
|
* @param body The body of the original request.
|
|
399
|
-
* @param blob Optional blob flag of the original request.
|
|
400
408
|
*/
|
|
401
|
-
|
|
402
|
-
return this
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
this.onUnauthenticated
|
|
408
|
-
|
|
409
|
-
|
|
409
|
+
handleUnauthenticated(method, url, contentType, body) {
|
|
410
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
411
|
+
return this.refresh()
|
|
412
|
+
.then(() => this.request(method, url, contentType, body))
|
|
413
|
+
.catch((error) => {
|
|
414
|
+
this.clear();
|
|
415
|
+
if (this.onUnauthenticated) {
|
|
416
|
+
this.onUnauthenticated();
|
|
417
|
+
}
|
|
418
|
+
return Promise.reject(error);
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Starts a new PKCE flow.
|
|
424
|
+
* These PKCE values are stateful, and must survive redirects and page refreshes.
|
|
425
|
+
*/
|
|
426
|
+
startPkce() {
|
|
427
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
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).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
|
434
|
+
this.storage.setString('codeChallenge', codeChallenge);
|
|
410
435
|
});
|
|
411
436
|
}
|
|
412
437
|
/**
|
|
@@ -414,27 +439,26 @@ class MedplumClient extends eventtarget_1.EventTarget {
|
|
|
414
439
|
* Clears all auth state including local storage and session storage.
|
|
415
440
|
* See: https://openid.net/specs/openid-connect-core-1_0.html#AuthorizationEndpoint
|
|
416
441
|
*/
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
'&code_challenge=' + encodeURIComponent(codeChallenge));
|
|
442
|
+
requestAuthorization() {
|
|
443
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
444
|
+
if (!this.authorizeUrl) {
|
|
445
|
+
throw new Error('Missing authorize URL');
|
|
446
|
+
}
|
|
447
|
+
this.startPkce();
|
|
448
|
+
window.location.assign(this.authorizeUrl +
|
|
449
|
+
'?response_type=code' +
|
|
450
|
+
'&state=' +
|
|
451
|
+
encodeURIComponent(this.storage.getString('pkceState')) +
|
|
452
|
+
'&client_id=' +
|
|
453
|
+
encodeURIComponent(this.clientId) +
|
|
454
|
+
'&redirect_uri=' +
|
|
455
|
+
encodeURIComponent(getBaseUrl()) +
|
|
456
|
+
'&scope=' +
|
|
457
|
+
encodeURIComponent(DEFAULT_SCOPE) +
|
|
458
|
+
'&code_challenge_method=S256' +
|
|
459
|
+
'&code_challenge=' +
|
|
460
|
+
encodeURIComponent(this.storage.getString('codeChallenge')));
|
|
461
|
+
});
|
|
438
462
|
}
|
|
439
463
|
/**
|
|
440
464
|
* Processes an OAuth authorization code.
|
|
@@ -453,47 +477,61 @@ class MedplumClient extends eventtarget_1.EventTarget {
|
|
|
453
477
|
throw new Error('Invalid PCKE code verifier');
|
|
454
478
|
}
|
|
455
479
|
return this.fetchTokens('grant_type=authorization_code' +
|
|
456
|
-
'&client_id=' + encodeURIComponent(this.clientId) +
|
|
457
|
-
'&code_verifier=' +
|
|
458
|
-
|
|
459
|
-
'&
|
|
480
|
+
(this.clientId ? '&client_id=' + encodeURIComponent(this.clientId) : '') +
|
|
481
|
+
'&code_verifier=' +
|
|
482
|
+
encodeURIComponent(codeVerifier) +
|
|
483
|
+
'&redirect_uri=' +
|
|
484
|
+
encodeURIComponent(getBaseUrl()) +
|
|
485
|
+
'&code=' +
|
|
486
|
+
encodeURIComponent(code));
|
|
460
487
|
}
|
|
461
488
|
/**
|
|
462
489
|
* Tries to refresh the auth tokens.
|
|
463
490
|
* See: https://openid.net/specs/openid-connect-core-1_0.html#RefreshTokens
|
|
464
491
|
*/
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
this.
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
492
|
+
refresh() {
|
|
493
|
+
var _a;
|
|
494
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
495
|
+
if (this.refreshPromise) {
|
|
496
|
+
return this.refreshPromise;
|
|
497
|
+
}
|
|
498
|
+
const refreshToken = (_a = this.getActiveLogin()) === null || _a === void 0 ? void 0 : _a.refreshToken;
|
|
499
|
+
if (!refreshToken) {
|
|
500
|
+
this.clear();
|
|
501
|
+
return Promise.reject('Invalid refresh token');
|
|
502
|
+
}
|
|
503
|
+
this.refreshPromise = this.fetchTokens('grant_type=refresh_token' +
|
|
504
|
+
'&client_id=' +
|
|
505
|
+
encodeURIComponent(this.clientId) +
|
|
506
|
+
'&refresh_token=' +
|
|
507
|
+
encodeURIComponent(refreshToken));
|
|
508
|
+
yield this.refreshPromise;
|
|
509
|
+
});
|
|
474
510
|
}
|
|
475
511
|
/**
|
|
476
512
|
* Makes a POST request to the tokens endpoint.
|
|
477
513
|
* See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint
|
|
478
514
|
* @param formBody Token parameters in URL encoded format.
|
|
479
515
|
*/
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
return this.fetch(this.tokenUrl, {
|
|
485
|
-
method: 'POST',
|
|
486
|
-
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
487
|
-
body: formBody
|
|
488
|
-
})
|
|
489
|
-
.then(response => {
|
|
490
|
-
if (!response.ok) {
|
|
491
|
-
return Promise.reject('Failed to fetch tokens');
|
|
516
|
+
fetchTokens(formBody) {
|
|
517
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
518
|
+
if (!this.tokenUrl) {
|
|
519
|
+
return Promise.reject('Missing token URL');
|
|
492
520
|
}
|
|
493
|
-
return
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
521
|
+
return this.fetch(this.tokenUrl, {
|
|
522
|
+
method: 'POST',
|
|
523
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
524
|
+
body: formBody,
|
|
525
|
+
})
|
|
526
|
+
.then((response) => {
|
|
527
|
+
if (!response.ok) {
|
|
528
|
+
return Promise.reject('Failed to fetch tokens');
|
|
529
|
+
}
|
|
530
|
+
return response.json();
|
|
531
|
+
})
|
|
532
|
+
.then((tokens) => this.verifyTokens(tokens))
|
|
533
|
+
.then(() => this.profile);
|
|
534
|
+
});
|
|
497
535
|
}
|
|
498
536
|
/**
|
|
499
537
|
* Verifies the tokens received from the auth server.
|
|
@@ -501,21 +539,27 @@ class MedplumClient extends eventtarget_1.EventTarget {
|
|
|
501
539
|
* See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint
|
|
502
540
|
* @param tokens
|
|
503
541
|
*/
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
this.
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
542
|
+
verifyTokens(tokens) {
|
|
543
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
544
|
+
const token = tokens.access_token;
|
|
545
|
+
// Verify token has not expired
|
|
546
|
+
const tokenPayload = (0, jwt_1.parseJWTPayload)(token);
|
|
547
|
+
if (Date.now() >= tokenPayload.exp * 1000) {
|
|
548
|
+
this.clear();
|
|
549
|
+
return Promise.reject('Token expired');
|
|
550
|
+
}
|
|
551
|
+
// Verify app_client_id
|
|
552
|
+
if (this.clientId && tokenPayload.client_id !== this.clientId) {
|
|
553
|
+
this.clear();
|
|
554
|
+
return Promise.reject('Token was not issued for this audience');
|
|
555
|
+
}
|
|
556
|
+
yield this.setActiveLogin({
|
|
557
|
+
accessToken: token,
|
|
558
|
+
refreshToken: tokens.refresh_token,
|
|
559
|
+
project: tokens.project,
|
|
560
|
+
profile: tokens.profile,
|
|
561
|
+
});
|
|
562
|
+
});
|
|
519
563
|
}
|
|
520
564
|
}
|
|
521
565
|
exports.MedplumClient = MedplumClient;
|