@opengeoweb/authentication 14.1.0 → 14.2.1
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 +88 -82
- package/package.json +4 -4
- package/src/index.d.ts +1 -1
- package/src/lib/components/ApiContext/ApiContext.d.ts +2 -2
- package/src/lib/components/ApiContext/index.d.ts +1 -1
- package/src/lib/components/ApiContext/types.d.ts +1 -1
- package/src/lib/components/AuthenticationContext/AuthenticationRenderTestComponent.d.ts +2 -2
- package/src/lib/components/Providers/Providers.d.ts +1 -1
- package/src/lib/components/apiHooks/useApi.d.ts +1 -1
- package/src/lib/utils/i18n.d.ts +1 -1
package/index.esm.js
CHANGED
|
@@ -1,41 +1,32 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
-
import * as React from 'react';
|
|
3
|
-
import React__default, { useRef, useEffect } from 'react';
|
|
4
2
|
import axios from 'axios';
|
|
3
|
+
import React, { useRef, useEffect, useState } from 'react';
|
|
5
4
|
import { Navigate, Link } from 'react-router-dom';
|
|
6
5
|
import { sessionStorageProvider, useIsMounted, SHARED_NAMESPACE, AlertBanner, useDebounce } from '@opengeoweb/shared';
|
|
7
|
-
import { ThemeWrapper } from '@opengeoweb/theme';
|
|
8
6
|
import { useTranslation, Trans } from 'react-i18next';
|
|
7
|
+
import { ThemeWrapper } from '@opengeoweb/theme';
|
|
9
8
|
import 'i18next';
|
|
10
9
|
import { Box, LinearProgress, FormGroup, FormLabel, FormControlLabel, Radio } from '@mui/material';
|
|
11
10
|
import { useDispatch } from 'react-redux';
|
|
12
11
|
import { snackbarTypes, snackbarActions } from '@opengeoweb/snackbar';
|
|
13
12
|
|
|
14
13
|
var en$1 = {
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"auth-role-title": "Role",
|
|
18
|
-
"auth-role-message-assigned": "Role {{role}} has been assigned"
|
|
14
|
+
"api-role-title-user": "User",
|
|
15
|
+
"api-role-title-preset-admin": "Preset-admin"
|
|
19
16
|
};
|
|
20
17
|
var fi$1 = {
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"auth-role-title": "Rooli",
|
|
24
|
-
"auth-role-message-assigned": "Rooli {{role}} on annettu"
|
|
18
|
+
"api-role-title-user": "Käyttäjä",
|
|
19
|
+
"api-role-title-preset-admin": "Preset-pääkäyttäjä"
|
|
25
20
|
};
|
|
26
21
|
var no$1 = {
|
|
27
|
-
"
|
|
28
|
-
"
|
|
29
|
-
"auth-role-title": "Rolle",
|
|
30
|
-
"auth-role-message-assigned": "Rolle {{role}} har blitt tildelt"
|
|
22
|
+
"api-role-title-user": "Bruker",
|
|
23
|
+
"api-role-title-preset-admin": "Preset-admin"
|
|
31
24
|
};
|
|
32
25
|
var nl$1 = {
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"auth-role-title": "Rol",
|
|
36
|
-
"auth-role-message-assigned": "Rol {{role}} is geactiveerd"
|
|
26
|
+
"api-role-title-user": "Gebruiker",
|
|
27
|
+
"api-role-title-preset-admin": "Preset-beheerder"
|
|
37
28
|
};
|
|
38
|
-
var
|
|
29
|
+
var apiTranslations = {
|
|
39
30
|
en: en$1,
|
|
40
31
|
fi: fi$1,
|
|
41
32
|
no: no$1,
|
|
@@ -43,22 +34,30 @@ var authTranslations = {
|
|
|
43
34
|
};
|
|
44
35
|
|
|
45
36
|
var en = {
|
|
46
|
-
"
|
|
47
|
-
"
|
|
37
|
+
"auth-logout-go-back-to-home-page": "Go back to the <1>Home Page</1>",
|
|
38
|
+
"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"
|
|
48
41
|
};
|
|
49
42
|
var fi = {
|
|
50
|
-
"
|
|
51
|
-
"
|
|
43
|
+
"auth-logout-go-back-to-home-page": "Palaa takaisin <1>Kotisivulle</1>",
|
|
44
|
+
"auth-logout-you-are-logged-out": "Olet kirjautunut ulos.",
|
|
45
|
+
"auth-role-title": "Rooli",
|
|
46
|
+
"auth-role-message-assigned": "Rooli {{role}} on annettu"
|
|
52
47
|
};
|
|
53
48
|
var no = {
|
|
54
|
-
"
|
|
55
|
-
"
|
|
49
|
+
"auth-logout-go-back-to-home-page": "Gå tilbake til <1>Hjemmesiden</1>",
|
|
50
|
+
"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"
|
|
56
53
|
};
|
|
57
54
|
var nl = {
|
|
58
|
-
"
|
|
59
|
-
"
|
|
55
|
+
"auth-logout-go-back-to-home-page": "Ga terug naar de <1>Startpagina</1>",
|
|
56
|
+
"auth-logout-you-are-logged-out": "Je bent uitgelogd.",
|
|
57
|
+
"auth-role-title": "Rol",
|
|
58
|
+
"auth-role-message-assigned": "Rol {{role}} is geactiveerd"
|
|
60
59
|
};
|
|
61
|
-
var
|
|
60
|
+
var authTranslations = {
|
|
62
61
|
en: en,
|
|
63
62
|
fi: fi,
|
|
64
63
|
no: no,
|
|
@@ -824,7 +823,7 @@ var getAuthConfig = function getAuthConfig(_configUrls) {
|
|
|
824
823
|
GW_AUTH_ROLE_CLAIM_VALUE_PRESETS_ADMIN: GW_AUTH_ROLE_CLAIM_VALUE_PRESETS_ADMIN
|
|
825
824
|
};
|
|
826
825
|
};
|
|
827
|
-
var AuthenticationContext = /*#__PURE__*/
|
|
826
|
+
var AuthenticationContext = /*#__PURE__*/React.createContext({
|
|
828
827
|
isLoggedIn: null,
|
|
829
828
|
onLogin: null,
|
|
830
829
|
auth: null,
|
|
@@ -839,10 +838,10 @@ var setAuthChangeListener = function setAuthChangeListener(listener) {
|
|
|
839
838
|
};
|
|
840
839
|
var useAuthenticationDefaultProps = function useAuthenticationDefaultProps() {
|
|
841
840
|
var _auth$roles$, _auth$roles;
|
|
842
|
-
var _React$useState =
|
|
841
|
+
var _React$useState = React.useState(false),
|
|
843
842
|
isLoggedIn = _React$useState[0],
|
|
844
843
|
setIsLoggedIn = _React$useState[1];
|
|
845
|
-
var _React$useState2 =
|
|
844
|
+
var _React$useState2 = React.useState(false),
|
|
846
845
|
hasConnectionIssue = _React$useState2[0],
|
|
847
846
|
setHasConnectionIssue = _React$useState2[1];
|
|
848
847
|
var emptyCredentials = {
|
|
@@ -853,24 +852,29 @@ var useAuthenticationDefaultProps = function useAuthenticationDefaultProps() {
|
|
|
853
852
|
expires_at: 0,
|
|
854
853
|
has_connection_issue: false
|
|
855
854
|
};
|
|
856
|
-
var _React$useState3 =
|
|
855
|
+
var _React$useState3 = React.useState(Object.assign({}, emptyCredentials)),
|
|
857
856
|
auth = _React$useState3[0],
|
|
858
857
|
setAuth = _React$useState3[1];
|
|
859
|
-
|
|
858
|
+
// TODO clean this up.
|
|
859
|
+
// hotfix revert to ref. There are parts of the state down the tree that rely on ref to work.
|
|
860
|
+
var authRef = React.useRef(auth).current;
|
|
861
|
+
var onSetAuth = React.useCallback(function (newAuth) {
|
|
860
862
|
if (newAuth) {
|
|
861
863
|
setAuth(function (prevAuth) {
|
|
862
864
|
return Object.assign({}, prevAuth, newAuth);
|
|
863
865
|
});
|
|
866
|
+
Object.assign(authRef, newAuth);
|
|
864
867
|
if (newAuth.has_connection_issue !== undefined && hasConnectionIssue !== newAuth.has_connection_issue) {
|
|
865
868
|
setHasConnectionIssue(newAuth.has_connection_issue);
|
|
866
869
|
}
|
|
867
870
|
} else {
|
|
868
871
|
setAuth(Object.assign({}, emptyCredentials));
|
|
872
|
+
Object.assign(authRef, Object.assign({}, emptyCredentials));
|
|
869
873
|
}
|
|
870
874
|
},
|
|
871
875
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
872
876
|
[hasConnectionIssue]);
|
|
873
|
-
var _React$useState4 =
|
|
877
|
+
var _React$useState4 = React.useState((_auth$roles$ = (_auth$roles = auth.roles) == null ? void 0 : _auth$roles[0]) != null ? _auth$roles$ : GEOWEB_ROLE_USER),
|
|
874
878
|
currentRole = _React$useState4[0],
|
|
875
879
|
setCurrentRole = _React$useState4[1];
|
|
876
880
|
useEffect(function () {
|
|
@@ -879,7 +883,7 @@ var useAuthenticationDefaultProps = function useAuthenticationDefaultProps() {
|
|
|
879
883
|
return {
|
|
880
884
|
isLoggedIn: isLoggedIn,
|
|
881
885
|
onLogin: setIsLoggedIn,
|
|
882
|
-
auth: isLoggedIn ?
|
|
886
|
+
auth: isLoggedIn ? authRef : null,
|
|
883
887
|
onSetAuth: onSetAuth,
|
|
884
888
|
sessionStorageProvider: sessionStorageProvider,
|
|
885
889
|
currentRole: currentRole,
|
|
@@ -903,7 +907,7 @@ var AuthenticationProvider = function AuthenticationProvider(_ref2) {
|
|
|
903
907
|
var authConfig = configURLS;
|
|
904
908
|
// Checks the token expiration time regularly and renews it before it expires.
|
|
905
909
|
var interval = useRef();
|
|
906
|
-
|
|
910
|
+
React.useEffect(function () {
|
|
907
911
|
interval.current = setInterval(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
908
912
|
var currentTime, timeInSecondsLeftBeforeExpiration;
|
|
909
913
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
@@ -915,7 +919,7 @@ var AuthenticationProvider = function AuthenticationProvider(_ref2) {
|
|
|
915
919
|
}
|
|
916
920
|
currentTime = getCurrentTimeInSeconds();
|
|
917
921
|
timeInSecondsLeftBeforeExpiration = auth.expires_at ? auth.expires_at - currentTime : 0;
|
|
918
|
-
if (!(timeInSecondsLeftBeforeExpiration <
|
|
922
|
+
if (!(timeInSecondsLeftBeforeExpiration < 60)) {
|
|
919
923
|
_context2.next = 6;
|
|
920
924
|
break;
|
|
921
925
|
}
|
|
@@ -942,7 +946,7 @@ var AuthenticationProvider = function AuthenticationProvider(_ref2) {
|
|
|
942
946
|
clearInterval(interval.current);
|
|
943
947
|
};
|
|
944
948
|
}, [auth, configURLS.GW_APP_URL, configURLS.GW_AUTH_CLIENT_ID, configURLS.GW_AUTH_TOKEN_URL, onSetAuth, configURLS, onLogin]);
|
|
945
|
-
var contextValue =
|
|
949
|
+
var contextValue = React.useMemo(function () {
|
|
946
950
|
return {
|
|
947
951
|
isLoggedIn: isLoggedIn,
|
|
948
952
|
onLogin: onLogin,
|
|
@@ -960,7 +964,7 @@ var AuthenticationProvider = function AuthenticationProvider(_ref2) {
|
|
|
960
964
|
});
|
|
961
965
|
};
|
|
962
966
|
var useAuthenticationContext = function useAuthenticationContext() {
|
|
963
|
-
return
|
|
967
|
+
return React.useContext(AuthenticationContext);
|
|
964
968
|
};
|
|
965
969
|
|
|
966
970
|
var axiosInstance = axios.create({
|
|
@@ -973,13 +977,13 @@ var HandleOAuth2Code = function HandleOAuth2Code() {
|
|
|
973
977
|
isLoggedIn = _useAuthenticationCon.isLoggedIn,
|
|
974
978
|
onLogin = _useAuthenticationCon.onLogin,
|
|
975
979
|
sessionStorageProvider = _useAuthenticationCon.sessionStorageProvider;
|
|
976
|
-
var _React$useState =
|
|
980
|
+
var _React$useState = React.useState(null),
|
|
977
981
|
error = _React$useState[0],
|
|
978
982
|
setError = _React$useState[1];
|
|
979
983
|
var _useIsMounted = useIsMounted(),
|
|
980
984
|
isMounted = _useIsMounted.isMounted;
|
|
981
|
-
var loginInProgress =
|
|
982
|
-
var authenticate =
|
|
985
|
+
var loginInProgress = React.useRef(false);
|
|
986
|
+
var authenticate = React.useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
983
987
|
var _Object$fromEntries, code, state, isStateRequired, isPkceRequired, payload, useDefaultContentType, data, config, res, newAuth;
|
|
984
988
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
985
989
|
while (1) switch (_context.prev = _context.next) {
|
|
@@ -1061,9 +1065,10 @@ var HandleOAuth2Code = function HandleOAuth2Code() {
|
|
|
1061
1065
|
if (isMounted.current) {
|
|
1062
1066
|
if (_context.t0 instanceof Error) {
|
|
1063
1067
|
setError(function () {
|
|
1068
|
+
var _error$stack;
|
|
1064
1069
|
return {
|
|
1065
1070
|
message: _context.t0.message,
|
|
1066
|
-
stack: _context.t0.stack
|
|
1071
|
+
stack: (_error$stack = _context.t0.stack) != null ? _error$stack : 'Error in HandleOAuth2Code'
|
|
1067
1072
|
};
|
|
1068
1073
|
});
|
|
1069
1074
|
}
|
|
@@ -1080,7 +1085,7 @@ var HandleOAuth2Code = function HandleOAuth2Code() {
|
|
|
1080
1085
|
}
|
|
1081
1086
|
}, _callee, null, [[15, 23]]);
|
|
1082
1087
|
})), [authConfig, isMounted, onLogin, onSetAuth, sessionStorageProvider]);
|
|
1083
|
-
|
|
1088
|
+
React.useEffect(function () {
|
|
1084
1089
|
var authenticateWithLock = /*#__PURE__*/function () {
|
|
1085
1090
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
1086
1091
|
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
@@ -1111,17 +1116,17 @@ var HandleOAuth2Code = function HandleOAuth2Code() {
|
|
|
1111
1116
|
}, [authenticate, isLoggedIn]);
|
|
1112
1117
|
return jsxs(Fragment, {
|
|
1113
1118
|
children: [error ? jsx(Navigate, {
|
|
1114
|
-
|
|
1119
|
+
replace: true,
|
|
1115
1120
|
state: {
|
|
1116
1121
|
error: {
|
|
1117
1122
|
message: error.message,
|
|
1118
1123
|
stack: error.stack
|
|
1119
1124
|
}
|
|
1120
1125
|
},
|
|
1121
|
-
|
|
1126
|
+
to: "/error"
|
|
1122
1127
|
}) : null, isLoggedIn ? jsx(Navigate, {
|
|
1123
|
-
|
|
1124
|
-
|
|
1128
|
+
replace: true,
|
|
1129
|
+
to: sessionStorageProvider.getCallbackUrl()
|
|
1125
1130
|
}) : null]
|
|
1126
1131
|
});
|
|
1127
1132
|
};
|
|
@@ -1167,7 +1172,7 @@ var getCurrentUrlLocation = function getCurrentUrlLocation(url, appUrl) {
|
|
|
1167
1172
|
var OAuth2Login = function OAuth2Login() {
|
|
1168
1173
|
var _useAuthenticationCon = useAuthenticationContext(),
|
|
1169
1174
|
authConfig = _useAuthenticationCon.authConfig;
|
|
1170
|
-
|
|
1175
|
+
React.useEffect(function () {
|
|
1171
1176
|
var callbackUrl = getCurrentUrlLocation(sessionStorageProvider.getCallbackUrl(), authConfig.GW_APP_URL);
|
|
1172
1177
|
sessionStorageProvider.setCallbackUrl(callbackUrl);
|
|
1173
1178
|
window.location.assign(authConfig.GW_AUTH_LOGIN_URL);
|
|
@@ -1206,12 +1211,12 @@ var OAuth2Logout = function OAuth2Logout() {
|
|
|
1206
1211
|
isLoggedIn = _useAuthenticationCon.isLoggedIn,
|
|
1207
1212
|
onLogin = _useAuthenticationCon.onLogin,
|
|
1208
1213
|
sessionStorageProvider = _useAuthenticationCon.sessionStorageProvider;
|
|
1209
|
-
var _React$useState =
|
|
1214
|
+
var _React$useState = React.useState(true),
|
|
1210
1215
|
showAlert = _React$useState[0],
|
|
1211
1216
|
setShowAlert = _React$useState[1];
|
|
1212
1217
|
var _useAuthenticationTra = useAuthenticationTranslation(),
|
|
1213
1218
|
t = _useAuthenticationTra.t;
|
|
1214
|
-
|
|
1219
|
+
React.useEffect(function () {
|
|
1215
1220
|
if (isLoggedIn) {
|
|
1216
1221
|
setShowAlert(false);
|
|
1217
1222
|
onSetAuth(null);
|
|
@@ -1222,8 +1227,6 @@ var OAuth2Logout = function OAuth2Logout() {
|
|
|
1222
1227
|
}, [isLoggedIn, onSetAuth, onLogin, sessionStorageProvider, authConfig.GW_AUTH_LOGOUT_URL]);
|
|
1223
1228
|
return showAlert ? jsx(ThemeWrapper, {
|
|
1224
1229
|
children: jsx(AlertBanner, {
|
|
1225
|
-
severity: "info",
|
|
1226
|
-
title: t('auth-logout-you-are-logged-out'),
|
|
1227
1230
|
info: jsx("p", {
|
|
1228
1231
|
children: jsxs(Trans, {
|
|
1229
1232
|
i18nKey: "auth-logout-go-back-to-home-page",
|
|
@@ -1233,7 +1236,9 @@ var OAuth2Logout = function OAuth2Logout() {
|
|
|
1233
1236
|
children: "Home Page"
|
|
1234
1237
|
})]
|
|
1235
1238
|
})
|
|
1236
|
-
})
|
|
1239
|
+
}),
|
|
1240
|
+
severity: "info",
|
|
1241
|
+
title: t('auth-logout-you-are-logged-out')
|
|
1237
1242
|
})
|
|
1238
1243
|
}) : null;
|
|
1239
1244
|
};
|
|
@@ -1255,8 +1260,8 @@ var UserMenuRoles = function UserMenuRoles(_ref) {
|
|
|
1255
1260
|
right: 0
|
|
1256
1261
|
},
|
|
1257
1262
|
children: jsx(LinearProgress, {
|
|
1258
|
-
|
|
1259
|
-
|
|
1263
|
+
color: "secondary",
|
|
1264
|
+
"data-testid": "loading-bar"
|
|
1260
1265
|
})
|
|
1261
1266
|
}) : null, jsxs(FormGroup, {
|
|
1262
1267
|
children: [jsx(FormLabel, {
|
|
@@ -1271,8 +1276,8 @@ var UserMenuRoles = function UserMenuRoles(_ref) {
|
|
|
1271
1276
|
}), roles == null ? void 0 : roles.map(function (role) {
|
|
1272
1277
|
return jsx(FormControlLabel, {
|
|
1273
1278
|
control: jsx(Radio, {
|
|
1274
|
-
|
|
1275
|
-
|
|
1279
|
+
checked: currentRole === role.name,
|
|
1280
|
+
disabled: isLoading
|
|
1276
1281
|
}),
|
|
1277
1282
|
label: t(role.title),
|
|
1278
1283
|
onChange: function onChange() {
|
|
@@ -1291,10 +1296,10 @@ var UserMenuRolesConnect = function UserMenuRolesConnect(_ref) {
|
|
|
1291
1296
|
_ref$isAdmin = _ref.isAdmin,
|
|
1292
1297
|
isAdmin = _ref$isAdmin === void 0 ? false : _ref$isAdmin;
|
|
1293
1298
|
var defaultRole = isAdmin ? GEOWEB_ROLE_PRESETS_ADMIN.name : GEOWEB_ROLE_USER.name;
|
|
1294
|
-
var _React$useState =
|
|
1299
|
+
var _React$useState = React.useState(false),
|
|
1295
1300
|
isLoading = _React$useState[0],
|
|
1296
1301
|
setIsLoading = _React$useState[1];
|
|
1297
|
-
var _React$useState2 =
|
|
1302
|
+
var _React$useState2 = React.useState(defaultRole),
|
|
1298
1303
|
currentRole = _React$useState2[0],
|
|
1299
1304
|
setCurrentRole = _React$useState2[1];
|
|
1300
1305
|
var dispatch = useDispatch();
|
|
@@ -1338,10 +1343,10 @@ var UserMenuRolesConnect = function UserMenuRolesConnect(_ref) {
|
|
|
1338
1343
|
});
|
|
1339
1344
|
};
|
|
1340
1345
|
return jsx(UserMenuRoles, {
|
|
1341
|
-
onChangeRole: onChangeRole,
|
|
1342
|
-
roles: roles,
|
|
1343
1346
|
currentRole: currentRole,
|
|
1344
|
-
isLoading: isLoading
|
|
1347
|
+
isLoading: isLoading,
|
|
1348
|
+
onChangeRole: onChangeRole,
|
|
1349
|
+
roles: roles
|
|
1345
1350
|
});
|
|
1346
1351
|
};
|
|
1347
1352
|
|
|
@@ -1362,7 +1367,7 @@ var ApiProvider = function ApiProvider(_ref) {
|
|
|
1362
1367
|
name = _ref.name,
|
|
1363
1368
|
apiModuleProps = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
1364
1369
|
var handleNewApi = React.useCallback(function () {
|
|
1365
|
-
var newApi = createApi
|
|
1370
|
+
var newApi = createApi(apiModuleProps);
|
|
1366
1371
|
if (name) {
|
|
1367
1372
|
registerApi(name, newApi);
|
|
1368
1373
|
}
|
|
@@ -1397,24 +1402,25 @@ var generateRandomId = function generateRandomId() {
|
|
|
1397
1402
|
var useApi = function useApi(
|
|
1398
1403
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1399
1404
|
apiCall,
|
|
1400
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1405
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
|
|
1401
1406
|
params, callbacks) {
|
|
1402
1407
|
var _useIsMounted = useIsMounted(),
|
|
1403
1408
|
isMounted = _useIsMounted.isMounted;
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1409
|
+
// eslint-disable-next-line react/hook-use-state
|
|
1410
|
+
var _useState = useState(generateRandomId()),
|
|
1411
|
+
id = _useState[0];
|
|
1412
|
+
var _useState2 = useState(true),
|
|
1413
|
+
isLoading = _useState2[0],
|
|
1414
|
+
setIsLoading = _useState2[1];
|
|
1415
|
+
var _useState3 = useState(null),
|
|
1416
|
+
error = _useState3[0],
|
|
1417
|
+
setError = _useState3[1];
|
|
1418
|
+
var _useState4 = useState(null),
|
|
1419
|
+
result = _useState4[0],
|
|
1420
|
+
setResult = _useState4[1];
|
|
1415
1421
|
var debouncedParams = useDebounce(JSON.stringify(params), 300);
|
|
1416
1422
|
// trick so that we don't have to include this in the useEffect dependency array (as it is likely that callbacks changes on every render)
|
|
1417
|
-
var callbacksRef =
|
|
1423
|
+
var callbacksRef = useRef();
|
|
1418
1424
|
callbacksRef.current = callbacks;
|
|
1419
1425
|
var handleError = function handleError(newError) {
|
|
1420
1426
|
if (isMounted.current) {
|
|
@@ -1431,7 +1437,7 @@ params, callbacks) {
|
|
|
1431
1437
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
1432
1438
|
while (1) switch (_context.prev = _context.next) {
|
|
1433
1439
|
case 0:
|
|
1434
|
-
|
|
1440
|
+
setIsLoading(true);
|
|
1435
1441
|
setError(null);
|
|
1436
1442
|
_context.prev = 2;
|
|
1437
1443
|
_context.next = 5;
|
|
@@ -1455,7 +1461,7 @@ params, callbacks) {
|
|
|
1455
1461
|
}
|
|
1456
1462
|
case 12:
|
|
1457
1463
|
_context.prev = 12;
|
|
1458
|
-
|
|
1464
|
+
setIsLoading(false);
|
|
1459
1465
|
return _context.finish(12);
|
|
1460
1466
|
case 15:
|
|
1461
1467
|
case "end":
|
|
@@ -1467,7 +1473,7 @@ params, callbacks) {
|
|
|
1467
1473
|
return _ref.apply(this, arguments);
|
|
1468
1474
|
};
|
|
1469
1475
|
}();
|
|
1470
|
-
|
|
1476
|
+
useEffect(function () {
|
|
1471
1477
|
fetchApiData(params)["catch"](function (newError) {
|
|
1472
1478
|
handleError(newError);
|
|
1473
1479
|
});
|
|
@@ -1475,7 +1481,7 @@ params, callbacks) {
|
|
|
1475
1481
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1476
1482
|
[debouncedParams]);
|
|
1477
1483
|
var clearResults = function clearResults() {
|
|
1478
|
-
|
|
1484
|
+
setIsLoading(true);
|
|
1479
1485
|
setResult(null);
|
|
1480
1486
|
};
|
|
1481
1487
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeoweb/authentication",
|
|
3
|
-
"version": "14.1
|
|
3
|
+
"version": "14.2.1",
|
|
4
4
|
"description": "GeoWeb authentication library for the opengeoweb project",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -10,11 +10,11 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"axios": "^1.7.7",
|
|
12
12
|
"react-router-dom": "^6.23.1",
|
|
13
|
-
"@opengeoweb/shared": "14.1
|
|
14
|
-
"@opengeoweb/theme": "14.1
|
|
13
|
+
"@opengeoweb/shared": "14.2.1",
|
|
14
|
+
"@opengeoweb/theme": "14.2.1",
|
|
15
15
|
"i18next": "^25.0.1",
|
|
16
16
|
"react-i18next": "^15.1.1",
|
|
17
|
-
"@opengeoweb/snackbar": "14.1
|
|
17
|
+
"@opengeoweb/snackbar": "14.2.1",
|
|
18
18
|
"react-redux": "^9.2.0",
|
|
19
19
|
"@reduxjs/toolkit": "^2.6.1",
|
|
20
20
|
"@mui/material": "^7.0.1"
|
package/src/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import authTranslations from '../locales/authentication.json';
|
|
2
1
|
import apiTranslations from '../locales/api.json';
|
|
2
|
+
import authTranslations from '../locales/authentication.json';
|
|
3
3
|
export { default as Code } from './lib/components/pages/Code';
|
|
4
4
|
export { default as Login } from './lib/components/pages/Login';
|
|
5
5
|
export { default as Logout } from './lib/components/pages/Logout';
|
|
@@ -28,7 +28,7 @@ export interface ApiModule {
|
|
|
28
28
|
export interface CreateApiProps extends ApiModule {
|
|
29
29
|
timeout?: number;
|
|
30
30
|
}
|
|
31
|
-
export type CreateApiFn = (props: CreateApiProps) =>
|
|
31
|
+
export type CreateApiFn = (props: CreateApiProps) => unknown;
|
|
32
32
|
export interface Role {
|
|
33
33
|
name: string;
|
|
34
34
|
title: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { Credentials } from '../ApiContext/types';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { Credentials } from '../ApiContext/types';
|
|
3
3
|
interface AuthenticationRenderTestComponentProps {
|
|
4
4
|
auth: Credentials | null;
|
|
5
5
|
newAuth: Credentials;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ConfigType } from '@opengeoweb/shared';
|
|
1
|
+
import type { ConfigType } from '@opengeoweb/shared';
|
|
2
2
|
export type ApiParams = string | ConfigType | Record<string, string | undefined> | null;
|
|
3
3
|
interface BaseApiHookProps {
|
|
4
4
|
fetchApiData?: (params: ApiParams) => Promise<void>;
|
package/src/lib/utils/i18n.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import i18n from 'i18next';
|
|
2
|
-
import { UseTranslationResponse } from 'react-i18next';
|
|
2
|
+
import type { UseTranslationResponse } from 'react-i18next';
|
|
3
3
|
export declare const AUTH_NAMESPACE = "auth";
|
|
4
4
|
export declare const initAuthTestI18n: () => void;
|
|
5
5
|
export declare const useAuthenticationTranslation: () => UseTranslationResponse<typeof AUTH_NAMESPACE, typeof i18n>;
|