@axa-fr/react-oidc 5.7.0-alpha0
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 +502 -0
- package/dist/FetchToken.d.ts +10 -0
- package/dist/FetchToken.d.ts.map +1 -0
- package/dist/FetchToken.js +107 -0
- package/dist/FetchToken.js.map +1 -0
- package/dist/OidcProvider.d.ts +25 -0
- package/dist/OidcProvider.d.ts.map +1 -0
- package/dist/OidcProvider.js +133 -0
- package/dist/OidcProvider.js.map +1 -0
- package/dist/OidcSecure.d.ts +10 -0
- package/dist/OidcSecure.d.ts.map +1 -0
- package/dist/OidcSecure.js +68 -0
- package/dist/OidcSecure.js.map +1 -0
- package/dist/OidcServiceWorker.js +272 -0
- package/dist/OidcTrustedDomains.js +6 -0
- package/dist/ReactOidc.d.ts +17 -0
- package/dist/ReactOidc.d.ts.map +1 -0
- package/dist/ReactOidc.js +106 -0
- package/dist/ReactOidc.js.map +1 -0
- package/dist/User.d.ts +15 -0
- package/dist/User.d.ts.map +1 -0
- package/dist/User.js +48 -0
- package/dist/User.js.map +1 -0
- package/dist/core/default-component/AuthenticateError.component.d.ts +4 -0
- package/dist/core/default-component/AuthenticateError.component.d.ts.map +1 -0
- package/dist/core/default-component/AuthenticateError.component.js +32 -0
- package/dist/core/default-component/AuthenticateError.component.js.map +1 -0
- package/dist/core/default-component/Authenticating.component.d.ts +4 -0
- package/dist/core/default-component/Authenticating.component.d.ts.map +1 -0
- package/dist/core/default-component/Authenticating.component.js +32 -0
- package/dist/core/default-component/Authenticating.component.js.map +1 -0
- package/dist/core/default-component/Callback.component.d.ts +5 -0
- package/dist/core/default-component/Callback.component.d.ts.map +1 -0
- package/dist/core/default-component/Callback.component.js +118 -0
- package/dist/core/default-component/Callback.component.js.map +1 -0
- package/dist/core/default-component/Loading.component.d.ts +4 -0
- package/dist/core/default-component/Loading.component.d.ts.map +1 -0
- package/dist/core/default-component/Loading.component.js +29 -0
- package/dist/core/default-component/Loading.component.js.map +1 -0
- package/dist/core/default-component/ServiceWorkerInstall.component.d.ts +4 -0
- package/dist/core/default-component/ServiceWorkerInstall.component.d.ts.map +1 -0
- package/dist/core/default-component/ServiceWorkerInstall.component.js +122 -0
- package/dist/core/default-component/ServiceWorkerInstall.component.js.map +1 -0
- package/dist/core/default-component/ServiceWorkerNotSupported.component.d.ts +4 -0
- package/dist/core/default-component/ServiceWorkerNotSupported.component.d.ts.map +1 -0
- package/dist/core/default-component/ServiceWorkerNotSupported.component.js +32 -0
- package/dist/core/default-component/ServiceWorkerNotSupported.component.js.map +1 -0
- package/dist/core/default-component/SessionLost.component.d.ts +4 -0
- package/dist/core/default-component/SessionLost.component.d.ts.map +1 -0
- package/dist/core/default-component/SessionLost.component.js +14 -0
- package/dist/core/default-component/SessionLost.component.js.map +1 -0
- package/dist/core/default-component/SilentCallback.component.d.ts +4 -0
- package/dist/core/default-component/SilentCallback.component.d.ts.map +1 -0
- package/dist/core/default-component/SilentCallback.component.js +96 -0
- package/dist/core/default-component/SilentCallback.component.js.map +1 -0
- package/dist/core/default-component/index.d.ts +7 -0
- package/dist/core/default-component/index.d.ts.map +1 -0
- package/dist/core/default-component/index.js +20 -0
- package/dist/core/default-component/index.js.map +1 -0
- package/dist/core/routes/OidcRoutes.d.ts +12 -0
- package/dist/core/routes/OidcRoutes.d.ts.map +1 -0
- package/dist/core/routes/OidcRoutes.js +71 -0
- package/dist/core/routes/OidcRoutes.js.map +1 -0
- package/dist/core/routes/index.d.ts +3 -0
- package/dist/core/routes/index.d.ts.map +1 -0
- package/dist/core/routes/index.js +9 -0
- package/dist/core/routes/index.js.map +1 -0
- package/dist/core/routes/route-utils.d.ts +2 -0
- package/dist/core/routes/route-utils.d.ts.map +1 -0
- package/dist/core/routes/route-utils.js +32 -0
- package/dist/core/routes/route-utils.js.map +1 -0
- package/dist/core/routes/withRouter.d.ts +19 -0
- package/dist/core/routes/withRouter.d.ts.map +1 -0
- package/dist/core/routes/withRouter.js +33 -0
- package/dist/core/routes/withRouter.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +19 -0
- package/dist/index.js.map +1 -0
- package/dist/vanilla/index.d.ts +2 -0
- package/dist/vanilla/index.d.ts.map +1 -0
- package/dist/vanilla/index.js +6 -0
- package/dist/vanilla/index.js.map +1 -0
- package/dist/vanilla/initSession.d.ts +11 -0
- package/dist/vanilla/initSession.d.ts.map +1 -0
- package/dist/vanilla/initSession.js +72 -0
- package/dist/vanilla/initSession.js.map +1 -0
- package/dist/vanilla/initWorker.d.ts +13 -0
- package/dist/vanilla/initWorker.d.ts.map +1 -0
- package/dist/vanilla/initWorker.js +211 -0
- package/dist/vanilla/initWorker.js.map +1 -0
- package/dist/vanilla/memoryStorageBackend.d.ts +10 -0
- package/dist/vanilla/memoryStorageBackend.d.ts.map +1 -0
- package/dist/vanilla/memoryStorageBackend.js +33 -0
- package/dist/vanilla/memoryStorageBackend.js.map +1 -0
- package/dist/vanilla/noHashQueryStringUtils.d.ts +5 -0
- package/dist/vanilla/noHashQueryStringUtils.d.ts.map +1 -0
- package/dist/vanilla/noHashQueryStringUtils.js +31 -0
- package/dist/vanilla/noHashQueryStringUtils.js.map +1 -0
- package/dist/vanilla/oidc.d.ts +77 -0
- package/dist/vanilla/oidc.d.ts.map +1 -0
- package/dist/vanilla/oidc.js +814 -0
- package/dist/vanilla/oidc.js.map +1 -0
- package/dist/vanilla/timer.d.ts +8 -0
- package/dist/vanilla/timer.d.ts.map +1 -0
- package/dist/vanilla/timer.js +135 -0
- package/dist/vanilla/timer.js.map +1 -0
- package/package.json +73 -0
- package/src/App.css +38 -0
- package/src/App.specold.tsx +46 -0
- package/src/App.tsx +61 -0
- package/src/FetchUser.tsx +53 -0
- package/src/Home.tsx +20 -0
- package/src/MultiAuth.tsx +114 -0
- package/src/Profile.tsx +77 -0
- package/src/configurations.ts +53 -0
- package/src/index.css +13 -0
- package/src/index.tsx +9 -0
- package/src/logo.svg +7 -0
- package/src/oidc/FetchToken.tsx +51 -0
- package/src/oidc/OidcProvider.tsx +165 -0
- package/src/oidc/OidcSecure.tsx +32 -0
- package/src/oidc/ReactOidc.tsx +112 -0
- package/src/oidc/User.ts +38 -0
- package/src/oidc/core/default-component/AuthenticateError.component.tsx +13 -0
- package/src/oidc/core/default-component/Authenticating.component.tsx +13 -0
- package/src/oidc/core/default-component/Callback.component.tsx +49 -0
- package/src/oidc/core/default-component/Loading.component.tsx +10 -0
- package/src/oidc/core/default-component/ServiceWorkerInstall.component.tsx +51 -0
- package/src/oidc/core/default-component/ServiceWorkerNotSupported.component.tsx +13 -0
- package/src/oidc/core/default-component/SessionLost.component.tsx +14 -0
- package/src/oidc/core/default-component/SilentCallback.component.tsx +31 -0
- package/src/oidc/core/default-component/index.ts +6 -0
- package/src/oidc/core/routes/OidcRoutes.spec.tsx +16 -0
- package/src/oidc/core/routes/OidcRoutes.tsx +69 -0
- package/src/oidc/core/routes/__snapshots__/OidcRoutes.spec.tsx.snap +7 -0
- package/src/oidc/core/routes/index.ts +2 -0
- package/src/oidc/core/routes/route-utils.spec.ts +9 -0
- package/src/oidc/core/routes/route-utils.ts +34 -0
- package/src/oidc/core/routes/withRouter.spec.tsx +48 -0
- package/src/oidc/core/routes/withRouter.tsx +60 -0
- package/src/oidc/index.ts +5 -0
- package/src/oidc/vanilla/OidcServiceWorker.js +272 -0
- package/src/oidc/vanilla/OidcTrustedDomains.js +6 -0
- package/src/oidc/vanilla/index.ts +1 -0
- package/src/oidc/vanilla/initSession.ts +36 -0
- package/src/oidc/vanilla/initWorker.ts +153 -0
- package/src/oidc/vanilla/memoryStorageBackend.ts +33 -0
- package/src/oidc/vanilla/noHashQueryStringUtils.ts +7 -0
- package/src/oidc/vanilla/oidc.ts +600 -0
- package/src/oidc/vanilla/timer.ts +157 -0
- package/src/override/AuthenticateError.component.tsx +14 -0
- package/src/override/Authenticating.component.tsx +14 -0
- package/src/override/Callback.component.tsx +13 -0
- package/src/override/Loading.component.tsx +13 -0
- package/src/override/ServiceWorkerNotSupported.component.tsx +15 -0
- package/src/override/SessionLost.component.tsx +21 -0
- package/src/override/style.ts +10 -0
- package/src/setupTests.js +5 -0
- package/tsconfig.json +38 -0
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
const timer = (function () {
|
|
2
|
+
const workerPort = (function () {
|
|
3
|
+
let worker;
|
|
4
|
+
let blobURL;
|
|
5
|
+
|
|
6
|
+
const workerCode = function () {
|
|
7
|
+
const innerIdsByOuterIds = {};
|
|
8
|
+
|
|
9
|
+
const methods = {
|
|
10
|
+
setTimeout: function (port, id, timeout) {
|
|
11
|
+
innerIdsByOuterIds[id] = setTimeout(function () {
|
|
12
|
+
port.postMessage(id);
|
|
13
|
+
innerIdsByOuterIds[id] = null;
|
|
14
|
+
}, timeout);
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
setInterval: function (port, id, timeout) {
|
|
18
|
+
innerIdsByOuterIds[id] = setInterval(function () {
|
|
19
|
+
port.postMessage(id);
|
|
20
|
+
}, timeout);
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
clearTimeout: function (port, id) {
|
|
24
|
+
clearTimeout(innerIdsByOuterIds[id]);
|
|
25
|
+
innerIdsByOuterIds[id] = null;
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
clearInterval: function (port, id) {
|
|
29
|
+
clearInterval(innerIdsByOuterIds[id]);
|
|
30
|
+
innerIdsByOuterIds[id] = null;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
function onMessage(port, event) {
|
|
35
|
+
var method = event.data[0];
|
|
36
|
+
var id = event.data[1];
|
|
37
|
+
var option = event.data[2];
|
|
38
|
+
|
|
39
|
+
if (methods[method]) {
|
|
40
|
+
methods[method](port, id, option);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// For Dedicated Worker
|
|
45
|
+
this.onmessage = function (event) {
|
|
46
|
+
onMessage(self, event);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// For Shared Worker
|
|
50
|
+
this.onconnect = function (event) {
|
|
51
|
+
const port = event.ports[0];
|
|
52
|
+
|
|
53
|
+
port.onmessage = function (event) {
|
|
54
|
+
onMessage(port, event);
|
|
55
|
+
};
|
|
56
|
+
};
|
|
57
|
+
}.toString();
|
|
58
|
+
|
|
59
|
+
try {
|
|
60
|
+
const blob = new Blob(['(', workerCode, ')()'], {type: 'application/javascript'});
|
|
61
|
+
blobURL = URL.createObjectURL(blob);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
return null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
try {
|
|
67
|
+
if (SharedWorker) {
|
|
68
|
+
worker = new SharedWorker(blobURL);
|
|
69
|
+
return worker.port;
|
|
70
|
+
}
|
|
71
|
+
} catch (error)
|
|
72
|
+
{
|
|
73
|
+
console.log("SharedWorker not available");
|
|
74
|
+
}
|
|
75
|
+
try {
|
|
76
|
+
if (Worker) {
|
|
77
|
+
worker = new Worker(blobURL);
|
|
78
|
+
return worker;
|
|
79
|
+
}
|
|
80
|
+
} catch (error)
|
|
81
|
+
{
|
|
82
|
+
console.log("Worker not available");
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return null;
|
|
86
|
+
}());
|
|
87
|
+
|
|
88
|
+
if (!workerPort) {
|
|
89
|
+
return {
|
|
90
|
+
setTimeout: setTimeout.bind(window),
|
|
91
|
+
clearTimeout: clearTimeout.bind(window),
|
|
92
|
+
setInterval: setInterval.bind(window),
|
|
93
|
+
clearInterval: clearInterval.bind(window)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const getId = (function () {
|
|
98
|
+
let currentId = 0;
|
|
99
|
+
|
|
100
|
+
return function () {
|
|
101
|
+
currentId++;
|
|
102
|
+
return currentId;
|
|
103
|
+
};
|
|
104
|
+
}());
|
|
105
|
+
|
|
106
|
+
const timeoutCallbacksById = {};
|
|
107
|
+
const intervalCallbacksById = {};
|
|
108
|
+
|
|
109
|
+
workerPort.onmessage = function (event) {
|
|
110
|
+
const id = event.data;
|
|
111
|
+
|
|
112
|
+
const timeoutCallback = timeoutCallbacksById[id];
|
|
113
|
+
if (timeoutCallback) {
|
|
114
|
+
timeoutCallback();
|
|
115
|
+
timeoutCallbacksById[id] = null;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const intervalCallback = intervalCallbacksById[id];
|
|
120
|
+
if (intervalCallback) {
|
|
121
|
+
intervalCallback();
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
function setTimeoutWorker(callback, timeout) {
|
|
126
|
+
const id = getId();
|
|
127
|
+
workerPort.postMessage(['setTimeout', id, timeout]);
|
|
128
|
+
timeoutCallbacksById[id] = callback;
|
|
129
|
+
return id;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function clearTimeoutWorker(id) {
|
|
133
|
+
workerPort.postMessage(['clearTimeout', id]);
|
|
134
|
+
timeoutCallbacksById[id] = null;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function setIntervalWorker(callback, timeout) {
|
|
138
|
+
const id = getId();
|
|
139
|
+
workerPort.postMessage(['setInterval', id, timeout]);
|
|
140
|
+
intervalCallbacksById[id] = callback;
|
|
141
|
+
return id;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function clearIntervalWorker(id) {
|
|
145
|
+
workerPort.postMessage(['clearInterval', id]);
|
|
146
|
+
intervalCallbacksById[id] = null;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
return {
|
|
150
|
+
setTimeout: setTimeoutWorker,
|
|
151
|
+
clearTimeout: clearTimeoutWorker,
|
|
152
|
+
setInterval: setIntervalWorker,
|
|
153
|
+
clearInterval: clearIntervalWorker
|
|
154
|
+
};
|
|
155
|
+
}());
|
|
156
|
+
|
|
157
|
+
export default timer;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import {ComponentType, PropsWithChildren} 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;
|
|
@@ -0,0 +1,14 @@
|
|
|
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;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, {ComponentType, PropsWithChildren} 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
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import {ComponentType, PropsWithChildren} 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;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import {ComponentType, PropsWithChildren} 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;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React, {ComponentType, PropsWithChildren} 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/tsconfig.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "es5",
|
|
4
|
+
"lib": ["es2015", "dom"],
|
|
5
|
+
"outDir": "dist",
|
|
6
|
+
"jsx": "react",
|
|
7
|
+
"module": "commonjs",
|
|
8
|
+
"declaration": true,
|
|
9
|
+
"declarationMap": true,
|
|
10
|
+
"sourceMap": true,
|
|
11
|
+
"strict": false,
|
|
12
|
+
"noImplicitAny": false,
|
|
13
|
+
"strictNullChecks": false,
|
|
14
|
+
"strictFunctionTypes": false,
|
|
15
|
+
"strictPropertyInitialization": false,
|
|
16
|
+
"noImplicitThis": false,
|
|
17
|
+
"alwaysStrict": false,
|
|
18
|
+
"noUnusedLocals": false,
|
|
19
|
+
"noUnusedParameters": false,
|
|
20
|
+
"noImplicitReturns": false,
|
|
21
|
+
"noFallthroughCasesInSwitch": true,
|
|
22
|
+
"moduleResolution": "node",
|
|
23
|
+
"resolveJsonModule": true,
|
|
24
|
+
"esModuleInterop": true,
|
|
25
|
+
"allowSyntheticDefaultImports": true
|
|
26
|
+
},
|
|
27
|
+
"include": ["src/oidc"],
|
|
28
|
+
"exclude": [
|
|
29
|
+
"node_modules",
|
|
30
|
+
"**/*.spec.ts",
|
|
31
|
+
"**/*.spec.tsx",
|
|
32
|
+
"**/*.test.ts",
|
|
33
|
+
"**/*.test.tsx",
|
|
34
|
+
"**/*.stories.tsx",
|
|
35
|
+
"./src/setupTests.ts"
|
|
36
|
+
],
|
|
37
|
+
"files": ["./src/oidc/index.ts"]
|
|
38
|
+
}
|