Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | 5x 5x 5x 5x 5x 2x 3x 3x 1x 2x 2x 2x | export async function generateInviteToken(
email: string,
packageName: string,
csrfToken: string
): Promise<{ token: string; inviteLink: string }> {
const formData = new FormData();
formData.set("collaborators", email);
formData.set("csrf_token", csrfToken);
const response = await fetch(`/api/packages/${packageName}/invites`, {
method: "POST",
body: formData,
});
if (!response.ok) {
throw new Error("Failed to generate invite link");
}
const inviteData = await response.json();
if (!inviteData.success) {
throw new Error(inviteData.message);
}
const token = inviteData.data[0].token;
const inviteLink = `https://charmhub.io/accept-invite?package=${packageName}&token=${token}`;
return { token, inviteLink };
}
|