//native
type Clerk = {
apiKey: string;
};
/**
* Returns the markup for the interstitial page
* The Clerk interstitial endpoint serves an html page that loads clerk.js in order to check the user's authentication state.
It is used by Clerk SDKs when the user's authentication state cannot be immediately determined.
*/
export async function main(
auth: Clerk,
frontendApi: string | undefined,
publishable_key: string | undefined,
) {
const url = new URL(`https://api.clerk.com/v1/public/interstitial`);
for (const [k, v] of [
["frontendApi", frontendApi],
["publishable_key", publishable_key],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Bearer " + auth.apiKey,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.text();
}
Submitted by hugo697 428 days ago