@atlaskit/media-client 27.6.1 → 28.0.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 +19 -0
- package/dist/cjs/client/file-fetcher/index.js +4 -7
- package/dist/cjs/client/media-store/MediaStore.js +4 -4
- package/dist/cjs/models/artifacts.js +1 -2
- package/dist/cjs/utils/mediaCdn.js +12 -2
- package/dist/es2019/client/file-fetcher/index.js +5 -8
- package/dist/es2019/client/media-store/MediaStore.js +4 -4
- package/dist/es2019/models/artifacts.js +1 -2
- package/dist/es2019/utils/mediaCdn.js +12 -2
- package/dist/esm/client/file-fetcher/index.js +5 -8
- package/dist/esm/client/media-store/MediaStore.js +4 -4
- package/dist/esm/models/artifacts.js +1 -2
- package/dist/esm/utils/mediaCdn.js +12 -2
- package/dist/types/utils/mediaCdn.d.ts +1 -1
- package/dist/types-ts4.5/utils/mediaCdn.d.ts +1 -1
- package/package.json +3 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# @atlaskit/media-client
|
|
2
2
|
|
|
3
|
+
## 28.0.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#147039](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/147039)
|
|
8
|
+
[`f29b4d6055c5e`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/f29b4d6055c5e) -
|
|
9
|
+
fix media cdn errors caused by excessive media token length
|
|
10
|
+
|
|
11
|
+
## 28.0.0
|
|
12
|
+
|
|
13
|
+
### Major Changes
|
|
14
|
+
|
|
15
|
+
- [#139803](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/139803)
|
|
16
|
+
[`573e2dccbc940`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/573e2dccbc940) -
|
|
17
|
+
BREAKING CHANGE: Attribute `preview` in File State is now set unnconditionally in the file state.
|
|
18
|
+
No longer when it's supported by the broswer. If your application relies on this attribute, check
|
|
19
|
+
the file mimetype to ensure that you are using it properly. This change was released in `v27.0.0`
|
|
20
|
+
behind a feature flag. Now, it is a permanent change.
|
|
21
|
+
|
|
3
22
|
## 27.6.1
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
|
@@ -47,7 +47,6 @@ var _shouldFetchRemoteFileStates = require("../../utils/shouldFetchRemoteFileSta
|
|
|
47
47
|
var _polling = require("../../utils/polling");
|
|
48
48
|
var _detectEmptyFile = require("../../utils/detectEmptyFile");
|
|
49
49
|
var _mediaState = require("@atlaskit/media-state");
|
|
50
|
-
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
51
50
|
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; }
|
|
52
51
|
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; }
|
|
53
52
|
var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
@@ -152,12 +151,10 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
152
151
|
if (content instanceof Blob) {
|
|
153
152
|
size = content.size;
|
|
154
153
|
mimeType = content.type;
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
};
|
|
160
|
-
}
|
|
154
|
+
preview = {
|
|
155
|
+
value: content,
|
|
156
|
+
origin: 'local'
|
|
157
|
+
};
|
|
161
158
|
}
|
|
162
159
|
var mediaType = (0, _getMediaTypeFromUploadableFile.getMediaTypeFromUploadableFile)(file);
|
|
163
160
|
return {
|
|
@@ -294,7 +294,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
294
294
|
auth: auth
|
|
295
295
|
};
|
|
296
296
|
var imageEndpoint = !(0, _isFedRamp.isFedRamp)() && (0, _platformFeatureFlags.fg)('platform.media-cdn-delivery') ? 'image/cdn' : 'image';
|
|
297
|
-
return (0, _mediaCdn.mapToMediaCdnUrl)((0, _helpers.createUrl)("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(imageEndpoint), options));
|
|
297
|
+
return (0, _mediaCdn.mapToMediaCdnUrl)((0, _helpers.createUrl)("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(imageEndpoint), options), auth.token);
|
|
298
298
|
}
|
|
299
299
|
}, {
|
|
300
300
|
key: "getFileBinary",
|
|
@@ -366,7 +366,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
366
366
|
auth: auth
|
|
367
367
|
};
|
|
368
368
|
binaryEndpoint = !(0, _isFedRamp.isFedRamp)() && (0, _platformFeatureFlags.fg)('platform.media-cdn-delivery') ? 'binary/cdn' : 'binary';
|
|
369
|
-
return _context6.abrupt("return", (0, _mediaCdn.mapToMediaCdnUrl)((0, _helpers.createUrl)("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options)));
|
|
369
|
+
return _context6.abrupt("return", (0, _mediaCdn.mapToMediaCdnUrl)((0, _helpers.createUrl)("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options), auth.token));
|
|
370
370
|
case 7:
|
|
371
371
|
case "end":
|
|
372
372
|
return _context6.stop();
|
|
@@ -406,7 +406,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
406
406
|
},
|
|
407
407
|
auth: auth
|
|
408
408
|
};
|
|
409
|
-
return _context7.abrupt("return", (0, _helpers.createUrl)(artifactUrl, options));
|
|
409
|
+
return _context7.abrupt("return", (0, _helpers.createUrl)((0, _mediaCdn.mapToMediaCdnUrl)(artifactUrl, auth.token), options));
|
|
410
410
|
case 8:
|
|
411
411
|
case "end":
|
|
412
412
|
return _context7.stop();
|
|
@@ -627,7 +627,7 @@ var MediaStore = exports.MediaStore = /*#__PURE__*/function () {
|
|
|
627
627
|
}) : undefined;
|
|
628
628
|
url = "".concat(auth.baseUrl).concat(path);
|
|
629
629
|
if (useMediaCdn) {
|
|
630
|
-
url = (0, _mediaCdn.mapToMediaCdnUrl)(url);
|
|
630
|
+
url = (0, _mediaCdn.mapToMediaCdnUrl)(url, auth.token);
|
|
631
631
|
}
|
|
632
632
|
_context12.next = 13;
|
|
633
633
|
return (0, _request3.request)(url, {
|
|
@@ -5,13 +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");
|
|
9
8
|
var _isFedRamp = require("../utils/isFedRamp");
|
|
10
9
|
var getArtifactUrl = exports.getArtifactUrl = function getArtifactUrl(artifacts, prop) {
|
|
11
10
|
var _artifacts$prop2;
|
|
12
11
|
if (!(0, _isFedRamp.isFedRamp)() && (0, _platformFeatureFlags.fg)('platform.media-cdn-delivery')) {
|
|
13
12
|
var _artifacts$prop;
|
|
14
|
-
return
|
|
13
|
+
return "".concat((_artifacts$prop = artifacts[prop]) === null || _artifacts$prop === void 0 ? void 0 : _artifacts$prop.url, "/cdn");
|
|
15
14
|
}
|
|
16
15
|
return (_artifacts$prop2 = artifacts[prop]) === null || _artifacts$prop2 === void 0 ? void 0 : _artifacts$prop2.url;
|
|
17
16
|
};
|
|
@@ -11,9 +11,19 @@ var MEDIA_CDN_MAP = exports.MEDIA_CDN_MAP = {
|
|
|
11
11
|
'api.media.atlassian.com': 'media-cdn.atlassian.com',
|
|
12
12
|
'media.staging.atl-paas.net': 'media-cdn.stg.atlassian.com'
|
|
13
13
|
};
|
|
14
|
-
|
|
14
|
+
|
|
15
|
+
// Cloudfront has a hard limit of 8,192 bytes
|
|
16
|
+
// https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html
|
|
17
|
+
// Assuming other parts of the URL make up a max of ~1000 (in reality it's lower), the token can be ~7000
|
|
18
|
+
var MEDIA_TOKEN_LENGTH_LIMIT = 7000;
|
|
19
|
+
function mapToMediaCdnUrl(url, token) {
|
|
20
|
+
var _token$length;
|
|
21
|
+
var tokenLength = (_token$length = token === null || token === void 0 ? void 0 : token.length) !== null && _token$length !== void 0 ? _token$length : 0;
|
|
22
|
+
if ((0, _isFedRamp.isFedRamp)() || tokenLength > MEDIA_TOKEN_LENGTH_LIMIT) {
|
|
23
|
+
return url;
|
|
24
|
+
}
|
|
15
25
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
16
|
-
if (
|
|
26
|
+
if ((0, _platformFeatureFlags.fg)('platform.media-cdn-delivery') && (0, _platformFeatureFlags.fg)('platform.media-cdn-single-host')) {
|
|
17
27
|
try {
|
|
18
28
|
var parsedUrl = new URL(url);
|
|
19
29
|
var cdnHost = MEDIA_CDN_MAP[parsedUrl.host];
|
|
@@ -19,12 +19,11 @@ import { convertBase64ToBlob } from '../../utils/convertBase64ToBlob';
|
|
|
19
19
|
import { toPromise, fromObservable } from '../../utils/mediaSubscribable';
|
|
20
20
|
import { getDimensionsFromBlob } from '../../utils/getDimensionsFromBlob';
|
|
21
21
|
import { createMediaSubject } from '../../utils/createMediaSubject';
|
|
22
|
-
import {
|
|
22
|
+
import { getMediaTypeFromMimeType } from '@atlaskit/media-common/mediaTypeUtils';
|
|
23
23
|
import { shouldFetchRemoteFileStates } from '../../utils/shouldFetchRemoteFileStates';
|
|
24
24
|
import { PollingFunction } from '../../utils/polling';
|
|
25
25
|
import { isEmptyFile } from '../../utils/detectEmptyFile';
|
|
26
26
|
import { mediaStore } from '@atlaskit/media-state';
|
|
27
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
28
27
|
export { isFileFetcherError, FileFetcherError } from './error';
|
|
29
28
|
export class FileFetcherImpl {
|
|
30
29
|
constructor(mediaApi, store = mediaStore) {
|
|
@@ -105,12 +104,10 @@ export class FileFetcherImpl {
|
|
|
105
104
|
if (content instanceof Blob) {
|
|
106
105
|
size = content.size;
|
|
107
106
|
mimeType = content.type;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
};
|
|
113
|
-
}
|
|
107
|
+
preview = {
|
|
108
|
+
value: content,
|
|
109
|
+
origin: 'local'
|
|
110
|
+
};
|
|
114
111
|
}
|
|
115
112
|
const mediaType = getMediaTypeFromUploadableFile(file);
|
|
116
113
|
return {
|
|
@@ -189,7 +189,7 @@ export class MediaStore {
|
|
|
189
189
|
auth
|
|
190
190
|
};
|
|
191
191
|
const imageEndpoint = !isFedRamp() && fg('platform.media-cdn-delivery') ? 'image/cdn' : 'image';
|
|
192
|
-
return mapToMediaCdnUrl(createUrl(`${auth.baseUrl}/file/${id}/${imageEndpoint}`, options));
|
|
192
|
+
return mapToMediaCdnUrl(createUrl(`${auth.baseUrl}/file/${id}/${imageEndpoint}`, options), auth.token);
|
|
193
193
|
}
|
|
194
194
|
async getFileBinary(id, collectionName, maxAge = FILE_CACHE_MAX_AGE) {
|
|
195
195
|
const headers = {};
|
|
@@ -224,7 +224,7 @@ export class MediaStore {
|
|
|
224
224
|
auth
|
|
225
225
|
};
|
|
226
226
|
const binaryEndpoint = !isFedRamp() && fg('platform.media-cdn-delivery') ? 'binary/cdn' : 'binary';
|
|
227
|
-
return mapToMediaCdnUrl(createUrl(`${auth.baseUrl}/file/${id}/${binaryEndpoint}`, options));
|
|
227
|
+
return mapToMediaCdnUrl(createUrl(`${auth.baseUrl}/file/${id}/${binaryEndpoint}`, options), auth.token);
|
|
228
228
|
}
|
|
229
229
|
async getArtifactURL(artifacts, artifactName, collectionName) {
|
|
230
230
|
const artifactUrl = getArtifactUrl(artifacts, artifactName);
|
|
@@ -241,7 +241,7 @@ export class MediaStore {
|
|
|
241
241
|
},
|
|
242
242
|
auth
|
|
243
243
|
};
|
|
244
|
-
return createUrl(artifactUrl, options);
|
|
244
|
+
return createUrl(mapToMediaCdnUrl(artifactUrl, auth.token), options);
|
|
245
245
|
}
|
|
246
246
|
async getImage(id, params, controller, fetchMaxRes, traceContext) {
|
|
247
247
|
// TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
|
|
@@ -365,7 +365,7 @@ export class MediaStore {
|
|
|
365
365
|
} : undefined;
|
|
366
366
|
let url = `${auth.baseUrl}${path}`;
|
|
367
367
|
if (useMediaCdn) {
|
|
368
|
-
url = mapToMediaCdnUrl(url);
|
|
368
|
+
url = mapToMediaCdnUrl(url, auth.token);
|
|
369
369
|
}
|
|
370
370
|
const response = await request(url, {
|
|
371
371
|
method,
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
-
import { mapToMediaCdnUrl } from '../utils/mediaCdn';
|
|
3
2
|
import { isFedRamp } from '../utils/isFedRamp';
|
|
4
3
|
export const getArtifactUrl = (artifacts, prop) => {
|
|
5
4
|
var _artifacts$prop2;
|
|
6
5
|
if (!isFedRamp() && fg('platform.media-cdn-delivery')) {
|
|
7
6
|
var _artifacts$prop;
|
|
8
|
-
return
|
|
7
|
+
return `${(_artifacts$prop = artifacts[prop]) === null || _artifacts$prop === void 0 ? void 0 : _artifacts$prop.url}/cdn`;
|
|
9
8
|
}
|
|
10
9
|
return (_artifacts$prop2 = artifacts[prop]) === null || _artifacts$prop2 === void 0 ? void 0 : _artifacts$prop2.url;
|
|
11
10
|
};
|
|
@@ -4,9 +4,19 @@ export const MEDIA_CDN_MAP = {
|
|
|
4
4
|
'api.media.atlassian.com': 'media-cdn.atlassian.com',
|
|
5
5
|
'media.staging.atl-paas.net': 'media-cdn.stg.atlassian.com'
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
// Cloudfront has a hard limit of 8,192 bytes
|
|
9
|
+
// https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html
|
|
10
|
+
// Assuming other parts of the URL make up a max of ~1000 (in reality it's lower), the token can be ~7000
|
|
11
|
+
const MEDIA_TOKEN_LENGTH_LIMIT = 7000;
|
|
12
|
+
export function mapToMediaCdnUrl(url, token) {
|
|
13
|
+
var _token$length;
|
|
14
|
+
const tokenLength = (_token$length = token === null || token === void 0 ? void 0 : token.length) !== null && _token$length !== void 0 ? _token$length : 0;
|
|
15
|
+
if (isFedRamp() || tokenLength > MEDIA_TOKEN_LENGTH_LIMIT) {
|
|
16
|
+
return url;
|
|
17
|
+
}
|
|
8
18
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
9
|
-
if (
|
|
19
|
+
if (fg('platform.media-cdn-delivery') && fg('platform.media-cdn-single-host')) {
|
|
10
20
|
try {
|
|
11
21
|
const parsedUrl = new URL(url);
|
|
12
22
|
const cdnHost = MEDIA_CDN_MAP[parsedUrl.host];
|
|
@@ -25,12 +25,11 @@ import { convertBase64ToBlob } from '../../utils/convertBase64ToBlob';
|
|
|
25
25
|
import { toPromise, fromObservable } from '../../utils/mediaSubscribable';
|
|
26
26
|
import { getDimensionsFromBlob } from '../../utils/getDimensionsFromBlob';
|
|
27
27
|
import { createMediaSubject } from '../../utils/createMediaSubject';
|
|
28
|
-
import {
|
|
28
|
+
import { getMediaTypeFromMimeType } from '@atlaskit/media-common/mediaTypeUtils';
|
|
29
29
|
import { shouldFetchRemoteFileStates } from '../../utils/shouldFetchRemoteFileStates';
|
|
30
30
|
import { PollingFunction } from '../../utils/polling';
|
|
31
31
|
import { isEmptyFile } from '../../utils/detectEmptyFile';
|
|
32
32
|
import { mediaStore } from '@atlaskit/media-state';
|
|
33
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
34
33
|
export { isFileFetcherError, FileFetcherError } from './error';
|
|
35
34
|
export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
36
35
|
function FileFetcherImpl(mediaApi) {
|
|
@@ -134,12 +133,10 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
|
|
|
134
133
|
if (content instanceof Blob) {
|
|
135
134
|
size = content.size;
|
|
136
135
|
mimeType = content.type;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
};
|
|
142
|
-
}
|
|
136
|
+
preview = {
|
|
137
|
+
value: content,
|
|
138
|
+
origin: 'local'
|
|
139
|
+
};
|
|
143
140
|
}
|
|
144
141
|
var mediaType = getMediaTypeFromUploadableFile(file);
|
|
145
142
|
return {
|
|
@@ -288,7 +288,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
288
288
|
auth: auth
|
|
289
289
|
};
|
|
290
290
|
var imageEndpoint = !isFedRamp() && fg('platform.media-cdn-delivery') ? 'image/cdn' : 'image';
|
|
291
|
-
return mapToMediaCdnUrl(createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(imageEndpoint), options));
|
|
291
|
+
return mapToMediaCdnUrl(createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(imageEndpoint), options), auth.token);
|
|
292
292
|
}
|
|
293
293
|
}, {
|
|
294
294
|
key: "getFileBinary",
|
|
@@ -360,7 +360,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
360
360
|
auth: auth
|
|
361
361
|
};
|
|
362
362
|
binaryEndpoint = !isFedRamp() && fg('platform.media-cdn-delivery') ? 'binary/cdn' : 'binary';
|
|
363
|
-
return _context6.abrupt("return", mapToMediaCdnUrl(createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options)));
|
|
363
|
+
return _context6.abrupt("return", mapToMediaCdnUrl(createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options), auth.token));
|
|
364
364
|
case 7:
|
|
365
365
|
case "end":
|
|
366
366
|
return _context6.stop();
|
|
@@ -400,7 +400,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
400
400
|
},
|
|
401
401
|
auth: auth
|
|
402
402
|
};
|
|
403
|
-
return _context7.abrupt("return", createUrl(artifactUrl, options));
|
|
403
|
+
return _context7.abrupt("return", createUrl(mapToMediaCdnUrl(artifactUrl, auth.token), options));
|
|
404
404
|
case 8:
|
|
405
405
|
case "end":
|
|
406
406
|
return _context7.stop();
|
|
@@ -621,7 +621,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
621
621
|
}) : undefined;
|
|
622
622
|
url = "".concat(auth.baseUrl).concat(path);
|
|
623
623
|
if (useMediaCdn) {
|
|
624
|
-
url = mapToMediaCdnUrl(url);
|
|
624
|
+
url = mapToMediaCdnUrl(url, auth.token);
|
|
625
625
|
}
|
|
626
626
|
_context12.next = 13;
|
|
627
627
|
return _request(url, {
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
-
import { mapToMediaCdnUrl } from '../utils/mediaCdn';
|
|
3
2
|
import { isFedRamp } from '../utils/isFedRamp';
|
|
4
3
|
export var getArtifactUrl = function getArtifactUrl(artifacts, prop) {
|
|
5
4
|
var _artifacts$prop2;
|
|
6
5
|
if (!isFedRamp() && fg('platform.media-cdn-delivery')) {
|
|
7
6
|
var _artifacts$prop;
|
|
8
|
-
return
|
|
7
|
+
return "".concat((_artifacts$prop = artifacts[prop]) === null || _artifacts$prop === void 0 ? void 0 : _artifacts$prop.url, "/cdn");
|
|
9
8
|
}
|
|
10
9
|
return (_artifacts$prop2 = artifacts[prop]) === null || _artifacts$prop2 === void 0 ? void 0 : _artifacts$prop2.url;
|
|
11
10
|
};
|
|
@@ -4,9 +4,19 @@ export var MEDIA_CDN_MAP = {
|
|
|
4
4
|
'api.media.atlassian.com': 'media-cdn.atlassian.com',
|
|
5
5
|
'media.staging.atl-paas.net': 'media-cdn.stg.atlassian.com'
|
|
6
6
|
};
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
// Cloudfront has a hard limit of 8,192 bytes
|
|
9
|
+
// https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/cloudfront-limits.html
|
|
10
|
+
// Assuming other parts of the URL make up a max of ~1000 (in reality it's lower), the token can be ~7000
|
|
11
|
+
var MEDIA_TOKEN_LENGTH_LIMIT = 7000;
|
|
12
|
+
export function mapToMediaCdnUrl(url, token) {
|
|
13
|
+
var _token$length;
|
|
14
|
+
var tokenLength = (_token$length = token === null || token === void 0 ? void 0 : token.length) !== null && _token$length !== void 0 ? _token$length : 0;
|
|
15
|
+
if (isFedRamp() || tokenLength > MEDIA_TOKEN_LENGTH_LIMIT) {
|
|
16
|
+
return url;
|
|
17
|
+
}
|
|
8
18
|
// eslint-disable-next-line @atlaskit/platform/no-preconditioning
|
|
9
|
-
if (
|
|
19
|
+
if (fg('platform.media-cdn-delivery') && fg('platform.media-cdn-single-host')) {
|
|
10
20
|
try {
|
|
11
21
|
var parsedUrl = new URL(url);
|
|
12
22
|
var cdnHost = MEDIA_CDN_MAP[parsedUrl.host];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-client",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "28.0.1",
|
|
4
4
|
"description": "Media API Web Client Library",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@atlaskit/chunkinator": "^6.1.0",
|
|
38
|
-
"@atlaskit/media-common": "^11.
|
|
38
|
+
"@atlaskit/media-common": "^11.5.0",
|
|
39
39
|
"@atlaskit/platform-feature-flags": "0.3.0",
|
|
40
40
|
"@babel/runtime": "^7.0.0",
|
|
41
41
|
"dataloader": "^2.1.0",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"@atlaskit/media-core": "^34.3.0",
|
|
58
58
|
"@atlaskit/media-state": "^1.1.0",
|
|
59
59
|
"@atlaskit/ssr": "*",
|
|
60
|
-
"@atlaskit/tokens": "^
|
|
60
|
+
"@atlaskit/tokens": "^2.0.0",
|
|
61
61
|
"@atlassian/feature-flags-test-utils": "0.2.3",
|
|
62
62
|
"@emotion/react": "^11.7.1",
|
|
63
63
|
"@types/deep-equal": "^1.0.1",
|
|
@@ -81,9 +81,6 @@
|
|
|
81
81
|
}
|
|
82
82
|
},
|
|
83
83
|
"platform-feature-flags": {
|
|
84
|
-
"platform.media-svg-rendering": {
|
|
85
|
-
"type": "boolean"
|
|
86
|
-
},
|
|
87
84
|
"platform.media-cdn-delivery": {
|
|
88
85
|
"type": "boolean"
|
|
89
86
|
},
|