diff --git a/src/components/output/raw/atproto/oauth.js b/src/components/output/raw/atproto/oauth.js index c9531373..1643617f 100644 --- a/src/components/output/raw/atproto/oauth.js +++ b/src/components/output/raw/atproto/oauth.js @@ -1,4 +1,3 @@ -import QS from "query-string"; import { configureOAuth } from "@atcute/oauth-browser-client"; import metadata from "../../../../oauth-client-metadata.json" with { @@ -44,14 +43,7 @@ let redirect_uri = (location.origin + location.pathname + location.search) const isLocalDev = redirect_uri.startsWith("http://127.0.0.1"); if (!isLocalDev) { - const url = new URL(location.href); - const params = Object.fromEntries(Array.from(url.searchParams.entries())); - - redirect_uri = location.origin + "/oauth/callback?" + QS.stringify({ - ...params, - redirect_path: location.pathname, - variant: url.pathname.replace(/(^\/+|\/+$)/g, "").split("/")[0], - }); + redirect_uri = location.origin + "/oauth/callback"; } configureOAuth({ @@ -95,6 +87,11 @@ export async function login(handle) { ); } + sessionStorage.setItem( + "diffuse/output/raw/atproto/oauth/redirect_path", + location.pathname + location.search, + ); + const authUrl = await createAuthorizationUrl({ target: { type: "account", identifier: /** @type {any} */ (handle) }, scope: SCOPE, diff --git a/src/oauth/callback/index.js b/src/oauth/callback/index.js index bd6c881d..5fda97c1 100644 --- a/src/oauth/callback/index.js +++ b/src/oauth/callback/index.js @@ -1,9 +1,5 @@ -const url = new URL(document.location.href); -const redirect_path = url.searchParams.get("redirect_path") ?? ""; +const prefix = "diffuse/output/raw/atproto/oauth"; +const redirect_path = sessionStorage.getItem(`${prefix}/redirect_path`) ?? "/"; -url.searchParams.delete("redirect_path"); -url.searchParams.delete("variant"); - -location.assign( - `${redirect_path}?${url.searchParams.toString()}${url.hash}`, -); +sessionStorage.removeItem(`${prefix}/redirect_path`); +location.assign(`${redirect_path}${location.hash}`);