@atlaskit/media-picker 61.0.1 → 62.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/dist/cjs/service/uploadServiceImpl.js +1 -54
- package/dist/cjs/util/ufoExperiences.js +11 -5
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/service/uploadServiceImpl.js +1 -56
- package/dist/es2019/util/analytics.js +2 -1
- package/dist/es2019/util/ufoExperiences.js +10 -5
- package/dist/es2019/version.json +1 -1
- package/dist/esm/service/uploadServiceImpl.js +2 -55
- package/dist/esm/util/analytics.js +2 -1
- package/dist/esm/util/ufoExperiences.js +10 -5
- package/dist/esm/version.json +1 -1
- package/dist/types/popup/domain/index.d.ts +1 -4
- package/dist/types/service/uploadServiceImpl.d.ts +0 -2
- package/dist/types/util/ufoExperiences.d.ts +1 -1
- package/package.json +8 -11
- package/dist/cjs/components/popup-auth.js +0 -97
- package/dist/cjs/popup/domain/auth.js +0 -37
- package/dist/cjs/popup/domain/source-file.js +0 -20
- package/dist/es2019/components/popup-auth.js +0 -44
- package/dist/es2019/popup/domain/auth.js +0 -27
- package/dist/es2019/popup/domain/source-file.js +0 -12
- package/dist/esm/components/popup-auth.js +0 -83
- package/dist/esm/popup/domain/auth.js +0 -27
- package/dist/esm/popup/domain/source-file.js +0 -12
- package/dist/types/components/popup-auth.d.ts +0 -3
- package/dist/types/popup/domain/auth.d.ts +0 -21
- package/dist/types/popup/domain/source-file.d.ts +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @atlaskit/media-picker
|
|
2
2
|
|
|
3
|
+
## 62.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- [`ad13b4d0bc6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ad13b4d0bc6) - [MEX-1525] Remove userAuth from Media-Core & Media-client
|
|
8
|
+
|
|
9
|
+
### Minor Changes
|
|
10
|
+
|
|
11
|
+
- [`fe7a1aaddd6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/fe7a1aaddd6) - Attach media environment to Media Picker UFO events
|
|
12
|
+
- [`7dad7e0c299`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7dad7e0c299) - [MEX-1413] Removed user auth from media-picker
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- [`a5d25a077bc`](https://bitbucket.org/atlassian/atlassian-frontend/commits/a5d25a077bc) - removed duplicated module from Confluence's node_modules introduced with our components
|
|
17
|
+
- [`e368c622418`](https://bitbucket.org/atlassian/atlassian-frontend/commits/e368c622418) - Updated component names in UFO experiences
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
|
|
3
20
|
## 61.0.1
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
|
@@ -25,18 +25,12 @@ var _constants = require("@atlaskit/media-client/constants");
|
|
|
25
25
|
|
|
26
26
|
var _eventemitter = require("eventemitter2");
|
|
27
27
|
|
|
28
|
-
var _sourceFile = require("../popup/domain/source-file");
|
|
29
|
-
|
|
30
28
|
var _getPreviewFromImage = require("../util/getPreviewFromImage");
|
|
31
29
|
|
|
32
30
|
var _types = require("../service/types");
|
|
33
31
|
|
|
34
32
|
var _getPreviewFromBlob = require("../util/getPreviewFromBlob");
|
|
35
33
|
|
|
36
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
37
|
-
|
|
38
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
39
|
-
|
|
40
34
|
var UploadServiceImpl = /*#__PURE__*/function () {
|
|
41
35
|
function UploadServiceImpl(tenantMediaClient, tenantUploadParams, shouldCopyFileToRecents) {
|
|
42
36
|
var _this = this;
|
|
@@ -54,10 +48,6 @@ var UploadServiceImpl = /*#__PURE__*/function () {
|
|
|
54
48
|
case 0:
|
|
55
49
|
mediaFile = cancellableFileUpload.mediaFile;
|
|
56
50
|
|
|
57
|
-
_this.copyFileToUsersCollection(fileId) // eslint-disable-next-line no-console
|
|
58
|
-
.catch(console.log); // We intentionally swallow these errors
|
|
59
|
-
|
|
60
|
-
|
|
61
51
|
_this.emit('file-converting', {
|
|
62
52
|
file: mediaFile
|
|
63
53
|
});
|
|
@@ -66,7 +56,7 @@ var UploadServiceImpl = /*#__PURE__*/function () {
|
|
|
66
56
|
_this.releaseCancellableFile(mediaFile);
|
|
67
57
|
};
|
|
68
58
|
|
|
69
|
-
case
|
|
59
|
+
case 3:
|
|
70
60
|
case "end":
|
|
71
61
|
return _context.stop();
|
|
72
62
|
}
|
|
@@ -105,18 +95,6 @@ var UploadServiceImpl = /*#__PURE__*/function () {
|
|
|
105
95
|
this.shouldCopyFileToRecents = shouldCopyFileToRecents;
|
|
106
96
|
this.emitter = new _eventemitter.EventEmitter2();
|
|
107
97
|
this.cancellableFilesUploads = {};
|
|
108
|
-
var userAuthProvider = tenantMediaClient.config.userAuthProvider;
|
|
109
|
-
|
|
110
|
-
if (userAuthProvider) {
|
|
111
|
-
this.userMediaStore = new _mediaClient.MediaStore({
|
|
112
|
-
authProvider: userAuthProvider
|
|
113
|
-
}); // We need to use the userAuth to upload this file (recents)
|
|
114
|
-
|
|
115
|
-
this.userMediaClient = new _mediaClient.MediaClient({
|
|
116
|
-
userAuthProvider: userAuthProvider,
|
|
117
|
-
authProvider: userAuthProvider
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
98
|
}
|
|
121
99
|
|
|
122
100
|
(0, _createClass2.default)(UploadServiceImpl, [{
|
|
@@ -362,37 +340,6 @@ var UploadServiceImpl = /*#__PURE__*/function () {
|
|
|
362
340
|
value: function releaseCancellableFile(mediaFile) {
|
|
363
341
|
delete this.cancellableFilesUploads[mediaFile.id];
|
|
364
342
|
}
|
|
365
|
-
}, {
|
|
366
|
-
key: "copyFileToUsersCollection",
|
|
367
|
-
value: // This method copies the file from the "tenant collection" to the "user collection" (recents).
|
|
368
|
-
// that means we need "tenant auth" as input and "user auth" as output
|
|
369
|
-
function copyFileToUsersCollection(sourceFileId) {
|
|
370
|
-
var shouldCopyFileToRecents = this.shouldCopyFileToRecents,
|
|
371
|
-
userMediaStore = this.userMediaStore,
|
|
372
|
-
tenantUploadParams = this.tenantUploadParams;
|
|
373
|
-
|
|
374
|
-
if (!shouldCopyFileToRecents || !userMediaStore) {
|
|
375
|
-
return Promise.resolve();
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
var sourceCollection = tenantUploadParams.collection;
|
|
379
|
-
var tenantAuthProvider = this.tenantMediaClient.config.authProvider;
|
|
380
|
-
return tenantAuthProvider({
|
|
381
|
-
collectionName: sourceCollection
|
|
382
|
-
}).then(function (auth) {
|
|
383
|
-
var body = {
|
|
384
|
-
sourceFile: {
|
|
385
|
-
id: sourceFileId,
|
|
386
|
-
collection: sourceCollection,
|
|
387
|
-
owner: _objectSpread({}, (0, _sourceFile.mapAuthToSourceFileOwner)(auth))
|
|
388
|
-
}
|
|
389
|
-
};
|
|
390
|
-
var params = {
|
|
391
|
-
collection: _constants.RECENTS_COLLECTION
|
|
392
|
-
};
|
|
393
|
-
return userMediaStore.copyFileWithToken(body, params);
|
|
394
|
-
});
|
|
395
|
-
}
|
|
396
343
|
}]);
|
|
397
344
|
return UploadServiceImpl;
|
|
398
345
|
}();
|
|
@@ -11,6 +11,8 @@ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/de
|
|
|
11
11
|
|
|
12
12
|
var _ufo = require("@atlaskit/ufo");
|
|
13
13
|
|
|
14
|
+
var _mediaClient = require("@atlaskit/media-client");
|
|
15
|
+
|
|
14
16
|
var _version = require("../version.json");
|
|
15
17
|
|
|
16
18
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
@@ -23,7 +25,7 @@ var initExperience = function initExperience(id, componentName) {
|
|
|
23
25
|
if (!ufoExperience) {
|
|
24
26
|
var inlineExperience = {
|
|
25
27
|
platform: {
|
|
26
|
-
component: componentName
|
|
28
|
+
component: "media-picker-".concat(componentName)
|
|
27
29
|
},
|
|
28
30
|
type: _ufo.ExperienceTypes.Experience,
|
|
29
31
|
performanceType: _ufo.ExperiencePerformanceTypes.InlineResult
|
|
@@ -40,8 +42,8 @@ var getExperience = function getExperience(id) {
|
|
|
40
42
|
}
|
|
41
43
|
};
|
|
42
44
|
|
|
43
|
-
var startMediaUploadUfoExperience = function startMediaUploadUfoExperience(id,
|
|
44
|
-
initExperience(id,
|
|
45
|
+
var startMediaUploadUfoExperience = function startMediaUploadUfoExperience(id, componentName) {
|
|
46
|
+
initExperience(id, componentName).start();
|
|
45
47
|
};
|
|
46
48
|
|
|
47
49
|
exports.startMediaUploadUfoExperience = startMediaUploadUfoExperience;
|
|
@@ -53,7 +55,9 @@ var succeedMediaUploadUfoExperience = function succeedMediaUploadUfoExperience(i
|
|
|
53
55
|
metadata: {
|
|
54
56
|
fileAttributes: properties,
|
|
55
57
|
packageName: _version.name,
|
|
56
|
-
packageVersion: _version.version
|
|
58
|
+
packageVersion: _version.version,
|
|
59
|
+
mediaEnvironment: (0, _mediaClient.getMediaEnvironment)(),
|
|
60
|
+
mediaRegion: (0, _mediaClient.getMediaRegion)()
|
|
57
61
|
}
|
|
58
62
|
});
|
|
59
63
|
};
|
|
@@ -65,7 +69,9 @@ var failMediaUploadUfoExperience = function failMediaUploadUfoExperience(id, pro
|
|
|
65
69
|
|
|
66
70
|
var refinedMetadata = _objectSpread(_objectSpread({}, properties), {}, {
|
|
67
71
|
packageName: _version.name,
|
|
68
|
-
packageVersion: _version.version
|
|
72
|
+
packageVersion: _version.version,
|
|
73
|
+
mediaEnvironment: (0, _mediaClient.getMediaEnvironment)(),
|
|
74
|
+
mediaRegion: (0, _mediaClient.getMediaRegion)()
|
|
69
75
|
});
|
|
70
76
|
|
|
71
77
|
(_getExperience2 = getExperience(id)) === null || _getExperience2 === void 0 ? void 0 : _getExperience2.failure({
|
package/dist/cjs/version.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
2
|
import uuidV4 from 'uuid/v4';
|
|
3
|
-
import {
|
|
3
|
+
import { UploadController, getMediaTypeFromMimeType, isMimeTypeSupportedByBrowser, globalMediaEventEmitter, RequestError } from '@atlaskit/media-client';
|
|
4
4
|
import { RECENTS_COLLECTION } from '@atlaskit/media-client/constants';
|
|
5
5
|
import { EventEmitter2 } from 'eventemitter2';
|
|
6
|
-
import { mapAuthToSourceFileOwner } from '../popup/domain/source-file';
|
|
7
6
|
import { getPreviewFromImage } from '../util/getPreviewFromImage';
|
|
8
7
|
import { LocalFileSource } from '../service/types';
|
|
9
8
|
import { getPreviewFromBlob } from '../util/getPreviewFromBlob';
|
|
@@ -17,9 +16,6 @@ export class UploadServiceImpl {
|
|
|
17
16
|
const {
|
|
18
17
|
mediaFile
|
|
19
18
|
} = cancellableFileUpload;
|
|
20
|
-
this.copyFileToUsersCollection(fileId) // eslint-disable-next-line no-console
|
|
21
|
-
.catch(console.log); // We intentionally swallow these errors
|
|
22
|
-
|
|
23
19
|
this.emit('file-converting', {
|
|
24
20
|
file: mediaFile
|
|
25
21
|
});
|
|
@@ -56,20 +52,6 @@ export class UploadServiceImpl {
|
|
|
56
52
|
this.shouldCopyFileToRecents = shouldCopyFileToRecents;
|
|
57
53
|
this.emitter = new EventEmitter2();
|
|
58
54
|
this.cancellableFilesUploads = {};
|
|
59
|
-
const {
|
|
60
|
-
userAuthProvider
|
|
61
|
-
} = tenantMediaClient.config;
|
|
62
|
-
|
|
63
|
-
if (userAuthProvider) {
|
|
64
|
-
this.userMediaStore = new MediaStore({
|
|
65
|
-
authProvider: userAuthProvider
|
|
66
|
-
}); // We need to use the userAuth to upload this file (recents)
|
|
67
|
-
|
|
68
|
-
this.userMediaClient = new MediaClient({
|
|
69
|
-
userAuthProvider,
|
|
70
|
-
authProvider: userAuthProvider
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
55
|
}
|
|
74
56
|
|
|
75
57
|
setUploadParams(uploadParams) {
|
|
@@ -297,41 +279,4 @@ export class UploadServiceImpl {
|
|
|
297
279
|
delete this.cancellableFilesUploads[mediaFile.id];
|
|
298
280
|
}
|
|
299
281
|
|
|
300
|
-
// This method copies the file from the "tenant collection" to the "user collection" (recents).
|
|
301
|
-
// that means we need "tenant auth" as input and "user auth" as output
|
|
302
|
-
copyFileToUsersCollection(sourceFileId) {
|
|
303
|
-
const {
|
|
304
|
-
shouldCopyFileToRecents,
|
|
305
|
-
userMediaStore,
|
|
306
|
-
tenantUploadParams
|
|
307
|
-
} = this;
|
|
308
|
-
|
|
309
|
-
if (!shouldCopyFileToRecents || !userMediaStore) {
|
|
310
|
-
return Promise.resolve();
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
const {
|
|
314
|
-
collection: sourceCollection
|
|
315
|
-
} = tenantUploadParams;
|
|
316
|
-
const {
|
|
317
|
-
authProvider: tenantAuthProvider
|
|
318
|
-
} = this.tenantMediaClient.config;
|
|
319
|
-
return tenantAuthProvider({
|
|
320
|
-
collectionName: sourceCollection
|
|
321
|
-
}).then(auth => {
|
|
322
|
-
const body = {
|
|
323
|
-
sourceFile: {
|
|
324
|
-
id: sourceFileId,
|
|
325
|
-
collection: sourceCollection,
|
|
326
|
-
owner: { ...mapAuthToSourceFileOwner(auth)
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
};
|
|
330
|
-
const params = {
|
|
331
|
-
collection: RECENTS_COLLECTION
|
|
332
|
-
};
|
|
333
|
-
return userMediaStore.copyFileWithToken(body, params);
|
|
334
|
-
});
|
|
335
|
-
}
|
|
336
|
-
|
|
337
282
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isRequestError } from '@atlaskit/media-client';
|
|
2
|
-
import { name as packageName, version as packageVersion } from '../version.json';
|
|
2
|
+
import { name as packageName, version as packageVersion } from '../version.json'; // Component name will be prefixed with "media-picker-" in logs. Check ufoExperiences in utils files
|
|
3
|
+
|
|
3
4
|
export function getPackageAttributes(componentName) {
|
|
4
5
|
return {
|
|
5
6
|
packageName,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ConcurrentExperience, ExperiencePerformanceTypes, ExperienceTypes } from '@atlaskit/ufo';
|
|
2
|
+
import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
|
|
2
3
|
import { name as packageName, version as packageVersion } from '../version.json';
|
|
3
4
|
let ufoExperience;
|
|
4
5
|
|
|
@@ -6,7 +7,7 @@ const initExperience = (id, componentName) => {
|
|
|
6
7
|
if (!ufoExperience) {
|
|
7
8
|
const inlineExperience = {
|
|
8
9
|
platform: {
|
|
9
|
-
component: componentName
|
|
10
|
+
component: `media-picker-${componentName}`
|
|
10
11
|
},
|
|
11
12
|
type: ExperienceTypes.Experience,
|
|
12
13
|
performanceType: ExperiencePerformanceTypes.InlineResult
|
|
@@ -23,8 +24,8 @@ const getExperience = id => {
|
|
|
23
24
|
}
|
|
24
25
|
};
|
|
25
26
|
|
|
26
|
-
export const startMediaUploadUfoExperience = (id,
|
|
27
|
-
initExperience(id,
|
|
27
|
+
export const startMediaUploadUfoExperience = (id, componentName) => {
|
|
28
|
+
initExperience(id, componentName).start();
|
|
28
29
|
};
|
|
29
30
|
export const succeedMediaUploadUfoExperience = (id, properties) => {
|
|
30
31
|
var _getExperience;
|
|
@@ -33,7 +34,9 @@ export const succeedMediaUploadUfoExperience = (id, properties) => {
|
|
|
33
34
|
metadata: {
|
|
34
35
|
fileAttributes: properties,
|
|
35
36
|
packageName,
|
|
36
|
-
packageVersion
|
|
37
|
+
packageVersion,
|
|
38
|
+
mediaEnvironment: getMediaEnvironment(),
|
|
39
|
+
mediaRegion: getMediaRegion()
|
|
37
40
|
}
|
|
38
41
|
});
|
|
39
42
|
};
|
|
@@ -42,7 +45,9 @@ export const failMediaUploadUfoExperience = (id, properties) => {
|
|
|
42
45
|
|
|
43
46
|
const refinedMetadata = { ...properties,
|
|
44
47
|
packageName,
|
|
45
|
-
packageVersion
|
|
48
|
+
packageVersion,
|
|
49
|
+
mediaEnvironment: getMediaEnvironment(),
|
|
50
|
+
mediaRegion: getMediaRegion()
|
|
46
51
|
};
|
|
47
52
|
(_getExperience2 = getExperience(id)) === null || _getExperience2 === void 0 ? void 0 : _getExperience2.failure({
|
|
48
53
|
metadata: refinedMetadata
|
package/dist/es2019/version.json
CHANGED
|
@@ -3,16 +3,10 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
3
3
|
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
|
|
4
4
|
import _createClass from "@babel/runtime/helpers/createClass";
|
|
5
5
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
|
-
|
|
7
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
8
|
-
|
|
9
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
-
|
|
11
6
|
import uuidV4 from 'uuid/v4';
|
|
12
|
-
import {
|
|
7
|
+
import { UploadController, getMediaTypeFromMimeType, isMimeTypeSupportedByBrowser, globalMediaEventEmitter, RequestError } from '@atlaskit/media-client';
|
|
13
8
|
import { RECENTS_COLLECTION } from '@atlaskit/media-client/constants';
|
|
14
9
|
import { EventEmitter2 } from 'eventemitter2';
|
|
15
|
-
import { mapAuthToSourceFileOwner } from '../popup/domain/source-file';
|
|
16
10
|
import { getPreviewFromImage } from '../util/getPreviewFromImage';
|
|
17
11
|
import { LocalFileSource } from '../service/types';
|
|
18
12
|
import { getPreviewFromBlob } from '../util/getPreviewFromBlob';
|
|
@@ -35,10 +29,6 @@ export var UploadServiceImpl = /*#__PURE__*/function () {
|
|
|
35
29
|
case 0:
|
|
36
30
|
mediaFile = cancellableFileUpload.mediaFile;
|
|
37
31
|
|
|
38
|
-
_this.copyFileToUsersCollection(fileId) // eslint-disable-next-line no-console
|
|
39
|
-
.catch(console.log); // We intentionally swallow these errors
|
|
40
|
-
|
|
41
|
-
|
|
42
32
|
_this.emit('file-converting', {
|
|
43
33
|
file: mediaFile
|
|
44
34
|
});
|
|
@@ -47,7 +37,7 @@ export var UploadServiceImpl = /*#__PURE__*/function () {
|
|
|
47
37
|
_this.releaseCancellableFile(mediaFile);
|
|
48
38
|
};
|
|
49
39
|
|
|
50
|
-
case
|
|
40
|
+
case 3:
|
|
51
41
|
case "end":
|
|
52
42
|
return _context.stop();
|
|
53
43
|
}
|
|
@@ -88,18 +78,6 @@ export var UploadServiceImpl = /*#__PURE__*/function () {
|
|
|
88
78
|
this.shouldCopyFileToRecents = shouldCopyFileToRecents;
|
|
89
79
|
this.emitter = new EventEmitter2();
|
|
90
80
|
this.cancellableFilesUploads = {};
|
|
91
|
-
var userAuthProvider = tenantMediaClient.config.userAuthProvider;
|
|
92
|
-
|
|
93
|
-
if (userAuthProvider) {
|
|
94
|
-
this.userMediaStore = new MediaStore({
|
|
95
|
-
authProvider: userAuthProvider
|
|
96
|
-
}); // We need to use the userAuth to upload this file (recents)
|
|
97
|
-
|
|
98
|
-
this.userMediaClient = new MediaClient({
|
|
99
|
-
userAuthProvider: userAuthProvider,
|
|
100
|
-
authProvider: userAuthProvider
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
81
|
}
|
|
104
82
|
|
|
105
83
|
_createClass(UploadServiceImpl, [{
|
|
@@ -344,37 +322,6 @@ export var UploadServiceImpl = /*#__PURE__*/function () {
|
|
|
344
322
|
value: function releaseCancellableFile(mediaFile) {
|
|
345
323
|
delete this.cancellableFilesUploads[mediaFile.id];
|
|
346
324
|
}
|
|
347
|
-
}, {
|
|
348
|
-
key: "copyFileToUsersCollection",
|
|
349
|
-
value: // This method copies the file from the "tenant collection" to the "user collection" (recents).
|
|
350
|
-
// that means we need "tenant auth" as input and "user auth" as output
|
|
351
|
-
function copyFileToUsersCollection(sourceFileId) {
|
|
352
|
-
var shouldCopyFileToRecents = this.shouldCopyFileToRecents,
|
|
353
|
-
userMediaStore = this.userMediaStore,
|
|
354
|
-
tenantUploadParams = this.tenantUploadParams;
|
|
355
|
-
|
|
356
|
-
if (!shouldCopyFileToRecents || !userMediaStore) {
|
|
357
|
-
return Promise.resolve();
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
var sourceCollection = tenantUploadParams.collection;
|
|
361
|
-
var tenantAuthProvider = this.tenantMediaClient.config.authProvider;
|
|
362
|
-
return tenantAuthProvider({
|
|
363
|
-
collectionName: sourceCollection
|
|
364
|
-
}).then(function (auth) {
|
|
365
|
-
var body = {
|
|
366
|
-
sourceFile: {
|
|
367
|
-
id: sourceFileId,
|
|
368
|
-
collection: sourceCollection,
|
|
369
|
-
owner: _objectSpread({}, mapAuthToSourceFileOwner(auth))
|
|
370
|
-
}
|
|
371
|
-
};
|
|
372
|
-
var params = {
|
|
373
|
-
collection: RECENTS_COLLECTION
|
|
374
|
-
};
|
|
375
|
-
return userMediaStore.copyFileWithToken(body, params);
|
|
376
|
-
});
|
|
377
|
-
}
|
|
378
325
|
}]);
|
|
379
326
|
|
|
380
327
|
return UploadServiceImpl;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { isRequestError } from '@atlaskit/media-client';
|
|
2
|
-
import { name as packageName, version as packageVersion } from '../version.json';
|
|
2
|
+
import { name as packageName, version as packageVersion } from '../version.json'; // Component name will be prefixed with "media-picker-" in logs. Check ufoExperiences in utils files
|
|
3
|
+
|
|
3
4
|
export function getPackageAttributes(componentName) {
|
|
4
5
|
return {
|
|
5
6
|
packageName: packageName,
|
|
@@ -5,6 +5,7 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
|
|
|
5
5
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
6
6
|
|
|
7
7
|
import { ConcurrentExperience, ExperiencePerformanceTypes, ExperienceTypes } from '@atlaskit/ufo';
|
|
8
|
+
import { getMediaEnvironment, getMediaRegion } from '@atlaskit/media-client';
|
|
8
9
|
import { name as packageName, version as packageVersion } from '../version.json';
|
|
9
10
|
var ufoExperience;
|
|
10
11
|
|
|
@@ -12,7 +13,7 @@ var initExperience = function initExperience(id, componentName) {
|
|
|
12
13
|
if (!ufoExperience) {
|
|
13
14
|
var inlineExperience = {
|
|
14
15
|
platform: {
|
|
15
|
-
component: componentName
|
|
16
|
+
component: "media-picker-".concat(componentName)
|
|
16
17
|
},
|
|
17
18
|
type: ExperienceTypes.Experience,
|
|
18
19
|
performanceType: ExperiencePerformanceTypes.InlineResult
|
|
@@ -29,8 +30,8 @@ var getExperience = function getExperience(id) {
|
|
|
29
30
|
}
|
|
30
31
|
};
|
|
31
32
|
|
|
32
|
-
export var startMediaUploadUfoExperience = function startMediaUploadUfoExperience(id,
|
|
33
|
-
initExperience(id,
|
|
33
|
+
export var startMediaUploadUfoExperience = function startMediaUploadUfoExperience(id, componentName) {
|
|
34
|
+
initExperience(id, componentName).start();
|
|
34
35
|
};
|
|
35
36
|
export var succeedMediaUploadUfoExperience = function succeedMediaUploadUfoExperience(id, properties) {
|
|
36
37
|
var _getExperience;
|
|
@@ -39,7 +40,9 @@ export var succeedMediaUploadUfoExperience = function succeedMediaUploadUfoExper
|
|
|
39
40
|
metadata: {
|
|
40
41
|
fileAttributes: properties,
|
|
41
42
|
packageName: packageName,
|
|
42
|
-
packageVersion: packageVersion
|
|
43
|
+
packageVersion: packageVersion,
|
|
44
|
+
mediaEnvironment: getMediaEnvironment(),
|
|
45
|
+
mediaRegion: getMediaRegion()
|
|
43
46
|
}
|
|
44
47
|
});
|
|
45
48
|
};
|
|
@@ -48,7 +51,9 @@ export var failMediaUploadUfoExperience = function failMediaUploadUfoExperience(
|
|
|
48
51
|
|
|
49
52
|
var refinedMetadata = _objectSpread(_objectSpread({}, properties), {}, {
|
|
50
53
|
packageName: packageName,
|
|
51
|
-
packageVersion: packageVersion
|
|
54
|
+
packageVersion: packageVersion,
|
|
55
|
+
mediaEnvironment: getMediaEnvironment(),
|
|
56
|
+
mediaRegion: getMediaRegion()
|
|
52
57
|
});
|
|
53
58
|
|
|
54
59
|
(_getExperience2 = getExperience(id)) === null || _getExperience2 === void 0 ? void 0 : _getExperience2.failure({
|
package/dist/esm/version.json
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
export type { AuthHeaders } from './auth';
|
|
2
|
-
export type { SourceFile, SourceFileOwner, ClientBasedSourceFileOwner, AsapBasedSourceFileOwner, } from './source-file';
|
|
3
|
-
export declare type ServiceName = 'recent_files' | 'google' | 'dropbox' | 'upload' | 'giphy' | string;
|
|
4
1
|
export interface ServiceFile {
|
|
5
2
|
readonly mimeType: string;
|
|
6
3
|
readonly id: string;
|
|
@@ -12,6 +9,6 @@ export interface ServiceFile {
|
|
|
12
9
|
readonly createdAt?: number;
|
|
13
10
|
}
|
|
14
11
|
export interface SelectedItem extends ServiceFile {
|
|
15
|
-
readonly serviceName:
|
|
12
|
+
readonly serviceName: string;
|
|
16
13
|
readonly accountId?: string;
|
|
17
14
|
}
|
|
@@ -12,7 +12,6 @@ export declare class UploadServiceImpl implements UploadService {
|
|
|
12
12
|
private readonly tenantMediaClient;
|
|
13
13
|
private tenantUploadParams;
|
|
14
14
|
private readonly shouldCopyFileToRecents;
|
|
15
|
-
private readonly userMediaStore?;
|
|
16
15
|
private readonly userMediaClient?;
|
|
17
16
|
private readonly emitter;
|
|
18
17
|
private cancellableFilesUploads;
|
|
@@ -31,5 +30,4 @@ export declare class UploadServiceImpl implements UploadService {
|
|
|
31
30
|
private releaseCancellableFile;
|
|
32
31
|
private readonly onFileSuccess;
|
|
33
32
|
private readonly onFileError;
|
|
34
|
-
private copyFileToUsersCollection;
|
|
35
33
|
}
|
|
@@ -8,6 +8,6 @@ export declare type UFOFailedEventPayload = {
|
|
|
8
8
|
uploadDurationMsec: number;
|
|
9
9
|
request?: RequestMetadata;
|
|
10
10
|
} & WithFileAttributes;
|
|
11
|
-
export declare const startMediaUploadUfoExperience: (id: string,
|
|
11
|
+
export declare const startMediaUploadUfoExperience: (id: string, componentName: ComponentName) => void;
|
|
12
12
|
export declare const succeedMediaUploadUfoExperience: (id: string, properties: FileAttributes) => void;
|
|
13
13
|
export declare const failMediaUploadUfoExperience: (id: string, properties?: UFOFailedEventPayload | undefined) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/media-picker",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "62.0.0",
|
|
4
4
|
"description": "Library for handling file uploads",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -27,22 +27,21 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@atlaskit/analytics-next": "^8.2.0",
|
|
30
|
-
"@atlaskit/media-client": "^
|
|
31
|
-
"@atlaskit/media-common": "^2.
|
|
32
|
-
"@atlaskit/media-ui": "^
|
|
30
|
+
"@atlaskit/media-client": "^16.0.0",
|
|
31
|
+
"@atlaskit/media-common": "^2.13.0",
|
|
32
|
+
"@atlaskit/media-ui": "^22.0.0",
|
|
33
33
|
"@atlaskit/ufo": "^0.1.0",
|
|
34
34
|
"@babel/runtime": "^7.0.0",
|
|
35
35
|
"eventemitter2": "^4.1.0",
|
|
36
36
|
"exenv": "^1.2.2",
|
|
37
37
|
"flat-files": "^1.0.6",
|
|
38
|
-
"jwt-decode": "^2.2.0",
|
|
39
38
|
"perf-marks": "^1.5.0",
|
|
40
39
|
"rxjs": "^5.5.0",
|
|
41
40
|
"uuid": "^3.1.0",
|
|
42
41
|
"uuid-validate": "^0.0.3"
|
|
43
42
|
},
|
|
44
43
|
"peerDependencies": {
|
|
45
|
-
"@atlaskit/media-core": "^
|
|
44
|
+
"@atlaskit/media-core": "^33.0.0",
|
|
46
45
|
"react": "^16.8.0",
|
|
47
46
|
"react-dom": "^16.8.0",
|
|
48
47
|
"react-intl-next": "npm:react-intl@^5.18.1",
|
|
@@ -54,17 +53,15 @@
|
|
|
54
53
|
"@atlaskit/button": "^16.3.0",
|
|
55
54
|
"@atlaskit/docs": "*",
|
|
56
55
|
"@atlaskit/dropdown-menu": "^11.1.0",
|
|
57
|
-
"@atlaskit/media-card": "^73.
|
|
58
|
-
"@atlaskit/media-core": "^
|
|
59
|
-
"@atlaskit/media-test-helpers": "^
|
|
56
|
+
"@atlaskit/media-card": "^73.6.0",
|
|
57
|
+
"@atlaskit/media-core": "^33.0.0",
|
|
58
|
+
"@atlaskit/media-test-helpers": "^30.0.0",
|
|
60
59
|
"@atlaskit/spinner": "^15.0.0",
|
|
61
60
|
"@atlaskit/ssr": "*",
|
|
62
61
|
"@atlaskit/toggle": "^12.4.0",
|
|
63
62
|
"@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
|
|
64
63
|
"@atlassian/ufo": "^0.1.12",
|
|
65
64
|
"@types/enzyme": "^3.1.15",
|
|
66
|
-
"@types/eventemitter2": "^4.1.0",
|
|
67
|
-
"@types/jwt-decode": "^2.2.1",
|
|
68
65
|
"@types/react": "^16.8.0",
|
|
69
66
|
"enzyme": "^3.10.0",
|
|
70
67
|
"fetch-mock": "^8.0.0",
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.createPopupUserAuthProvider = void 0;
|
|
9
|
-
|
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
-
|
|
14
|
-
var _jwtDecode = _interopRequireDefault(require("jwt-decode"));
|
|
15
|
-
|
|
16
|
-
var _mediaCore = require("@atlaskit/media-core");
|
|
17
|
-
|
|
18
|
-
var getAuthFromEdgeData = function getAuthFromEdgeData(response) {
|
|
19
|
-
return {
|
|
20
|
-
clientId: response.data.clientId,
|
|
21
|
-
token: response.data.token,
|
|
22
|
-
baseUrl: response.data.baseUrl
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
var getClientIdFromAuth = function getClientIdFromAuth(auth) {
|
|
27
|
-
if ((0, _mediaCore.isClientBasedAuth)(auth)) {
|
|
28
|
-
return auth.clientId;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
var tokenData = (0, _jwtDecode.default)(auth.token);
|
|
32
|
-
return tokenData.clientId;
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
var createPopupUserAuthProvider = function createPopupUserAuthProvider(stargate, mediaClientConfig) {
|
|
36
|
-
var tokenData;
|
|
37
|
-
return /*#__PURE__*/function () {
|
|
38
|
-
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(context) {
|
|
39
|
-
var userAuthProvider, authProvider, clientId;
|
|
40
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
41
|
-
while (1) {
|
|
42
|
-
switch (_context.prev = _context.next) {
|
|
43
|
-
case 0:
|
|
44
|
-
userAuthProvider = mediaClientConfig.userAuthProvider;
|
|
45
|
-
|
|
46
|
-
if (!userAuthProvider) {
|
|
47
|
-
_context.next = 3;
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return _context.abrupt("return", userAuthProvider(context));
|
|
52
|
-
|
|
53
|
-
case 3:
|
|
54
|
-
_context.prev = 3;
|
|
55
|
-
|
|
56
|
-
if (!(!tokenData || stargate.isTokenExpired(tokenData))) {
|
|
57
|
-
_context.next = 14;
|
|
58
|
-
break;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
authProvider = mediaClientConfig.authProvider;
|
|
62
|
-
_context.t0 = getClientIdFromAuth;
|
|
63
|
-
_context.next = 9;
|
|
64
|
-
return authProvider(context);
|
|
65
|
-
|
|
66
|
-
case 9:
|
|
67
|
-
_context.t1 = _context.sent;
|
|
68
|
-
clientId = (0, _context.t0)(_context.t1);
|
|
69
|
-
_context.next = 13;
|
|
70
|
-
return stargate.fetchToken(clientId);
|
|
71
|
-
|
|
72
|
-
case 13:
|
|
73
|
-
tokenData = _context.sent;
|
|
74
|
-
|
|
75
|
-
case 14:
|
|
76
|
-
return _context.abrupt("return", getAuthFromEdgeData(tokenData));
|
|
77
|
-
|
|
78
|
-
case 17:
|
|
79
|
-
_context.prev = 17;
|
|
80
|
-
_context.t2 = _context["catch"](3);
|
|
81
|
-
throw new Error('Popup media picker Stargate call failed. If you were not intending to use Stargate you should provide userAuthProvider in the context');
|
|
82
|
-
|
|
83
|
-
case 20:
|
|
84
|
-
case "end":
|
|
85
|
-
return _context.stop();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}, _callee, null, [[3, 17]]);
|
|
89
|
-
}));
|
|
90
|
-
|
|
91
|
-
return function (_x) {
|
|
92
|
-
return _ref.apply(this, arguments);
|
|
93
|
-
};
|
|
94
|
-
}();
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
exports.createPopupUserAuthProvider = createPopupUserAuthProvider;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.mapAuthToAuthHeaders = mapAuthToAuthHeaders;
|
|
7
|
-
exports.mapAuthToQueryParameters = mapAuthToQueryParameters;
|
|
8
|
-
|
|
9
|
-
var _mediaCore = require("@atlaskit/media-core");
|
|
10
|
-
|
|
11
|
-
function mapAuthToAuthHeaders(auth) {
|
|
12
|
-
if ((0, _mediaCore.isClientBasedAuth)(auth)) {
|
|
13
|
-
return {
|
|
14
|
-
'X-Client-Id': auth.clientId,
|
|
15
|
-
Authorization: "Bearer ".concat(auth.token)
|
|
16
|
-
};
|
|
17
|
-
} else {
|
|
18
|
-
return {
|
|
19
|
-
'X-Issuer': auth.asapIssuer,
|
|
20
|
-
Authorization: "Bearer ".concat(auth.token)
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
function mapAuthToQueryParameters(auth) {
|
|
26
|
-
if ((0, _mediaCore.isClientBasedAuth)(auth)) {
|
|
27
|
-
return {
|
|
28
|
-
client: auth.clientId,
|
|
29
|
-
token: auth.token
|
|
30
|
-
};
|
|
31
|
-
} else {
|
|
32
|
-
return {
|
|
33
|
-
issuer: auth.asapIssuer,
|
|
34
|
-
token: auth.token
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.mapAuthToSourceFileOwner = mapAuthToSourceFileOwner;
|
|
7
|
-
|
|
8
|
-
var _mediaCore = require("@atlaskit/media-core");
|
|
9
|
-
|
|
10
|
-
function mapAuthToSourceFileOwner(auth) {
|
|
11
|
-
if ((0, _mediaCore.isClientBasedAuth)(auth)) {
|
|
12
|
-
return {
|
|
13
|
-
id: auth.clientId,
|
|
14
|
-
token: auth.token,
|
|
15
|
-
baseUrl: auth.baseUrl
|
|
16
|
-
};
|
|
17
|
-
} else {
|
|
18
|
-
return auth;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import jwtDecode from 'jwt-decode';
|
|
2
|
-
import { isClientBasedAuth } from '@atlaskit/media-core';
|
|
3
|
-
|
|
4
|
-
const getAuthFromEdgeData = response => ({
|
|
5
|
-
clientId: response.data.clientId,
|
|
6
|
-
token: response.data.token,
|
|
7
|
-
baseUrl: response.data.baseUrl
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
const getClientIdFromAuth = auth => {
|
|
11
|
-
if (isClientBasedAuth(auth)) {
|
|
12
|
-
return auth.clientId;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const tokenData = jwtDecode(auth.token);
|
|
16
|
-
return tokenData.clientId;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const createPopupUserAuthProvider = (stargate, mediaClientConfig) => {
|
|
20
|
-
let tokenData;
|
|
21
|
-
return async context => {
|
|
22
|
-
const {
|
|
23
|
-
userAuthProvider
|
|
24
|
-
} = mediaClientConfig;
|
|
25
|
-
|
|
26
|
-
if (userAuthProvider) {
|
|
27
|
-
return userAuthProvider(context);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
if (!tokenData || stargate.isTokenExpired(tokenData)) {
|
|
32
|
-
const {
|
|
33
|
-
authProvider
|
|
34
|
-
} = mediaClientConfig;
|
|
35
|
-
const clientId = getClientIdFromAuth(await authProvider(context));
|
|
36
|
-
tokenData = await stargate.fetchToken(clientId);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return getAuthFromEdgeData(tokenData);
|
|
40
|
-
} catch (e) {
|
|
41
|
-
throw new Error('Popup media picker Stargate call failed. If you were not intending to use Stargate you should provide userAuthProvider in the context');
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { isClientBasedAuth } from '@atlaskit/media-core';
|
|
2
|
-
export function mapAuthToAuthHeaders(auth) {
|
|
3
|
-
if (isClientBasedAuth(auth)) {
|
|
4
|
-
return {
|
|
5
|
-
'X-Client-Id': auth.clientId,
|
|
6
|
-
Authorization: `Bearer ${auth.token}`
|
|
7
|
-
};
|
|
8
|
-
} else {
|
|
9
|
-
return {
|
|
10
|
-
'X-Issuer': auth.asapIssuer,
|
|
11
|
-
Authorization: `Bearer ${auth.token}`
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export function mapAuthToQueryParameters(auth) {
|
|
16
|
-
if (isClientBasedAuth(auth)) {
|
|
17
|
-
return {
|
|
18
|
-
client: auth.clientId,
|
|
19
|
-
token: auth.token
|
|
20
|
-
};
|
|
21
|
-
} else {
|
|
22
|
-
return {
|
|
23
|
-
issuer: auth.asapIssuer,
|
|
24
|
-
token: auth.token
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { isClientBasedAuth } from '@atlaskit/media-core';
|
|
2
|
-
export function mapAuthToSourceFileOwner(auth) {
|
|
3
|
-
if (isClientBasedAuth(auth)) {
|
|
4
|
-
return {
|
|
5
|
-
id: auth.clientId,
|
|
6
|
-
token: auth.token,
|
|
7
|
-
baseUrl: auth.baseUrl
|
|
8
|
-
};
|
|
9
|
-
} else {
|
|
10
|
-
return auth;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
2
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
-
import jwtDecode from 'jwt-decode';
|
|
4
|
-
import { isClientBasedAuth } from '@atlaskit/media-core';
|
|
5
|
-
|
|
6
|
-
var getAuthFromEdgeData = function getAuthFromEdgeData(response) {
|
|
7
|
-
return {
|
|
8
|
-
clientId: response.data.clientId,
|
|
9
|
-
token: response.data.token,
|
|
10
|
-
baseUrl: response.data.baseUrl
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
var getClientIdFromAuth = function getClientIdFromAuth(auth) {
|
|
15
|
-
if (isClientBasedAuth(auth)) {
|
|
16
|
-
return auth.clientId;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
var tokenData = jwtDecode(auth.token);
|
|
20
|
-
return tokenData.clientId;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export var createPopupUserAuthProvider = function createPopupUserAuthProvider(stargate, mediaClientConfig) {
|
|
24
|
-
var tokenData;
|
|
25
|
-
return /*#__PURE__*/function () {
|
|
26
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(context) {
|
|
27
|
-
var userAuthProvider, authProvider, clientId;
|
|
28
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
29
|
-
while (1) {
|
|
30
|
-
switch (_context.prev = _context.next) {
|
|
31
|
-
case 0:
|
|
32
|
-
userAuthProvider = mediaClientConfig.userAuthProvider;
|
|
33
|
-
|
|
34
|
-
if (!userAuthProvider) {
|
|
35
|
-
_context.next = 3;
|
|
36
|
-
break;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
return _context.abrupt("return", userAuthProvider(context));
|
|
40
|
-
|
|
41
|
-
case 3:
|
|
42
|
-
_context.prev = 3;
|
|
43
|
-
|
|
44
|
-
if (!(!tokenData || stargate.isTokenExpired(tokenData))) {
|
|
45
|
-
_context.next = 14;
|
|
46
|
-
break;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
authProvider = mediaClientConfig.authProvider;
|
|
50
|
-
_context.t0 = getClientIdFromAuth;
|
|
51
|
-
_context.next = 9;
|
|
52
|
-
return authProvider(context);
|
|
53
|
-
|
|
54
|
-
case 9:
|
|
55
|
-
_context.t1 = _context.sent;
|
|
56
|
-
clientId = (0, _context.t0)(_context.t1);
|
|
57
|
-
_context.next = 13;
|
|
58
|
-
return stargate.fetchToken(clientId);
|
|
59
|
-
|
|
60
|
-
case 13:
|
|
61
|
-
tokenData = _context.sent;
|
|
62
|
-
|
|
63
|
-
case 14:
|
|
64
|
-
return _context.abrupt("return", getAuthFromEdgeData(tokenData));
|
|
65
|
-
|
|
66
|
-
case 17:
|
|
67
|
-
_context.prev = 17;
|
|
68
|
-
_context.t2 = _context["catch"](3);
|
|
69
|
-
throw new Error('Popup media picker Stargate call failed. If you were not intending to use Stargate you should provide userAuthProvider in the context');
|
|
70
|
-
|
|
71
|
-
case 20:
|
|
72
|
-
case "end":
|
|
73
|
-
return _context.stop();
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}, _callee, null, [[3, 17]]);
|
|
77
|
-
}));
|
|
78
|
-
|
|
79
|
-
return function (_x) {
|
|
80
|
-
return _ref.apply(this, arguments);
|
|
81
|
-
};
|
|
82
|
-
}();
|
|
83
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { isClientBasedAuth } from '@atlaskit/media-core';
|
|
2
|
-
export function mapAuthToAuthHeaders(auth) {
|
|
3
|
-
if (isClientBasedAuth(auth)) {
|
|
4
|
-
return {
|
|
5
|
-
'X-Client-Id': auth.clientId,
|
|
6
|
-
Authorization: "Bearer ".concat(auth.token)
|
|
7
|
-
};
|
|
8
|
-
} else {
|
|
9
|
-
return {
|
|
10
|
-
'X-Issuer': auth.asapIssuer,
|
|
11
|
-
Authorization: "Bearer ".concat(auth.token)
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export function mapAuthToQueryParameters(auth) {
|
|
16
|
-
if (isClientBasedAuth(auth)) {
|
|
17
|
-
return {
|
|
18
|
-
client: auth.clientId,
|
|
19
|
-
token: auth.token
|
|
20
|
-
};
|
|
21
|
-
} else {
|
|
22
|
-
return {
|
|
23
|
-
issuer: auth.asapIssuer,
|
|
24
|
-
token: auth.token
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { isClientBasedAuth } from '@atlaskit/media-core';
|
|
2
|
-
export function mapAuthToSourceFileOwner(auth) {
|
|
3
|
-
if (isClientBasedAuth(auth)) {
|
|
4
|
-
return {
|
|
5
|
-
id: auth.clientId,
|
|
6
|
-
token: auth.token,
|
|
7
|
-
baseUrl: auth.baseUrl
|
|
8
|
-
};
|
|
9
|
-
} else {
|
|
10
|
-
return auth;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Auth } from '@atlaskit/media-core';
|
|
2
|
-
export interface ClientBasedAuthHeaders {
|
|
3
|
-
readonly 'X-Client-Id': string;
|
|
4
|
-
readonly Authorization: string;
|
|
5
|
-
}
|
|
6
|
-
export interface AsapBasedAuthHeaders {
|
|
7
|
-
readonly 'X-Issuer': string;
|
|
8
|
-
readonly Authorization: string;
|
|
9
|
-
}
|
|
10
|
-
export declare type AuthHeaders = ClientBasedAuthHeaders | AsapBasedAuthHeaders;
|
|
11
|
-
export interface ClientBasedQueryParameters {
|
|
12
|
-
readonly client: string;
|
|
13
|
-
readonly token: string;
|
|
14
|
-
}
|
|
15
|
-
export interface AsapBasedQueryParameters {
|
|
16
|
-
readonly issuer: string;
|
|
17
|
-
readonly token: string;
|
|
18
|
-
}
|
|
19
|
-
export declare type AuthQueryParameters = ClientBasedQueryParameters | AsapBasedQueryParameters;
|
|
20
|
-
export declare function mapAuthToAuthHeaders(auth: Auth): AuthHeaders;
|
|
21
|
-
export declare function mapAuthToQueryParameters(auth: Auth): AuthQueryParameters;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Auth } from '@atlaskit/media-core';
|
|
2
|
-
export type { SourceFile } from '@atlaskit/media-client';
|
|
3
|
-
export declare type ClientBasedSourceFileOwner = {
|
|
4
|
-
readonly id: string;
|
|
5
|
-
readonly token: string;
|
|
6
|
-
readonly baseUrl: string;
|
|
7
|
-
};
|
|
8
|
-
export declare type AsapBasedSourceFileOwner = {
|
|
9
|
-
readonly asapIssuer: string;
|
|
10
|
-
readonly token: string;
|
|
11
|
-
readonly baseUrl: string;
|
|
12
|
-
};
|
|
13
|
-
export declare type SourceFileOwner = ClientBasedSourceFileOwner | AsapBasedSourceFileOwner;
|
|
14
|
-
export declare function mapAuthToSourceFileOwner(auth: Auth): SourceFileOwner;
|