@atlaskit/media-client 35.2.1 → 35.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/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # @atlaskit/media-client
2
2
 
3
+ ## 35.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#197821](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/197821)
8
+ [`33a6ed876f806`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/33a6ed876f806) -
9
+ Add feature flag and logic that disable Media CDN delivery for requests from Isolated Cloud
10
+
3
11
  ## 35.2.1
4
12
 
5
13
  ### Patch Changes
@@ -17,8 +17,6 @@ var _request3 = require("../../utils/request");
17
17
  var _helpers = require("../../utils/request/helpers");
18
18
  var _mediaCdn = require("../../utils/mediaCdn");
19
19
  var _resolveAuth = require("./resolveAuth");
20
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
21
- var _isCommercial = require("../../utils/isCommercial");
22
20
  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; }
23
21
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
24
22
  var MEDIA_API_REGION = 'media-api-region';
@@ -41,7 +39,7 @@ var jsonHeaders = {
41
39
  };
42
40
  var cdnFeatureFlag = function cdnFeatureFlag(endpoint) {
43
41
  var result = endpoint;
44
- if ((0, _isCommercial.isCommercial)() && (0, _platformFeatureFlags.fg)('platform_media_cdn_delivery')) {
42
+ if ((0, _mediaCdn.isCDNEnabled)()) {
45
43
  result += '/cdn';
46
44
  }
47
45
  return result;
@@ -4,12 +4,11 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getArtifactUrl = void 0;
7
- var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
8
- var _isCommercial = require("../utils/isCommercial");
7
+ var _mediaCdn = require("../utils/mediaCdn");
9
8
  var getArtifactUrl = exports.getArtifactUrl = function getArtifactUrl(artifacts, prop) {
10
9
  var _artifacts$prop, _artifacts$prop3;
11
10
  // eslint-disable-next-line @atlaskit/platform/no-preconditioning
12
- if ((0, _isCommercial.isCommercial)() && (0, _platformFeatureFlags.fg)('platform_media_cdn_delivery') && (_artifacts$prop = artifacts[prop]) !== null && _artifacts$prop !== void 0 && _artifacts$prop.url) {
11
+ if ((0, _mediaCdn.isCDNEnabled)() && (_artifacts$prop = artifacts[prop]) !== null && _artifacts$prop !== void 0 && _artifacts$prop.url) {
13
12
  var _artifacts$prop2;
14
13
  return "".concat((_artifacts$prop2 = artifacts[prop]) === null || _artifacts$prop2 === void 0 ? void 0 : _artifacts$prop2.url, "/cdn");
15
14
  }
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.MEDIA_CDN_MAP = void 0;
7
+ exports.isCDNEnabled = isCDNEnabled;
7
8
  exports.mapToMediaCdnUrl = mapToMediaCdnUrl;
8
9
  var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
9
10
  var _isCommercial = require("./isCommercial");
@@ -17,17 +18,16 @@ var MEDIA_CDN_MAP = exports.MEDIA_CDN_MAP = {
17
18
  // https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html
18
19
  // Assuming other parts of the URL make up a max of ~1000 (in reality it's lower), the token can be ~7000
19
20
  var MEDIA_TOKEN_LENGTH_LIMIT = 7000;
21
+ function isCDNEnabled() {
22
+ var isIsolatedCloudWithDisabledCDN = (0, _platformFeatureFlags.fg)('platform_disable_isolated_cloud_media_cdn_delivery') && (0, _atlassianContext.isIsolatedCloud)();
23
+ return (0, _isCommercial.isCommercial)() && !isIsolatedCloudWithDisabledCDN && (0, _platformFeatureFlags.fg)('platform_media_cdn_delivery');
24
+ }
20
25
  function mapToMediaCdnUrl(url, token) {
21
26
  var _token$length;
22
27
  var tokenLength = (_token$length = token === null || token === void 0 ? void 0 : token.length) !== null && _token$length !== void 0 ? _token$length : 0;
23
- if (!(0, _isCommercial.isCommercial)() || tokenLength > MEDIA_TOKEN_LENGTH_LIMIT) {
28
+ if (!isCDNEnabled() || tokenLength > MEDIA_TOKEN_LENGTH_LIMIT) {
24
29
  return url;
25
30
  }
26
- if ((0, _platformFeatureFlags.fg)('platform_disable_isolated_cloud_media_cdn_delivery')) {
27
- if ((0, _atlassianContext.isIsolatedCloud)()) {
28
- return url;
29
- }
30
- }
31
31
 
32
32
  // eslint-disable-next-line @atlaskit/platform/no-preconditioning
33
33
  if ((0, _platformFeatureFlags.fg)('platform_media_cdn_delivery') && (0, _platformFeatureFlags.fg)('platform_media_cdn_single_host')) {
@@ -4,11 +4,9 @@ import { FILE_CACHE_MAX_AGE, MAX_RESOLUTION } from '../../constants';
4
4
  import { getArtifactUrl } from '../../models/artifacts';
5
5
  import { isRequestError, request } from '../../utils/request';
6
6
  import { createUrl, createMapResponseToJson, createMapResponseToBlob, defaultShouldRetryError, extendTraceContext } from '../../utils/request/helpers';
7
- import { mapToMediaCdnUrl } from '../../utils/mediaCdn';
7
+ import { isCDNEnabled, mapToMediaCdnUrl } from '../../utils/mediaCdn';
8
8
  import { resolveAuth, resolveInitialAuth } from './resolveAuth';
9
9
  import { ChunkHashAlgorithm } from '@atlaskit/media-core';
10
- import { fg } from '@atlaskit/platform-feature-flags';
11
- import { isCommercial } from '../../utils/isCommercial';
12
10
  const MEDIA_API_REGION = 'media-api-region';
13
11
  const MEDIA_API_ENVIRONMENT = 'media-api-environment';
14
12
  const extendImageParams = (params, fetchMaxRes = false) => {
@@ -30,7 +28,7 @@ const jsonHeaders = {
30
28
  };
31
29
  const cdnFeatureFlag = endpoint => {
32
30
  let result = endpoint;
33
- if (isCommercial() && fg('platform_media_cdn_delivery')) {
31
+ if (isCDNEnabled()) {
34
32
  result += '/cdn';
35
33
  }
36
34
  return result;
@@ -1,9 +1,8 @@
1
- import { fg } from '@atlaskit/platform-feature-flags';
2
- import { isCommercial } from '../utils/isCommercial';
1
+ import { isCDNEnabled } from '../utils/mediaCdn';
3
2
  export const getArtifactUrl = (artifacts, prop) => {
4
3
  var _artifacts$prop, _artifacts$prop3;
5
4
  // eslint-disable-next-line @atlaskit/platform/no-preconditioning
6
- if (isCommercial() && fg('platform_media_cdn_delivery') && (_artifacts$prop = artifacts[prop]) !== null && _artifacts$prop !== void 0 && _artifacts$prop.url) {
5
+ if (isCDNEnabled() && (_artifacts$prop = artifacts[prop]) !== null && _artifacts$prop !== void 0 && _artifacts$prop.url) {
7
6
  var _artifacts$prop2;
8
7
  return `${(_artifacts$prop2 = artifacts[prop]) === null || _artifacts$prop2 === void 0 ? void 0 : _artifacts$prop2.url}/cdn`;
9
8
  }
@@ -10,17 +10,16 @@ export const MEDIA_CDN_MAP = {
10
10
  // https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html
11
11
  // Assuming other parts of the URL make up a max of ~1000 (in reality it's lower), the token can be ~7000
12
12
  const MEDIA_TOKEN_LENGTH_LIMIT = 7000;
13
+ export function isCDNEnabled() {
14
+ const isIsolatedCloudWithDisabledCDN = fg('platform_disable_isolated_cloud_media_cdn_delivery') && isIsolatedCloud();
15
+ return isCommercial() && !isIsolatedCloudWithDisabledCDN && fg('platform_media_cdn_delivery');
16
+ }
13
17
  export function mapToMediaCdnUrl(url, token) {
14
18
  var _token$length;
15
19
  const tokenLength = (_token$length = token === null || token === void 0 ? void 0 : token.length) !== null && _token$length !== void 0 ? _token$length : 0;
16
- if (!isCommercial() || tokenLength > MEDIA_TOKEN_LENGTH_LIMIT) {
20
+ if (!isCDNEnabled() || tokenLength > MEDIA_TOKEN_LENGTH_LIMIT) {
17
21
  return url;
18
22
  }
19
- if (fg('platform_disable_isolated_cloud_media_cdn_delivery')) {
20
- if (isIsolatedCloud()) {
21
- return url;
22
- }
23
- }
24
23
 
25
24
  // eslint-disable-next-line @atlaskit/platform/no-preconditioning
26
25
  if (fg('platform_media_cdn_delivery') && fg('platform_media_cdn_single_host')) {
@@ -10,11 +10,9 @@ import { FILE_CACHE_MAX_AGE, MAX_RESOLUTION } from '../../constants';
10
10
  import { getArtifactUrl } from '../../models/artifacts';
11
11
  import { isRequestError, request as _request } from '../../utils/request';
12
12
  import { createUrl, createMapResponseToJson, createMapResponseToBlob, defaultShouldRetryError, extendTraceContext } from '../../utils/request/helpers';
13
- import { mapToMediaCdnUrl } from '../../utils/mediaCdn';
13
+ import { isCDNEnabled, mapToMediaCdnUrl } from '../../utils/mediaCdn';
14
14
  import { resolveAuth, resolveInitialAuth } from './resolveAuth';
15
15
  import { ChunkHashAlgorithm } from '@atlaskit/media-core';
16
- import { fg } from '@atlaskit/platform-feature-flags';
17
- import { isCommercial } from '../../utils/isCommercial';
18
16
  var MEDIA_API_REGION = 'media-api-region';
19
17
  var MEDIA_API_ENVIRONMENT = 'media-api-environment';
20
18
  var extendImageParams = function extendImageParams(params) {
@@ -35,7 +33,7 @@ var jsonHeaders = {
35
33
  };
36
34
  var cdnFeatureFlag = function cdnFeatureFlag(endpoint) {
37
35
  var result = endpoint;
38
- if (isCommercial() && fg('platform_media_cdn_delivery')) {
36
+ if (isCDNEnabled()) {
39
37
  result += '/cdn';
40
38
  }
41
39
  return result;
@@ -1,9 +1,8 @@
1
- import { fg } from '@atlaskit/platform-feature-flags';
2
- import { isCommercial } from '../utils/isCommercial';
1
+ import { isCDNEnabled } from '../utils/mediaCdn';
3
2
  export var getArtifactUrl = function getArtifactUrl(artifacts, prop) {
4
3
  var _artifacts$prop, _artifacts$prop3;
5
4
  // eslint-disable-next-line @atlaskit/platform/no-preconditioning
6
- if (isCommercial() && fg('platform_media_cdn_delivery') && (_artifacts$prop = artifacts[prop]) !== null && _artifacts$prop !== void 0 && _artifacts$prop.url) {
5
+ if (isCDNEnabled() && (_artifacts$prop = artifacts[prop]) !== null && _artifacts$prop !== void 0 && _artifacts$prop.url) {
7
6
  var _artifacts$prop2;
8
7
  return "".concat((_artifacts$prop2 = artifacts[prop]) === null || _artifacts$prop2 === void 0 ? void 0 : _artifacts$prop2.url, "/cdn");
9
8
  }
@@ -10,17 +10,16 @@ export var MEDIA_CDN_MAP = {
10
10
  // https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html
11
11
  // Assuming other parts of the URL make up a max of ~1000 (in reality it's lower), the token can be ~7000
12
12
  var MEDIA_TOKEN_LENGTH_LIMIT = 7000;
13
+ export function isCDNEnabled() {
14
+ var isIsolatedCloudWithDisabledCDN = fg('platform_disable_isolated_cloud_media_cdn_delivery') && isIsolatedCloud();
15
+ return isCommercial() && !isIsolatedCloudWithDisabledCDN && fg('platform_media_cdn_delivery');
16
+ }
13
17
  export function mapToMediaCdnUrl(url, token) {
14
18
  var _token$length;
15
19
  var tokenLength = (_token$length = token === null || token === void 0 ? void 0 : token.length) !== null && _token$length !== void 0 ? _token$length : 0;
16
- if (!isCommercial() || tokenLength > MEDIA_TOKEN_LENGTH_LIMIT) {
20
+ if (!isCDNEnabled() || tokenLength > MEDIA_TOKEN_LENGTH_LIMIT) {
17
21
  return url;
18
22
  }
19
- if (fg('platform_disable_isolated_cloud_media_cdn_delivery')) {
20
- if (isIsolatedCloud()) {
21
- return url;
22
- }
23
- }
24
23
 
25
24
  // eslint-disable-next-line @atlaskit/platform/no-preconditioning
26
25
  if (fg('platform_media_cdn_delivery') && fg('platform_media_cdn_single_host')) {
@@ -1,4 +1,5 @@
1
1
  export declare const MEDIA_CDN_MAP: {
2
2
  [key: string]: string;
3
3
  };
4
+ export declare function isCDNEnabled(): boolean;
4
5
  export declare function mapToMediaCdnUrl(url: string, token: string): string;
@@ -1,4 +1,5 @@
1
1
  export declare const MEDIA_CDN_MAP: {
2
2
  [key: string]: string;
3
3
  };
4
+ export declare function isCDNEnabled(): boolean;
4
5
  export declare function mapToMediaCdnUrl(url: string, token: string): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-client",
3
- "version": "35.2.1",
3
+ "version": "35.3.0",
4
4
  "description": "Media API Web Client Library",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -58,15 +58,14 @@
58
58
  "@atlaskit/media-core": "^37.0.0",
59
59
  "@atlaskit/media-state": "^1.8.0",
60
60
  "@atlaskit/ssr": "workspace:^",
61
- "@atlaskit/tokens": "^5.6.0",
61
+ "@atlaskit/tokens": "^6.0.0",
62
62
  "@atlassian/feature-flags-test-utils": "^0.3.0",
63
63
  "@emotion/react": "^11.7.1",
64
64
  "@types/deep-equal": "^1.0.1",
65
65
  "@types/uuid-validate": "^0.0.2",
66
66
  "fetch-mock": "^8.0.0",
67
67
  "react": "^18.2.0",
68
- "react-dom": "^18.2.0",
69
- "typescript": "~5.4.2"
68
+ "react-dom": "^18.2.0"
70
69
  },
71
70
  "techstack": {
72
71
  "@atlassian/frontend": {