Functions

exchange-code

fn (request: ExchangeCodeRequest): AuthResponse
fn (request: ExchangeCodeRequest, opts: Map): AuthResponse

Exchange a PKCE authorization code for a session.

Example

::auth ::supabase::auth

session ::auth/exchange-code(::auth/ExchangeCodeRequest({
  auth_code: "code-from-the-redirect",
  code_verifier: ::hot::ctx/get("pkce.verifier")
}))
session.access_token

get-user

fn (access-token: Str): User
fn (access-token: Str, opts: Map): User

Get the currently authenticated user. Pass the user's access token.

Example

::auth ::supabase::auth

user ::auth/get-user("user-access-token")
user.id     // => "uuid-..."
user.email  // => "alice@example.com"

recover-password

fn (email: Str): Map
fn (email: Str, opts: Map): Map

Send a password reset email.

Example

::auth ::supabase::auth

::auth/recover-password("alice@example.com")

refresh-token

fn (refresh-token-value: Str): AuthResponse
fn (refresh-token-value: Str, opts: Map): AuthResponse

Exchange a refresh token for a new access token.

Example

::auth ::supabase::auth

session ::auth/refresh-token("current-refresh-token")
session.access_token   // => "new-eyJ..."
session.refresh_token  // => "new-abc..."

session-with-tokens-masked

fn (session: Result): Any

Mask a session's access and refresh tokens in the run's call records and return the session as is. An Err passes through.

Example

password ::hot::ctx/get("supabase.test.password")
response ::supabase::api/request("POST", "/auth/v1/token?grant_type=password", {}, {email: "alice@example.com", password: password})

// Keeps the tokens out of the call records when you call the endpoint yourself
session ::supabase::auth/session-with-tokens-masked(response)
session.user.id

sign-in-otp

fn (request: SignInOtpRequest): Map
fn (request: SignInOtpRequest, opts: Map): Map

Send a magic link (email) or OTP code (phone). The user clicks the link or enters the code to complete sign-in.

Example

::auth ::supabase::auth

// Magic link via email
::auth/sign-in-otp(::auth/SignInOtpRequest({
  email: "alice@example.com"
}))

// OTP via phone
::auth/sign-in-otp(::auth/SignInOtpRequest({
  phone: "+15551234567"
}))

sign-in-password

fn (request: SignInPasswordRequest): AuthResponse
fn (request: SignInPasswordRequest, opts: Map): AuthResponse

Sign in with email/password or phone/password. Returns access_token, refresh_token, expires_in, and user.

Example

::auth ::supabase::auth

session ::auth/sign-in-password(::auth/SignInPasswordRequest({
  email: "alice@example.com",
  password: "securePassword123"
}))
session.access_token   // => "eyJ..."
session.refresh_token  // => "abc..."
session.user.id        // => "uuid-..."

sign-out

fn (access-token: Str): Any
fn (access-token: Str, scope: SignOutScope): Any
fn (access-token: Str, scope: SignOutScope, opts: Map): Any

Sign out a user by invalidating their session. Pass the user's access token. Optional scope: "global" (all sessions), "local" (current only, default), "others" (all except current).

Example

::auth ::supabase::auth

::auth/sign-out("user-access-token")

sign-up

fn (request: SignUpRequest): AuthResponse
fn (request: SignUpRequest, opts: Map): AuthResponse

Create a new user with email/password or phone/password. Returns the user object and session (if auto-confirm is enabled).

data is optional user metadata stored on the user object.

Example

::auth ::supabase::auth

result ::auth/sign-up(::auth/SignUpRequest({
  email: "alice@example.com",
  password: "securePassword123",
  data: {name: "Alice"}
}))
result.user.id  // => "uuid-..."

update-user

fn (request: UpdateUserRequest, access-token: Str): User
fn (request: UpdateUserRequest, access-token: Str, opts: Map): User

Update the authenticated user's email, phone, password, or metadata. Pass the user's access token.

Example

::auth ::supabase::auth

updated ::auth/update-user(::auth/UpdateUserRequest({
  data: {name: "Alice Smith"}
}), "user-access-token")

verify-otp

fn (request: VerifyOtpRequest): AuthResponse
fn (request: VerifyOtpRequest, opts: Map): AuthResponse

Verify an OTP or magic link token. type can be: "signup", "recovery", "invite", "magiclink", "email_change", "email", "sms", "phone_change".

For SMS/phone OTP, provide phone + token. For email magic link, provide email + token or token_hash.

Example

::auth ::supabase::auth

session ::auth/verify-otp(::auth/VerifyOtpRequest({
  type: "sms",
  phone: "+15551234567",
  token: "123456"
}))
session.access_token  // => "eyJ..."

Types

AuthChannel

AuthChannel type "sms" | "whatsapp"

AuthResponse

AuthResponse type {
    access_token: Str?,
    token_type: Str?,
    expires_in: Int?,
    expires_at: Int?,
    refresh_token: Str?,
    user: User?,
    weak_password: Map?
}

CodeChallengeMethod

CodeChallengeMethod type "plain" | "s256"

ExchangeCodeRequest

ExchangeCodeRequest type {
    auth_code: Str,
    code_verifier: Str
}

OtpType

OtpType type "signup" | "recovery" | "invite" | "magiclink" | "email_change" | "email" | "sms" | "phone_change"

SignInOtpRequest

SignInOtpRequest type {
    email: Str?,
    phone: Str?,
    channel: AuthChannel?,
    create_user: Bool?,
    data: Map?,
    code_challenge: Str?,
    code_challenge_method: CodeChallengeMethod?,
    captcha_token: Str?
}

SignInPasswordRequest

SignInPasswordRequest type {
    email: Str?,
    phone: Str?,
    password: Str,
    captcha_token: Str?
}

SignOutScope

SignOutScope type "global" | "local" | "others"

SignUpRequest

SignUpRequest type {
    email: Str?,
    phone: Str?,
    channel: AuthChannel?,
    password: Str,
    data: Map?,
    code_challenge: Str?,
    code_challenge_method: CodeChallengeMethod?,
    captcha_token: Str?
}

UpdateUserRequest

UpdateUserRequest type {
    email: Str?,
    phone: Str?,
    password: Str?,
    data: Map?,
    nonce: Str?
}

User

User type {
    id: Str,
    aud: Str?,
    role: Str?,
    email: Str?,
    phone: Str?,
    app_metadata: Map?,
    user_metadata: Map?,
    created_at: Str?,
    updated_at: Str?
}

VerifyOtpRequest

VerifyOtpRequest type {
    type: OtpType,
    token: Str?,
    token_hash: Str?,
    email: Str?,
    phone: Str?,
    redirect_to: Str?
}