Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/improsocial/impro
An extensible Bluesky client for web impro.social
Something went wrong. Try again.
HTML
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586<!doctype html><html lang="en"> <head> {% include "head.html" %} </head>
<body> <script type="module"> import { createAuth, OAuthProvider } from "/js/auth.js"; import { IdentityResolver } from "/js/atproto.js"; import { validateReturnToParam } from "/js/navigation.js";
async function main() { const auth = createAuth({ identityResolver: new IdentityResolver() });
if (!(auth.provider instanceof OAuthProvider)) { throw new Error("callback.html requires an OAuth provider on auth"); }
const params = new URLSearchParams(window.location.search);
const code = params.get("code"); const state = params.get("state"); const iss = params.get("iss"); const errorParam = params.get("error"); const errorDescription = params.get("error_description");
const parsedState = state ? JSON.parse(decodeURIComponent(state)) : null; const returnToFromState = parsedState ? validateReturnToParam(parsedState.returnTo) : null;
if (errorParam) { const errorParams = new URLSearchParams(); errorParams.set( "error_message", errorDescription ? `Login failed: ${errorDescription}` : `Login failed: ${errorParam}`, ); if (returnToFromState) { errorParams.set("returnTo", returnToFromState); } window.location.href = "/login?" + errorParams.toString(); return; }
if (!code || !state || !iss) { window.location.href = "/"; return; }
if ( parsedState.loopback === true && window.env.environment === "development" && window.location.hostname !== "localhost" ) { window.location.href = "http://localhost:8080/callback.html" + window.location.search; return; } try { await auth.provider.handleOauthCallback(window.location.href); window.location.href = returnToFromState ?? "/"; return; } catch (error) { console.error("error", error); const failureParams = new URLSearchParams(); failureParams.set( "error_message", "OAuth callback failed. Please try again.", ); if (returnToFromState) { failureParams.set("returnTo", returnToFromState); } window.location.href = "/login?" + failureParams.toString(); return; } } main(); </script> </body></html>