@opengeoweb/authentication 9.6.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/package.json ADDED
@@ -0,0 +1,23 @@
1
+ {
2
+ "name": "@opengeoweb/authentication",
3
+ "version": "9.6.0",
4
+ "description": "GeoWeb authentication library for the opengeoweb project",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git@gitlab.com:opengeoweb/opengeoweb.git"
9
+ },
10
+ "dependencies": {
11
+ "axios": "1.5.0",
12
+ "@opengeoweb/api": "*",
13
+ "react-router-dom": "^6.21.0",
14
+ "@opengeoweb/shared": "*",
15
+ "@opengeoweb/theme": "*"
16
+ },
17
+ "peerDependencies": {
18
+ "react": "18"
19
+ },
20
+ "module": "./index.esm.js",
21
+ "type": "module",
22
+ "main": "./index.esm.js"
23
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ export { default as Code } from './lib/pages/Code';
2
+ export { default as Login } from './lib/pages/Login';
3
+ export { default as Logout } from './lib/pages/Logout';
4
+ export * from './lib/AuthenticationContext';
5
+ export * from './lib/PrivateRoute';
6
+ export * from './lib/utils/session';
7
+ export * from './lib/utils/utils';
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import { AuthenticationConfig, AuthenticationContextProps, AuthenticationDefaultStateProps } from './types';
3
+ export declare const getRandomString: () => string;
4
+ export declare const getCodeChallenge: (codeVerifier: string) => Promise<string>;
5
+ export declare const replaceTemplateKeys: (url: string, clientId: string, appUrl: string, oauthState?: string, codeChallenge?: string) => string;
6
+ export declare const getAuthConfig: (_configUrls: AuthenticationConfig) => AuthenticationConfig;
7
+ export declare const AuthenticationContext: React.Context<AuthenticationContextProps>;
8
+ export declare const useAuthenticationDefaultProps: () => AuthenticationDefaultStateProps;
9
+ interface AuthenticationProviderProps {
10
+ children: React.ReactNode;
11
+ value?: AuthenticationDefaultStateProps;
12
+ configURLS?: AuthenticationConfig;
13
+ }
14
+ export declare const AuthenticationProvider: React.FC<AuthenticationProviderProps>;
15
+ export declare const useAuthenticationContext: () => AuthenticationContextProps;
16
+ export {};
@@ -0,0 +1,10 @@
1
+ import * as React from 'react';
2
+ import { Credentials } from '@opengeoweb/api';
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;
@@ -0,0 +1,2 @@
1
+ export { useAuthenticationContext, AuthenticationProvider, useAuthenticationDefaultProps, AuthenticationContext, getAuthConfig, getRandomString, getCodeChallenge, } from './AuthenticationContext';
2
+ export * from './types';
@@ -0,0 +1,42 @@
1
+ import { Credentials } from '@opengeoweb/api';
2
+ export interface AuthenticationConfig {
3
+ GW_AUTH_LOGIN_URL: string;
4
+ GW_AUTH_LOGOUT_URL: string;
5
+ GW_AUTH_TOKEN_URL: string;
6
+ GW_APP_URL: string;
7
+ GW_AUTH_CLIENT_ID: string;
8
+ GW_INFRA_BASE_URL?: string;
9
+ }
10
+ export interface SessionStorageProvider {
11
+ setOauthState: (value: string) => void;
12
+ getOauthState: () => string;
13
+ removeOauthState: () => void;
14
+ setOauthCodeVerifier: (value: string) => void;
15
+ getOauthCodeVerifier: () => string;
16
+ removeOauthCodeVerifier: () => void;
17
+ setOauthCodeChallenge: (value: string) => void;
18
+ getOauthCodeChallenge: () => string;
19
+ removeOauthCodeChallenge: () => void;
20
+ setHasAuthenticated: (value: string) => void;
21
+ getHasAuthenticated: () => string;
22
+ removeHasAuthenticated: () => void;
23
+ getCallbackUrl: () => string;
24
+ setCallbackUrl: (value: string) => void;
25
+ }
26
+ export declare enum SessionStorageKey {
27
+ OAUTH_STATE = "oauth_state",
28
+ OAUTH_CODE_VERIFIER = "code_verifier",
29
+ OAUTH_CODE_CHALLENGE = "code_challenge",
30
+ HAS_AUTHENTICATED = "has_authenticated",
31
+ CALLBACK_URL = "callback_url"
32
+ }
33
+ export interface AuthenticationDefaultStateProps {
34
+ isLoggedIn: boolean;
35
+ onLogin: (isLoggedIn: boolean) => void;
36
+ auth: Credentials | null;
37
+ onSetAuth: (auth: Credentials) => void;
38
+ sessionStorageProvider: SessionStorageProvider;
39
+ }
40
+ export interface AuthenticationContextProps extends AuthenticationDefaultStateProps {
41
+ authConfig: AuthenticationConfig;
42
+ }
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ interface RequireAuthProps {
3
+ children: React.ReactElement;
4
+ }
5
+ export declare const RequireAuth: React.FC<RequireAuthProps>;
6
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from './RequireAuth';
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ export declare const axiosInstance: import("axios").AxiosInstance;
3
+ export declare const HandleOAuth2Code: React.FC;
4
+ export default HandleOAuth2Code;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const OAuth2Login: React.FC;
3
+ export default OAuth2Login;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const OAuth2Logout: React.FC;
3
+ export default OAuth2Logout;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,18 @@
1
+ export declare const mockloginSuccess: {
2
+ statusCode: number;
3
+ body: {
4
+ access_token: string;
5
+ refresh_token: string;
6
+ id_token: string;
7
+ };
8
+ };
9
+ export declare const mockloginSuccessGitlab: {
10
+ statusCode: number;
11
+ access_token: string;
12
+ refresh_token: string;
13
+ id_token: string;
14
+ };
15
+ export declare const mockloginFailed: {
16
+ statusCode: number;
17
+ body: {};
18
+ };
@@ -0,0 +1,2 @@
1
+ import { SessionStorageProvider } from '../AuthenticationContext/types';
2
+ export declare const getSessionStorageProvider: () => SessionStorageProvider;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export declare const getCurrentUrlLocation: (url: string, appUrl: string) => string;
@@ -0,0 +1 @@
1
+ export {};