auth module handles authentication for the current end user. Use it to register and log in users, rotate tokens, and run password and email-verification flows.
These functions run as the end user — there is no API key and no actor user ID.
signIn, signUp, and verifyExternalUser automatically store the returned tokens, and signOut clears them (see the auth section of the SDK overview).signUp
Registers a new user and stores the returned tokens.The user’s email address.
The user’s plain-text password (hashed server-side).
Display name for the user.
Unique username for the user.
URL of the user’s avatar image.
Short biography for the user.
The user’s geographic location.
The user’s birthdate as an ISO 8601 string.
Arbitrary key-value data attached to the user at creation time.
Sensitive key-value data attached to the user, not exposed to clients.
Promise<{ user: AuthUser; accessToken: string; refreshToken: string }>
signIn
Authenticates with email/password and stores the returned tokens.The user’s email address.
The user’s password.
Promise<{ user: AuthUser; accessToken: string; refreshToken: string }>
signOut
Signs the user out (revokes the refresh token) and clears stored tokens.The refresh token to revoke. Defaults to the SDK’s stored refresh token.
Promise<void>
verifyExternalUser
Exchanges a host-issued user JWT for Sublay tokens and stores them. Use this when your app manages its own auth.A JWT issued by your application, containing user identity claims.
Promise<{ user: AuthUser; accessToken: string; refreshToken: string }>
requestNewAccessToken
Manually rotates the access token using a refresh token. Normally this is handled automatically on a403 in SDK-managed mode.
The refresh token to exchange. Defaults to the SDK’s stored refresh token.
Persist the new
refreshToken if one is present (token rotation), or use SDK-managed mode, which does this for you.Promise<{ accessToken: string; refreshToken?: string }>
requestPasswordReset
Sends a password-reset email.The email address to send the reset link to.
Promise<void>
resetPassword
Completes a password reset using a token from the email.The reset token from the password reset email.
The new password to set for the account.
Promise<void>
changePassword
Changes the authenticated user’s password after verifying the current one. Use this for an authenticated “change password” flow, as opposed to the token-basedresetPassword.
The user’s current password (verified before the change).
The new password to set.
Promise<{ success: boolean; message: string }>
sendVerificationEmail
Sends (or re-sends) an email-verification message to the authenticated user, delivered as a code or a link."code" emails a short token the user enters; "link" emails a verification URL. Defaults to "code".Format of the generated token.
Length of the generated token.
For
mode: "link" — where to send the user after the link is verified.Promise<{ success: boolean }>
verifyEmail
Verifies a user’s email using a verification token.The email verification token.
Promise<void>
requestAccountDeletion
Starts self-service deletion of the authenticated user’s account by emailing them a one-time confirmation code (valid for 10 minutes). This does not delete anything on its own — pass the code toconfirmAccountDeletion to finish.
@sublay/node. The request fails with auth/no-email-on-file otherwise.
Takes no arguments.
Returns — Promise<{ success: boolean }>
confirmAccountDeletion
Verifies the emailed code and permanently deletes the authenticated user’s account. The cascade matches the service-key delete — entities and comments are kept as hollow shells; everything else owned by the user is removed.The one-time confirmation code from the deletion email.
Promise<void>
