@opengeoweb/authentication 12.2.0 → 12.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 +3 -103
- package/package.json +7 -7
- package/src/index.d.ts +0 -1
- package/src/lib/components/AuthenticationContext/types.d.ts +1 -1
- package/src/lib/components/Providers/Providers.d.ts +0 -2
- package/src/lib/utils/utils.d.ts +0 -2
- package/src/lib/utils/session.d.ts +0 -29
- package/src/lib/utils/session.spec.d.ts +0 -1
package/index.esm.js
CHANGED
|
@@ -3,14 +3,13 @@ import * as React from 'react';
|
|
|
3
3
|
import React__default, { useRef } from 'react';
|
|
4
4
|
import axios from 'axios';
|
|
5
5
|
import { Navigate, Link } from 'react-router-dom';
|
|
6
|
-
import { useIsMounted, SHARED_NAMESPACE, AlertBanner, useDebounce } from '@opengeoweb/shared';
|
|
7
|
-
import { snackbarReducer, snackbarListener, snackbarTypes, snackbarActions } from '@opengeoweb/snackbar';
|
|
8
|
-
import { configureStore } from '@reduxjs/toolkit';
|
|
6
|
+
import { sessionStorageProvider, useIsMounted, SHARED_NAMESPACE, AlertBanner, useDebounce } from '@opengeoweb/shared';
|
|
9
7
|
import { ThemeWrapper } from '@opengeoweb/theme';
|
|
10
8
|
import { useTranslation, Trans } from 'react-i18next';
|
|
11
9
|
import 'i18next';
|
|
12
10
|
import { Box, LinearProgress, FormGroup, FormLabel, FormControlLabel, Radio } from '@mui/material';
|
|
13
11
|
import { useDispatch } from 'react-redux';
|
|
12
|
+
import { snackbarTypes, snackbarActions } from '@opengeoweb/snackbar';
|
|
14
13
|
|
|
15
14
|
var en$1 = {
|
|
16
15
|
"auth-logout-go-back-to-home-page": "Go back to the <1>Home Page</1>",
|
|
@@ -402,90 +401,6 @@ function _regeneratorRuntime() {
|
|
|
402
401
|
}, e;
|
|
403
402
|
}
|
|
404
403
|
|
|
405
|
-
/* *
|
|
406
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
407
|
-
* you may not use this file except in compliance with the License.
|
|
408
|
-
* You may obtain a copy of the License at
|
|
409
|
-
*
|
|
410
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
411
|
-
*
|
|
412
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
413
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
414
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
415
|
-
* See the License for the specific language governing permissions and
|
|
416
|
-
* limitations under the License.
|
|
417
|
-
*
|
|
418
|
-
* Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
|
|
419
|
-
* Copyright 2024 - Finnish Meteorological Institute (FMI)
|
|
420
|
-
* Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
|
|
421
|
-
* */
|
|
422
|
-
var SessionStorageKey;
|
|
423
|
-
(function (SessionStorageKey) {
|
|
424
|
-
SessionStorageKey["CONFIG"] = "config";
|
|
425
|
-
SessionStorageKey["OAUTH_STATE"] = "oauth_state";
|
|
426
|
-
SessionStorageKey["OAUTH_CODE_VERIFIER"] = "code_verifier";
|
|
427
|
-
SessionStorageKey["OAUTH_CODE_CHALLENGE"] = "code_challenge";
|
|
428
|
-
SessionStorageKey["HAS_AUTHENTICATED"] = "has_authenticated";
|
|
429
|
-
SessionStorageKey["CALLBACK_URL"] = "callback_url";
|
|
430
|
-
})(SessionStorageKey || (SessionStorageKey = {}));
|
|
431
|
-
var getSessionStorageProvider = function getSessionStorageProvider() {
|
|
432
|
-
var _window = window,
|
|
433
|
-
sessionStorage = _window.sessionStorage;
|
|
434
|
-
return {
|
|
435
|
-
setConfig: function setConfig(value) {
|
|
436
|
-
return sessionStorage.setItem(SessionStorageKey.CONFIG, JSON.stringify(value));
|
|
437
|
-
},
|
|
438
|
-
getConfig: function getConfig() {
|
|
439
|
-
return JSON.parse(sessionStorage.getItem(SessionStorageKey.CONFIG) || '{}');
|
|
440
|
-
},
|
|
441
|
-
setOauthState: function setOauthState(value) {
|
|
442
|
-
return sessionStorage.setItem(SessionStorageKey.OAUTH_STATE, value);
|
|
443
|
-
},
|
|
444
|
-
getOauthState: function getOauthState() {
|
|
445
|
-
return sessionStorage.getItem(SessionStorageKey.OAUTH_STATE);
|
|
446
|
-
},
|
|
447
|
-
removeOauthState: function removeOauthState() {
|
|
448
|
-
return sessionStorage.removeItem(SessionStorageKey.OAUTH_STATE);
|
|
449
|
-
},
|
|
450
|
-
setOauthCodeVerifier: function setOauthCodeVerifier(value) {
|
|
451
|
-
return sessionStorage.setItem(SessionStorageKey.OAUTH_CODE_VERIFIER, value);
|
|
452
|
-
},
|
|
453
|
-
getOauthCodeVerifier: function getOauthCodeVerifier() {
|
|
454
|
-
return sessionStorage.getItem(SessionStorageKey.OAUTH_CODE_VERIFIER);
|
|
455
|
-
},
|
|
456
|
-
removeOauthCodeVerifier: function removeOauthCodeVerifier() {
|
|
457
|
-
return sessionStorage.removeItem(SessionStorageKey.OAUTH_CODE_VERIFIER);
|
|
458
|
-
},
|
|
459
|
-
setOauthCodeChallenge: function setOauthCodeChallenge(value) {
|
|
460
|
-
return sessionStorage.setItem(SessionStorageKey.OAUTH_CODE_CHALLENGE, value);
|
|
461
|
-
},
|
|
462
|
-
getOauthCodeChallenge: function getOauthCodeChallenge() {
|
|
463
|
-
return sessionStorage.getItem(SessionStorageKey.OAUTH_CODE_CHALLENGE);
|
|
464
|
-
},
|
|
465
|
-
removeOauthCodeChallenge: function removeOauthCodeChallenge() {
|
|
466
|
-
return sessionStorage.removeItem(SessionStorageKey.OAUTH_CODE_CHALLENGE);
|
|
467
|
-
},
|
|
468
|
-
setHasAuthenticated: function setHasAuthenticated(value) {
|
|
469
|
-
return sessionStorage.setItem(SessionStorageKey.HAS_AUTHENTICATED, value);
|
|
470
|
-
},
|
|
471
|
-
getHasAuthenticated: function getHasAuthenticated() {
|
|
472
|
-
return sessionStorage.getItem(SessionStorageKey.HAS_AUTHENTICATED);
|
|
473
|
-
},
|
|
474
|
-
removeHasAuthenticated: function removeHasAuthenticated() {
|
|
475
|
-
return sessionStorage.removeItem(SessionStorageKey.HAS_AUTHENTICATED);
|
|
476
|
-
},
|
|
477
|
-
getCallbackUrl: function getCallbackUrl() {
|
|
478
|
-
return sessionStorage.getItem(SessionStorageKey.CALLBACK_URL);
|
|
479
|
-
},
|
|
480
|
-
setCallbackUrl: function setCallbackUrl(value) {
|
|
481
|
-
return sessionStorage.setItem(SessionStorageKey.CALLBACK_URL, value);
|
|
482
|
-
}
|
|
483
|
-
};
|
|
484
|
-
};
|
|
485
|
-
var getConfig = function getConfig() {
|
|
486
|
-
return getSessionStorageProvider().getConfig();
|
|
487
|
-
};
|
|
488
|
-
|
|
489
404
|
var API_NAMESPACE$1 = 'api';
|
|
490
405
|
var DEFAULT_TIMEOUT = 15000;
|
|
491
406
|
var KEEP_ALIVE_POLLER_IN_SECONDS = 60; // Number of seconds between the checks if the token should be refreshed.
|
|
@@ -874,7 +789,6 @@ var getAuthConfig = function getAuthConfig(_configUrls) {
|
|
|
874
789
|
GW_AUTH_CLIENT_ID = _configUrls.GW_AUTH_CLIENT_ID,
|
|
875
790
|
GW_AUTH_ROLE_CLAIM_NAME = _configUrls.GW_AUTH_ROLE_CLAIM_NAME,
|
|
876
791
|
GW_AUTH_ROLE_CLAIM_VALUE_PRESETS_ADMIN = _configUrls.GW_AUTH_ROLE_CLAIM_VALUE_PRESETS_ADMIN;
|
|
877
|
-
var sessionStorageProvider = getSessionStorageProvider();
|
|
878
792
|
var loginUrl = replaceTemplateKeys(GW_AUTH_LOGIN_URL, GW_AUTH_CLIENT_ID, GW_APP_URL, sessionStorageProvider.getOauthState(), sessionStorageProvider.getOauthCodeChallenge());
|
|
879
793
|
var logOutUrl = replaceTemplateKeys(GW_AUTH_LOGOUT_URL, GW_AUTH_CLIENT_ID, GW_APP_URL);
|
|
880
794
|
return {
|
|
@@ -927,7 +841,6 @@ var useAuthenticationDefaultProps = function useAuthenticationDefaultProps() {
|
|
|
927
841
|
Object.assign(auth, emptyCredentials);
|
|
928
842
|
}
|
|
929
843
|
};
|
|
930
|
-
var sessionStorageProvider = getSessionStorageProvider();
|
|
931
844
|
var _React$useState3 = React__default.useState(auth.roles && auth.roles[0] || GEOWEB_ROLE_USER),
|
|
932
845
|
currentRole = _React$useState3[0],
|
|
933
846
|
setCurrentRole = _React$useState3[1];
|
|
@@ -1200,18 +1113,6 @@ var HandleOAuth2Code = function HandleOAuth2Code() {
|
|
|
1200
1113
|
var getCurrentUrlLocation = function getCurrentUrlLocation(url, appUrl) {
|
|
1201
1114
|
return url ? url.replace(appUrl, '') : '/';
|
|
1202
1115
|
};
|
|
1203
|
-
var createAuthenticationTestStore = function createAuthenticationTestStore(preloadedState) {
|
|
1204
|
-
var store = configureStore({
|
|
1205
|
-
reducer: {
|
|
1206
|
-
snackbar: snackbarReducer
|
|
1207
|
-
},
|
|
1208
|
-
middleware: function middleware(getDefaultMiddleware) {
|
|
1209
|
-
return getDefaultMiddleware().prepend(snackbarListener.middleware);
|
|
1210
|
-
},
|
|
1211
|
-
preloadedState: preloadedState
|
|
1212
|
-
});
|
|
1213
|
-
return store;
|
|
1214
|
-
};
|
|
1215
1116
|
|
|
1216
1117
|
/* *
|
|
1217
1118
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -1233,7 +1134,6 @@ var createAuthenticationTestStore = function createAuthenticationTestStore(prelo
|
|
|
1233
1134
|
var OAuth2Login = function OAuth2Login() {
|
|
1234
1135
|
var _useAuthenticationCon = useAuthenticationContext(),
|
|
1235
1136
|
authConfig = _useAuthenticationCon.authConfig;
|
|
1236
|
-
var sessionStorageProvider = getSessionStorageProvider();
|
|
1237
1137
|
React__default.useEffect(function () {
|
|
1238
1138
|
var callbackUrl = getCurrentUrlLocation(sessionStorageProvider.getCallbackUrl(), authConfig.GW_APP_URL);
|
|
1239
1139
|
sessionStorageProvider.setCallbackUrl(callbackUrl);
|
|
@@ -1551,4 +1451,4 @@ params, callbacks) {
|
|
|
1551
1451
|
};
|
|
1552
1452
|
};
|
|
1553
1453
|
|
|
1554
|
-
export { AUTH_NAMESPACE, ApiProvider, 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, RequireAuth,
|
|
1454
|
+
export { AUTH_NAMESPACE, ApiProvider, 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, RequireAuth, UserMenuRoles, UserMenuRolesConnect, apiTranslations, authTranslations, createApiInstance, createFakeApiInstance, createNonAuthApiInstance, fakeApiRequest, getApi, getAuthConfig, getCodeChallenge, getCurrentTimeInSeconds, getCurrentUrlLocation, getRandomString, groupsToRoles, makeCredentialsFromTokenResponse, refreshAccessToken, refreshAccessTokenAndSetAuthContext, useApi, useApiContext, useAuthenticationContext, useAuthenticationDefaultProps };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opengeoweb/authentication",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.3.0",
|
|
4
4
|
"description": "GeoWeb authentication library for the opengeoweb project",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -10,14 +10,14 @@
|
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"axios": "^1.7.7",
|
|
12
12
|
"react-router-dom": "^6.23.1",
|
|
13
|
-
"@opengeoweb/shared": "12.
|
|
14
|
-
"@opengeoweb/theme": "12.
|
|
13
|
+
"@opengeoweb/shared": "12.3.0",
|
|
14
|
+
"@opengeoweb/theme": "12.3.0",
|
|
15
15
|
"i18next": "^23.11.5",
|
|
16
16
|
"react-i18next": "^15.1.1",
|
|
17
|
-
"@opengeoweb/snackbar": "12.
|
|
18
|
-
"react-redux": "^
|
|
19
|
-
"@reduxjs/toolkit": "^
|
|
20
|
-
"@mui/material": "^
|
|
17
|
+
"@opengeoweb/snackbar": "12.3.0",
|
|
18
|
+
"react-redux": "^9.2.0",
|
|
19
|
+
"@reduxjs/toolkit": "^2.6.1",
|
|
20
|
+
"@mui/material": "^7.0.1"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": "18",
|
package/src/index.d.ts
CHANGED
|
@@ -8,7 +8,6 @@ export * from './lib/components/AuthenticationContext';
|
|
|
8
8
|
export * from './lib/components/PrivateRoute';
|
|
9
9
|
export * from './lib/components/ApiContext';
|
|
10
10
|
export * from './lib/components/apiHooks';
|
|
11
|
-
export * from './lib/utils/session';
|
|
12
11
|
export * from './lib/utils/utils';
|
|
13
12
|
export { AUTH_NAMESPACE } from './lib/utils/i18n';
|
|
14
13
|
export { authTranslations, apiTranslations };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { Store } from '@reduxjs/toolkit';
|
|
3
|
-
import { ToolkitStore } from '@reduxjs/toolkit/dist/configureStore';
|
|
4
3
|
interface AuthTranslationWrapperProps {
|
|
5
4
|
children?: React.ReactNode;
|
|
6
5
|
}
|
|
@@ -9,5 +8,4 @@ export declare const DemoWrapper: React.FC<AuthTranslationWrapperProps>;
|
|
|
9
8
|
export declare const DemoWrapperConnect: React.FC<AuthTranslationWrapperProps & {
|
|
10
9
|
store: Store;
|
|
11
10
|
}>;
|
|
12
|
-
export declare const createTestAuthenticationStore: () => ToolkitStore;
|
|
13
11
|
export {};
|
package/src/lib/utils/utils.d.ts
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
import { ConfigureStoreOptions, ToolkitStore } from '@reduxjs/toolkit/dist/configureStore';
|
|
2
1
|
export declare const getCurrentUrlLocation: (url: string, appUrl: string) => string;
|
|
3
|
-
export declare const createAuthenticationTestStore: (preloadedState?: ConfigureStoreOptions['preloadedState']) => ToolkitStore;
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { ConfigType } from '@opengeoweb/shared';
|
|
2
|
-
export interface SessionStorageProvider {
|
|
3
|
-
setConfig: (value: ConfigType) => void;
|
|
4
|
-
getConfig: () => ConfigType;
|
|
5
|
-
setOauthState: (value: string) => void;
|
|
6
|
-
getOauthState: () => string;
|
|
7
|
-
removeOauthState: () => void;
|
|
8
|
-
setOauthCodeVerifier: (value: string) => void;
|
|
9
|
-
getOauthCodeVerifier: () => string;
|
|
10
|
-
removeOauthCodeVerifier: () => void;
|
|
11
|
-
setOauthCodeChallenge: (value: string) => void;
|
|
12
|
-
getOauthCodeChallenge: () => string;
|
|
13
|
-
removeOauthCodeChallenge: () => void;
|
|
14
|
-
setHasAuthenticated: (value: string) => void;
|
|
15
|
-
getHasAuthenticated: () => string;
|
|
16
|
-
removeHasAuthenticated: () => void;
|
|
17
|
-
getCallbackUrl: () => string;
|
|
18
|
-
setCallbackUrl: (value: string) => void;
|
|
19
|
-
}
|
|
20
|
-
export declare enum SessionStorageKey {
|
|
21
|
-
CONFIG = "config",
|
|
22
|
-
OAUTH_STATE = "oauth_state",
|
|
23
|
-
OAUTH_CODE_VERIFIER = "code_verifier",
|
|
24
|
-
OAUTH_CODE_CHALLENGE = "code_challenge",
|
|
25
|
-
HAS_AUTHENTICATED = "has_authenticated",
|
|
26
|
-
CALLBACK_URL = "callback_url"
|
|
27
|
-
}
|
|
28
|
-
export declare const getSessionStorageProvider: () => SessionStorageProvider;
|
|
29
|
-
export declare const getConfig: () => ConfigType;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|