@atlaskit/media-client 39.4.11 → 39.4.13
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/AGENTS.md +8 -0
- package/CHANGELOG.md +16 -0
- package/README.md +14 -0
- package/dist/cjs/client/media-store/MediaStore.js +449 -198
- package/dist/es2019/client/media-store/MediaStore.js +115 -41
- package/dist/esm/client/media-store/MediaStore.js +449 -198
- package/dist/types/client/media-store/MediaStore.d.ts +1 -0
- package/package.json +2 -2
|
@@ -17,6 +17,7 @@ import { isPathBasedEnabled } from '../../utils/isPathBasedEnabled';
|
|
|
17
17
|
import { mapToMediaCdnUrl } from '../../utils/mapToMediaCdnUrl';
|
|
18
18
|
import { mapToPathBasedUrl } from '../../utils/mapToPathBasedUrl';
|
|
19
19
|
import { mapToSeedBasedCdnUrl } from '../../utils/mapToSeedBasedCdnUrl';
|
|
20
|
+
import { MEDIA_TOKEN_LENGTH_LIMIT } from '../../utils/mediaCdn';
|
|
20
21
|
import { isRequestError, request as _request } from '../../utils/request';
|
|
21
22
|
import { createMapResponseToBlob } from '../../utils/request/createMapResponseToBlob';
|
|
22
23
|
import { createMapResponseToJson } from '../../utils/request/createMapResponseToJson';
|
|
@@ -390,45 +391,87 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
390
391
|
}()
|
|
391
392
|
}, {
|
|
392
393
|
key: "getFile",
|
|
393
|
-
value: function getFile(fileId) {
|
|
394
|
-
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
395
|
-
var traceContext = arguments.length > 2 ? arguments[2] : undefined;
|
|
396
|
-
var metadata = {
|
|
397
|
-
method: 'GET',
|
|
398
|
-
endpoint: '/file/{fileId}'
|
|
399
|
-
};
|
|
400
|
-
var options = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
401
|
-
authContext: {
|
|
402
|
-
collectionName: params.collection
|
|
403
|
-
},
|
|
404
|
-
params: params,
|
|
405
|
-
traceContext: traceContext
|
|
406
|
-
});
|
|
407
|
-
return this.request("/file/".concat(fileId), options).then(createMapResponseToJson(metadata));
|
|
408
|
-
}
|
|
409
|
-
}, {
|
|
410
|
-
key: "getFileImageURL",
|
|
411
394
|
value: function () {
|
|
412
|
-
var
|
|
413
|
-
var
|
|
395
|
+
var _getFile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(fileId) {
|
|
396
|
+
var params,
|
|
397
|
+
traceContext,
|
|
398
|
+
metadata,
|
|
399
|
+
options,
|
|
400
|
+
_args8 = arguments,
|
|
401
|
+
_t,
|
|
402
|
+
_t2,
|
|
403
|
+
_t3,
|
|
404
|
+
_t4,
|
|
405
|
+
_t5;
|
|
414
406
|
return _regeneratorRuntime.wrap(function (_context8) {
|
|
415
407
|
while (1) switch (_context8.prev = _context8.next) {
|
|
416
408
|
case 0:
|
|
417
|
-
|
|
409
|
+
params = _args8.length > 1 && _args8[1] !== undefined ? _args8[1] : {};
|
|
410
|
+
traceContext = _args8.length > 2 ? _args8[2] : undefined;
|
|
411
|
+
metadata = {
|
|
412
|
+
method: 'GET',
|
|
413
|
+
endpoint: '/file/{fileId}'
|
|
414
|
+
};
|
|
415
|
+
_t = _objectSpread;
|
|
416
|
+
_t2 = _objectSpread;
|
|
417
|
+
_t3 = _objectSpread({}, metadata);
|
|
418
|
+
if (!fg('platform_media_bounded_read_tokens')) {
|
|
419
|
+
_context8.next = 2;
|
|
420
|
+
break;
|
|
421
|
+
}
|
|
418
422
|
_context8.next = 1;
|
|
419
|
-
return this.
|
|
420
|
-
collectionName: collectionName
|
|
421
|
-
});
|
|
423
|
+
return this.resolveReadAuth(fileId, params.collection);
|
|
422
424
|
case 1:
|
|
423
|
-
|
|
424
|
-
|
|
425
|
+
_t5 = _context8.sent;
|
|
426
|
+
_t4 = {
|
|
427
|
+
resolvedAuth: _t5
|
|
428
|
+
};
|
|
429
|
+
_context8.next = 3;
|
|
430
|
+
break;
|
|
425
431
|
case 2:
|
|
432
|
+
_t4 = {
|
|
433
|
+
authContext: {
|
|
434
|
+
collectionName: params.collection
|
|
435
|
+
}
|
|
436
|
+
};
|
|
437
|
+
case 3:
|
|
438
|
+
options = _t(_t2(_t3, _t4), {}, {
|
|
439
|
+
params: params,
|
|
440
|
+
traceContext: traceContext
|
|
441
|
+
});
|
|
442
|
+
return _context8.abrupt("return", this.request("/file/".concat(fileId), options).then(createMapResponseToJson(metadata)));
|
|
443
|
+
case 4:
|
|
426
444
|
case "end":
|
|
427
445
|
return _context8.stop();
|
|
428
446
|
}
|
|
429
447
|
}, _callee8, this);
|
|
430
448
|
}));
|
|
431
|
-
function
|
|
449
|
+
function getFile(_x23) {
|
|
450
|
+
return _getFile.apply(this, arguments);
|
|
451
|
+
}
|
|
452
|
+
return getFile;
|
|
453
|
+
}()
|
|
454
|
+
}, {
|
|
455
|
+
key: "getFileImageURL",
|
|
456
|
+
value: function () {
|
|
457
|
+
var _getFileImageURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(id, params) {
|
|
458
|
+
var _ref5, collectionName, auth;
|
|
459
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
460
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
461
|
+
case 0:
|
|
462
|
+
_ref5 = params || {}, collectionName = _ref5.collection;
|
|
463
|
+
_context9.next = 1;
|
|
464
|
+
return this.resolveReadAuth(id, collectionName);
|
|
465
|
+
case 1:
|
|
466
|
+
auth = _context9.sent;
|
|
467
|
+
return _context9.abrupt("return", this.createFileImageURL(id, auth, params));
|
|
468
|
+
case 2:
|
|
469
|
+
case "end":
|
|
470
|
+
return _context9.stop();
|
|
471
|
+
}
|
|
472
|
+
}, _callee9, this);
|
|
473
|
+
}));
|
|
474
|
+
function getFileImageURL(_x24, _x25) {
|
|
432
475
|
return _getFileImageURL.apply(this, arguments);
|
|
433
476
|
}
|
|
434
477
|
return getFileImageURL;
|
|
@@ -461,41 +504,66 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
461
504
|
}, {
|
|
462
505
|
key: "getFileBinary",
|
|
463
506
|
value: function () {
|
|
464
|
-
var _getFileBinary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
507
|
+
var _getFileBinary = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee0(id, collectionName, abortController) {
|
|
465
508
|
var maxAge,
|
|
466
509
|
headers,
|
|
467
510
|
binaryEndpoint,
|
|
468
511
|
metadata,
|
|
469
512
|
options,
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
513
|
+
_args0 = arguments,
|
|
514
|
+
_t6,
|
|
515
|
+
_t7,
|
|
516
|
+
_t8,
|
|
517
|
+
_t9,
|
|
518
|
+
_t0;
|
|
519
|
+
return _regeneratorRuntime.wrap(function (_context0) {
|
|
520
|
+
while (1) switch (_context0.prev = _context0.next) {
|
|
473
521
|
case 0:
|
|
474
|
-
maxAge =
|
|
522
|
+
maxAge = _args0.length > 3 && _args0[3] !== undefined ? _args0[3] : FILE_CACHE_MAX_AGE;
|
|
475
523
|
headers = {};
|
|
476
524
|
binaryEndpoint = cdnFeatureFlag('binary');
|
|
477
525
|
metadata = {
|
|
478
526
|
method: 'GET',
|
|
479
527
|
endpoint: "/file/{fileId}/".concat(binaryEndpoint)
|
|
480
528
|
};
|
|
481
|
-
|
|
529
|
+
_t6 = _objectSpread;
|
|
530
|
+
_t7 = _objectSpread;
|
|
531
|
+
_t8 = _objectSpread({}, metadata);
|
|
532
|
+
if (!fg('platform_media_bounded_read_tokens')) {
|
|
533
|
+
_context0.next = 2;
|
|
534
|
+
break;
|
|
535
|
+
}
|
|
536
|
+
_context0.next = 1;
|
|
537
|
+
return this.resolveReadAuth(id, collectionName);
|
|
538
|
+
case 1:
|
|
539
|
+
_t0 = _context0.sent;
|
|
540
|
+
_t9 = {
|
|
541
|
+
resolvedAuth: _t0
|
|
542
|
+
};
|
|
543
|
+
_context0.next = 3;
|
|
544
|
+
break;
|
|
545
|
+
case 2:
|
|
546
|
+
_t9 = {
|
|
482
547
|
authContext: {
|
|
483
548
|
collectionName: collectionName
|
|
484
|
-
}
|
|
549
|
+
}
|
|
550
|
+
};
|
|
551
|
+
case 3:
|
|
552
|
+
options = _t6(_t7(_t8, _t9), {}, {
|
|
485
553
|
headers: headers,
|
|
486
554
|
params: {
|
|
487
555
|
collection: collectionName,
|
|
488
556
|
'max-age': "".concat(maxAge)
|
|
489
557
|
}
|
|
490
558
|
});
|
|
491
|
-
return
|
|
492
|
-
case
|
|
559
|
+
return _context0.abrupt("return", this.request("/file/".concat(id, "/").concat(binaryEndpoint), options, abortController, true).then(createMapResponseToBlob(metadata)));
|
|
560
|
+
case 4:
|
|
493
561
|
case "end":
|
|
494
|
-
return
|
|
562
|
+
return _context0.stop();
|
|
495
563
|
}
|
|
496
|
-
},
|
|
564
|
+
}, _callee0, this);
|
|
497
565
|
}));
|
|
498
|
-
function getFileBinary(
|
|
566
|
+
function getFileBinary(_x26, _x27, _x28) {
|
|
499
567
|
return _getFileBinary.apply(this, arguments);
|
|
500
568
|
}
|
|
501
569
|
return getFileBinary;
|
|
@@ -503,24 +571,22 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
503
571
|
}, {
|
|
504
572
|
key: "getFileBinaryURL",
|
|
505
573
|
value: function () {
|
|
506
|
-
var _getFileBinaryURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
574
|
+
var _getFileBinaryURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee1(id, collectionName) {
|
|
507
575
|
var maxAge,
|
|
508
576
|
name,
|
|
509
577
|
auth,
|
|
510
578
|
options,
|
|
511
579
|
binaryEndpoint,
|
|
512
|
-
|
|
513
|
-
return _regeneratorRuntime.wrap(function (
|
|
514
|
-
while (1) switch (
|
|
580
|
+
_args1 = arguments;
|
|
581
|
+
return _regeneratorRuntime.wrap(function (_context1) {
|
|
582
|
+
while (1) switch (_context1.prev = _context1.next) {
|
|
515
583
|
case 0:
|
|
516
|
-
maxAge =
|
|
517
|
-
name =
|
|
518
|
-
|
|
519
|
-
return this.
|
|
520
|
-
collectionName: collectionName
|
|
521
|
-
});
|
|
584
|
+
maxAge = _args1.length > 2 && _args1[2] !== undefined ? _args1[2] : FILE_CACHE_MAX_AGE;
|
|
585
|
+
name = _args1.length > 3 ? _args1[3] : undefined;
|
|
586
|
+
_context1.next = 1;
|
|
587
|
+
return this.resolveReadAuth(id, collectionName);
|
|
522
588
|
case 1:
|
|
523
|
-
auth =
|
|
589
|
+
auth = _context1.sent;
|
|
524
590
|
options = {
|
|
525
591
|
params: _objectSpread({
|
|
526
592
|
dl: true,
|
|
@@ -533,19 +599,19 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
533
599
|
};
|
|
534
600
|
binaryEndpoint = cdnFeatureFlag('binary');
|
|
535
601
|
if (!isPathBasedEnabled()) {
|
|
536
|
-
|
|
602
|
+
_context1.next = 2;
|
|
537
603
|
break;
|
|
538
604
|
}
|
|
539
|
-
return
|
|
605
|
+
return _context1.abrupt("return", mapToPathBasedUrl(createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options)));
|
|
540
606
|
case 2:
|
|
541
|
-
return
|
|
607
|
+
return _context1.abrupt("return", mapToMediaCdnUrl(createUrl("".concat(auth.baseUrl, "/file/").concat(id, "/").concat(binaryEndpoint), options), auth.token));
|
|
542
608
|
case 3:
|
|
543
609
|
case "end":
|
|
544
|
-
return
|
|
610
|
+
return _context1.stop();
|
|
545
611
|
}
|
|
546
|
-
},
|
|
612
|
+
}, _callee1, this);
|
|
547
613
|
}));
|
|
548
|
-
function getFileBinaryURL(
|
|
614
|
+
function getFileBinaryURL(_x29, _x30) {
|
|
549
615
|
return _getFileBinaryURL.apply(this, arguments);
|
|
550
616
|
}
|
|
551
617
|
return getFileBinaryURL;
|
|
@@ -553,17 +619,17 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
553
619
|
}, {
|
|
554
620
|
key: "getArtifactURL",
|
|
555
621
|
value: function () {
|
|
556
|
-
var _getArtifactURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
622
|
+
var _getArtifactURL = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(artifacts, artifactName, collectionName) {
|
|
557
623
|
var maxAge,
|
|
558
624
|
artifactUrl,
|
|
559
625
|
auth,
|
|
560
626
|
options,
|
|
561
627
|
url,
|
|
562
|
-
|
|
563
|
-
return _regeneratorRuntime.wrap(function (
|
|
564
|
-
while (1) switch (
|
|
628
|
+
_args10 = arguments;
|
|
629
|
+
return _regeneratorRuntime.wrap(function (_context10) {
|
|
630
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
565
631
|
case 0:
|
|
566
|
-
maxAge =
|
|
632
|
+
maxAge = _args10.length > 3 && _args10[3] !== undefined ? _args10[3] : FILE_CACHE_MAX_AGE;
|
|
567
633
|
// ----- WARNING ----------
|
|
568
634
|
// DO NOT USE!!!!!
|
|
569
635
|
// artifact.cdnUrl fails in Jira.
|
|
@@ -578,17 +644,17 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
578
644
|
} */
|
|
579
645
|
artifactUrl = getArtifactUrl(artifacts, artifactName);
|
|
580
646
|
if (artifactUrl) {
|
|
581
|
-
|
|
647
|
+
_context10.next = 1;
|
|
582
648
|
break;
|
|
583
649
|
}
|
|
584
650
|
throw new Error("artifact ".concat(artifactName, " not found"));
|
|
585
651
|
case 1:
|
|
586
|
-
|
|
652
|
+
_context10.next = 2;
|
|
587
653
|
return this.resolveAuth({
|
|
588
654
|
collectionName: collectionName
|
|
589
655
|
});
|
|
590
656
|
case 2:
|
|
591
|
-
auth =
|
|
657
|
+
auth = _context10.sent;
|
|
592
658
|
options = {
|
|
593
659
|
params: {
|
|
594
660
|
collection: collectionName,
|
|
@@ -598,19 +664,19 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
598
664
|
};
|
|
599
665
|
url = mapToMediaCdnUrl(createUrl("".concat(auth.baseUrl).concat(artifactUrl), options), auth.token);
|
|
600
666
|
if (!isPathBasedEnabled()) {
|
|
601
|
-
|
|
667
|
+
_context10.next = 3;
|
|
602
668
|
break;
|
|
603
669
|
}
|
|
604
|
-
return
|
|
670
|
+
return _context10.abrupt("return", mapToPathBasedUrl(url));
|
|
605
671
|
case 3:
|
|
606
|
-
return
|
|
672
|
+
return _context10.abrupt("return", url);
|
|
607
673
|
case 4:
|
|
608
674
|
case "end":
|
|
609
|
-
return
|
|
675
|
+
return _context10.stop();
|
|
610
676
|
}
|
|
611
|
-
},
|
|
677
|
+
}, _callee10, this);
|
|
612
678
|
}));
|
|
613
|
-
function getArtifactURL(
|
|
679
|
+
function getArtifactURL(_x31, _x32, _x33) {
|
|
614
680
|
return _getArtifactURL.apply(this, arguments);
|
|
615
681
|
}
|
|
616
682
|
return getArtifactURL;
|
|
@@ -624,31 +690,31 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
624
690
|
* compare it to tell whether the watermark config has changed since.
|
|
625
691
|
*/
|
|
626
692
|
function () {
|
|
627
|
-
var _getImageWatermarkVersion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
693
|
+
var _getImageWatermarkVersion = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(collectionName) {
|
|
628
694
|
var auth;
|
|
629
|
-
return _regeneratorRuntime.wrap(function (
|
|
630
|
-
while (1) switch (
|
|
695
|
+
return _regeneratorRuntime.wrap(function (_context11) {
|
|
696
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
631
697
|
case 0:
|
|
632
698
|
if (fg('confluence_watermark_admin_ui')) {
|
|
633
|
-
|
|
699
|
+
_context11.next = 1;
|
|
634
700
|
break;
|
|
635
701
|
}
|
|
636
|
-
return
|
|
702
|
+
return _context11.abrupt("return", undefined);
|
|
637
703
|
case 1:
|
|
638
|
-
|
|
704
|
+
_context11.next = 2;
|
|
639
705
|
return this.resolveAuth({
|
|
640
706
|
collectionName: collectionName
|
|
641
707
|
});
|
|
642
708
|
case 2:
|
|
643
|
-
auth =
|
|
644
|
-
return
|
|
709
|
+
auth = _context11.sent;
|
|
710
|
+
return _context11.abrupt("return", getWatermarkVersionFromToken(auth.token));
|
|
645
711
|
case 3:
|
|
646
712
|
case "end":
|
|
647
|
-
return
|
|
713
|
+
return _context11.stop();
|
|
648
714
|
}
|
|
649
|
-
},
|
|
715
|
+
}, _callee11, this);
|
|
650
716
|
}));
|
|
651
|
-
function getImageWatermarkVersion(
|
|
717
|
+
function getImageWatermarkVersion(_x34) {
|
|
652
718
|
return _getImageWatermarkVersion.apply(this, arguments);
|
|
653
719
|
}
|
|
654
720
|
return getImageWatermarkVersion;
|
|
@@ -656,10 +722,10 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
656
722
|
}, {
|
|
657
723
|
key: "getImage",
|
|
658
724
|
value: function () {
|
|
659
|
-
var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
660
|
-
var isWebpSupported, headers, imageEndpoint, metadata, wmvParams, authOptions, auth, wmv, options;
|
|
661
|
-
return _regeneratorRuntime.wrap(function (
|
|
662
|
-
while (1) switch (
|
|
725
|
+
var _getImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(id, params, controller, fetchMaxRes, traceContext, clientOptions) {
|
|
726
|
+
var isWebpSupported, headers, imageEndpoint, metadata, wmvParams, authOptions, _authOptions$resolved, auth, wmv, options, _t1, _t10, _t11;
|
|
727
|
+
return _regeneratorRuntime.wrap(function (_context12) {
|
|
728
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
663
729
|
case 0:
|
|
664
730
|
// TODO add checkWebpSupport() back https://product-fabric.atlassian.net/browse/MPT-584
|
|
665
731
|
isWebpSupported = false;
|
|
@@ -673,19 +739,45 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
673
739
|
endpoint: "/file/{fileId}/".concat(imageEndpoint)
|
|
674
740
|
};
|
|
675
741
|
wmvParams = {};
|
|
676
|
-
|
|
742
|
+
if (!fg('platform_media_bounded_read_tokens')) {
|
|
743
|
+
_context12.next = 2;
|
|
744
|
+
break;
|
|
745
|
+
}
|
|
746
|
+
_context12.next = 1;
|
|
747
|
+
return this.resolveReadAuth(id, params && params.collection);
|
|
748
|
+
case 1:
|
|
749
|
+
_t10 = _context12.sent;
|
|
750
|
+
_t1 = {
|
|
751
|
+
resolvedAuth: _t10
|
|
752
|
+
};
|
|
753
|
+
_context12.next = 3;
|
|
754
|
+
break;
|
|
755
|
+
case 2:
|
|
756
|
+
_t1 = {
|
|
677
757
|
authContext: {
|
|
678
758
|
collectionName: params && params.collection
|
|
679
759
|
}
|
|
680
760
|
};
|
|
761
|
+
case 3:
|
|
762
|
+
authOptions = _t1;
|
|
681
763
|
if (!(fg('confluence_watermark_admin_ui') || fg('jira_enable_media_watermark_admin_ui'))) {
|
|
682
|
-
|
|
764
|
+
_context12.next = 7;
|
|
765
|
+
break;
|
|
766
|
+
}
|
|
767
|
+
if (!((_authOptions$resolved = authOptions.resolvedAuth) !== null && _authOptions$resolved !== void 0)) {
|
|
768
|
+
_context12.next = 4;
|
|
683
769
|
break;
|
|
684
770
|
}
|
|
685
|
-
|
|
771
|
+
_t11 = _authOptions$resolved;
|
|
772
|
+
_context12.next = 6;
|
|
773
|
+
break;
|
|
774
|
+
case 4:
|
|
775
|
+
_context12.next = 5;
|
|
686
776
|
return this.resolveAuth(authOptions.authContext);
|
|
687
|
-
case
|
|
688
|
-
|
|
777
|
+
case 5:
|
|
778
|
+
_t11 = _context12.sent;
|
|
779
|
+
case 6:
|
|
780
|
+
auth = _t11;
|
|
689
781
|
wmv = getWatermarkVersionFromToken(auth.token);
|
|
690
782
|
if (wmv) {
|
|
691
783
|
wmvParams = {
|
|
@@ -695,7 +787,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
695
787
|
authOptions = {
|
|
696
788
|
resolvedAuth: auth
|
|
697
789
|
};
|
|
698
|
-
case
|
|
790
|
+
case 7:
|
|
699
791
|
options = _objectSpread(_objectSpread(_objectSpread({}, metadata), authOptions), {}, {
|
|
700
792
|
params: _objectSpread(_objectSpread({}, extendImageParams(params, fetchMaxRes)), wmvParams),
|
|
701
793
|
headers: headers,
|
|
@@ -703,14 +795,14 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
703
795
|
clientOptions: clientOptions,
|
|
704
796
|
addMediaClientParam: true
|
|
705
797
|
});
|
|
706
|
-
return
|
|
707
|
-
case
|
|
798
|
+
return _context12.abrupt("return", this.request("/file/".concat(id, "/").concat(imageEndpoint), options, controller, true).then(createMapResponseToBlob(metadata)));
|
|
799
|
+
case 8:
|
|
708
800
|
case "end":
|
|
709
|
-
return
|
|
801
|
+
return _context12.stop();
|
|
710
802
|
}
|
|
711
|
-
},
|
|
803
|
+
}, _callee12, this);
|
|
712
804
|
}));
|
|
713
|
-
function getImage(
|
|
805
|
+
function getImage(_x35, _x36, _x37, _x38, _x39, _x40) {
|
|
714
806
|
return _getImage.apply(this, arguments);
|
|
715
807
|
}
|
|
716
808
|
return getImage;
|
|
@@ -718,41 +810,101 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
718
810
|
}, {
|
|
719
811
|
key: "getItems",
|
|
720
812
|
value: function () {
|
|
721
|
-
var _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
722
|
-
var
|
|
723
|
-
|
|
724
|
-
|
|
813
|
+
var _getItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(ids, collectionName, traceContext, includeHashForDuplicateFiles) {
|
|
814
|
+
var _this2 = this;
|
|
815
|
+
var metadata, requestItems, auth, fileAuth, groups, responses;
|
|
816
|
+
return _regeneratorRuntime.wrap(function (_context13) {
|
|
817
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
725
818
|
case 0:
|
|
726
|
-
descriptors = ids.map(function (id) {
|
|
727
|
-
return {
|
|
728
|
-
type: 'file',
|
|
729
|
-
id: id,
|
|
730
|
-
collection: collectionName
|
|
731
|
-
};
|
|
732
|
-
});
|
|
733
819
|
metadata = {
|
|
734
820
|
method: 'POST',
|
|
735
821
|
endpoint: '/items'
|
|
736
822
|
};
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
}),
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
823
|
+
requestItems = function requestItems(fileIds, resolvedAuth) {
|
|
824
|
+
var descriptors = fileIds.map(function (id) {
|
|
825
|
+
return {
|
|
826
|
+
type: 'file',
|
|
827
|
+
id: id,
|
|
828
|
+
collection: collectionName
|
|
829
|
+
};
|
|
830
|
+
});
|
|
831
|
+
return _this2.request('/items', _objectSpread(_objectSpread({}, metadata), {}, {
|
|
832
|
+
authContext: {
|
|
833
|
+
collectionName: collectionName
|
|
834
|
+
},
|
|
835
|
+
resolvedAuth: resolvedAuth,
|
|
836
|
+
headers: jsonHeaders,
|
|
837
|
+
body: JSON.stringify({
|
|
838
|
+
descriptors: descriptors,
|
|
839
|
+
includeHashForDuplicateFiles: includeHashForDuplicateFiles
|
|
840
|
+
}),
|
|
841
|
+
traceContext: traceContext
|
|
842
|
+
})).then(createMapResponseToJson(metadata));
|
|
843
|
+
};
|
|
844
|
+
if (fg('platform_media_bounded_read_tokens')) {
|
|
845
|
+
_context13.next = 1;
|
|
846
|
+
break;
|
|
847
|
+
}
|
|
848
|
+
return _context13.abrupt("return", requestItems(ids));
|
|
749
849
|
case 1:
|
|
850
|
+
_context13.next = 2;
|
|
851
|
+
return this.resolveAuth({
|
|
852
|
+
collectionName: collectionName
|
|
853
|
+
});
|
|
854
|
+
case 2:
|
|
855
|
+
auth = _context13.sent;
|
|
856
|
+
if (!(auth.token.length <= MEDIA_TOKEN_LENGTH_LIMIT)) {
|
|
857
|
+
_context13.next = 3;
|
|
858
|
+
break;
|
|
859
|
+
}
|
|
860
|
+
return _context13.abrupt("return", requestItems(ids, auth));
|
|
861
|
+
case 3:
|
|
862
|
+
_context13.next = 4;
|
|
863
|
+
return Promise.all(ids.map(function (id) {
|
|
864
|
+
return _this2.resolveAuth({
|
|
865
|
+
collectionName: collectionName,
|
|
866
|
+
access: [{
|
|
867
|
+
type: 'file',
|
|
868
|
+
id: id,
|
|
869
|
+
actions: ['read']
|
|
870
|
+
}]
|
|
871
|
+
});
|
|
872
|
+
}));
|
|
873
|
+
case 4:
|
|
874
|
+
fileAuth = _context13.sent;
|
|
875
|
+
groups = new Map();
|
|
876
|
+
fileAuth.forEach(function (resolvedAuth, index) {
|
|
877
|
+
var key = JSON.stringify(resolvedAuth);
|
|
878
|
+
var group = groups.get(key);
|
|
879
|
+
if (group) {
|
|
880
|
+
group.ids.push(ids[index]);
|
|
881
|
+
} else {
|
|
882
|
+
groups.set(key, {
|
|
883
|
+
auth: resolvedAuth,
|
|
884
|
+
ids: [ids[index]]
|
|
885
|
+
});
|
|
886
|
+
}
|
|
887
|
+
});
|
|
888
|
+
_context13.next = 5;
|
|
889
|
+
return Promise.all(Array.from(groups.values(), function (group) {
|
|
890
|
+
return requestItems(group.ids, group.auth);
|
|
891
|
+
}));
|
|
892
|
+
case 5:
|
|
893
|
+
responses = _context13.sent;
|
|
894
|
+
return _context13.abrupt("return", {
|
|
895
|
+
data: {
|
|
896
|
+
items: responses.flatMap(function (response) {
|
|
897
|
+
return response.data.items;
|
|
898
|
+
})
|
|
899
|
+
}
|
|
900
|
+
});
|
|
901
|
+
case 6:
|
|
750
902
|
case "end":
|
|
751
|
-
return
|
|
903
|
+
return _context13.stop();
|
|
752
904
|
}
|
|
753
|
-
},
|
|
905
|
+
}, _callee13, this);
|
|
754
906
|
}));
|
|
755
|
-
function getItems(
|
|
907
|
+
function getItems(_x41, _x42, _x43, _x44) {
|
|
756
908
|
return _getItems.apply(this, arguments);
|
|
757
909
|
}
|
|
758
910
|
return getItems;
|
|
@@ -760,30 +912,50 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
760
912
|
}, {
|
|
761
913
|
key: "getImageMetadata",
|
|
762
914
|
value: function () {
|
|
763
|
-
var _getImageMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
764
|
-
var metadata, options;
|
|
765
|
-
return _regeneratorRuntime.wrap(function (
|
|
766
|
-
while (1) switch (
|
|
915
|
+
var _getImageMetadata = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(id, params, traceContext) {
|
|
916
|
+
var metadata, options, _t12, _t13, _t14, _t15, _t16;
|
|
917
|
+
return _regeneratorRuntime.wrap(function (_context14) {
|
|
918
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
767
919
|
case 0:
|
|
768
920
|
metadata = {
|
|
769
921
|
method: 'GET',
|
|
770
922
|
endpoint: '/file/{fileId}/image/metadata'
|
|
771
923
|
};
|
|
772
|
-
|
|
924
|
+
_t12 = _objectSpread;
|
|
925
|
+
_t13 = _objectSpread;
|
|
926
|
+
_t14 = _objectSpread({}, metadata);
|
|
927
|
+
if (!fg('platform_media_bounded_read_tokens')) {
|
|
928
|
+
_context14.next = 2;
|
|
929
|
+
break;
|
|
930
|
+
}
|
|
931
|
+
_context14.next = 1;
|
|
932
|
+
return this.resolveReadAuth(id, params && params.collection);
|
|
933
|
+
case 1:
|
|
934
|
+
_t16 = _context14.sent;
|
|
935
|
+
_t15 = {
|
|
936
|
+
resolvedAuth: _t16
|
|
937
|
+
};
|
|
938
|
+
_context14.next = 3;
|
|
939
|
+
break;
|
|
940
|
+
case 2:
|
|
941
|
+
_t15 = {
|
|
773
942
|
authContext: {
|
|
774
943
|
collectionName: params && params.collection
|
|
775
|
-
}
|
|
944
|
+
}
|
|
945
|
+
};
|
|
946
|
+
case 3:
|
|
947
|
+
options = _t12(_t13(_t14, _t15), {}, {
|
|
776
948
|
params: params,
|
|
777
949
|
traceContext: traceContext
|
|
778
950
|
});
|
|
779
|
-
return
|
|
780
|
-
case
|
|
951
|
+
return _context14.abrupt("return", this.request("/file/".concat(id, "/image/metadata"), options).then(createMapResponseToJson(metadata)));
|
|
952
|
+
case 4:
|
|
781
953
|
case "end":
|
|
782
|
-
return
|
|
954
|
+
return _context14.stop();
|
|
783
955
|
}
|
|
784
|
-
},
|
|
956
|
+
}, _callee14, this);
|
|
785
957
|
}));
|
|
786
|
-
function getImageMetadata(
|
|
958
|
+
function getImageMetadata(_x45, _x46, _x47) {
|
|
787
959
|
return _getImageMetadata.apply(this, arguments);
|
|
788
960
|
}
|
|
789
961
|
return getImageMetadata;
|
|
@@ -791,10 +963,10 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
791
963
|
}, {
|
|
792
964
|
key: "getDocumentContent",
|
|
793
965
|
value: function () {
|
|
794
|
-
var _getDocumentContent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
795
|
-
var shouldCache, endpoint, metadata, headers, requestOptions;
|
|
796
|
-
return _regeneratorRuntime.wrap(function (
|
|
797
|
-
while (1) switch (
|
|
966
|
+
var _getDocumentContent = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(id, options, traceContext) {
|
|
967
|
+
var shouldCache, endpoint, metadata, headers, requestOptions, _t17, _t18, _t19, _t20, _t21;
|
|
968
|
+
return _regeneratorRuntime.wrap(function (_context15) {
|
|
969
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
798
970
|
case 0:
|
|
799
971
|
// when requesting for password protected document don't use CDN as it won't forward headers
|
|
800
972
|
// this is deliberate to avoid caching Password protected files
|
|
@@ -808,10 +980,30 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
808
980
|
headers = options.password ? {
|
|
809
981
|
'x-document-authorization': "Basic ".concat(options.password)
|
|
810
982
|
} : {};
|
|
811
|
-
|
|
983
|
+
_t17 = _objectSpread;
|
|
984
|
+
_t18 = _objectSpread;
|
|
985
|
+
_t19 = _objectSpread({}, metadata);
|
|
986
|
+
if (!fg('platform_media_bounded_read_tokens')) {
|
|
987
|
+
_context15.next = 2;
|
|
988
|
+
break;
|
|
989
|
+
}
|
|
990
|
+
_context15.next = 1;
|
|
991
|
+
return this.resolveReadAuth(id, options.collectionName);
|
|
992
|
+
case 1:
|
|
993
|
+
_t21 = _context15.sent;
|
|
994
|
+
_t20 = {
|
|
995
|
+
resolvedAuth: _t21
|
|
996
|
+
};
|
|
997
|
+
_context15.next = 3;
|
|
998
|
+
break;
|
|
999
|
+
case 2:
|
|
1000
|
+
_t20 = {
|
|
812
1001
|
authContext: {
|
|
813
1002
|
collectionName: options.collectionName
|
|
814
|
-
}
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
1005
|
+
case 3:
|
|
1006
|
+
requestOptions = _t17(_t18(_t19, _t20), {}, {
|
|
815
1007
|
headers: headers,
|
|
816
1008
|
params: {
|
|
817
1009
|
collection: options.collectionName,
|
|
@@ -821,14 +1013,14 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
821
1013
|
},
|
|
822
1014
|
traceContext: traceContext
|
|
823
1015
|
});
|
|
824
|
-
return
|
|
825
|
-
case
|
|
1016
|
+
return _context15.abrupt("return", this.request("/file/".concat(id, "/document/").concat(endpoint), requestOptions).then(createMapResponseToJson(metadata)));
|
|
1017
|
+
case 4:
|
|
826
1018
|
case "end":
|
|
827
|
-
return
|
|
1019
|
+
return _context15.stop();
|
|
828
1020
|
}
|
|
829
|
-
},
|
|
1021
|
+
}, _callee15, this);
|
|
830
1022
|
}));
|
|
831
|
-
function getDocumentContent(
|
|
1023
|
+
function getDocumentContent(_x48, _x49, _x50) {
|
|
832
1024
|
return _getDocumentContent.apply(this, arguments);
|
|
833
1025
|
}
|
|
834
1026
|
return getDocumentContent;
|
|
@@ -836,10 +1028,10 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
836
1028
|
}, {
|
|
837
1029
|
key: "getDocumentPageImage",
|
|
838
1030
|
value: function () {
|
|
839
|
-
var _getDocumentPageImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
840
|
-
var shouldCache, endpoint, metadata, headers, requestOptions;
|
|
841
|
-
return _regeneratorRuntime.wrap(function (
|
|
842
|
-
while (1) switch (
|
|
1031
|
+
var _getDocumentPageImage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(id, options, traceContext) {
|
|
1032
|
+
var shouldCache, endpoint, metadata, headers, requestOptions, _t22, _t23, _t24, _t25, _t26;
|
|
1033
|
+
return _regeneratorRuntime.wrap(function (_context16) {
|
|
1034
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
843
1035
|
case 0:
|
|
844
1036
|
// when requesting for password protected document don't use CDN as it won't forward headers
|
|
845
1037
|
// this is deliberate to avoid caching Password protected files
|
|
@@ -853,10 +1045,30 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
853
1045
|
headers = options.password ? {
|
|
854
1046
|
'x-document-authorization': "Basic ".concat(options.password)
|
|
855
1047
|
} : {};
|
|
856
|
-
|
|
1048
|
+
_t22 = _objectSpread;
|
|
1049
|
+
_t23 = _objectSpread;
|
|
1050
|
+
_t24 = _objectSpread({}, metadata);
|
|
1051
|
+
if (!fg('platform_media_bounded_read_tokens')) {
|
|
1052
|
+
_context16.next = 2;
|
|
1053
|
+
break;
|
|
1054
|
+
}
|
|
1055
|
+
_context16.next = 1;
|
|
1056
|
+
return this.resolveReadAuth(id, options.collectionName);
|
|
1057
|
+
case 1:
|
|
1058
|
+
_t26 = _context16.sent;
|
|
1059
|
+
_t25 = {
|
|
1060
|
+
resolvedAuth: _t26
|
|
1061
|
+
};
|
|
1062
|
+
_context16.next = 3;
|
|
1063
|
+
break;
|
|
1064
|
+
case 2:
|
|
1065
|
+
_t25 = {
|
|
857
1066
|
authContext: {
|
|
858
1067
|
collectionName: options.collectionName
|
|
859
|
-
}
|
|
1068
|
+
}
|
|
1069
|
+
};
|
|
1070
|
+
case 3:
|
|
1071
|
+
requestOptions = _t22(_t23(_t24, _t25), {}, {
|
|
860
1072
|
headers: headers,
|
|
861
1073
|
params: {
|
|
862
1074
|
collection: options.collectionName,
|
|
@@ -866,14 +1078,14 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
866
1078
|
},
|
|
867
1079
|
traceContext: traceContext
|
|
868
1080
|
});
|
|
869
|
-
return
|
|
870
|
-
case
|
|
1081
|
+
return _context16.abrupt("return", this.request("/file/".concat(id, "/document/").concat(endpoint), requestOptions).then(createMapResponseToBlob(metadata)));
|
|
1082
|
+
case 4:
|
|
871
1083
|
case "end":
|
|
872
|
-
return
|
|
1084
|
+
return _context16.stop();
|
|
873
1085
|
}
|
|
874
|
-
},
|
|
1086
|
+
}, _callee16, this);
|
|
875
1087
|
}));
|
|
876
|
-
function getDocumentPageImage(
|
|
1088
|
+
function getDocumentPageImage(_x51, _x52, _x53) {
|
|
877
1089
|
return _getDocumentPageImage.apply(this, arguments);
|
|
878
1090
|
}
|
|
879
1091
|
return getDocumentPageImage;
|
|
@@ -881,10 +1093,10 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
881
1093
|
}, {
|
|
882
1094
|
key: "appendChunksToUpload",
|
|
883
1095
|
value: function () {
|
|
884
|
-
var _appendChunksToUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1096
|
+
var _appendChunksToUpload = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(uploadId, body, collectionName, traceContext, options) {
|
|
885
1097
|
var metadata, headers, requestOptions;
|
|
886
|
-
return _regeneratorRuntime.wrap(function (
|
|
887
|
-
while (1) switch (
|
|
1098
|
+
return _regeneratorRuntime.wrap(function (_context17) {
|
|
1099
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
888
1100
|
case 0:
|
|
889
1101
|
metadata = {
|
|
890
1102
|
method: 'PUT',
|
|
@@ -902,15 +1114,15 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
902
1114
|
body: JSON.stringify(body),
|
|
903
1115
|
traceContext: traceContext
|
|
904
1116
|
});
|
|
905
|
-
|
|
1117
|
+
_context17.next = 1;
|
|
906
1118
|
return this.request("/upload/".concat(uploadId, "/chunks"), requestOptions);
|
|
907
1119
|
case 1:
|
|
908
1120
|
case "end":
|
|
909
|
-
return
|
|
1121
|
+
return _context17.stop();
|
|
910
1122
|
}
|
|
911
|
-
},
|
|
1123
|
+
}, _callee17, this);
|
|
912
1124
|
}));
|
|
913
|
-
function appendChunksToUpload(
|
|
1125
|
+
function appendChunksToUpload(_x54, _x55, _x56, _x57, _x58) {
|
|
914
1126
|
return _appendChunksToUpload.apply(this, arguments);
|
|
915
1127
|
}
|
|
916
1128
|
return appendChunksToUpload;
|
|
@@ -968,10 +1180,10 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
968
1180
|
}, {
|
|
969
1181
|
key: "registerCopyIntents",
|
|
970
1182
|
value: function () {
|
|
971
|
-
var _registerCopyIntents = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1183
|
+
var _registerCopyIntents = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(files, traceContext, resolvedAuth) {
|
|
972
1184
|
var metadata, options;
|
|
973
|
-
return _regeneratorRuntime.wrap(function (
|
|
974
|
-
while (1) switch (
|
|
1185
|
+
return _regeneratorRuntime.wrap(function (_context18) {
|
|
1186
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
975
1187
|
case 0:
|
|
976
1188
|
metadata = {
|
|
977
1189
|
method: 'POST',
|
|
@@ -985,15 +1197,15 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
985
1197
|
traceContext: traceContext,
|
|
986
1198
|
resolvedAuth: resolvedAuth
|
|
987
1199
|
});
|
|
988
|
-
|
|
1200
|
+
_context18.next = 1;
|
|
989
1201
|
return this.request('/file/copy/intents', options);
|
|
990
1202
|
case 1:
|
|
991
1203
|
case "end":
|
|
992
|
-
return
|
|
1204
|
+
return _context18.stop();
|
|
993
1205
|
}
|
|
994
|
-
},
|
|
1206
|
+
}, _callee18, this);
|
|
995
1207
|
}));
|
|
996
|
-
function registerCopyIntents(
|
|
1208
|
+
function registerCopyIntents(_x59, _x60, _x61) {
|
|
997
1209
|
return _registerCopyIntents.apply(this, arguments);
|
|
998
1210
|
}
|
|
999
1211
|
return registerCopyIntents;
|
|
@@ -1001,7 +1213,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
1001
1213
|
}, {
|
|
1002
1214
|
key: "request",
|
|
1003
1215
|
value: function () {
|
|
1004
|
-
var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1216
|
+
var _request2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(path) {
|
|
1005
1217
|
var options,
|
|
1006
1218
|
controller,
|
|
1007
1219
|
useMediaCdn,
|
|
@@ -1021,33 +1233,33 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
1021
1233
|
extendedParams,
|
|
1022
1234
|
url,
|
|
1023
1235
|
response,
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
return _regeneratorRuntime.wrap(function (
|
|
1027
|
-
while (1) switch (
|
|
1236
|
+
_args19 = arguments,
|
|
1237
|
+
_t27;
|
|
1238
|
+
return _regeneratorRuntime.wrap(function (_context19) {
|
|
1239
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1028
1240
|
case 0:
|
|
1029
|
-
options =
|
|
1241
|
+
options = _args19.length > 1 && _args19[1] !== undefined ? _args19[1] : {
|
|
1030
1242
|
method: 'GET',
|
|
1031
1243
|
endpoint: undefined,
|
|
1032
1244
|
authContext: {}
|
|
1033
1245
|
};
|
|
1034
|
-
controller =
|
|
1035
|
-
useMediaCdn =
|
|
1246
|
+
controller = _args19.length > 2 ? _args19[2] : undefined;
|
|
1247
|
+
useMediaCdn = _args19.length > 3 ? _args19[3] : undefined;
|
|
1036
1248
|
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;
|
|
1037
1249
|
if (!(resolvedAuth !== null && resolvedAuth !== void 0)) {
|
|
1038
|
-
|
|
1250
|
+
_context19.next = 1;
|
|
1039
1251
|
break;
|
|
1040
1252
|
}
|
|
1041
|
-
|
|
1042
|
-
|
|
1253
|
+
_t27 = resolvedAuth;
|
|
1254
|
+
_context19.next = 3;
|
|
1043
1255
|
break;
|
|
1044
1256
|
case 1:
|
|
1045
|
-
|
|
1257
|
+
_context19.next = 2;
|
|
1046
1258
|
return this.resolveAuth(authContext);
|
|
1047
1259
|
case 2:
|
|
1048
|
-
|
|
1260
|
+
_t27 = _context19.sent;
|
|
1049
1261
|
case 3:
|
|
1050
|
-
auth =
|
|
1262
|
+
auth = _t27;
|
|
1051
1263
|
clientId = isClientBasedAuth(auth) ? auth.clientId : undefined;
|
|
1052
1264
|
extendedTraceContext = extendTraceContext(traceContext);
|
|
1053
1265
|
extendedParams = addMediaClientParam ? _objectSpread(_objectSpread({}, params), {}, {
|
|
@@ -1060,7 +1272,7 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
1060
1272
|
if (isPathBasedEnabled()) {
|
|
1061
1273
|
url = mapToPathBasedUrl(url);
|
|
1062
1274
|
}
|
|
1063
|
-
|
|
1275
|
+
_context19.next = 4;
|
|
1064
1276
|
return _request(url, {
|
|
1065
1277
|
method: method,
|
|
1066
1278
|
endpoint: endpoint,
|
|
@@ -1072,17 +1284,17 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
1072
1284
|
traceContext: extendedTraceContext
|
|
1073
1285
|
}, controller);
|
|
1074
1286
|
case 4:
|
|
1075
|
-
response =
|
|
1287
|
+
response = _context19.sent;
|
|
1076
1288
|
setKeyValueInSessionStorage(MEDIA_API_REGION, response.headers.get('x-media-region'));
|
|
1077
1289
|
setKeyValueInSessionStorage(MEDIA_API_ENVIRONMENT, response.headers.get('x-media-env'));
|
|
1078
|
-
return
|
|
1290
|
+
return _context19.abrupt("return", response);
|
|
1079
1291
|
case 5:
|
|
1080
1292
|
case "end":
|
|
1081
|
-
return
|
|
1293
|
+
return _context19.stop();
|
|
1082
1294
|
}
|
|
1083
|
-
},
|
|
1295
|
+
}, _callee19, this);
|
|
1084
1296
|
}));
|
|
1085
|
-
function request(
|
|
1297
|
+
function request(_x62) {
|
|
1086
1298
|
return _request2.apply(this, arguments);
|
|
1087
1299
|
}
|
|
1088
1300
|
return request;
|
|
@@ -1090,16 +1302,16 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
1090
1302
|
}, {
|
|
1091
1303
|
key: "testUrl",
|
|
1092
1304
|
value: function () {
|
|
1093
|
-
var _testUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1305
|
+
var _testUrl = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(url) {
|
|
1094
1306
|
var options,
|
|
1095
1307
|
traceContext,
|
|
1096
|
-
|
|
1097
|
-
return _regeneratorRuntime.wrap(function (
|
|
1098
|
-
while (1) switch (
|
|
1308
|
+
_args20 = arguments;
|
|
1309
|
+
return _regeneratorRuntime.wrap(function (_context20) {
|
|
1310
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1099
1311
|
case 0:
|
|
1100
|
-
options =
|
|
1312
|
+
options = _args20.length > 1 && _args20[1] !== undefined ? _args20[1] : {};
|
|
1101
1313
|
traceContext = options.traceContext;
|
|
1102
|
-
|
|
1314
|
+
_context20.next = 1;
|
|
1103
1315
|
return _request(url, {
|
|
1104
1316
|
method: 'HEAD',
|
|
1105
1317
|
traceContext: extendTraceContext(traceContext),
|
|
@@ -1111,15 +1323,54 @@ export var MediaStore = /*#__PURE__*/function () {
|
|
|
1111
1323
|
});
|
|
1112
1324
|
case 1:
|
|
1113
1325
|
case "end":
|
|
1114
|
-
return
|
|
1326
|
+
return _context20.stop();
|
|
1115
1327
|
}
|
|
1116
|
-
},
|
|
1328
|
+
}, _callee20);
|
|
1117
1329
|
}));
|
|
1118
|
-
function testUrl(
|
|
1330
|
+
function testUrl(_x63) {
|
|
1119
1331
|
return _testUrl.apply(this, arguments);
|
|
1120
1332
|
}
|
|
1121
1333
|
return testUrl;
|
|
1122
1334
|
}()
|
|
1335
|
+
}, {
|
|
1336
|
+
key: "resolveReadAuth",
|
|
1337
|
+
value: function () {
|
|
1338
|
+
var _resolveReadAuth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(id, collectionName) {
|
|
1339
|
+
var auth;
|
|
1340
|
+
return _regeneratorRuntime.wrap(function (_context21) {
|
|
1341
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1342
|
+
case 0:
|
|
1343
|
+
_context21.next = 1;
|
|
1344
|
+
return this.resolveAuth({
|
|
1345
|
+
collectionName: collectionName
|
|
1346
|
+
});
|
|
1347
|
+
case 1:
|
|
1348
|
+
auth = _context21.sent;
|
|
1349
|
+
if (!(!fg('platform_media_bounded_read_tokens') || auth.token.length <= MEDIA_TOKEN_LENGTH_LIMIT)) {
|
|
1350
|
+
_context21.next = 2;
|
|
1351
|
+
break;
|
|
1352
|
+
}
|
|
1353
|
+
return _context21.abrupt("return", auth);
|
|
1354
|
+
case 2:
|
|
1355
|
+
return _context21.abrupt("return", this.resolveAuth({
|
|
1356
|
+
collectionName: collectionName,
|
|
1357
|
+
access: [{
|
|
1358
|
+
type: 'file',
|
|
1359
|
+
id: id,
|
|
1360
|
+
actions: ['read']
|
|
1361
|
+
}]
|
|
1362
|
+
}));
|
|
1363
|
+
case 3:
|
|
1364
|
+
case "end":
|
|
1365
|
+
return _context21.stop();
|
|
1366
|
+
}
|
|
1367
|
+
}, _callee21, this);
|
|
1368
|
+
}));
|
|
1369
|
+
function resolveReadAuth(_x64, _x65) {
|
|
1370
|
+
return _resolveReadAuth.apply(this, arguments);
|
|
1371
|
+
}
|
|
1372
|
+
return resolveReadAuth;
|
|
1373
|
+
}()
|
|
1123
1374
|
}, {
|
|
1124
1375
|
key: "chunkHashAlgorithm",
|
|
1125
1376
|
get: function get() {
|