@medplum/core 2.0.0 → 2.0.2

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.
@@ -1 +1 @@
1
- {"version":3,"file":"base-schema.json.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -71,6 +71,14 @@ export interface MedplumClientOptions {
71
71
  * See: https://developer.mozilla.org/en-US/docs/Web/API/Request/cache
72
72
  */
73
73
  cacheTime?: number;
74
+ /**
75
+ * The length of time in milliseconds to delay requests for auto batching.
76
+ *
77
+ * Auto batching attempts to group multiple requests together into a single batch request.
78
+ *
79
+ * Default value is 0, which disables auto batching.
80
+ */
81
+ autoBatchTime?: number;
74
82
  /**
75
83
  * Fetch implementation.
76
84
  *
@@ -216,7 +224,7 @@ export interface BotEvent<T = Resource | Hl7Message | string | Record<string, an
216
224
  }
217
225
  /**
218
226
  * JSONPatch patch operation.
219
- * Compatible with fast-json-patch Operation.
227
+ * Compatible with fast-json-patch and rfc6902 Operation.
220
228
  */
221
229
  export interface PatchOperation {
222
230
  readonly op: 'add' | 'remove' | 'replace' | 'copy' | 'move' | 'test';
@@ -488,7 +496,7 @@ export declare class MedplumClient extends EventTarget {
488
496
  * Does not invalidate tokens with the server.
489
497
  * @category Authentication
490
498
  */
491
- signOut(): void;
499
+ signOut(): Promise<void>;
492
500
  /**
493
501
  * Tries to sign in the user.
494
502
  * Returns true if the user is signed in.
@@ -503,6 +511,14 @@ export declare class MedplumClient extends EventTarget {
503
511
  * @category Authentication
504
512
  */
505
513
  signOutWithRedirect(): void;
514
+ /**
515
+ * Initiates sign in with an external identity provider.
516
+ * @param authorizeUrl The external authorization URL.
517
+ * @param clientId The external client ID.
518
+ * @param redirectUri The external identity provider redirect URI.
519
+ * @param baseLogin The Medplum login request.
520
+ */
521
+ signInWithExternalAuth(authorizeUrl: string, clientId: string, redirectUri: string, baseLogin: BaseLoginRequest): Promise<void>;
506
522
  /**
507
523
  * Builds a FHIR URL from a collection of URL path components.
508
524
  * For example, `buildUrl('/Patient', '123')` returns `fhir/R4/Patient/123`.
@@ -10,8 +10,8 @@ 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
- 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 = "2.0.0-7fe99080";
13
+ var _MedplumClient_instances, _MedplumClient_fetch, _MedplumClient_createPdf, _MedplumClient_storage, _MedplumClient_requestCache, _MedplumClient_cacheTime, _MedplumClient_baseUrl, _MedplumClient_fhirBaseUrl, _MedplumClient_authorizeUrl, _MedplumClient_tokenUrl, _MedplumClient_logoutUrl, _MedplumClient_onUnauthenticated, _MedplumClient_autoBatchTime, _MedplumClient_autoBatchQueue, _MedplumClient_clientId, _MedplumClient_clientSecret, _MedplumClient_autoBatchTimerId, _MedplumClient_accessToken, _MedplumClient_refreshToken, _MedplumClient_refreshPromise, _MedplumClient_profilePromise, _MedplumClient_profile, _MedplumClient_config, _MedplumClient_addLogin, _MedplumClient_refreshProfile, _MedplumClient_getCacheEntry, _MedplumClient_setCacheEntry, _MedplumClient_request, _MedplumClient_executeAutoBatch, _MedplumClient_addFetchOptionsDefaults, _MedplumClient_setRequestContentType, _MedplumClient_setRequestBody, _MedplumClient_handleUnauthenticated, _MedplumClient_requestAuthorization, _MedplumClient_refresh, _MedplumClient_fetchTokens, _MedplumClient_verifyTokens, _MedplumClient_setupStorageListener;
14
+ const MEDPLUM_VERSION = "2.0.2-2d479f42";
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
@@ -80,12 +80,16 @@ class MedplumClient extends EventTarget {
80
80
  _MedplumClient_requestCache.set(this, void 0);
81
81
  _MedplumClient_cacheTime.set(this, void 0);
82
82
  _MedplumClient_baseUrl.set(this, void 0);
83
+ _MedplumClient_fhirBaseUrl.set(this, void 0);
83
84
  _MedplumClient_authorizeUrl.set(this, void 0);
84
85
  _MedplumClient_tokenUrl.set(this, void 0);
85
86
  _MedplumClient_logoutUrl.set(this, void 0);
86
87
  _MedplumClient_onUnauthenticated.set(this, void 0);
88
+ _MedplumClient_autoBatchTime.set(this, void 0);
89
+ _MedplumClient_autoBatchQueue.set(this, void 0);
87
90
  _MedplumClient_clientId.set(this, void 0);
88
91
  _MedplumClient_clientSecret.set(this, void 0);
92
+ _MedplumClient_autoBatchTimerId.set(this, void 0);
89
93
  _MedplumClient_accessToken.set(this, void 0);
90
94
  _MedplumClient_refreshToken.set(this, void 0);
91
95
  _MedplumClient_refreshPromise.set(this, void 0);
@@ -97,17 +101,20 @@ class MedplumClient extends EventTarget {
97
101
  throw new Error('Base URL must start with http or https');
98
102
  }
99
103
  }
100
- __classPrivateFieldSet(this, _MedplumClient_fetch, options?.fetch || window.fetch.bind(window), "f");
104
+ __classPrivateFieldSet(this, _MedplumClient_fetch, options?.fetch || getDefaultFetch(), "f");
101
105
  __classPrivateFieldSet(this, _MedplumClient_createPdf, options?.createPdf, "f");
102
106
  __classPrivateFieldSet(this, _MedplumClient_storage, new ClientStorage(), "f");
103
107
  __classPrivateFieldSet(this, _MedplumClient_requestCache, new LRUCache(options?.resourceCacheSize ?? DEFAULT_RESOURCE_CACHE_SIZE), "f");
104
108
  __classPrivateFieldSet(this, _MedplumClient_cacheTime, options?.cacheTime ?? DEFAULT_CACHE_TIME, "f");
105
109
  __classPrivateFieldSet(this, _MedplumClient_baseUrl, ensureTrailingSlash(options?.baseUrl) || DEFAULT_BASE_URL, "f");
110
+ __classPrivateFieldSet(this, _MedplumClient_fhirBaseUrl, __classPrivateFieldGet(this, _MedplumClient_baseUrl, "f") + 'fhir/R4/', "f");
106
111
  __classPrivateFieldSet(this, _MedplumClient_clientId, options?.clientId || '', "f");
107
112
  __classPrivateFieldSet(this, _MedplumClient_authorizeUrl, options?.authorizeUrl || __classPrivateFieldGet(this, _MedplumClient_baseUrl, "f") + 'oauth2/authorize', "f");
108
113
  __classPrivateFieldSet(this, _MedplumClient_tokenUrl, options?.tokenUrl || __classPrivateFieldGet(this, _MedplumClient_baseUrl, "f") + 'oauth2/token', "f");
109
114
  __classPrivateFieldSet(this, _MedplumClient_logoutUrl, options?.logoutUrl || __classPrivateFieldGet(this, _MedplumClient_baseUrl, "f") + 'oauth2/logout', "f");
110
115
  __classPrivateFieldSet(this, _MedplumClient_onUnauthenticated, options?.onUnauthenticated, "f");
116
+ __classPrivateFieldSet(this, _MedplumClient_autoBatchTime, options?.autoBatchTime ?? 0, "f");
117
+ __classPrivateFieldSet(this, _MedplumClient_autoBatchQueue, [], "f");
111
118
  const activeLogin = this.getActiveLogin();
112
119
  if (activeLogin) {
113
120
  __classPrivateFieldSet(this, _MedplumClient_accessToken, activeLogin.accessToken, "f");
@@ -188,9 +195,27 @@ class MedplumClient extends EventTarget {
188
195
  if (cached) {
189
196
  return cached.value;
190
197
  }
191
- const promise = new ReadablePromise(__classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'GET', url, options));
192
- __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setCacheEntry).call(this, url, promise);
193
- return promise;
198
+ let promise;
199
+ if (url.startsWith(__classPrivateFieldGet(this, _MedplumClient_fhirBaseUrl, "f")) && __classPrivateFieldGet(this, _MedplumClient_autoBatchTime, "f") > 0) {
200
+ promise = new Promise((resolve, reject) => {
201
+ __classPrivateFieldGet(this, _MedplumClient_autoBatchQueue, "f").push({
202
+ method: 'GET',
203
+ url: url.replace(__classPrivateFieldGet(this, _MedplumClient_fhirBaseUrl, "f"), ''),
204
+ options,
205
+ resolve,
206
+ reject,
207
+ });
208
+ if (!__classPrivateFieldGet(this, _MedplumClient_autoBatchTimerId, "f")) {
209
+ __classPrivateFieldSet(this, _MedplumClient_autoBatchTimerId, setTimeout(() => __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_executeAutoBatch).call(this), __classPrivateFieldGet(this, _MedplumClient_autoBatchTime, "f")), "f");
210
+ }
211
+ });
212
+ }
213
+ else {
214
+ promise = __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, 'GET', url, options);
215
+ }
216
+ const readablePromise = new ReadablePromise(promise);
217
+ __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_setCacheEntry).call(this, url, readablePromise);
218
+ return readablePromise;
194
219
  }
195
220
  /**
196
221
  * Makes an HTTP POST request to the specified URL.
@@ -368,7 +393,8 @@ class MedplumClient extends EventTarget {
368
393
  * Does not invalidate tokens with the server.
369
394
  * @category Authentication
370
395
  */
371
- signOut() {
396
+ async signOut() {
397
+ await this.post(__classPrivateFieldGet(this, _MedplumClient_logoutUrl, "f"), {});
372
398
  this.clear();
373
399
  }
374
400
  /**
@@ -397,6 +423,23 @@ class MedplumClient extends EventTarget {
397
423
  signOutWithRedirect() {
398
424
  window.location.assign(__classPrivateFieldGet(this, _MedplumClient_logoutUrl, "f"));
399
425
  }
426
+ /**
427
+ * Initiates sign in with an external identity provider.
428
+ * @param authorizeUrl The external authorization URL.
429
+ * @param clientId The external client ID.
430
+ * @param redirectUri The external identity provider redirect URI.
431
+ * @param baseLogin The Medplum login request.
432
+ */
433
+ async signInWithExternalAuth(authorizeUrl, clientId, redirectUri, baseLogin) {
434
+ const loginRequest = await this.ensureCodeChallenge(baseLogin);
435
+ const url = new URL(authorizeUrl);
436
+ url.searchParams.set('response_type', 'code');
437
+ url.searchParams.set('client_id', clientId);
438
+ url.searchParams.set('redirect_uri', redirectUri);
439
+ url.searchParams.set('scope', 'openid profile email');
440
+ url.searchParams.set('state', JSON.stringify(loginRequest));
441
+ window.location.assign(url.toString());
442
+ }
400
443
  /**
401
444
  * Builds a FHIR URL from a collection of URL path components.
402
445
  * For example, `buildUrl('/Patient', '123')` returns `fhir/R4/Patient/123`.
@@ -405,7 +448,7 @@ class MedplumClient extends EventTarget {
405
448
  * @returns The well-formed FHIR URL.
406
449
  */
407
450
  fhirUrl(...path) {
408
- return new URL(__classPrivateFieldGet(this, _MedplumClient_baseUrl, "f") + 'fhir/R4/' + path.join('/'));
451
+ return new URL(__classPrivateFieldGet(this, _MedplumClient_fhirBaseUrl, "f") + path.join('/'));
409
452
  }
410
453
  /**
411
454
  * Builds a FHIR search URL from a search query or structured query object.
@@ -1330,7 +1373,7 @@ class MedplumClient extends EventTarget {
1330
1373
  formBody.set('grant_type', 'authorization_code');
1331
1374
  formBody.set('client_id', __classPrivateFieldGet(this, _MedplumClient_clientId, "f"));
1332
1375
  formBody.set('code', code);
1333
- formBody.set('redirect_uri', getBaseUrl());
1376
+ formBody.set('redirect_uri', getWindowOrigin());
1334
1377
  const codeVerifier = sessionStorage.getItem('codeVerifier');
1335
1378
  if (codeVerifier) {
1336
1379
  formBody.set('code_verifier', codeVerifier);
@@ -1355,7 +1398,7 @@ class MedplumClient extends EventTarget {
1355
1398
  return __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_fetchTokens).call(this, formBody);
1356
1399
  }
1357
1400
  }
1358
- _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) {
1401
+ _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_fhirBaseUrl = new WeakMap(), _MedplumClient_authorizeUrl = new WeakMap(), _MedplumClient_tokenUrl = new WeakMap(), _MedplumClient_logoutUrl = new WeakMap(), _MedplumClient_onUnauthenticated = new WeakMap(), _MedplumClient_autoBatchTime = new WeakMap(), _MedplumClient_autoBatchQueue = new WeakMap(), _MedplumClient_clientId = new WeakMap(), _MedplumClient_clientSecret = new WeakMap(), _MedplumClient_autoBatchTimerId = 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) {
1359
1402
  const logins = this.getLogins().filter((login) => login.profile?.reference !== newLogin.profile?.reference);
1360
1403
  logins.push(newLogin);
1361
1404
  __classPrivateFieldGet(this, _MedplumClient_storage, "f").setObject('logins', logins);
@@ -1416,6 +1459,43 @@ async function _MedplumClient_request(method, url, options = {}) {
1416
1459
  throw obj;
1417
1460
  }
1418
1461
  return obj;
1462
+ }, _MedplumClient_executeAutoBatch =
1463
+ /**
1464
+ * Executes a batch of requests that were automatically batched together.
1465
+ */
1466
+ async function _MedplumClient_executeAutoBatch() {
1467
+ // Get the current queue
1468
+ const entries = [...__classPrivateFieldGet(this, _MedplumClient_autoBatchQueue, "f")];
1469
+ // Clear the queue
1470
+ __classPrivateFieldGet(this, _MedplumClient_autoBatchQueue, "f").length = 0;
1471
+ // Clear the timer
1472
+ __classPrivateFieldSet(this, _MedplumClient_autoBatchTimerId, undefined, "f");
1473
+ // If there is only one request in the batch, just execute it
1474
+ if (entries.length === 1) {
1475
+ const entry = entries[0];
1476
+ entry.resolve(await __classPrivateFieldGet(this, _MedplumClient_instances, "m", _MedplumClient_request).call(this, entry.method, __classPrivateFieldGet(this, _MedplumClient_fhirBaseUrl, "f") + entry.url, entry.options));
1477
+ return;
1478
+ }
1479
+ // Build the batch request
1480
+ const batch = {
1481
+ resourceType: 'Bundle',
1482
+ type: 'batch',
1483
+ entry: entries.map((e) => ({
1484
+ request: {
1485
+ method: e.method,
1486
+ url: e.url,
1487
+ },
1488
+ resource: e.options.body ? JSON.parse(e.options.body) : undefined,
1489
+ })),
1490
+ };
1491
+ // Execute the batch request
1492
+ const response = (await this.post('fhir/R4', batch));
1493
+ // Process the response
1494
+ for (let i = 0; i < entries.length; i++) {
1495
+ const entry = entries[i];
1496
+ const responseEntry = response.entry?.[i];
1497
+ entry.resolve(responseEntry?.resource);
1498
+ }
1419
1499
  }, _MedplumClient_addFetchOptionsDefaults = function _MedplumClient_addFetchOptionsDefaults(options) {
1420
1500
  if (!options.headers) {
1421
1501
  options.headers = {};
@@ -1471,7 +1551,7 @@ async function _MedplumClient_requestAuthorization(loginParams) {
1471
1551
  url.searchParams.set('response_type', 'code');
1472
1552
  url.searchParams.set('state', sessionStorage.getItem('pkceState'));
1473
1553
  url.searchParams.set('client_id', loginRequest.clientId || __classPrivateFieldGet(this, _MedplumClient_clientId, "f"));
1474
- url.searchParams.set('redirect_uri', loginRequest.redirectUri || getBaseUrl());
1554
+ url.searchParams.set('redirect_uri', loginRequest.redirectUri || getWindowOrigin());
1475
1555
  url.searchParams.set('code_challenge_method', loginRequest.codeChallengeMethod);
1476
1556
  url.searchParams.set('code_challenge', loginRequest.codeChallenge);
1477
1557
  url.searchParams.set('scope', loginRequest.scope || 'openid profile');
@@ -1554,12 +1634,34 @@ async function _MedplumClient_verifyTokens(tokens) {
1554
1634
  // Silently ignore if this environment does not support storage events
1555
1635
  }
1556
1636
  };
1637
+ /**
1638
+ * Returns the current window if available.
1639
+ * All access to the current window should use this to support SSR such as Next.js.
1640
+ * @returns The current window or undefined if not available.
1641
+ */
1642
+ function getWindow() {
1643
+ return typeof window === 'undefined' ? undefined : window;
1644
+ }
1645
+ /**
1646
+ * Returns the default fetch method.
1647
+ * The default fetch is currently only available in browser environments.
1648
+ * If you want to use SSR such as Next.js, you should pass a custom fetch function.
1649
+ * @returns The default fetch function for the current environment.
1650
+ */
1651
+ function getDefaultFetch() {
1652
+ const window = getWindow();
1653
+ if (!window) {
1654
+ throw new Error('Fetch not available in this environment');
1655
+ }
1656
+ return window.fetch.bind(window);
1657
+ }
1557
1658
  /**
1558
1659
  * Returns the base URL for the current page.
1559
1660
  * @category HTTP
1560
1661
  */
1561
- function getBaseUrl() {
1562
- return window.location.protocol + '//' + window.location.host + '/';
1662
+ function getWindowOrigin() {
1663
+ const window = getWindow();
1664
+ return window ? window.location.protocol + '//' + window.location.host + '/' : '';
1563
1665
  }
1564
1666
  function ensureTrailingSlash(url) {
1565
1667
  if (!url) {