diff --git a/README.md b/README.md
index 22ef4a9..4fe4b0f 100644
--- a/README.md
+++ b/README.md
@@ -220,4 +220,4 @@ jobs:
EOF
```
-You can also remove `oidc-spa`, `powerhooks` and `tsafe` from your dependencies.
+You can also remove `oidc-spa`, `powerhooks`, `zod` and `tsafe` from your dependencies.
diff --git a/package.json b/package.json
index 3ac061e..d6037e7 100755
--- a/package.json
+++ b/package.json
@@ -25,12 +25,13 @@
"keywords": [],
"dependencies": {
"evt": "^2.4.15",
- "oidc-spa": "^2.2.0",
- "keycloakify": "^9.1.4",
+ "oidc-spa": "^3.0.3",
+ "keycloakify": "^9.1.6",
"powerhooks": "^0.26.8",
"react": "18.1.0",
"react-dom": "18.1.0",
- "tsafe": "^1.6.0"
+ "tsafe": "^1.6.0",
+ "zod": "^3.22.4"
},
"devDependencies": {
"@types/node": "^15.3.1",
diff --git a/src/App/App.tsx b/src/App/App.tsx
index ed71f44..13633b8 100644
--- a/src/App/App.tsx
+++ b/src/App/App.tsx
@@ -1,44 +1,7 @@
import "./App.css";
import logo from "./logo.svg";
import myimg from "./myimg.png";
-import { useMemo } from "react";
-import { createOidcProvider, useOidc } from "oidc-spa/react";
-import { decodeJwt } from "oidc-spa";
-import { assert } from "tsafe/assert";
-
-//On older Keycloak version you need the /auth (e.g: http://localhost:8080/auth)
-//On newer version you must remove it (e.g: http://localhost:8080 )
-const keycloakUrl = "https://auth.code.gouv.fr/auth";
-const keycloakRealm = "keycloakify";
-const keycloakClientId= "starter";
-
-const { OidcProvider } = createOidcProvider({
- issuerUri: `${keycloakUrl}/realms/${keycloakRealm}`,
- clientId: keycloakClientId,
- // NOTE: You can also pass queries params when calling oidc.login()
- getExtraQueryParams: () => ({
- // This adding ui_locales to the url will ensure the consistency of the language between the app and the login pages
- // If your app implements a i18n system (like i18nifty.dev for example) you should use this and replace "en" by the
- // current language of the app.
- // On the other side you will find kcContext.locale.currentLanguageTag to be whatever you set here.
- "ui_locales": "en",
- "my_custom_param": "value of foo transferred to login page"
- }),
- /*
- * This parameter have to be provided provide if your App is not hosted at the origin of the subdomain.
- * For example if your site is hosted by navigating to `https://www.example.com`
- * you don't have to provide this parameter.
- * On the other end if your site is hosted by navigating to `https://www.example.com/my-app`
- * Then you want to set publicUrl to `/my-app`
- *
- * Be mindful that `${window.location.origin}${publicUrl}/silent-sso.html` must return the `silent-sso.html` that
- * you are supposed to have created in your `public/` directory.
- *
- * If your are still using `create-react-app` (like we are for now) you can just set
- * publicUrl to `process.env.PUBLIC_URL` and don't have to think about it further.
- */
- publicUrl: process.env.PUBLIC_URL
-});
+import { OidcProvider, useOidc, getKeycloakAccountUrl } from "./oidc";
export default function App() {
return (
@@ -48,25 +11,44 @@ export default function App() {
);
}
-
function ContextualizedApp() {
- const { oidc } = useOidc();
+ const { isUserLoggedIn, login, logout, oidcTokens } = useOidc();
return (