@opengeoweb/authentication 12.1.2 → 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 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>",
@@ -95,7 +94,7 @@ function _objectWithoutPropertiesLoose(r, e) {
95
94
  if (null == r) return {};
96
95
  var t = {};
97
96
  for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
98
- if (e.indexOf(n) >= 0) continue;
97
+ if (-1 !== e.indexOf(n)) continue;
99
98
  t[n] = r[n];
100
99
  }
101
100
  return t;
@@ -118,9 +117,9 @@ function _regeneratorRuntime() {
118
117
  function define(t, e, r) {
119
118
  return Object.defineProperty(t, e, {
120
119
  value: r,
121
- enumerable: !0,
122
- configurable: !0,
123
- writable: !0
120
+ enumerable: true,
121
+ configurable: true,
122
+ writable: true
124
123
  }), t[e];
125
124
  }
126
125
  try {
@@ -213,7 +212,7 @@ function _regeneratorRuntime() {
213
212
  if ("throw" === i) throw a;
214
213
  return {
215
214
  value: t,
216
- done: !0
215
+ done: true
217
216
  };
218
217
  }
219
218
  for (n.method = i, n.arg = a;;) {
@@ -264,7 +263,7 @@ function _regeneratorRuntime() {
264
263
  function Context(t) {
265
264
  this.tryEntries = [{
266
265
  tryLoc: "root"
267
- }], t.forEach(pushTryEntry, this), this.reset(!0);
266
+ }], t.forEach(pushTryEntry, this), this.reset(true);
268
267
  }
269
268
  function values(e) {
270
269
  if (e || "" === e) {
@@ -274,8 +273,8 @@ function _regeneratorRuntime() {
274
273
  if (!isNaN(e.length)) {
275
274
  var o = -1,
276
275
  i = function next() {
277
- for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
278
- return next.value = t, next.done = !0, next;
276
+ for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = false, next;
277
+ return next.value = t, next.done = true, next;
279
278
  };
280
279
  return i.next = i;
281
280
  }
@@ -284,10 +283,10 @@ function _regeneratorRuntime() {
284
283
  }
285
284
  return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
286
285
  value: GeneratorFunctionPrototype,
287
- configurable: !0
286
+ configurable: true
288
287
  }), o(GeneratorFunctionPrototype, "constructor", {
289
288
  value: GeneratorFunction,
290
- configurable: !0
289
+ configurable: true
291
290
  }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
292
291
  var e = "function" == typeof t && t.constructor;
293
292
  return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
@@ -316,17 +315,17 @@ function _regeneratorRuntime() {
316
315
  return r.reverse(), function next() {
317
316
  for (; r.length;) {
318
317
  var t = r.pop();
319
- if (t in e) return next.value = t, next.done = !1, next;
318
+ if (t in e) return next.value = t, next.done = false, next;
320
319
  }
321
- return next.done = !0, next;
320
+ return next.done = true, next;
322
321
  };
323
322
  }, e.values = values, Context.prototype = {
324
323
  constructor: Context,
325
324
  reset: function (e) {
326
- if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
325
+ if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = false, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
327
326
  },
328
327
  stop: function () {
329
- this.done = !0;
328
+ this.done = true;
330
329
  var t = this.tryEntries[0].completion;
331
330
  if ("throw" === t.type) throw t.arg;
332
331
  return this.rval;
@@ -345,10 +344,10 @@ function _regeneratorRuntime() {
345
344
  var c = n.call(i, "catchLoc"),
346
345
  u = n.call(i, "finallyLoc");
347
346
  if (c && u) {
348
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
347
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, true);
349
348
  if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
350
349
  } else if (c) {
351
- if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
350
+ if (this.prev < i.catchLoc) return handle(i.catchLoc, true);
352
351
  } else {
353
352
  if (!u) throw Error("try statement without catch or finally");
354
353
  if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
@@ -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, SessionStorageKey, UserMenuRoles, UserMenuRolesConnect, apiTranslations, authTranslations, createApiInstance, createAuthenticationTestStore, createFakeApiInstance, createNonAuthApiInstance, fakeApiRequest, getApi, getAuthConfig, getCodeChallenge, getConfig, getCurrentTimeInSeconds, getCurrentUrlLocation, getRandomString, getSessionStorageProvider, groupsToRoles, makeCredentialsFromTokenResponse, refreshAccessToken, refreshAccessTokenAndSetAuthContext, useApi, useApiContext, useAuthenticationContext, useAuthenticationDefaultProps };
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.1.2",
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.1.2",
14
- "@opengeoweb/theme": "12.1.2",
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.1.2",
18
- "react-redux": "^8.1.3",
19
- "@reduxjs/toolkit": "^1.9.7",
20
- "@mui/material": "^6.1.1"
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,4 +1,4 @@
1
- import { SessionStorageProvider } from '../../utils/session';
1
+ import { SessionStorageProvider } from '@opengeoweb/shared';
2
2
  import { Credentials, Role } from '../ApiContext/types';
3
3
  export interface AuthenticationConfig {
4
4
  GW_AUTH_LOGIN_URL: string;
@@ -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 {};
@@ -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 {};