Makes invites, and checks and claims them at sign-up. An invite works once, for UNUSED_INVITES_RETENTION_DAYS days. routes/invites.ts makes and checks them, and POST /api/users claims one.

Functions

f
claimInvite(token: string): string

Marks invite token used and returns the inviter's id. Call it before the async account creation, and releaseInvite if that fails: checking first and marking after would let parallel sign-ups share one invite.

f
createInvite(inviterId: string): string

Makes an invite from inviterId and returns its token, which the client puts in the invite link.

f
releaseInvite(token: string): void

Makes a claimed invite usable again, when the sign-up that claimed it failed.

f
validateInvite(token: string): string

Returns the id of the inviter when invite token is unused and still in its window, which is the one after which db/startup.ts purges it. It doesn't claim the invite: sign-up goes through claimInvite.