@atlaskit/media-client 27.4.0 → 27.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @atlaskit/media-client
2
2
 
3
+ ## 27.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [`eaacfc7b03414`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/eaacfc7b03414) -
8
+ Changed the feature flag used for analytics publishing to prevent spamming due to cached clients
9
+ using bugged versions of Card
10
+
11
+ ## 27.5.0
12
+
13
+ ### Minor Changes
14
+
15
+ - [#132649](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/132649)
16
+ [`ab55ae1b17d7d`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/ab55ae1b17d7d) -
17
+ add media cdn single host redirect
18
+
3
19
  ## 27.4.0
4
20
 
5
21
  ### Minor Changes
@@ -16,6 +16,7 @@ var _constants = require("../../constants");
16
16
  var _artifacts = require("../../models/artifacts");
17
17
  var _request3 = require("../../utils/request");
18
18
  var _helpers = require("../../utils/request/helpers");
19
+ var _mediaCdn = require("../../utils/mediaCdn");
19
20
  var _resolveAuth = require("./resolveAuth");
20
21
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
21
22
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
@@ -292,7 +293,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
292
293
  auth: auth
293
294
  };
294
295
  var imageEndpoint = (0, _platformFeatureFlags.fg)('platform.media-cdn-delivery') ? 'image/cdn' : 'image';
295
- return (0, _helpers.createUrl)("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(imageEndpoint), options);
296
+ return (0, _mediaCdn.mapToMediaCdnUrl)((0, _helpers.createUrl)("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(imageEndpoint), options));
296
297
  }
297
298
  }, {
298
299
  key: "getFileBinary",
@@ -324,7 +325,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
324
325
  'max-age': "".concat(maxAge)
325
326
  }
326
327
  });
327
- return _context5.abrupt("return", this.request("/file/".concat(id, "/").concat(binaryEndpoint), options).then((0, _helpers.createMapResponseToBlob)(metadata)));
328
+ return _context5.abrupt("return", this.request("/file/".concat(id, "/").concat(binaryEndpoint), options, undefined, true).then((0, _helpers.createMapResponseToBlob)(metadata)));
328
329
  case 6:
329
330
  case "end":
330
331
  return _context5.stop();
@@ -364,7 +365,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
364
365
  auth: auth
365
366
  };
366
367
  binaryEndpoint = (0, _platformFeatureFlags.fg)('platform.media-cdn-delivery') ? 'binary/cdn' : 'binary';
367
- return _context6.abrupt("return", (0, _helpers.createUrl)("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options));
368
+ return _context6.abrupt("return", (0, _mediaCdn.mapToMediaCdnUrl)((0, _helpers.createUrl)("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options)));
368
369
  case 7:
369
370
  case "end":
370
371
  return _context6.stop();
@@ -442,9 +443,9 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
442
443
  params: extendImageParams(params, fetchMaxRes),
443
444
  headers: headers,
444
445
  traceContext: traceContext,
445
- addMediaClientParam: (0, _platformFeatureFlags.fg)('platform.media-card-performance-observer_lgc7b') && true
446
+ addMediaClientParam: (0, _platformFeatureFlags.fg)('platform.media-card-performance-observer_a803k') && true
446
447
  });
447
- return _context8.abrupt("return", this.request("/file/".concat(id, "/").concat(imageEndpoint), options, controller).then((0, _helpers.createMapResponseToBlob)(metadata)));
448
+ return _context8.abrupt("return", this.request("/file/".concat(id, "/").concat(imageEndpoint), options, controller, true).then((0, _helpers.createMapResponseToBlob)(metadata)));
448
449
  case 7:
449
450
  case "end":
450
451
  return _context8.stop();
@@ -588,6 +589,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
588
589
  var _request2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee12(path) {
589
590
  var options,
590
591
  controller,
592
+ useMediaCdn,
591
593
  method,
592
594
  endpoint,
593
595
  authContext,
@@ -600,6 +602,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
600
602
  auth,
601
603
  clientId,
602
604
  extendedTraceContext,
605
+ url,
603
606
  response,
604
607
  _args12 = arguments;
605
608
  return _regenerator.default.wrap(function _callee12$(_context12) {
@@ -611,17 +614,22 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
611
614
  authContext: {}
612
615
  };
613
616
  controller = _args12.length > 2 ? _args12[2] : undefined;
617
+ useMediaCdn = _args12.length > 3 ? _args12[3] : undefined;
614
618
  method = options.method, endpoint = options.endpoint, authContext = options.authContext, params = options.params, headers = options.headers, body = options.body, clientOptions = options.clientOptions, traceContext = options.traceContext, addMediaClientParam = options.addMediaClientParam;
615
- _context12.next = 5;
619
+ _context12.next = 6;
616
620
  return this.resolveAuth(authContext);
617
- case 5:
621
+ case 6:
618
622
  auth = _context12.sent;
619
623
  clientId = (0, _mediaCore.isClientBasedAuth)(auth) ? auth.clientId : undefined;
620
624
  extendedTraceContext = traceContext ? _objectSpread(_objectSpread({}, traceContext), {}, {
621
625
  spanId: (traceContext === null || traceContext === void 0 ? void 0 : traceContext.spanId) || (0, _mediaCommon.getRandomHex)(8)
622
626
  }) : undefined;
623
- _context12.next = 10;
624
- return (0, _request3.request)("".concat(auth.baseUrl).concat(path), {
627
+ url = "".concat(auth.baseUrl).concat(path);
628
+ if (useMediaCdn) {
629
+ url = (0, _mediaCdn.mapToMediaCdnUrl)(url);
630
+ }
631
+ _context12.next = 13;
632
+ return (0, _request3.request)(url, {
625
633
  method: method,
626
634
  endpoint: endpoint,
627
635
  auth: auth,
@@ -633,12 +641,12 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
633
641
  clientOptions: clientOptions,
634
642
  traceContext: extendedTraceContext
635
643
  }, controller);
636
- case 10:
644
+ case 13:
637
645
  response = _context12.sent;
638
646
  setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
639
647
  setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
640
648
  return _context12.abrupt("return", response);
641
- case 14:
649
+ case 17:
642
650
  case "end":
643
651
  return _context12.stop();
644
652
  }
@@ -5,11 +5,12 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getArtifactUrl = void 0;
7
7
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
8
+ var _mediaCdn = require("../utils/mediaCdn");
8
9
  var getArtifactUrl = exports.getArtifactUrl = function getArtifactUrl(artifacts, prop) {
9
10
  var _artifacts$prop2;
10
11
  if ((0, _platformFeatureFlags.fg)('platform.media-cdn-delivery')) {
11
12
  var _artifacts$prop;
12
- return "".concat((_artifacts$prop = artifacts[prop]) === null || _artifacts$prop === void 0 ? void 0 : _artifacts$prop.url, "/cdn");
13
+ return (0, _mediaCdn.mapToMediaCdnUrl)("".concat((_artifacts$prop = artifacts[prop]) === null || _artifacts$prop === void 0 ? void 0 : _artifacts$prop.url, "/cdn"));
13
14
  }
14
15
  return (_artifacts$prop2 = artifacts[prop]) === null || _artifacts$prop2 === void 0 ? void 0 : _artifacts$prop2.url;
15
16
  };
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.MEDIA_CDN_MAP = void 0;
7
+ exports.mapToMediaCdnUrl = mapToMediaCdnUrl;
8
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
+ var MEDIA_CDN_MAP = exports.MEDIA_CDN_MAP = {
10
+ 'api.media.atlassian.com': 'media-cdn.atlassian.com',
11
+ 'media.staging.atl-paas.net': 'media-cdn.stg.atlassian.com'
12
+ };
13
+ function mapToMediaCdnUrl(url) {
14
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
15
+ if ((0, _platformFeatureFlags.fg)('platform.media-cdn-delivery') && (0, _platformFeatureFlags.fg)('platform.media-cdn-single-host')) {
16
+ try {
17
+ var parsedUrl = new URL(url);
18
+ var cdnHost = MEDIA_CDN_MAP[parsedUrl.host];
19
+
20
+ // If no mapping is found, return the original URL
21
+ if (!cdnHost) {
22
+ return url;
23
+ }
24
+
25
+ // Replace the host with the CDN host in the original URL
26
+ parsedUrl.host = cdnHost;
27
+ return parsedUrl.toString();
28
+ } catch (error) {
29
+ return url;
30
+ }
31
+ }
32
+ return url;
33
+ }
@@ -5,6 +5,7 @@ import { FILE_CACHE_MAX_AGE, MAX_RESOLUTION } from '../../constants';
5
5
  import { getArtifactUrl } from '../../models/artifacts';
6
6
  import { request } from '../../utils/request';
7
7
  import { createUrl, createMapResponseToJson, createMapResponseToBlob } from '../../utils/request/helpers';
8
+ import { mapToMediaCdnUrl } from '../../utils/mediaCdn';
8
9
  import { resolveAuth, resolveInitialAuth } from './resolveAuth';
9
10
  import { ChunkHashAlgorithm } from '@atlaskit/media-core';
10
11
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -187,7 +188,7 @@ export class MediaStore {
187
188
  auth
188
189
  };
189
190
  const imageEndpoint = fg('platform.media-cdn-delivery') ? 'image/cdn' : 'image';
190
- return createUrl(`${auth.baseUrl}/file/${id}/${imageEndpoint}`, options);
191
+ return mapToMediaCdnUrl(createUrl(`${auth.baseUrl}/file/${id}/${imageEndpoint}`, options));
191
192
  }
192
193
  async getFileBinary(id, collectionName, maxAge = FILE_CACHE_MAX_AGE) {
193
194
  const headers = {};
@@ -207,7 +208,7 @@ export class MediaStore {
207
208
  'max-age': `${maxAge}`
208
209
  }
209
210
  };
210
- return this.request(`/file/${id}/${binaryEndpoint}`, options).then(createMapResponseToBlob(metadata));
211
+ return this.request(`/file/${id}/${binaryEndpoint}`, options, undefined, true).then(createMapResponseToBlob(metadata));
211
212
  }
212
213
  async getFileBinaryURL(id, collectionName, maxAge = FILE_CACHE_MAX_AGE) {
213
214
  const auth = await this.resolveAuth({
@@ -222,7 +223,7 @@ export class MediaStore {
222
223
  auth
223
224
  };
224
225
  const binaryEndpoint = fg('platform.media-cdn-delivery') ? 'binary/cdn' : 'binary';
225
- return createUrl(`${auth.baseUrl}/file/${id}/${binaryEndpoint}`, options);
226
+ return mapToMediaCdnUrl(createUrl(`${auth.baseUrl}/file/${id}/${binaryEndpoint}`, options));
226
227
  }
227
228
  async getArtifactURL(artifacts, artifactName, collectionName) {
228
229
  const artifactUrl = getArtifactUrl(artifacts, artifactName);
@@ -261,9 +262,9 @@ export class MediaStore {
261
262
  params: extendImageParams(params, fetchMaxRes),
262
263
  headers,
263
264
  traceContext,
264
- addMediaClientParam: fg('platform.media-card-performance-observer_lgc7b') && true
265
+ addMediaClientParam: fg('platform.media-card-performance-observer_a803k') && true
265
266
  };
266
- return this.request(`/file/${id}/${imageEndpoint}`, options, controller).then(createMapResponseToBlob(metadata));
267
+ return this.request(`/file/${id}/${imageEndpoint}`, options, controller, true).then(createMapResponseToBlob(metadata));
267
268
  }
268
269
  async getItems(ids, collectionName, traceContext) {
269
270
  const descriptors = ids.map(id => ({
@@ -343,7 +344,7 @@ export class MediaStore {
343
344
  method: 'GET',
344
345
  endpoint: undefined,
345
346
  authContext: {}
346
- }, controller) {
347
+ }, controller, useMediaCdn) {
347
348
  const {
348
349
  method,
349
350
  endpoint,
@@ -361,7 +362,11 @@ export class MediaStore {
361
362
  ...traceContext,
362
363
  spanId: (traceContext === null || traceContext === void 0 ? void 0 : traceContext.spanId) || getRandomHex(8)
363
364
  } : undefined;
364
- const response = await request(`${auth.baseUrl}${path}`, {
365
+ let url = `${auth.baseUrl}${path}`;
366
+ if (useMediaCdn) {
367
+ url = mapToMediaCdnUrl(url);
368
+ }
369
+ const response = await request(url, {
365
370
  method,
366
371
  endpoint,
367
372
  auth,
@@ -1,9 +1,10 @@
1
1
  import { fg } from '@atlaskit/platform-feature-flags';
2
+ import { mapToMediaCdnUrl } from '../utils/mediaCdn';
2
3
  export const getArtifactUrl = (artifacts, prop) => {
3
4
  var _artifacts$prop2;
4
5
  if (fg('platform.media-cdn-delivery')) {
5
6
  var _artifacts$prop;
6
- return `${(_artifacts$prop = artifacts[prop]) === null || _artifacts$prop === void 0 ? void 0 : _artifacts$prop.url}/cdn`;
7
+ return mapToMediaCdnUrl(`${(_artifacts$prop = artifacts[prop]) === null || _artifacts$prop === void 0 ? void 0 : _artifacts$prop.url}/cdn`);
7
8
  }
8
9
  return (_artifacts$prop2 = artifacts[prop]) === null || _artifacts$prop2 === void 0 ? void 0 : _artifacts$prop2.url;
9
10
  };
@@ -0,0 +1,26 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
2
+ export const MEDIA_CDN_MAP = {
3
+ 'api.media.atlassian.com': 'media-cdn.atlassian.com',
4
+ 'media.staging.atl-paas.net': 'media-cdn.stg.atlassian.com'
5
+ };
6
+ export function mapToMediaCdnUrl(url) {
7
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
8
+ if (fg('platform.media-cdn-delivery') && fg('platform.media-cdn-single-host')) {
9
+ try {
10
+ const parsedUrl = new URL(url);
11
+ const cdnHost = MEDIA_CDN_MAP[parsedUrl.host];
12
+
13
+ // If no mapping is found, return the original URL
14
+ if (!cdnHost) {
15
+ return url;
16
+ }
17
+
18
+ // Replace the host with the CDN host in the original URL
19
+ parsedUrl.host = cdnHost;
20
+ return parsedUrl.toString();
21
+ } catch (error) {
22
+ return url;
23
+ }
24
+ }
25
+ return url;
26
+ }
@@ -11,6 +11,7 @@ import { FILE_CACHE_MAX_AGE, MAX_RESOLUTION } from '../../constants';
11
11
  import { getArtifactUrl } from '../../models/artifacts';
12
12
  import { request as _request } from '../../utils/request';
13
13
  import { createUrl, createMapResponseToJson, createMapResponseToBlob } from '../../utils/request/helpers';
14
+ import { mapToMediaCdnUrl } from '../../utils/mediaCdn';
14
15
  import { resolveAuth, resolveInitialAuth } from './resolveAuth';
15
16
  import { ChunkHashAlgorithm } from '@atlaskit/media-core';
16
17
  import { fg } from '@atlaskit/platform-feature-flags';
@@ -286,7 +287,7 @@ export var MediaStore = /*#__PURE__*/function () {
286
287
  auth: auth
287
288
  };
288
289
  var imageEndpoint = fg('platform.media-cdn-delivery') ? 'image/cdn' : 'image';
289
- return createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(imageEndpoint), options);
290
+ return mapToMediaCdnUrl(createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(imageEndpoint), options));
290
291
  }
291
292
  }, {
292
293
  key: "getFileBinary",
@@ -318,7 +319,7 @@ export var MediaStore = /*#__PURE__*/function () {
318
319
  'max-age': "".concat(maxAge)
319
320
  }
320
321
  });
321
- return _context5.abrupt("return", this.request("/file/".concat(id, "/").concat(binaryEndpoint), options).then(createMapResponseToBlob(metadata)));
322
+ return _context5.abrupt("return", this.request("/file/".concat(id, "/").concat(binaryEndpoint), options, undefined, true).then(createMapResponseToBlob(metadata)));
322
323
  case 6:
323
324
  case "end":
324
325
  return _context5.stop();
@@ -358,7 +359,7 @@ export var MediaStore = /*#__PURE__*/function () {
358
359
  auth: auth
359
360
  };
360
361
  binaryEndpoint = fg('platform.media-cdn-delivery') ? 'binary/cdn' : 'binary';
361
- return _context6.abrupt("return", createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options));
362
+ return _context6.abrupt("return", mapToMediaCdnUrl(createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options)));
362
363
  case 7:
363
364
  case "end":
364
365
  return _context6.stop();
@@ -436,9 +437,9 @@ export var MediaStore = /*#__PURE__*/function () {
436
437
  params: extendImageParams(params, fetchMaxRes),
437
438
  headers: headers,
438
439
  traceContext: traceContext,
439
- addMediaClientParam: fg('platform.media-card-performance-observer_lgc7b') && true
440
+ addMediaClientParam: fg('platform.media-card-performance-observer_a803k') && true
440
441
  });
441
- return _context8.abrupt("return", this.request("/file/".concat(id, "/").concat(imageEndpoint), options, controller).then(createMapResponseToBlob(metadata)));
442
+ return _context8.abrupt("return", this.request("/file/".concat(id, "/").concat(imageEndpoint), options, controller, true).then(createMapResponseToBlob(metadata)));
442
443
  case 7:
443
444
  case "end":
444
445
  return _context8.stop();
@@ -582,6 +583,7 @@ export var MediaStore = /*#__PURE__*/function () {
582
583
  var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(path) {
583
584
  var options,
584
585
  controller,
586
+ useMediaCdn,
585
587
  method,
586
588
  endpoint,
587
589
  authContext,
@@ -594,6 +596,7 @@ export var MediaStore = /*#__PURE__*/function () {
594
596
  auth,
595
597
  clientId,
596
598
  extendedTraceContext,
599
+ url,
597
600
  response,
598
601
  _args12 = arguments;
599
602
  return _regeneratorRuntime.wrap(function _callee12$(_context12) {
@@ -605,17 +608,22 @@ export var MediaStore = /*#__PURE__*/function () {
605
608
  authContext: {}
606
609
  };
607
610
  controller = _args12.length > 2 ? _args12[2] : undefined;
611
+ useMediaCdn = _args12.length > 3 ? _args12[3] : undefined;
608
612
  method = options.method, endpoint = options.endpoint, authContext = options.authContext, params = options.params, headers = options.headers, body = options.body, clientOptions = options.clientOptions, traceContext = options.traceContext, addMediaClientParam = options.addMediaClientParam;
609
- _context12.next = 5;
613
+ _context12.next = 6;
610
614
  return this.resolveAuth(authContext);
611
- case 5:
615
+ case 6:
612
616
  auth = _context12.sent;
613
617
  clientId = isClientBasedAuth(auth) ? auth.clientId : undefined;
614
618
  extendedTraceContext = traceContext ? _objectSpread(_objectSpread({}, traceContext), {}, {
615
619
  spanId: (traceContext === null || traceContext === void 0 ? void 0 : traceContext.spanId) || getRandomHex(8)
616
620
  }) : undefined;
617
- _context12.next = 10;
618
- return _request("".concat(auth.baseUrl).concat(path), {
621
+ url = "".concat(auth.baseUrl).concat(path);
622
+ if (useMediaCdn) {
623
+ url = mapToMediaCdnUrl(url);
624
+ }
625
+ _context12.next = 13;
626
+ return _request(url, {
619
627
  method: method,
620
628
  endpoint: endpoint,
621
629
  auth: auth,
@@ -627,12 +635,12 @@ export var MediaStore = /*#__PURE__*/function () {
627
635
  clientOptions: clientOptions,
628
636
  traceContext: extendedTraceContext
629
637
  }, controller);
630
- case 10:
638
+ case 13:
631
639
  response = _context12.sent;
632
640
  setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
633
641
  setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
634
642
  return _context12.abrupt("return", response);
635
- case 14:
643
+ case 17:
636
644
  case "end":
637
645
  return _context12.stop();
638
646
  }
@@ -1,9 +1,10 @@
1
1
  import { fg } from '@atlaskit/platform-feature-flags';
2
+ import { mapToMediaCdnUrl } from '../utils/mediaCdn';
2
3
  export var getArtifactUrl = function getArtifactUrl(artifacts, prop) {
3
4
  var _artifacts$prop2;
4
5
  if (fg('platform.media-cdn-delivery')) {
5
6
  var _artifacts$prop;
6
- return "".concat((_artifacts$prop = artifacts[prop]) === null || _artifacts$prop === void 0 ? void 0 : _artifacts$prop.url, "/cdn");
7
+ return mapToMediaCdnUrl("".concat((_artifacts$prop = artifacts[prop]) === null || _artifacts$prop === void 0 ? void 0 : _artifacts$prop.url, "/cdn"));
7
8
  }
8
9
  return (_artifacts$prop2 = artifacts[prop]) === null || _artifacts$prop2 === void 0 ? void 0 : _artifacts$prop2.url;
9
10
  };
@@ -0,0 +1,26 @@
1
+ import { fg } from '@atlaskit/platform-feature-flags';
2
+ export var MEDIA_CDN_MAP = {
3
+ 'api.media.atlassian.com': 'media-cdn.atlassian.com',
4
+ 'media.staging.atl-paas.net': 'media-cdn.stg.atlassian.com'
5
+ };
6
+ export function mapToMediaCdnUrl(url) {
7
+ // eslint-disable-next-line @atlaskit/platform/no-preconditioning
8
+ if (fg('platform.media-cdn-delivery') && fg('platform.media-cdn-single-host')) {
9
+ try {
10
+ var parsedUrl = new URL(url);
11
+ var cdnHost = MEDIA_CDN_MAP[parsedUrl.host];
12
+
13
+ // If no mapping is found, return the original URL
14
+ if (!cdnHost) {
15
+ return url;
16
+ }
17
+
18
+ // Replace the host with the CDN host in the original URL
19
+ parsedUrl.host = cdnHost;
20
+ return parsedUrl.toString();
21
+ } catch (error) {
22
+ return url;
23
+ }
24
+ }
25
+ return url;
26
+ }
@@ -28,7 +28,7 @@ export declare class MediaStore implements MediaApi {
28
28
  }>;
29
29
  appendChunksToUpload(uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
30
30
  copyFileWithToken(body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
31
- request(path: string, options?: MediaStoreRequestOptions, controller?: AbortController): Promise<Response>;
31
+ request(path: string, options?: MediaStoreRequestOptions, controller?: AbortController, useMediaCdn?: boolean): Promise<Response>;
32
32
  resolveAuth: (authContext?: AuthContext) => Promise<Auth>;
33
33
  resolveInitialAuth: () => Auth;
34
34
  get chunkHashAlgorithm(): ChunkHashAlgorithm;
@@ -0,0 +1,4 @@
1
+ export declare const MEDIA_CDN_MAP: {
2
+ [key: string]: string;
3
+ };
4
+ export declare function mapToMediaCdnUrl(url: string): string;
@@ -28,7 +28,7 @@ export declare class MediaStore implements MediaApi {
28
28
  }>;
29
29
  appendChunksToUpload(uploadId: string, body: AppendChunksToUploadRequestBody, collectionName?: string, traceContext?: MediaTraceContext): Promise<void>;
30
30
  copyFileWithToken(body: MediaStoreCopyFileWithTokenBody, params: MediaStoreCopyFileWithTokenParams, traceContext?: MediaTraceContext): Promise<MediaStoreResponse<MediaFile>>;
31
- request(path: string, options?: MediaStoreRequestOptions, controller?: AbortController): Promise<Response>;
31
+ request(path: string, options?: MediaStoreRequestOptions, controller?: AbortController, useMediaCdn?: boolean): Promise<Response>;
32
32
  resolveAuth: (authContext?: AuthContext) => Promise<Auth>;
33
33
  resolveInitialAuth: () => Auth;
34
34
  get chunkHashAlgorithm(): ChunkHashAlgorithm;
@@ -0,0 +1,4 @@
1
+ export declare const MEDIA_CDN_MAP: {
2
+ [key: string]: string;
3
+ };
4
+ export declare function mapToMediaCdnUrl(url: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-client",
3
- "version": "27.4.0",
3
+ "version": "27.5.1",
4
4
  "description": "Media API Web Client Library",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -36,7 +36,7 @@
36
36
  }
37
37
  },
38
38
  "dependencies": {
39
- "@atlaskit/chunkinator": "^6.0.0",
39
+ "@atlaskit/chunkinator": "^6.1.0",
40
40
  "@atlaskit/media-common": "^11.4.0",
41
41
  "@atlaskit/platform-feature-flags": "0.3.0",
42
42
  "@babel/runtime": "^7.0.0",
@@ -90,7 +90,10 @@
90
90
  "platform.media-cdn-delivery": {
91
91
  "type": "boolean"
92
92
  },
93
- "platform.media-card-performance-observer_lgc7b": {
93
+ "platform.media-card-performance-observer_a803k": {
94
+ "type": "boolean"
95
+ },
96
+ "platform.media-cdn-single-host": {
94
97
  "type": "boolean"
95
98
  }
96
99
  }