//native
type Clerk = {
apiKey: string;
};
/**
* Revoke a session
* Sets the status of a session as "revoked", which is an unauthenticated state.
In multi-session mode, a revoked session will still be returned along with its client object, however the user will need to sign in again.
*/
export async function main(auth: Clerk, session_id: string) {
const url = new URL(`https://api.clerk.com/v1/sessions/${session_id}/revoke`);
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Bearer " + auth.apiKey,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 428 days ago