Exosphere is a set of small, modular, self-hostable community tools built on the AT Protocol.
app.exosphere.site
1import { signal } from "@preact/signals";
2
3interface AuthState {
4 loading: boolean;
5 authenticated: boolean;
6 did: string | null;
7 handle: string | null;
8}
9
10export const auth = signal<AuthState>({
11 loading: true,
12 authenticated: false,
13 did: null,
14 handle: null,
15});
16
17export async function checkSession() {
18 try {
19 const res = await fetch("/api/oauth/session");
20 const data = await res.json();
21 auth.value = {
22 loading: false,
23 authenticated: data.authenticated,
24 did: data.did ?? null,
25 handle: data.handle ?? null,
26 };
27 } catch {
28 auth.value = { loading: false, authenticated: false, did: null, handle: null };
29 }
30}
31
32export async function logout() {
33 await fetch("/api/oauth/logout", { method: "POST" });
34 auth.value = { loading: false, authenticated: false, did: null, handle: null };
35}