JavaScript: Authentication
Sign app users up and in with email and password, magic links, email codes, SMS codes and social providers; manage sessions, MFA, users and roles with @sovaria/sdk.
sovaria.auth signs app users — the people who use your app — in and out of your project. The client keeps the session, sends it with every request, refreshes it before it expires and, in browsers, keeps it across reloads. Your policies and row-level security then decide what each user can do.
import { createClient } from '@sovaria/sdk'
const sovaria = createClient('https://<project-ref>.sovarias.in', '<anon-key>')
// Fires once right away with the current session, then on every sign-in, refresh and sign-out.
const stop = sovaria.auth.onAuthStateChange((event, session) => {
console.log(event, session?.user?.email)
})
await sovaria.auth.signUp('ada@example.com', 'Correct-Horse-9!', 'Ada')
await sovaria.auth.signIn('ada@example.com', 'Correct-Horse-9!')
console.log(sovaria.auth.getSession()?.user)
await sovaria.auth.signOut()
stop()#sovaria.auth
sovaria.auth.onAuthStateChange
Listen for sign-in, token refresh and sign-out.
sovaria.auth.onAuthStateChange(
callback: (event: AuthChangeEvent, session: SovariaSession | null) => void,
): AuthSubscriptionFires once right away with the current session (INITIAL_SESSION). Returns a function that stops listening.
Parameters
callback(event: AuthChangeEvent, session: SovariaSession | null) => voidrequired- Called with the event (
INITIAL_SESSION,SIGNED_IN,TOKEN_REFRESHED,SIGNED_OUT) and the session (ornull).
Returns
AuthSubscription — A function that stops listening.
sovaria.auth.signInWithPassword
Sign in with email and password, supabase-js style: const { data, error } = await sovaria.auth.signInWithPassword({ email, password }).
sovaria.auth.signInWithPassword(
credentials: { email?: string; phone?: string; password: string; options?: { captchaToken?: string } },
): Promise<AuthResponse>Never throws; data.mfa_required means call auth.verifyMfa(code) next.
Parameters
credentials{ email?: string; phone?: string; password: string; options?: { captchaToken?: string } }required
Returns
Promise<AuthResponse>
sovaria.auth.signInAnonymously
Sign in as a new anonymous user (turn it on in Authentication › Sign in / Providers).
sovaria.auth.signInAnonymously(
credentials?: { options?: { captchaToken?: string; data?: Record<string, unknown> } } = {},
): Promise<AuthResponse>The user can become permanent later with updateUser({ email, password }) or linkIdentity().
Parameters
credentials{ options?: { captchaToken?: string; data?: Record<string, unknown> } }optionaldefault{}
Returns
Promise<AuthResponse>
sovaria.auth.signInWithOAuth
"Sign in with Google / GitHub / …", supabase-js style: { data: { provider, url }, error }.
sovaria.auth.signInWithOAuth(
credentials: { provider: string; options?: { redirectTo?: string; skipBrowserRedirect?: boolean } },
): Promise<{ data: { provider: string; url: string; }; error: null; } | { data: { provider: string; url: null; }; error: SovariaError; }>The browser goes to the provider unless skipBrowserRedirect (then open data.url yourself, e.g. in a popup or an app's browser tab). It comes back to redirectTo with ?code=…&type=sso for handleEmailLink().
Parameters
credentials{ provider: string; options?: { redirectTo?: string; skipBrowserRedirect?: boolean } }required
Returns
Promise<{ data: { provider: string; url: string; }; error: null; } | { data: { provider: string; url: null; }; error: SovariaError; }>
sovaria.auth.signInWithOAuthNative
Provider sign-in from a React Native / Expo app: opens the provider in the system's auth browser session, waits for it to come back on redirectTo (your app's scheme, e.g.
sovaria.auth.signInWithOAuthNative(
credentials: { provider: string; redirectTo: string; openAuthSession: OpenAuthSession },
): Promise<AuthResponse>myapp://auth/callback, or an https app link) and exchanges the code with this app's PKCE verifier. Pass expo-web-browser's openAuthSessionAsync. Add redirectTo to the project's redirect allow-list (Authentication › URL configuration). Resolves to { data: { user, session }, error }; a cancelled sheet is an error with code AUTH_CANCELLED.
Parameters
credentials{ provider: string; redirectTo: string; openAuthSession: OpenAuthSession }required
Returns
Promise<AuthResponse>
sovaria.auth.completeOAuthNative
Finish a provider sign-in from the deep link that opened the app (when the link opened the app instead of returning to openAuthSession, e.g.
sovaria.auth.completeOAuthNative(
callbackUrl: string,
redirectTo: string,
): Promise<AuthResponse>after the app was closed). Only redirectTo links are accepted.
Parameters
callbackUrlstringrequiredredirectTostringrequired
Returns
Promise<AuthResponse>
sovaria.auth.signInWithIdToken
Native "Sign in with Apple / Google" (supabase-js signInWithIdToken): send the provider's ID token from the device and get a Sovaria session, { data: { user, session }, error }.
sovaria.auth.signInWithIdToken(
credentials: { provider: string; token: string; nonce?: string; accessToken?: string },
): Promise<AuthResponse>nonce is the raw nonce you gave the provider; the provider must be turned on in Authentication › Providers with this app's client ID.
Parameters
credentials{ provider: string; token: string; nonce?: string; accessToken?: string }required
Returns
Promise<AuthResponse>
sovaria.auth.signInWithThirdPartyToken
Keep your existing sign-in (Firebase Auth, Auth0, Clerk, Cognito, WorkOS or any OIDC issuer you trusted with sov auth-third-party add) and exchange its token for a Sovaria session: { data: { user, session }, error }.
sovaria.auth.signInWithThirdPartyToken(
token: string,
): Promise<AuthResponse>Parameters
tokenstringrequired
Returns
Promise<AuthResponse>
sovaria.auth.openLinkedApp
Linked Apps: open another app of your organization that an owner linked to this one (Organization › Linked apps), with the user already signed in.
sovaria.auth.openLinkedApp(
targetProjectId: string,
targetUrl: string,
opts?: { navigate?: boolean } = {},
): Promise<{ url: string; }>The other app's page (its SDK) asks Sovaria to come back signed in, this app gives it a one-time code for the signed-in user, and the other app finishes the sign-in with a secret only its own tab holds: a link someone else started never signs anyone in. Each app keeps its own session, account, roles and policies; nothing is shared between the apps' browsers. { navigate: false } returns the address.
Parameters
targetProjectIdstringrequiredtargetUrlstringrequiredopts{ navigate?: boolean }optionaldefault{}
Returns
Promise<{ url: string; }>
sovaria.auth.startLinkedSignIn
Linked Apps, step 1 (done on load): ask the app at sourceUrl for a one-time code back to returnUrl.
sovaria.auth.startLinkedSignIn(
sourceProjectId: string,
sourceUrl: string,
returnUrl: string,
): Promise<AuthResponse>Parameters
sourceProjectIdstringrequiredsourceUrlstringrequiredreturnUrlstringrequired
Returns
Promise<AuthResponse>
sovaria.auth.continueLinkedApp
Linked Apps, step 2 (done on load when signed in): give the app that asked a one-time code and go back to it.
sovaria.auth.continueLinkedApp(
requestId?: string,
): Promise<AuthResponse>Not signed in yet: call it after sign-in with no argument (the request waits in this tab for 5 minutes).
Parameters
requestIdstringoptional
Returns
Promise<AuthResponse>
sovaria.auth.signInWithLinkedHandoff
Linked Apps, step 3 (done on load): exchange the code with this tab's PKCE verifier for this app's session.
sovaria.auth.signInWithLinkedHandoff(
code: string,
codeVerifier: string,
): Promise<AuthResponse>Parameters
codestringrequiredcodeVerifierstringrequired
Returns
Promise<AuthResponse>
sovaria.auth.linkedHandoffResult
The sign-in from a linked-app link found when this client started (null when the page had none).
sovaria.auth.linkedHandoffResult(): Promise<AuthResponse> | nullReturns
Promise<AuthResponse> | null
sovaria.auth.signInWithOtp
Passwordless sign-in, supabase-js style: { email } emails a sign-in link plus a 6-digit code (finish with verifyOtp({ email, token }) or handleEmailLink()); { phone } texts a code (verifyOtp({ phone, token })).
sovaria.auth.signInWithOtp(
credentials: { email?: string phone?: string options?: { emailRedirectTo?: string; captchaToken?: string; shouldCreateUser?: boolean; data?: Record<string, unknown> } },
): Promise<AuthResponse>Parameters
credentials{ email?: string phone?: string options?: { emailRedirectTo?: string; captchaToken?: string; shouldCreateUser?: boolean; data?: Record<string, unknown> } }required
Returns
Promise<AuthResponse>
sovaria.auth.getUser
The signed-in user from the server, supabase-js style: const { data: { user } } = await sovaria.auth.getUser().
sovaria.auth.getUser(
): Promise<{ data: { user: AuthUser | null; }; error: SovariaError | null; }>user is null (and error says why) when nobody is signed in.
Returns
Promise<{ data: { user: AuthUser | null; }; error: SovariaError | null; }>
sovaria.auth.updateUser
Change the signed-in user's metadata, email or password (PATCH /auth/me), supabase-js style: await sovaria.auth.updateUser({ data: { theme: 'dark' } }).
sovaria.auth.updateUser(
attributes: UpdateUserAttributes,
options?: { emailRedirectTo?: string } = {},
): Promise<{ data: { user: AuthUser | null; }; error: SovariaError | null; }>A new email is confirmed by a link first. An anonymous user who adds an email (and a password) becomes permanent.
Parameters
attributesUpdateUserAttributesrequiredoptions{ emailRedirectTo?: string }optionaldefault{}
Returns
Promise<{ data: { user: AuthUser | null; }; error: SovariaError | null; }>
sovaria.auth.getSession
The signed-in app user's session, or null.
sovaria.auth.getSession(
): SovariaSession | Promise<{ data: { session: { token_type: "bearer"; user: AuthUser | null; access_token: string; refresh_token?: string | undefined; expires_at: number; } | null; }; error: null; }> | nullIn results: 'supabase' mode it resolves to supabase-js's { data: { session }, error }; otherwise a non-null session also has .data.session, so const { data: { session } } = await sovaria.auth.getSession() works in both.
Returns
SovariaSession | Promise<{ data: { session: { token_type: "bearer"; user: AuthUser | null; access_token: string; refresh_token?: string | undefined; expires_at: number; } | null; }; error: null; }> | null — The current session, or null when nobody is signed in (no network call). In results: 'supabase' mode it resolves to { data: { session }, error } like supabase-js; otherwise a session also answers .data.session, so supabase code works in both.
sovaria.auth.refreshSession
Refresh the session now (supabase-js): { data: { session, user }, error }.
sovaria.auth.refreshSession(
current?: { refresh_token?: string },
): Promise<AuthResponse>Parameters
current{ refresh_token?: string }optional
Returns
Promise<AuthResponse> — { data: { user, session }, error } after a refresh now (the SDK also refreshes by itself before expiry).
sovaria.auth.setSession
Sign in with tokens you already have (from a server, another tab or a native app).
sovaria.auth.setSession(
tokens: { access_token: string; refresh_token: string },
): Promise<AuthResponse>Parameters
tokens{ access_token: string; refresh_token: string }requiredaccess_tokenandrefresh_tokenyou already have (a server, another tab, a native app).
Returns
Promise<AuthResponse> — { data: { user, session }, error }.
await sovaria.auth.setSession({ access_token, refresh_token })sovaria.auth.reauthenticate
Email/text the signed-in user a one-time code to prove a recent sign-in; pass it as updateUser({ nonce }).
sovaria.auth.reauthenticate(): Promise<AuthResponse>Returns
Promise<AuthResponse> — { data, error }. Sends the signed-in user a one-time code; pass it as updateUser({ password, nonce }) when the project asks for a recent sign-in.
sovaria.auth.getUserId
The signed-in app user's id (the session token's subject), or null for visitors.
sovaria.auth.getUserId(): string | nullFor showing "mine" in the UI and for filters; owner columns are filled in by the database, so writes don't need it.
Returns
string | null
sovaria.auth.signOut
Sign the app user out and fall back to the anon key, supabase-js style: const { error } = await sovaria.auth.signOut().
sovaria.auth.signOut(
options?: { scope?: 'global' | 'local' | 'others' } = {},
): Promise<{ error: SovariaError | null; }>Never throws. scope: 'local' (default) revokes this session; 'global' also signs out every other device; 'others' signs out the other devices and keeps this one. This device is signed out locally even when the server can't be reached (then error says so).
Parameters
options{ scope?: 'global' | 'local' | 'others' }optionaldefault{}
Returns
Promise<{ error: SovariaError | null; }> — Resolves when the refresh token is revoked; the client then acts as an anonymous visitor (anon key).
sovaria.auth.signUp
Create an app user and sign them in.
sovaria.auth.signUp(
emailOrCredentials: string | SignUpCredentials,
password?: string,
name?: string = '',
): Promise<JsonObject | AuthResponse>When the project requires email confirmation, the result has email_verification_required: true and no session until the user confirms.
Parameters
emailOrCredentialsstring | SignUpCredentialsrequiredpasswordstringoptional- Must meet the project's password rules (Authentication → Settings).
namestringoptionaldefault''- Display name stored on the user.
Returns
Promise<JsonObject | AuthResponse> — The new user and a session — or email_verification_required: true and no session when the project requires email confirmation first.
- Fails with
403 SIGNUP_DISABLEDwhen new sign-ups are turned off for the project.
const result = await sovaria.auth.signUp('ada@example.com', 'Correct-Horse-9!', 'Ada')
if (result.email_verification_required) {
showMessage('Check your inbox to confirm your email.')
}sovaria.auth.signIn
Sign an app user in with email and password (same as projectLogin).
sovaria.auth.signIn(
email: string,
password: string,
): Promise<JsonObject>Parameters
emailstringrequired- The user's email address.
passwordstringrequired- Their password.
Returns
Promise<JsonObject> — The session; afterwards every request from this client runs as the user.
- If the user has MFA turned on, finish with
auth.verifyMfa(code).
try {
await sovaria.auth.signIn(email, password)
} catch (err) {
if (err.statusCode === 401) showError('Wrong email or password')
else throw err
}sovaria.auth.register
Create an app user (no session).
sovaria.auth.register(
email: string,
password: string,
name: string,
opts?: { captchaToken?: string; data?: Record<string, unknown> } = {},
): Promise<JsonObject>Most apps want signUp(), which also signs them in.
Parameters
emailstringrequiredpasswordstringrequirednamestringrequiredopts{ captchaToken?: string; data?: Record<string, unknown> }optionaldefault{}
Returns
Promise<JsonObject>
- Most apps want
signUp, which also signs the user in.
sovaria.auth.login
Login.
sovaria.auth.login(email: string, password: string): Promise<JsonObject>Parameters
emailstringrequiredpasswordstringrequired
Returns
Promise<JsonObject>
sovaria.auth.consoleLogin
Strict console login — rejects every project-scoped credential.
sovaria.auth.consoleLogin(
email: string,
password: string,
): Promise<JsonObject>Parameters
emailstringrequiredpasswordstringrequired
Returns
Promise<JsonObject>
- For scripts acting as a team member (managing the project). Never use it for app users.
sovaria.auth.loginConsole
Alias for consoleLogin() matching lane terminology in docs.
sovaria.auth.loginConsole(
email: string,
password: string,
): Promise<JsonObject>Parameters
emailstringrequiredpasswordstringrequired
Returns
Promise<JsonObject>
sovaria.auth.projectLogin
Strict project login — requires X-Sovaria-Org-ID + X-Sovaria-Project-ID.
sovaria.auth.projectLogin(
email: string,
password: string,
opts?: { captchaToken?: string } = {},
): Promise<JsonObject>Parameters
emailstringrequiredpasswordstringrequiredopts{ captchaToken?: string }optionaldefault{}
Returns
Promise<JsonObject>
sovaria.auth.loginProduct
Alias for projectLogin() matching lane terminology in docs.
sovaria.auth.loginProduct(
email: string,
password: string,
): Promise<JsonObject>Parameters
emailstringrequiredpasswordstringrequired
Returns
Promise<JsonObject>
sovaria.auth.refresh
Swap the refresh token for new tokens.
sovaria.auth.refresh(refreshToken?: string): Promise<JsonObject>Without an argument (or with the session's own token) concurrent calls share one rotation: two rotations of the same refresh token read as token theft and sign the session out.
Parameters
refreshTokenstringoptional
Returns
Promise<JsonObject>
sovaria.auth.logout
Logout.
sovaria.auth.logout(refreshToken?: string): Promise<JsonObject>Parameters
refreshTokenstringoptional
Returns
Promise<JsonObject>
sovaria.auth.me
Me.
sovaria.auth.me(): Promise<JsonObject>Returns
Promise<JsonObject> — The signed-in user's profile (id, email, roles, metadata).
sovaria.auth.verifyMfa
Verify mfa.
sovaria.auth.verifyMfa(
code: string,
method?: 'totp' | 'phone' = 'totp',
): Promise<JsonObject>Parameters
codestringrequired- The 6-digit code from the authenticator app (or SMS).
method'totp' | 'phone'optionaldefault'totp'totpfor an authenticator app,phonefor SMS.
Returns
Promise<JsonObject>
sovaria.auth.sendMagicLink
Email a sign-in link (plus a 6-digit code).
sovaria.auth.sendMagicLink(
email: string,
opts?: { orgId?: string; projectId?: string; redirectTo?: string; pkce?: boolean; createUser?: boolean; data?: Record<string, unknown>; captchaToken?: string } = {},
): Promise<JsonObject>A link that opens a mobile app (myapp://… or a registered app link) is bound to this app with PKCE automatically; pass pkce: true to force it.
Parameters
emailstringrequired- Where to send the link.
opts{ orgId?: string; projectId?: string; redirectTo?: string; pkce?: boolean; createUser?: boolean; data?: Record<string, unknown>; captchaToken?: string }optionaldefault{}redirectTo: the page of your app the link opens (must be an allowed redirect URL);orgId/projectIdonly when the client has no project scope.
Returns
Promise<JsonObject>
- Always succeeds, whether or not the address has an account, so it can't be used to discover users.
await sovaria.auth.sendMagicLink('ada@example.com', { redirectTo: 'https://app.example.com/auth/callback' })sovaria.auth.resetPasswordForEmail
Email a password-reset link.
sovaria.auth.resetPasswordForEmail(
email: string,
opts?: { orgId?: string; projectId?: string; redirectTo?: string; pkce?: boolean; captchaToken?: string } = {},
): Promise<JsonObject | { data: {}; error: null; } | { data: null; error: SovariaError; }>Returns 200 even for unknown emails.
Parameters
emailstringrequired- The account's email.
opts{ orgId?: string; projectId?: string; redirectTo?: string; pkce?: boolean; captchaToken?: string }optionaldefault{}redirectTo: your page that sets the new password.
Returns
Promise<JsonObject | { data: {}; error: null; } | { data: null; error: SovariaError; }>
await sovaria.auth.resetPasswordForEmail(email, { redirectTo: 'https://app.example.com/reset' })sovaria.auth._sendPasswordReset
_send password reset.
sovaria.auth._sendPasswordReset(
email: string,
opts?: { orgId?: string; projectId?: string; redirectTo?: string; pkce?: boolean } = {},
): Promise<JsonObject>Parameters
emailstringrequiredopts{ orgId?: string; projectId?: string; redirectTo?: string; pkce?: boolean }optionaldefault{}
Returns
Promise<JsonObject>
sovaria.auth.confirmPasswordReset
Set a new password with the token from a reset link (type=recovery).
sovaria.auth.confirmPasswordReset(
token: string,
newPassword: string,
codeVerifier?: string,
): Promise<JsonObject>Parameters
tokenstringrequired- The
tokenfrom the reset link. newPasswordstringrequired- The new password (same rules as sign-up).
codeVerifierstringoptional
Returns
Promise<JsonObject>
{
"status": "password_updated",
"user_id": "6e19c0a2-3f5b-4a8e-9b1d-0c7f2e8a4d51"
}sovaria.auth.handleEmailLink
Handle the link an auth email opened (?token=…&type=… on your Site URL).
sovaria.auth.handleEmailLink(
url?: string,
opts?: { allowAccountSwitch?: boolean } = {},
): Promise<{ type: string; error: string; description: string | undefined; session?: undefined; result?: undefined; token?: undefined; } | { type: string; session: JsonObject; error?: undefined; description?: undefined; result?: undefined; token?: undefined; } | { type: string; result: JsonObject; error?: undefined; description?: undefined; session?: undefined; token?: undefined; } | { type: string; token: string; error?: undefined; description?: undefined; session?: undefined; result?: undefined; } | null>Magic links sign the user in; email confirmations are confirmed; for recovery the token is returned so you can show a "new password" form and call confirmPasswordReset. Returns null when the URL isn't an auth link.
Magic links opened on another device still work (no PKCE verifier here). A link for a *different* account than the one already signed in is refused with error: 'ACCOUNT_SWITCH_REFUSED' (its session is ended at once), so a link someone sends you can't silently swap your session; pass { allowAccountSwitch: true } after asking the user.
Parameters
urlstringoptional- The URL to read; defaults to the current page.
opts{ allowAccountSwitch?: boolean }optionaldefault{}
Returns
Promise<{ type: string; error: string; description: string | undefined; session?: undefined; result?: undefined; token?: undefined; } | { type: string; session: JsonObject; error?: undefined; description?: undefined; result?: undefined; token?: undefined; } | { type: string; result: JsonObject; error?: undefined; description?: undefined; session?: undefined; token?: undefined; } | { type: string; token: string; error?: undefined; description?: undefined; session?: undefined; result?: undefined; } | null> — { type, error, … } — type is what the link did (sign-in, email verification, password recovery, email change).
// On the page your auth emails link to (your Site URL or redirectTo):
const { type, error } = await sovaria.auth.handleEmailLink()
if (error) showError(error)
else if (type === 'recovery') router.push('/set-new-password')
else router.push('/')sovaria.auth.signInWithProvider
"Sign in with Google / GitHub / …" (providers connected in Authentication › Sign in / Providers).
sovaria.auth.signInWithProvider(
providerId: string,
opts?: { redirectTo?: string; projectId?: string } = {},
): Promise<{ url: string; }>Sends the browser to the provider; it comes back to redirectTo (or your Site URL) with ?code=…&type=sso, which handleEmailLink() / exchangeCodeForSession() turn into a session. A PKCE verifier is kept in sessionStorage so only this browser can redeem the code.
Parameters
providerIdstringrequired- A provider enabled under Authentication → Providers, e.g.
googleorgithub. opts{ redirectTo?: string; projectId?: string }optionaldefault{}redirectTo: where the provider sends the user back.
Returns
Promise<{ url: string; }> — { url } — the browser is sent there; after consent the user returns to redirectTo with a code.
await sovaria.auth.signInWithProvider('github', { redirectTo: 'https://app.example.com/auth/callback' })
// on /auth/callback:
const code = new URL(location.href).searchParams.get('code')
if (code) await sovaria.auth.exchangeCodeForSession(code)sovaria.auth.signInWithSSO
Enterprise SAML single sign-on for your app's users (connections in Authentication › SAML SSO, Team plan).
sovaria.auth.signInWithSSO(
opts: { email?: string; domain?: string; connectionId?: string; redirectTo?: string; projectId?: string },
): Promise<{ url: string; connectionId: string; }>Pass the user's work email (or its domain) to find their company's identity provider, or a connectionId. The browser goes to the IdP and comes back like signInWithProvider(): ?code=…&type=sso, which exchangeCodeForSession() turns into a session.
Parameters
opts{ email?: string; domain?: string; connectionId?: string; redirectTo?: string; projectId?: string }required
Returns
Promise<{ url: string; connectionId: string; }>
sovaria.auth.exchangeCodeForSession
Exchange the one-time code from a provider sign-in redirect for a session.
sovaria.auth.exchangeCodeForSession(
code: string,
codeVerifier?: string,
): Promise<JsonObject | AuthResponse>In results: 'supabase' mode it resolves to { data: { session, user }, error }.
Parameters
codestringrequired- The
codequery parameter from the redirect. codeVerifierstringoptional- Only if you started the flow yourself; the SDK keeps it otherwise.
Returns
Promise<JsonObject | AuthResponse>
sovaria.auth._exchangeCode
_exchange code.
sovaria.auth._exchangeCode(
code: string,
codeVerifier?: string,
): Promise<JsonObject>Parameters
codestringrequiredcodeVerifierstringoptional
Returns
Promise<JsonObject>
sovaria.auth.linkIdentity
Link another sign-in method (Google/GitHub/SAML…) to the SIGNED-IN user (Supabase linkIdentity).
sovaria.auth.linkIdentity(
providerOrCredentials: string | { provider: string; options?: { redirectTo?: string; skipBrowserRedirect?: boolean } },
opts?: { redirectTo?: string } = {},
): Promise<{ url: string; }> | Promise<{ data: { provider: string; url: string; }; error: null; } | { data: { provider: string; url: null; }; error: SovariaError; }>Sends the browser to the provider; it returns to redirectTo (or your Site URL) with ?code=…&type=link, which handleEmailLink() / exchangeCodeForSession() complete. The completion is bound to THIS browser by a PKCE verifier kept in sessionStorage, so a forwarded link can't attach someone else's identity to your account. An anonymous user who links a verified provider becomes permanent.
Parameters
providerOrCredentialsstring | { provider: string; options?: { redirectTo?: string; skipBrowserRedirect?: boolean } }requiredopts{ redirectTo?: string }optionaldefault{}
Returns
Promise<{ url: string; }> | Promise<{ data: { provider: string; url: string; }; error: null; } | { data: { provider: string; url: null; }; error: SovariaError; }>
sovaria.auth._linkIdentity
_link identity.
sovaria.auth._linkIdentity(
providerId: string,
opts?: { redirectTo?: string; skipBrowserRedirect?: boolean } = {},
): Promise<{ url: string; }>Parameters
providerIdstringrequiredopts{ redirectTo?: string; skipBrowserRedirect?: boolean }optionaldefault{}
Returns
Promise<{ url: string; }>
sovaria.auth.getUserIdentities
The sign-in methods linked to the signed-in user (email, google, saml:…, passkey).
sovaria.auth.getUserIdentities(
): Promise<JsonObject | { data: { identities: JsonObject[]; }; error: null; } | { data: null; error: SovariaError; }>In results: 'supabase' mode: { data: { identities }, error }.
Returns
Promise<JsonObject | { data: { identities: JsonObject[]; }; error: null; } | { data: null; error: SovariaError; }>
sovaria.auth.unlinkIdentity
Remove a linked sign-in method (never the last one).
sovaria.auth.unlinkIdentity(
identity: string | { identity_id?: string; id?: string; provider?: string },
opts?: { nonce?: string } = {},
): Promise<JsonObject> | Promise<{ data: {}; error: null; } | { data: null; error: SovariaError; }>Pass a recent-auth nonce if the project requires it. supabase-js's form takes the identity object from getUserIdentities() and resolves to { data, error }.
Parameters
identitystring | { identity_id?: string; id?: string; provider?: string }requiredopts{ nonce?: string }optionaldefault{}
Returns
Promise<JsonObject> | Promise<{ data: {}; error: null; } | { data: null; error: SovariaError; }>
- HTTP
DELETE /api/v1/auth/me/identities/{…}{…}
sovaria.auth.listProviders
Enabled social / enterprise providers for your sign-in screen.
sovaria.auth.listProviders(projectId?: string): Promise<JsonValue>Parameters
projectIdstringoptional
Returns
Promise<JsonValue> — The providers you enabled, to render sign-in buttons.
sovaria.auth.getPublicConfig
Public sign-in config for a project: enabled providers, password rules, MFA factors, passkeys.
sovaria.auth.getPublicConfig(projectId?: string): Promise<JsonObject>Parameters
projectIdstringoptional
Returns
Promise<JsonObject> — Whether sign-up is open, enabled providers, password rules, MFA and passkey settings — everything a sign-in screen needs, without a session.
- HTTP
GET /api/v1/auth/public-config{…}
sovaria.auth.verifyMagicLink
Exchange a magic-link token for an access + refresh token pair.
sovaria.auth.verifyMagicLink(
token: string,
codeVerifier?: string,
): Promise<JsonObject>Parameters
tokenstringrequiredcodeVerifierstringoptional
Returns
Promise<JsonObject>
sovaria.auth.verifyEmailCode
Sign in with the 6-digit code from the sign-in email (the same email carries the magic link).
sovaria.auth.verifyEmailCode(
email: string,
code: string,
opts?: { orgId?: string; projectId?: string } = {},
): Promise<JsonObject>Uses the client scope's org/project unless given.
Parameters
emailstringrequired- The address the code was sent to.
codestringrequired- The 6-digit code from the email.
opts{ orgId?: string; projectId?: string }optionaldefault{}
Returns
Promise<JsonObject>
await sovaria.auth.verifyEmailCode('ada@example.com', '123456')sovaria.auth.sendOtp
Send an SMS OTP code for phone-based login.
sovaria.auth.sendOtp(
phone: string,
opts?: { orgId?: string; projectId?: string; envId?: string; createUser?: boolean; data?: Record<string, unknown>; captchaToken?: string } = {},
): Promise<JsonObject>Parameters
phonestringrequired- E.164 number, e.g.
+15551234567. opts{ orgId?: string; projectId?: string; envId?: string; createUser?: boolean; data?: Record<string, unknown>; captchaToken?: string }optionaldefault{}
Returns
Promise<JsonObject>
- Needs an SMS provider configured for the project.
sovaria.auth.verifyOtp
Verify an SMS OTP code and establish a session.
sovaria.auth.verifyOtp(
phoneOrParams: string | VerifyOtpParams,
code?: string,
opts?: { orgId?: string; projectId?: string; envId?: string; password?: string } = {},
): Promise<JsonObject | AuthResponse>Passwordless by default — pass password when argon2_salt is present to populate the session KEK without a follow-up password login.
Parameters
phoneOrParamsstring | VerifyOtpParamsrequiredcodestringoptional- The code from the SMS.
opts{ orgId?: string; projectId?: string; envId?: string; password?: string }optionaldefault{}
Returns
Promise<JsonObject | AuthResponse>
sovaria.auth.oauthHandoff
Exchange an OAuth handoff token for a session (console OAuth callback).
sovaria.auth.oauthHandoff(
token: string,
password?: string,
): Promise<JsonObject>Passwordless: session KEK is not derived unless password is supplied.
Parameters
tokenstringrequiredpasswordstringoptional
Returns
Promise<JsonObject>
sovaria.auth.listConsoleProductUsers
Console-operator listing of product users across accessible projects.
sovaria.auth.listConsoleProductUsers(): Promise<JsonValue>Path: GET /api/v1/auth/product-users (console lane).
Returns
Promise<JsonValue>
[
{
"id": "a71d0c5e-2f84-4b9a-9e13-6c5d8f2b1a47",
"node_id": "3c8f1e2a-9b47-4d6e-a5c1-7f0e2d4b8a93",
"email": "ana@example.com",
"is_active": true,
"created_at": "2026-10-02T08:14:22.481Z",
"updated_at": "2026-10-16T19:03:51.112Z",
"mfa_enabled": false,
"phone_mfa_enabled": false,
"any_mfa_enabled": false,
"last_sign_in_at": "2026-10-17T09:41:05.330Z",
"roles": [
"staff"
],
"role_sources": [
"project_settings"
],
"project_id": "f0c3e9a2-1b4d-4e7f-8a6c-2d9b5e3f1a07"
}
]sovaria.auth.sendVerificationEmail
Trigger a verification email for the authenticated user.
sovaria.auth.sendVerificationEmail(): Promise<JsonObject>Returns
Promise<JsonObject>
{
"status": "sent"
}sovaria.auth.confirmVerificationEmail
Confirm an address from its verification link.
sovaria.auth.confirmVerificationEmail(
token: string,
): Promise<JsonObject>When this client is signed in, its session goes along: a confirmation from the account's own session just confirms; one from anywhere else also marks the account so the inbox owner's first email sign-in ends whatever was set before the address was proven.
Parameters
tokenstringrequired
Returns
Promise<JsonObject>
sovaria.auth.listUsers
List users.
sovaria.auth.listUsers(): Promise<JsonValue>Returns
Promise<JsonValue>
- Needs the service role key or a project admin session; never call it from a browser.
sovaria.auth.deleteUser
Delete user.
sovaria.auth.deleteUser(userId: string): Promise<JsonObject>Parameters
userIdstringrequired
Returns
Promise<JsonObject>
sovaria.auth.banUser
Ban user.
sovaria.auth.banUser(userId: string): Promise<JsonObject>Parameters
userIdstringrequired
Returns
Promise<JsonObject>
#Admin API (supabase-js auth.admin)
sovaria.auth.admin.createUser
Create an app user.
sovaria.auth.admin.createUser(
attributes: AdminUserAttributes,
): Promise<ParityResult<{ user: AdminUser | null; temporaryPassword?: string | undefined; }>>Without a password the user signs in by link or code (inviteUserByEmail emails one).
Parameters
attributesAdminUserAttributesrequiredemail, optionalpassword(none: the user signs in by link or code),email_confirm,user_metadata,app_metadata,roles.
Returns
Promise<ParityResult<{ user: AdminUser | null; temporaryPassword?: string | undefined; }>> — { data: { user }, error }.
- Org owners/admins only (a team member's session or a server key) — never from a browser with the anon key.
const { data, error } = await sovaria.auth.admin.createUser({
email: 'ada@example.com', password: 'Correct-Horse-9!', email_confirm: true,
user_metadata: { name: 'Ada' }, app_metadata: { plan: 'pro' },
})sovaria.auth.admin.listUsers
A page of users, newest first: { users, nextPage, lastPage, total }.
sovaria.auth.admin.listUsers(
params?: { page?: number; perPage?: number } = {},
): Promise<ParityResult<{ users: AdminUser[]; aud: string; nextPage: number | null; lastPage: number | null; total: number | null; }>>page starts at 1 (max 50 pages deep; use auth.productUsers.listPage() with its cursor for more).
Parameters
params{ page?: number; perPage?: number }optionaldefault{}page(from 1) andperPage(up to 500).
Returns
Promise<ParityResult<{ users: AdminUser[]; aud: string; nextPage: number | null; lastPage: number | null; total: number | null; }>> — { data: { users, nextPage, lastPage, total }, error } — newest first; a banned user has banned_until: 'infinity'.
sovaria.auth.admin.getUserById
Get user by id.
sovaria.auth.admin.getUserById(
uid: string,
): Promise<ParityResult<{ user: AdminUser | null; }>>Parameters
uidstringrequired
Returns
Promise<ParityResult<{ user: AdminUser | null; }>> — { data: { user }, error } with user_metadata, app_metadata and custom claims.
sovaria.auth.admin.updateUserById
Change metadata, the confirmed flag, roles or the ban (supabase's ban_duration).
sovaria.auth.admin.updateUserById(
uid: string,
attributes: AdminUserAttributes,
): Promise<ParityResult<{ user: AdminUser | null; }>>Parameters
uidstringrequired- The user's id.
attributesAdminUserAttributesrequireduser_metadata,app_metadata(only admins can set it),email_confirm,roles,ban_duration('none'lifts a ban, any other value bans).
Returns
Promise<ParityResult<{ user: AdminUser | null; }>>
- Email, password and phone belong to the user: they change them with
updateUser, or you send a recovery link (generateLink({ type: 'recovery' })).
sovaria.auth.admin.deleteUser
Delete user.
sovaria.auth.admin.deleteUser(
uid: string,
): Promise<ParityResult<{ user: null; }>>Parameters
uidstringrequired
Returns
Promise<ParityResult<{ user: null; }>>
sovaria.auth.admin.inviteUserByEmail
Create a passwordless user and email them a sign-in link (the project's magic-link email).
sovaria.auth.admin.inviteUserByEmail(
email: string,
options?: { data?: Record<string, unknown>; redirectTo?: string } = {},
): Promise<ParityResult<{ user: AdminUser | null; }>>Parameters
emailstringrequired- The new user's address.
options{ data?: Record<string, unknown>; redirectTo?: string }optionaldefault{}data(their user_metadata).
Returns
Promise<ParityResult<{ user: AdminUser | null; }>> — Creates a passwordless user and emails them a sign-in link.
sovaria.auth.admin.generateLink
The link an auth email would carry, returned instead of sent (magiclink, recovery, invite).
sovaria.auth.admin.generateLink(
params: GenerateLinkParams,
): Promise<ParityResult<{ properties: GenerateLinkProperties | null; user: AdminUser | null; created: boolean; }>>Org owners/admins.
Parameters
paramsGenerateLinkParamsrequiredtype(magiclink,recoveryorinvite),email,options.redirectTo, and forinviteoptions.data.
Returns
Promise<ParityResult<{ properties: GenerateLinkProperties | null; user: AdminUser | null; created: boolean; }>> — { data: { properties: { action_link, email_otp, hashed_token, verification_type, redirect_to }, user }, error }. Nothing is emailed: send the link your way (your own email provider, a support tool).
- Org owners/admins only, at most 60 links an hour per admin, and every link is in the audit log (
auth.admin.link_generated). The link signs that user in: treat it like a password.
#Admin: users' second factors
sovaria.auth.admin.mfa.listFactors
A user's second factors (as the Users page shows them).
sovaria.auth.admin.mfa.listFactors(
params: { userId: string },
): Promise<ParityResult<{ factors: JsonObject[]; raw: JsonObject | null; }>>Parameters
params{ userId: string }required
Returns
Promise<ParityResult<{ factors: JsonObject[]; raw: JsonObject | null; }>>
sovaria.auth.admin.mfa.deleteFactors
Remove every second factor of a user (they enroll again; backup codes are revoked).
sovaria.auth.admin.mfa.deleteFactors(
params: { userId: string },
): Promise<ParityResult<{ id: string | null; }>>Parameters
params{ userId: string }required
Returns
Promise<ParityResult<{ id: string | null; }>>
#App users (admin)
sovaria.auth.productUsers.list
Every product user: follows all pages.
sovaria.auth.productUsers.list(): Promise<JsonObject[]>Use listPage() for big projects.
Returns
Promise<JsonObject[]>
sovaria.auth.productUsers.listPage
One page of product users, newest first.
sovaria.auth.productUsers.listPage(
params?: { limit?: number; cursor?: string | null; search?: string; status?: 'active' | 'banned' } = {},
): Promise<ProductUsersPage>search matches part of an email or an exact id.
Parameters
params{ limit?: number; cursor?: string | null; search?: string; status?: 'active' | 'banned' }optionaldefault{}limit(page size),cursor(from the previous page),search(part of an email or name).
Returns
Promise<ProductUsersPage>
let cursor = null
do {
const page = await sovaria.auth.productUsers.listPage({ limit: 100, cursor })
page.users.forEach((u) => console.log(u.email))
cursor = page.nextCursor
} while (cursor)sovaria.auth.productUsers.delete
Delete.
sovaria.auth.productUsers.delete(userId: string): Promise<JsonObject>Parameters
userIdstringrequired
Returns
Promise<JsonObject>
sovaria.auth.productUsers.ban
Bans the user (signed out, can't sign in).
sovaria.auth.productUsers.ban(
userId: string,
banned?: boolean = true,
): Promise<JsonObject>banned: false unbans; a repeated call keeps the state.
Parameters
userIdstringrequiredbannedbooleanoptionaldefaulttrue
Returns
Promise<JsonObject>
sovaria.auth.productUsers.unban
Lets a banned user sign in again.
sovaria.auth.productUsers.unban(userId: string): Promise<JsonObject>Parameters
userIdstringrequired
Returns
Promise<JsonObject>
sovaria.auth.productUsers.roles
Roles.
sovaria.auth.productUsers.roles(userId: string): Promise<JsonObject>Parameters
userIdstringrequired
Returns
Promise<JsonObject>
sovaria.auth.productUsers.setRoles
Set roles.
sovaria.auth.productUsers.setRoles(
userId: string,
roles: string[],
): Promise<JsonObject>Parameters
userIdstringrequired- The app user's id.
rolesstring[]required- App roles to give the user, e.g.
["librarian"]. Policies refer to them asapp:<role>.
Returns
Promise<JsonObject>
await sovaria.auth.productUsers.setRoles(userId, ['librarian'])sovaria.auth.productUsers.create
Create.
sovaria.auth.productUsers.create(
payload: { email: string; password: string; name?: string; roles?: string[] },
): Promise<JsonObject>Parameters
payload{ email: string; password: string; name?: string; roles?: string[] }requiredemail,password, optionalnameandroles.
Returns
Promise<JsonObject>
sovaria.auth.productUsers.import
Bulk-import app users (up to 1,000 per call) with their ids and password hashes: bcrypt (Supabase) as is, firebase_scrypt (Firebase) checked with hashConfig and upgraded to bcrypt at first sign-in.
sovaria.auth.productUsers.import(
users: Array<{ email: string id?: string email_verified?: boolean phone?: string | null display_name?: string | null password_algorithm?: 'bcrypt' | 'firebase_scrypt' | null password_hash?: string | null password_salt?: string | null }>,
hashConfig?: { signer_key: string; salt_separator: string; rounds: number; mem_cost: number },
): Promise<JsonObject>No emails, hooks or triggers fire; existing emails are skipped. Org owners/admins.
Parameters
usersArray<{ email: string id?: string email_verified?: boolean phone?: string | null display_name?: string | null password_algorithm?: 'bcrypt' | 'firebase_scrypt' | null password_hash?: string | null password_salt?: string | null }>requiredhashConfig{ signer_key: string; salt_separator: string; rounds: number; mem_cost: number }optional
Returns
Promise<JsonObject>
#App admins manage users (in your app)
sovaria.auth.users.access
Whether the signed-in user may manage users, and which roles they may give.
sovaria.auth.users.access(): Promise<AppUserAccess>Any signed-in user may ask.
Returns
Promise<AppUserAccess>
sovaria.auth.users.list
One page of the app's users, newest first.
sovaria.auth.users.list(
params?: { limit?: number; cursor?: string | null; search?: string; status?: 'active' | 'disabled'; role?: string } = {},
): Promise<AppUsersPage>search matches part of an email or name.
Parameters
params{ limit?: number; cursor?: string | null; search?: string; status?: 'active' | 'disabled'; role?: string }optionaldefault{}
Returns
Promise<AppUsersPage>
sovaria.auth.users.all
Every user, a page at a time (100 per request, following the cursor): for await (const u of sovaria.auth.users.all({ role: 'SALES' })) ….
sovaria.auth.users.all(
params?: { search?: string; status?: 'active' | 'disabled'; role?: string; max?: number } = {},
): AsyncGenerator<AppUser, any, any>Stops after max users (default 10,000).
Parameters
params{ search?: string; status?: 'active' | 'disabled'; role?: string; max?: number }optionaldefault{}
Returns
AsyncGenerator<AppUser, any, any>
sovaria.auth.users.create
Add a user.
sovaria.auth.users.create(
payload: { email: string; name?: string; roles?: string[]; mode?: 'invite' | 'temporary_password' },
): Promise<CreatedAppUser>mode: 'invite' (default) emails a sign-in link; mode: 'temporary_password' returns a password once, in this response, and the user must change it at first sign-in (user.must_change_password).
Parameters
payload{ email: string; name?: string; roles?: string[]; mode?: 'invite' | 'temporary_password' }required
Returns
Promise<CreatedAppUser>
sovaria.auth.users.setRoles
Replace a user's app roles.
sovaria.auth.users.setRoles(
userId: string,
roles: string[],
): Promise<{ id: string; roles: string[]; }>They apply to the user's requests within 20 seconds (usually at once), even on tokens already issued; the user stays signed in.
Parameters
userIdstringrequiredrolesstring[]required
Returns
Promise<{ id: string; roles: string[]; }>
sovaria.auth.users.disable
Turn a user's account off (signed out everywhere, can't sign in) or back on.
sovaria.auth.users.disable(
userId: string,
): Promise<{ id: string; is_active: boolean; }>Parameters
userIdstringrequired
Returns
Promise<{ id: string; is_active: boolean; }>
sovaria.auth.users.enable
Enable.
sovaria.auth.users.enable(
userId: string,
): Promise<{ id: string; is_active: boolean; }>Parameters
userIdstringrequired
Returns
Promise<{ id: string; is_active: boolean; }>
sovaria.auth.users.delete
Delete a user and everything tied to their account.
sovaria.auth.users.delete(userId: string): Promise<JsonObject>Parameters
userIdstringrequired
Returns
Promise<JsonObject>
#App roles: define, assign, revoke, read from the token
sovaria.roles.list
Every role with its permissions (built-in and custom).
sovaria.roles.list(
): Promise<{ name: string; permissions: string[]; builtIn: boolean; }[]>Returns
Promise<{ name: string; permissions: string[]; builtIn: boolean; }[]>
sovaria.roles.create
Add a role (or fail with a 409 SovariaError when one with that name exists).
sovaria.roles.create(
name: string,
permissions?: string[] = [],
): Promise<{ status: string; roles: string[]; }>Counts toward auth.app_roles.
Parameters
namestringrequiredpermissionsstring[]optionaldefault[]
Returns
Promise<{ status: string; roles: string[]; }>
sovaria.roles.update
Replace one role's permissions.
sovaria.roles.update(
name: string,
permissions: string[],
): Promise<{ status: string; roles: string[]; }>Parameters
namestringrequiredpermissionsstring[]required
Returns
Promise<{ status: string; roles: string[]; }>
sovaria.roles.delete
Remove a role (users holding it lose it; row rules that test it then refuse them).
sovaria.roles.delete(
name: string,
): Promise<{ status: string; roles: string[]; }>Parameters
namestringrequired
Returns
Promise<{ status: string; roles: string[]; }>
sovaria.roles.saveMatrix
Save matrix.
sovaria.roles.saveMatrix(
entries: ReadonlyArray<readonly [string, readonly string[]]>,
): Promise<{ status: string; roles: string[]; }>Parameters
entriesReadonlyArray<readonly [string, readonly string[]]>required
Returns
Promise<{ status: string; roles: string[]; }>
{
"status": "ok",
"roles": [
"admin",
"customer",
"staff"
]
}sovaria.roles.status
Whether the saved roles are enforced, and the plan's allowance (roles_used / roles_limit).
sovaria.roles.status(): Promise<JsonObject>Returns
Promise<JsonObject>
sovaria.roles.of
An app user's roles (project team).
sovaria.roles.of(userId: string): Promise<string[]>Parameters
userIdstringrequired
Returns
Promise<string[]>
sovaria.roles.assign
Give an app user roles, keeping the ones they have (project team).
sovaria.roles.assign(
userId: string,
roles?: string[],
): Promise<JsonObject>Parameters
userIdstringrequiredrolesstring[]optional
Returns
Promise<JsonObject>
sovaria.roles.revoke
Take roles away from an app user (project team).
sovaria.roles.revoke(
userId: string,
roles?: string[],
): Promise<JsonObject>Parameters
userIdstringrequiredrolesstring[]optional
Returns
Promise<JsonObject>
sovaria.roles.current
The signed-in user's app roles as their current token states them (refresh to see a change).
sovaria.roles.current(): string[]Returns
string[]
sovaria.roles.has
current() holds role (case-insensitive).
sovaria.roles.has(role: string): booleanFor showing UI only: the server decides access.
Parameters
rolestringrequired
Returns
boolean
#Sessions
sovaria.auth.sessions.list
List.
sovaria.auth.sessions.list(): Promise<JsonValue>Returns
Promise<JsonValue>
[
{
"id": "sess_8f2…",
"device": "Chrome on macOS",
"ip": "203.0.113.24",
"last_active_at": "2026-10-17T12:30:01Z",
"expires_in_seconds": 600391,
"current": true
},
{
"id": "sess_1c7…",
"device": "Safari on iPhone",
"ip": "198.51.100.7",
"last_active_at": "2026-10-15T08:11:40Z",
"expires_in_seconds": 412044,
"current": false
}
]sovaria.auth.sessions.revoke
Revoke.
sovaria.auth.sessions.revoke(sessionId: string): Promise<JsonObject>Parameters
sessionIdstringrequired
Returns
Promise<JsonObject>
sovaria.auth.sessions.revokeOthers
Sign out every other device; this session (its refresh token is sent so the server knows it) stays.
sovaria.auth.sessions.revokeOthers(): Promise<JsonObject>Returns
Promise<JsonObject> — Signs the user out everywhere except this device.
sovaria.auth.sessions.getConfig
Get config.
sovaria.auth.sessions.getConfig(): Promise<JsonObject>Returns
Promise<JsonObject>
{
"timeout_minutes": 15,
"refresh_days": 7,
"max_concurrent": 0,
"single_session": false
}sovaria.auth.sessions.setConfig
Set config.
sovaria.auth.sessions.setConfig(body: JsonObject): Promise<JsonObject>Parameters
bodyJsonObjectrequired
Returns
Promise<JsonObject>
{
"timeout_minutes": 30,
"refresh_days": 14,
"max_concurrent": 5,
"single_session": false
}#Your users' organizations (B2B)
sovaria.auth.organizations.list
{ organizations: [{ id, name, slug, role, … }], active_org_id } for the signed-in user.
sovaria.auth.organizations.list(): Promise<JsonObject>Returns
Promise<JsonObject>
sovaria.auth.organizations.get
Get.
sovaria.auth.organizations.get(orgId: string): Promise<JsonObject>Parameters
orgIdstringrequired
Returns
Promise<JsonObject>
sovaria.auth.organizations.create
Create an organization; you are its owner.
sovaria.auth.organizations.create(
name: string,
options?: { slug?: string } = {},
): Promise<JsonObject>Parameters
namestringrequiredoptions{ slug?: string }optionaldefault{}
Returns
Promise<JsonObject>
sovaria.auth.organizations.update
Update.
sovaria.auth.organizations.update(
orgId: string,
patch: { name?: string; metadata?: Record<string, unknown> },
): Promise<JsonObject>Parameters
orgIdstringrequiredpatch{ name?: string; metadata?: Record<string, unknown> }required
Returns
Promise<JsonObject>
sovaria.auth.organizations.delete
Delete.
sovaria.auth.organizations.delete(orgId: string): Promise<JsonObject>Parameters
orgIdstringrequired
Returns
Promise<JsonObject>
sovaria.auth.organizations.setActive
Make an organization (or null for none) the active one and refresh the session, so the new tokens carry app_org right away.
sovaria.auth.organizations.setActive(
orgId: string | null,
): Promise<JsonObject>Parameters
orgIdstring | nullrequired
Returns
Promise<JsonObject>
sovaria.auth.organizations.invite
Email an invite link (valid 7 days).
sovaria.auth.organizations.invite(
orgId: string,
email: string,
role?: string = 'member',
options?: { redirectTo?: string } = {},
): Promise<JsonObject>role is member (default), admin or owner.
Parameters
orgIdstringrequiredemailstringrequiredrolestringoptionaldefault'member'options{ redirectTo?: string }optionaldefault{}
Returns
Promise<JsonObject>
sovaria.auth.organizations.revokeInvite
Revoke invite.
sovaria.auth.organizations.revokeInvite(
orgId: string,
inviteId: string,
): Promise<JsonObject>Parameters
orgIdstringrequiredinviteIdstringrequired
Returns
Promise<JsonObject>
sovaria.auth.organizations.acceptInvite
Accept an invite with the token from its link (the signed-in user's verified email must match).
sovaria.auth.organizations.acceptInvite(
token: string,
): Promise<JsonObject>Parameters
tokenstringrequired
Returns
Promise<JsonObject>
sovaria.auth.organizations.setMemberRole
Set member role.
sovaria.auth.organizations.setMemberRole(
orgId: string,
userId: string,
role: string,
): Promise<JsonObject>Parameters
orgIdstringrequireduserIdstringrequiredrolestringrequired
Returns
Promise<JsonObject>
sovaria.auth.organizations.removeMember
Remove member.
sovaria.auth.organizations.removeMember(
orgId: string,
userId: string,
): Promise<JsonObject>Parameters
orgIdstringrequireduserIdstringrequired
Returns
Promise<JsonObject>
sovaria.auth.organizations.addDomain
Claim an email domain: publish the TXT record the response names, then verifyDomain.
sovaria.auth.organizations.addDomain(
orgId: string,
domain: string,
): Promise<JsonObject>Parameters
orgIdstringrequireddomainstringrequired
Returns
Promise<JsonObject>
sovaria.auth.organizations.verifyDomain
Check the TXT record now: { found, domains }.
sovaria.auth.organizations.verifyDomain(
orgId: string,
domain: string,
): Promise<JsonObject>Users with a verified email at the domain join as members.
Parameters
orgIdstringrequireddomainstringrequired
Returns
Promise<JsonObject>
#Multi-factor authentication
sovaria.auth.mfa.status
Status.
sovaria.auth.mfa.status(): Promise<JsonObject>Returns
Promise<JsonObject>
{
"mfa_enabled": true,
"phone_mfa_enabled": false,
"enrolled_at": "2026-10-02T09:14:07Z"
}sovaria.auth.mfa.enroll
Enroll.
sovaria.auth.mfa.enroll(
params?: { factorType: 'totp' | 'phone' | 'webauthn'; friendlyName?: string; phone?: string; issuer?: string },
): Promise<JsonObject> | Promise<ParityResult<JsonObject | null>>Parameters
params{ factorType: 'totp' | 'phone' | 'webauthn'; friendlyName?: string; phone?: string; issuer?: string }optional- supabase-js's form:
factorType(totp,phone,webauthn),friendlyName,phone. With no argument, the older single-TOTP enrolment.
Returns
Promise<JsonObject> | Promise<ParityResult<JsonObject | null>> — { data: { id, type, totp: { qr_code, secret, uri } }, error } (no argument: a secret and otpauth:// URL to confirm with auth.verifyMfa).
sovaria.auth.mfa.disable
Disable.
sovaria.auth.mfa.disable(totpCode: string): Promise<JsonObject>Parameters
totpCodestringrequired
Returns
Promise<JsonObject>
{
"status": "disabled",
"message": "MFA has been removed"
}sovaria.auth.mfa.challenge
Challenge.
sovaria.auth.mfa.challenge(
params: { factorId: string },
): Promise<ParityResult<JsonObject | null>>Parameters
params{ factorId: string }requiredfactorIdfromlistFactors()orenroll().
Returns
Promise<ParityResult<JsonObject | null>> — { data: { id, type, expires_at }, error } — id is the challenge for verify() (a phone factor is texted a code).
sovaria.auth.mfa.verify
Verify.
sovaria.auth.mfa.verify(
params: { factorId: string; challengeId: string; code: string },
): Promise<ParityResult<(JsonObject & { user: unknown; session: unknown; }) | null>>Parameters
params{ factorId: string; challengeId: string; code: string }requiredfactorId,challengeId, and thecode.
Returns
Promise<ParityResult<(JsonObject & { user: unknown; session: unknown; }) | null>> — { data: { user, session, … }, error }: the session is now two-factor (aal2). The first verify of a new factor also returns backup_codes once.
sovaria.auth.mfa.challengeAndVerify
Challenge and verify.
sovaria.auth.mfa.challengeAndVerify(
params: { factorId: string; code: string },
): Promise<ParityResult<(JsonObject & { user: unknown; session: unknown; }) | null>>Parameters
params{ factorId: string; code: string }required
Returns
Promise<ParityResult<(JsonObject & { user: unknown; session: unknown; }) | null>>
const { data: factor } = await sovaria.auth.mfa.enroll({ factorType: 'totp', friendlyName: 'Phone' })
showQr(factor.totp.qr_code)
await sovaria.auth.mfa.challengeAndVerify({ factorId: factor.id, code })sovaria.auth.mfa.unenroll
Unenroll.
sovaria.auth.mfa.unenroll(
params: { factorId: string },
): Promise<ParityResult<{ id: string; } | null>>Parameters
params{ factorId: string }required
Returns
Promise<ParityResult<{ id: string; } | null>>
sovaria.auth.mfa.listFactors
List factors.
sovaria.auth.mfa.listFactors(
): Promise<ParityResult<{ all: MfaFactor[]; totp: MfaFactor[]; phone: MfaFactor[]; webauthn: MfaFactor[]; }>>Returns
Promise<ParityResult<{ all: MfaFactor[]; totp: MfaFactor[]; phone: MfaFactor[]; webauthn: MfaFactor[]; }>>
sovaria.auth.mfa.getAuthenticatorAssuranceLevel
Get authenticator assurance level.
sovaria.auth.mfa.getAuthenticatorAssuranceLevel(
): Promise<ParityResult<{ currentLevel: AuthenticatorAssuranceLevel | null; nextLevel: AuthenticatorAssuranceLevel | null; currentAuthenticationMethods: JsonObject[]; }>>Returns
Promise<ParityResult<{ currentLevel: AuthenticatorAssuranceLevel | null; nextLevel: AuthenticatorAssuranceLevel | null; currentAuthenticationMethods: JsonObject[]; }>> — { data: { currentLevel, nextLevel }, error } — ask for a code when nextLevel is aal2 and currentLevel is aal1.
#Passkeys
sovaria.auth.passkeys.isSupported
True when this browser can create and use passkeys.
sovaria.auth.passkeys.isSupported(): booleanReturns
boolean
sovaria.auth.passkeys.startRegistration
Registration options for the signed-in user (their existing passkeys are excluded).
sovaria.auth.passkeys.startRegistration(
name?: string = 'Passkey',
): Promise<JsonObject>Parameters
namestringoptionaldefault'Passkey'
Returns
Promise<JsonObject>
{
"options": {
"challenge": "x9H3…",
"rp": {
"id": "skolist-shop.sovarias.in",
"name": "skolist-shop"
},
"user": {
"id": "bmUxOWMw…",
"name": "ada@example.com",
"displayName": "Ada Lovelace"
},
"pubKeyCredParams": [
{
"type": "public-key",
"alg": -7
}
],
"timeout": 60000,
"attestation": "none"
}
}sovaria.auth.passkeys.finishRegistration
Save the credential the authenticator created (credential is WebAuthn JSON).
sovaria.auth.passkeys.finishRegistration(
credential: JsonObject,
name?: string = 'Passkey',
): Promise<JsonObject>Parameters
credentialJsonObjectrequirednamestringoptionaldefault'Passkey'
Returns
Promise<JsonObject>
{
"passkey_id": "9c1d…",
"name": "MacBook",
"created_at": "2026-10-17T11:02:44Z"
}sovaria.auth.passkeys.register
Create a passkey for the signed-in user with the browser's WebAuthn API and save it.
sovaria.auth.passkeys.register(
name?: string = 'Passkey',
): Promise<JsonObject>Parameters
namestringoptionaldefault'Passkey'
Returns
Promise<JsonObject>
sovaria.auth.passkeys.startSignIn
Sign-in options: { challenge_id, options }.
sovaria.auth.passkeys.startSignIn(
opts?: { userId?: string } = {},
): Promise<JsonObject>Pass userId to offer only that user's passkeys.
Parameters
opts{ userId?: string }optionaldefault{}
Returns
Promise<JsonObject>
sovaria.auth.passkeys.finishSignIn
Verify the signed challenge and sign the user in (the session is kept and refreshed like any sign-in).
sovaria.auth.passkeys.finishSignIn(
challengeId: string,
credential: JsonObject,
): Promise<JsonObject>Parameters
challengeIdstringrequiredcredentialJsonObjectrequired
Returns
Promise<JsonObject>
sovaria.auth.passkeys.signIn
Sign in with a passkey using the browser's WebAuthn API.
sovaria.auth.passkeys.signIn(
opts?: { userId?: string } = {},
): Promise<JsonObject>Resolves to the session tokens (aal says if it was two-factor).
Parameters
opts{ userId?: string }optionaldefault{}
Returns
Promise<JsonObject>
sovaria.auth.passkeys.list
The signed-in user's passkeys: id, name, created_at, last_used_at.
sovaria.auth.passkeys.list(): Promise<JsonValue>Returns
Promise<JsonValue>
[
{
"id": "9c1d…",
"name": "MacBook",
"aaguid": "adce0002-35bc-c60a-648b-0b25f1f05503",
"transports": [
"internal",
"hybrid"
],
"created_at": "2026-10-17T11:02:44Z",
"last_used_at": "2026-10-17T12:30:01Z"
}
]sovaria.auth.passkeys.remove
Remove one of the signed-in user's passkeys.
sovaria.auth.passkeys.remove(passkeyId: string): Promise<JsonValue>Parameters
passkeyIdstringrequired
Returns
Promise<JsonValue>
#Provider settings
sovaria.auth.providersConfig.get
Get.
sovaria.auth.providersConfig.get(): Promise<JsonObject>Returns
Promise<JsonObject>
{
"providers": [
{
"id": "email",
"label": "Email + Password",
"enabled": true,
"requested_enabled": true,
"available": true,
"managed_by": "core",
"description": "Built-in credential authentication.",
"setup_required": []
},
{
"id": "magic_link",
"label": "Magic Link",
"enabled": true,
"requested_enabled": true,
"available": true,
"managed_by": "core",
"description": "…",
"setup_required": []
}
],
"database_link": {
"enabled": false,
"engine": "postgresql",
"host": "",
"port": 5432,
"database": "",
"schema": "public",
"username": "",
"ssl": true
},
"sms_config": {
"provider": "twilio",
"account_sid": "AC5f…",
"from_number": "+14155550123",
"auth_token_set": true,
"auth_token_hint": "8c…f2"
}
}sovaria.auth.providersConfig.set
Set.
sovaria.auth.providersConfig.set(body: JsonObject): Promise<JsonObject>Parameters
bodyJsonObjectrequired
Returns
Promise<JsonObject>
#Auth event hooks
sovaria.auth.eventHooks.list
List.
sovaria.auth.eventHooks.list(): Promise<JsonValue>Returns
Promise<JsonValue>
[
{
"id": "0b6e…",
"name": "CRM sync",
"url": "https://hooks.skolist.com/sovaria-auth",
"events": [
"auth.user.login.success",
"auth.user.registered"
],
"enabled": true,
"created_at": "2026-10-01T10:00:00+00:00",
"updated_at": "2026-10-01T10:00:00+00:00",
"delivery_count": 412,
"failure_count": 3,
"last_delivery_at": "2026-10-17T09:41:05+00:00",
"last_error": null
}
]sovaria.auth.eventHooks.create
Create.
sovaria.auth.eventHooks.create(
payload: { name: string url: string events: string[] secret?: string enabled?: boolean projectId?: string },
): Promise<JsonObject>Parameters
payload{ name: string url: string events: string[] secret?: string enabled?: boolean projectId?: string }required
Returns
Promise<JsonObject>
{
"id": "0b6e…",
"name": "CRM sync",
"url": "https://hooks.skolist.com/sovaria-auth",
"events": [
"auth.user.login.success",
"auth.user.registered"
],
"enabled": true,
"created_at": "2026-10-18T10:10:00+00:00",
"updated_at": "2026-10-18T10:10:00+00:00",
"delivery_count": 0,
"failure_count": 0,
"last_delivery_at": null,
"last_error": null
}sovaria.auth.eventHooks.delete
Delete.
sovaria.auth.eventHooks.delete(hookId: string): Promise<JsonObject>Parameters
hookIdstringrequired
Returns
Promise<JsonObject>
#Blocking hooks (before create, before sign-in)
sovaria.auth.blockingHooks.get
Get.
sovaria.auth.blockingHooks.get(): Promise<JsonObject>Returns
Promise<JsonObject>
{
"before_create": null,
"before_sign_in": {
"target": "webhook",
"url": "https://api.acme.com/hooks/before-sign-in",
"function": null,
"timeout_ms": 1500,
"fail": "closed",
"enabled": true,
"updated_at": "2026-10-23T09:00:00Z",
"updated_by": "8d1e…",
"has_secret": true
},
"plan_allowed": true,
"disabled_by_staff": false,
"disabled_reason": null,
"max_timeout_ms": 5000
}sovaria.auth.blockingHooks.set
Set.
sovaria.auth.blockingHooks.set(
event: 'before_create' | 'before_sign_in',
hook: { target?: 'webhook' | 'function' url?: string function?: string timeoutMs?: number fail?: 'closed' | 'open' enabled?: boolean rotateSecret?: boolean },
): Promise<JsonObject>Parameters
event'before_create' | 'before_sign_in'requiredhook{ target?: 'webhook' | 'function' url?: string function?: string timeoutMs?: number fail?: 'closed' | 'open' enabled?: boolean rotateSecret?: boolean }required
Returns
Promise<JsonObject>
{
"target": "webhook",
"url": "https://api.acme.com/hooks/before-sign-in",
"function": null,
"timeout_ms": 1500,
"fail": "closed",
"enabled": true,
"updated_at": "2026-10-23T09:00:00Z",
"updated_by": "8d1e…",
"has_secret": true,
"secret": "whsec_…"
}sovaria.auth.blockingHooks.delete
Delete.
sovaria.auth.blockingHooks.delete(
event: 'before_create' | 'before_sign_in',
): Promise<JsonObject>Parameters
event'before_create' | 'before_sign_in'required
Returns
Promise<JsonObject>
sovaria.auth.blockingHooks.test
Send a sample event and get the hook's decision (allowed, claims, message, failed, error, latency_ms).
sovaria.auth.blockingHooks.test(
event: 'before_create' | 'before_sign_in',
sample?: { email?: string; provider?: string } = {},
): Promise<JsonObject>Parameters
event'before_create' | 'before_sign_in'requiredsample{ email?: string; provider?: string }optionaldefault{}
Returns
Promise<JsonObject>
{
"allowed": false,
"claims": {},
"message": "Use your Acme email.",
"failed": false,
"error": null,
"latency_ms": 84.2
}#SCIM provisioning
sovaria.auth.scim.status
Status.
sovaria.auth.scim.status(): Promise<JsonObject>Returns
Promise<JsonObject>
{
"enabled": true,
"base_url": "https://api.sovaria.in/api/v1/auth/scim/v2/c0ffee00-…",
"token": {
"prefix": "scim_Xb3kQ9",
"created_at": "2026-10-23T09:00:00Z",
"created_by": "8d1e…",
"last_used_at": "2026-10-23T10:12:00Z"
},
"plan_allowed": true,
"disabled_by_staff": false,
"disabled_reason": null,
"users_provisioned": 42,
"groups": 3
}sovaria.auth.scim.createToken
Create token.
sovaria.auth.scim.createToken(): Promise<JsonObject>Returns
Promise<JsonObject>
{
"token": "scim_…",
"base_url": "https://api.sovaria.in/api/v1/auth/scim/v2/c0ffee00-…",
"rotated": false,
"token_info": {
"prefix": "scim_Xb3kQ9",
"created_at": "2026-10-23T09:00:00Z",
"created_by": "8d1e…",
"last_used_at": null
}
}sovaria.auth.scim.revokeToken
Revoke token.
sovaria.auth.scim.revokeToken(): Promise<JsonObject>Returns
Promise<JsonObject>
#Console members
sovaria.auth.consoleMembers.list
List.
sovaria.auth.consoleMembers.list(): Promise<JsonValue>Returns
Promise<JsonValue>
sovaria.auth.consoleMembers.delete
Delete.
sovaria.auth.consoleMembers.delete(userId: string): Promise<JsonObject>Parameters
userIdstringrequired
Returns
Promise<JsonObject>
sovaria.auth.consoleMembers.ban
Ban.
sovaria.auth.consoleMembers.ban(userId: string): Promise<JsonObject>Parameters
userIdstringrequired
Returns
Promise<JsonObject>
#GitHub connection (console)
sovaria.auth.github.connectionState
Connection state.
sovaria.auth.github.connectionState(): Promise<JsonObject>Returns
Promise<JsonObject>
{
"provider": "github",
"project_scope": "f0c3e9a2-1b4d-4e7f-8a6c-2d9b5e3f1a07",
"connected": true,
"connected_at": "2026-10-04T15:20:00Z",
"updated_at": "2026-10-04T15:20:00Z",
"token_hint": "gho_…1f",
"metadata": {
"email": "dev@skolist.com",
"login": "skolist-dev",
"name": "Skolist Dev",
"scopes": [
"read:user",
"repo",
"user:email"
]
}
}sovaria.auth.github.disconnect
Disconnect.
sovaria.auth.github.disconnect(): Promise<JsonObject>Returns
Promise<JsonObject>
{
"provider": "github",
"project_scope": "f0c3e9a2-1b4d-4e7f-8a6c-2d9b5e3f1a07",
"connected": false,
"disconnected": true
}