@opengeoweb/authentication 9.19.1 → 9.20.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
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
1
2
|
import React, { useRef } from 'react';
|
|
2
3
|
import axios from 'axios';
|
|
3
4
|
import { Navigate, useLocation, Link } from 'react-router-dom';
|
|
4
5
|
import { useIsMounted, AlertBanner } from '@opengeoweb/shared';
|
|
5
|
-
import { KEEP_ALIVE_POLLER_IN_SECONDS, MILLISECOND_TO_SECOND, getCurrentTimeInSeconds, refreshAccessTokenAndSetAuthContext, makeCredentialsFromTokenResponse, GEOWEB_ROLE_USER } from '@opengeoweb/api';
|
|
6
|
+
import { KEEP_ALIVE_POLLER_IN_SECONDS, MILLISECOND_TO_SECOND, getCurrentTimeInSeconds, refreshAccessTokenAndSetAuthContext, makeCredentialsFromTokenResponse, GEOWEB_ROLE_PRESETS_ADMIN, GEOWEB_ROLE_USER } from '@opengeoweb/api';
|
|
6
7
|
import { ThemeWrapper } from '@opengeoweb/theme';
|
|
7
8
|
import { useTranslation, Trans } from 'react-i18next';
|
|
8
9
|
import 'i18next';
|
|
@@ -362,7 +363,9 @@ var store$3 = sharedStore.exports = globalThis$1[SHARED] || defineGlobalProperty
|
|
|
362
363
|
source: 'https://github.com/zloirock/core-js'
|
|
363
364
|
});
|
|
364
365
|
|
|
365
|
-
var
|
|
366
|
+
var sharedStoreExports = sharedStore.exports;
|
|
367
|
+
|
|
368
|
+
var store$2 = sharedStoreExports;
|
|
366
369
|
|
|
367
370
|
var shared$4 = function (key, value) {
|
|
368
371
|
return store$2[key] || (store$2[key] = value || {});
|
|
@@ -604,7 +607,7 @@ var functionName = {
|
|
|
604
607
|
|
|
605
608
|
var uncurryThis$s = functionUncurryThis;
|
|
606
609
|
var isCallable$i = isCallable$o;
|
|
607
|
-
var store$1 =
|
|
610
|
+
var store$1 = sharedStoreExports;
|
|
608
611
|
|
|
609
612
|
var functionToString = uncurryThis$s(Function.toString);
|
|
610
613
|
|
|
@@ -640,7 +643,7 @@ var global$q = global$y;
|
|
|
640
643
|
var isObject$c = isObject$h;
|
|
641
644
|
var createNonEnumerableProperty$7 = createNonEnumerableProperty$8;
|
|
642
645
|
var hasOwn$c = hasOwnProperty_1;
|
|
643
|
-
var shared$1 =
|
|
646
|
+
var shared$1 = sharedStoreExports;
|
|
644
647
|
var sharedKey$2 = sharedKey$3;
|
|
645
648
|
var hiddenKeys$3 = hiddenKeys$4;
|
|
646
649
|
|
|
@@ -761,9 +764,11 @@ Function.prototype.toString = makeBuiltIn$2(function toString() {
|
|
|
761
764
|
return isCallable$g(this) && getInternalState$5(this).source || inspectSource$2(this);
|
|
762
765
|
}, 'toString');
|
|
763
766
|
|
|
767
|
+
var makeBuiltInExports = makeBuiltIn$3.exports;
|
|
768
|
+
|
|
764
769
|
var isCallable$f = isCallable$o;
|
|
765
770
|
var definePropertyModule$4 = objectDefineProperty;
|
|
766
|
-
var makeBuiltIn$1 =
|
|
771
|
+
var makeBuiltIn$1 = makeBuiltInExports;
|
|
767
772
|
var defineGlobalProperty$1 = defineGlobalProperty$3;
|
|
768
773
|
|
|
769
774
|
var defineBuiltIn$d = function (O, key, value, options) {
|
|
@@ -2364,7 +2369,7 @@ var urlConstructorDetection = !fails$f(function () {
|
|
|
2364
2369
|
|| new URL('http://x', undefined).host !== 'x';
|
|
2365
2370
|
});
|
|
2366
2371
|
|
|
2367
|
-
var makeBuiltIn =
|
|
2372
|
+
var makeBuiltIn = makeBuiltInExports;
|
|
2368
2373
|
var defineProperty$2 = objectDefineProperty;
|
|
2369
2374
|
|
|
2370
2375
|
var defineBuiltInAccessor$8 = function (target, name, descriptor) {
|
|
@@ -2965,6 +2970,8 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
2965
2970
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
2966
2971
|
PERFORMANCE OF THIS SOFTWARE.
|
|
2967
2972
|
***************************************************************************** */
|
|
2973
|
+
/* global Reflect, Promise, SuppressedError, Symbol */
|
|
2974
|
+
|
|
2968
2975
|
|
|
2969
2976
|
function __awaiter(thisArg, _arguments, P, generator) {
|
|
2970
2977
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -4771,7 +4778,9 @@ if (DESCRIPTORS$3) {
|
|
|
4771
4778
|
};
|
|
4772
4779
|
} else typedArrayConstructor.exports = function () { /* empty */ };
|
|
4773
4780
|
|
|
4774
|
-
var
|
|
4781
|
+
var typedArrayConstructorExports = typedArrayConstructor.exports;
|
|
4782
|
+
|
|
4783
|
+
var createTypedArrayConstructor$1 = typedArrayConstructorExports;
|
|
4775
4784
|
|
|
4776
4785
|
// `Uint8Array` constructor
|
|
4777
4786
|
// https://tc39.es/ecma262/#sec-typedarray-objects
|
|
@@ -4781,7 +4790,7 @@ createTypedArrayConstructor$1('Uint8', function (init) {
|
|
|
4781
4790
|
};
|
|
4782
4791
|
});
|
|
4783
4792
|
|
|
4784
|
-
var createTypedArrayConstructor =
|
|
4793
|
+
var createTypedArrayConstructor = typedArrayConstructorExports;
|
|
4785
4794
|
|
|
4786
4795
|
// `Uint32Array` constructor
|
|
4787
4796
|
// https://tc39.es/ecma262/#sec-typedarray-objects
|
|
@@ -5703,9 +5712,11 @@ const AuthenticationProvider = ({
|
|
|
5703
5712
|
authConfig,
|
|
5704
5713
|
sessionStorageProvider
|
|
5705
5714
|
}), [isLoggedIn, onLogin, auth, onSetAuth, authConfig, sessionStorageProvider]);
|
|
5706
|
-
return
|
|
5715
|
+
return jsx(AuthenticationContext.Provider, Object.assign({
|
|
5707
5716
|
value: contextValue
|
|
5708
|
-
},
|
|
5717
|
+
}, {
|
|
5718
|
+
children: children
|
|
5719
|
+
}));
|
|
5709
5720
|
};
|
|
5710
5721
|
const useAuthenticationContext = () => React.useContext(AuthenticationContext);
|
|
5711
5722
|
|
|
@@ -5802,19 +5813,21 @@ const HandleOAuth2Code = () => {
|
|
|
5802
5813
|
});
|
|
5803
5814
|
authenticateWithLock();
|
|
5804
5815
|
}, [authenticate, isLoggedIn]);
|
|
5805
|
-
return
|
|
5806
|
-
|
|
5807
|
-
|
|
5808
|
-
|
|
5809
|
-
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
|
|
5814
|
-
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5816
|
+
return jsxs(Fragment, {
|
|
5817
|
+
children: [error ? jsx(Navigate, {
|
|
5818
|
+
to: "/error",
|
|
5819
|
+
state: {
|
|
5820
|
+
error: {
|
|
5821
|
+
message: error.message,
|
|
5822
|
+
stack: error.stack
|
|
5823
|
+
}
|
|
5824
|
+
},
|
|
5825
|
+
replace: true
|
|
5826
|
+
}) : null, isLoggedIn ? jsx(Navigate, {
|
|
5827
|
+
to: sessionStorageProvider.getCallbackUrl(),
|
|
5828
|
+
replace: true
|
|
5829
|
+
}) : null]
|
|
5830
|
+
});
|
|
5818
5831
|
};
|
|
5819
5832
|
|
|
5820
5833
|
/* *
|
|
@@ -5891,34 +5904,26 @@ const OAuth2Logout = () => {
|
|
|
5891
5904
|
window.location.assign(authConfig.GW_AUTH_LOGOUT_URL);
|
|
5892
5905
|
}
|
|
5893
5906
|
}, [isLoggedIn, onSetAuth, onLogin, sessionStorageProvider, authConfig.GW_AUTH_LOGOUT_URL]);
|
|
5894
|
-
return showAlert ? (
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
|
|
5903
|
-
|
|
5907
|
+
return showAlert ? jsx(ThemeWrapper, {
|
|
5908
|
+
children: jsx(AlertBanner, {
|
|
5909
|
+
severity: "info",
|
|
5910
|
+
title: t('auth-logout-you-are-logged-out'),
|
|
5911
|
+
info: jsx("p", {
|
|
5912
|
+
children: jsxs(Trans, Object.assign({
|
|
5913
|
+
i18nKey: "auth-logout-go-back-to-home-page",
|
|
5914
|
+
ns: AUTH_NAMESPACE
|
|
5915
|
+
}, {
|
|
5916
|
+
children: ["Go back to the ", jsx(Link, Object.assign({
|
|
5917
|
+
to: "/"
|
|
5918
|
+
}, {
|
|
5919
|
+
children: "Home Page"
|
|
5920
|
+
}))]
|
|
5921
|
+
}))
|
|
5922
|
+
})
|
|
5923
|
+
})
|
|
5924
|
+
}) : null;
|
|
5904
5925
|
};
|
|
5905
5926
|
|
|
5906
|
-
/* *
|
|
5907
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5908
|
-
* you may not use this file except in compliance with the License.
|
|
5909
|
-
* You may obtain a copy of the License at
|
|
5910
|
-
*
|
|
5911
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
5912
|
-
*
|
|
5913
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
5914
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
5915
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
5916
|
-
* See the License for the specific language governing permissions and
|
|
5917
|
-
* limitations under the License.
|
|
5918
|
-
*
|
|
5919
|
-
* Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
5920
|
-
* Copyright 2024 - Finnish Meteorological Institute (FMI)
|
|
5921
|
-
* */
|
|
5922
5927
|
const UserMenuRoles = ({
|
|
5923
5928
|
roles,
|
|
5924
5929
|
onChangeRole,
|
|
@@ -5928,33 +5933,40 @@ const UserMenuRoles = ({
|
|
|
5928
5933
|
const {
|
|
5929
5934
|
t
|
|
5930
5935
|
} = useAuthenticationTranslation();
|
|
5931
|
-
return
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
|
|
5942
|
-
|
|
5943
|
-
|
|
5944
|
-
|
|
5945
|
-
|
|
5946
|
-
|
|
5947
|
-
|
|
5948
|
-
|
|
5949
|
-
|
|
5950
|
-
|
|
5951
|
-
|
|
5952
|
-
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5936
|
+
return jsxs(Fragment, {
|
|
5937
|
+
children: [isLoading && jsx(Box, Object.assign({
|
|
5938
|
+
sx: {
|
|
5939
|
+
position: 'absolute',
|
|
5940
|
+
top: 0,
|
|
5941
|
+
left: 0,
|
|
5942
|
+
right: 0
|
|
5943
|
+
}
|
|
5944
|
+
}, {
|
|
5945
|
+
children: jsx(LinearProgress, {
|
|
5946
|
+
"data-testid": "loading-bar",
|
|
5947
|
+
color: "secondary"
|
|
5948
|
+
})
|
|
5949
|
+
})), jsxs(FormGroup, {
|
|
5950
|
+
children: [jsx(FormLabel, Object.assign({
|
|
5951
|
+
component: "legend",
|
|
5952
|
+
sx: {
|
|
5953
|
+
fontSize: 14,
|
|
5954
|
+
fontWeight: 400,
|
|
5955
|
+
color: 'geowebColors.typographyAndIcons.text',
|
|
5956
|
+
opacity: 1
|
|
5957
|
+
}
|
|
5958
|
+
}, {
|
|
5959
|
+
children: t('auth-role-title')
|
|
5960
|
+
})), roles && roles.map(role => jsx(FormControlLabel, {
|
|
5961
|
+
control: jsx(Radio, {
|
|
5962
|
+
disabled: isLoading,
|
|
5963
|
+
checked: _currentRole === role.name
|
|
5964
|
+
}),
|
|
5965
|
+
label: role.title,
|
|
5966
|
+
onChange: () => onChangeRole(role)
|
|
5967
|
+
}, role.name))]
|
|
5968
|
+
})]
|
|
5969
|
+
});
|
|
5958
5970
|
};
|
|
5959
5971
|
|
|
5960
5972
|
var userAgent$2 = engineUserAgent;
|
|
@@ -6708,10 +6720,12 @@ $({ target: 'Promise', stat: true, forced: FORCED_PROMISE_CONSTRUCTOR }, {
|
|
|
6708
6720
|
|
|
6709
6721
|
const UserMenuRolesConnect = ({
|
|
6710
6722
|
temporaryOnChangeRoleForDemo: _temporaryOnChangeRoleForDemo = () => {},
|
|
6711
|
-
roles
|
|
6723
|
+
roles,
|
|
6724
|
+
isAdmin: _isAdmin = false
|
|
6712
6725
|
}) => {
|
|
6726
|
+
const defaultRole = _isAdmin ? GEOWEB_ROLE_PRESETS_ADMIN.name : GEOWEB_ROLE_USER.name;
|
|
6713
6727
|
const [isLoading, setIsLoading] = React.useState(false);
|
|
6714
|
-
const [currentRole, setCurrentRole] = React.useState(
|
|
6728
|
+
const [currentRole, setCurrentRole] = React.useState(defaultRole);
|
|
6715
6729
|
const dispatch = useDispatch();
|
|
6716
6730
|
const {
|
|
6717
6731
|
t
|
|
@@ -6735,7 +6749,7 @@ const UserMenuRolesConnect = ({
|
|
|
6735
6749
|
}));
|
|
6736
6750
|
});
|
|
6737
6751
|
};
|
|
6738
|
-
return
|
|
6752
|
+
return jsx(UserMenuRoles, {
|
|
6739
6753
|
onChangeRole: onChangeRole,
|
|
6740
6754
|
roles: roles,
|
|
6741
6755
|
currentRole: currentRole,
|
|
@@ -6743,34 +6757,18 @@ const UserMenuRolesConnect = ({
|
|
|
6743
6757
|
});
|
|
6744
6758
|
};
|
|
6745
6759
|
|
|
6746
|
-
/* *
|
|
6747
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6748
|
-
* you may not use this file except in compliance with the License.
|
|
6749
|
-
* You may obtain a copy of the License at
|
|
6750
|
-
*
|
|
6751
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
6752
|
-
*
|
|
6753
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
6754
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
6755
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6756
|
-
* See the License for the specific language governing permissions and
|
|
6757
|
-
* limitations under the License.
|
|
6758
|
-
*
|
|
6759
|
-
* Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
6760
|
-
* Copyright 2021 - Finnish Meteorological Institute (FMI)
|
|
6761
|
-
* */
|
|
6762
6760
|
const RequireAuth = ({
|
|
6763
6761
|
children
|
|
6764
6762
|
}) => {
|
|
6765
6763
|
const {
|
|
6766
6764
|
isLoggedIn
|
|
6767
6765
|
} = useAuthenticationContext();
|
|
6768
|
-
return isLoggedIn ? children : (
|
|
6766
|
+
return isLoggedIn ? children : jsx(Navigate, {
|
|
6769
6767
|
to: "/login",
|
|
6770
6768
|
state: {
|
|
6771
6769
|
url: window.location.href
|
|
6772
6770
|
}
|
|
6773
|
-
})
|
|
6771
|
+
});
|
|
6774
6772
|
};
|
|
6775
6773
|
|
|
6776
6774
|
export { AUTH_NAMESPACE, AuthenticationContext, AuthenticationProvider, HandleOAuth2Code as Code, OAuth2Login as Login, OAuth2Logout as Logout, RequireAuth, SessionStorageKey, UserMenuRoles, UserMenuRolesConnect, authTranslations, getAuthConfig, getCodeChallenge, getCurrentUrlLocation, getRandomString, getSessionStorageProvider, useAuthenticationContext, useAuthenticationDefaultProps };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeoweb/authentication",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.20.1",
|
|
4
4
|
"description": "GeoWeb authentication library for the opengeoweb project",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"@opengeoweb/theme": "*",
|
|
16
16
|
"i18next": "^23.7.11",
|
|
17
17
|
"react-i18next": "^13.5.0",
|
|
18
|
-
"@opengeoweb/snackbar": "9.
|
|
18
|
+
"@opengeoweb/snackbar": "9.20.1",
|
|
19
19
|
"react-redux": "^8.1.3",
|
|
20
20
|
"@reduxjs/toolkit": "^1.9.7",
|
|
21
21
|
"@mui/material": "~5.15.11"
|
|
@@ -26,4 +26,4 @@
|
|
|
26
26
|
"module": "./index.esm.js",
|
|
27
27
|
"type": "module",
|
|
28
28
|
"main": "./index.esm.js"
|
|
29
|
-
}
|
|
29
|
+
}
|