@opengeoweb/authentication 15.2.0 → 15.3.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/index.esm.js +33 -106
- package/package.json +3 -6
- package/src/lib/components/Providers/Providers.d.ts +0 -4
- package/src/lib/components/UserMenuRoles/UserMenuRoles.d.ts +2 -3
- package/src/lib/components/UserMenuRoles/index.d.ts +0 -1
- package/src/lib/components/UserMenuRoles/UserMenuRolesConnect.d.ts +0 -7
- package/src/lib/components/UserMenuRoles/UserMenuRolesConnect.spec.d.ts +0 -1
- package/src/lib/components/UserMenuRoles/UserMenuRolesConnect.stories.d.ts +0 -8
package/index.esm.js
CHANGED
|
@@ -6,9 +6,7 @@ import { sessionStorageProvider, useIsMounted, SHARED_NAMESPACE, AlertBanner, us
|
|
|
6
6
|
import { useTranslation, Trans } from 'react-i18next';
|
|
7
7
|
import { ThemeWrapper } from '@opengeoweb/theme';
|
|
8
8
|
import 'i18next';
|
|
9
|
-
import {
|
|
10
|
-
import { useDispatch } from 'react-redux';
|
|
11
|
-
import { snackbarTypes, snackbarActions } from '@opengeoweb/snackbar';
|
|
9
|
+
import { FormControl, FormLabel, RadioGroup, FormControlLabel, Radio } from '@mui/material';
|
|
12
10
|
|
|
13
11
|
var en$1 = {
|
|
14
12
|
"api-role-title-user": "User",
|
|
@@ -36,26 +34,22 @@ var apiTranslations = {
|
|
|
36
34
|
var en = {
|
|
37
35
|
"auth-logout-go-back-to-home-page": "Go back to the <1>Home Page</1>",
|
|
38
36
|
"auth-logout-you-are-logged-out": "You are logged out.",
|
|
39
|
-
"auth-role-title": "Role"
|
|
40
|
-
"auth-role-message-assigned": "Role {{role}} has been assigned"
|
|
37
|
+
"auth-role-title": "Role"
|
|
41
38
|
};
|
|
42
39
|
var fi = {
|
|
43
40
|
"auth-logout-go-back-to-home-page": "Palaa takaisin <1>Kotisivulle</1>",
|
|
44
41
|
"auth-logout-you-are-logged-out": "Olet kirjautunut ulos.",
|
|
45
|
-
"auth-role-title": "Rooli"
|
|
46
|
-
"auth-role-message-assigned": "Rooli {{role}} on annettu"
|
|
42
|
+
"auth-role-title": "Rooli"
|
|
47
43
|
};
|
|
48
44
|
var no = {
|
|
49
45
|
"auth-logout-go-back-to-home-page": "Gå tilbake til <1>Hjemmesiden</1>",
|
|
50
46
|
"auth-logout-you-are-logged-out": "Du er logget ut",
|
|
51
|
-
"auth-role-title": "Rolle"
|
|
52
|
-
"auth-role-message-assigned": "Rolle {{role}} har blitt tildelt"
|
|
47
|
+
"auth-role-title": "Rolle"
|
|
53
48
|
};
|
|
54
49
|
var nl = {
|
|
55
50
|
"auth-logout-go-back-to-home-page": "Ga terug naar de <1>Startpagina</1>",
|
|
56
51
|
"auth-logout-you-are-logged-out": "Je bent uitgelogd.",
|
|
57
|
-
"auth-role-title": "Rol"
|
|
58
|
-
"auth-role-message-assigned": "Rol {{role}} is geactiveerd"
|
|
52
|
+
"auth-role-title": "Rol"
|
|
59
53
|
};
|
|
60
54
|
var authTranslations = {
|
|
61
55
|
en: en,
|
|
@@ -1235,112 +1229,45 @@ var OAuth2Logout = function OAuth2Logout() {
|
|
|
1235
1229
|
};
|
|
1236
1230
|
|
|
1237
1231
|
var UserMenuRoles = function UserMenuRoles(_ref) {
|
|
1238
|
-
var
|
|
1232
|
+
var currentRole = _ref.currentRole,
|
|
1239
1233
|
onChangeRole = _ref.onChangeRole,
|
|
1240
|
-
|
|
1241
|
-
_ref$currentRole = _ref.currentRole,
|
|
1242
|
-
currentRole = _ref$currentRole === void 0 ? '' : _ref$currentRole;
|
|
1234
|
+
roles = _ref.roles;
|
|
1243
1235
|
var _useAuthenticationTra = useAuthenticationTranslation(),
|
|
1244
1236
|
t = _useAuthenticationTra.t;
|
|
1245
|
-
|
|
1246
|
-
|
|
1237
|
+
var handleChangeRole = function handleChangeRole(event) {
|
|
1238
|
+
var selectedRole = roles == null ? void 0 : roles.find(function (role) {
|
|
1239
|
+
return role.name === event.target.value;
|
|
1240
|
+
});
|
|
1241
|
+
if (selectedRole) {
|
|
1242
|
+
onChangeRole == null || onChangeRole(selectedRole);
|
|
1243
|
+
}
|
|
1244
|
+
};
|
|
1245
|
+
return jsxs(FormControl, {
|
|
1246
|
+
children: [jsx(FormLabel, {
|
|
1247
|
+
component: "legend",
|
|
1247
1248
|
sx: {
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1249
|
+
fontSize: 14,
|
|
1250
|
+
fontWeight: 400,
|
|
1251
|
+
color: 'geowebColors.typographyAndIcons.text',
|
|
1252
|
+
opacity: 1
|
|
1252
1253
|
},
|
|
1253
|
-
children:
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
sx: {
|
|
1261
|
-
fontSize: 14,
|
|
1262
|
-
fontWeight: 400,
|
|
1263
|
-
color: 'geowebColors.typographyAndIcons.text',
|
|
1264
|
-
opacity: 1
|
|
1265
|
-
},
|
|
1266
|
-
children: t('auth-role-title')
|
|
1267
|
-
}), roles == null ? void 0 : roles.map(function (role) {
|
|
1254
|
+
children: t('auth-role-title')
|
|
1255
|
+
}), jsx(RadioGroup, {
|
|
1256
|
+
"aria-labelledby": "user-menu-roles",
|
|
1257
|
+
name: "user-menu-roles",
|
|
1258
|
+
onChange: handleChangeRole,
|
|
1259
|
+
value: currentRole == null ? void 0 : currentRole.name,
|
|
1260
|
+
children: roles == null ? void 0 : roles.map(function (role) {
|
|
1268
1261
|
return jsx(FormControlLabel, {
|
|
1269
|
-
control: jsx(Radio, {
|
|
1270
|
-
checked: currentRole === role.name,
|
|
1271
|
-
disabled: isLoading
|
|
1272
|
-
}),
|
|
1262
|
+
control: jsx(Radio, {}),
|
|
1273
1263
|
label: t(role.title),
|
|
1274
|
-
|
|
1275
|
-
return onChangeRole(role);
|
|
1276
|
-
}
|
|
1264
|
+
value: role.name
|
|
1277
1265
|
}, role.name);
|
|
1278
|
-
})
|
|
1266
|
+
})
|
|
1279
1267
|
})]
|
|
1280
1268
|
});
|
|
1281
1269
|
};
|
|
1282
1270
|
|
|
1283
|
-
var UserMenuRolesConnect = function UserMenuRolesConnect(_ref) {
|
|
1284
|
-
var _ref$temporaryOnChang = _ref.temporaryOnChangeRoleForDemo,
|
|
1285
|
-
temporaryOnChangeRoleForDemo = _ref$temporaryOnChang === void 0 ? function () {} : _ref$temporaryOnChang,
|
|
1286
|
-
roles = _ref.roles,
|
|
1287
|
-
_ref$isAdmin = _ref.isAdmin,
|
|
1288
|
-
isAdmin = _ref$isAdmin === void 0 ? false : _ref$isAdmin;
|
|
1289
|
-
var defaultRole = isAdmin ? GEOWEB_ROLE_PRESETS_ADMIN.name : GEOWEB_ROLE_USER.name;
|
|
1290
|
-
var _React$useState = React.useState(false),
|
|
1291
|
-
isLoading = _React$useState[0],
|
|
1292
|
-
setIsLoading = _React$useState[1];
|
|
1293
|
-
var _React$useState2 = React.useState(defaultRole),
|
|
1294
|
-
currentRole = _React$useState2[0],
|
|
1295
|
-
setCurrentRole = _React$useState2[1];
|
|
1296
|
-
var dispatch = useDispatch();
|
|
1297
|
-
var _useAuthenticationTra = useAuthenticationTranslation(),
|
|
1298
|
-
t = _useAuthenticationTra.t;
|
|
1299
|
-
var onFakeRequest = /*#__PURE__*/function () {
|
|
1300
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
1301
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1302
|
-
while (1) switch (_context.prev = _context.next) {
|
|
1303
|
-
case 0:
|
|
1304
|
-
return _context.abrupt("return", new Promise(function (resolve) {
|
|
1305
|
-
setTimeout(function () {
|
|
1306
|
-
resolve();
|
|
1307
|
-
}, 300);
|
|
1308
|
-
}));
|
|
1309
|
-
case 1:
|
|
1310
|
-
case "end":
|
|
1311
|
-
return _context.stop();
|
|
1312
|
-
}
|
|
1313
|
-
}, _callee);
|
|
1314
|
-
}));
|
|
1315
|
-
return function onFakeRequest() {
|
|
1316
|
-
return _ref2.apply(this, arguments);
|
|
1317
|
-
};
|
|
1318
|
-
}();
|
|
1319
|
-
var onChangeRole = function onChangeRole(role) {
|
|
1320
|
-
setIsLoading(true);
|
|
1321
|
-
onFakeRequest().then(function () {
|
|
1322
|
-
setCurrentRole(role.name);
|
|
1323
|
-
temporaryOnChangeRoleForDemo(role);
|
|
1324
|
-
var message = {
|
|
1325
|
-
type: snackbarTypes.SnackbarMessageType.TRANSLATABLE_MESSAGE,
|
|
1326
|
-
key: 'auth-role-message-assigned',
|
|
1327
|
-
params: {
|
|
1328
|
-
role: t(role.title)
|
|
1329
|
-
}
|
|
1330
|
-
};
|
|
1331
|
-
dispatch(snackbarActions.openSnackbar(message));
|
|
1332
|
-
})["catch"](function () {})["finally"](function () {
|
|
1333
|
-
setIsLoading(false);
|
|
1334
|
-
});
|
|
1335
|
-
};
|
|
1336
|
-
return jsx(UserMenuRoles, {
|
|
1337
|
-
currentRole: currentRole,
|
|
1338
|
-
isLoading: isLoading,
|
|
1339
|
-
onChangeRole: onChangeRole,
|
|
1340
|
-
roles: roles
|
|
1341
|
-
});
|
|
1342
|
-
};
|
|
1343
|
-
|
|
1344
1271
|
var generateRandomId = function generateRandomId() {
|
|
1345
1272
|
return "-" + Math.random().toString(36).substring(2, 11);
|
|
1346
1273
|
};
|
|
@@ -1438,4 +1365,4 @@ params, callbacks) {
|
|
|
1438
1365
|
};
|
|
1439
1366
|
};
|
|
1440
1367
|
|
|
1441
|
-
export { AUTH_NAMESPACE, AuthenticationContext, AuthenticationProvider, HandleOAuth2Code as Code, GEOWEB_ROLE_PRESETS_ADMIN, GEOWEB_ROLE_USER, KEEP_ALIVE_POLLER_IN_SECONDS, OAuth2Login as Login, OAuth2Logout as Logout, MILLISECOND_TO_SECOND, REFRESH_TOKEN_WHEN_PCT_EXPIRED, UserMenuRoles,
|
|
1368
|
+
export { AUTH_NAMESPACE, AuthenticationContext, AuthenticationProvider, HandleOAuth2Code as Code, GEOWEB_ROLE_PRESETS_ADMIN, GEOWEB_ROLE_USER, KEEP_ALIVE_POLLER_IN_SECONDS, OAuth2Login as Login, OAuth2Logout as Logout, MILLISECOND_TO_SECOND, REFRESH_TOKEN_WHEN_PCT_EXPIRED, UserMenuRoles, apiTranslations, authTranslations, createApiInstance, createFakeApiInstance, createNonAuthApiInstance, fakeApiRequest, getAuthConfig, getCodeChallenge, getCurrentTimeInSeconds, getCurrentUrlLocation, getRandomString, groupsToRoles, makeCredentialsFromTokenResponse, refreshAccessToken, refreshAccessTokenAndSetAuthContext, setAuthChangeListener, useApi, useAuthenticationContext, useAuthenticationDefaultProps };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeoweb/authentication",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.3.0",
|
|
4
4
|
"description": "GeoWeb authentication library for the opengeoweb project",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -10,13 +10,10 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"axios": "^1.7.7",
|
|
12
12
|
"react-router-dom": "^6.23.1",
|
|
13
|
-
"@opengeoweb/shared": "15.
|
|
14
|
-
"@opengeoweb/theme": "15.
|
|
13
|
+
"@opengeoweb/shared": "15.3.0",
|
|
14
|
+
"@opengeoweb/theme": "15.3.0",
|
|
15
15
|
"i18next": "^25.0.1",
|
|
16
16
|
"react-i18next": "^15.1.1",
|
|
17
|
-
"@opengeoweb/snackbar": "15.2.0",
|
|
18
|
-
"react-redux": "^9.2.0",
|
|
19
|
-
"@reduxjs/toolkit": "^2.6.1",
|
|
20
17
|
"@mui/material": "^7.0.1"
|
|
21
18
|
},
|
|
22
19
|
"peerDependencies": {
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import type { Store } from '@reduxjs/toolkit';
|
|
2
1
|
import React from 'react';
|
|
3
2
|
interface AuthTranslationWrapperProps {
|
|
4
3
|
children?: React.ReactNode;
|
|
5
4
|
}
|
|
6
5
|
export declare const AuthI18nProvider: React.FC<AuthTranslationWrapperProps>;
|
|
7
6
|
export declare const DemoWrapper: React.FC<AuthTranslationWrapperProps>;
|
|
8
|
-
export declare const DemoWrapperConnect: React.FC<AuthTranslationWrapperProps & {
|
|
9
|
-
store: Store;
|
|
10
|
-
}>;
|
|
11
7
|
export {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { Role } from '../ApiContext/types';
|
|
3
3
|
export declare const UserMenuRoles: React.FC<{
|
|
4
|
+
currentRole?: Role;
|
|
5
|
+
onChangeRole?: (role: Role) => void;
|
|
4
6
|
roles?: Role[];
|
|
5
|
-
currentRole?: string;
|
|
6
|
-
onChangeRole: (role: Role) => void;
|
|
7
|
-
isLoading: boolean;
|
|
8
7
|
}>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { StoryObj } from '@storybook/react-webpack5';
|
|
2
|
-
import { UserMenuRolesConnect } from './UserMenuRolesConnect';
|
|
3
|
-
type Story = StoryObj<typeof UserMenuRolesConnect>;
|
|
4
|
-
declare const _default: {
|
|
5
|
-
title: string;
|
|
6
|
-
};
|
|
7
|
-
export default _default;
|
|
8
|
-
export declare const AuthenticationDemo: Story;
|