//native
type Clerk = {
apiKey: string;
};
/**
* Create sign-in token
* Creates a new sign-in token and associates it with the given user.
By default, sign-in tokens expire in 30 days.
You can optionally supply a different duration in seconds using the `expires_in_seconds` property.
*/
export async function main(
auth: Clerk,
body: { user_id?: string; expires_in_seconds?: number },
) {
const url = new URL(`https://api.clerk.com/v1/sign_in_tokens`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + auth.apiKey,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago