@atlaskit/media-client 38.0.3 → 38.1.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
+ ## 38.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`d2921f7a6fcaa`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/d2921f7a6fcaa) -
8
+ MIME-derived file extensions on anonymized Rovo image uploads behind experiment gate
9
+ "cc_maui_polish_changes_batch_8".
10
+
3
11
  ## 38.0.3
4
12
 
5
13
  ### Patch Changes
@@ -25,9 +25,11 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
25
25
  var _map = require("rxjs/operators/map");
26
26
  var _Subscription = require("rxjs/Subscription");
27
27
  var _uuid = require("uuid");
28
+ var _mime = require("mime");
28
29
  var _authToOwner = require("@atlaskit/media-core/auth-to-owner");
29
30
  var _isValidUuid = require("@atlaskit/media-common/isValidUuid");
30
31
  var _downloadUrl = require("@atlaskit/media-common/downloadUrl");
32
+ var _isExperimentEnabled = require("@atlaskit/platform-feature-experiments/is-experiment-enabled");
31
33
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
32
34
  var _constants = require("../../constants");
33
35
  var _fileStreamsCache = require("../../file-streams-cache");
@@ -573,7 +575,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
573
575
  value: function () {
574
576
  var _uploadExternal = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee0(url, collection, traceContext, anonymizeFilename) {
575
577
  var _this3 = this;
576
- var uploadableFileUpfrontIds, id, occurrenceKey, subject, deferredBlob, preview, name, fileState;
578
+ var uploadableFileUpfrontIds, id, occurrenceKey, subject, deferredBlob, preview, initialName, fileState;
577
579
  return _regenerator.default.wrap(function (_context0) {
578
580
  while (1) switch (_context0.prev = _context0.next) {
579
581
  case 0:
@@ -612,10 +614,10 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
612
614
  return _ref0.apply(this, arguments);
613
615
  };
614
616
  }());
615
- name = anonymizeFilename ? crypto.randomUUID() : url.split('/').pop() || ''; // we create a initial fileState with the minimum info that we have at this point
617
+ initialName = anonymizeFilename ? crypto.randomUUID() : url.split('/').pop() || ''; // we create a initial fileState with the minimum info that we have at this point
616
618
  fileState = {
617
619
  status: 'processing',
618
- name: name,
620
+ name: initialName,
619
621
  size: 0,
620
622
  mediaType: 'unknown',
621
623
  mimeType: '',
@@ -629,7 +631,7 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
629
631
  this.setFileState(id, fileState);
630
632
  return _context0.abrupt("return", new Promise( /*#__PURE__*/function () {
631
633
  var _ref1 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee9(resolve, reject) {
632
- var blob, type, size, file, mediaType, dimensions, _t4;
634
+ var blob, type, size, extension, name, file, mediaType, dimensions, _t4;
633
635
  return _regenerator.default.wrap(function (_context9) {
634
636
  while (1) switch (_context9.prev = _context9.next) {
635
637
  case 0:
@@ -644,6 +646,8 @@ var FileFetcherImpl = exports.FileFetcherImpl = /*#__PURE__*/function () {
644
646
  return _context9.abrupt("return", reject('Could not download remote file'));
645
647
  case 2:
646
648
  type = blob.type, size = blob.size;
649
+ extension = anonymizeFilename && (0, _isExperimentEnabled.isExperimentEnabled)('cc_maui_polish_changes_batch_8') ? (0, _mime.getExtension)(type) : undefined;
650
+ name = extension ? "".concat(initialName, ".").concat(extension) : initialName;
647
651
  file = {
648
652
  content: blob,
649
653
  mimeType: type,
@@ -4,9 +4,11 @@ import { map } from 'rxjs/operators/map';
4
4
  import { Subscription } from 'rxjs/Subscription';
5
5
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
6
6
  import { v4 as uuid } from 'uuid';
7
+ import { getExtension } from 'mime';
7
8
  import { authToOwner } from '@atlaskit/media-core/auth-to-owner';
8
9
  import { isValidUuid } from '@atlaskit/media-common/isValidUuid';
9
10
  import { downloadUrl } from '@atlaskit/media-common/downloadUrl';
11
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
10
12
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
11
13
  import { RECENTS_COLLECTION } from '../../constants';
12
14
  import { getFileStreamsCache } from '../../file-streams-cache';
@@ -384,11 +386,11 @@ export class FileFetcherImpl {
384
386
  origin: 'remote'
385
387
  });
386
388
  });
387
- const name = anonymizeFilename ? crypto.randomUUID() : url.split('/').pop() || '';
389
+ const initialName = anonymizeFilename ? crypto.randomUUID() : url.split('/').pop() || '';
388
390
  // we create a initial fileState with the minimum info that we have at this point
389
391
  const fileState = {
390
392
  status: 'processing',
391
- name,
393
+ name: initialName,
392
394
  size: 0,
393
395
  mediaType: 'unknown',
394
396
  mimeType: '',
@@ -409,6 +411,8 @@ export class FileFetcherImpl {
409
411
  type,
410
412
  size
411
413
  } = blob;
414
+ const extension = anonymizeFilename && isExperimentEnabled('cc_maui_polish_changes_batch_8') ? getExtension(type) : undefined;
415
+ const name = extension ? `${initialName}.${extension}` : initialName;
412
416
  const file = {
413
417
  content: blob,
414
418
  mimeType: type,
@@ -10,9 +10,11 @@ import { map } from 'rxjs/operators/map';
10
10
  import { Subscription } from 'rxjs/Subscription';
11
11
  // eslint-disable-next-line @atlaskit/platform/prefer-crypto-random-uuid -- Use crypto.randomUUID instead
12
12
  import { v4 as uuid } from 'uuid';
13
+ import { getExtension } from 'mime';
13
14
  import { authToOwner } from '@atlaskit/media-core/auth-to-owner';
14
15
  import { isValidUuid } from '@atlaskit/media-common/isValidUuid';
15
16
  import { downloadUrl } from '@atlaskit/media-common/downloadUrl';
17
+ import { isExperimentEnabled } from '@atlaskit/platform-feature-experiments/is-experiment-enabled';
16
18
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
17
19
  import { RECENTS_COLLECTION } from '../../constants';
18
20
  import { getFileStreamsCache } from '../../file-streams-cache';
@@ -558,7 +560,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
558
560
  value: function () {
559
561
  var _uploadExternal = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee0(url, collection, traceContext, anonymizeFilename) {
560
562
  var _this3 = this;
561
- var uploadableFileUpfrontIds, id, occurrenceKey, subject, deferredBlob, preview, name, fileState;
563
+ var uploadableFileUpfrontIds, id, occurrenceKey, subject, deferredBlob, preview, initialName, fileState;
562
564
  return _regeneratorRuntime.wrap(function (_context0) {
563
565
  while (1) switch (_context0.prev = _context0.next) {
564
566
  case 0:
@@ -597,10 +599,10 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
597
599
  return _ref0.apply(this, arguments);
598
600
  };
599
601
  }());
600
- name = anonymizeFilename ? crypto.randomUUID() : url.split('/').pop() || ''; // we create a initial fileState with the minimum info that we have at this point
602
+ initialName = anonymizeFilename ? crypto.randomUUID() : url.split('/').pop() || ''; // we create a initial fileState with the minimum info that we have at this point
601
603
  fileState = {
602
604
  status: 'processing',
603
- name: name,
605
+ name: initialName,
604
606
  size: 0,
605
607
  mediaType: 'unknown',
606
608
  mimeType: '',
@@ -614,7 +616,7 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
614
616
  this.setFileState(id, fileState);
615
617
  return _context0.abrupt("return", new Promise( /*#__PURE__*/function () {
616
618
  var _ref1 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(resolve, reject) {
617
- var blob, type, size, file, mediaType, dimensions, _t4;
619
+ var blob, type, size, extension, name, file, mediaType, dimensions, _t4;
618
620
  return _regeneratorRuntime.wrap(function (_context9) {
619
621
  while (1) switch (_context9.prev = _context9.next) {
620
622
  case 0:
@@ -629,6 +631,8 @@ export var FileFetcherImpl = /*#__PURE__*/function () {
629
631
  return _context9.abrupt("return", reject('Could not download remote file'));
630
632
  case 2:
631
633
  type = blob.type, size = blob.size;
634
+ extension = anonymizeFilename && isExperimentEnabled('cc_maui_polish_changes_batch_8') ? getExtension(type) : undefined;
635
+ name = extension ? "".concat(initialName, ".").concat(extension) : initialName;
632
636
  file = {
633
637
  content: blob,
634
638
  mimeType: type,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-client",
3
- "version": "38.0.3",
3
+ "version": "38.1.0",
4
4
  "description": "Media API Web Client Library",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -24,6 +24,7 @@
24
24
  "@atlaskit/atlassian-context": "^1.1.0",
25
25
  "@atlaskit/chunkinator": "^8.1.0",
26
26
  "@atlaskit/media-common": "^14.6.0",
27
+ "@atlaskit/platform-feature-experiments": "^0.3.0",
27
28
  "@atlaskit/platform-feature-flags": "^2.2.0",
28
29
  "@atlaskit/tmp-editor-statsig": "^182.0.0",
29
30
  "@babel/runtime": "^7.0.0",
@@ -32,6 +33,7 @@
32
33
  "eventemitter2": "^4.1.0",
33
34
  "js-sha256": "^0.10.1",
34
35
  "lru_map": "^0.4.1",
36
+ "mime": "^2.4.6",
35
37
  "rusha": "^0.8.13",
36
38
  "rxjs": "^5.5.0",
37
39
  "uuid": "^11.1.1",
@@ -48,6 +50,7 @@
48
50
  "@atlaskit/ssr": "workspace:^",
49
51
  "@atlaskit/tokens": "^16.11.0",
50
52
  "@atlassian/a11y-jest-testing": "^0.17.0",
53
+ "@atlassian/experiment-test-utils": "^0.2.0",
51
54
  "@atlassian/feature-flags-test-utils": "^1.3.0",
52
55
  "@emotion/react": "^11.7.1",
53
56
  "@types/deep-equal": "^1.0.1",