---
title: '@svartz/auth/server'
description: The `@svartz/auth/server` entry point.
updated_at: '2026-11-25T17:56:14+01:00'
---

# @svartz/auth/server

## Interfaces

- [Account](https://svartz.dev/reference/api/auth/server/account.md) — A person on the site: one account, however many providers they sign in with.
- [AccountStanding](https://svartz.dev/reference/api/auth/server/accountstanding.md) — An account as a page about it shows it: who it is, its user page and its reputation.
- [AuditEntry](https://svartz.dev/reference/api/auth/server/auditentry.md) — One change, as the log keeps it.
- [AuditLogPage](https://svartz.dev/reference/api/auth/server/auditlogpage.md)
- [AuditQuery](https://svartz.dev/reference/api/auth/server/auditquery.md) — Which entries `readAuditLog` answers.
- [AuditRecord](https://svartz.dev/reference/api/auth/server/auditrecord.md) — An entry as `readAuditLog` answers it. Every string is as its writer stored it: escape it to show it.
- [AuthOptions](https://svartz.dev/reference/api/auth/server/authoptions.md) — The `auth` plugin's options.
- [AuthServerData](https://svartz.dev/reference/api/auth/server/authserverdata.md) — What the plugin's build hook records for the server module.
- [AuthServerOptions](https://svartz.dev/reference/api/auth/server/authserveroptions.md) — What the server module receives: the options, plus where sign-in runs when another vault runs it.
- [IdentityGrant](https://svartz.dev/reference/api/auth/server/identitygrant.md) — A grant a plugin's config gives an identity, such as a moderator it lists, to move onto that identity's account.
- [ProviderOptions](https://svartz.dev/reference/api/auth/server/provideroptions.md) — One provider's OAuth app. The secret is named by environment variable, never inlined.
- [PublicProfile](https://svartz.dev/reference/api/auth/server/publicprofile.md) — A person's public profile, as their handle reaches it.
- [Reversal](https://svartz.dev/reference/api/auth/server/reversal.md) — Taking back what an `edit` or `page` event earned, when the content it scored for is undone.
- [Standing](https://svartz.dev/reference/api/auth/server/standing.md) — Where an account stands: its score, and the next threshold whose role it doesn't hold, if any.
- [SuspendedAccount](https://svartz.dev/reference/api/auth/server/suspendedaccount.md) — A suspended account, as a list of them shows it.
- [Suspension](https://svartz.dev/reference/api/auth/server/suspension.md) — Why an account is suspended, and until when; read by the account itself and by moderators.
- [SuspensionSubject](https://svartz.dev/reference/api/auth/server/suspensionsubject.md) — An account as a moderator about to act on it sees it.
- [Threshold](https://svartz.dev/reference/api/auth/server/threshold.md) — A threshold: reaching `score` gives the account `role`.
- [UserPageLocation](https://svartz.dev/reference/api/auth/server/userpagelocation-interface.md) — Where user pages live: a folder of one vault. Without a `vault`, no page is a user page.

## Types

- [LiftResult](https://svartz.dev/reference/api/auth/server/liftresult.md) — What `liftSuspension` did.
- [PermissionTarget](https://svartz.dev/reference/api/auth/server/permissiontarget.md) — What a check is about: the whole site (`{}`), a vault, or a page of one, by its slug.
- [Recipient](https://svartz.dev/reference/api/auth/server/recipient.md) — Who an entry credits: an account by its id, or the account a provider account (`github:583231`) is linked to.
- [ReputationEvent](https://svartz.dev/reference/api/auth/server/reputationevent.md) — An event that earns points, as a plugin posts it. `ref` names the event, unique within its kind and prefixed with the posting plugin's id (`submissions:…`): posting the same event again changes nothing.
- [SignedOutReason](https://svartz.dev/reference/api/auth/server/signedoutreason.md) — Why `readSignIn` found no account.
- [SignIn](https://svartz.dev/reference/api/auth/server/signin.md) — The signed-in account, or `null` and the reason there is none; for a suspended account, why and until when.
- [SuspendResult](https://svartz.dev/reference/api/auth/server/suspendresult.md) — What `suspend` did: suspended the account, or nothing, because no account has the handle, it's an admin, or it's the actor's.

## Functions

- [audit](https://svartz.dev/reference/api/auth/server/audit.md) — Append `entry` to the audit log. Pass the change itself as `changes`, statements prepared on the same `SVARTZ_DB` binding: they and the entry run as one transaction, so neither lands without the other. For a change kept elsewhere, call this first and make the change only once it resolves. Throws when the site binds no `SVARTZ_DB`, or the write fails.
- [auditIfChanged](https://svartz.dev/reference/api/auth/server/auditifchanged.md) — The statement that appends `entry` only when the statement just before it in the batch changed a row, for a change whose own guard may leave it undone. Its results hold the entry's id when it appended one, and nothing otherwise, so the batch's last result says whether the change happened.
- [can](https://svartz.dev/reference/api/auth/server/can.md) — Whether `account` (`null` for a guest) may do `permission` on `target`: the site (`{}`), a vault (`{ vault }`), or a page of one (`{ vault, page }`, by the page's slug). Grants on the page, its folders, its vault and the site apply, the most specific first; see `resolve` in `permissions.ts` for the order.
- [canEach](https://svartz.dev/reference/api/auth/server/caneach.md) — `can` for each of `targets`, in order, in the D1 calls one check makes: for a list that asks about many pages at once, such as a queue of comments on different pages.
- [findProfile](https://svartz.dev/reference/api/auth/server/findprofile.md) — The public profile of the account that holds or held `handle`, under its current handle; `undefined` when no account ever held it or the site binds no `SVARTZ_DB`. A result whose `handle` differs from the one asked for means the asked one is old: redirect to the current one. Old handles never pass to another account.
- [findProfileByIdentity](https://svartz.dev/reference/api/auth/server/findprofilebyidentity.md) — The public profile of the account provider account `identity` (such as `github:583231`) is linked to, for a plugin that stored who wrote something by their sign-in; `undefined` when no account has it or the site binds no `SVARTZ_DB`.
- [findProfiles](https://svartz.dev/reference/api/auth/server/findprofiles.md) — The public profiles of the accounts with ids `ids`, by id, for plugins that stored an account id, such as a commit's `Svartz-Account` trailer. Ids no account has are absent, and so is every id when the site binds no `SVARTZ_DB`.
- [findProfilesByHandle](https://svartz.dev/reference/api/auth/server/findprofilesbyhandle.md) — `findProfile` for each of `handles` in one D1 call, by the handle asked for; handles no account ever held are absent, and so is every one when the site binds no `SVARTZ_DB`.
- [findProfilesByIdentity](https://svartz.dev/reference/api/auth/server/findprofilesbyidentity.md) — `findProfileByIdentity` for each of `identities` in one D1 call, by identity; identities no account has are absent.
- [findStanding](https://svartz.dev/reference/api/auth/server/findstanding.md) — The account that holds or held `handle`, under its current handle, with its user page and reputation; `undefined` when no account ever held it or the site binds no `SVARTZ_DB`.
- [findSuspension](https://svartz.dev/reference/api/auth/server/findsuspension.md) — The account that holds or held `handle`, for a moderator about to suspend it or lift its suspension; `undefined` when no account ever held it or the site binds no `SVARTZ_DB`.
- [liftSuspension](https://svartz.dev/reference/api/auth/server/liftsuspension.md) — End the suspension in force on the account that holds or held `handle` now, ahead of its time. `"not-suspended"`, recording nothing, when none is in force, as when it ended or another moderator lifted it first. Throws without `SVARTZ_DB`.
- [linkedIdentities](https://svartz.dev/reference/api/auth/server/linkedidentities.md) — Every provider account linked to `account`, the first linked first, each with the profile it last signed in with. Empty when the site binds no `SVARTZ_DB`. `env` is the handler's `context.env`.
- [listSuspensions](https://svartz.dev/reference/api/auth/server/listsuspensions.md) — Every suspension in force, the most recent first; `[]` without `SVARTZ_DB`.
- [migrateGrants](https://svartz.dev/reference/api/auth/server/migrategrants.md) — Give each identity's account its grant, once ever: the first call that finds the identity linked to an account stores the grant, unless that account already holds one for the same permission and object, and records that it did. Later calls change nothing, so a grant an admin changed or removed since stays that way. Answers, per grant, whether it is in place: `false` for an identity with no account yet, which a later call can still move once they sign in, and for every grant when the site binds no `SVARTZ_DB`.
- [postReputation](https://svartz.dev/reference/api/auth/server/postreputation.md) — Record `event` in the ledger, weighed with the site's weights, and give its account any role a threshold now grants. Posting an event again, as a repeated webhook delivery or a poll that reads it again would, scores nothing more, and gives any role the first post failed to give. An event whose recipient has no account changes nothing.
- [readAccount](https://svartz.dev/reference/api/auth/server/readaccount.md) — The account behind `request`, or `null` when nobody is signed in, the session was deleted or expired, the account is suspended, or the site binds no `SVARTZ_DB`. `readSignIn` says which.
- [readAuditLog](https://svartz.dev/reference/api/auth/server/readauditlog.md) — The audit log, newest first, a page at a time, in one query: every plugin's entries, filtered by who made them and what they changed. Throws when the site binds no `SVARTZ_DB`. The log is append-only, so nothing here changes it.
- [readIdentity](https://svartz.dev/reference/api/auth/server/readidentity.md) — Who sent `request`: the provider account they signed in with, or `null` when nobody is signed in or their account is suspended. `env` is the handler's `context.env`. Without a usable `PRIVATE_SVARTZ_SESSION_SECRET` nobody can be signed in, so this answers `null`; the auth routes report the missing secret with a 503. Plugins that need a person rather than a provider account use `readAccount`.
- [readSignIn](https://svartz.dev/reference/api/auth/server/readsignin.md) — The account behind `request`, or `null` and why: signed out, no accounts database bound, or the account suspended, with the suspension's reason and end. `env` is the handler's `context.env`. A cookie from before accounts becomes an account and a session on its first read here.
- [reverseReputation](https://svartz.dev/reference/api/auth/server/reversereputation.md) — Take back what each `edit` or `page` event `ref` earned its `account`, as one `reversal` entry per event under the same ref, all in one transaction however many there are, then give any role a threshold grants. An event is taken back once: reversing it again changes nothing. An event not posted yet still gets its entry, at 0 points, and scores nothing when it is posted; one that was posted and earned `account` nothing (it scored 0, or credited someone else) gets none. A reversal lowers a score but never takes away a role the account holds.
- [suspend](https://svartz.dev/reference/api/auth/server/suspend.md) — Suspend the account that holds or held `handle` until `until`, or for good without it, with `reason`, which the account reads. It replaces any suspension in force. `actor` is the signed-in moderator, from `readAccount`; check their permission first. Refused without writing anything for an admin and for the actor's own account. Throws without `SVARTZ_DB`.
- [userPageLocation](https://svartz.dev/reference/api/auth/server/userpagelocation-function.md) — Where user pages live, such as `{ vault: "notes", folder: "users" }`.
- [userPageOf](https://svartz.dev/reference/api/auth/server/userpageof.md) — The URL, below the deployment base, of the user page at `handle`; `undefined` while there is none, for a hidden one, and until the vault that holds user pages has started.

## Variables

- [ACCOUNTS_DATABASE_ENV](https://svartz.dev/reference/api/auth/server/accounts_database_env.md) — The D1 binding accounts live in. A fixed name, like `PRIVATE_SVARTZ_SESSION_SECRET`, because every server plugin reads accounts with only `(request, env)` in hand.
- [ADMIN_ROLE](https://svartz.dev/reference/api/auth/server/admin_role.md) — The role bootstrap admins hold.
- [default](https://svartz.dev/reference/api/auth/server/default.md) — The `auth` server module: `server: { module, options, pages: ["account", "dashboard", "groups"] }` with `AuthOptions`.
- [LIFT_ACTION](https://svartz.dev/reference/api/auth/server/lift_action.md)
- [SUSPEND_ACTION](https://svartz.dev/reference/api/auth/server/suspend_action.md) — The audit log's actions for a suspension and for lifting one early.

## Re-exports

- [Identity](https://svartz.dev/reference/api/auth/identity.md)
- [ProviderId](https://svartz.dev/reference/api/auth/providerid.md)
