@axa-fr/react-oidc 6.0.0-alpha7 → 6.0.0-beta0
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/README.md +1 -1
- package/dist/OidcServiceWorker.js +8 -10
- package/dist/vanilla/initWorker.d.ts.map +1 -1
- package/dist/vanilla/initWorker.js +2 -3
- package/dist/vanilla/initWorker.js.map +1 -1
- package/dist/vanilla/oidc.d.ts.map +1 -1
- package/dist/vanilla/oidc.js +126 -102
- package/dist/vanilla/oidc.js.map +1 -1
- package/package.json +2 -2
- package/src/oidc/vanilla/OidcServiceWorker.js +8 -10
- package/src/oidc/vanilla/initWorker.ts +2 -3
- package/src/oidc/vanilla/oidc.ts +73 -73
- package/src/App.css +0 -38
- package/src/App.specold.tsx +0 -46
- package/src/App.tsx +0 -96
- package/src/FetchUser.tsx +0 -53
- package/src/Home.tsx +0 -22
- package/src/MultiAuth.tsx +0 -116
- package/src/Profile.tsx +0 -77
- package/src/configurations.ts +0 -70
- package/src/index.css +0 -13
- package/src/index.tsx +0 -9
- package/src/logo.svg +0 -7
- package/src/override/AuthenticateError.component.tsx +0 -14
- package/src/override/Authenticating.component.tsx +0 -14
- package/src/override/Callback.component.tsx +0 -13
- package/src/override/Loading.component.tsx +0 -13
- package/src/override/ServiceWorkerNotSupported.component.tsx +0 -15
- package/src/override/SessionLost.component.tsx +0 -21
- package/src/override/style.ts +0 -10
- package/src/setupTests.js +0 -5
package/src/Profile.tsx
DELETED
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import {OidcSecure, useOidcAccessToken, useOidcIdToken, useOidcUser, OidcUserStatus} from "./oidc";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const DisplayUserInfo = () => {
|
|
7
|
-
const{ oidcUser, oidcUserLoadingState } = useOidcUser();
|
|
8
|
-
|
|
9
|
-
switch (oidcUserLoadingState){
|
|
10
|
-
case OidcUserStatus.Loading:
|
|
11
|
-
return <p>User Information are loading</p>;
|
|
12
|
-
case OidcUserStatus.Unauthenticated:
|
|
13
|
-
return <p>you are not authenticated</p>;
|
|
14
|
-
case OidcUserStatus.LoadingError:
|
|
15
|
-
return <p>Fail to load user information</p>;
|
|
16
|
-
default:
|
|
17
|
-
return (
|
|
18
|
-
<div className="card text-white bg-success mb-3">
|
|
19
|
-
<div className="card-body">
|
|
20
|
-
<h5 className="card-title">User information</h5>
|
|
21
|
-
<p className="card-text">{JSON.stringify(oidcUser)}</p>
|
|
22
|
-
</div>
|
|
23
|
-
</div>
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const Profile = () => {
|
|
29
|
-
|
|
30
|
-
return (
|
|
31
|
-
<div className="container mt-3">
|
|
32
|
-
<DisplayAccessToken/>
|
|
33
|
-
<DisplayIdToken/>
|
|
34
|
-
<DisplayUserInfo/>
|
|
35
|
-
</div>
|
|
36
|
-
);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const DisplayAccessToken = () => {
|
|
40
|
-
const{ accessToken, accessTokenPayload } = useOidcAccessToken();
|
|
41
|
-
|
|
42
|
-
if(!accessToken){
|
|
43
|
-
return <p>you are not authenticated</p>
|
|
44
|
-
}
|
|
45
|
-
return (
|
|
46
|
-
<div className="card text-white bg-info mb-3">
|
|
47
|
-
<div className="card-body">
|
|
48
|
-
<h5 className="card-title">Access Token</h5>
|
|
49
|
-
<p style={{color:'red', "backgroundColor": 'white'}}>Please consider to configure the ServiceWorker in order to protect your application from XSRF attacks. "access_token" and "refresh_token" will never be accessible from your client side javascript.</p>
|
|
50
|
-
{<p className="card-text">Access Token: {JSON.stringify(accessToken)}</p>}
|
|
51
|
-
{accessTokenPayload != null && <p className="card-text">Access Token Payload: {JSON.stringify(accessTokenPayload)}</p>}
|
|
52
|
-
</div>
|
|
53
|
-
</div>
|
|
54
|
-
)
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const DisplayIdToken =() => {
|
|
59
|
-
const{ idToken, idTokenPayload } = useOidcIdToken();
|
|
60
|
-
|
|
61
|
-
if(!idToken){
|
|
62
|
-
return <p>you are not authenticated</p>
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<div className="card text-white bg-info mb-3">
|
|
67
|
-
<div className="card-body">
|
|
68
|
-
<h5 className="card-title">ID Token</h5>
|
|
69
|
-
{<p className="card-text">IdToken: {JSON.stringify(idToken)}</p>}
|
|
70
|
-
{idTokenPayload != null && <p className="card-text">IdToken Payload: {JSON.stringify(idTokenPayload)}</p>}
|
|
71
|
-
</div>
|
|
72
|
-
</div>
|
|
73
|
-
);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
export const SecureProfile = () => <OidcSecure><Profile /></OidcSecure>;
|
package/src/configurations.ts
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
export const configurationIdentityServer = {
|
|
2
|
-
client_id: 'interactive.public.short',
|
|
3
|
-
redirect_uri: window.location.origin+'/authentication/callback',
|
|
4
|
-
silent_redirect_uri: window.location.origin+'/authentication/silent-callback',
|
|
5
|
-
silent_signin_uri: window.location.origin+'/authentication/silent-sign-in',
|
|
6
|
-
scope: 'openid profile email api offline_access',
|
|
7
|
-
authority: 'https://demo.duendesoftware.com',
|
|
8
|
-
//authority_time_cache_wellknowurl_in_second: 60* 60,
|
|
9
|
-
refresh_time_before_tokens_expiration_in_second: 280,
|
|
10
|
-
service_worker_relative_url:'/OidcServiceWorker.js',
|
|
11
|
-
service_worker_only: false,
|
|
12
|
-
//storage: localStorage,
|
|
13
|
-
//silent_signin_timeout: 3333000
|
|
14
|
-
monitor_session:true,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export const configurationIdentityServerWithHash = {
|
|
18
|
-
client_id: 'interactive.public.short',
|
|
19
|
-
redirect_uri: window.location.origin+'/multi-auth/authentification#authentication-callback',
|
|
20
|
-
silent_redirect_uri: window.location.origin+'/multi-auth/authentification#authentication-silent-callback',
|
|
21
|
-
silent_signin_uri: window.location.origin+'#authentication-silent-signin',
|
|
22
|
-
scope: 'openid profile email api offline_access',
|
|
23
|
-
authority: 'https://demo.duendesoftware.com',
|
|
24
|
-
refresh_time_before_tokens_expiration_in_second: 70,
|
|
25
|
-
service_worker_relative_url:'/OidcServiceWorker.js',
|
|
26
|
-
service_worker_only: false,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export const configurationIdentityServerWithoutDiscovery = {
|
|
30
|
-
client_id: 'interactive.public.short',
|
|
31
|
-
redirect_uri: window.location.origin+'/authentication/callback',
|
|
32
|
-
silent_redirect_uri: window.location.origin+'/authentication/silent-callback',
|
|
33
|
-
silent_signin_uri: window.location.origin+'/authentication/silent-sign-in',
|
|
34
|
-
scope: 'openid profile email api offline_access',
|
|
35
|
-
authority: 'https://demo.duendesoftware.com',
|
|
36
|
-
authority_configuration: {
|
|
37
|
-
authorization_endpoint: 'https://demo.duendesoftware.com/connect/authorize',
|
|
38
|
-
token_endpoint: 'https://demo.duendesoftware.com/connect/token',
|
|
39
|
-
userinfo_endpoint: 'https://demo.duendesoftware.com/connect/userinfo',
|
|
40
|
-
end_session_endpoint: 'https://demo.duendesoftware.com/connect/endsession',
|
|
41
|
-
revocation_endpoint: 'https://demo.duendesoftware.com/connect/revocation',
|
|
42
|
-
},
|
|
43
|
-
refresh_time_before_tokens_expiration_in_second: 70,
|
|
44
|
-
service_worker_relative_url:'/OidcServiceWorker.js',
|
|
45
|
-
service_worker_only: false,
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export const configurationAuth0 = {
|
|
49
|
-
client_id: 'xGZxEAJhzlkuQUlWl90y1ntIX-0UDWHx',
|
|
50
|
-
redirect_uri: window.location.origin+'/callback',
|
|
51
|
-
scope: 'openid profile email api offline_access',
|
|
52
|
-
authority: 'https://kdhttps.auth0.com',
|
|
53
|
-
refresh_time_before_tokens_expiration_in_second: 70,
|
|
54
|
-
service_worker_relative_url:'/OidcServiceWorker.js',
|
|
55
|
-
service_worker_only: false,
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export const configurationGoogle = {
|
|
59
|
-
client_id: '908893276222-f2drloh56ll0g99md38lv2k810d0nk0p.apps.googleusercontent.com',
|
|
60
|
-
redirect_uri: `${window.location.origin}/multi-auth/callback-google`,
|
|
61
|
-
silent_redirect_uri: window.location.origin+'/multi-auth/silent-callback-google',
|
|
62
|
-
silent_signin_uri: window.location.origin+'/multi-auth/silent-signin-google',
|
|
63
|
-
scope: 'openid profile email',
|
|
64
|
-
authority: 'https://accounts.google.com/',
|
|
65
|
-
service_worker_relative_url:'/OidcServiceWorker.js',
|
|
66
|
-
service_worker_only: false,
|
|
67
|
-
token_request_extras: {
|
|
68
|
-
client_secret : "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"
|
|
69
|
-
}
|
|
70
|
-
};
|
package/src/index.css
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
body {
|
|
2
|
-
margin: 0;
|
|
3
|
-
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
|
|
4
|
-
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
|
|
5
|
-
sans-serif;
|
|
6
|
-
-webkit-font-smoothing: antialiased;
|
|
7
|
-
-moz-osx-font-smoothing: grayscale;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
code {
|
|
11
|
-
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
|
|
12
|
-
monospace;
|
|
13
|
-
}
|
package/src/index.tsx
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { createRoot } from 'react-dom/client';
|
|
3
|
-
import './index.css';
|
|
4
|
-
import App from './App';
|
|
5
|
-
import 'bootstrap/dist/css/bootstrap.min.css';
|
|
6
|
-
|
|
7
|
-
const container = document.getElementById('root');
|
|
8
|
-
const root = createRoot(container); // createRoot(container!) if you use TypeScript
|
|
9
|
-
root.render(<React.StrictMode><App/></React.StrictMode>);
|
package/src/logo.svg
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 841.9 595.3">
|
|
2
|
-
<g fill="#61DAFB">
|
|
3
|
-
<path d="M666.3 296.5c0-32.5-40.7-63.3-103.1-82.4 14.4-63.6 8-114.2-20.2-130.4-6.5-3.8-14.1-5.6-22.4-5.6v22.3c4.6 0 8.3.9 11.4 2.6 13.6 7.8 19.5 37.5 14.9 75.7-1.1 9.4-2.9 19.3-5.1 29.4-19.6-4.8-41-8.5-63.5-10.9-13.5-18.5-27.5-35.3-41.6-50 32.6-30.3 63.2-46.9 84-46.9V78c-27.5 0-63.5 19.6-99.9 53.6-36.4-33.8-72.4-53.2-99.9-53.2v22.3c20.7 0 51.4 16.5 84 46.6-14 14.7-28 31.4-41.3 49.9-22.6 2.4-44 6.1-63.6 11-2.3-10-4-19.7-5.2-29-4.7-38.2 1.1-67.9 14.6-75.8 3-1.8 6.9-2.6 11.5-2.6V78.5c-8.4 0-16 1.8-22.6 5.6-28.1 16.2-34.4 66.7-19.9 130.1-62.2 19.2-102.7 49.9-102.7 82.3 0 32.5 40.7 63.3 103.1 82.4-14.4 63.6-8 114.2 20.2 130.4 6.5 3.8 14.1 5.6 22.5 5.6 27.5 0 63.5-19.6 99.9-53.6 36.4 33.8 72.4 53.2 99.9 53.2 8.4 0 16-1.8 22.6-5.6 28.1-16.2 34.4-66.7 19.9-130.1 62-19.1 102.5-49.9 102.5-82.3zm-130.2-66.7c-3.7 12.9-8.3 26.2-13.5 39.5-4.1-8-8.4-16-13.1-24-4.6-8-9.5-15.8-14.4-23.4 14.2 2.1 27.9 4.7 41 7.9zm-45.8 106.5c-7.8 13.5-15.8 26.3-24.1 38.2-14.9 1.3-30 2-45.2 2-15.1 0-30.2-.7-45-1.9-8.3-11.9-16.4-24.6-24.2-38-7.6-13.1-14.5-26.4-20.8-39.8 6.2-13.4 13.2-26.8 20.7-39.9 7.8-13.5 15.8-26.3 24.1-38.2 14.9-1.3 30-2 45.2-2 15.1 0 30.2.7 45 1.9 8.3 11.9 16.4 24.6 24.2 38 7.6 13.1 14.5 26.4 20.8 39.8-6.3 13.4-13.2 26.8-20.7 39.9zm32.3-13c5.4 13.4 10 26.8 13.8 39.8-13.1 3.2-26.9 5.9-41.2 8 4.9-7.7 9.8-15.6 14.4-23.7 4.6-8 8.9-16.1 13-24.1zM421.2 430c-9.3-9.6-18.6-20.3-27.8-32 9 .4 18.2.7 27.5.7 9.4 0 18.7-.2 27.8-.7-9 11.7-18.3 22.4-27.5 32zm-74.4-58.9c-14.2-2.1-27.9-4.7-41-7.9 3.7-12.9 8.3-26.2 13.5-39.5 4.1 8 8.4 16 13.1 24 4.7 8 9.5 15.8 14.4 23.4zM420.7 163c9.3 9.6 18.6 20.3 27.8 32-9-.4-18.2-.7-27.5-.7-9.4 0-18.7.2-27.8.7 9-11.7 18.3-22.4 27.5-32zm-74 58.9c-4.9 7.7-9.8 15.6-14.4 23.7-4.6 8-8.9 16-13 24-5.4-13.4-10-26.8-13.8-39.8 13.1-3.1 26.9-5.8 41.2-7.9zm-90.5 125.2c-35.4-15.1-58.3-34.9-58.3-50.6 0-15.7 22.9-35.6 58.3-50.6 8.6-3.7 18-7 27.7-10.1 5.7 19.6 13.2 40 22.5 60.9-9.2 20.8-16.6 41.1-22.2 60.6-9.9-3.1-19.3-6.5-28-10.2zM310 490c-13.6-7.8-19.5-37.5-14.9-75.7 1.1-9.4 2.9-19.3 5.1-29.4 19.6 4.8 41 8.5 63.5 10.9 13.5 18.5 27.5 35.3 41.6 50-32.6 30.3-63.2 46.9-84 46.9-4.5-.1-8.3-1-11.3-2.7zm237.2-76.2c4.7 38.2-1.1 67.9-14.6 75.8-3 1.8-6.9 2.6-11.5 2.6-20.7 0-51.4-16.5-84-46.6 14-14.7 28-31.4 41.3-49.9 22.6-2.4 44-6.1 63.6-11 2.3 10.1 4.1 19.8 5.2 29.1zm38.5-66.7c-8.6 3.7-18 7-27.7 10.1-5.7-19.6-13.2-40-22.5-60.9 9.2-20.8 16.6-41.1 22.2-60.6 9.9 3.1 19.3 6.5 28.1 10.2 35.4 15.1 58.3 34.9 58.3 50.6-.1 15.7-23 35.6-58.4 50.6zM320.8 78.4z"/>
|
|
4
|
-
<circle cx="420.9" cy="296.5" r="45.7"/>
|
|
5
|
-
<path d="M520.5 78.1z"/>
|
|
6
|
-
</g>
|
|
7
|
-
</svg>
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import {ComponentType} from "react";
|
|
3
|
-
import {style} from "./style";
|
|
4
|
-
|
|
5
|
-
const AuthenticatingError: ComponentType<any> = ({configurationName}) => (
|
|
6
|
-
<div className="oidc-authenticating" style={style}>
|
|
7
|
-
<div className="oidc-authenticating__container">
|
|
8
|
-
<h1 className="oidc-authenticating__title">Error authentication for {configurationName}</h1>
|
|
9
|
-
<p className="oidc-authenticating__content">An error occurred during authentication.</p>
|
|
10
|
-
</div>
|
|
11
|
-
</div>
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
export default AuthenticatingError;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import {PropsWithChildren} from "react";
|
|
3
|
-
import {style} from "./style";
|
|
4
|
-
|
|
5
|
-
const Authenticating : PropsWithChildren<any> = ({configurationName}) => (
|
|
6
|
-
<div className="oidc-authenticating" style={style}>
|
|
7
|
-
<div className="oidc-authenticating__container">
|
|
8
|
-
<h1 className="oidc-authenticating__title">Authentication in progress for {configurationName}</h1>
|
|
9
|
-
<p className="oidc-authenticating__content">You will be redirected to the login page.</p>
|
|
10
|
-
</div>
|
|
11
|
-
</div>
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
export default Authenticating;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React, {ComponentType} from 'react';
|
|
2
|
-
import {style} from "./style";
|
|
3
|
-
|
|
4
|
-
export const CallBackSuccess: ComponentType<any> = ({configurationName}) => (<><div className="oidc-callback" style={style}>
|
|
5
|
-
<div className="oidc-callback__container">
|
|
6
|
-
<h1 className="oidc-callback__title">Authentication complete for {configurationName}</h1>
|
|
7
|
-
<p className="oidc-callback__content">You will be redirected to your application.</p>
|
|
8
|
-
</div>
|
|
9
|
-
</div>
|
|
10
|
-
<div>
|
|
11
|
-
</div>
|
|
12
|
-
</>
|
|
13
|
-
);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import {ComponentType } from "react";
|
|
3
|
-
import {style} from "./style";
|
|
4
|
-
|
|
5
|
-
const Loading : ComponentType<any> = ({children, configurationName}) => (
|
|
6
|
-
<>
|
|
7
|
-
<span className="oidc-loading" style={style}>
|
|
8
|
-
Loading for {configurationName}
|
|
9
|
-
</span>
|
|
10
|
-
</>
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
export default Loading;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import {ComponentType} from "react";
|
|
3
|
-
import {style} from "./style";
|
|
4
|
-
|
|
5
|
-
const ServiceWorkerNotSupported : ComponentType<any> = ({configurationName}) => (
|
|
6
|
-
<><div className="oidc-serviceworker" style={style}>
|
|
7
|
-
<div className="oidc-serviceworker__container">
|
|
8
|
-
<h1 className="oidc-serviceworker__title">Unable to authenticate on this browser for {configurationName}</h1>
|
|
9
|
-
<p className="oidc-serviceworker__content">Your browser is not secure enough to make authentication work. Try updating your browser or use a newer browser.</p>
|
|
10
|
-
</div>
|
|
11
|
-
</div>
|
|
12
|
-
</>
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
export default ServiceWorkerNotSupported;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React, {ComponentType} from 'react';
|
|
2
|
-
import {style} from "./style"
|
|
3
|
-
import {useOidc} from "../oidc";
|
|
4
|
-
|
|
5
|
-
export const SessionLost: ComponentType<any> = ({configurationName}) => {
|
|
6
|
-
const { login} = useOidc(configurationName);
|
|
7
|
-
|
|
8
|
-
return (<>
|
|
9
|
-
<div className="oidc-session-lost" style={style}>
|
|
10
|
-
<div className="oidc-session-lost__container">
|
|
11
|
-
<h1 className="oidc-session-lost__title">Session timed out for {configurationName}</h1>
|
|
12
|
-
<p className="oidc-session-lost__content">
|
|
13
|
-
Your session has expired. Please re-authenticate.
|
|
14
|
-
</p>
|
|
15
|
-
<button type="button" className="btn btn-primary" onClick={() => login(null)}>Login</button>
|
|
16
|
-
</div>
|
|
17
|
-
</div>
|
|
18
|
-
</>)
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default SessionLost;
|
package/src/override/style.ts
DELETED
package/src/setupTests.js
DELETED