auth module handles user authentication flows server-side. This is useful for custom onboarding pipelines, admin-initiated account creation, token introspection, and password management.
All auth functions operate on behalf of your project. The caller is your server, authenticated via API key — not an end user.
signUp
Creates a new user account and returns credentials.Promise<{ user: AuthUser; accessToken: string; refreshToken: string }>
signIn
Authenticates an existing user and returns fresh credentials.Promise<{ user: AuthUser; accessToken: string; refreshToken: string }>
signOut
Invalidates a refresh token, ending the user’s session.Optional. The device the user is signing out on —
{ platform: "ios" | "android", token }
or { platform: "web", subscription }. When supplied (and the project has the
push bundle), the server deletes that user’s push binding for the device in the
same transaction as the sign-out. Omit it and the sign-out revokes the token
family only, leaving any push binding in place.Promise<void>
requestNewAccessToken
Exchanges a valid refresh token for a new access token.Promise<{ accessToken: string }>
verifyExternalUser
Verifies a signed JWT representing an externally-authenticated user and returns Sublay credentials. Use this when your application manages its own auth and you want to associate users with Sublay.Promise<{ user: AuthUser; accessToken: string; refreshToken: string }>
requestPasswordReset
Sends a password reset email to the specified address.Promise<void>
resetPassword
Completes a password reset using a token from the reset email. This revokes every session for that user and removes every push binding they hold, on every device — a reset is the remedy for a suspected compromise, so nothing is spared and there is no field to spare one with. ContrastchangePassword, which keeps the calling session and can keep one device’s binding. They sign in again everywhere, and each device re-binds for push on its own once it is next opened. Projects without the push bundle skip the binding step and are otherwise unaffected.
Promise<void>
verifyEmail
Marks a user’s email address as verified using a token from the verification email.Promise<void>
sendVerificationEmail
Sends (or re-sends) an email-verification message to a user. Verification can be delivered as a short code or as a clickable link.mode is always required, and it determines what else is required — enforced by TypeScript as a discriminated union, not just documented:
"code" emails a short token the user enters; "link" emails a verification URL.Format of the generated token.
- Required when
mode: "code"— there’s no default, since"hex"produces a 64-character token no one would want to type. - Optional when
mode: "link"(defaults to"hex") — the token sits in a URL, never read by a human, so format doesn’t matter.
Length of the generated token (4–12).
- Required when
mode: "code"andtokenFormatisn’t"hex". - Not allowed when
tokenFormatis"hex"— hex ignores length and always produces a fixed 64-character token. - Optional when
mode: "link"(defaults to6).
Promise<{ success: boolean }>
changePassword
Changes a user’s password, verifying their current password first. Use this for an authenticated “change password” flow (as opposed to the token-basedresetPassword).
A password change ends every session for that user and deletes every push binding they hold — see Change Password. A service key is not a session, so a call made with one has nothing to spare.
One device whose push binding should survive the change:
{ platform: "ios" | "android", token } or { platform: "web", subscription }.A server-side caller normally has no device to name and should omit this — every binding for the user then goes, which is the right default when acting on someone’s behalf. Supply it only when your own client told you which device it is on and you want that one to keep receiving notifications.Promise<{ success: boolean; message: string }>
