Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

669 B
Raw Blame
import { supabase } from "@editor/auth/supabase";
import type { AppSession } from "@editor-cloud/auth/session";

export type { AppSession };

/**
 * SaaS (web) implementation of the @editor/auth/session seam.
 *
 * Reads the Supabase web session and returns its access token. Mirrors the
 * token lookup that apiClientSetup.getAuthHeaders performed previously.
 */
export async function getAccessToken(): Promise<string | null> {
  try {
    const {
      data: { session },
    } = await supabase.auth.getSession();
    return session?.access_token ?? null;
  } catch (e) {
    console.warn("[auth/session] Failed to read Supabase session", e);
    return null;
  }
}