···66 BrowserOAuthClient,
77 OAuthSession,
88} from "@atproto/oauth-client-browser";
99+import { useRouter } from "@tanstack/react-router";
910import {
1011 createContext,
1112 ReactNode,
···2122 callbackHandler: (arg0: URLSearchParams) => void;
2223 handle: string | null;
2324 setHandle: (arg0: string) => void;
2525+ signOut: () => void;
2426} | null>(null);
25272628export const OAuthProvider = ({ children }: { children: ReactNode }) => {
···4850 [client],
4951 );
50525353+ // when we move this to a package, remove this.
5454+ const router = useRouter();
5555+5656+ const signOut = () => {
5757+ if (!session)
5858+ throw new Error(
5959+ "No OAuth session found. You should be careful about the ordering of your calls. Ensure that the client and the session is loaded before attempting to call `signOut` on the OAuth provider.",
6060+ );
6161+6262+ session.signOut();
6363+ setSession(null);
6464+ };
6565+6666+ // When we release the package, we need to remove this and replace it with a prop that takes in any effectful function and runs it here.
6767+ // For now, we just perform the effect.
6868+6969+ useEffect(() => {
7070+ router.invalidate();
7171+ }, [session]);
7272+5173 useEffect(() => {
5274 const oAuthClient = new BrowserOAuthClient({
5375 //@ts-expect-error fuck it we ball
···88110 callbackHandler,
89111 handle,
90112 setHandle,
113113+ signOut,
91114 };
9211593116 return <OAuthContext value={contextValue}>{children}</OAuthContext>;