import { connect, type ClientAuth } from "@bijectionhq/bijection/client";
import type App from "../bijection/app";
const listeners = new Set<() => void>();
const auth: ClientAuth = {
token: async ({ refresh }) =>
(await auth0.isAuthenticated()) ? await auth0.getTokenSilently({ cacheMode: refresh ? "off" : "on" }) : null,
subscribe: (changed) => {
listeners.add(changed);
return () => listeners.delete(changed);
},
};
export const client = connect(url, { contract: "discover", token: auth });
// On principal, session, or audience changes, notify before yielding:
// for (const changed of listeners) changed();