Skip to content

Commit

Permalink
Upgrade react-oidc to 6.16.14 & cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ludojmj committed Apr 22, 2023
1 parent a7db6ae commit 962f946
Show file tree
Hide file tree
Showing 9 changed files with 283 additions and 782 deletions.
2 changes: 1 addition & 1 deletion client/jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* a value or a type, so tell TypeScript to enforce using
* `import type` instead of `import` for Types.
*/
"importsNotUsedAsValues": "error",
"verbatimModuleSyntax": true,
"isolatedModules": true,
"resolveJsonModule": true,
/**
Expand Down
648 changes: 267 additions & 381 deletions client/package-lock.json

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
"preview": "vite preview"
},
"devDependencies": {
"@axa-fr/vanilla-oidc": "^6.16.0",
"@sveltejs/vite-plugin-svelte": "^2.0.2",
"axios": "^1.2.2",
"@axa-fr/vanilla-oidc": "^6.16.14",
"@sveltejs/vite-plugin-svelte": "^2.0.4",
"axios": "^1.3.5",
"bootstrap": "^5.2.3",
"sass": "^1.57.1",
"svelte": "^3.55.0",
"sass": "^1.61.0",
"svelte": "^3.58.0",
"svelte-navigator": "^3.2.2",
"vite": "^4.0.4"
"vite": "^4.2.1"
}
}
369 changes: 1 addition & 368 deletions client/public/OidcServiceWorker.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions client/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import "./variables.scss";
import { Router, Route } from "svelte-navigator";
import { crud } from "./lib/const.js";
import { userInfo } from "./lib/store.js";
import { tokens } from "./lib/store.js";
import AuthWrapper from "./components/oidc/AuthWrapper.svelte";
import CrudManager from "./components/CrudManager.svelte";
import StuffCreate from "./components/StuffCreate.svelte";
Expand Down Expand Up @@ -33,5 +33,5 @@
<Error msgErr="I got lost." hasReset={true} />
</Route>
</Router>
<pre>{JSON.stringify($userInfo, null, "\t")}</pre>
<pre>{JSON.stringify($tokens, null, "\t")}</pre>
</AuthWrapper>
3 changes: 1 addition & 2 deletions client/src/components/oidc/AuthWrapper.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@
// AuthWrapper.svelte
import { onMount } from "svelte";
import { isAuthLoading, tokens } from "../../lib/store.js";
import { getTokenAync, getUserAsync } from "../../lib/oidc.js";
import { getTokenAync } from "../../lib/oidc.js";
import Loading from "../common/Loading.svelte";
import Login from "./Login.svelte";
onMount(async () => {
await getTokenAync();
await getUserAsync();
});
</script>

Expand Down
7 changes: 4 additions & 3 deletions client/src/lib/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ export const configuration = {
silent_redirect_uri: window.location.origin + "/authentication/silent-callback",
scope: "openid profile email api offline_access",
authority: "https://demo.duendesoftware.com",
// service_worker_relative_url: "/OidcServiceWorker.js",
// service_worker_only: true,
// monitor_session: true
service_worker_relative_url: '/OidcServiceWorker.js',
service_worker_only: false,
silent_login_timeout: 1000,
monitor_session: true,
};

export const apiErrMsg = {
Expand Down
10 changes: 1 addition & 9 deletions client/src/lib/oidc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// oidc.js
import { VanillaOidc } from "@axa-fr/vanilla-oidc";
import { isAuthLoading, tokens, userInfo } from "./store.js";
import { isAuthLoading, tokens } from "./store.js";
import { configuration } from "./const.js";

const href = window.location.href;
Expand All @@ -23,14 +23,6 @@ export let getTokenAync = async () => {
});
};

export let getUserAsync = async () => {
vanillaOidc.getValidTokenAsync().then(() => {
vanillaOidc.userInfoAsync().then((result) => {
userInfo.set(result);
});
});
};

export const loginAsync = async () => {
await vanillaOidc.loginAsync("/");
};
Expand Down
10 changes: 0 additions & 10 deletions client/src/lib/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,6 @@
import { writable } from "svelte/store";

export const isAuthLoading = writable(false);
isAuthLoading.subscribe(value => value);

export const isLoading = writable(false);
isLoading.subscribe(value => value);

export const selectedItem = writable(JSON.parse(localStorage.getItem("selectedItem")) || {});
selectedItem.subscribe(val => localStorage.setItem("selectedItem", JSON.stringify(val)));

export const tokens = writable(null);
tokens.subscribe(value => value);

export const userInfo = writable(null);
userInfo.subscribe(value => value);

0 comments on commit 962f946

Please sign in to comment.