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