Sigra.DataExport behaviour (Sigra v1.0.0)

Copy Markdown View Source

Behaviour for exporting user data.

Sigra provides a versioned export contract for Sigra-owned auth and account data. Application developers implement this behaviour to add host-app data alongside the Sigra-owned export.

Usage

defmodule MyApp.DataExport do
  @behaviour Sigra.DataExport

  @impl true
  def export_user_data(user) do
    {:ok, %{
      profile: %{name: user.name, bio: user.bio},
      posts: MyApp.Posts.list_by_user(user.id)
    }}
  end
end

Summary

Callbacks

Export all data associated with the given user.

Functions

Exports Sigra's own auth data for a user.

Callbacks

export_user_data(user)

(since 0.8.0)
@callback export_user_data(user :: struct()) :: {:ok, map()} | {:error, term()}

Export all data associated with the given user.

Returns {:ok, map()} with the exported data or {:error, reason}. The map keys and structure are implementation-defined.

Functions

export_auth_data(repo, user, opts \\ [])

(since 0.8.0)
@spec export_auth_data(module(), struct(), keyword()) :: {:ok, map()}

Exports Sigra's own auth data for a user.

Returns a versioned map describing Sigra-owned auth/account surfaces for the user. The payload is intentionally explicit and stable so host apps can present or archive it without reverse-engineering Sigra internals.

Options

  • :session_schema - The generated UserSession Ecto schema module.
  • :identity_schema - The generated UserIdentity Ecto schema module.
  • :audit_schema - The generated AuditEvent schema module.
  • :mfa_credential_schema - The generated MFA credential schema module.
  • :backup_code_schema - The generated backup code schema module.
  • :user_passkey_schema - The generated passkey schema module.
  • :membership_schema - The generated organization membership schema module.