@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.
Files changed (160) hide show
  1. package/README.md +502 -0
  2. package/dist/FetchToken.d.ts +10 -0
  3. package/dist/FetchToken.d.ts.map +1 -0
  4. package/dist/FetchToken.js +107 -0
  5. package/dist/FetchToken.js.map +1 -0
  6. package/dist/OidcProvider.d.ts +25 -0
  7. package/dist/OidcProvider.d.ts.map +1 -0
  8. package/dist/OidcProvider.js +133 -0
  9. package/dist/OidcProvider.js.map +1 -0
  10. package/dist/OidcSecure.d.ts +10 -0
  11. package/dist/OidcSecure.d.ts.map +1 -0
  12. package/dist/OidcSecure.js +68 -0
  13. package/dist/OidcSecure.js.map +1 -0
  14. package/dist/OidcServiceWorker.js +272 -0
  15. package/dist/OidcTrustedDomains.js +6 -0
  16. package/dist/ReactOidc.d.ts +17 -0
  17. package/dist/ReactOidc.d.ts.map +1 -0
  18. package/dist/ReactOidc.js +106 -0
  19. package/dist/ReactOidc.js.map +1 -0
  20. package/dist/User.d.ts +15 -0
  21. package/dist/User.d.ts.map +1 -0
  22. package/dist/User.js +48 -0
  23. package/dist/User.js.map +1 -0
  24. package/dist/core/default-component/AuthenticateError.component.d.ts +4 -0
  25. package/dist/core/default-component/AuthenticateError.component.d.ts.map +1 -0
  26. package/dist/core/default-component/AuthenticateError.component.js +32 -0
  27. package/dist/core/default-component/AuthenticateError.component.js.map +1 -0
  28. package/dist/core/default-component/Authenticating.component.d.ts +4 -0
  29. package/dist/core/default-component/Authenticating.component.d.ts.map +1 -0
  30. package/dist/core/default-component/Authenticating.component.js +32 -0
  31. package/dist/core/default-component/Authenticating.component.js.map +1 -0
  32. package/dist/core/default-component/Callback.component.d.ts +5 -0
  33. package/dist/core/default-component/Callback.component.d.ts.map +1 -0
  34. package/dist/core/default-component/Callback.component.js +118 -0
  35. package/dist/core/default-component/Callback.component.js.map +1 -0
  36. package/dist/core/default-component/Loading.component.d.ts +4 -0
  37. package/dist/core/default-component/Loading.component.d.ts.map +1 -0
  38. package/dist/core/default-component/Loading.component.js +29 -0
  39. package/dist/core/default-component/Loading.component.js.map +1 -0
  40. package/dist/core/default-component/ServiceWorkerInstall.component.d.ts +4 -0
  41. package/dist/core/default-component/ServiceWorkerInstall.component.d.ts.map +1 -0
  42. package/dist/core/default-component/ServiceWorkerInstall.component.js +122 -0
  43. package/dist/core/default-component/ServiceWorkerInstall.component.js.map +1 -0
  44. package/dist/core/default-component/ServiceWorkerNotSupported.component.d.ts +4 -0
  45. package/dist/core/default-component/ServiceWorkerNotSupported.component.d.ts.map +1 -0
  46. package/dist/core/default-component/ServiceWorkerNotSupported.component.js +32 -0
  47. package/dist/core/default-component/ServiceWorkerNotSupported.component.js.map +1 -0
  48. package/dist/core/default-component/SessionLost.component.d.ts +4 -0
  49. package/dist/core/default-component/SessionLost.component.d.ts.map +1 -0
  50. package/dist/core/default-component/SessionLost.component.js +14 -0
  51. package/dist/core/default-component/SessionLost.component.js.map +1 -0
  52. package/dist/core/default-component/SilentCallback.component.d.ts +4 -0
  53. package/dist/core/default-component/SilentCallback.component.d.ts.map +1 -0
  54. package/dist/core/default-component/SilentCallback.component.js +96 -0
  55. package/dist/core/default-component/SilentCallback.component.js.map +1 -0
  56. package/dist/core/default-component/index.d.ts +7 -0
  57. package/dist/core/default-component/index.d.ts.map +1 -0
  58. package/dist/core/default-component/index.js +20 -0
  59. package/dist/core/default-component/index.js.map +1 -0
  60. package/dist/core/routes/OidcRoutes.d.ts +12 -0
  61. package/dist/core/routes/OidcRoutes.d.ts.map +1 -0
  62. package/dist/core/routes/OidcRoutes.js +71 -0
  63. package/dist/core/routes/OidcRoutes.js.map +1 -0
  64. package/dist/core/routes/index.d.ts +3 -0
  65. package/dist/core/routes/index.d.ts.map +1 -0
  66. package/dist/core/routes/index.js +9 -0
  67. package/dist/core/routes/index.js.map +1 -0
  68. package/dist/core/routes/route-utils.d.ts +2 -0
  69. package/dist/core/routes/route-utils.d.ts.map +1 -0
  70. package/dist/core/routes/route-utils.js +32 -0
  71. package/dist/core/routes/route-utils.js.map +1 -0
  72. package/dist/core/routes/withRouter.d.ts +19 -0
  73. package/dist/core/routes/withRouter.d.ts.map +1 -0
  74. package/dist/core/routes/withRouter.js +33 -0
  75. package/dist/core/routes/withRouter.js.map +1 -0
  76. package/dist/index.d.ts +6 -0
  77. package/dist/index.d.ts.map +1 -0
  78. package/dist/index.js +19 -0
  79. package/dist/index.js.map +1 -0
  80. package/dist/vanilla/index.d.ts +2 -0
  81. package/dist/vanilla/index.d.ts.map +1 -0
  82. package/dist/vanilla/index.js +6 -0
  83. package/dist/vanilla/index.js.map +1 -0
  84. package/dist/vanilla/initSession.d.ts +11 -0
  85. package/dist/vanilla/initSession.d.ts.map +1 -0
  86. package/dist/vanilla/initSession.js +72 -0
  87. package/dist/vanilla/initSession.js.map +1 -0
  88. package/dist/vanilla/initWorker.d.ts +13 -0
  89. package/dist/vanilla/initWorker.d.ts.map +1 -0
  90. package/dist/vanilla/initWorker.js +211 -0
  91. package/dist/vanilla/initWorker.js.map +1 -0
  92. package/dist/vanilla/memoryStorageBackend.d.ts +10 -0
  93. package/dist/vanilla/memoryStorageBackend.d.ts.map +1 -0
  94. package/dist/vanilla/memoryStorageBackend.js +33 -0
  95. package/dist/vanilla/memoryStorageBackend.js.map +1 -0
  96. package/dist/vanilla/noHashQueryStringUtils.d.ts +5 -0
  97. package/dist/vanilla/noHashQueryStringUtils.d.ts.map +1 -0
  98. package/dist/vanilla/noHashQueryStringUtils.js +31 -0
  99. package/dist/vanilla/noHashQueryStringUtils.js.map +1 -0
  100. package/dist/vanilla/oidc.d.ts +77 -0
  101. package/dist/vanilla/oidc.d.ts.map +1 -0
  102. package/dist/vanilla/oidc.js +814 -0
  103. package/dist/vanilla/oidc.js.map +1 -0
  104. package/dist/vanilla/timer.d.ts +8 -0
  105. package/dist/vanilla/timer.d.ts.map +1 -0
  106. package/dist/vanilla/timer.js +135 -0
  107. package/dist/vanilla/timer.js.map +1 -0
  108. package/package.json +73 -0
  109. package/src/App.css +38 -0
  110. package/src/App.specold.tsx +46 -0
  111. package/src/App.tsx +61 -0
  112. package/src/FetchUser.tsx +53 -0
  113. package/src/Home.tsx +20 -0
  114. package/src/MultiAuth.tsx +114 -0
  115. package/src/Profile.tsx +77 -0
  116. package/src/configurations.ts +53 -0
  117. package/src/index.css +13 -0
  118. package/src/index.tsx +9 -0
  119. package/src/logo.svg +7 -0
  120. package/src/oidc/FetchToken.tsx +51 -0
  121. package/src/oidc/OidcProvider.tsx +165 -0
  122. package/src/oidc/OidcSecure.tsx +32 -0
  123. package/src/oidc/ReactOidc.tsx +112 -0
  124. package/src/oidc/User.ts +38 -0
  125. package/src/oidc/core/default-component/AuthenticateError.component.tsx +13 -0
  126. package/src/oidc/core/default-component/Authenticating.component.tsx +13 -0
  127. package/src/oidc/core/default-component/Callback.component.tsx +49 -0
  128. package/src/oidc/core/default-component/Loading.component.tsx +10 -0
  129. package/src/oidc/core/default-component/ServiceWorkerInstall.component.tsx +51 -0
  130. package/src/oidc/core/default-component/ServiceWorkerNotSupported.component.tsx +13 -0
  131. package/src/oidc/core/default-component/SessionLost.component.tsx +14 -0
  132. package/src/oidc/core/default-component/SilentCallback.component.tsx +31 -0
  133. package/src/oidc/core/default-component/index.ts +6 -0
  134. package/src/oidc/core/routes/OidcRoutes.spec.tsx +16 -0
  135. package/src/oidc/core/routes/OidcRoutes.tsx +69 -0
  136. package/src/oidc/core/routes/__snapshots__/OidcRoutes.spec.tsx.snap +7 -0
  137. package/src/oidc/core/routes/index.ts +2 -0
  138. package/src/oidc/core/routes/route-utils.spec.ts +9 -0
  139. package/src/oidc/core/routes/route-utils.ts +34 -0
  140. package/src/oidc/core/routes/withRouter.spec.tsx +48 -0
  141. package/src/oidc/core/routes/withRouter.tsx +60 -0
  142. package/src/oidc/index.ts +5 -0
  143. package/src/oidc/vanilla/OidcServiceWorker.js +272 -0
  144. package/src/oidc/vanilla/OidcTrustedDomains.js +6 -0
  145. package/src/oidc/vanilla/index.ts +1 -0
  146. package/src/oidc/vanilla/initSession.ts +36 -0
  147. package/src/oidc/vanilla/initWorker.ts +153 -0
  148. package/src/oidc/vanilla/memoryStorageBackend.ts +33 -0
  149. package/src/oidc/vanilla/noHashQueryStringUtils.ts +7 -0
  150. package/src/oidc/vanilla/oidc.ts +600 -0
  151. package/src/oidc/vanilla/timer.ts +157 -0
  152. package/src/override/AuthenticateError.component.tsx +14 -0
  153. package/src/override/Authenticating.component.tsx +14 -0
  154. package/src/override/Callback.component.tsx +13 -0
  155. package/src/override/Loading.component.tsx +13 -0
  156. package/src/override/ServiceWorkerNotSupported.component.tsx +15 -0
  157. package/src/override/SessionLost.component.tsx +21 -0
  158. package/src/override/style.ts +10 -0
  159. package/src/setupTests.js +5 -0
  160. 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;
@@ -0,0 +1,10 @@
1
+ export const style = {
2
+ "color": "rgb(53,110,255)",
3
+ "backgroundColor": "rgb(255 255 255 / 88%)",
4
+ "position": "absolute",
5
+ "zIndex": 1000,
6
+ "top": "0px",
7
+ "bottom": "0px",
8
+ "right": "0px",
9
+ "left": "0px",
10
+ };
@@ -0,0 +1,5 @@
1
+ // jest-dom adds custom jest matchers for asserting on DOM nodes.
2
+ // allows you to do things like:
3
+ // expect(element).toHaveTextContent(/react/i)
4
+ // learn more: https://github.com/testing-library/jest-dom
5
+ import '@testing-library/jest-dom/extend-expect';
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
+ }