@atlaskit/media-test-helpers 36.0.2 → 36.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/media-test-helpers
2
2
 
3
+ ## 36.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [#134528](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/pull-requests/134528)
8
+ [`61165836daa36`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/61165836daa36) -
9
+ [ux] Use latest media token on video resume or seek
10
+
11
+ Previously when resuming a video after the current token had expired the video player would fail
12
+ to load and would show an error boundary page.
13
+
14
+ The same bug would occur when seeking to a new `currentTime` after the token expired.
15
+
16
+ Now both the dedicated and inline player will update their `src` to a new URL with the latest
17
+ cached token.
18
+
19
+ - Updated dependencies
20
+
3
21
  ## 36.0.2
4
22
 
5
23
  ### Patch Changes
@@ -19,6 +19,7 @@ var StoryBookAuthProvider = exports.StoryBookAuthProvider = /*#__PURE__*/functio
19
19
  return (0, _createClass2.default)(StoryBookAuthProvider, null, [{
20
20
  key: "create",
21
21
  value: function create(isAsapEnvironment, access) {
22
+ var expiresIn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 600;
22
23
  var loadTenatAuth = /*#__PURE__*/function () {
23
24
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(collectionName) {
24
25
  var environment, headers, config, url, response;
@@ -33,7 +34,8 @@ var StoryBookAuthProvider = exports.StoryBookAuthProvider = /*#__PURE__*/functio
33
34
  method: 'POST',
34
35
  headers: headers,
35
36
  body: access ? JSON.stringify({
36
- access: access
37
+ access: access,
38
+ expiresIn: expiresIn
37
39
  }) : undefined
38
40
  };
39
41
  url = "".concat(_mediaBaseURLS.MEDIA_PLAYGROUND_BASE_URL, "/token/tenant?collection=").concat(collectionName, "&environment=").concat(environment);
@@ -61,6 +63,9 @@ var StoryBookAuthProvider = exports.StoryBookAuthProvider = /*#__PURE__*/functio
61
63
  var cacheKey = "".concat(collectionName, "-").concat(accessStr, "-").concat(isAsapEnvironment);
62
64
  if (!cachedAuths[cacheKey]) {
63
65
  cachedAuths[cacheKey] = loadTenatAuth(collectionName);
66
+ setInterval(function () {
67
+ cachedAuths[cacheKey] = loadTenatAuth(collectionName);
68
+ }, expiresIn * 1000 / 2);
64
69
  }
65
70
  return cachedAuths[cacheKey];
66
71
  };
@@ -31,6 +31,7 @@ var accessUrns = {
31
31
  var requestAuthProvider = /*#__PURE__*/function () {
32
32
  var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(authEnvironment, collectionName) {
33
33
  var env,
34
+ expiresIn,
34
35
  url,
35
36
  body,
36
37
  headers,
@@ -40,23 +41,25 @@ var requestAuthProvider = /*#__PURE__*/function () {
40
41
  while (1) switch (_context.prev = _context.next) {
41
42
  case 0:
42
43
  env = _args.length > 2 && _args[2] !== undefined ? _args[2] : 'staging';
44
+ expiresIn = _args.length > 3 && _args[3] !== undefined ? _args[3] : 600;
43
45
  url = "https://media-playground.".concat(env, ".atl-paas.net/token/tenant?environment=").concat(authEnvironment);
44
46
  body = JSON.stringify({
45
- access: accessUrns[collectionName] || {}
47
+ access: accessUrns[collectionName] || {},
48
+ expiresIn: expiresIn
46
49
  });
47
50
  headers = new Headers();
48
51
  headers.append('Content-Type', 'application/json; charset=utf-8');
49
52
  headers.append('Accept', 'text/plain, */*; q=0.01');
50
- _context.next = 8;
53
+ _context.next = 9;
51
54
  return fetch(url, {
52
55
  method: 'POST',
53
56
  body: body,
54
57
  headers: headers
55
58
  });
56
- case 8:
59
+ case 9:
57
60
  response = _context.sent;
58
61
  return _context.abrupt("return", response.json());
59
- case 10:
62
+ case 11:
60
63
  case "end":
61
64
  return _context.stop();
62
65
  }
@@ -69,12 +72,16 @@ var requestAuthProvider = /*#__PURE__*/function () {
69
72
  var mediaPickerAuthProvider = exports.mediaPickerAuthProvider = function mediaPickerAuthProvider() {
70
73
  var authEnvironment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asap';
71
74
  var env = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'staging';
75
+ var expiresIn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 600;
72
76
  return function (context) {
73
77
  var collectionName = context && context.collectionName || _collectionNames.defaultCollectionName;
74
78
  authEnvironment = authEnvironment === 'asap' ? 'asap' : '';
75
79
  var cacheKey = "".concat(collectionName, ":").concat(authEnvironment);
76
80
  if (!cachedAuths[cacheKey]) {
77
81
  cachedAuths[cacheKey] = requestAuthProvider(authEnvironment, collectionName, env);
82
+ setInterval(function () {
83
+ cachedAuths[cacheKey] = requestAuthProvider(authEnvironment, collectionName, env);
84
+ }, expiresIn * 1000 / 2);
78
85
  }
79
86
  return cachedAuths[cacheKey];
80
87
  };
@@ -2,7 +2,7 @@ import { defaultCollectionName } from './collectionNames';
2
2
  import { MEDIA_PLAYGROUND_BASE_URL } from './mediaBaseURLS';
3
3
  const cachedAuths = {};
4
4
  export class StoryBookAuthProvider {
5
- static create(isAsapEnvironment, access) {
5
+ static create(isAsapEnvironment, access, expiresIn = 600) {
6
6
  const loadTenatAuth = async collectionName => {
7
7
  const environment = isAsapEnvironment ? 'asap' : '';
8
8
  const headers = new Headers();
@@ -12,7 +12,8 @@ export class StoryBookAuthProvider {
12
12
  method: 'POST',
13
13
  headers,
14
14
  body: access ? JSON.stringify({
15
- access
15
+ access,
16
+ expiresIn
16
17
  }) : undefined
17
18
  };
18
19
  const url = `${MEDIA_PLAYGROUND_BASE_URL}/token/tenant?collection=${collectionName}&environment=${environment}`;
@@ -27,6 +28,9 @@ export class StoryBookAuthProvider {
27
28
  const cacheKey = `${collectionName}-${accessStr}-${isAsapEnvironment}`;
28
29
  if (!cachedAuths[cacheKey]) {
29
30
  cachedAuths[cacheKey] = loadTenatAuth(collectionName);
31
+ setInterval(() => {
32
+ cachedAuths[cacheKey] = loadTenatAuth(collectionName);
33
+ }, expiresIn * 1000 / 2);
30
34
  }
31
35
  return cachedAuths[cacheKey];
32
36
  };
@@ -19,10 +19,11 @@ const accessUrns = {
19
19
  'urn:filestore:file:*': ['read', 'update']
20
20
  }
21
21
  };
22
- const requestAuthProvider = async (authEnvironment, collectionName, env = 'staging') => {
22
+ const requestAuthProvider = async (authEnvironment, collectionName, env = 'staging', expiresIn = 600) => {
23
23
  const url = `https://media-playground.${env}.atl-paas.net/token/tenant?environment=${authEnvironment}`;
24
24
  const body = JSON.stringify({
25
- access: accessUrns[collectionName] || {}
25
+ access: accessUrns[collectionName] || {},
26
+ expiresIn
26
27
  });
27
28
  const headers = new Headers();
28
29
  headers.append('Content-Type', 'application/json; charset=utf-8');
@@ -36,12 +37,15 @@ const requestAuthProvider = async (authEnvironment, collectionName, env = 'stagi
36
37
  // We leverage the fact, that our internal /toke/tenant API returns data in the same format as Auth
37
38
  return response.json();
38
39
  };
39
- export const mediaPickerAuthProvider = (authEnvironment = 'asap', env = 'staging') => context => {
40
+ export const mediaPickerAuthProvider = (authEnvironment = 'asap', env = 'staging', expiresIn = 600) => context => {
40
41
  const collectionName = context && context.collectionName || defaultCollectionName;
41
42
  authEnvironment = authEnvironment === 'asap' ? 'asap' : '';
42
43
  const cacheKey = `${collectionName}:${authEnvironment}`;
43
44
  if (!cachedAuths[cacheKey]) {
44
45
  cachedAuths[cacheKey] = requestAuthProvider(authEnvironment, collectionName, env);
46
+ setInterval(() => {
47
+ cachedAuths[cacheKey] = requestAuthProvider(authEnvironment, collectionName, env);
48
+ }, expiresIn * 1000 / 2);
45
49
  }
46
50
  return cachedAuths[cacheKey];
47
51
  };
@@ -12,6 +12,7 @@ export var StoryBookAuthProvider = /*#__PURE__*/function () {
12
12
  return _createClass(StoryBookAuthProvider, null, [{
13
13
  key: "create",
14
14
  value: function create(isAsapEnvironment, access) {
15
+ var expiresIn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 600;
15
16
  var loadTenatAuth = /*#__PURE__*/function () {
16
17
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(collectionName) {
17
18
  var environment, headers, config, url, response;
@@ -26,7 +27,8 @@ export var StoryBookAuthProvider = /*#__PURE__*/function () {
26
27
  method: 'POST',
27
28
  headers: headers,
28
29
  body: access ? JSON.stringify({
29
- access: access
30
+ access: access,
31
+ expiresIn: expiresIn
30
32
  }) : undefined
31
33
  };
32
34
  url = "".concat(MEDIA_PLAYGROUND_BASE_URL, "/token/tenant?collection=").concat(collectionName, "&environment=").concat(environment);
@@ -54,6 +56,9 @@ export var StoryBookAuthProvider = /*#__PURE__*/function () {
54
56
  var cacheKey = "".concat(collectionName, "-").concat(accessStr, "-").concat(isAsapEnvironment);
55
57
  if (!cachedAuths[cacheKey]) {
56
58
  cachedAuths[cacheKey] = loadTenatAuth(collectionName);
59
+ setInterval(function () {
60
+ cachedAuths[cacheKey] = loadTenatAuth(collectionName);
61
+ }, expiresIn * 1000 / 2);
57
62
  }
58
63
  return cachedAuths[cacheKey];
59
64
  };
@@ -24,6 +24,7 @@ var accessUrns = {
24
24
  var requestAuthProvider = /*#__PURE__*/function () {
25
25
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(authEnvironment, collectionName) {
26
26
  var env,
27
+ expiresIn,
27
28
  url,
28
29
  body,
29
30
  headers,
@@ -33,23 +34,25 @@ var requestAuthProvider = /*#__PURE__*/function () {
33
34
  while (1) switch (_context.prev = _context.next) {
34
35
  case 0:
35
36
  env = _args.length > 2 && _args[2] !== undefined ? _args[2] : 'staging';
37
+ expiresIn = _args.length > 3 && _args[3] !== undefined ? _args[3] : 600;
36
38
  url = "https://media-playground.".concat(env, ".atl-paas.net/token/tenant?environment=").concat(authEnvironment);
37
39
  body = JSON.stringify({
38
- access: accessUrns[collectionName] || {}
40
+ access: accessUrns[collectionName] || {},
41
+ expiresIn: expiresIn
39
42
  });
40
43
  headers = new Headers();
41
44
  headers.append('Content-Type', 'application/json; charset=utf-8');
42
45
  headers.append('Accept', 'text/plain, */*; q=0.01');
43
- _context.next = 8;
46
+ _context.next = 9;
44
47
  return fetch(url, {
45
48
  method: 'POST',
46
49
  body: body,
47
50
  headers: headers
48
51
  });
49
- case 8:
52
+ case 9:
50
53
  response = _context.sent;
51
54
  return _context.abrupt("return", response.json());
52
- case 10:
55
+ case 11:
53
56
  case "end":
54
57
  return _context.stop();
55
58
  }
@@ -62,12 +65,16 @@ var requestAuthProvider = /*#__PURE__*/function () {
62
65
  export var mediaPickerAuthProvider = function mediaPickerAuthProvider() {
63
66
  var authEnvironment = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'asap';
64
67
  var env = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'staging';
68
+ var expiresIn = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 600;
65
69
  return function (context) {
66
70
  var collectionName = context && context.collectionName || defaultCollectionName;
67
71
  authEnvironment = authEnvironment === 'asap' ? 'asap' : '';
68
72
  var cacheKey = "".concat(collectionName, ":").concat(authEnvironment);
69
73
  if (!cachedAuths[cacheKey]) {
70
74
  cachedAuths[cacheKey] = requestAuthProvider(authEnvironment, collectionName, env);
75
+ setInterval(function () {
76
+ cachedAuths[cacheKey] = requestAuthProvider(authEnvironment, collectionName, env);
77
+ }, expiresIn * 1000 / 2);
71
78
  }
72
79
  return cachedAuths[cacheKey];
73
80
  };
@@ -2,5 +2,5 @@ import { type AuthProvider } from '@atlaskit/media-core';
2
2
  export declare class StoryBookAuthProvider {
3
3
  static create(isAsapEnvironment: boolean, access?: {
4
4
  [resourceUrn: string]: string[];
5
- }): AuthProvider;
5
+ }, expiresIn?: number): AuthProvider;
6
6
  }
@@ -1,3 +1,3 @@
1
1
  import { type Auth, type AuthContext } from '@atlaskit/media-core';
2
2
  export type MediaEnv = 'staging';
3
- export declare const mediaPickerAuthProvider: (authEnvironment?: string, env?: MediaEnv) => (context?: AuthContext) => Promise<Auth>;
3
+ export declare const mediaPickerAuthProvider: (authEnvironment?: string, env?: MediaEnv, expiresIn?: number) => (context?: AuthContext) => Promise<Auth>;
@@ -2,5 +2,5 @@ import { type AuthProvider } from '@atlaskit/media-core';
2
2
  export declare class StoryBookAuthProvider {
3
3
  static create(isAsapEnvironment: boolean, access?: {
4
4
  [resourceUrn: string]: string[];
5
- }): AuthProvider;
5
+ }, expiresIn?: number): AuthProvider;
6
6
  }
@@ -1,3 +1,3 @@
1
1
  import { type Auth, type AuthContext } from '@atlaskit/media-core';
2
2
  export type MediaEnv = 'staging';
3
- export declare const mediaPickerAuthProvider: (authEnvironment?: string, env?: MediaEnv) => (context?: AuthContext) => Promise<Auth>;
3
+ export declare const mediaPickerAuthProvider: (authEnvironment?: string, env?: MediaEnv, expiresIn?: number) => (context?: AuthContext) => Promise<Auth>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/media-test-helpers",
3
- "version": "36.0.2",
3
+ "version": "36.0.3",
4
4
  "description": "Collection of test helpers used in media component stories and specs",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -29,17 +29,17 @@
29
29
  "@atlaskit/button": "^23.2.0",
30
30
  "@atlaskit/checkbox": "^17.1.0",
31
31
  "@atlaskit/form": "^12.0.0",
32
- "@atlaskit/icon": "^26.1.0",
32
+ "@atlaskit/icon": "^26.4.0",
33
33
  "@atlaskit/locale": "^3.0.0",
34
34
  "@atlaskit/media-client": "^33.3.0",
35
35
  "@atlaskit/media-common": "^12.1.0",
36
36
  "@atlaskit/media-ui": "^28.2.0",
37
- "@atlaskit/popup": "^4.2.0",
37
+ "@atlaskit/popup": "^4.3.0",
38
38
  "@atlaskit/primitives": "^14.8.0",
39
39
  "@atlaskit/tabs": "^18.1.0",
40
40
  "@atlaskit/textfield": "^8.0.0",
41
41
  "@atlaskit/tokens": "^4.9.0",
42
- "@atlaskit/tooltip": "^20.0.0",
42
+ "@atlaskit/tooltip": "^20.2.0",
43
43
  "@atlaskit/ufo": "^0.4.0",
44
44
  "@babel/runtime": "^7.0.0",
45
45
  "@emotion/react": "^11.7.1",