Supabase.Auth.Passkey.Behaviour behaviour (supabase_auth v1.1.0)

View Source

Behaviour and type definitions for passkey (first-factor WebAuthn) operations.

The WebAuthn ceremony itself (navigator.credentials.create/get) runs in the browser; these callbacks cover the HTTP half: fetching challenge options and verifying the resulting credential. See the passkey guide (pages/passkey_guide.md) for wiring the ceremony via LiveView + JS hooks.

Summary

Types

creation_options()

@type creation_options() :: %{
  :challenge_id => String.t(),
  :options => map(),
  optional(:expires_at) => integer() | nil
}

credential()

@type credential() :: map()

passkey()

@type passkey() :: %{
  :id => String.t(),
  optional(:friendly_name) => String.t() | nil,
  optional(:created_at) => String.t() | nil,
  optional(:last_used_at) => String.t() | nil
}

request_options()

@type request_options() :: %{
  :challenge_id => String.t(),
  :options => map(),
  optional(:expires_at) => integer() | nil
}

Callbacks

delete(t, t, t)

@callback delete(Supabase.Client.t(), Supabase.Auth.Session.t(), String.t()) ::
  :ok | {:error, term()}

list(t, t)

@callback list(Supabase.Client.t(), Supabase.Auth.Session.t()) ::
  {:ok, [passkey()]} | {:error, term()}

start_authentication(t, map)

@callback start_authentication(Supabase.Client.t(), map()) ::
  {:ok, request_options()} | {:error, term()}

start_registration(t, t)

@callback start_registration(Supabase.Client.t(), Supabase.Auth.Session.t()) ::
  {:ok, creation_options()} | {:error, term()}

update(t, t, t, t)

@callback update(Supabase.Client.t(), Supabase.Auth.Session.t(), String.t(), String.t()) ::
  {:ok, passkey()} | {:error, term()}

verify_authentication(t, t, credential)

@callback verify_authentication(Supabase.Client.t(), String.t(), credential()) ::
  {:ok, Supabase.Auth.Session.t()} | {:error, term()}

verify_registration(t, t, t, credential)

@callback verify_registration(
  Supabase.Client.t(),
  Supabase.Auth.Session.t(),
  String.t(),
  credential()
) ::
  {:ok, passkey()} | {:error, term()}