@medplum/core 1.0.5 → 1.0.6
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 +9 -7
- package/dist/cjs/format.d.ts +2 -1
- package/dist/cjs/{index.js → index.cjs} +325 -363
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.min.cjs +1 -0
- package/dist/cjs/search.d.ts +2 -1
- package/dist/esm/{base-schema.json.js → base-schema.json.mjs} +1 -1
- package/dist/esm/{base-schema.json.js.map → base-schema.json.mjs.map} +1 -1
- package/dist/esm/{cache.js → cache.mjs} +2 -2
- package/dist/esm/cache.mjs.map +1 -0
- package/dist/esm/{client.js → client.mjs} +241 -246
- package/dist/esm/client.mjs.map +1 -0
- package/dist/esm/{crypto.js → crypto.mjs} +4 -7
- package/dist/esm/crypto.mjs.map +1 -0
- package/dist/esm/{eventtarget.js → eventtarget.mjs} +2 -2
- package/dist/esm/eventtarget.mjs.map +1 -0
- package/dist/esm/fhirlexer/{parse.js → parse.mjs} +5 -6
- package/dist/esm/fhirlexer/parse.mjs.map +1 -0
- package/dist/esm/fhirlexer/{tokenize.js → tokenize.mjs} +11 -11
- package/dist/esm/fhirlexer/tokenize.mjs.map +1 -0
- package/dist/esm/fhirpath/{atoms.js → atoms.mjs} +11 -12
- package/dist/esm/fhirpath/atoms.mjs.map +1 -0
- package/dist/esm/fhirpath/{date.js → date.mjs} +1 -1
- package/dist/esm/fhirpath/date.mjs.map +1 -0
- package/dist/esm/fhirpath/{functions.js → functions.mjs} +16 -22
- package/dist/esm/fhirpath/functions.mjs.map +1 -0
- package/dist/esm/fhirpath/{parse.js → parse.mjs} +9 -10
- package/dist/esm/fhirpath/parse.mjs.map +1 -0
- package/dist/esm/fhirpath/{tokenize.js → tokenize.mjs} +3 -3
- package/dist/esm/fhirpath/tokenize.mjs.map +1 -0
- package/dist/esm/fhirpath/{utils.js → utils.mjs} +6 -7
- package/dist/esm/fhirpath/utils.mjs.map +1 -0
- package/dist/esm/format.d.ts +2 -1
- package/dist/esm/{format.js → format.mjs} +29 -21
- package/dist/esm/format.mjs.map +1 -0
- package/dist/esm/{hl7.js → hl7.mjs} +8 -9
- package/dist/esm/hl7.mjs.map +1 -0
- package/dist/esm/index.min.mjs +1 -0
- package/dist/esm/{index.js → index.mjs} +17 -17
- package/dist/esm/index.mjs.map +1 -0
- package/dist/esm/{jwt.js → jwt.mjs} +1 -1
- package/dist/esm/jwt.mjs.map +1 -0
- package/dist/esm/{match.js → match.mjs} +12 -13
- package/dist/esm/match.mjs.map +1 -0
- package/dist/esm/node_modules/tslib/{tslib.es6.js → tslib.es6.mjs} +2 -12
- package/dist/esm/node_modules/tslib/tslib.es6.mjs.map +1 -0
- package/dist/esm/{outcomes.js → outcomes.mjs} +3 -5
- package/dist/esm/outcomes.mjs.map +1 -0
- package/dist/esm/{readablepromise.js → readablepromise.mjs} +2 -2
- package/dist/esm/readablepromise.mjs.map +1 -0
- package/dist/esm/search.d.ts +2 -1
- package/dist/esm/{search.js → search.mjs} +1 -1
- package/dist/esm/search.mjs.map +1 -0
- package/dist/esm/{searchparams.js → searchparams.mjs} +8 -9
- package/dist/esm/searchparams.mjs.map +1 -0
- package/dist/esm/{storage.js → storage.mjs} +4 -5
- package/dist/esm/storage.mjs.map +1 -0
- package/dist/esm/{types.js → types.mjs} +6 -9
- package/dist/esm/types.mjs.map +1 -0
- package/dist/esm/{utils.js → utils.mjs} +15 -26
- package/dist/esm/utils.mjs.map +1 -0
- package/package.json +5 -5
- package/rollup.config.mjs +6 -7
- package/dist/cjs/fhirmapper/testall.d.ts +0 -1
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/index.min.js +0 -2
- package/dist/cjs/index.min.js.map +0 -1
- package/dist/esm/cache.js.map +0 -1
- package/dist/esm/client.js.map +0 -1
- package/dist/esm/crypto.js.map +0 -1
- package/dist/esm/eventtarget.js.map +0 -1
- package/dist/esm/fhirlexer/parse.js.map +0 -1
- package/dist/esm/fhirlexer/tokenize.js.map +0 -1
- package/dist/esm/fhirmapper/testall.d.ts +0 -1
- package/dist/esm/fhirpath/atoms.js.map +0 -1
- package/dist/esm/fhirpath/date.js.map +0 -1
- package/dist/esm/fhirpath/functions.js.map +0 -1
- package/dist/esm/fhirpath/parse.js.map +0 -1
- package/dist/esm/fhirpath/tokenize.js.map +0 -1
- package/dist/esm/fhirpath/utils.js.map +0 -1
- package/dist/esm/format.js.map +0 -1
- package/dist/esm/hl7.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/index.min.js +0 -2
- package/dist/esm/index.min.js.map +0 -1
- package/dist/esm/jwt.js.map +0 -1
- package/dist/esm/match.js.map +0 -1
- package/dist/esm/node_modules/tslib/tslib.es6.js.map +0 -1
- package/dist/esm/outcomes.js.map +0 -1
- package/dist/esm/readablepromise.js.map +0 -1
- package/dist/esm/search.js.map +0 -1
- package/dist/esm/searchparams.js.map +0 -1
- package/dist/esm/storage.js.map +0 -1
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/utils.js.map +0 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { __classPrivateFieldSet, __classPrivateFieldGet
|
|
2
|
-
import { LRUCache } from './cache.
|
|
3
|
-
import { getRandomString, encryptSHA256 } from './crypto.
|
|
4
|
-
import { EventTarget } from './eventtarget.
|
|
5
|
-
import { parseJWTPayload } from './jwt.
|
|
6
|
-
import { ReadablePromise } from './readablepromise.
|
|
7
|
-
import { ClientStorage } from './storage.
|
|
8
|
-
import { globalSchema, indexStructureDefinition, indexSearchParameter } from './types.
|
|
9
|
-
import { createReference, arrayBufferToBase64 } from './utils.
|
|
1
|
+
import { __classPrivateFieldSet, __classPrivateFieldGet } from './node_modules/tslib/tslib.es6.mjs';
|
|
2
|
+
import { LRUCache } from './cache.mjs';
|
|
3
|
+
import { getRandomString, encryptSHA256 } from './crypto.mjs';
|
|
4
|
+
import { EventTarget } from './eventtarget.mjs';
|
|
5
|
+
import { parseJWTPayload } from './jwt.mjs';
|
|
6
|
+
import { ReadablePromise } from './readablepromise.mjs';
|
|
7
|
+
import { ClientStorage } from './storage.mjs';
|
|
8
|
+
import { globalSchema, indexStructureDefinition, indexSearchParameter } from './types.mjs';
|
|
9
|
+
import { createReference, arrayBufferToBase64 } from './utils.mjs';
|
|
10
10
|
|
|
11
11
|
// PKCE auth based on:
|
|
12
12
|
// https://aws.amazon.com/blogs/security/how-to-add-authentication-single-page-web-application-with-amazon-cognito-oauth2-implementation/
|
|
13
13
|
var _MedplumClient_instances, _MedplumClient_fetch, _MedplumClient_createPdf, _MedplumClient_storage, _MedplumClient_requestCache, _MedplumClient_cacheTime, _MedplumClient_baseUrl, _MedplumClient_authorizeUrl, _MedplumClient_tokenUrl, _MedplumClient_logoutUrl, _MedplumClient_onUnauthenticated, _MedplumClient_clientId, _MedplumClient_clientSecret, _MedplumClient_accessToken, _MedplumClient_refreshToken, _MedplumClient_refreshPromise, _MedplumClient_profilePromise, _MedplumClient_profile, _MedplumClient_config, _MedplumClient_addLogin, _MedplumClient_refreshProfile, _MedplumClient_getCacheEntry, _MedplumClient_setCacheEntry, _MedplumClient_request, _MedplumClient_addFetchOptionsDefaults, _MedplumClient_setRequestContentType, _MedplumClient_setRequestBody, _MedplumClient_handleUnauthenticated, _MedplumClient_requestAuthorization, _MedplumClient_refresh, _MedplumClient_fetchTokens, _MedplumClient_verifyTokens, _MedplumClient_setupStorageListener;
|
|
14
|
-
const MEDPLUM_VERSION = "1.0.
|
|
14
|
+
const MEDPLUM_VERSION = "1.0.6-5860113c";
|
|
15
15
|
const DEFAULT_BASE_URL = 'https://api.medplum.com/';
|
|
16
16
|
const DEFAULT_RESOURCE_CACHE_SIZE = 1000;
|
|
17
17
|
const DEFAULT_CACHE_TIME = 60000; // 60 seconds
|
|
@@ -72,7 +72,6 @@ const PATCH_CONTENT_TYPE = 'application/json-patch+json';
|
|
|
72
72
|
*/
|
|
73
73
|
class MedplumClient extends EventTarget {
|
|
74
74
|
constructor(options) {
|
|
75
|
-
var _a, _b;
|
|
76
75
|
super();
|
|
77
76
|
_MedplumClient_instances.add(this);
|
|
78
77
|
_MedplumClient_fetch.set(this, void 0);
|
|
@@ -93,22 +92,22 @@ class MedplumClient extends EventTarget {
|
|
|
93
92
|
_MedplumClient_profilePromise.set(this, void 0);
|
|
94
93
|
_MedplumClient_profile.set(this, void 0);
|
|
95
94
|
_MedplumClient_config.set(this, void 0);
|
|
96
|
-
if (options
|
|
95
|
+
if (options?.baseUrl) {
|
|
97
96
|
if (!options.baseUrl.startsWith('http')) {
|
|
98
97
|
throw new Error('Base URL must start with http or https');
|
|
99
98
|
}
|
|
100
99
|
}
|
|
101
|
-
__classPrivateFieldSet(this, _MedplumClient_fetch,
|
|
102
|
-
__classPrivateFieldSet(this, _MedplumClient_createPdf, options
|
|
100
|
+
__classPrivateFieldSet(this, _MedplumClient_fetch, options?.fetch || window.fetch.bind(window), "f");
|
|
101
|
+
__classPrivateFieldSet(this, _MedplumClient_createPdf, options?.createPdf, "f");
|
|
103
102
|
__classPrivateFieldSet(this, _MedplumClient_storage, new ClientStorage(), "f");
|
|
104
|
-
__classPrivateFieldSet(this, _MedplumClient_requestCache, new LRUCache(
|
|
105
|
-
__classPrivateFieldSet(this, _MedplumClient_cacheTime,
|
|
106
|
-
__classPrivateFieldSet(this, _MedplumClient_baseUrl, ensureTrailingSlash(options
|
|
107
|
-
__classPrivateFieldSet(this, _MedplumClient_clientId,
|
|
108
|
-
__classPrivateFieldSet(this, _MedplumClient_authorizeUrl,
|
|
109
|
-
__classPrivateFieldSet(this, _MedplumClient_tokenUrl,
|
|
110
|
-
__classPrivateFieldSet(this, _MedplumClient_logoutUrl,
|
|
111
|
-
__classPrivateFieldSet(this, _MedplumClient_onUnauthenticated, options
|
|
103
|
+
__classPrivateFieldSet(this, _MedplumClient_requestCache, new LRUCache(options?.resourceCacheSize ?? DEFAULT_RESOURCE_CACHE_SIZE), "f");
|
|
104
|
+
__classPrivateFieldSet(this, _MedplumClient_cacheTime, options?.cacheTime ?? DEFAULT_CACHE_TIME, "f");
|
|
105
|
+
__classPrivateFieldSet(this, _MedplumClient_baseUrl, ensureTrailingSlash(options?.baseUrl) || DEFAULT_BASE_URL, "f");
|
|
106
|
+
__classPrivateFieldSet(this, _MedplumClient_clientId, options?.clientId || '', "f");
|
|
107
|
+
__classPrivateFieldSet(this, _MedplumClient_authorizeUrl, options?.authorizeUrl || __classPrivateFieldGet(this, _MedplumClient_baseUrl, "f") + 'oauth2/authorize', "f");
|
|
108
|
+
__classPrivateFieldSet(this, _MedplumClient_tokenUrl, options?.tokenUrl || __classPrivateFieldGet(this, _MedplumClient_baseUrl, "f") + 'oauth2/token', "f");
|
|
109
|
+
__classPrivateFieldSet(this, _MedplumClient_logoutUrl, options?.logoutUrl || __classPrivateFieldGet(this, _MedplumClient_baseUrl, "f") + 'oauth2/logout', "f");
|
|
110
|
+
__classPrivateFieldSet(this, _MedplumClient_onUnauthenticated, options?.onUnauthenticated, "f");
|
|
112
111
|
const activeLogin = this.getActiveLogin();
|
|
113
112
|
if (activeLogin) {
|
|
114
113
|
__classPrivateFieldSet(this, _MedplumClient_accessToken, activeLogin.accessToken, "f");
|
|
@@ -283,10 +282,12 @@ class MedplumClient extends EventTarget {
|
|
|
283
282
|
* @param newUserRequest Register request including email and password.
|
|
284
283
|
* @returns Promise to the authentication response.
|
|
285
284
|
*/
|
|
286
|
-
startNewUser(newUserRequest) {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
285
|
+
async startNewUser(newUserRequest) {
|
|
286
|
+
await this.startPkce();
|
|
287
|
+
return this.post('auth/newuser', {
|
|
288
|
+
...newUserRequest,
|
|
289
|
+
codeChallengeMethod: 'S256',
|
|
290
|
+
codeChallenge: sessionStorage.getItem('codeChallenge'),
|
|
290
291
|
});
|
|
291
292
|
}
|
|
292
293
|
/**
|
|
@@ -297,10 +298,8 @@ class MedplumClient extends EventTarget {
|
|
|
297
298
|
* @param newProjectRequest Register request including email and password.
|
|
298
299
|
* @returns Promise to the authentication response.
|
|
299
300
|
*/
|
|
300
|
-
startNewProject(newProjectRequest) {
|
|
301
|
-
return
|
|
302
|
-
return this.post('auth/newproject', newProjectRequest);
|
|
303
|
-
});
|
|
301
|
+
async startNewProject(newProjectRequest) {
|
|
302
|
+
return this.post('auth/newproject', newProjectRequest);
|
|
304
303
|
}
|
|
305
304
|
/**
|
|
306
305
|
* Initiates a new patient flow.
|
|
@@ -310,10 +309,8 @@ class MedplumClient extends EventTarget {
|
|
|
310
309
|
* @param newPatientRequest Register request including email and password.
|
|
311
310
|
* @returns Promise to the authentication response.
|
|
312
311
|
*/
|
|
313
|
-
startNewPatient(newPatientRequest) {
|
|
314
|
-
return
|
|
315
|
-
return this.post('auth/newpatient', newPatientRequest);
|
|
316
|
-
});
|
|
312
|
+
async startNewPatient(newPatientRequest) {
|
|
313
|
+
return this.post('auth/newpatient', newPatientRequest);
|
|
317
314
|
}
|
|
318
315
|
/**
|
|
319
316
|
* Initiates a user login flow.
|
|
@@ -321,12 +318,14 @@ class MedplumClient extends EventTarget {
|
|
|
321
318
|
* @param loginRequest Login request including email and password.
|
|
322
319
|
* @returns Promise to the authentication response.
|
|
323
320
|
*/
|
|
324
|
-
startLogin(loginRequest) {
|
|
325
|
-
|
|
326
|
-
return
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
321
|
+
async startLogin(loginRequest) {
|
|
322
|
+
const { codeChallenge, codeChallengeMethod } = this.getCodeChallenge(loginRequest);
|
|
323
|
+
return this.post('auth/login', {
|
|
324
|
+
...loginRequest,
|
|
325
|
+
clientId: loginRequest.clientId ?? __classPrivateFieldGet(this, _MedplumClient_clientId, "f"),
|
|
326
|
+
scope: loginRequest.scope,
|
|
327
|
+
codeChallengeMethod,
|
|
328
|
+
codeChallenge,
|
|
330
329
|
});
|
|
331
330
|
}
|
|
332
331
|
/**
|
|
@@ -337,12 +336,14 @@ class MedplumClient extends EventTarget {
|
|
|
337
336
|
* @param loginRequest Login request including Google credential response.
|
|
338
337
|
* @returns Promise to the authentication response.
|
|
339
338
|
*/
|
|
340
|
-
startGoogleLogin(loginRequest) {
|
|
341
|
-
|
|
342
|
-
return
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
339
|
+
async startGoogleLogin(loginRequest) {
|
|
340
|
+
const { codeChallenge, codeChallengeMethod } = this.getCodeChallenge(loginRequest);
|
|
341
|
+
return this.post('auth/google', {
|
|
342
|
+
...loginRequest,
|
|
343
|
+
clientId: loginRequest.clientId ?? __classPrivateFieldGet(this, _MedplumClient_clientId, "f"),
|
|
344
|
+
scope: loginRequest.scope,
|
|
345
|
+
codeChallengeMethod,
|
|
346
|
+
codeChallenge,
|
|
346
347
|
});
|
|
347
348
|
}
|
|
348
349
|
getCodeChallenge(loginRequest) {
|
|
@@ -375,18 +376,16 @@ class MedplumClient extends EventTarget {
|
|
|
375
376
|
* This may result in navigating away to the sign in page.
|
|
376
377
|
* @category Authentication
|
|
377
378
|
*/
|
|
378
|
-
signInWithRedirect() {
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
}
|
|
389
|
-
});
|
|
379
|
+
async signInWithRedirect() {
|
|
380
|
+
const urlParams = new URLSearchParams(window.location.search);
|
|
381
|
+
const code = urlParams.get('code');
|
|
382
|
+
if (!code) {
|
|
383
|
+
await __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_requestAuthorization).call(this);
|
|
384
|
+
return undefined;
|
|
385
|
+
}
|
|
386
|
+
else {
|
|
387
|
+
return this.processCode(code);
|
|
388
|
+
}
|
|
390
389
|
}
|
|
391
390
|
/**
|
|
392
391
|
* Tries to sign out the user.
|
|
@@ -502,7 +501,7 @@ class MedplumClient extends EventTarget {
|
|
|
502
501
|
if (cached) {
|
|
503
502
|
return cached.value;
|
|
504
503
|
}
|
|
505
|
-
const promise = new ReadablePromise(this.search(resourceType, url.searchParams, options).then((b) =>
|
|
504
|
+
const promise = new ReadablePromise(this.search(resourceType, url.searchParams, options).then((b) => b.entry?.[0]?.resource));
|
|
506
505
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setCacheEntry).call(this, cacheKey, promise);
|
|
507
506
|
return promise;
|
|
508
507
|
}
|
|
@@ -535,7 +534,7 @@ class MedplumClient extends EventTarget {
|
|
|
535
534
|
if (cached) {
|
|
536
535
|
return cached.value;
|
|
537
536
|
}
|
|
538
|
-
const promise = new ReadablePromise(this.search(resourceType, query, options).then((b) =>
|
|
537
|
+
const promise = new ReadablePromise(this.search(resourceType, query, options).then((b) => b.entry?.map((e) => e.resource) ?? []));
|
|
539
538
|
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setCacheEntry).call(this, cacheKey, promise);
|
|
540
539
|
return promise;
|
|
541
540
|
}
|
|
@@ -563,8 +562,7 @@ class MedplumClient extends EventTarget {
|
|
|
563
562
|
* @returns The resource if it is available in the cache; undefined otherwise.
|
|
564
563
|
*/
|
|
565
564
|
getCached(resourceType, id) {
|
|
566
|
-
|
|
567
|
-
const cached = (_a = __classPrivateFieldGet(this, _MedplumClient_requestCache, "f").get(this.fhirUrl(resourceType, id).toString())) === null || _a === void 0 ? void 0 : _a.value;
|
|
565
|
+
const cached = __classPrivateFieldGet(this, _MedplumClient_requestCache, "f").get(this.fhirUrl(resourceType, id).toString())?.value;
|
|
568
566
|
return cached && cached.isOk() ? cached.read() : undefined;
|
|
569
567
|
}
|
|
570
568
|
/**
|
|
@@ -627,7 +625,7 @@ class MedplumClient extends EventTarget {
|
|
|
627
625
|
* @returns The resource if available; undefined otherwise.
|
|
628
626
|
*/
|
|
629
627
|
readReference(reference, options = {}) {
|
|
630
|
-
const refString = reference
|
|
628
|
+
const refString = reference?.reference;
|
|
631
629
|
if (!refString) {
|
|
632
630
|
return new ReadablePromise(Promise.reject(new Error('Missing reference')));
|
|
633
631
|
}
|
|
@@ -655,12 +653,11 @@ class MedplumClient extends EventTarget {
|
|
|
655
653
|
* @param resourceType The FHIR resource type.
|
|
656
654
|
* @returns Promise to a schema with the requested resource type.
|
|
657
655
|
*/
|
|
658
|
-
requestSchema(resourceType) {
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
const query = `{
|
|
656
|
+
async requestSchema(resourceType) {
|
|
657
|
+
if (resourceType in globalSchema.types) {
|
|
658
|
+
return globalSchema;
|
|
659
|
+
}
|
|
660
|
+
const query = `{
|
|
664
661
|
StructureDefinitionList(name: "${resourceType}") {
|
|
665
662
|
name,
|
|
666
663
|
description,
|
|
@@ -689,15 +686,14 @@ class MedplumClient extends EventTarget {
|
|
|
689
686
|
target
|
|
690
687
|
}
|
|
691
688
|
}`.replace(/\s+/g, ' ');
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
});
|
|
689
|
+
const response = (await this.graphql(query));
|
|
690
|
+
for (const structureDefinition of response.data.StructureDefinitionList) {
|
|
691
|
+
indexStructureDefinition(structureDefinition);
|
|
692
|
+
}
|
|
693
|
+
for (const searchParameter of response.data.SearchParameterList) {
|
|
694
|
+
indexSearchParameter(searchParameter);
|
|
695
|
+
}
|
|
696
|
+
return globalSchema;
|
|
701
697
|
}
|
|
702
698
|
/**
|
|
703
699
|
* Reads resource history by resource type and ID.
|
|
@@ -835,11 +831,8 @@ class MedplumClient extends EventTarget {
|
|
|
835
831
|
* @param query The search query for an equivalent resource (should not include resource type or "?").
|
|
836
832
|
* @returns The result of the create operation.
|
|
837
833
|
*/
|
|
838
|
-
createResourceIfNoneExist(resource, query) {
|
|
839
|
-
|
|
840
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
841
|
-
return ((_a = (yield this.searchOne(resource.resourceType, query))) !== null && _a !== void 0 ? _a : this.createResource(resource));
|
|
842
|
-
});
|
|
834
|
+
async createResourceIfNoneExist(resource, query) {
|
|
835
|
+
return ((await this.searchOne(resource.resourceType, query)) ?? this.createResource(resource));
|
|
843
836
|
}
|
|
844
837
|
/**
|
|
845
838
|
* Creates a FHIR `Binary` resource with the provided data content.
|
|
@@ -926,14 +919,12 @@ class MedplumClient extends EventTarget {
|
|
|
926
919
|
* @param docDefinition The PDF document definition.
|
|
927
920
|
* @returns The result of the create operation.
|
|
928
921
|
*/
|
|
929
|
-
createPdf(docDefinition, filename, tableLayouts, fonts) {
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
return this.createBinary(blob, filename, 'application/pdf');
|
|
936
|
-
});
|
|
922
|
+
async createPdf(docDefinition, filename, tableLayouts, fonts) {
|
|
923
|
+
if (!__classPrivateFieldGet(this, _MedplumClient_createPdf, "f")) {
|
|
924
|
+
throw new Error('PDF creation not enabled');
|
|
925
|
+
}
|
|
926
|
+
const blob = await __classPrivateFieldGet(this, _MedplumClient_createPdf, "f").call(this, docDefinition, tableLayouts, fonts);
|
|
927
|
+
return this.createBinary(blob, filename, 'application/pdf');
|
|
937
928
|
}
|
|
938
929
|
/**
|
|
939
930
|
* Creates a FHIR `Communication` resource with the provided data content.
|
|
@@ -995,20 +986,18 @@ class MedplumClient extends EventTarget {
|
|
|
995
986
|
* @param resource The FHIR resource to update.
|
|
996
987
|
* @returns The result of the update operation.
|
|
997
988
|
*/
|
|
998
|
-
updateResource(resource) {
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
return result !== null && result !== void 0 ? result : resource;
|
|
1011
|
-
});
|
|
989
|
+
async updateResource(resource) {
|
|
990
|
+
if (!resource.resourceType) {
|
|
991
|
+
throw new Error('Missing resourceType');
|
|
992
|
+
}
|
|
993
|
+
if (!resource.id) {
|
|
994
|
+
throw new Error('Missing id');
|
|
995
|
+
}
|
|
996
|
+
this.invalidateSearches(resource.resourceType);
|
|
997
|
+
const result = await this.put(this.fhirUrl(resource.resourceType, resource.id), resource);
|
|
998
|
+
// On 304 not modified, result will be undefined
|
|
999
|
+
// Return the user input instead
|
|
1000
|
+
return result ?? resource;
|
|
1012
1001
|
}
|
|
1013
1002
|
/**
|
|
1014
1003
|
* Updates a FHIR resource using JSONPatch operations.
|
|
@@ -1243,18 +1232,16 @@ class MedplumClient extends EventTarget {
|
|
|
1243
1232
|
/**
|
|
1244
1233
|
* @category Authentication
|
|
1245
1234
|
*/
|
|
1246
|
-
setActiveLogin(login) {
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
yield __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_refreshProfile).call(this);
|
|
1257
|
-
});
|
|
1235
|
+
async setActiveLogin(login) {
|
|
1236
|
+
__classPrivateFieldSet(this, _MedplumClient_accessToken, login.accessToken, "f");
|
|
1237
|
+
__classPrivateFieldSet(this, _MedplumClient_refreshToken, login.refreshToken, "f");
|
|
1238
|
+
__classPrivateFieldSet(this, _MedplumClient_profile, undefined, "f");
|
|
1239
|
+
__classPrivateFieldSet(this, _MedplumClient_config, undefined, "f");
|
|
1240
|
+
__classPrivateFieldGet(this, _MedplumClient_storage, "f").setObject('activeLogin', login);
|
|
1241
|
+
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_addLogin).call(this, login);
|
|
1242
|
+
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").clear();
|
|
1243
|
+
__classPrivateFieldSet(this, _MedplumClient_refreshPromise, undefined, "f");
|
|
1244
|
+
await __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_refreshProfile).call(this);
|
|
1258
1245
|
}
|
|
1259
1246
|
/**
|
|
1260
1247
|
* @category Authentication
|
|
@@ -1275,8 +1262,7 @@ class MedplumClient extends EventTarget {
|
|
|
1275
1262
|
* @category Authentication
|
|
1276
1263
|
*/
|
|
1277
1264
|
getLogins() {
|
|
1278
|
-
|
|
1279
|
-
return (_a = __classPrivateFieldGet(this, _MedplumClient_storage, "f").getObject('logins')) !== null && _a !== void 0 ? _a : [];
|
|
1265
|
+
return __classPrivateFieldGet(this, _MedplumClient_storage, "f").getObject('logins') ?? [];
|
|
1280
1266
|
}
|
|
1281
1267
|
/**
|
|
1282
1268
|
* @category Authentication
|
|
@@ -1293,13 +1279,11 @@ class MedplumClient extends EventTarget {
|
|
|
1293
1279
|
/**
|
|
1294
1280
|
* @category User Profile
|
|
1295
1281
|
*/
|
|
1296
|
-
getProfileAsync() {
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
return this.getProfile();
|
|
1302
|
-
});
|
|
1282
|
+
async getProfileAsync() {
|
|
1283
|
+
if (__classPrivateFieldGet(this, _MedplumClient_profilePromise, "f")) {
|
|
1284
|
+
await __classPrivateFieldGet(this, _MedplumClient_profilePromise, "f");
|
|
1285
|
+
}
|
|
1286
|
+
return this.getProfile();
|
|
1303
1287
|
}
|
|
1304
1288
|
/**
|
|
1305
1289
|
* @category User Profile
|
|
@@ -1314,30 +1298,26 @@ class MedplumClient extends EventTarget {
|
|
|
1314
1298
|
* @param url The URL to request.
|
|
1315
1299
|
* @returns Promise to the response body as a blob.
|
|
1316
1300
|
*/
|
|
1317
|
-
download(url, options = {}) {
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
return response.blob();
|
|
1325
|
-
});
|
|
1301
|
+
async download(url, options = {}) {
|
|
1302
|
+
if (__classPrivateFieldGet(this, _MedplumClient_refreshPromise, "f")) {
|
|
1303
|
+
await __classPrivateFieldGet(this, _MedplumClient_refreshPromise, "f");
|
|
1304
|
+
}
|
|
1305
|
+
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_addFetchOptionsDefaults).call(this, options);
|
|
1306
|
+
const response = await __classPrivateFieldGet(this, _MedplumClient_fetch, "f").call(this, url.toString(), options);
|
|
1307
|
+
return response.blob();
|
|
1326
1308
|
}
|
|
1327
1309
|
/**
|
|
1328
1310
|
* Starts a new PKCE flow.
|
|
1329
1311
|
* These PKCE values are stateful, and must survive redirects and page refreshes.
|
|
1330
1312
|
*/
|
|
1331
|
-
startPkce() {
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
sessionStorage.setItem('codeChallenge', codeChallenge);
|
|
1340
|
-
});
|
|
1313
|
+
async startPkce() {
|
|
1314
|
+
const pkceState = getRandomString();
|
|
1315
|
+
sessionStorage.setItem('pkceState', pkceState);
|
|
1316
|
+
const codeVerifier = getRandomString();
|
|
1317
|
+
sessionStorage.setItem('codeVerifier', codeVerifier);
|
|
1318
|
+
const arrayHash = await encryptSHA256(codeVerifier);
|
|
1319
|
+
const codeChallenge = arrayBufferToBase64(arrayHash).replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '');
|
|
1320
|
+
sessionStorage.setItem('codeChallenge', codeChallenge);
|
|
1341
1321
|
}
|
|
1342
1322
|
/**
|
|
1343
1323
|
* Processes an OAuth authorization code.
|
|
@@ -1364,39 +1344,35 @@ class MedplumClient extends EventTarget {
|
|
|
1364
1344
|
* @param clientSecret The client secret.
|
|
1365
1345
|
* @returns Promise that resolves to the client profile.
|
|
1366
1346
|
*/
|
|
1367
|
-
startClientLogin(clientId, clientSecret) {
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_fetchTokens).call(this, formBody);
|
|
1376
|
-
});
|
|
1347
|
+
async startClientLogin(clientId, clientSecret) {
|
|
1348
|
+
__classPrivateFieldSet(this, _MedplumClient_clientId, clientId, "f");
|
|
1349
|
+
__classPrivateFieldSet(this, _MedplumClient_clientSecret, clientSecret, "f");
|
|
1350
|
+
const formBody = new URLSearchParams();
|
|
1351
|
+
formBody.set('grant_type', 'client_credentials');
|
|
1352
|
+
formBody.set('client_id', clientId);
|
|
1353
|
+
formBody.set('client_secret', clientSecret);
|
|
1354
|
+
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_fetchTokens).call(this, formBody);
|
|
1377
1355
|
}
|
|
1378
1356
|
}
|
|
1379
1357
|
_MedplumClient_fetch = new WeakMap(), _MedplumClient_createPdf = new WeakMap(), _MedplumClient_storage = new WeakMap(), _MedplumClient_requestCache = new WeakMap(), _MedplumClient_cacheTime = new WeakMap(), _MedplumClient_baseUrl = new WeakMap(), _MedplumClient_authorizeUrl = new WeakMap(), _MedplumClient_tokenUrl = new WeakMap(), _MedplumClient_logoutUrl = new WeakMap(), _MedplumClient_onUnauthenticated = new WeakMap(), _MedplumClient_clientId = new WeakMap(), _MedplumClient_clientSecret = new WeakMap(), _MedplumClient_accessToken = new WeakMap(), _MedplumClient_refreshToken = new WeakMap(), _MedplumClient_refreshPromise = new WeakMap(), _MedplumClient_profilePromise = new WeakMap(), _MedplumClient_profile = new WeakMap(), _MedplumClient_config = new WeakMap(), _MedplumClient_instances = new WeakSet(), _MedplumClient_addLogin = function _MedplumClient_addLogin(newLogin) {
|
|
1380
|
-
const logins = this.getLogins().filter((login) =>
|
|
1358
|
+
const logins = this.getLogins().filter((login) => login.profile?.reference !== newLogin.profile?.reference);
|
|
1381
1359
|
logins.push(newLogin);
|
|
1382
1360
|
__classPrivateFieldGet(this, _MedplumClient_storage, "f").setObject('logins', logins);
|
|
1383
|
-
}, _MedplumClient_refreshProfile = function _MedplumClient_refreshProfile() {
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
return __classPrivateFieldGet(this, _MedplumClient_profilePromise, "f");
|
|
1397
|
-
});
|
|
1361
|
+
}, _MedplumClient_refreshProfile = async function _MedplumClient_refreshProfile() {
|
|
1362
|
+
__classPrivateFieldSet(this, _MedplumClient_profilePromise, new Promise((resolve, reject) => {
|
|
1363
|
+
this.get('auth/me')
|
|
1364
|
+
.then((result) => {
|
|
1365
|
+
__classPrivateFieldSet(this, _MedplumClient_profilePromise, undefined, "f");
|
|
1366
|
+
__classPrivateFieldSet(this, _MedplumClient_profile, result.profile, "f");
|
|
1367
|
+
__classPrivateFieldSet(this, _MedplumClient_config, result.config, "f");
|
|
1368
|
+
this.dispatchEvent({ type: 'change' });
|
|
1369
|
+
resolve(__classPrivateFieldGet(this, _MedplumClient_profile, "f"));
|
|
1370
|
+
})
|
|
1371
|
+
.catch(reject);
|
|
1372
|
+
}), "f");
|
|
1373
|
+
return __classPrivateFieldGet(this, _MedplumClient_profilePromise, "f");
|
|
1398
1374
|
}, _MedplumClient_getCacheEntry = function _MedplumClient_getCacheEntry(key, options) {
|
|
1399
|
-
if (__classPrivateFieldGet(this, _MedplumClient_cacheTime, "f") <= 0 ||
|
|
1375
|
+
if (__classPrivateFieldGet(this, _MedplumClient_cacheTime, "f") <= 0 || options?.cache === 'no-cache' || options?.cache === 'reload') {
|
|
1400
1376
|
return undefined;
|
|
1401
1377
|
}
|
|
1402
1378
|
const entry = __classPrivateFieldGet(this, _MedplumClient_requestCache, "f").get(key);
|
|
@@ -1408,31 +1384,37 @@ _MedplumClient_fetch = new WeakMap(), _MedplumClient_createPdf = new WeakMap(),
|
|
|
1408
1384
|
if (__classPrivateFieldGet(this, _MedplumClient_cacheTime, "f") > 0) {
|
|
1409
1385
|
__classPrivateFieldGet(this, _MedplumClient_requestCache, "f").set(key, { requestTime: Date.now(), value });
|
|
1410
1386
|
}
|
|
1411
|
-
}, _MedplumClient_request =
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1387
|
+
}, _MedplumClient_request =
|
|
1388
|
+
/**
|
|
1389
|
+
* Makes an HTTP request.
|
|
1390
|
+
* @param {string} method
|
|
1391
|
+
* @param {string} url
|
|
1392
|
+
* @param {string=} contentType
|
|
1393
|
+
* @param {Object=} body
|
|
1394
|
+
*/
|
|
1395
|
+
async function _MedplumClient_request(method, url, options = {}) {
|
|
1396
|
+
if (__classPrivateFieldGet(this, _MedplumClient_refreshPromise, "f")) {
|
|
1397
|
+
await __classPrivateFieldGet(this, _MedplumClient_refreshPromise, "f");
|
|
1398
|
+
}
|
|
1399
|
+
if (!url.startsWith('http')) {
|
|
1400
|
+
url = __classPrivateFieldGet(this, _MedplumClient_baseUrl, "f") + url;
|
|
1401
|
+
}
|
|
1402
|
+
options.method = method;
|
|
1403
|
+
__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_addFetchOptionsDefaults).call(this, options);
|
|
1404
|
+
const response = await __classPrivateFieldGet(this, _MedplumClient_fetch, "f").call(this, url, options);
|
|
1405
|
+
if (response.status === 401) {
|
|
1406
|
+
// Refresh and try again
|
|
1407
|
+
return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_handleUnauthenticated).call(this, method, url, options);
|
|
1408
|
+
}
|
|
1409
|
+
if (response.status === 204 || response.status === 304) {
|
|
1410
|
+
// No content or change
|
|
1411
|
+
return undefined;
|
|
1412
|
+
}
|
|
1413
|
+
const obj = await response.json();
|
|
1414
|
+
if (response.status >= 400) {
|
|
1415
|
+
throw obj;
|
|
1416
|
+
}
|
|
1417
|
+
return obj;
|
|
1436
1418
|
}, _MedplumClient_addFetchOptionsDefaults = function _MedplumClient_addFetchOptionsDefaults(options) {
|
|
1437
1419
|
if (!options.headers) {
|
|
1438
1420
|
options.headers = {};
|
|
@@ -1476,18 +1458,22 @@ _MedplumClient_fetch = new WeakMap(), _MedplumClient_createPdf = new WeakMap(),
|
|
|
1476
1458
|
__classPrivateFieldGet(this, _MedplumClient_onUnauthenticated, "f").call(this);
|
|
1477
1459
|
}
|
|
1478
1460
|
return Promise.reject(new Error('Unauthenticated'));
|
|
1479
|
-
}, _MedplumClient_requestAuthorization =
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1461
|
+
}, _MedplumClient_requestAuthorization =
|
|
1462
|
+
/**
|
|
1463
|
+
* Redirects the user to the login screen for authorization.
|
|
1464
|
+
* Clears all auth state including local storage and session storage.
|
|
1465
|
+
* See: https://openid.net/specs/openid-connect-core-1_0.html#AuthorizationEndpoint
|
|
1466
|
+
*/
|
|
1467
|
+
async function _MedplumClient_requestAuthorization() {
|
|
1468
|
+
await this.startPkce();
|
|
1469
|
+
const url = new URL(__classPrivateFieldGet(this, _MedplumClient_authorizeUrl, "f"));
|
|
1470
|
+
url.searchParams.set('response_type', 'code');
|
|
1471
|
+
url.searchParams.set('state', sessionStorage.getItem('pkceState'));
|
|
1472
|
+
url.searchParams.set('client_id', __classPrivateFieldGet(this, _MedplumClient_clientId, "f"));
|
|
1473
|
+
url.searchParams.set('redirect_uri', getBaseUrl());
|
|
1474
|
+
url.searchParams.set('code_challenge_method', 'S256');
|
|
1475
|
+
url.searchParams.set('code_challenge', sessionStorage.getItem('codeChallenge'));
|
|
1476
|
+
window.location.assign(url.toString());
|
|
1491
1477
|
}, _MedplumClient_refresh = function _MedplumClient_refresh() {
|
|
1492
1478
|
if (__classPrivateFieldGet(this, _MedplumClient_refreshPromise, "f")) {
|
|
1493
1479
|
return __classPrivateFieldGet(this, _MedplumClient_refreshPromise, "f");
|
|
@@ -1505,43 +1491,52 @@ _MedplumClient_fetch = new WeakMap(), _MedplumClient_createPdf = new WeakMap(),
|
|
|
1505
1491
|
return __classPrivateFieldGet(this, _MedplumClient_refreshPromise, "f");
|
|
1506
1492
|
}
|
|
1507
1493
|
return undefined;
|
|
1508
|
-
}, _MedplumClient_fetchTokens =
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
});
|
|
1525
|
-
}, _MedplumClient_verifyTokens = function _MedplumClient_verifyTokens(tokens) {
|
|
1526
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
1527
|
-
const token = tokens.access_token;
|
|
1528
|
-
// Verify token has not expired
|
|
1529
|
-
const tokenPayload = parseJWTPayload(token);
|
|
1530
|
-
if (Date.now() >= tokenPayload.exp * 1000) {
|
|
1531
|
-
this.clear();
|
|
1532
|
-
throw new Error('Token expired');
|
|
1533
|
-
}
|
|
1534
|
-
// Verify app_client_id
|
|
1535
|
-
if (__classPrivateFieldGet(this, _MedplumClient_clientId, "f") && tokenPayload.client_id !== __classPrivateFieldGet(this, _MedplumClient_clientId, "f")) {
|
|
1536
|
-
this.clear();
|
|
1537
|
-
throw new Error('Token was not issued for this audience');
|
|
1494
|
+
}, _MedplumClient_fetchTokens =
|
|
1495
|
+
/**
|
|
1496
|
+
* Makes a POST request to the tokens endpoint.
|
|
1497
|
+
* See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint
|
|
1498
|
+
* @param formBody Token parameters in URL encoded format.
|
|
1499
|
+
*/
|
|
1500
|
+
async function _MedplumClient_fetchTokens(formBody) {
|
|
1501
|
+
return __classPrivateFieldGet(this, _MedplumClient_fetch, "f").call(this, __classPrivateFieldGet(this, _MedplumClient_tokenUrl, "f"), {
|
|
1502
|
+
method: 'POST',
|
|
1503
|
+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
|
|
1504
|
+
body: formBody,
|
|
1505
|
+
credentials: 'include',
|
|
1506
|
+
})
|
|
1507
|
+
.then((response) => {
|
|
1508
|
+
if (!response.ok) {
|
|
1509
|
+
throw new Error('Failed to fetch tokens');
|
|
1538
1510
|
}
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1511
|
+
return response.json();
|
|
1512
|
+
})
|
|
1513
|
+
.then((tokens) => __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_verifyTokens).call(this, tokens))
|
|
1514
|
+
.then(() => this.getProfile());
|
|
1515
|
+
}, _MedplumClient_verifyTokens =
|
|
1516
|
+
/**
|
|
1517
|
+
* Verifies the tokens received from the auth server.
|
|
1518
|
+
* Validates the JWT against the JWKS.
|
|
1519
|
+
* See: https://openid.net/specs/openid-connect-core-1_0.html#TokenEndpoint
|
|
1520
|
+
* @param tokens
|
|
1521
|
+
*/
|
|
1522
|
+
async function _MedplumClient_verifyTokens(tokens) {
|
|
1523
|
+
const token = tokens.access_token;
|
|
1524
|
+
// Verify token has not expired
|
|
1525
|
+
const tokenPayload = parseJWTPayload(token);
|
|
1526
|
+
if (Date.now() >= tokenPayload.exp * 1000) {
|
|
1527
|
+
this.clear();
|
|
1528
|
+
throw new Error('Token expired');
|
|
1529
|
+
}
|
|
1530
|
+
// Verify app_client_id
|
|
1531
|
+
if (__classPrivateFieldGet(this, _MedplumClient_clientId, "f") && tokenPayload.client_id !== __classPrivateFieldGet(this, _MedplumClient_clientId, "f")) {
|
|
1532
|
+
this.clear();
|
|
1533
|
+
throw new Error('Token was not issued for this audience');
|
|
1534
|
+
}
|
|
1535
|
+
await this.setActiveLogin({
|
|
1536
|
+
accessToken: token,
|
|
1537
|
+
refreshToken: tokens.refresh_token,
|
|
1538
|
+
project: tokens.project,
|
|
1539
|
+
profile: tokens.profile,
|
|
1545
1540
|
});
|
|
1546
1541
|
}, _MedplumClient_setupStorageListener = function _MedplumClient_setupStorageListener() {
|
|
1547
1542
|
try {
|
|
@@ -1573,4 +1568,4 @@ function ensureTrailingSlash(url) {
|
|
|
1573
1568
|
}
|
|
1574
1569
|
|
|
1575
1570
|
export { MEDPLUM_VERSION, MedplumClient };
|
|
1576
|
-
//# sourceMappingURL=client.
|
|
1571
|
+
//# sourceMappingURL=client.mjs.map
|