asab_webui_shell 27.8.5 → 28.0.0-alpha.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.
Files changed (82) hide show
  1. package/dist/actions.js +15 -15
  2. package/dist/components/branding/BrandImage.js +3 -5
  3. package/dist/components/locationReplace.js +5 -11
  4. package/dist/config/ConfigReducer.js +2 -4
  5. package/dist/config/ConfigService.js +7 -10
  6. package/dist/containers/Alerts/index.js +34 -45
  7. package/dist/containers/Alerts/reducer.js +19 -20
  8. package/dist/containers/Application.js +200 -207
  9. package/dist/containers/FullscreenMode/reducer.js +5 -10
  10. package/dist/containers/Header/ApplicationScreenTitle/ApplicationScreenTitle.js +27 -32
  11. package/dist/containers/Header/ApplicationScreenTitle/index.js +8 -10
  12. package/dist/containers/Header/Help/HelpButton.js +58 -55
  13. package/dist/containers/Header/Help/HelpService.js +3 -4
  14. package/dist/containers/Header/index.js +23 -23
  15. package/dist/containers/Header/reducer.js +13 -15
  16. package/dist/containers/Navigation/index.js +4 -6
  17. package/dist/containers/Navigation/reducer.js +7 -11
  18. package/dist/containers/RouteErrorHandler/ErrorContainer.js +47 -31
  19. package/dist/containers/RouteErrorHandler/index.js +26 -27
  20. package/dist/containers/Router/ApplicationHashRouter.js +7 -8
  21. package/dist/containers/Router/ApplicationRouter.js +38 -38
  22. package/dist/containers/Router/index.js +2 -4
  23. package/dist/containers/Router/reducer.js +7 -11
  24. package/dist/containers/Sidebar/NavbarBrand.js +30 -38
  25. package/dist/containers/Sidebar/SidebarBottomItem.js +42 -36
  26. package/dist/containers/Sidebar/SidebarIcon.js +12 -9
  27. package/dist/containers/Sidebar/SidebarItem.js +135 -132
  28. package/dist/containers/Sidebar/SidebarItemRenderer.js +25 -26
  29. package/dist/containers/Sidebar/index.js +55 -70
  30. package/dist/containers/Sidebar/reducer.js +7 -11
  31. package/dist/containers/Sidebar/utils/sidebarRouteMatch.js +12 -15
  32. package/dist/containers/Sidepanel/Sidepanel.js +35 -40
  33. package/dist/containers/Toast/ToastComponent.js +21 -15
  34. package/dist/containers/Toast/ToastContainer.js +23 -32
  35. package/dist/containers/Toast/reducer.js +14 -16
  36. package/dist/index.js +10 -10
  37. package/dist/modules/about/AboutScreen.js +80 -65
  38. package/dist/modules/about/index.js +3 -3
  39. package/dist/modules/attentionrequired/attentionRequiredReducer.js +5 -10
  40. package/dist/modules/attentionrequired/components/OfflineIndication.js +9 -7
  41. package/dist/modules/attentionrequired/connectivityReducer.js +5 -10
  42. package/dist/modules/attentionrequired/index.js +2 -3
  43. package/dist/modules/attentionrequired/service.js +21 -24
  44. package/dist/modules/auth/actions.js +1 -1
  45. package/dist/modules/auth/api.js +53 -61
  46. package/dist/modules/auth/components/LoginLoopCard.js +24 -15
  47. package/dist/modules/auth/components/SessionExpirationAlert.js +26 -18
  48. package/dist/modules/auth/header.js +69 -62
  49. package/dist/modules/auth/index.js +418 -458
  50. package/dist/modules/auth/reducer.js +11 -14
  51. package/dist/modules/auth/screens/AccessControlScreen.js +71 -50
  52. package/dist/modules/i18n/actions.js +1 -1
  53. package/dist/modules/i18n/dropdown.js +52 -46
  54. package/dist/modules/i18n/escapeHtmlMinimal.js +2 -2
  55. package/dist/modules/i18n/index.js +2 -2
  56. package/dist/modules/i18n/reducer.js +5 -10
  57. package/dist/modules/i18n/service.js +52 -73
  58. package/dist/modules/invite/InvitationScreen.js +162 -138
  59. package/dist/modules/invite/index.js +5 -4
  60. package/dist/modules/tenant/TenantDropdown.js +52 -58
  61. package/dist/modules/tenant/access/AccessDeniedCard.js +52 -52
  62. package/dist/modules/tenant/actions.js +1 -1
  63. package/dist/modules/tenant/index.js +2 -2
  64. package/dist/modules/tenant/reducer.js +2 -4
  65. package/dist/modules/tenant/service.js +74 -91
  66. package/dist/screens/InvalidRouteScreen.js +30 -20
  67. package/dist/screens/SuspenseScreen.js +26 -24
  68. package/dist/screens/UnauthorizedAccessScreen.js +44 -33
  69. package/dist/screens/UnsupportedBrowserScreen.js +44 -38
  70. package/dist/services/BrandingService.js +16 -24
  71. package/dist/services/HeaderService.js +4 -7
  72. package/dist/services/TitleService.js +19 -20
  73. package/dist/theme/ThemeButton.js +18 -14
  74. package/dist/theme/ThemeReducer.js +3 -5
  75. package/dist/theme/ThemeService.js +6 -8
  76. package/dist/theme/actions.js +1 -1
  77. package/dist/utils/browserSupport.js +18 -23
  78. package/dist/utils/extractTenantFromUrl.js +3 -3
  79. package/dist/utils/jsonParseWithBigInt.js +10 -9
  80. package/dist/utils/pageLifecycle.js +5 -5
  81. package/dist/utils/statusAlerts.js +1 -1
  82. package/package.json +13 -13
@@ -1,28 +1,23 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = attentionRequiredReducer;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
7
  var _actions = require("../../actions");
10
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
- var initialState = {
8
+ const initialState = {
13
9
  beacon: {}
14
10
  };
15
11
 
16
12
  // Reducer for attention required, returning beacon
17
- function attentionRequiredReducer() {
18
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
19
- var action = arguments.length > 1 ? arguments[1] : undefined;
13
+ function attentionRequiredReducer(state = initialState, action) {
20
14
  switch (action.type) {
21
15
  case _actions.SET_ATTENTION_REQUIRED_BEACON:
22
16
  {
23
- return _objectSpread(_objectSpread({}, state), {}, {
17
+ return {
18
+ ...state,
24
19
  beacon: action.beacon
25
- });
20
+ };
26
21
  }
27
22
  default:
28
23
  return state;
@@ -1,19 +1,21 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.OfflineIndication = OfflineIndication;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _reactI18next = require("react-i18next");
10
+ var _jsxRuntime = require("react/jsx-runtime");
10
11
  // Header badge for displaying offline status
11
- function OfflineIndication(_ref) {
12
- var _ref$title = _ref.title,
13
- title = _ref$title === void 0 ? 'General|You are offline. Functionality of the Application may be limited.' : _ref$title;
14
- var _useTranslation = (0, _reactI18next.useTranslation)(),
15
- t = _useTranslation.t;
16
- return /*#__PURE__*/_react.default.createElement("i", {
12
+ function OfflineIndication({
13
+ title = 'General|You are offline. Functionality of the Application may be limited.'
14
+ }) {
15
+ const {
16
+ t
17
+ } = (0, _reactI18next.useTranslation)();
18
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("i", {
17
19
  title: t(title),
18
20
  className: "bi bi-wifi-off mx-3",
19
21
  style: {
@@ -1,28 +1,23 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.default = connectivityReducer;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
7
  var _actions = require("../../actions");
10
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
11
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
12
- var initialState = {
8
+ const initialState = {
13
9
  status: null
14
10
  };
15
11
 
16
12
  // Reducer for connectivity status
17
- function connectivityReducer() {
18
- var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState;
19
- var action = arguments.length > 1 ? arguments[1] : undefined;
13
+ function connectivityReducer(state = initialState, action) {
20
14
  switch (action.type) {
21
15
  case _actions.SET_CONNECTIVITY_STATUS:
22
16
  {
23
- return _objectSpread(_objectSpread({}, state), {}, {
17
+ return {
18
+ ...state,
24
19
  status: action.status
25
- });
20
+ };
26
21
  }
27
22
  default:
28
23
  return state;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
@@ -11,8 +11,7 @@ var _service = _interopRequireDefault(require("./service.js"));
11
11
  var _connectivityReducer = _interopRequireDefault(require("./connectivityReducer.js"));
12
12
  var _attentionRequiredReducer = _interopRequireDefault(require("./attentionRequiredReducer.js"));
13
13
  class AttentionRequiredModule extends _asab_webui_components.Module {
14
- constructor(app) {
15
- var name = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "AttentionRequiredModule";
14
+ constructor(app, name = "AttentionRequiredModule") {
16
15
  super(app, name);
17
16
  this.App = app;
18
17
  this.AttentionRequiredService = new _service.default(app, "AttentionRequiredService");
@@ -9,8 +9,7 @@ var _actions = require("../../actions");
9
9
  var _OfflineIndication = require("./components/OfflineIndication.js");
10
10
  // Service handling attention required
11
11
  class AttentionRequiredService extends _asab_webui_components.Service {
12
- constructor(app) {
13
- var serviceName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "AttentionRequiredService";
12
+ constructor(app, serviceName = "AttentionRequiredService") {
14
13
  super(app, serviceName);
15
14
  this.beaconWebSocket = null; // beacon websocket variable
16
15
  this.reconnectTimeout = null; // timeout variable
@@ -26,9 +25,8 @@ class AttentionRequiredService extends _asab_webui_components.Service {
26
25
 
27
26
  // Method for connection to beacon websocket
28
27
  connectBeaconWebSocket() {
29
- var _this$App;
30
28
  // Retrieve current tenant
31
- var currentTenant = (_this$App = this.App) === null || _this$App === void 0 || (_this$App = _this$App.Services) === null || _this$App === void 0 || (_this$App = _this$App.TenantService) === null || _this$App === void 0 ? void 0 : _this$App.getCurrentTenant();
29
+ const currentTenant = this.App?.Services?.TenantService?.getCurrentTenant();
32
30
  // Gracefully reconnect if tenant was not found
33
31
  if (!currentTenant) {
34
32
  // TODO: maybe set offline
@@ -36,7 +34,7 @@ class AttentionRequiredService extends _asab_webui_components.Service {
36
34
  this.reconnectBeaconWebSocket();
37
35
  return;
38
36
  }
39
- var BeaconServiceClient = this.App.createWebSocket('asab-lighthouse', "/beacon/".concat(currentTenant, "/ws"));
37
+ const BeaconServiceClient = this.App.createWebSocket('asab-lighthouse', `/beacon/${currentTenant}/ws`);
40
38
  this.beaconWebSocket = BeaconServiceClient;
41
39
  this.beaconWebSocket.onopen = () => {
42
40
  this.connectionStatus('online');
@@ -46,7 +44,7 @@ class AttentionRequiredService extends _asab_webui_components.Service {
46
44
  };
47
45
  this.beaconWebSocket.onmessage = message => {
48
46
  try {
49
- var data = JSON.parse(message.data);
47
+ const data = JSON.parse(message.data);
50
48
  // TODO: implement some type based recognition
51
49
  this.distributeData(data);
52
50
  } catch (e) {
@@ -98,18 +96,17 @@ class AttentionRequiredService extends _asab_webui_components.Service {
98
96
 
99
97
  // Method for distributing the data into Application store
100
98
  distributeData(data) {
101
- var next = this.transformData(data);
102
- var initial = this.prevBeacon === null;
103
- var nextEmpty = _isEmptyObject(next);
104
- var prevEmpty = _isEmptyObject(this.prevBeacon);
99
+ const next = this.transformData(data);
100
+ const initial = this.prevBeacon === null;
101
+ const nextEmpty = _isEmptyObject(next);
102
+ const prevEmpty = _isEmptyObject(this.prevBeacon);
105
103
 
106
104
  /*
107
105
  We dont want to repetitivelly dispatch empty beacons to the AppStore
108
106
  because it is causing unwanted re-rendering of the Application
109
107
  */
110
108
  if (initial || !nextEmpty || nextEmpty && !prevEmpty) {
111
- var _this$App2, _this$App2$dispatch;
112
- (_this$App2 = this.App) === null || _this$App2 === void 0 || (_this$App2 = _this$App2.AppStore) === null || _this$App2 === void 0 || (_this$App2$dispatch = _this$App2.dispatch) === null || _this$App2$dispatch === void 0 || _this$App2$dispatch.call(_this$App2, {
109
+ this.App?.AppStore?.dispatch?.({
113
110
  type: _actions.SET_ATTENTION_REQUIRED_BEACON,
114
111
  beacon: next
115
112
  });
@@ -125,17 +122,19 @@ class AttentionRequiredService extends _asab_webui_components.Service {
125
122
  return {};
126
123
  }
127
124
  return inputData.reduce((acc, entry) => {
128
- var type = entry.type,
129
- _c = entry._c,
130
- reference_path = entry.reference_path;
125
+ const {
126
+ type,
127
+ _c,
128
+ reference_path
129
+ } = entry;
131
130
 
132
131
  // Identify the dynamic key (it could be 'library', 'configuration', 'services', etc.)
133
- var dynamicKey = Object.keys(entry).find(key => typeof entry[key] === 'object' && entry[key] !== null && !Array.isArray(entry[key]));
132
+ const dynamicKey = Object.keys(entry).find(key => typeof entry[key] === 'object' && entry[key] !== null && !Array.isArray(entry[key]));
134
133
  if (!dynamicKey) {
135
134
  // Skip if no valid dynamic key is found
136
135
  return acc;
137
136
  }
138
- var data = entry[dynamicKey];
137
+ const data = entry[dynamicKey];
139
138
  // Ensure type is present in the accumulator
140
139
  if (!acc[type]) {
141
140
  acc[type] = {
@@ -152,23 +151,21 @@ class AttentionRequiredService extends _asab_webui_components.Service {
152
151
  }
153
152
  // Method for publishing the connection status and displaying offline indication
154
153
  connectionStatus(status) {
155
- var _this$App3;
156
- if ((_this$App3 = this.App) !== null && _this$App3 !== void 0 && _this$App3.PubSub) {
157
- var _this$App4, _this$App5;
154
+ if (this.App?.PubSub) {
158
155
  // Distribute status
159
- (_this$App4 = this.App) === null || _this$App4 === void 0 || (_this$App4 = _this$App4.PubSub) === null || _this$App4 === void 0 || _this$App4.publish('Application.status!', {
156
+ this.App?.PubSub?.publish('Application.status!', {
160
157
  status
161
158
  });
162
- var headerService = (_this$App5 = this.App) === null || _this$App5 === void 0 || (_this$App5 = _this$App5.Services) === null || _this$App5 === void 0 ? void 0 : _this$App5.HeaderService;
159
+ const headerService = this.App?.Services?.HeaderService;
163
160
  if (headerService) {
164
161
  if (this.prevStatus != status) {
165
162
  if (status === 'offline') {
166
- headerService === null || headerService === void 0 || headerService.addComponent({
163
+ headerService?.addComponent({
167
164
  component: _OfflineIndication.OfflineIndication,
168
165
  order: 100
169
166
  });
170
167
  } else {
171
- headerService === null || headerService === void 0 || headerService.removeComponent(_OfflineIndication.OfflineIndication);
168
+ headerService?.removeComponent(_OfflineIndication.OfflineIndication);
172
169
  }
173
170
  this.prevStatus = status;
174
171
  }
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.types = void 0;
7
- var types = exports.types = {
7
+ const types = exports.types = {
8
8
  AUTH_USERINFO: "SeaCat/AUTH_USERINFO",
9
9
  AUTH_RESOURCES: "SeaCat/AUTH_RESOURCES",
10
10
  AUTH_SESSION_EXPIRATION: "SeaCat/AUTH_SESSION_EXPIRATION"
@@ -1,11 +1,10 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports.SeaCatAuthApi = exports.GoogleOAuth2Api = void 0;
8
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
9
8
  var _axios = _interopRequireDefault(require("axios"));
10
9
  var _locationReplace = require("../../components/locationReplace");
11
10
  class SeaCatAuthApi {
@@ -35,47 +34,44 @@ class SeaCatAuthApi {
35
34
  }
36
35
 
37
36
  // This method will cause a navigation from the app to the OAuth2 login screen
38
- login(redirect_uri, force_login_prompt) {
39
- var _this = this;
40
- return (0, _asyncToGenerator2.default)(function* () {
41
- /*
42
- Adding tenant directly to scope (if available).
43
- */
44
- var currentTenant = null;
45
- if (_this.App.Services.TenantService) {
46
- currentTenant = _this.App.Services.TenantService.getCurrentTenant();
47
- }
48
- var scopeArray = _this.Scope.split(" ");
49
- var tenantValue = scopeArray.find(str => str.includes("tenant"));
50
- var loginScope = currentTenant != null && tenantValue != undefined ? _this.Scope.replace("".concat(tenantValue), "tenant:".concat(currentTenant)) : _this.Scope;
37
+ async login(redirect_uri, force_login_prompt) {
38
+ /*
39
+ Adding tenant directly to scope (if available).
40
+ */
41
+ let currentTenant = null;
42
+ if (this.App.Services.TenantService) {
43
+ currentTenant = this.App.Services.TenantService.getCurrentTenant();
44
+ }
45
+ let scopeArray = this.Scope.split(" ");
46
+ let tenantValue = scopeArray.find(str => str.includes("tenant"));
47
+ let loginScope = currentTenant != null && tenantValue != undefined ? this.Scope.replace(`${tenantValue}`, `tenant:${currentTenant}`) : this.Scope;
51
48
 
52
- // Generate random state
53
- var typedArray = new Uint32Array(10);
54
- crypto.getRandomValues(typedArray);
55
- var randomIndex = Math.floor(Math.random() * typedArray.length);
56
- var stateIndex = typedArray[randomIndex];
49
+ // Generate random state
50
+ const typedArray = new Uint32Array(10);
51
+ crypto.getRandomValues(typedArray);
52
+ let randomIndex = Math.floor(Math.random() * typedArray.length);
53
+ const stateIndex = typedArray[randomIndex];
57
54
 
58
- /*
59
- As per OAuth2 specs, the redirect_uri must *exactly* match one of the URIs pre-registered
60
- at the authorization server, hence it cannot contain variable components (query, hash).
61
- Here we use the application's base URL as the redirect_uri and store the variable parts in the state.
62
- */
63
- var redirectUri = new URL(redirect_uri);
64
- var state = redirectUri.search + redirectUri.hash;
65
- localStorage.setItem("oauth2_state_".concat(stateIndex), state);
66
- var params = new URLSearchParams({
67
- response_type: "code",
68
- scope: loginScope,
69
- client_id: _this.ClientId,
70
- redirect_uri: redirectUri.origin + redirectUri.pathname,
71
- state: stateIndex
72
- });
73
- if (force_login_prompt === true) {
74
- params.append("prompt", "login");
75
- }
76
- var oidcURL = _this.App.getServiceURL('openidconnect');
77
- yield (0, _locationReplace.locationReplace)(oidcURL + "/authorize?" + params.toString());
78
- })();
55
+ /*
56
+ As per OAuth2 specs, the redirect_uri must *exactly* match one of the URIs pre-registered
57
+ at the authorization server, hence it cannot contain variable components (query, hash).
58
+ Here we use the application's base URL as the redirect_uri and store the variable parts in the state.
59
+ */
60
+ const redirectUri = new URL(redirect_uri);
61
+ const state = redirectUri.search + redirectUri.hash;
62
+ localStorage.setItem(`oauth2_state_${stateIndex}`, state);
63
+ const params = new URLSearchParams({
64
+ response_type: "code",
65
+ scope: loginScope,
66
+ client_id: this.ClientId,
67
+ redirect_uri: redirectUri.origin + redirectUri.pathname,
68
+ state: stateIndex
69
+ });
70
+ if (force_login_prompt === true) {
71
+ params.append("prompt", "login");
72
+ }
73
+ let oidcURL = this.App.getServiceURL('openidconnect');
74
+ await (0, _locationReplace.locationReplace)(oidcURL + "/authorize?" + params.toString());
79
75
  }
80
76
  logout(access_token) {
81
77
  return this.OidcAPI.get('/logout', {
@@ -84,12 +80,11 @@ class SeaCatAuthApi {
84
80
  }
85
81
  });
86
82
  }
87
- userinfo(access_token) {
88
- var internal = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
83
+ userinfo(access_token, internal = false) {
89
84
  // 'internal' is a flag to indicate that the userinfo is requested from the internal API (SeaCat Auth API)
90
85
  // instead of the public OpenID Connect API - that is used for the web app that runs inside of the cluser (asab-pyppeteer)
91
86
 
92
- var headers = {};
87
+ let headers = {};
93
88
  // Add access bearer token to the Authorization headers
94
89
  if (access_token != null) {
95
90
  headers.Authorization = 'Bearer ' + access_token;
@@ -105,8 +100,8 @@ class SeaCatAuthApi {
105
100
  }
106
101
  }
107
102
  token_authorization_code(authorization_code, redirect_uri) {
108
- var redirectUri = new URL(redirect_uri);
109
- var qs = new URLSearchParams({
103
+ const redirectUri = new URL(redirect_uri);
104
+ const qs = new URLSearchParams({
110
105
  grant_type: "authorization_code",
111
106
  code: authorization_code,
112
107
  client_id: this.ClientId,
@@ -121,7 +116,7 @@ class SeaCatAuthApi {
121
116
 
122
117
  // Method for token refresh
123
118
  token_refresh(refresh_token) {
124
- var qs = new URLSearchParams({
119
+ const qs = new URLSearchParams({
125
120
  grant_type: "refresh_token",
126
121
  refresh_token: refresh_token,
127
122
  client_id: this.ClientId
@@ -147,38 +142,35 @@ class GoogleOAuth2Api {
147
142
  this.Axios = _axios.default.create({
148
143
  timeout: 10000
149
144
  });
150
- var scope = config.get('google.oauth2.scope');
145
+ const scope = config.get('google.oauth2.scope');
151
146
  this.ClientId = config.get('google.oauth2.client_id');
152
147
  this.ClientSecret = config.get('google.oauth2.client_secret');
153
148
  this.Scope = scope ? scope : "openid https://www.googleapis.com/auth/userinfo.profile";
154
149
  }
155
150
 
156
151
  // This method will cause a navigation from the app to the OAuth2 login screen
157
- login(redirect_uri) {
158
- var _this2 = this;
159
- return (0, _asyncToGenerator2.default)(function* () {
160
- var params = new URLSearchParams({
161
- response_type: "code",
162
- scope: _this2.Scope,
163
- client_id: _this2.ClientId,
164
- redirect_uri: redirect_uri
165
- });
166
- yield (0, _locationReplace.locationReplace)("https://accounts.google.com/o/oauth2/auth" + "?" + params.toString());
167
- })();
152
+ async login(redirect_uri) {
153
+ const params = new URLSearchParams({
154
+ response_type: "code",
155
+ scope: this.Scope,
156
+ client_id: this.ClientId,
157
+ redirect_uri: redirect_uri
158
+ });
159
+ await (0, _locationReplace.locationReplace)("https://accounts.google.com/o/oauth2/auth" + "?" + params.toString());
168
160
  }
169
161
  logout(access_token) {
170
162
  // There is no Google logout API URL, to our best knowledge
171
163
  return null;
172
164
  }
173
165
  userinfo(access_token) {
174
- var qs = new URLSearchParams({
166
+ const qs = new URLSearchParams({
175
167
  alt: "json",
176
168
  access_token: access_token
177
169
  });
178
170
  return this.Axios.get('https://www.googleapis.com/oauth2/v1/userinfo?' + qs.toString());
179
171
  }
180
172
  token_authorization_code(authorization_code, redirect_uri) {
181
- var qs = new URLSearchParams({
173
+ const qs = new URLSearchParams({
182
174
  grant_type: "authorization_code",
183
175
  code: authorization_code,
184
176
  client_id: this.ClientId,
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
@@ -9,29 +9,38 @@ var _react = _interopRequireDefault(require("react"));
9
9
  var _reactI18next = require("react-i18next");
10
10
  var _reactstrap = require("reactstrap");
11
11
  require("./LoginLoopCard.scss");
12
+ var _jsxRuntime = require("react/jsx-runtime");
12
13
  function LoginLoopCard(props) {
13
- var _props$app;
14
- var _useTranslation = (0, _reactI18next.useTranslation)(),
15
- t = _useTranslation.t;
14
+ const {
15
+ t
16
+ } = (0, _reactI18next.useTranslation)();
16
17
 
17
18
  // Validate if AuthModule is present
18
- var hasAuthModule = (_props$app = props.app) === null || _props$app === void 0 || (_props$app = _props$app.Modules) === null || _props$app === void 0 ? void 0 : _props$app.some(m => m.Name === 'AuthModule');
19
+ const hasAuthModule = props.app?.Modules?.some(m => m.Name === 'AuthModule');
19
20
  if (!hasAuthModule) {
20
21
  return null;
21
22
  }
22
23
 
23
24
  // Read the number of login attempts from sessionStorage and render the card if the number is greater than 10
24
- var attempts = parseInt(sessionStorage.getItem('SeaCatLoginAttempts') || '0', 10);
25
+ const attempts = parseInt(sessionStorage.getItem('SeaCatLoginAttempts') || '0', 10);
25
26
  if (!Number.isFinite(attempts) || attempts <= 10) {
26
27
  return null;
27
28
  }
28
- return /*#__PURE__*/_react.default.createElement("div", {
29
- className: "auth-login-loop-wrapper"
30
- }, /*#__PURE__*/_react.default.createElement(_reactstrap.Card, null, /*#__PURE__*/_react.default.createElement(_reactstrap.CardHeader, {
31
- className: "card-header-flex"
32
- }, /*#__PURE__*/_react.default.createElement("div", {
33
- className: "flex-fill text-center"
34
- }, /*#__PURE__*/_react.default.createElement("h2", {
35
- className: "text-primary"
36
- }, t('ASABAuthModule|Authentication error')))), /*#__PURE__*/_react.default.createElement(_reactstrap.CardBody, null, t('ASABAuthModule|Too many login redirects occurred. Please contact application administrator.'))));
29
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
30
+ className: "auth-login-loop-wrapper",
31
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactstrap.Card, {
32
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactstrap.CardHeader, {
33
+ className: "card-header-flex",
34
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
35
+ className: "flex-fill text-center",
36
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("h2", {
37
+ className: "text-primary",
38
+ children: t('ASABAuthModule|Authentication error')
39
+ })
40
+ })
41
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactstrap.CardBody, {
42
+ children: t('ASABAuthModule|Too many login redirects occurred. Please contact application administrator.')
43
+ })]
44
+ })
45
+ });
37
46
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
@@ -8,26 +8,34 @@ exports.SessionExpirationAlert = SessionExpirationAlert;
8
8
  var _react = _interopRequireDefault(require("react"));
9
9
  var _reactI18next = require("react-i18next");
10
10
  var _reactstrap = require("reactstrap");
11
+ var _jsxRuntime = require("react/jsx-runtime");
11
12
  // Session expiration custom Alert component
12
- function SessionExpirationAlert(_ref) {
13
- var alert = _ref.alert;
14
- var _useTranslation = (0, _reactI18next.useTranslation)(),
15
- t = _useTranslation.t; // Use the hook inside the functional component
13
+ function SessionExpirationAlert({
14
+ alert
15
+ }) {
16
+ const {
17
+ t
18
+ } = (0, _reactI18next.useTranslation)(); // Use the hook inside the functional component
16
19
 
17
- return /*#__PURE__*/_react.default.createElement(_reactstrap.Alert, {
18
- key: alert.key,
20
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactstrap.Alert, {
19
21
  color: alert.level,
20
22
  className: "shadow",
21
23
  fade: true,
22
- isOpen: !alert.acked
23
- }, /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("h5", null, t(alert.message)), /*#__PURE__*/_react.default.createElement("div", {
24
- onClick: () => window.location.reload(),
25
- className: "mt-2",
26
- style: {
27
- whiteSpace: 'pre-wrap',
28
- fontWeight: 'bold',
29
- cursor: 'pointer',
30
- textDecoration: 'underline'
31
- }
32
- }, t('ASABAuthModule|Click here to proceed to login.'))));
24
+ isOpen: !alert.acked,
25
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
26
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h5", {
27
+ children: t(alert.message)
28
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
29
+ onClick: () => window.location.reload(),
30
+ className: "mt-2",
31
+ style: {
32
+ whiteSpace: 'pre-wrap',
33
+ fontWeight: 'bold',
34
+ cursor: 'pointer',
35
+ textDecoration: 'underline'
36
+ },
37
+ children: t('ASABAuthModule|Click here to proceed to login.')
38
+ })]
39
+ })
40
+ }, alert.key);
33
41
  }