import { createClerkClient } from "@clerk/chrome-extension/background";

const CLERK_PUBLISHABLE_KEY = "pk_live_Y2xlcmsuZ2V0c2tpcGl0LmNvbSQ";
const CLERK_SYNC_HOST = "https://clerk.getskipit.com";

async function getAuthToken() {
  try {
    const clerk = await createClerkClient({
      publishableKey: CLERK_PUBLISHABLE_KEY,
      syncHost: CLERK_SYNC_HOST
    });

    if (!clerk || !clerk.session) {
      return null;
    }

    return await clerk.session.getToken();
  } catch (error) {
    console.warn("SafeScene Skipit auth error:", error);
    return null;
  }
}

globalThis.SafeSceneSkipitAuth = {
  getAuthToken
};
