@atlaskit/media-client 35.7.0 → 35.8.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cjs/client/file-fetcher/index.js +3 -3
  3. package/dist/cjs/client/media-client.js +43 -24
  4. package/dist/cjs/client/media-store/MediaStore.js +189 -148
  5. package/dist/cjs/models/file-state.js +4 -2
  6. package/dist/cjs/utils/url.js +3 -1
  7. package/dist/es2019/client/file-fetcher/index.js +2 -2
  8. package/dist/es2019/client/media-client.js +3 -0
  9. package/dist/es2019/client/media-store/MediaStore.js +21 -2
  10. package/dist/es2019/models/file-state.js +4 -2
  11. package/dist/es2019/utils/url.js +3 -1
  12. package/dist/esm/client/file-fetcher/index.js +3 -3
  13. package/dist/esm/client/media-client.js +43 -24
  14. package/dist/esm/client/media-store/MediaStore.js +189 -148
  15. package/dist/esm/models/file-state.js +4 -2
  16. package/dist/esm/utils/url.js +3 -1
  17. package/dist/types/client/events.d.ts +1 -0
  18. package/dist/types/client/file-fetcher/index.d.ts +1 -0
  19. package/dist/types/client/media-client.d.ts +1 -0
  20. package/dist/types/client/media-store/MediaStore.d.ts +2 -1
  21. package/dist/types/models/item.d.ts +2 -0
  22. package/dist/types/models/media.d.ts +3 -1
  23. package/dist/types/utils/url.d.ts +1 -0
  24. package/dist/types-ts4.5/client/events.d.ts +1 -0
  25. package/dist/types-ts4.5/client/file-fetcher/index.d.ts +1 -0
  26. package/dist/types-ts4.5/client/media-client.d.ts +1 -0
  27. package/dist/types-ts4.5/client/media-store/MediaStore.d.ts +2 -1
  28. package/dist/types-ts4.5/models/item.d.ts +2 -0
  29. package/dist/types-ts4.5/models/media.d.ts +3 -1
  30. package/dist/types-ts4.5/utils/url.d.ts +1 -0
  31. package/package.json +4 -3
@@ -39,6 +39,9 @@ var cdnFeatureFlag = function cdnFeatureFlag(endpoint) {
39
39
  }
40
40
  return result;
41
41
  };
42
+ var decodeJwtToken = function decodeJwtToken(token) {
43
+ return JSON.parse(atob(token.split('.')[1].replace(/-/g, '+').replace(/_/g, '/')));
44
+ };
42
45
  export var MediaStore = /*#__PURE__*/function () {
43
46
  function MediaStore(config) {
44
47
  var _this = this;
@@ -164,12 +167,49 @@ export var MediaStore = /*#__PURE__*/function () {
164
167
  this._chunkHashAlgorithm = config.chunkHashAlgorithm || ChunkHashAlgorithm.Sha256;
165
168
  }
166
169
  return _createClass(MediaStore, [{
167
- key: "removeCollectionFile",
170
+ key: "getClientId",
168
171
  value: function () {
169
- var _removeCollectionFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(id, collectionName, occurrenceKey, traceContext) {
170
- var metadata, body, options;
172
+ var _getClientId = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(collectionName) {
173
+ var auth, jwtPayload;
171
174
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
172
175
  while (1) switch (_context4.prev = _context4.next) {
176
+ case 0:
177
+ _context4.next = 2;
178
+ return this.resolveAuth({
179
+ collectionName: collectionName
180
+ });
181
+ case 2:
182
+ auth = _context4.sent;
183
+ if (isClientBasedAuth(auth)) {
184
+ _context4.next = 11;
185
+ break;
186
+ }
187
+ _context4.prev = 4;
188
+ jwtPayload = decodeJwtToken(auth.token);
189
+ return _context4.abrupt("return", jwtPayload.clientId);
190
+ case 9:
191
+ _context4.prev = 9;
192
+ _context4.t0 = _context4["catch"](4);
193
+ case 11:
194
+ return _context4.abrupt("return", isClientBasedAuth(auth) ? auth.clientId : undefined);
195
+ case 12:
196
+ case "end":
197
+ return _context4.stop();
198
+ }
199
+ }, _callee4, this, [[4, 9]]);
200
+ }));
201
+ function getClientId(_x11) {
202
+ return _getClientId.apply(this, arguments);
203
+ }
204
+ return getClientId;
205
+ }()
206
+ }, {
207
+ key: "removeCollectionFile",
208
+ value: function () {
209
+ var _removeCollectionFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(id, collectionName, occurrenceKey, traceContext) {
210
+ var metadata, body, options;
211
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
212
+ while (1) switch (_context5.prev = _context5.next) {
173
213
  case 0:
174
214
  metadata = {
175
215
  method: 'PUT',
@@ -196,15 +236,15 @@ export var MediaStore = /*#__PURE__*/function () {
196
236
  body: JSON.stringify(body),
197
237
  traceContext: traceContext
198
238
  });
199
- _context4.next = 5;
239
+ _context5.next = 5;
200
240
  return this.request("/collection/".concat(collectionName), options);
201
241
  case 5:
202
242
  case "end":
203
- return _context4.stop();
243
+ return _context5.stop();
204
244
  }
205
- }, _callee4, this);
245
+ }, _callee5, this);
206
246
  }));
207
- function removeCollectionFile(_x11, _x12, _x13, _x14) {
247
+ function removeCollectionFile(_x12, _x13, _x14, _x15) {
208
248
  return _removeCollectionFile.apply(this, arguments);
209
249
  }
210
250
  return removeCollectionFile;
@@ -237,10 +277,10 @@ export var MediaStore = /*#__PURE__*/function () {
237
277
  }, {
238
278
  key: "uploadChunk",
239
279
  value: function () {
240
- var _uploadChunk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(etag, blob, uploadId, partNumber, collectionName, traceContext) {
280
+ var _uploadChunk = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(etag, blob, uploadId, partNumber, collectionName, traceContext) {
241
281
  var metadata, options;
242
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
243
- while (1) switch (_context5.prev = _context5.next) {
282
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
283
+ while (1) switch (_context6.prev = _context6.next) {
244
284
  case 0:
245
285
  metadata = {
246
286
  method: 'PUT',
@@ -257,15 +297,15 @@ export var MediaStore = /*#__PURE__*/function () {
257
297
  body: blob,
258
298
  traceContext: traceContext
259
299
  });
260
- _context5.next = 4;
300
+ _context6.next = 4;
261
301
  return this.request("/chunk/".concat(etag), options);
262
302
  case 4:
263
303
  case "end":
264
- return _context5.stop();
304
+ return _context6.stop();
265
305
  }
266
- }, _callee5, this);
306
+ }, _callee6, this);
267
307
  }));
268
- function uploadChunk(_x15, _x16, _x17, _x18, _x19, _x20) {
308
+ function uploadChunk(_x16, _x17, _x18, _x19, _x20, _x21) {
269
309
  return _uploadChunk.apply(this, arguments);
270
310
  }
271
311
  return uploadChunk;
@@ -307,17 +347,17 @@ export var MediaStore = /*#__PURE__*/function () {
307
347
  }, {
308
348
  key: "touchFiles",
309
349
  value: function () {
310
- var _touchFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(body) {
350
+ var _touchFiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(body) {
311
351
  var params,
312
352
  traceContext,
313
353
  metadata,
314
354
  options,
315
- _args6 = arguments;
316
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
317
- while (1) switch (_context6.prev = _context6.next) {
355
+ _args7 = arguments;
356
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
357
+ while (1) switch (_context7.prev = _context7.next) {
318
358
  case 0:
319
- params = _args6.length > 1 && _args6[1] !== undefined ? _args6[1] : {};
320
- traceContext = _args6.length > 2 ? _args6[2] : undefined;
359
+ params = _args7.length > 1 && _args7[1] !== undefined ? _args7[1] : {};
360
+ traceContext = _args7.length > 2 ? _args7[2] : undefined;
321
361
  metadata = {
322
362
  method: 'POST',
323
363
  endpoint: '/upload/createWithFiles'
@@ -333,14 +373,14 @@ export var MediaStore = /*#__PURE__*/function () {
333
373
  hashAlgorithm: this._chunkHashAlgorithm
334
374
  }
335
375
  });
336
- return _context6.abrupt("return", this.request('/upload/createWithFiles', options).then(createMapResponseToJson(metadata)));
376
+ return _context7.abrupt("return", this.request('/upload/createWithFiles', options).then(createMapResponseToJson(metadata)));
337
377
  case 5:
338
378
  case "end":
339
- return _context6.stop();
379
+ return _context7.stop();
340
380
  }
341
- }, _callee6, this);
381
+ }, _callee7, this);
342
382
  }));
343
- function touchFiles(_x21) {
383
+ function touchFiles(_x22) {
344
384
  return _touchFiles.apply(this, arguments);
345
385
  }
346
386
  return touchFiles;
@@ -366,26 +406,26 @@ export var MediaStore = /*#__PURE__*/function () {
366
406
  }, {
367
407
  key: "getFileImageURL",
368
408
  value: function () {
369
- var _getFileImageURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(id, params) {
409
+ var _getFileImageURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(id, params) {
370
410
  var _ref5, collectionName, auth;
371
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
372
- while (1) switch (_context7.prev = _context7.next) {
411
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
412
+ while (1) switch (_context8.prev = _context8.next) {
373
413
  case 0:
374
414
  _ref5 = params || {}, collectionName = _ref5.collection;
375
- _context7.next = 3;
415
+ _context8.next = 3;
376
416
  return this.resolveAuth({
377
417
  collectionName: collectionName
378
418
  });
379
419
  case 3:
380
- auth = _context7.sent;
381
- return _context7.abrupt("return", this.createFileImageURL(id, auth, params));
420
+ auth = _context8.sent;
421
+ return _context8.abrupt("return", this.createFileImageURL(id, auth, params));
382
422
  case 5:
383
423
  case "end":
384
- return _context7.stop();
424
+ return _context8.stop();
385
425
  }
386
- }, _callee7, this);
426
+ }, _callee8, this);
387
427
  }));
388
- function getFileImageURL(_x22, _x23) {
428
+ function getFileImageURL(_x23, _x24) {
389
429
  return _getFileImageURL.apply(this, arguments);
390
430
  }
391
431
  return getFileImageURL;
@@ -412,17 +452,17 @@ export var MediaStore = /*#__PURE__*/function () {
412
452
  }, {
413
453
  key: "getFileBinary",
414
454
  value: function () {
415
- var _getFileBinary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(id, collectionName, abortController) {
455
+ var _getFileBinary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(id, collectionName, abortController) {
416
456
  var maxAge,
417
457
  headers,
418
458
  binaryEndpoint,
419
459
  metadata,
420
460
  options,
421
- _args8 = arguments;
422
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
423
- while (1) switch (_context8.prev = _context8.next) {
461
+ _args9 = arguments;
462
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
463
+ while (1) switch (_context9.prev = _context9.next) {
424
464
  case 0:
425
- maxAge = _args8.length > 3 && _args8[3] !== undefined ? _args8[3] : FILE_CACHE_MAX_AGE;
465
+ maxAge = _args9.length > 3 && _args9[3] !== undefined ? _args9[3] : FILE_CACHE_MAX_AGE;
426
466
  headers = {};
427
467
  binaryEndpoint = cdnFeatureFlag('binary');
428
468
  metadata = {
@@ -439,14 +479,14 @@ export var MediaStore = /*#__PURE__*/function () {
439
479
  'max-age': "".concat(maxAge)
440
480
  }
441
481
  });
442
- return _context8.abrupt("return", this.request("/file/".concat(id, "/").concat(binaryEndpoint), options, abortController, true).then(createMapResponseToBlob(metadata)));
482
+ return _context9.abrupt("return", this.request("/file/".concat(id, "/").concat(binaryEndpoint), options, abortController, true).then(createMapResponseToBlob(metadata)));
443
483
  case 6:
444
484
  case "end":
445
- return _context8.stop();
485
+ return _context9.stop();
446
486
  }
447
- }, _callee8, this);
487
+ }, _callee9, this);
448
488
  }));
449
- function getFileBinary(_x24, _x25, _x26) {
489
+ function getFileBinary(_x25, _x26, _x27) {
450
490
  return _getFileBinary.apply(this, arguments);
451
491
  }
452
492
  return getFileBinary;
@@ -454,22 +494,22 @@ export var MediaStore = /*#__PURE__*/function () {
454
494
  }, {
455
495
  key: "getFileBinaryURL",
456
496
  value: function () {
457
- var _getFileBinaryURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(id, collectionName) {
497
+ var _getFileBinaryURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee0(id, collectionName) {
458
498
  var maxAge,
459
499
  auth,
460
500
  options,
461
501
  binaryEndpoint,
462
- _args9 = arguments;
463
- return _regeneratorRuntime.wrap(function _callee9$(_context9) {
464
- while (1) switch (_context9.prev = _context9.next) {
502
+ _args0 = arguments;
503
+ return _regeneratorRuntime.wrap(function _callee0$(_context0) {
504
+ while (1) switch (_context0.prev = _context0.next) {
465
505
  case 0:
466
- maxAge = _args9.length > 2 && _args9[2] !== undefined ? _args9[2] : FILE_CACHE_MAX_AGE;
467
- _context9.next = 3;
506
+ maxAge = _args0.length > 2 && _args0[2] !== undefined ? _args0[2] : FILE_CACHE_MAX_AGE;
507
+ _context0.next = 3;
468
508
  return this.resolveAuth({
469
509
  collectionName: collectionName
470
510
  });
471
511
  case 3:
472
- auth = _context9.sent;
512
+ auth = _context0.sent;
473
513
  options = {
474
514
  params: {
475
515
  dl: true,
@@ -480,19 +520,19 @@ export var MediaStore = /*#__PURE__*/function () {
480
520
  };
481
521
  binaryEndpoint = cdnFeatureFlag('binary');
482
522
  if (!isPathBasedEnabled()) {
483
- _context9.next = 8;
523
+ _context0.next = 8;
484
524
  break;
485
525
  }
486
- return _context9.abrupt("return", mapToPathBasedUrl(createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options)));
526
+ return _context0.abrupt("return", mapToPathBasedUrl(createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options)));
487
527
  case 8:
488
- return _context9.abrupt("return", mapToMediaCdnUrl(createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options), auth.token));
528
+ return _context0.abrupt("return", mapToMediaCdnUrl(createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options), auth.token));
489
529
  case 9:
490
530
  case "end":
491
- return _context9.stop();
531
+ return _context0.stop();
492
532
  }
493
- }, _callee9, this);
533
+ }, _callee0, this);
494
534
  }));
495
- function getFileBinaryURL(_x27, _x28) {
535
+ function getFileBinaryURL(_x28, _x29) {
496
536
  return _getFileBinaryURL.apply(this, arguments);
497
537
  }
498
538
  return getFileBinaryURL;
@@ -500,17 +540,17 @@ export var MediaStore = /*#__PURE__*/function () {
500
540
  }, {
501
541
  key: "getArtifactURL",
502
542
  value: function () {
503
- var _getArtifactURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee0(artifacts, artifactName, collectionName) {
543
+ var _getArtifactURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee1(artifacts, artifactName, collectionName) {
504
544
  var maxAge,
505
545
  artifactUrl,
506
546
  auth,
507
547
  options,
508
548
  url,
509
- _args0 = arguments;
510
- return _regeneratorRuntime.wrap(function _callee0$(_context0) {
511
- while (1) switch (_context0.prev = _context0.next) {
549
+ _args1 = arguments;
550
+ return _regeneratorRuntime.wrap(function _callee1$(_context1) {
551
+ while (1) switch (_context1.prev = _context1.next) {
512
552
  case 0:
513
- maxAge = _args0.length > 3 && _args0[3] !== undefined ? _args0[3] : FILE_CACHE_MAX_AGE;
553
+ maxAge = _args1.length > 3 && _args1[3] !== undefined ? _args1[3] : FILE_CACHE_MAX_AGE;
514
554
  // ----- WARNING ----------
515
555
  // DO NOT USE!!!!!
516
556
  // artifact.cdnUrl fails in Jira.
@@ -525,17 +565,17 @@ export var MediaStore = /*#__PURE__*/function () {
525
565
  } */
526
566
  artifactUrl = getArtifactUrl(artifacts, artifactName);
527
567
  if (artifactUrl) {
528
- _context0.next = 4;
568
+ _context1.next = 4;
529
569
  break;
530
570
  }
531
571
  throw new Error("artifact ".concat(artifactName, " not found"));
532
572
  case 4:
533
- _context0.next = 6;
573
+ _context1.next = 6;
534
574
  return this.resolveAuth({
535
575
  collectionName: collectionName
536
576
  });
537
577
  case 6:
538
- auth = _context0.sent;
578
+ auth = _context1.sent;
539
579
  options = {
540
580
  params: {
541
581
  collection: collectionName,
@@ -545,19 +585,19 @@ export var MediaStore = /*#__PURE__*/function () {
545
585
  };
546
586
  url = mapToMediaCdnUrl(createUrl("".concat(auth.baseUrl).concat(artifactUrl), options), auth.token);
547
587
  if (!isPathBasedEnabled()) {
548
- _context0.next = 11;
588
+ _context1.next = 11;
549
589
  break;
550
590
  }
551
- return _context0.abrupt("return", mapToPathBasedUrl(url));
591
+ return _context1.abrupt("return", mapToPathBasedUrl(url));
552
592
  case 11:
553
- return _context0.abrupt("return", url);
593
+ return _context1.abrupt("return", url);
554
594
  case 12:
555
595
  case "end":
556
- return _context0.stop();
596
+ return _context1.stop();
557
597
  }
558
- }, _callee0, this);
598
+ }, _callee1, this);
559
599
  }));
560
- function getArtifactURL(_x29, _x30, _x31) {
600
+ function getArtifactURL(_x30, _x31, _x32) {
561
601
  return _getArtifactURL.apply(this, arguments);
562
602
  }
563
603
  return getArtifactURL;
@@ -565,10 +605,10 @@ export var MediaStore = /*#__PURE__*/function () {
565
605
  }, {
566
606
  key: "getImage",
567
607
  value: function () {
568
- var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee1(id, params, controller, fetchMaxRes, traceContext) {
608
+ var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(id, params, controller, fetchMaxRes, traceContext) {
569
609
  var isWebpSupported, headers, imageEndpoint, metadata, options;
570
- return _regeneratorRuntime.wrap(function _callee1$(_context1) {
571
- while (1) switch (_context1.prev = _context1.next) {
610
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
611
+ while (1) switch (_context10.prev = _context10.next) {
572
612
  case 0:
573
613
  // TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
574
614
  isWebpSupported = false;
@@ -590,14 +630,14 @@ export var MediaStore = /*#__PURE__*/function () {
590
630
  traceContext: traceContext,
591
631
  addMediaClientParam: true
592
632
  });
593
- return _context1.abrupt("return", this.request("/file/".concat(id, "/").concat(imageEndpoint), options, controller, true).then(createMapResponseToBlob(metadata)));
633
+ return _context10.abrupt("return", this.request("/file/".concat(id, "/").concat(imageEndpoint), options, controller, true).then(createMapResponseToBlob(metadata)));
594
634
  case 7:
595
635
  case "end":
596
- return _context1.stop();
636
+ return _context10.stop();
597
637
  }
598
- }, _callee1, this);
638
+ }, _callee10, this);
599
639
  }));
600
- function getImage(_x32, _x33, _x34, _x35, _x36) {
640
+ function getImage(_x33, _x34, _x35, _x36, _x37) {
601
641
  return _getImage.apply(this, arguments);
602
642
  }
603
643
  return getImage;
@@ -605,10 +645,10 @@ export var MediaStore = /*#__PURE__*/function () {
605
645
  }, {
606
646
  key: "getItems",
607
647
  value: function () {
608
- var _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(ids, collectionName, traceContext, includeHashForDuplicateFiles) {
648
+ var _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(ids, collectionName, traceContext, includeHashForDuplicateFiles) {
609
649
  var descriptors, metadata, options;
610
- return _regeneratorRuntime.wrap(function _callee10$(_context10) {
611
- while (1) switch (_context10.prev = _context10.next) {
650
+ return _regeneratorRuntime.wrap(function _callee11$(_context11) {
651
+ while (1) switch (_context11.prev = _context11.next) {
612
652
  case 0:
613
653
  descriptors = ids.map(function (id) {
614
654
  return {
@@ -632,14 +672,14 @@ export var MediaStore = /*#__PURE__*/function () {
632
672
  }),
633
673
  traceContext: traceContext
634
674
  });
635
- return _context10.abrupt("return", this.request('/items', options).then(createMapResponseToJson(metadata)));
675
+ return _context11.abrupt("return", this.request('/items', options).then(createMapResponseToJson(metadata)));
636
676
  case 4:
637
677
  case "end":
638
- return _context10.stop();
678
+ return _context11.stop();
639
679
  }
640
- }, _callee10, this);
680
+ }, _callee11, this);
641
681
  }));
642
- function getItems(_x37, _x38, _x39, _x40) {
682
+ function getItems(_x38, _x39, _x40, _x41) {
643
683
  return _getItems.apply(this, arguments);
644
684
  }
645
685
  return getItems;
@@ -647,10 +687,10 @@ export var MediaStore = /*#__PURE__*/function () {
647
687
  }, {
648
688
  key: "getImageMetadata",
649
689
  value: function () {
650
- var _getImageMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(id, params, traceContext) {
690
+ var _getImageMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(id, params, traceContext) {
651
691
  var metadata, options;
652
- return _regeneratorRuntime.wrap(function _callee11$(_context11) {
653
- while (1) switch (_context11.prev = _context11.next) {
692
+ return _regeneratorRuntime.wrap(function _callee12$(_context12) {
693
+ while (1) switch (_context12.prev = _context12.next) {
654
694
  case 0:
655
695
  metadata = {
656
696
  method: 'GET',
@@ -663,14 +703,14 @@ export var MediaStore = /*#__PURE__*/function () {
663
703
  params: params,
664
704
  traceContext: traceContext
665
705
  });
666
- return _context11.abrupt("return", this.request("/file/".concat(id, "/image/metadata"), options).then(createMapResponseToJson(metadata)));
706
+ return _context12.abrupt("return", this.request("/file/".concat(id, "/image/metadata"), options).then(createMapResponseToJson(metadata)));
667
707
  case 3:
668
708
  case "end":
669
- return _context11.stop();
709
+ return _context12.stop();
670
710
  }
671
- }, _callee11, this);
711
+ }, _callee12, this);
672
712
  }));
673
- function getImageMetadata(_x41, _x42, _x43) {
713
+ function getImageMetadata(_x42, _x43, _x44) {
674
714
  return _getImageMetadata.apply(this, arguments);
675
715
  }
676
716
  return getImageMetadata;
@@ -678,10 +718,10 @@ export var MediaStore = /*#__PURE__*/function () {
678
718
  }, {
679
719
  key: "getDocumentContent",
680
720
  value: function () {
681
- var _getDocumentContent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(id, options, traceContext) {
721
+ var _getDocumentContent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(id, options, traceContext) {
682
722
  var shouldCache, endpoint, metadata, headers, requestOptions;
683
- return _regeneratorRuntime.wrap(function _callee12$(_context12) {
684
- while (1) switch (_context12.prev = _context12.next) {
723
+ return _regeneratorRuntime.wrap(function _callee13$(_context13) {
724
+ while (1) switch (_context13.prev = _context13.next) {
685
725
  case 0:
686
726
  // when requesting for password protected document don't use CDN as it won't forward headers
687
727
  // this is deliberate to avoid caching Password protected files
@@ -708,14 +748,14 @@ export var MediaStore = /*#__PURE__*/function () {
708
748
  },
709
749
  traceContext: traceContext
710
750
  });
711
- return _context12.abrupt("return", this.request("/file/".concat(id, "/document/").concat(endpoint), requestOptions).then(createMapResponseToJson(metadata)));
751
+ return _context13.abrupt("return", this.request("/file/".concat(id, "/document/").concat(endpoint), requestOptions).then(createMapResponseToJson(metadata)));
712
752
  case 6:
713
753
  case "end":
714
- return _context12.stop();
754
+ return _context13.stop();
715
755
  }
716
- }, _callee12, this);
756
+ }, _callee13, this);
717
757
  }));
718
- function getDocumentContent(_x44, _x45, _x46) {
758
+ function getDocumentContent(_x45, _x46, _x47) {
719
759
  return _getDocumentContent.apply(this, arguments);
720
760
  }
721
761
  return getDocumentContent;
@@ -723,10 +763,10 @@ export var MediaStore = /*#__PURE__*/function () {
723
763
  }, {
724
764
  key: "getDocumentPageImage",
725
765
  value: function () {
726
- var _getDocumentPageImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(id, options, traceContext) {
766
+ var _getDocumentPageImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(id, options, traceContext) {
727
767
  var shouldCache, endpoint, metadata, headers, requestOptions;
728
- return _regeneratorRuntime.wrap(function _callee13$(_context13) {
729
- while (1) switch (_context13.prev = _context13.next) {
768
+ return _regeneratorRuntime.wrap(function _callee14$(_context14) {
769
+ while (1) switch (_context14.prev = _context14.next) {
730
770
  case 0:
731
771
  // when requesting for password protected document don't use CDN as it won't forward headers
732
772
  // this is deliberate to avoid caching Password protected files
@@ -753,14 +793,14 @@ export var MediaStore = /*#__PURE__*/function () {
753
793
  },
754
794
  traceContext: traceContext
755
795
  });
756
- return _context13.abrupt("return", this.request("/file/".concat(id, "/document/").concat(endpoint), requestOptions).then(createMapResponseToBlob(metadata)));
796
+ return _context14.abrupt("return", this.request("/file/".concat(id, "/document/").concat(endpoint), requestOptions).then(createMapResponseToBlob(metadata)));
757
797
  case 6:
758
798
  case "end":
759
- return _context13.stop();
799
+ return _context14.stop();
760
800
  }
761
- }, _callee13, this);
801
+ }, _callee14, this);
762
802
  }));
763
- function getDocumentPageImage(_x47, _x48, _x49) {
803
+ function getDocumentPageImage(_x48, _x49, _x50) {
764
804
  return _getDocumentPageImage.apply(this, arguments);
765
805
  }
766
806
  return getDocumentPageImage;
@@ -768,10 +808,10 @@ export var MediaStore = /*#__PURE__*/function () {
768
808
  }, {
769
809
  key: "appendChunksToUpload",
770
810
  value: function () {
771
- var _appendChunksToUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(uploadId, body, collectionName, traceContext) {
811
+ var _appendChunksToUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(uploadId, body, collectionName, traceContext) {
772
812
  var metadata, options;
773
- return _regeneratorRuntime.wrap(function _callee14$(_context14) {
774
- while (1) switch (_context14.prev = _context14.next) {
813
+ return _regeneratorRuntime.wrap(function _callee15$(_context15) {
814
+ while (1) switch (_context15.prev = _context15.next) {
775
815
  case 0:
776
816
  metadata = {
777
817
  method: 'PUT',
@@ -785,15 +825,15 @@ export var MediaStore = /*#__PURE__*/function () {
785
825
  body: JSON.stringify(body),
786
826
  traceContext: traceContext
787
827
  });
788
- _context14.next = 4;
828
+ _context15.next = 4;
789
829
  return this.request("/upload/".concat(uploadId, "/chunks"), options);
790
830
  case 4:
791
831
  case "end":
792
- return _context14.stop();
832
+ return _context15.stop();
793
833
  }
794
- }, _callee14, this);
834
+ }, _callee15, this);
795
835
  }));
796
- function appendChunksToUpload(_x50, _x51, _x52, _x53) {
836
+ function appendChunksToUpload(_x51, _x52, _x53, _x54) {
797
837
  return _appendChunksToUpload.apply(this, arguments);
798
838
  }
799
839
  return appendChunksToUpload;
@@ -821,7 +861,7 @@ export var MediaStore = /*#__PURE__*/function () {
821
861
  }
822
862
  }, {
823
863
  key: "copyFile",
824
- value: function copyFile(id, params, traceContext) {
864
+ value: function copyFile(id, params, traceContext, clientId) {
825
865
  var metadata = {
826
866
  method: 'POST',
827
867
  endpoint: '/v2/file/copy'
@@ -833,7 +873,8 @@ export var MediaStore = /*#__PURE__*/function () {
833
873
  params: params,
834
874
  headers: jsonHeaders,
835
875
  body: JSON.stringify({
836
- id: id
876
+ id: id,
877
+ clientId: clientId
837
878
  }),
838
879
  traceContext: traceContext,
839
880
  clientOptions: {
@@ -850,10 +891,10 @@ export var MediaStore = /*#__PURE__*/function () {
850
891
  }, {
851
892
  key: "registerCopyIntents",
852
893
  value: function () {
853
- var _registerCopyIntents = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(files, traceContext, resolvedAuth) {
894
+ var _registerCopyIntents = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(files, traceContext, resolvedAuth) {
854
895
  var metadata, options;
855
- return _regeneratorRuntime.wrap(function _callee15$(_context15) {
856
- while (1) switch (_context15.prev = _context15.next) {
896
+ return _regeneratorRuntime.wrap(function _callee16$(_context16) {
897
+ while (1) switch (_context16.prev = _context16.next) {
857
898
  case 0:
858
899
  metadata = {
859
900
  method: 'POST',
@@ -867,15 +908,15 @@ export var MediaStore = /*#__PURE__*/function () {
867
908
  traceContext: traceContext,
868
909
  resolvedAuth: resolvedAuth
869
910
  });
870
- _context15.next = 4;
911
+ _context16.next = 4;
871
912
  return this.request('/file/copy/intents', options);
872
913
  case 4:
873
914
  case "end":
874
- return _context15.stop();
915
+ return _context16.stop();
875
916
  }
876
- }, _callee15, this);
917
+ }, _callee16, this);
877
918
  }));
878
- function registerCopyIntents(_x54, _x55, _x56) {
919
+ function registerCopyIntents(_x55, _x56, _x57) {
879
920
  return _registerCopyIntents.apply(this, arguments);
880
921
  }
881
922
  return registerCopyIntents;
@@ -883,7 +924,7 @@ export var MediaStore = /*#__PURE__*/function () {
883
924
  }, {
884
925
  key: "request",
885
926
  value: function () {
886
- var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(path) {
927
+ var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(path) {
887
928
  var options,
888
929
  controller,
889
930
  useMediaCdn,
@@ -903,32 +944,32 @@ export var MediaStore = /*#__PURE__*/function () {
903
944
  extendedParams,
904
945
  url,
905
946
  response,
906
- _args16 = arguments;
907
- return _regeneratorRuntime.wrap(function _callee16$(_context16) {
908
- while (1) switch (_context16.prev = _context16.next) {
947
+ _args17 = arguments;
948
+ return _regeneratorRuntime.wrap(function _callee17$(_context17) {
949
+ while (1) switch (_context17.prev = _context17.next) {
909
950
  case 0:
910
- options = _args16.length > 1 && _args16[1] !== undefined ? _args16[1] : {
951
+ options = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : {
911
952
  method: 'GET',
912
953
  endpoint: undefined,
913
954
  authContext: {}
914
955
  };
915
- controller = _args16.length > 2 ? _args16[2] : undefined;
916
- useMediaCdn = _args16.length > 3 ? _args16[3] : undefined;
956
+ controller = _args17.length > 2 ? _args17[2] : undefined;
957
+ useMediaCdn = _args17.length > 3 ? _args17[3] : undefined;
917
958
  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, resolvedAuth = options.resolvedAuth;
918
959
  if (!(resolvedAuth !== null && resolvedAuth !== void 0)) {
919
- _context16.next = 8;
960
+ _context17.next = 8;
920
961
  break;
921
962
  }
922
- _context16.t0 = resolvedAuth;
923
- _context16.next = 11;
963
+ _context17.t0 = resolvedAuth;
964
+ _context17.next = 11;
924
965
  break;
925
966
  case 8:
926
- _context16.next = 10;
967
+ _context17.next = 10;
927
968
  return this.resolveAuth(authContext);
928
969
  case 10:
929
- _context16.t0 = _context16.sent;
970
+ _context17.t0 = _context17.sent;
930
971
  case 11:
931
- auth = _context16.t0;
972
+ auth = _context17.t0;
932
973
  clientId = isClientBasedAuth(auth) ? auth.clientId : undefined;
933
974
  extendedTraceContext = extendTraceContext(traceContext);
934
975
  extendedParams = addMediaClientParam ? _objectSpread(_objectSpread({}, params), {}, {
@@ -941,7 +982,7 @@ export var MediaStore = /*#__PURE__*/function () {
941
982
  if (isPathBasedEnabled()) {
942
983
  url = mapToPathBasedUrl(url);
943
984
  }
944
- _context16.next = 20;
985
+ _context17.next = 20;
945
986
  return _request(url, {
946
987
  method: method,
947
988
  endpoint: endpoint,
@@ -953,17 +994,17 @@ export var MediaStore = /*#__PURE__*/function () {
953
994
  traceContext: extendedTraceContext
954
995
  }, controller);
955
996
  case 20:
956
- response = _context16.sent;
997
+ response = _context17.sent;
957
998
  setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
958
999
  setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
959
- return _context16.abrupt("return", response);
1000
+ return _context17.abrupt("return", response);
960
1001
  case 24:
961
1002
  case "end":
962
- return _context16.stop();
1003
+ return _context17.stop();
963
1004
  }
964
- }, _callee16, this);
1005
+ }, _callee17, this);
965
1006
  }));
966
- function request(_x57) {
1007
+ function request(_x58) {
967
1008
  return _request2.apply(this, arguments);
968
1009
  }
969
1010
  return request;
@@ -971,16 +1012,16 @@ export var MediaStore = /*#__PURE__*/function () {
971
1012
  }, {
972
1013
  key: "testUrl",
973
1014
  value: function () {
974
- var _testUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(url) {
1015
+ var _testUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(url) {
975
1016
  var options,
976
1017
  traceContext,
977
- _args17 = arguments;
978
- return _regeneratorRuntime.wrap(function _callee17$(_context17) {
979
- while (1) switch (_context17.prev = _context17.next) {
1018
+ _args18 = arguments;
1019
+ return _regeneratorRuntime.wrap(function _callee18$(_context18) {
1020
+ while (1) switch (_context18.prev = _context18.next) {
980
1021
  case 0:
981
- options = _args17.length > 1 && _args17[1] !== undefined ? _args17[1] : {};
1022
+ options = _args18.length > 1 && _args18[1] !== undefined ? _args18[1] : {};
982
1023
  traceContext = options.traceContext;
983
- _context17.next = 4;
1024
+ _context18.next = 4;
984
1025
  return _request(url, {
985
1026
  method: 'HEAD',
986
1027
  traceContext: extendTraceContext(traceContext),
@@ -992,11 +1033,11 @@ export var MediaStore = /*#__PURE__*/function () {
992
1033
  });
993
1034
  case 4:
994
1035
  case "end":
995
- return _context17.stop();
1036
+ return _context18.stop();
996
1037
  }
997
- }, _callee17);
1038
+ }, _callee18);
998
1039
  }));
999
- function testUrl(_x58) {
1040
+ function testUrl(_x59) {
1000
1041
  return _testUrl.apply(this, arguments);
1001
1042
  }
1002
1043
  return testUrl;