@opengeoweb/authentication 15.3.0 → 17.0.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.
Files changed (32) hide show
  1. package/index.esm.js +77 -22
  2. package/package.json +4 -4
  3. package/src/index.d.ts +0 -12
  4. package/src/lib/components/ApiContext/index.d.ts +0 -2
  5. package/src/lib/components/ApiContext/types.d.ts +0 -35
  6. package/src/lib/components/ApiContext/utils.d.ts +0 -27
  7. package/src/lib/components/ApiContext/utils.spec.d.ts +0 -1
  8. package/src/lib/components/AuthenticationContext/AuthenticationContext.d.ts +0 -19
  9. package/src/lib/components/AuthenticationContext/AuthenticationContext.spec.d.ts +0 -1
  10. package/src/lib/components/AuthenticationContext/AuthenticationRenderTestComponent.d.ts +0 -10
  11. package/src/lib/components/AuthenticationContext/AuthenticationRenderTestComponent.spec.d.ts +0 -1
  12. package/src/lib/components/AuthenticationContext/index.d.ts +0 -2
  13. package/src/lib/components/AuthenticationContext/types.d.ts +0 -25
  14. package/src/lib/components/Providers/Providers.d.ts +0 -7
  15. package/src/lib/components/Providers/index.d.ts +0 -1
  16. package/src/lib/components/UserMenuRoles/UserMenuRoles.d.ts +0 -7
  17. package/src/lib/components/UserMenuRoles/UserMenuRoles.spec.d.ts +0 -1
  18. package/src/lib/components/UserMenuRoles/index.d.ts +0 -1
  19. package/src/lib/components/apiHooks/index.d.ts +0 -1
  20. package/src/lib/components/apiHooks/useApi.d.ts +0 -36
  21. package/src/lib/components/apiHooks/useApi.spec.d.ts +0 -1
  22. package/src/lib/components/pages/Code.d.ts +0 -4
  23. package/src/lib/components/pages/Code.spec.d.ts +0 -1
  24. package/src/lib/components/pages/Login.d.ts +0 -3
  25. package/src/lib/components/pages/Login.spec.d.ts +0 -1
  26. package/src/lib/components/pages/Logout.d.ts +0 -3
  27. package/src/lib/components/pages/Logout.spec.d.ts +0 -1
  28. package/src/lib/components/pages/index.d.ts +0 -3
  29. package/src/lib/utils/i18n.d.ts +0 -6
  30. package/src/lib/utils/mockdata.d.ts +0 -11
  31. package/src/lib/utils/utils.d.ts +0 -1
  32. package/src/lib/utils/utils.spec.d.ts +0 -1
package/index.esm.js CHANGED
@@ -1,8 +1,8 @@
1
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
1
  import axios from 'axios';
3
2
  import React, { useRef, useEffect, useState } from 'react';
4
3
  import { Navigate, Link } from 'react-router-dom';
5
4
  import { sessionStorageProvider, useIsMounted, SHARED_NAMESPACE, AlertBanner, useDebounce } from '@opengeoweb/shared';
5
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
6
  import { useTranslation, Trans } from 'react-i18next';
7
7
  import { ThemeWrapper } from '@opengeoweb/theme';
8
8
  import 'i18next';
@@ -332,8 +332,11 @@ function _regeneratorRuntime() {
332
332
 
333
333
  var DEFAULT_TIMEOUT = 15000;
334
334
  var KEEP_ALIVE_POLLER_IN_SECONDS = 60; // Number of seconds between the checks if the token should be refreshed.
335
+
335
336
  var REFRESH_TOKEN_WHEN_PCT_EXPIRED = 75; // Refresh token when 75% expired. Set to (10 / 3600) * 100 = 0.2777778% to test with 10 second interval (assuming 1 hour token expiration).
337
+
336
338
  var DEFAULT_TOKEN_EXPIRES_IN = 3600; // Number of seconds a token expires by default
339
+
337
340
  var MILLISECOND_TO_SECOND = 1 / 1000;
338
341
  var GEOWEB_ROLE_PRESETS_ADMIN = {
339
342
  name: 'ROLE_PRESET_ADMIN',
@@ -343,6 +346,7 @@ var GEOWEB_ROLE_USER = {
343
346
  name: 'ROLE_USER',
344
347
  title: 'api-role-title-user'
345
348
  };
349
+
346
350
  /**
347
351
  * Creates a Credentials object based on the axios response from the token service.
348
352
  *
@@ -424,7 +428,7 @@ var refreshAccessToken = /*#__PURE__*/function () {
424
428
  }();
425
429
  var refreshAccessTokenAndSetAuthContext = /*#__PURE__*/function () {
426
430
  var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_ref3) {
427
- var auth, onSetAuth, config, _ref3$timeout, timeout, configURLS, onLogin, refreshedToken, newAuth, _e$response, status;
431
+ var auth, onSetAuth, config, _ref3$timeout, timeout, configURLS, onLogin, refreshedToken, newAuth, _response, status;
428
432
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
429
433
  while (1) switch (_context2.prev = _context2.next) {
430
434
  case 0:
@@ -442,6 +446,7 @@ var refreshAccessTokenAndSetAuthContext = /*#__PURE__*/function () {
442
446
  if (!newAuth.refresh_token || newAuth.refresh_token.length === 0) {
443
447
  newAuth.refresh_token = auth.refresh_token;
444
448
  }
449
+
445
450
  // If the prop for the role config is not set, keep the roles of the current auth context.
446
451
  if (!configURLS) {
447
452
  newAuth.roles = auth.roles;
@@ -452,7 +457,7 @@ var refreshAccessTokenAndSetAuthContext = /*#__PURE__*/function () {
452
457
  case 11:
453
458
  _context2.prev = 11;
454
459
  _context2.t0 = _context2["catch"](1);
455
- status = (_e$response = _context2.t0.response) == null ? void 0 : _e$response.status;
460
+ status = (_response = _context2.t0.response) == null ? void 0 : _response.status;
456
461
  if (status === 400) {
457
462
  onLogin(false);
458
463
  } else {
@@ -524,6 +529,7 @@ var createApiInstance = function createApiInstance(_ref5) {
524
529
  return _ref7.apply(this, arguments);
525
530
  };
526
531
  }());
532
+
527
533
  // Response interceptor for API calls done AFTER the request is made.
528
534
  axiosInstance.interceptors.response.use(function (response) {
529
535
  return response;
@@ -570,6 +576,7 @@ var createNonAuthApiInstance = function createNonAuthApiInstance(_ref9) {
570
576
  headers: {},
571
577
  timeout: timeout
572
578
  });
579
+
573
580
  // Request interceptor for API calls
574
581
  axiosInstance.interceptors.request.use(/*#__PURE__*/function () {
575
582
  var _ref0 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee6(config) {
@@ -840,6 +847,7 @@ var useAuthenticationDefaultProps = function useAuthenticationDefaultProps() {
840
847
  var _React$useState3 = React.useState(Object.assign({}, emptyCredentials)),
841
848
  auth = _React$useState3[0],
842
849
  setAuth = _React$useState3[1];
850
+
843
851
  // TODO clean this up.
844
852
  // hotfix revert to ref. There are parts of the state down the tree that rely on ref to work.
845
853
  var authRef = React.useRef(auth).current;
@@ -890,6 +898,7 @@ var AuthenticationProvider = function AuthenticationProvider(_ref2) {
890
898
  currentRole = _ref3.currentRole,
891
899
  setCurrentRole = _ref3.setCurrentRole;
892
900
  var authConfig = configURLS;
901
+
893
902
  // Checks the token expiration time regularly and renews it before it expires.
894
903
  var interval = useRef();
895
904
  React.useEffect(function () {
@@ -943,7 +952,7 @@ var AuthenticationProvider = function AuthenticationProvider(_ref2) {
943
952
  setCurrentRole: setCurrentRole
944
953
  };
945
954
  }, [isLoggedIn, onLogin, auth, onSetAuth, authConfig, sessionStorageProvider, currentRole, setCurrentRole]);
946
- return jsx(AuthenticationContext.Provider, {
955
+ return /*#__PURE__*/jsx(AuthenticationContext.Provider, {
947
956
  value: contextValue,
948
957
  children: children
949
958
  });
@@ -1099,8 +1108,8 @@ var HandleOAuth2Code = function HandleOAuth2Code() {
1099
1108
  loginInProgress.current = false;
1100
1109
  });
1101
1110
  }, [authenticate, isLoggedIn]);
1102
- return jsxs(Fragment, {
1103
- children: [error ? jsx(Navigate, {
1111
+ return /*#__PURE__*/jsxs(Fragment, {
1112
+ children: [error ? /*#__PURE__*/jsx(Navigate, {
1104
1113
  replace: true,
1105
1114
  state: {
1106
1115
  error: {
@@ -1109,7 +1118,7 @@ var HandleOAuth2Code = function HandleOAuth2Code() {
1109
1118
  }
1110
1119
  },
1111
1120
  to: "/error"
1112
- }) : null, isLoggedIn ? jsx(Navigate, {
1121
+ }) : null, isLoggedIn ? /*#__PURE__*/jsx(Navigate, {
1113
1122
  replace: true,
1114
1123
  to: sessionStorageProvider.getCallbackUrl()
1115
1124
  }) : null]
@@ -1133,6 +1142,7 @@ var HandleOAuth2Code = function HandleOAuth2Code() {
1133
1142
  * Copyright 2024 - Finnish Meteorological Institute (FMI)
1134
1143
  * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1135
1144
  * */
1145
+
1136
1146
  var getCurrentUrlLocation = function getCurrentUrlLocation(url, appUrl) {
1137
1147
  return url ? url.replace(appUrl, '') : '/';
1138
1148
  };
@@ -1182,6 +1192,7 @@ var OAuth2Login = function OAuth2Login() {
1182
1192
  * Copyright 2023 - Finnish Meteorological Institute (FMI)
1183
1193
  * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1184
1194
  * */
1195
+
1185
1196
  var API_NAMESPACE = 'api';
1186
1197
  var AUTH_NAMESPACE = 'auth';
1187
1198
  var ns = [AUTH_NAMESPACE, API_NAMESPACE, SHARED_NAMESPACE];
@@ -1189,6 +1200,23 @@ var useAuthenticationTranslation = function useAuthenticationTranslation() {
1189
1200
  return useTranslation(ns);
1190
1201
  };
1191
1202
 
1203
+ /* *
1204
+ * Licensed under the Apache License, Version 2.0 (the "License");
1205
+ * you may not use this file except in compliance with the License.
1206
+ * You may obtain a copy of the License at
1207
+ *
1208
+ * http://www.apache.org/licenses/LICENSE-2.0
1209
+ *
1210
+ * Unless required by applicable law or agreed to in writing, software
1211
+ * distributed under the License is distributed on an "AS IS" BASIS,
1212
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1213
+ * See the License for the specific language governing permissions and
1214
+ * limitations under the License.
1215
+ *
1216
+ * Copyright 2021 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1217
+ * Copyright 2021 - Finnish Meteorological Institute (FMI)
1218
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1219
+ * */
1192
1220
  var OAuth2Logout = function OAuth2Logout() {
1193
1221
  var _useAuthenticationCon = useAuthenticationContext(),
1194
1222
  onSetAuth = _useAuthenticationCon.onSetAuth,
@@ -1210,13 +1238,13 @@ var OAuth2Logout = function OAuth2Logout() {
1210
1238
  window.location.assign(authConfig.GW_AUTH_LOGOUT_URL);
1211
1239
  }
1212
1240
  }, [isLoggedIn, onSetAuth, onLogin, sessionStorageProvider, authConfig.GW_AUTH_LOGOUT_URL]);
1213
- return showAlert ? jsx(ThemeWrapper, {
1214
- children: jsx(AlertBanner, {
1215
- info: jsx("p", {
1216
- children: jsxs(Trans, {
1241
+ return showAlert ? /*#__PURE__*/jsx(ThemeWrapper, {
1242
+ children: /*#__PURE__*/jsx(AlertBanner, {
1243
+ info: /*#__PURE__*/jsx("p", {
1244
+ children: /*#__PURE__*/jsxs(Trans, {
1217
1245
  i18nKey: "auth-logout-go-back-to-home-page",
1218
1246
  ns: AUTH_NAMESPACE,
1219
- children: ["Go back to the ", jsx(Link, {
1247
+ children: ["Go back to the ", /*#__PURE__*/jsx(Link, {
1220
1248
  to: "/",
1221
1249
  children: "Home Page"
1222
1250
  })]
@@ -1228,6 +1256,23 @@ var OAuth2Logout = function OAuth2Logout() {
1228
1256
  }) : null;
1229
1257
  };
1230
1258
 
1259
+ /* *
1260
+ * Licensed under the Apache License, Version 2.0 (the "License");
1261
+ * you may not use this file except in compliance with the License.
1262
+ * You may obtain a copy of the License at
1263
+ *
1264
+ * http://www.apache.org/licenses/LICENSE-2.0
1265
+ *
1266
+ * Unless required by applicable law or agreed to in writing, software
1267
+ * distributed under the License is distributed on an "AS IS" BASIS,
1268
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1269
+ * See the License for the specific language governing permissions and
1270
+ * limitations under the License.
1271
+ *
1272
+ * Copyright 2024 - Koninklijk Nederlands Meteorologisch Instituut (KNMI)
1273
+ * Copyright 2024 - Finnish Meteorological Institute (FMI)
1274
+ * Copyright 2024 - The Norwegian Meteorological Institute (MET Norway)
1275
+ * */
1231
1276
  var UserMenuRoles = function UserMenuRoles(_ref) {
1232
1277
  var currentRole = _ref.currentRole,
1233
1278
  onChangeRole = _ref.onChangeRole,
@@ -1242,8 +1287,8 @@ var UserMenuRoles = function UserMenuRoles(_ref) {
1242
1287
  onChangeRole == null || onChangeRole(selectedRole);
1243
1288
  }
1244
1289
  };
1245
- return jsxs(FormControl, {
1246
- children: [jsx(FormLabel, {
1290
+ return /*#__PURE__*/jsxs(FormControl, {
1291
+ children: [/*#__PURE__*/jsx(FormLabel, {
1247
1292
  component: "legend",
1248
1293
  sx: {
1249
1294
  fontSize: 14,
@@ -1252,14 +1297,14 @@ var UserMenuRoles = function UserMenuRoles(_ref) {
1252
1297
  opacity: 1
1253
1298
  },
1254
1299
  children: t('auth-role-title')
1255
- }), jsx(RadioGroup, {
1300
+ }), /*#__PURE__*/jsx(RadioGroup, {
1256
1301
  "aria-labelledby": "user-menu-roles",
1257
1302
  name: "user-menu-roles",
1258
1303
  onChange: handleChangeRole,
1259
1304
  value: currentRole == null ? void 0 : currentRole.name,
1260
1305
  children: roles == null ? void 0 : roles.map(function (role) {
1261
- return jsx(FormControlLabel, {
1262
- control: jsx(Radio, {}),
1306
+ return /*#__PURE__*/jsx(FormControlLabel, {
1307
+ control: /*#__PURE__*/jsx(Radio, {}),
1263
1308
  label: t(role.title),
1264
1309
  value: role.name
1265
1310
  }, role.name);
@@ -1268,14 +1313,23 @@ var UserMenuRoles = function UserMenuRoles(_ref) {
1268
1313
  });
1269
1314
  };
1270
1315
 
1316
+ /*
1317
+ Summary. Accepts a promise base apiCall with params, and returns an object with result
1318
+
1319
+ @param {Promise} apiCall: api request Promise
1320
+ @param {object} params: params for api request
1321
+ @return {isLoading: boolean, error: Error, results: any}
1322
+
1323
+ @example:
1324
+ const { isLoading, error, result } = useApi(api.getList, {
1325
+ id: 'xxxxx',
1326
+ });
1327
+ */
1328
+
1271
1329
  var generateRandomId = function generateRandomId() {
1272
1330
  return "-" + Math.random().toString(36).substring(2, 11);
1273
1331
  };
1274
- var useApi = function useApi(
1275
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
1276
- apiCall,
1277
- // eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/explicit-module-boundary-types
1278
- params, callbacks) {
1332
+ var useApi = function useApi(apiCall, params, callbacks) {
1279
1333
  var _useIsMounted = useIsMounted(),
1280
1334
  isMounted = _useIsMounted.isMounted;
1281
1335
  // eslint-disable-next-line react/hook-use-state
@@ -1291,6 +1345,7 @@ params, callbacks) {
1291
1345
  result = _useState4[0],
1292
1346
  setResult = _useState4[1];
1293
1347
  var debouncedParams = useDebounce(JSON.stringify(params), 300);
1348
+
1294
1349
  // 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)
1295
1350
  var callbacksRef = useRef();
1296
1351
  callbacksRef.current = callbacks;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opengeoweb/authentication",
3
- "version": "15.3.0",
3
+ "version": "17.0.0",
4
4
  "description": "GeoWeb authentication library for the opengeoweb project",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -10,8 +10,8 @@
10
10
  "dependencies": {
11
11
  "axios": "^1.7.7",
12
12
  "react-router-dom": "^6.23.1",
13
- "@opengeoweb/shared": "15.3.0",
14
- "@opengeoweb/theme": "15.3.0",
13
+ "@opengeoweb/shared": "17.0.0",
14
+ "@opengeoweb/theme": "17.0.0",
15
15
  "i18next": "^25.0.1",
16
16
  "react-i18next": "^15.1.1",
17
17
  "@mui/material": "^7.0.1"
@@ -22,7 +22,7 @@
22
22
  "@emotion/styled": "*"
23
23
  },
24
24
  "devDependencies": {
25
- "eslint-plugin-storybook": "9.0.17"
25
+ "eslint-plugin-storybook": "10.3.3"
26
26
  },
27
27
  "module": "./index.esm.js",
28
28
  "type": "module",
package/src/index.d.ts DELETED
@@ -1,12 +0,0 @@
1
- import apiTranslations from '../locales/api.json';
2
- import authTranslations from '../locales/authentication.json';
3
- export { default as Code } from './lib/components/pages/Code';
4
- export { default as Login } from './lib/components/pages/Login';
5
- export { default as Logout } from './lib/components/pages/Logout';
6
- export * from './lib/components/UserMenuRoles';
7
- export * from './lib/components/AuthenticationContext';
8
- export * from './lib/components/ApiContext';
9
- export * from './lib/components/apiHooks';
10
- export * from './lib/utils/utils';
11
- export { AUTH_NAMESPACE } from './lib/utils/i18n';
12
- export { authTranslations, apiTranslations };
@@ -1,2 +0,0 @@
1
- export * from './utils';
2
- export type * from './types';
@@ -1,35 +0,0 @@
1
- export interface GeoWebJWT {
2
- access_token: string;
3
- refresh_token?: string;
4
- id_token: string;
5
- expires_in: number;
6
- }
7
- export interface Credentials {
8
- username: string;
9
- roles?: Role[];
10
- token: string;
11
- refresh_token: string;
12
- expires_at?: number;
13
- has_connection_issue?: boolean;
14
- }
15
- export interface ApiUrls {
16
- baseURL?: string;
17
- appURL?: string;
18
- authTokenURL?: string;
19
- authClientId?: string;
20
- }
21
- export interface ApiModule {
22
- auth?: Credentials;
23
- onSetAuth?: (cred: Credentials) => void;
24
- config?: ApiUrls;
25
- name?: string;
26
- onLogin?: (isLoggedIn: boolean) => void;
27
- }
28
- export interface CreateApiProps extends ApiModule {
29
- timeout?: number;
30
- }
31
- export type CreateApiFn = (props: CreateApiProps) => unknown;
32
- export interface Role {
33
- name: string;
34
- title: string;
35
- }
@@ -1,27 +0,0 @@
1
- import type { AxiosInstance, AxiosResponse } from 'axios';
2
- import type { ConfigType } from '@opengeoweb/shared';
3
- import type { CreateApiProps, Credentials, Role } from './types';
4
- export declare const KEEP_ALIVE_POLLER_IN_SECONDS = 60;
5
- export declare const REFRESH_TOKEN_WHEN_PCT_EXPIRED = 75;
6
- export declare const MILLISECOND_TO_SECOND: number;
7
- export declare const GEOWEB_ROLE_PRESETS_ADMIN: Role;
8
- export declare const GEOWEB_ROLE_USER: Role;
9
- /**
10
- * Creates a Credentials object based on the axios response from the token service.
11
- *
12
- * It will calculate the expires_at attribute based on the expires_in property found in the JWT.
13
- *
14
- * @param tokenResponse Response of the tokenservice as axios response object.
15
- * @returns Credentials object.
16
- */
17
- export declare const makeCredentialsFromTokenResponse: (tokenResponse: AxiosResponse, authConfig?: ConfigType) => Credentials;
18
- export declare const refreshAccessToken: ({ auth, config: { authTokenURL, authClientId, appURL }, timeout, }: CreateApiProps) => Promise<AxiosResponse>;
19
- export declare const refreshAccessTokenAndSetAuthContext: ({ auth, onSetAuth, config, timeout, configURLS, onLogin, }: CreateApiProps & {
20
- configURLS?: ConfigType;
21
- }) => Promise<void>;
22
- export declare const createApiInstance: ({ auth, config: { baseURL }, timeout, }: CreateApiProps) => AxiosInstance;
23
- export declare const createNonAuthApiInstance: ({ config: { baseURL }, timeout, }: CreateApiProps) => AxiosInstance;
24
- export declare const fakeApiRequest: (signal?: AbortController) => Promise<void>;
25
- export declare const createFakeApiInstance: () => AxiosInstance;
26
- export declare const getCurrentTimeInSeconds: () => number;
27
- export declare const groupsToRoles: (groups: string[] | undefined, authConfig?: ConfigType) => Role[];
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- import React from 'react';
2
- import type { AuthenticationConfig, AuthenticationContextProps, AuthenticationDefaultStateProps } from './types';
3
- import type { Credentials } from '../ApiContext/types';
4
- export declare const getRandomString: () => string;
5
- export declare const getCodeChallenge: (codeVerifier: string) => Promise<string>;
6
- export declare const replaceTemplateKeys: (url: string, clientId: string, appUrl: string, oauthState?: string, codeChallenge?: string) => string;
7
- export declare const getAuthConfig: (_configUrls: AuthenticationConfig) => AuthenticationConfig;
8
- export declare const AuthenticationContext: React.Context<AuthenticationContextProps>;
9
- type OnAuthChange = (isLoggedIn: boolean, auth: Credentials | null) => void;
10
- export declare const setAuthChangeListener: (listener: OnAuthChange) => void;
11
- export declare const useAuthenticationDefaultProps: () => AuthenticationDefaultStateProps;
12
- interface AuthenticationProviderProps {
13
- children: React.ReactNode;
14
- value?: AuthenticationDefaultStateProps;
15
- configURLS?: AuthenticationConfig;
16
- }
17
- export declare const AuthenticationProvider: React.FC<AuthenticationProviderProps>;
18
- export declare const useAuthenticationContext: () => AuthenticationContextProps;
19
- export {};
@@ -1,10 +0,0 @@
1
- import React from 'react';
2
- import type { Credentials } from '../ApiContext/types';
3
- interface AuthenticationRenderTestComponentProps {
4
- auth: Credentials | null;
5
- newAuth: Credentials;
6
- onSetAuth: (auth: Credentials) => void;
7
- }
8
- export declare const resetNumRenders: () => void;
9
- declare const AuthenticationRenderTestComponent: React.FC<AuthenticationRenderTestComponentProps>;
10
- export default AuthenticationRenderTestComponent;
@@ -1,2 +0,0 @@
1
- export { useAuthenticationContext, AuthenticationProvider, useAuthenticationDefaultProps, AuthenticationContext, getAuthConfig, getRandomString, getCodeChallenge, setAuthChangeListener, } from './AuthenticationContext';
2
- export type * from './types';
@@ -1,25 +0,0 @@
1
- import type { SessionStorageProvider } from '@opengeoweb/shared';
2
- import type { Credentials, Role } from '../ApiContext/types';
3
- export interface AuthenticationConfig {
4
- GW_AUTH_LOGIN_URL: string;
5
- GW_AUTH_LOGOUT_URL: string;
6
- GW_AUTH_TOKEN_URL: string;
7
- GW_AUTH_ROLE_CLAIM_NAME?: string;
8
- GW_AUTH_ROLE_CLAIM_VALUE_PRESETS_ADMIN?: string;
9
- GW_APP_URL: string;
10
- GW_BE_VERSION_BASE_URL?: string;
11
- GW_AUTH_CLIENT_ID: string;
12
- }
13
- export interface AuthenticationDefaultStateProps {
14
- isLoggedIn: boolean;
15
- onLogin: (isLoggedIn: boolean) => void;
16
- auth: Credentials | null;
17
- onSetAuth: (auth: Credentials) => void;
18
- sessionStorageProvider: SessionStorageProvider;
19
- currentRole?: Role;
20
- setCurrentRole?: (newRole: Role) => void;
21
- }
22
- export interface AuthenticationContextProps extends AuthenticationDefaultStateProps {
23
- authConfig: AuthenticationConfig;
24
- }
25
- export type AuthChangeListener = (isLoggedIn: boolean, auth: Credentials | null) => void;
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- interface AuthTranslationWrapperProps {
3
- children?: React.ReactNode;
4
- }
5
- export declare const AuthI18nProvider: React.FC<AuthTranslationWrapperProps>;
6
- export declare const DemoWrapper: React.FC<AuthTranslationWrapperProps>;
7
- export {};
@@ -1 +0,0 @@
1
- export * from './Providers';
@@ -1,7 +0,0 @@
1
- import React from 'react';
2
- import type { Role } from '../ApiContext/types';
3
- export declare const UserMenuRoles: React.FC<{
4
- currentRole?: Role;
5
- onChangeRole?: (role: Role) => void;
6
- roles?: Role[];
7
- }>;
@@ -1 +0,0 @@
1
- export { UserMenuRoles } from './UserMenuRoles';
@@ -1 +0,0 @@
1
- export { useApi } from './useApi';
@@ -1,36 +0,0 @@
1
- import type { ConfigType } from '@opengeoweb/shared';
2
- export type ApiParams = string | ConfigType | Record<string, string | undefined> | null;
3
- interface BaseApiHookProps {
4
- fetchApiData?: (params: ApiParams) => Promise<void>;
5
- clearResults?: () => void;
6
- }
7
- type PendingApiHookProps = BaseApiHookProps & {
8
- isLoading: true;
9
- result: null;
10
- error: null;
11
- };
12
- type DoneApiHookProps<R> = BaseApiHookProps & {
13
- isLoading: false;
14
- result: R;
15
- error: null;
16
- };
17
- type ErrorApiHookProps = BaseApiHookProps & {
18
- isLoading: false;
19
- result: null;
20
- error: Error;
21
- };
22
- export type ApiHookProps<TData> = ErrorApiHookProps | PendingApiHookProps | DoneApiHookProps<TData>;
23
- interface Callbacks<TData> {
24
- onSuccess?: (data: TData) => void;
25
- onError?: (e: Error) => void;
26
- }
27
- export declare const useApi: <TResponse extends {
28
- data: unknown;
29
- } | {
30
- data: unknown;
31
- }[], TResult = TResponse extends {
32
- data: infer TData;
33
- }[] ? TData[] : TResponse extends {
34
- data: infer TData_1;
35
- } ? TData_1 : never>(apiCall?: (params?: any, id?: string) => Promise<TResponse>, params?: any, callbacks?: Callbacks<TResult>) => ApiHookProps<TResult>;
36
- export {};
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- import React from 'react';
2
- export declare const axiosInstance: import("axios").AxiosInstance;
3
- export declare const HandleOAuth2Code: React.FC;
4
- export default HandleOAuth2Code;
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- declare const OAuth2Login: React.FC;
3
- export default OAuth2Login;
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- import React from 'react';
2
- declare const OAuth2Logout: React.FC;
3
- export default OAuth2Logout;
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- export { default as Code } from './Code';
2
- export { default as Login } from './Login';
3
- export { default as Logout } from './Logout';
@@ -1,6 +0,0 @@
1
- import i18n from 'i18next';
2
- import type { UseTranslationResponse } from 'react-i18next';
3
- export declare const AUTH_NAMESPACE = "auth";
4
- export declare const initAuthTestI18n: () => void;
5
- export declare const useAuthenticationTranslation: () => UseTranslationResponse<typeof AUTH_NAMESPACE, typeof i18n>;
6
- export declare const translateInTestsAndStories: (key: string, params?: Record<string, string | number> | undefined) => string;
@@ -1,11 +0,0 @@
1
- export declare const mockloginSuccess: {
2
- access_token: string;
3
- refresh_token: string;
4
- id_token: string;
5
- };
6
- export declare const mockloginSuccessGitlab: {
7
- access_token: string;
8
- refresh_token: string;
9
- id_token: string;
10
- };
11
- export declare const mockloginFailed: {};
@@ -1 +0,0 @@
1
- export declare const getCurrentUrlLocation: (url: string, appUrl: string) => string;
@@ -1 +0,0 @@
1
- export {};