@opengeoweb/authentication 9.8.0 → 9.10.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
@@ -5,6 +5,8 @@ import { Navigate, useLocation, Link } from 'react-router-dom';
5
5
  import { useIsMounted, AlertBanner } from '@opengeoweb/shared';
6
6
  import { KEEP_ALIVE_POLLER_IN_SECONDS, MILLISECOND_TO_SECOND, getCurrentTimeInSeconds, refreshAccessTokenAndSetAuthContext, makeCredentialsFromTokenResponse } from '@opengeoweb/api';
7
7
  import { ThemeWrapper } from '@opengeoweb/theme';
8
+ import { useTranslation, Trans } from 'react-i18next';
9
+ import 'i18next';
8
10
 
9
11
  var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
10
12
 
@@ -4709,7 +4711,7 @@ const authConfigKeys = {
4709
4711
  GW_AUTH_LOGOUT_URL: null,
4710
4712
  GW_AUTH_TOKEN_URL: null,
4711
4713
  GW_APP_URL: null,
4712
- GW_INFRA_BASE_URL: null,
4714
+ GW_BE_VERSION_BASE_URL: null,
4713
4715
  GW_AUTH_CLIENT_ID: null
4714
4716
  };
4715
4717
  const getRandomString = () => {
@@ -4733,7 +4735,7 @@ const getAuthConfig = _configUrls => {
4733
4735
  GW_AUTH_LOGOUT_URL,
4734
4736
  GW_AUTH_TOKEN_URL,
4735
4737
  GW_APP_URL,
4736
- GW_INFRA_BASE_URL,
4738
+ GW_BE_VERSION_BASE_URL,
4737
4739
  GW_AUTH_CLIENT_ID
4738
4740
  } = _configUrls;
4739
4741
  const sessionStorageProvider = getSessionStorageProvider();
@@ -4744,8 +4746,8 @@ const getAuthConfig = _configUrls => {
4744
4746
  GW_AUTH_LOGOUT_URL: logOutUrl,
4745
4747
  GW_AUTH_TOKEN_URL,
4746
4748
  GW_APP_URL,
4747
- GW_AUTH_CLIENT_ID,
4748
- GW_INFRA_BASE_URL
4749
+ GW_BE_VERSION_BASE_URL,
4750
+ GW_AUTH_CLIENT_ID
4749
4751
  };
4750
4752
  };
4751
4753
  const AuthenticationContext = /*#__PURE__*/React.createContext({
@@ -5004,6 +5006,62 @@ const OAuth2Login = () => {
5004
5006
  return null;
5005
5007
  };
5006
5008
 
5009
+ var en = {
5010
+ "auth-logout-go-back-to-home-page": "Go back to the <1>Home Page</1>",
5011
+ "auth-logout-you-are-logged-out": "You are logged out."
5012
+ };
5013
+ var fi = {
5014
+ "auth-logout-go-back-to-home-page": "🚧 ei käännetty. Go back to the <1>Home Page</1>",
5015
+ "auth-logout-you-are-logged-out": "🚧 ei käännetty"
5016
+ };
5017
+ var no = {
5018
+ "auth-logout-go-back-to-home-page": "🚧 ikke oversatt. Go back to the <1>Home Page</1>",
5019
+ "auth-logout-you-are-logged-out": "🚧 ikke oversatt"
5020
+ };
5021
+ var nl = {
5022
+ "auth-logout-go-back-to-home-page": "🚧 niet vertaald. Go back to the <1>Home Page</1>",
5023
+ "auth-logout-you-are-logged-out": "🚧 niet vertaald"
5024
+ };
5025
+ var authTrans = {
5026
+ en: en,
5027
+ fi: fi,
5028
+ no: no,
5029
+ nl: nl
5030
+ };
5031
+
5032
+ /* *
5033
+ * Licensed under the Apache License, Version 2.0 (the "License");
5034
+ * you may not use this file except in compliance with the License.
5035
+ * You may obtain a copy of the License at
5036
+ *
5037
+ * http://www.apache.org/licenses/LICENSE-2.0
5038
+ *
5039
+ * Unless required by applicable law or agreed to in writing, software
5040
+ * distributed under the License is distributed on an "AS IS" BASIS,
5041
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
5042
+ * See the License for the specific language governing permissions and
5043
+ * limitations under the License.
5044
+ *
5045
+ * Copyright 2023 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
5046
+ * Copyright 2023 - Finnish Meteorological Institute (FMI)
5047
+ * */
5048
+ const AUTH_NAMESPACE = 'auth';
5049
+
5050
+ const AuthTranslationsWrapper = ({
5051
+ children
5052
+ }) => {
5053
+ const {
5054
+ i18n
5055
+ } = useTranslation();
5056
+ React.useEffect(() => {
5057
+ i18n.addResourceBundle('en', AUTH_NAMESPACE, authTrans.en);
5058
+ i18n.addResourceBundle('fi', AUTH_NAMESPACE, authTrans.fi);
5059
+ i18n.addResourceBundle('no', AUTH_NAMESPACE, authTrans.no);
5060
+ i18n.addResourceBundle('nl', AUTH_NAMESPACE, authTrans.nl);
5061
+ }, [i18n]);
5062
+ return children;
5063
+ };
5064
+
5007
5065
  const OAuth2Logout = () => {
5008
5066
  const {
5009
5067
  onSetAuth,
@@ -5013,6 +5071,9 @@ const OAuth2Logout = () => {
5013
5071
  sessionStorageProvider
5014
5072
  } = useAuthenticationContext();
5015
5073
  const [showAlert, setShowAlert] = React.useState(true);
5074
+ const {
5075
+ t
5076
+ } = useTranslation(AUTH_NAMESPACE);
5016
5077
  React.useEffect(() => {
5017
5078
  if (isLoggedIn) {
5018
5079
  setShowAlert(false);
@@ -5022,16 +5083,23 @@ const OAuth2Logout = () => {
5022
5083
  window.location.assign(authConfig.GW_AUTH_LOGOUT_URL);
5023
5084
  }
5024
5085
  }, [isLoggedIn, onSetAuth, onLogin, sessionStorageProvider, authConfig.GW_AUTH_LOGOUT_URL]);
5025
- return showAlert ? jsx(ThemeWrapper, {
5026
- children: jsx(AlertBanner, {
5027
- severity: "info",
5028
- title: "You are logged out.",
5029
- info: jsxs("p", {
5030
- children: ["Go back to the ", jsx(Link, Object.assign({
5031
- to: "/"
5032
- }, {
5033
- children: "Home Page"
5034
- }))]
5086
+ return showAlert ? jsx(AuthTranslationsWrapper, {
5087
+ children: jsx(ThemeWrapper, {
5088
+ children: jsx(AlertBanner, {
5089
+ severity: "info",
5090
+ title: t('auth-logout-you-are-logged-out'),
5091
+ info: jsx("p", {
5092
+ children: jsxs(Trans, Object.assign({
5093
+ i18nKey: "auth-logout-go-back-to-home-page",
5094
+ ns: AUTH_NAMESPACE
5095
+ }, {
5096
+ children: ["Go back to the ", jsx(Link, Object.assign({
5097
+ to: "/"
5098
+ }, {
5099
+ children: "Home Page"
5100
+ }))]
5101
+ }))
5102
+ })
5035
5103
  })
5036
5104
  })
5037
5105
  }) : null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/authentication",
3
- "version": "9.8.0",
3
+ "version": "9.10.0",
4
4
  "description": "GeoWeb authentication library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -12,7 +12,9 @@
12
12
  "@opengeoweb/api": "*",
13
13
  "react-router-dom": "^6.21.0",
14
14
  "@opengeoweb/shared": "*",
15
- "@opengeoweb/theme": "*"
15
+ "@opengeoweb/theme": "*",
16
+ "i18next": "^23.7.11",
17
+ "react-i18next": "^13.5.0"
16
18
  },
17
19
  "peerDependencies": {
18
20
  "react": "18"
@@ -4,8 +4,8 @@ export interface AuthenticationConfig {
4
4
  GW_AUTH_LOGOUT_URL: string;
5
5
  GW_AUTH_TOKEN_URL: string;
6
6
  GW_APP_URL: string;
7
+ GW_BE_VERSION_BASE_URL?: string;
7
8
  GW_AUTH_CLIENT_ID: string;
8
- GW_INFRA_BASE_URL?: string;
9
9
  }
10
10
  export interface SessionStorageProvider {
11
11
  setOauthState: (value: string) => void;
@@ -0,0 +1,7 @@
1
+ import React from 'react';
2
+ interface AuthTranslationWrapperProps {
3
+ children?: React.ReactNode;
4
+ }
5
+ export declare const AuthTranslationsWrapper: React.FC<AuthTranslationWrapperProps>;
6
+ export declare const AuthI18nProvider: React.FC<AuthTranslationWrapperProps>;
7
+ export {};
@@ -0,0 +1 @@
1
+ export * from './Providers';
@@ -0,0 +1,2 @@
1
+ export declare const AUTH_NAMESPACE = "auth";
2
+ export declare const initAuthTestI18n: () => void;