Skip to content

A free and open source instant messaging and VoIP chat app built for friends, groups, and communities.

TypeScript fluxerfluxerapp

docs: document email code sign-in, sign-up, drop passkey bridge

Hampus352206051053
diff --git a/fluxer_docs/src/content/docs/gateway/overview.md b/fluxer_docs/src/content/docs/gateway/overview.md
index 29a6cbaed..2f1ba0178 100644
--- a/fluxer_docs/src/content/docs/gateway/overview.md
+++ b/fluxer_docs/src/content/docs/gateway/overview.md
@@ -46,7 +46,7 @@ Read `endpoints.gateway` from the [instance discovery document](/http-api/instan
## Connection parameters
-Append the connection parameters to the discovered URL.
+Add the connection parameters to the query of the discovered URL. The URL an instance derives from its domain has no query, but an operator can set one that has its own query. Parse the URL and set each parameter on it, and don't append `?` and a string.
| Field | Type | Description |
| --- | --- | --- |
diff --git a/fluxer_docs/src/content/docs/http-api/authentication.mdx b/fluxer_docs/src/content/docs/http-api/authentication.mdx
index 04d3ce57b..1508948eb 100644
--- a/fluxer_docs/src/content/docs/http-api/authentication.mdx
+++ b/fluxer_docs/src/content/docs/http-api/authentication.mdx
@@ -1,7 +1,7 @@
---
# SPDX-License-Identifier: AGPL-3.0-or-later
title: Authentication resource
-description: Registration, login, credentials, sessions, recovery, SSO, IP authorisation, desktop handoff, origin handoff, and the passkey bridge.
+description: Registration, login, credentials, sessions, recovery, SSO, IP authorisation, desktop handoff, and origin handoff.
---
import RouteHeader from '@/components/RouteHeader.astro';
@@ -22,7 +22,7 @@ Every route has a route bucket and is also subject to the [global HTTP limit](/t
An invalid JSON shape returns 400 `INVALID_FORM_BODY` with [validation error object](/http-api/#validation-error-object) entries in `errors`. An unexpected failure returns 500 `INTERNAL_SERVER_ERROR`. Every enumerated code on this page is registered in [Errors](/http-api/errors/), and every snowflake field is the decimal string form defined by [Snowflakes](/snowflakes/).
-When SSO is both enabled and enforced, every local authentication operation returns 403 `SSO_REQUIRED`. The SSO status route, SSO start and completion, logout, both session routes, every handoff route, and the passkey bridge options, complete, and cancel routes stay available under enforcement. Every other route on this page is a local authentication operation.
+When SSO is both enabled and enforced, every local authentication operation returns 403 `SSO_REQUIRED`. The SSO status route, SSO start and completion, logout, both session routes, and every handoff route stay available under enforcement. [Complete login with TOTP](#complete-login-with-totp), [get WebAuthn MFA options](#get-webauthn-mfa-options) and [complete login with WebAuthn MFA](#complete-login-with-webauthn-mfa) stay available for a ticket that [complete SSO](#complete-sso) returned. Every other route on this page is a local authentication operation.
:::caution[SSO enforcement precedes every other check]
An enforced instance returns 403 `SSO_REQUIRED` even for a malformed or unauthenticated local authentication request.
@@ -38,7 +38,7 @@ Revoking a session, whether the account revoked it or an administrator terminate
## Authentication token response object
-A newly issued session token and the account it belongs to. Password login without a second factor, MFA completion, discoverable WebAuthn authentication, immediate registration, password reset, account recovery, email reversion, SSO completion, IP authorisation polling, and handoff polling all return these fields.
+A newly issued session token and the account it belongs to. Password login without a second factor, MFA completion, discoverable WebAuthn authentication, immediate registration, password reset, account recovery, email reversion, SSO completion, IP authorisation polling, sign-in link redemption, and handoff polling all return these fields.
### Structure
@@ -47,9 +47,15 @@ A newly issued session token and the account it belongs to. Password login witho
| token<sup>1</sup> | string | The newly issued user session token |
| user_id | snowflake | The authenticated user ID |
| user | [partial user](/http-api/users/#partial-user-object) object | The public representation of the authenticated account |
+| device_proof?<sup>2</sup> | string | A value to keep beside the account and send to [identify an account](#identify-an-account) from this device later |
+| entry?<sup>3</sup> | ?[guild entry](/http-api/users/current-user/#guild-entry-object) object | The community to open next, from the invite used at sign-up |
<sup>1</sup> The token is the literal prefix `flx_` followed by exactly 36 base62 characters, and this response is the only way to read it
+<sup>2</sup> Returned by sign-in, sign-up and handoff redemption. It is not a credential and signs nothing in on its own
+
+<sup>3</sup> Returned only by registration. Null when no invite applied, or while the account still has to enter a date of birth
+
:::caution[A session token is returned once]
A lost session token cannot be recovered through any operation. The account MUST authenticate again to obtain a new session.
:::
@@ -69,6 +75,7 @@ The public single sign-on state. The same object is embedded by the [instance di
| enabled<sup>1</sup> | boolean | Whether SSO can be started on this instance |
| enforced<sup>2</sup> | boolean | Whether SSO is required for every user |
| display_name | ?string | The configured provider display name, or null when none is set |
+| button_label | ?string | The text the operator set for the SSO sign-in button, or null when the client shows its own default label |
| redirect_uri | string | The default OAuth2 redirect URI used for the provider callback |
| available? | boolean | Whether an SSO provider is configured for this instance |
@@ -94,7 +101,7 @@ A client MUST return the state unchanged and MUST NOT interpret its contents.
## SSO completion response object
-SSO completion always issues a session. It extends the [authentication token response](#authentication-token-response) with the redirect bound to the consumed state.
+The result of [complete SSO](#complete-sso). It extends an [authentication token response](#authentication-token-response) or an [MFA challenge response](#mfa-challenge-response) with the redirect bound to the consumed state.
### Structure
@@ -107,9 +114,7 @@ SSO completion always issues a session. It extends the [authentication token res
<sup>1</sup> The value is the empty string when [start SSO](#start-sso) received no `redirect_to` or when the supplied value did not survive sanitisation
-:::note[SSO completion never issues an MFA challenge]
-Completion does not check the account's second factor and cannot return an [MFA challenge response](#mfa-challenge-response). A client MUST NOT branch on an `mfa` member here.
-:::
+A client MUST branch on the `mfa` member. When it is `true`, the object has the MFA challenge fields and `redirect_to` instead of a session, and the client finishes the sign-in with the ticket the same way as after [password login](#log-in-with-a-password).
## Registration pending approval response object
@@ -130,7 +135,7 @@ Every authenticated result on this page embeds the public account representation
## MFA challenge response object
-The ticket and the method list a client needs to finish a login with a second factor. Password login returns this object when the account has one.
+The ticket and the method list a client needs to finish a login with a second factor. Password login returns this object when the account has one, and [complete SSO](#complete-sso) returns it inside its response before it first links such an account.
### Structure
@@ -159,7 +164,7 @@ The ticket and the method list a client needs to finish a login with a second fa
Both WebAuthn option operations return a PublicKeyCredential request options object that a browser passes straight to its credential request. The [WebAuthn authentication options object](/http-api/users/mfa/#webauthn-authentication-options-object) on the Multi-factor authentication resource defines its fields, together with its [WebAuthn credential descriptor](/http-api/users/mfa/#webauthn-credential-descriptor-object) and [WebAuthn client extension inputs](/http-api/users/mfa/#webauthn-client-extension-inputs-object) objects.
-A challenge issued for MFA completion is also bound to its ticket and account, so it cannot be replayed against discoverable login. The MFA route lists one group of the resolved account's credentials in `allowCredentials`, and the discoverable route omits the member, because discovery happens at the authenticator. [Passkey domain selection](/http-api/users/mfa/#passkey-domain-selection) decides the group and `rpId` on both routes.
+A challenge issued for MFA completion is also bound to its ticket and account, so it cannot be replayed against discoverable login. The MFA route lists one group of the resolved account's credentials in `allowCredentials`, and the discoverable route omits the member, because discovery happens at the authenticator.
<a id="webauthn-assertion"></a>
@@ -219,8 +224,6 @@ The approximate geolocation Fluxer derives from the IP address recorded for a se
## Password reset validity object
-The result of checking a password reset token without consuming it.
-
### Structure
| Field | Type | Description |
@@ -259,8 +262,6 @@ The state of one IP authorisation ticket, as observed by the device whose sign-i
## Username suggestions object
-Username candidates derived from a display name.
-
### Structure
| Field | Type | Description |
@@ -271,169 +272,142 @@ Username candidates derived from a display name.
## Username availability object
-Whether a username is free for a new account.
-
### Structure
| Field | Type | Description |
| --- | --- | --- |
| available | boolean | Whether no other account holds the username |
-## Handoff initiation object
+## Identify response object
-The code that identifies one pending desktop handoff.
+The next step after [identify an account](#identify-an-account).
### Structure
| Field | Type | Description |
| --- | --- | --- |
-| code<sup>1</sup> | string | The handoff code to present to the approving device |
-| expires_at | ISO8601 timestamp | The time at which the handoff expires, five minutes after creation |
-| poll_secret? | string | The secret the initiating device presents to read the issued token |
-| return_method? | string | How the approving browser hands the sign-in back, `deep_link` when the request registered a `return_uri` and `code` otherwise |
-
-<sup>1</sup> The code is 12 characters drawn from the alphabet `ABCDEFGHJKMNPQRSTUVWXYZ23456789`, rendered as two groups of six separated by a hyphen
+| ticket<sup>1</sup> | string | The ticket the next step sends |
+| account | string | `existing` when an account uses the identifier, `new` otherwise |
+| sign_in_method | ?string | `password` when the existing account has a password, `code` when it has none, and null when `account` is `new` |
+| registration<sup>2</sup> | ?[identify registration](#identify-registration-object) object | What signing up needs, present when `account` is `new` |
-:::caution[The code alone reads the device metadata]
-Anyone who learns the code reads the pending device metadata. Reading the token and cancelling the handoff both require `poll_secret`. A client MUST show the code only to the person performing the handoff.
-:::
+<sup>1</sup> The ticket is valid for 15 minutes and names the identifier only. It holds no credential
-## Handoff information object
+<sup>2</sup> Null when `account` is `existing`
-The device metadata shown to the approving device before it transfers a session.
-
-### Structure
+### Identify registration object
| Field | Type | Description |
| --- | --- | --- |
-| status | string | The state, either `pending` or `expired` |
-| client_info?<sup>1</sup> | ?[client info](#client-info-object) object | The initiating device metadata |
-| return_method? | string | How the approving browser hands the sign-in back, either `deep_link` or `code`, present only when the status is `pending` |
+| mode | string | How new accounts are admitted, one of `open`, `approval` or `closed` |
+| consent_required | boolean | Whether signing up needs `consent` set to true |
+| requires_password | boolean | Whether signing up needs a password, because the instance cannot send email codes |
+| instant_account_availability?<sup>1</sup> | string | One of the [instant account availability](/http-api/instance/#instant-account-availability) values |
-<sup>1</sup> The value is null whenever the status is `expired`
+<sup>1</sup> Whether an account can be created from just a display name, with `registration_url_code` taken into account
-## Handoff status object
+An account with a password signs in with its password, and a passkey also works. Only an account without a password signs in with an email code.
-The state of one desktop handoff as observed by the device that initiated it.
+## Email code send response object
### Structure
| Field | Type | Description |
| --- | --- | --- |
-| status<sup>1</sup> | string | The state, one of `pending`, `denied`, `expired`, or `completed` |
-| token?<sup>2</sup> | ?string | The newly issued user session token |
-| user_id?<sup>2</sup> | ?snowflake | The authenticated user ID |
-| user?<sup>2</sup> | ?[partial user](/http-api/users/#partial-user-object) object | The public representation of the authenticated account |
-
-<sup>1</sup> An unknown code and an expired code both report `expired`
-
-<sup>2</sup> The fields are present together only when the status is `completed`
-
-## Handoff completion object
+| purpose | string | `sign_in` when the code signs in to an existing account, `sign_up` when it creates one |
+| code_expires_at | ISO8601 timestamp | When the emailed code stops working, 10 minutes after sending |
+| resend_available_at | ISO8601 timestamp | When another code can be requested, 30 seconds after sending |
-The deep link that returns a completed handoff to the initiating app.
+## Account handoff object
### Structure
| Field | Type | Description |
| --- | --- | --- |
-| return_url<sup>1</sup> | string | The registered `return_uri` with the handoff `code` and a one-time `grant` in its query string |
+| handoff_code | string | The code the web app or a native app redeems, 43 URL-safe base64 characters |
-<sup>1</sup> The grant is 32 random bytes as 43 base64url characters, and only the initiating app that receives the link can present it
-
-## Origin handoff object
-
-The identifier of one stored origin handoff.
+## CAPTCHA challenge object
### Structure
| Field | Type | Description |
| --- | --- | --- |
-| handoff_id | string | The single-use identifier the receiving origin redeems, 32 random bytes as 43 base64url characters |
+| captcha_provider | string | `altcha` while the check is on and `none` while it is off |
+| altcha_challenge? | object | The ALTCHA challenge, present when `captcha_provider` is `altcha` |
-## Origin handoff payload object
+## Handoff initiation object
-The client state released by one redeemed origin handoff.
+The code that identifies one pending desktop handoff.
### Structure
| Field | Type | Description |
| --- | --- | --- |
-| payload | string | The base64url string stored by [create origin handoff](#create-origin-handoff), returned unchanged |
-
-## Passkey bridge
-
-The official instance is moving its web client from `https://web.fluxer.app` to `https://fluxer.com`, and its canary client from `https://web.canary.fluxer.app` to `https://canary.fluxer.com`. A passkey works only under the domain it was created for, so a page on a new origin cannot use a passkey created for `fluxer.app`. The passkey bridge runs that passkey somewhere that can, then hands the result back to the new origin.
-
-The bridge exists only on the official instance and only for requests from the two new origins. It keeps working while the [domain migration switch](/http-api/instance/#domain-migration-object) is off, so people already on a new origin can still use their passkeys. Every bridge route on a self-hosted instance returns 403 `INVALID_API_ORIGIN`.
+| code<sup>1</sup> | string | The handoff code to present to the approving device |
+| expires_at | ISO8601 timestamp | The time at which the handoff expires, five minutes after creation |
+| poll_secret? | string | The secret the initiating device presents to read the issued token |
+| return_method? | string | How the approving browser hands the sign-in back, `deep_link` when the request registered a `return_uri` and `code` otherwise |
-A ceremony has one of three purposes. `login` signs in with any passkey the person picks, `login_mfa` finishes a password login whose second factor is passkeys, and `sudo` proves [sudo mode](/http-api/users/mfa/#sudo-mode) through [start passkey bridge sudo verification](/http-api/users/mfa/#start-passkey-bridge-sudo-verification). It also has one of two runners. With `page`, the ceremony runs on the paired legacy origin at `/passkey-bridge`. With `native`, the desktop client on the new origin runs it itself.
+<sup>1</sup> The code is 12 characters drawn from the alphabet `ABCDEFGHJKMNPQRSTUVWXYZ23456789`, rendered as two groups of six separated by a hyphen
-A ceremony runs in four steps.
+:::caution[The code alone reads the device metadata]
+Anyone who learns the code reads the pending device metadata. Reading the token and cancelling the handoff both require `poll_secret`. A client MUST show the code only to the person performing the handoff.
+:::
-1. The page on the new origin draws a nonce, keeps it, and starts the ceremony with the nonce's SHA-256 digest.
-2. The runner fetches [passkey bridge options](#get-passkey-bridge-options), asks the authenticator, and calls [complete passkey bridge](#complete-passkey-bridge) or [cancel passkey bridge](#cancel-passkey-bridge).
-3. Completing or cancelling issues a completion code. The `page` runner gets it in the fragment of `return_url` and navigates there. The `native` runner gets it in the response.
-4. The page on the new origin redeems the ceremony once with the nonce and the completion code.
+## Handoff information object
-Redemption needs both secrets. Someone who starts a ceremony and sends another person the bridge link holds the nonce, but the completion code reaches the other person's browser, which holds no nonce.
+The device metadata shown to the approving device before it transfers a session.
-A ceremony lasts 10 minutes from its start, or 5 minutes for `login_mfa`, which is the life of an MFA ticket. It is `pending` until it completes or is cancelled. Only a passkey the account lists for `fluxer.app` completes a ceremony. A [replaced passkey](/http-api/users/mfa/#replaced-passkeys) never does.
+### Structure
-When the request comes from a new origin and the instance-wide [domain migration switch](/http-api/instance/#domain-migration-object) is on, a completed redemption also opens a [passkey update](/http-api/users/mfa/#passkey-updates) for the session it signs in, or for the session that proves sudo mode.
+| Field | Type | Description |
+| --- | --- | --- |
+| status | string | The state, either `pending` or `expired` |
+| client_info?<sup>1</sup> | ?[client info](#client-info-object) object | The initiating device metadata |
+| return_method? | string | How the approving browser hands the sign-in back, either `deep_link` or `code`, present only when the status is `pending` |
-## Passkey bridge start object
+<sup>1</sup> The value is null whenever the status is `expired`
-One started passkey bridge ceremony.
+## Handoff status object
### Structure
| Field | Type | Description |
| --- | --- | --- |
-| ceremony_id | string | The ceremony identifier, 32 random bytes as 43 base64url characters |
-| bridge_url<sup>1</sup> | ?string | The page that runs the ceremony |
+| status<sup>1</sup> | string | The state, one of `pending`, `denied`, `expired`, or `completed` |
+| token?<sup>2</sup> | ?string | The newly issued user session token |
+| user_id?<sup>2</sup> | ?snowflake | The authenticated user ID |
+| user?<sup>2</sup> | ?[partial user](/http-api/users/#partial-user-object) object | The public representation of the authenticated account |
-<sup>1</sup> The paired legacy origin, the path `/passkey-bridge`, and the ceremony ID as the fragment. Null for the `native` runner
+<sup>1</sup> An unknown code and an expired code both report `expired`
-## Passkey bridge options object
+<sup>2</sup> The fields are present together only when the status is `completed`
-The WebAuthn request for one pending ceremony.
+## Handoff completion object
### Structure
| Field | Type | Description |
| --- | --- | --- |
-| options | [WebAuthn authentication options](#webauthn-authentication-options) object | The request options the runner passes to the authenticator |
+| return_url<sup>1</sup> | string | The registered `return_uri` with the handoff `code` and a one-time `grant` in its query string |
-## Passkey bridge finish object
+<sup>1</sup> The grant is 32 random bytes as 43 base64url characters, and only the initiating app that receives the link can present it
-What the runner does after a ceremony completes or is cancelled. Exactly one field is non-null.
+## Origin handoff object
### Structure
| Field | Type | Description |
| --- | --- | --- |
-| return_url<sup>1</sup> | ?string | Where the `page` runner goes next, null for the `native` runner |
-| completion_code<sup>2</sup> | ?string | The code the `native` runner redeems, null for the `page` runner |
-
-<sup>1</sup> Always `/passkey-bridge` on the new origin, whatever the purpose. The fragment is `passkey-bridge=` followed by the ceremony ID, a full stop, and the completion code. The page there decides where the code goes next from what the starting tab kept, so the start request cannot choose where the code lands
-
-<sup>2</sup> 32 random bytes as 43 base64url characters. Each call issues a new one
-
-## Passkey bridge sign-in redemption object
+| handoff_id | string | The single-use identifier the receiving origin redeems, 32 random bytes as 43 base64url characters |
-The result of one redeemed `login` or `login_mfa` ceremony.
+## Origin handoff payload object
### Structure
| Field | Type | Description |
| --- | --- | --- |
-| status | string | The ceremony state, either `completed` or `cancelled` |
-| token?<sup>1</sup> | string | The newly issued user session token |
-| user_id?<sup>1</sup> | snowflake | The authenticated user ID |
-| user?<sup>1</sup> | [partial user](/http-api/users/#partial-user-object) object | The public representation of the authenticated account |
-
-<sup>1</sup> Present together only when the status is `completed`
+| payload | string | The base64url string stored by [create origin handoff](#create-origin-handoff), returned unchanged |
## Get SSO status
@@ -494,6 +468,8 @@ The returned state can be completed once and expires after ten minutes. Starting
Completes a single sign-on flow and signs in or creates the linked account. Authentication is not required. Returns an [SSO completion response](#sso-completion-response-object).
+When the provider subject is not yet linked and the verified provider email belongs to an account with a second factor, completion returns the MFA challenge shape of that response. The account has a second factor when it has TOTP, passkeys as a second factor, or an unconsumed backup code. Fluxer binds the subject to the account and issues the session only when the ticket completes through [complete login with TOTP](#complete-login-with-totp) or [complete login with WebAuthn MFA](#complete-login-with-webauthn-mfa), and that completion returns an [authentication token response](#authentication-token-response). A ticket that expires leaves the subject unlinked. Later sign-ins with the linked subject return a session directly.
+
### JSON body
| Field | Type | Description |
@@ -504,18 +480,20 @@ Completes a single sign-on flow and signs in or creates the linked account. Auth
<sup>1</sup> The state is consumed on the first call that resolves it, so a repeated request with the same state returns the field code `INVALID_OR_EXPIRED_SSO_STATE`
:::note[Identity binding is one-to-one]
-A provider subject is bound to exactly one Fluxer account, and an account accepts exactly one provider subject. A subject already linked to a different account, or a new subject for an account that already holds a different linked subject, returns the field code `SSO_IDENTITY_MISMATCH`.
+A provider subject is bound to exactly one Fluxer account, and an account accepts exactly one provider subject. A subject already linked to a different account returns the field code `SSO_IDENTITY_LINKED_TO_ANOTHER_ACCOUNT`, and a new subject for an account that already holds a different linked subject returns `SSO_ACCOUNT_LINKED_TO_ANOTHER_IDENTITY`.
:::
:::caution[A verified provider email adopts a local account]
-When the subject is not yet linked, Fluxer adopts any existing account holding the verified email address in the provider claim and binds the subject to it, whether or not that account has a password or an authenticator. A provider that asserts an arbitrary verified address therefore takes over the matching local account. An operator MUST enable SSO only for a provider that controls the addresses it asserts.
+When the subject is not yet linked, Fluxer adopts any existing account holding the verified email address in the provider claim and binds the subject to it, whether or not that account has a password. A provider that asserts an arbitrary verified address therefore takes over a matching local account that has no second factor. An operator MUST enable SSO only for a provider that controls the addresses it asserts.
:::
Fluxer refuses the adoption only when the account already holds a different provider subject.
-The provider exchange and claim resolution can return the field codes `INVALID_SSO_AUTHORIZATION_CODE`, `INVALID_SSO_TOKEN`, `FAILED_TO_FETCH_SSO_USER_INFO`, `FAILED_TO_PARSE_SSO_USER_INFO`, `SSO_PROVIDER_DID_NOT_RETURN_EMAIL`, `SSO_IDENTITY_MISMATCH`, `SSO_MISCONFIGURED`, `INVALID_EMAIL_ADDRESS`, `EMAIL_DOMAIN_NOT_ALLOWED_FOR_SSO`, or `SSO_UNABLE_TO_ALLOCATE_DISCRIMINATOR`. An unverified provider email uses the field code `INVALID_SSO_TOKEN`.
+While the instance enforces single sign-on, a sign-in on an instance where people sign in with an email replaces the account email with a different verified provider email, unless another account already holds it. Deleting an account releases its provider subject, so the next sign-in with that subject provisions a new account. An account closed by an enforcement action keeps its subject, and a sign-in with it returns 403 `ACCOUNT_SUSPENDED_PERMANENTLY`.
+
+The provider exchange and claim resolution can return the field codes `INVALID_SSO_AUTHORIZATION_CODE`, `INVALID_SSO_TOKEN`, `FAILED_TO_FETCH_SSO_USER_INFO`, `FAILED_TO_PARSE_SSO_USER_INFO`, `SSO_PROVIDER_DID_NOT_RETURN_EMAIL`, `SSO_EMAIL_NOT_VERIFIED`, `SSO_IDENTITY_MISMATCH` when the ID token and the user info disagree on the subject or email, `SSO_MISCONFIGURED`, `INVALID_EMAIL_ADDRESS`, `EMAIL_DOMAIN_NOT_ALLOWED_FOR_SSO`, or `SSO_UNABLE_TO_ALLOCATE_DISCRIMINATOR`. A missing provider email returns the field code `SSO_PROVIDER_DID_NOT_RETURN_EMAIL`, and one the provider marks as unverified returns `SSO_EMAIL_NOT_VERIFIED`. On an instance where people sign in with a username, the email claim is optional unless the SSO configuration lists allowed email domains. Without a domain list, such an instance ignores an unverified email and identifies the account by the subject alone.
-Closed registration returns 403 `REGISTRATION_CLOSED`, an unknown account on an instance with automatic provisioning disabled returns 403 `SSO_REQUIRED`, an account awaiting approval returns 403 `REGISTRATION_PENDING_APPROVAL`, and account suspension returns 403 `ACCOUNT_SUSPENDED_TEMPORARILY` or 403 `ACCOUNT_SUSPENDED_PERMANENTLY`. A provisioned username or display name containing a blocked substring returns 403 `CONTENT_BLOCKED`.
+Closed registration doesn't stop automatic provisioning, because the provider decides who can sign in. A new account on a self-hosted instance that has its first admin account but hasn't finished setup returns 403 `REGISTRATION_CLOSED`. Before that admin account exists, an instance that enforces its setup token returns the field code `SETUP_TOKEN_REQUIRED` for a new account. An unknown account on an instance with automatic provisioning disabled returns 403 `SSO_REQUIRED`, an account awaiting approval returns 403 `REGISTRATION_PENDING_APPROVAL`, and account suspension returns 403 `ACCOUNT_SUSPENDED_TEMPORARILY` or 403 `ACCOUNT_SUSPENDED_PERMANENTLY`. A provisioned username or display name containing a blocked substring returns 403 `CONTENT_BLOCKED`.
A verified provider email that adopts a bot account returns 403 `BOT_USER_AUTH_SESSION_CREATION_DENIED`, and one that adopts a rejected registration returns 403 `REGISTRATION_REJECTED`.
@@ -523,7 +501,7 @@ A verified provider email that adopts a bot account returns 403 `BOT_USER_AUTH_S
| Status | Body | Condition |
| --- | --- | --- |
-| 200 | [SSO completion response](#sso-completion-response-object) | SSO completed and a session was issued |
+| 200 | [SSO completion response](#sso-completion-response-object) | SSO completed and a session was issued, or the account's second factor is needed first |
| 400 | [error response](/http-api/#error-response) | The body, state, provider exchange, claims, or resolved email is invalid |
| 403 | [error response](/http-api/#error-response) | SSO, registration policy, a bot account, or account suspension rejects completion |
| 429 | [rate limit response](/topics/rate-limits/#rate-limit-response-object) | Route or global bucket denies the request |
@@ -534,7 +512,7 @@ A verified provider email that adopts a bot account returns 403 `BOT_USER_AUTH_S
A failed completion requires a fresh SSO flow. A newly created account has a verified email, no local password or authenticator, and default settings. SSO registration accepts no invite and joins no guild.
-Approval mode registration instead returns 403 `REGISTRATION_PENDING_APPROVAL` and creates no session. Otherwise the operation creates one authentication session and clears an expired temporary suspension.
+Approval mode registration instead returns 403 `REGISTRATION_PENDING_APPROVAL` and creates no session. An MFA challenge creates no session and links nothing. Otherwise the operation creates one authentication session and clears an expired temporary suspension.
### Rate limit
@@ -544,10 +522,12 @@ Approval mode registration instead returns 403 `REGISTRATION_PENDING_APPROVAL` a
<RouteHeader method="POST" path="/v1/auth/register" unauthenticated />
-Creates an ordinary account. Returns an [authentication token response](#authentication-token-response) when the instance admits the account immediately and a [registration pending approval response](#registration-pending-approval-response-object) when it does not. Emits a [Guild Member Add](/gateway/events/#guild-member-add) Gateway event for each guild the new account joins through an invite or through the instance's single community guild.
+Creates an ordinary account, or an account without an email. Returns an [authentication token response](#authentication-token-response) when the instance admits the account immediately and a [registration pending approval response](#registration-pending-approval-response-object) when it does not. Emits a [Guild Member Add](/gateway/events/#guild-member-add) Gateway event for each guild the new account joins through an invite or through the instance's single community guild.
Registration verifies a [CAPTCHA](/topics/captcha/). It permits 3 attempts per hour for each client IP address and 15 per hour for each client subnet, which is the IPv4 /24 or IPv6 /48 network. A supplied email address permits 3 attempts per 15 minutes of its own, except on a `username` instance, which discards the address. Those allowances are separate from the route bucket, and only a deployment with `dev.relax_registration_rate_limits` set to true disables them.
+A body with no `password`, and on an `email` instance no `email` either, asks for an account without an email. New clients send only `global_name`, the name the person wants others to see, and the server derives a username from it. With the `random` [tag style](/http-api/instance/#tag-styles) the server allocates a discriminator for that name, and with `none` it makes the derived username unique and gives it the discriminator `0000`. Either way the person never picks a username and nothing is ever taken. The instance must allow these [instant accounts](/admin-api/instance/#auth-configuration-object), and otherwise the request returns 403 `INSTANT_ACCOUNTS_DISABLED`. The person keeps the account by [claiming it](/http-api/users/current-user/#claim-an-account), which adds an email on an `email` instance and sets a password on a `username` instance. The claim result has `next_step`, which is `confirm_email` when a code was emailed to the new address and `none` when the claim is already complete. They replace the allowances above with 5 accounts per hour and 20 per day for each client IP address, and 40 per hour for each subnet. The CAPTCHA cost doubles for each instant account the same IP address created in the last hour, and once more for each block of accounts the whole instance created in the hour, up to 64 times the base cost.
+
### Request headers
| Field | Type | Description |
@@ -568,31 +548,31 @@ Registration verifies a [CAPTCHA](/topics/captcha/). It permits 3 attempts per h
| global_name? | string | The display name after normalisation (1-32 characters) |
| password?<sup>3</sup> | string | The account password (8-256 characters) |
| date_of_birth?<sup>4</sup> | string | The date of birth in exact `YYYY-MM-DD` form |
-| consent?<sup>5</sup> | boolean | Whether the terms of service and privacy policy are accepted (default false) |
+| consent?<sup>5</sup> | boolean | Whether the person submitted the step that says creating the account accepts the terms of service (default false) |
| invite_code? | ?string | The invite accepted immediately after registration (0-256 characters) |
| registration_url_code?<sup>6</sup> | ?string | The administrator-issued registration URL code (1-256 characters) |
| theme? | string | The initial theme preference, one of `dark`, `dark_legacy`, `coal`, `light`, or `system` |
| setup_token?<sup>7</sup> | ?string | The setup token of a new self-hosted instance (1-256 characters) |
-<sup>1</sup> Omitting the email address creates an unclaimed account, which has no recovery path until it is claimed. An address whose domain has no usable DNS records, or whose top-level domain the instance blocks, returns the field code `INVALID_EMAIL_ADDRESS`, and an address already in use returns `EMAIL_ALREADY_IN_USE`. A `username` instance accepts any string of 1-320 characters here, because older apps send one, and discards it. It stores no address and sends no email. It does not check the address against DNS or the blocklists, or whether another account uses it
+<sup>1</sup> Omitting the email address creates an unclaimed account, which has no recovery path until it is [claimed](/http-api/users/current-user/#claim-an-account). An address stored on any account is in use, whether or not it is confirmed. An address whose domain has no usable DNS records, or whose top-level domain the instance blocks, returns the field code `INVALID_EMAIL_ADDRESS`, and an address already in use returns `EMAIL_ALREADY_IN_USE`. When the instance lists allowed email domains, an address on any other domain returns the field code `EMAIL_DOMAIN_NOT_ALLOWED`, unless the sign-up uses an admin-issued registration URL. A `username` instance accepts any string of 1-320 characters here, because older apps send one, and discards it. It stores no address and sends no email. It does not check the address against DNS or the blocklists, or whether another account uses it
-<sup>2</sup> Omitting the username derives one from `global_name` when that value produces a permitted username, and otherwise allocates a generated username, in both cases with a server-allocated discriminator. On a `username` instance a body with `password` and neither `username` nor `email` returns the field code `USERNAME_LENGTH_INVALID`. A body there with `email` and no `username` asks for the part before the `@` as the username when the address is at the [instance host](#log-in-with-a-password), normalised the way a display name is, so `[email protected]` asks for `alex_lee` and `alex#[email protected]` asks for `alex`. A name another account holds then returns `USERNAME_ALREADY_TAKEN` on `username`. A part that cannot be a username returns the field code a `username` value would, such as `USERNAME_RESERVED_VALUE`, on `username`. An address at any other host, a value with no `@` and a value with a second `@` return `INSTANCE_ADDRESS_REQUIRED` on `email`, whose message names the instance host. Only a body without `email` gets a username from `global_name` or the generator. With the `none` [tag style](/http-api/instance/#tag-styles), a username another account holds in any letter case returns `USERNAME_ALREADY_TAKEN`, a derived username is made unique first, and every account gets the discriminator `0000`. With `random`, which only an `email` instance can use, the discriminator is random
+<sup>2</sup> Omitting the username derives one from `global_name`: the display name is normalised (NFKC), transliterated to Latin letters (so `Åsa Öberg` gives `Asa_Oberg`, `Дмитрий` gives `Dmitriy` and `さくら` gives `sakura`), and reduced to letters, digits and single underscores of at most 32 characters. Reserved terms are dropped, a name that is reserved on its own such as `everyone` gets a few digits, and a name that leaves nothing, such as emoji only, or one with a blocked substring gets a generated username instead. When every discriminator for the derived name is in use, a close variant with a few digits is used, and a generated username after that. Without `global_name` a generated username is allocated. With `random` all of these get a server-allocated discriminator. On a `username` instance a body with `password` and neither `username` nor `email` returns the field code `USERNAME_LENGTH_INVALID`. A body there with `email` and no `username` asks for the part before the `@` as the username when the address is at the [instance host](#log-in-with-a-password), normalised the way a display name is, so `[email protected]` asks for `alex_lee` and `alex#[email protected]` asks for `alex`. A name another account holds then returns `USERNAME_ALREADY_TAKEN` on `username`. A part that cannot be a username returns the field code a `username` value would, such as `USERNAME_RESERVED_VALUE`, on `username`. An address at any other host, a value with no `@` and a value with a second `@` return `INSTANCE_ADDRESS_REQUIRED` on `email`, whose message names the instance host. Only a body without `email` gets a username from `global_name` or the generator. With the `none` [tag style](/http-api/instance/#tag-styles), a username another account holds in any letter case returns `USERNAME_ALREADY_TAKEN`, a derived username is made unique first, and every account gets the discriminator `0000`. With `random`, which only an `email` instance can use, the discriminator is random
<sup>3</sup> The password is checked against the public breached-password corpus described under [reset a password](#reset-a-password), and a match returns the field code `PASSWORD_IS_TOO_COMMON`
-<sup>4</sup> The field is required when the instance [collects date of birth](/http-api/instance/#public-registration-fields-object). An absent or blank value, or a value in `YYYY-MM-DD` shape that is not a real calendar date, returns the field code `INVALID_DATE_OF_BIRTH_FORMAT`. A value that is not ten characters in `YYYY-MM-DD` shape fails schema validation with the field code `STRING_LENGTH_EXACT` or `INVALID_FORMAT`
+<sup>4</sup> Read only when the instance [collects date of birth](/http-api/instance/#public-registration-fields-object). An absent value creates the account anyway, and the account then has to [set its date of birth](/http-api/users/current-user/#set-date-of-birth) before most other operations. A blank value, or a value in `YYYY-MM-DD` shape that is not a real calendar date, is today or later, or lies more than 120 years before today (UTC), returns the field code `INVALID_DATE_OF_BIRTH_FORMAT`. A value that is not ten characters in `YYYY-MM-DD` shape fails schema validation with the field code `STRING_LENGTH_EXACT` or `INVALID_FORMAT`
-<sup>5</sup> A false or absent value returns the field code `MUST_AGREE_TO_TOS_AND_PRIVACY_POLICY` on the official instance and on any instance that publishes a terms or privacy document
+<sup>5</sup> A false or absent value returns the field code `MUST_AGREE_TO_TOS_AND_PRIVACY_POLICY` on an instance that publishes a terms or privacy document
<sup>6</sup> A code supplied on an instance with administrator registration URLs disabled, and a code that does not resolve, both return 400 `REGISTRATION_URL_INVALID`. A valid code overrides the closed registration mode and replaces the instance approval mode with its own approval setting
-<sup>7</sup> Required while a self-hosted instance is unconfigured and has no admin account, where an absent or blank value returns the field code `SETUP_TOKEN_REQUIRED`. Accepted until the first admin account exists, and a wrong value returns the field code `SETUP_TOKEN_INVALID`. Ignored afterwards, on a hosted instance, and on a self-hosted instance that does not [enforce the token](/operator/configuration/#setup-token). Surrounding whitespace is trimmed
+<sup>7</sup> Required while a self-hosted instance is unconfigured and has no admin account, where an absent or blank value returns the field code `SETUP_TOKEN_REQUIRED`. Accepted until the first admin account exists, and a wrong value returns the field code `SETUP_TOKEN_INVALID`. Ignored afterwards, on a hosted instance, and on a self-hosted instance that does not enforce the token. Surrounding whitespace is trimmed
-Fluxer resolves the region from the client IP address, and an age below the minimum for that region returns the field code `MUST_BE_MINIMUM_AGE`. That minimum is 13 years unless the region sets a different minimum, and the applied minimum appears only in the localised message.
+Fluxer resolves the region from the client IP address, and an age below the minimum for that region returns the field code `MUST_BE_MINIMUM_AGE`. The age counts whole years up to today's date in UTC. That minimum is 13 years unless the region sets a different minimum, and the applied minimum appears only in the localised message.
-Registration returns 403 `REGISTRATION_CLOSED` when the instance is closed and no valid registration URL was supplied. A registration that would wait for approval, through the approval mode or a registration URL that requires approval, returns 400 `REGISTRATION_CREDENTIALS_REQUIRED` unless it has a `password`, and on an `email` instance also an `email`, because an account without them could never sign in once approved. That refusal counts against no registration allowance and uses no registration URL seat. A username whose discriminator space is exhausted returns the field code `TOO_MANY_USERS_WITH_THIS_USERNAME`. A username or display name containing a blocked substring returns 403 `CONTENT_BLOCKED`.
+Registration returns 403 `REGISTRATION_CLOSED` when the instance is closed and no valid registration URL was supplied. A self-hosted instance also returns it from the moment its first admin account exists until setup finishes, even with a valid registration URL. A registration that would wait for approval, through the approval mode or a registration URL that requires approval, returns 400 `REGISTRATION_CREDENTIALS_REQUIRED` unless it has a `password`, and on an `email` instance also an `email`, because an account without them could never sign in once approved. That refusal counts against no registration allowance and uses no registration URL seat. On an `email` instance that does not send email, a body with an `email` and no `password` returns 400 `REGISTRATION_CREDENTIAL_REQUIRED`, because nobody could confirm the address and the account would have no way to sign in. A username whose discriminator space is exhausted returns the field code `TOO_MANY_USERS_WITH_THIS_USERNAME`. A username or display name containing a blocked substring returns 403 `CONTENT_BLOCKED`.
-After the route rate limit, the CAPTCHA and schema validation, the setup token is checked before every other registration rule. A registration that presents the correct token is admitted whatever the registration mode is, is exempt from the registration allowances above, and receives the wildcard [Admin ACL](/admin-api/#acl-registry) when it creates a claimed account, which needs `email` on an `email` instance and `password` on a `username` instance. A client IP address is permitted 10 wrong tokens per 30 minutes, and further requests that present a token from that address return 429 until the window passes, the correct token included. A request with no token does not count.
+After the route rate limit, the CAPTCHA and schema validation, the setup token is checked before every other registration rule. A request for an account without an email that sends no token gets `SETUP_TOKEN_REQUIRED` before the CAPTCHA and before the instant account check. A registration that presents the correct token is admitted whatever the registration mode is, is exempt from the registration allowances above, and receives the wildcard [Admin ACL](/admin-api/#acl-registry) when it creates a claimed account, which needs `email` on an `email` instance and `password` on a `username` instance. A client IP address is permitted 10 wrong tokens per 30 minutes, and further requests that present a token from that address return 429 until the window passes, the correct token included. A request with no token does not count.
:::caution[Registration reports an address already in use]
[Log in with a password](#log-in-with-a-password) and [request password recovery](#request-password-recovery) are enumeration-safe and registration is not. An address that already holds an account returns the field code `EMAIL_ALREADY_IN_USE`, so an unauthenticated caller learns from the response whether that address is registered.
@@ -618,6 +598,8 @@ There is no retry key. A repeated request with the same values creates a second
The operation applies the instance's registration, email-domain, breached-password, and regional policies before creating the account. It records the accepted terms and privacy policy, authorises the registering client IP address, and sends an email verification message when the instance sends email. An instance that sends no email marks the address verified at creation instead.
+An account created without a date of birth joins no guild until it sets one. The invite is held for 7 days and accepted then.
+
Registration accepts the `invite_code` from the body, or the instance's configured auto-join invite when the body has none. On an instance with single-community mode enabled, the account also joins the community guild. Each join emits [Guild Member Add](/gateway/events/#guild-member-add) to the affected guild's sessions.
Approval mode registration creates no guild membership and no authentication session, and the account cannot sign in until an administrator approves it. The pending registration keeps that invite, and [approving it](/admin-api/instance/#update-pending-registration) joins the account to that guild and to the single community guild. Every other successful registration creates one session and returns its token.
@@ -626,6 +608,266 @@ Approval mode registration creates no guild membership and no authentication ses
10 requests per 10 seconds, on the `auth:register` bucket.
+## Identify an account
+
+<RouteHeader method="POST" path="/v1/auth/identify" unauthenticated />
+
+Starts the email-first sign-in, which serves both signing in and signing up. Authentication is not required. Returns an [identify response](#identify-response-object) object.
+
+The operation is served only while the instance has [identifier-first sign-in](/admin-api/instance/#auth-configuration-object) turned on, and otherwise returns 403 `FEATURE_TEMPORARILY_DISABLED`. A client reads `identifier_first` in the [instance features](/http-api/instance/#instance-features-object) to decide which sign-in screen to show.
+
+Every answer takes at least 300 milliseconds, and an unknown identifier costs the same lookups as a known one.
+
+### Request headers
+
+| Field | Type | Description |
+| --- | --- | --- |
+| X-Captcha-Token?<sup>1</sup> | string | The solved ALTCHA challenge, see [CAPTCHA handling](/topics/captcha/) |
+
+<sup>1</sup> Asked for only after heavy use. A challenge is asked once the client IP address has made 10 lookups in 10 minutes, its subnet 100 in an hour, or anyone 10 for the same identifier in an hour. Past the identifier allowance the cost doubles with each further lookup. A device that signed in to the account before, shown by `device_proof` or an authorised IP address, has an identifier allowance of its own. While the instance has the check off, no challenge is asked and the client IP address can make 30 lookups in 10 minutes and its subnet, the IPv4 /24 or IPv6 /48, 300 in an hour, after which lookups return 429 `RATE_LIMITED`
+
+### JSON body
+
+| Field | Type | Description |
+| --- | --- | --- |
+| email?<sup>1</sup> | string | The email address, on an `email` instance |
+| login?<sup>1</sup> | string | The username, on a `username` instance |
+| device_proof? | string | The `device_proof` from an earlier sign-in on this device (1-128 characters) |
+| registration_url_code? | ?string | The administrator-issued registration URL code, for a sign-up (1-256 characters) |
+
+<sup>1</sup> Send the one the instance signs in with. A missing value returns the field code `EMAIL_IS_REQUIRED` on `email` or `USERNAME_LENGTH_INVALID` on `login`
+
+### Response
+
+| Status | Body | Condition |
+| --- | --- | --- |
+| 200 | [identify response](#identify-response-object) object | The identifier was looked up |
+
+### Side effects
+
+The operation stores the ticket for 15 minutes and changes no account. No Gateway Dispatch is emitted.
+
+### Rate limit
+
+10 requests per 10 seconds, on the `auth:identify` bucket.
+
+## Send an email code
+
+<RouteHeader method="POST" path="/v1/auth/email-code/send" unauthenticated />
+
+Emails a 6-digit code to the address behind an identify ticket. The code signs in to the existing account, or creates a new one. Authentication is not required. Returns an [email code send response](#email-code-send-response-object) object.
+
+An instance that cannot send email, or that has identifier-first sign-in turned off, returns 400 `EMAIL_CODES_UNAVAILABLE`, and so does every `username` instance. An unknown or expired ticket returns 400 `UNKNOWN_SIGN_IN_TICKET`. A ticket for an account that has a password returns 400 `PASSWORD_SIGN_IN_REQUIRED` and sends no email.
+
+### Request headers
+
+| Field | Type | Description |
+| --- | --- | --- |
+| X-Captcha-Token?<sup>1</sup> | string | The solved ALTCHA challenge, see [CAPTCHA handling](/topics/captcha/) |
+
+<sup>1</sup> A sign-up always needs one. A sign-in needs one once the address has had 5 codes in an hour, with the cost doubling for each further code, or 5 wrong codes in a day on codes that one subnet asked for the address from devices that never signed in to the account
+
+### JSON body
+
+| Field | Type | Description |
+| --- | --- | --- |
+| ticket | string | The ticket from [identify an account](#identify-an-account) (1-128 characters) |
+| registration_url_code?<sup>1</sup> | ?string | The administrator-issued registration URL code (1-256 characters) |
+
+<sup>1</sup> Read only for a sign-up, with the same rules as in [register an account](#register-an-account)
+
+A sign-up also runs the registration checks of [register an account](#register-an-account): the registration mode, the address checks and the per-address and per-network registration allowances.
+
+While a self-hosted instance still requires its setup token, a sign-up returns the field code `SETUP_TOKEN_REQUIRED` on `setup_token` and no code is sent. Only [register an account](#register-an-account) takes the token, so the first account of an instance is created there. Once the first admin account exists, a sign-up returns 403 `REGISTRATION_CLOSED` until setup finishes.
+
+Asking again for the same ticket within 30 seconds returns 429 `EMAIL_CODE_RESEND_COOLDOWN` with `retry_after`. After 5 codes to one address in an hour, each further code waits twice as long as the one before, up to 15 minutes, and early requests get the same error. Each client IP address can send 20 codes per hour and each subnet 100.
+
+Wrong codes also stop sends until the end of the UTC day, with the same error. Each wrong code counts against the subnet, the IPv4 /24 or IPv6 /48, that asked for the code, wherever the guess comes from. After 30 wrong codes on codes that one subnet asked for an address from devices that never signed in to the account, that subnet gets no more codes for the address, and other networks still do. After 50 wrong codes from the account's own devices, counted with wrong codes in [sudo mode](/http-api/users/mfa/#sudo-mode), the account gets no more sign-in or sudo codes. Password and passkey sign-in keep working.
+
+:::note[A bounced address answers the same]
+An account whose address bounced gets the same response and no email, so the answer does not reveal the bounce.
+:::
+
+### Response
+
+| Status | Body | Condition |
+| --- | --- | --- |
+| 200 | [email code send response](#email-code-send-response-object) object | The code was sent, or the address bounced |
+| 400 | [error response](/http-api/#error-response) | The body, ticket, CAPTCHA, address or registration URL code is invalid, or no code can be sent |
+| 403 | [error response](/http-api/#error-response) | Registration policy or SSO enforcement rejects the operation |
+| 429 | [rate limit response](/topics/rate-limits/#rate-limit-response-object) | A route, global, address, IP, subnet or wrong-code limit denies the request, or the resend cooldown is running |
+| 500 | [error response](/http-api/#error-response) | Unexpected internal failure occurs |
+| 503 | [error response](/http-api/#error-response) | The instance is at its in-flight request ceiling |
+
+### Side effects
+
+The operation stores the code for 10 minutes and emails it with the approximate location and device that asked for it. A new code replaces the previous one for the same ticket. No Gateway Dispatch is emitted.
+
+### Rate limit
+
+5 requests per minute, on the `auth:email_code:send` bucket.
+
+## Verify an email code
+
+<RouteHeader method="POST" path="/v1/auth/email-code/verify" unauthenticated />
+
+Checks the emailed code. Authentication is not required. For an existing account it signs in and returns an [authentication token response](#authentication-token-response), or an [MFA challenge response](#mfa-challenge-response) when the account has a second factor. For a new address it creates the account with a confirmed email and returns what [register an account](#register-an-account) returns.
+
+A wrong code returns 400 `INVALID_SIGN_IN_CODE` and counts toward the wrong-code limits of [send an email code](#send-an-email-code). Each code allows 5 tries, after which, or after it expires, the code returns 400 `SIGN_IN_CODE_EXPIRED`. A correct code uses up the ticket.
+
+### JSON body
+
+| Field | Type | Description |
+| --- | --- | --- |
+| ticket | string | The ticket from [identify an account](#identify-an-account) (1-128 characters) |
+| code | string | The 6-digit code from the email |
+| consent?<sup>1</sup> | boolean | Whether the person submitted the step that says creating the account accepts the terms of service, for a sign-up |
+| registration_url_code? | ?string | The administrator-issued registration URL code, for a sign-up (1-256 characters) |
+| invite_code?<sup>2</sup> | ?string | The invite to open after sign-up (0-256 characters) |
+
+<sup>1</sup> Required for a sign-up when the [identify registration](#identify-registration-object) object has `consent_required` set to true. A false or absent value then returns the field code `MUST_AGREE_TO_TOS_AND_PRIVACY_POLICY` before the code is checked, so the same code still works on the next try
+
+<sup>2</sup> An account that still has to enter a date of birth joins the community after that step
+
+A new account gets a username derived from the part of the address before the `@`. A ticket for an account that has a password returns 400 `PASSWORD_SIGN_IN_REQUIRED` before the code is checked. Signing in to an account whose address was never confirmed confirms it, and that ends every other session of the account, forgets its authorised IP addresses and revokes its OAuth2 tokens. An account with a second factor gets an MFA ticket instead, its address stays unconfirmed, and passing the factor authorises the client IP address.
+
+An address that changed owner since the ticket was issued returns 400 `UNKNOWN_SIGN_IN_TICKET`. Account policy can return 403 `REGISTRATION_PENDING_APPROVAL`, 403 `REGISTRATION_REJECTED`, 403 `ACCOUNT_BELOW_MINIMUM_AGE` or a suspension code.
+
+While a self-hosted instance still requires its setup token, a sign-up returns the field code `SETUP_TOKEN_REQUIRED` on `setup_token` before the code is checked, and creates no account. Once the first admin account exists, a sign-up returns 403 `REGISTRATION_CLOSED` until setup finishes.
+
+### Response
+
+| Status | Body | Condition |
+| --- | --- | --- |
+| 200 | [authentication token response](#authentication-token-response) \| [MFA challenge response](#mfa-challenge-response) \| [registration pending approval response](#registration-pending-approval-response-object) | The code was accepted |
+| 400 | [error response](/http-api/#error-response) | The body, ticket or code is invalid, or the account has a password |
+| 403 | [error response](/http-api/#error-response) | Account policy, registration policy or SSO enforcement rejects the operation |
+| 429 | [rate limit response](/topics/rate-limits/#rate-limit-response-object) | Route or global bucket denies the request |
+| 500 | [error response](/http-api/#error-response) | Unexpected internal failure occurs |
+| 503 | [error response](/http-api/#error-response) | The instance is at its in-flight request ceiling |
+
+### Side effects
+
+A sign-in creates one authentication session, authorises the client IP address and returns a `device_proof`. A sign-up creates the account the way [register an account](#register-an-account) does, with the address already confirmed. No Gateway Dispatch is emitted for a sign-in.
+
+### Rate limit
+
+10 requests per minute, on the `auth:email_code:verify` bucket.
+
+## Get the website sign-up challenge
+
+<RouteHeader method="GET" path="/v1/auth/register/handoff/challenge" unauthenticated />
+
+Returns the CAPTCHA challenge that [start an account for the website](#start-an-account-for-the-website) needs for one visitor right now. Returns a [CAPTCHA challenge](#captcha-challenge-object) object.
+
+Only a caller holding a trusted caller key for the `auth:register:handoff:challenge` bucket may call it. It sends the key in `X-Fluxer-Internal-Key` and the visitor IP address in `X-Fluxer-Client-IP`, and any other caller gets 403 `MISSING_ACCESS`. An instance with instant accounts turned off returns 403 `INSTANT_ACCOUNTS_DISABLED`.
+
+### Response
+
+| Status | Body | Condition |
+| --- | --- | --- |
+| 200 | [CAPTCHA challenge](#captcha-challenge-object) object | The challenge was issued |
+| 403 | [error response](/http-api/#error-response) | The caller is not trusted, or instant accounts are off |
+| 429 | [rate limit response](/topics/rate-limits/#rate-limit-response-object) | Route or global bucket denies the request |
+| 500 | [error response](/http-api/#error-response) | Unexpected internal failure occurs |
+| 503 | [error response](/http-api/#error-response) | The instance is at its in-flight request ceiling |
+
+### Side effects
+
+None. The response has `Cache-Control: no-store`. No Gateway Dispatch is emitted.
+
+### Rate limit
+
+20 requests per minute for each visitor IP address, on the `auth:register:handoff:challenge` bucket.
+
+## Start an account for the website
+
+<RouteHeader method="POST" path="/v1/auth/register/handoff" unauthenticated />
+
+Checks the display name a visitor of the website typed and returns a code the web app redeems. Returns an [account handoff](#account-handoff-object) object. No account exists until [create a website account](#create-a-website-account) redeems the code, because the visitor accepts the terms of service in the web app, where the notice sits next to the create account button.
+
+The same trusted caller rule as [get the website sign-up challenge](#get-the-website-sign-up-challenge) applies, for the `auth:register:handoff` bucket. The operation succeeds only while registration is `open`, and otherwise returns 403 `REGISTRATION_CLOSED`. A display name that breaks the display name rules returns a field code on `global_name` such as `GLOBAL_NAME_LENGTH_INVALID`, and one with a blocked substring returns 403 `CONTENT_BLOCKED`. Nothing about the username is checked here, because the username is derived when the account is created. While a self-hosted instance still requires its setup token, the operation returns the field code `SETUP_TOKEN_REQUIRED` on `setup_token`.
+
+### Request headers
+
+| Field | Type | Description |
+| --- | --- | --- |
+| X-Captcha-Token<sup>1</sup> | string | The visitor's solved ALTCHA challenge, see [CAPTCHA handling](/topics/captcha/) |
+
+<sup>1</sup> The cost grows with recent instant account sign-ups, as described under [register an account](#register-an-account)
+
+### JSON body
+
+| Field | Type | Description |
+| --- | --- | --- |
+| global_name | string | The display name for the new account (1-32 characters after normalisation) |
+| nonce_hash | string | The hex SHA-256 of a random nonce the visitor's browser keeps |
+| locale? | string | The locale of the page the visitor started from (2-16 characters) |
+| registration_url_code? | ?string | The administrator-issued registration URL code the visitor arrived with (1-256 characters) |
+
+### Response
+
+| Status | Body | Condition |
+| --- | --- | --- |
+| 200 | [account handoff](#account-handoff-object) object | The display name is allowed |
+| 400 | [error response](/http-api/#error-response) | The body or CAPTCHA is invalid |
+| 403 | [error response](/http-api/#error-response) | The caller is not trusted, registration is not open, instant accounts are off, or the display name is blocked |
+| 429 | [rate limit response](/topics/rate-limits/#rate-limit-response-object) | A route, global, IP or subnet bucket denies the request |
+| 500 | [error response](/http-api/#error-response) | Unexpected internal failure occurs |
+| 503 | [error response](/http-api/#error-response) | The instance is at its in-flight request ceiling |
+
+### Side effects
+
+The operation stores the display name, the nonce hash and the visitor IP address under the handoff code for 15 minutes. It creates no account and no session, and holds no username. No Gateway Dispatch is emitted.
+
+### Rate limit
+
+10 requests per 10 seconds for each visitor IP address, on the `auth:register:handoff` bucket.
+
+## Create a website account
+
+<RouteHeader method="POST" path="/v1/auth/register/handoff/redeem" unauthenticated />
+
+Creates the account started by [start an account for the website](#start-an-account-for-the-website) and starts a session for it. Authentication is not required. Returns an [authentication token response](#authentication-token-response) with an optional `entry`, the community to open next.
+
+The web app and the native apps redeem the code, so the request needs no `Origin`.
+
+### JSON body
+
+| Field | Type | Description |
+| --- | --- | --- |
+| handoff_code | string | The code from the website, 43 URL-safe base64 characters |
+| nonce | string | The nonce whose hash was sent with the handoff (16-256 URL-safe base64 characters) |
+| consent?<sup>1</sup> | boolean | Whether the person submitted the step that says creating the account accepts the terms of service |
+| global_name?<sup>2</sup> | string | The display name, when the person changed it in the app (1-32 characters after normalisation) |
+
+<sup>1</sup> A false or absent value returns the field code `MUST_AGREE_TO_TOS_AND_PRIVACY_POLICY` on an instance that publishes a terms or privacy document. The code stays usable
+
+<sup>2</sup> Defaults to the display name sent with the handoff. A value that breaks the display name rules returns a field code on `global_name`, and one with a blocked substring returns 403 `CONTENT_BLOCKED`. Both answer before the code is used
+
+While a self-hosted instance still requires its setup token, the operation returns the field code `SETUP_TOKEN_REQUIRED` on `setup_token` before the code is used, and creates no account. Once the first admin account exists, it returns 403 `REGISTRATION_CLOSED` until setup finishes.
+
+A code works once. An unknown, expired or used code returns 400 `UNKNOWN_ACCOUNT_HANDOFF`, and a nonce that does not match returns 400 `INVALID_ACCOUNT_HANDOFF_NONCE` and uses the code up. The account is created with the same rules as [register an account](#register-an-account) for an instant account, using the visitor IP address the website passed. Its username is derived from the display name the same way, so no name can be taken in the meantime. On instances that collect dates of birth the new account then has to [set its date of birth](/http-api/users/current-user/#set-date-of-birth) before anything else.
+
+### Response
+
+| Status | Body | Condition |
+| --- | --- | --- |
+| 200 | [authentication token response](#authentication-token-response) | The account was created |
+| 400 | [error response](/http-api/#error-response) | The body, code, nonce or agreement is invalid |
+| 403 | [error response](/http-api/#error-response) | SSO is enforced, registration or instant accounts are off, or the name is blocked |
+| 429 | [rate limit response](/topics/rate-limits/#rate-limit-response-object) | Route or global bucket denies the request |
+| 500 | [error response](/http-api/#error-response) | Unexpected internal failure occurs |
+| 503 | [error response](/http-api/#error-response) | The instance is at its in-flight request ceiling |
+
+### Side effects
+
+The operation creates the account, records when it accepted the terms of service and was shown the privacy policy, creates one authentication session and returns a `device_proof`. It never ends or replaces another session. No Gateway Dispatch is emitted.
+
+### Rate limit
+
+10 requests per minute, on the `auth:register:handoff:redeem` bucket.
+
## Log in with a password
<RouteHeader method="POST" path="/v1/auth/login" unauthenticated />
@@ -714,7 +956,7 @@ MFA verification also permits 10 failed attempts per account in 15 minutes and d
| Field | Type | Description |
| --- | --- | --- |
| code<sup>1</sup> | string | The authenticator code or an unconsumed backup code |
-| ticket | string | The ticket returned by [password login](#log-in-with-a-password) |
+| ticket | string | The ticket returned by [password login](#log-in-with-a-password) or [complete SSO](#complete-sso) |
<sup>1</sup> A validated authenticator code is claimed for 30 seconds, so the same code cannot be presented twice. A backup code is consumed permanently on the attempt that accepts it
@@ -750,11 +992,11 @@ Resolves the account from an MFA ticket and creates a challenge restricted to th
| Field | Type | Description |
| --- | --- | --- |
-| ticket<sup>1</sup> | string | The ticket returned by [password login](#log-in-with-a-password) (1-256 characters) |
+| ticket<sup>1</sup> | string | The ticket returned by [password login](#log-in-with-a-password) or [complete SSO](#complete-sso) (1-256 characters) |
<sup>1</sup> The ticket is read but not consumed
-A client MUST still complete the returned challenge through [complete login with WebAuthn MFA](#complete-login-with-webauthn-mfa) before the ticket expires. An expired or unknown ticket returns the field code `SESSION_TIMEOUT` on `ticket`. An account with no credential in the group [passkey domain selection](/http-api/users/mfa/#passkey-domain-selection) picks returns 400 `NO_PASSKEYS_REGISTERED`.
+A client MUST still complete the returned challenge through [complete login with WebAuthn MFA](#complete-login-with-webauthn-mfa) before the ticket expires. An expired or unknown ticket returns the field code `SESSION_TIMEOUT` on `ticket`. An account with no passkey returns 400 `NO_PASSKEYS_REGISTERED`.
### Response
@@ -787,7 +1029,7 @@ Consumes the MFA ticket, verifies the WebAuthn assertion against the challenge,
| --- | --- | --- |
| response | [WebAuthn assertion](#webauthn-assertion) object | The browser credential assertion |
| challenge<sup>1</sup> | string | The challenge returned by [get WebAuthn MFA options](#get-webauthn-mfa-options) |
-| ticket | string | The ticket returned by [password login](#log-in-with-a-password) |
+| ticket | string | The ticket returned by [password login](#log-in-with-a-password) or [complete SSO](#complete-sso) |
<sup>1</sup> The challenge is consumed before verification and is accepted only when its bound context, account, and ticket all match this request
@@ -822,7 +1064,7 @@ Success consumes the challenge and ticket and creates one authentication session
Creates a challenge for passwordless authentication with a discoverable credential. Authentication is not required. Returns a [WebAuthn authentication options](#webauthn-authentication-options) object.
-The request has no body. The response omits `allowCredentials` and requests `required` user verification. Its `rpId` follows [passkey domain selection](/http-api/users/mfa/#passkey-domain-selection).
+The request has no body. The response omits `allowCredentials` and requests `required` user verification.
### Response
@@ -1266,28 +1508,12 @@ The caller MUST send a valid sudo token in the `X-Fluxer-Sudo-Mode-JWT` header,
| --- | --- | --- |
| session_id_hashes<sup>1</sup> | array[string] | The session digests to delete (max 100 entries) |
| password?<sup>2</sup> | string | The password proof for an account holding no TOTP secret and no registered WebAuthn credential (8-256 characters) |
-| mfa_method?<sup>3</sup> | string | The proof method, either `totp` or `webauthn` |
+| mfa_method?<sup>3</sup> | string | The proof method, one of `totp`, `webauthn` or `email_code` |
| mfa_code? | string | The authenticator code or an unconsumed backup code when the method is `totp` (1-32 characters) |
| webauthn_response? | [WebAuthn assertion](#webauthn-assertion) object | The assertion when the method is `webauthn` |
| webauthn_challenge? | string | The challenge bound to the sudo mode assertion |
-
-<sup>1</sup> Each value is the base64url `id_hash` from [list authentication sessions](#list-authentication-sessions). Fluxer ignores an unknown identifier, and an empty array deletes nothing and still returns 204
-
-<sup>2</sup> The password is accepted only while the account holds neither a TOTP secret nor a registered WebAuthn credential, and a value that does not match returns the field code `INVALID_PASSWORD`
-
-<sup>3</sup> The MFA proof is accepted only while the account holds a TOTP secret or a registered WebAuthn credential, which a passkey satisfies whether or not passkeys are enabled as a second factor. Any failure returns the field code `INVALID_MFA_CODE` on `mfa_code`, and a successful proof issues a fresh sudo token
-
-A `totp` method reads `mfa_code` as an authenticator code and accepts an unconsumed backup code in its place, and it reads the value as a backup code alone while the account holds no TOTP secret. A `webauthn` method reads `webauthn_response` and `webauthn_challenge` together, and it accepts only a challenge that was issued for the sudo context.
-
-:::caution[The caller can delete its own session]
-The operation deletes exactly the sessions identified by the supplied `id_hash` values. A client that wants to keep its own session MUST omit the `id_hash` of the entry whose `current` is true. Revoking the calling credential still returns 204.
-:::
-
-Missing or unusable proof returns 403 `SUDO_MODE_REQUIRED`, whose error body has top-level `has_mfa` and `methods` members, and `methods` reports whether `totp`, `webauthn`, and `backup_codes` are available.
-
-:::note[An unclaimed account needs no proof]
-An account that has no password, no TOTP secret, and no registered WebAuthn credential satisfies sudo mode with no body proof and no sudo token, and Fluxer issues none. Every other account MUST present a valid sudo token, a password, or an MFA proof.
-:::
+| email_code_ticket? | string | The ticket from [send a sudo email code](/http-api/users/mfa/#send-a-sudo-email-code) (1-128 characters) |
+| email_code? | string | The 6-digit code from that email |
### Response
@@ -1321,7 +1547,7 @@ Consumes the authorisation token delivered by email, authorises the pending clie
| --- | --- | --- |
| token | string | The authorisation token delivered by email |
-An unknown, expired, already consumed, or account-mismatched token returns the field code `INVALID_OR_EXPIRED_AUTHORIZATION_TOKEN`. A token that resolves to an account that no longer exists returns 404 `UNKNOWN_USER`, and one that resolves to a bot account returns 403 `BOT_USER_AUTH_ENDPOINT_ACCESS_DENIED`. Session creation also rejects an account that has not been admitted or is suspended, with the codes listed under [log in with a password](#log-in-with-a-password).
+An unknown, expired, already consumed, or account-mismatched token returns the field code `INVALID_OR_EXPIRED_AUTHORIZATION_TOKEN`, and so does a token for a sign-in attempt made before the account's password last changed. A token that resolves to an account that no longer exists returns 404 `UNKNOWN_USER`, and one that resolves to a bot account returns 403 `BOT_USER_AUTH_ENDPOINT_ACCESS_DENIED`. Session creation also rejects an account that has not been admitted or is suspended, with the codes listed under [log in with a password](#log-in-with-a-password).
### Response
@@ -1345,6 +1571,37 @@ The session token is then published against the ticket and remains readable by [
5 requests per minute, on the `auth:authorize_ip` bucket.
+## Redeem a sign-in link
+
+<RouteHeader method="POST" path="/v1/auth/sign-in-link" unauthenticated />
+
+Consumes the token from a one-time sign-in link that the instance operator created for an admin account with [create admin sign-in link](/admin-api/users/#create-admin-sign-in-link). Authentication is not required. Returns an [authentication token response](#authentication-token-response).
+
+### JSON body
+
+| Field | Type | Description |
+| --- | --- | --- |
+| token | string | The token from the fragment of the sign-in link |
+
+### Response
+
+| Status | Body | Condition |
+| --- | --- | --- |
+| 200 | [authentication token response](#authentication-token-response) | The account was signed in |
+| 400 | [error response](/http-api/#error-response) | The body or token is invalid |
+| 403 | [error response](/http-api/#error-response) | The token resolves to a bot account or a suspended account |
+| 429 | [rate limit response](/topics/rate-limits/#rate-limit-response-object) | Route or global bucket denies the request |
+| 500 | [error response](/http-api/#error-response) | Unexpected internal failure occurs |
+| 503 | [error response](/http-api/#error-response) | The instance is at its in-flight request ceiling |
+
+### Side effects
+
+The operation consumes the token, adds the client IP address of the request to the account's authorised set, and creates one authentication session. It records one [Admin audit entry](/admin-api/#admin-audit-entry-object) with action `use_sign_in_link`. No Gateway Dispatch is emitted.
+
+### Rate limit
+
+5 requests per minute, on the `auth:authorize_ip` bucket.
+
## Resend IP authorisation
<RouteHeader method="POST" path="/v1/auth/ip-authorization/resend" unauthenticated />
@@ -1478,11 +1735,6 @@ The operation holds nothing. Registration checks the name again and returns the
| Status | Body | Condition |
| --- | --- | --- |
| 200 | [username availability](#username-availability-object) object | The username was checked |
-| 400 | [error response](/http-api/#error-response) | The query or username is invalid, or the instance signs members in with email |
-| 403 | [error response](/http-api/#error-response) | SSO enforcement rejects the operation |
-| 429 | [rate limit response](/topics/rate-limits/#rate-limit-response-object) | Route or global bucket denies the request |
-| 500 | [error response](/http-api/#error-response) | Unexpected internal failure occurs |
-| 503 | [error response](/http-api/#error-response) | The instance is at its in-flight request ceiling |
### Side effects
@@ -1792,7 +2044,7 @@ Cancelling prevents any further token retrieval but does not revoke a session al
<RouteHeader method="POST" path="/v1/auth/origin-handoff" />
-Stores encrypted client state so that another web origin of the same instance can take it over once. The official web client uses it to move a signed-in browser from its legacy origin to a new one. Requires a user session token. Returns an [origin handoff](#origin-handoff-object) object.
+Stores encrypted client state so that another web origin of the same instance can take it over once. Requires a user session token. Returns an [origin handoff](#origin-handoff-object) object.
The sending origin encrypts the state and keeps the key. Fluxer never receives the key and never reads the payload. The receiving origin holds a nonce, and the sender passes only its digest here.
@@ -1810,13 +2062,6 @@ A bot token and an OAuth2 bearer token both return 403 `ACCESS_DENIED`.
| Status | Body | Condition |
| --- | --- | --- |
| 200 | [origin handoff](#origin-handoff-object) object | The state was stored |
-| 400 | [error response](/http-api/#error-response) | The body is invalid, returning `INVALID_FORM_BODY` |
-| 400 | [error response](/http-api/#error-response) | The body is larger than 8 MiB plus 1 KiB and the request returns `FILE_SIZE_TOO_LARGE` |
-| 401 | [error response](/http-api/#error-response) | The user session credential is missing or invalid |
-| 403 | [error response](/http-api/#error-response) | The credential is a bot token or an OAuth2 bearer token |
-| 429 | [rate limit response](/topics/rate-limits/#rate-limit-response-object) | Route or global bucket denies the request |
-| 500 | [error response](/http-api/#error-response) | Unexpected internal failure occurs |
-| 503 | [error response](/http-api/#error-response) | The instance is at its in-flight request ceiling |
### Side effects
@@ -1845,15 +2090,12 @@ An unknown, expired, or already redeemed identifier returns 404 `UNKNOWN_ORIGIN_
Fluxer deletes the stored state before it compares the nonce. A wrong nonce leaves nothing to retry, so the sender MUST create a new handoff.
:::
-On an instance that is not self-hosted, the request MUST send an `Origin` header naming one of the instance's web app origins. Any other `Origin`, or none, returns 403 `INVALID_API_ORIGIN`. A self-hosted instance skips this check.
-
### Response
| Status | Body | Condition |
| --- | --- | --- |
| 200 | [origin handoff payload](#origin-handoff-payload-object) object | The state was released and deleted |
| 400 | [error response](/http-api/#error-response) | The body is invalid, or the nonce does not match |
-| 403 | [error response](/http-api/#error-response) | The `Origin` is not a web app origin of the instance, returning `INVALID_API_ORIGIN` |
| 404 | [error response](/http-api/#error-response) | No stored handoff has this identifier, returning `UNKNOWN_ORIGIN_HANDOFF` |
| 429 | [rate limit response](/topics/rate-limits/#rate-limit-response-object) | Route or global bucket denies the request |
| 500 | [error response](/http-api/#error-response) | Unexpected internal failure occurs |
@@ -1866,210 +2108,3 @@ A redemption that finds the handoff deletes it, whether or not the nonce matches
### Rate limit
10 requests per minute, on the `auth:origin_handoff:redeem` bucket.
-
-## Start passkey bridge sign-in
-
-<RouteHeader method="POST" path="/v1/auth/passkey-bridge" unauthenticated />
-
-Starts a `login` or `login_mfa` [passkey bridge](#passkey-bridge) ceremony. Authentication is not required. Returns a [passkey bridge start](#passkey-bridge-start-object) object.
-
-### JSON body
-
-| Field | Type | Description |
-| --- | --- | --- |
-| purpose | string | The purpose, either `login` or `login_mfa` |
-| runner | string | Where the ceremony runs, either `page` or `native` |
-| ticket?<sup>1</sup> | string | The ticket returned by [password login](#log-in-with-a-password) (1-256 characters) |
-| nonce_hash | string | The SHA-256 digest of the nonce the new origin keeps, as 64 lowercase hex characters |
-
-<sup>1</sup> Required for `login_mfa` and refused for `login`. The ticket is read but not consumed
-
-The request MUST send an `Origin` header of `https://fluxer.com` or `https://canary.fluxer.com`. Any other `Origin`, none, or a self-hosted instance returns 403 `INVALID_API_ORIGIN`.
-
-For `login_mfa`, an expired or unknown ticket returns the field code `SESSION_TIMEOUT` on `ticket`. A ticket for an account that does not count passkeys as its second factor returns 400 `TWO_FACTOR_REQUIRED`, and one for an account with no passkey listed for `fluxer.app` returns 400 `NO_PASSKEYS_REGISTERED`. A ticket that resolves to a bot account returns 403 `BOT_USER_AUTH_ENDPOINT_ACCESS_DENIED`.
-
-### Response
-
-| Status | Body | Condition |
-| --- | --- | --- |
-| 200 | [passkey bridge start](#passkey-bridge-start-object) object | The ceremony was started |
-| 400 | [error response](/http-api/#error-response) | The body or ticket is invalid, passkeys are not the second factor, or the account has no `fluxer.app` passkey |
-| 403 | [error response](/http-api/#error-response) | SSO enforcement rejects the operation, the `Origin` is refused, or the ticket resolves to a bot account |
-| 404 | [error response](/http-api/#error-response) | The ticket resolves to an account that no longer exists |
-| 429 | [rate limit response](/topics/rate-limits/#rate-limit-response-object) | Route or global bucket denies the request |
-| 500 | [error response](/http-api/#error-response) | Unexpected internal failure occurs |
-| 503 | [error response](/http-api/#error-response) | The instance is at its in-flight request ceiling |
-
-### Side effects
-
-Fluxer stores the ceremony for 10 minutes, or 5 minutes for `login_mfa`, under a key derived from its identifier. It changes no account state. No Gateway Dispatch is emitted.
-
-### Rate limit
-
-10 requests per minute, on the `auth:passkey_bridge:start` bucket.
-
-## Get passkey bridge options
-
-<RouteHeader method="POST" path="/v1/auth/passkey-bridge/{ceremony_id}/options" unauthenticated />
-
-Issues the WebAuthn request for a pending [passkey bridge](#passkey-bridge) ceremony. Authentication is not required. Returns a [passkey bridge options](#passkey-bridge-options-object) object.
-
-### Path parameters
-
-| Field | Type | Description |
-| --- | --- | --- |
-| ceremony_id | string | The identifier from the start response, 43 base64url characters |
-
-The request has no body. Its `Origin` MUST be the origin that runs the ceremony, which is the paired legacy origin for `page` and the new origin for `native`. Any other `Origin` returns 403 `INVALID_API_ORIGIN`. An unknown, expired, completed, or cancelled ceremony returns 404 `UNKNOWN_PASSKEY_BRIDGE`, as does a request that arrives while another request holds the same ceremony.
-
-A `login` ceremony gets options with no `allowCredentials` and `required` user verification. A `login_mfa` or `sudo` ceremony gets the account's passkeys for `fluxer.app` in `allowCredentials` and `discouraged` user verification, and an account left with none returns 400 `NO_PASSKEYS_REGISTERED`. `rpId` is always `fluxer.app`.
-
-### Response
-
-| Status | Body | Condition |
-| --- | --- | --- |
-| 200 | [passkey bridge options](#passkey-bridge-options-object) object | A challenge was issued |
-| 400 | [error response](/http-api/#error-response) | The ceremony ID is malformed, or the account has no passkey for `fluxer.app` |
-| 403 | [error response](/http-api/#error-response) | The `Origin` is refused, returning `INVALID_API_ORIGIN` |
-| 404 | [error response](/http-api/#error-response) | The ceremony is not pending, returning `UNKNOWN_PASSKEY_BRIDGE` |
-| 429 | [rate limit response](/topics/rate-limits/#rate-limit-response-object) | Route or global bucket denies the request |
-| 500 | [error response](/http-api/#error-response) | Unexpected internal failure occurs |
-| 503 | [error response](/http-api/#error-response) | The instance is at its in-flight request ceiling |
-
-### Side effects
-
-The operation issues a one-use challenge valid for five minutes and bound to the bridge, so no other WebAuthn route accepts it. It revokes the challenge the ceremony held before, so only the latest options can complete it. No Gateway Dispatch is emitted.
-
-### Rate limit
-
-20 requests per minute, on the `auth:passkey_bridge:ceremony` bucket, shared with complete and cancel.
-
-## Complete passkey bridge
-
-<RouteHeader method="POST" path="/v1/auth/passkey-bridge/{ceremony_id}/complete" unauthenticated />
-
-Verifies the assertion for a pending [passkey bridge](#passkey-bridge) ceremony and marks it completed. Authentication is not required. Returns a [passkey bridge finish](#passkey-bridge-finish-object) object.
-
-### Path parameters
-
-| Field | Type | Description |
-| --- | --- | --- |
-| ceremony_id | string | The identifier from the start response, 43 base64url characters |
-
-### JSON body
-
-| Field | Type | Description |
-| --- | --- | --- |
-| response | [WebAuthn assertion](#webauthn-assertion) object | The browser credential assertion |
-
-The `Origin` rule and the 404 cases are those of [get passkey bridge options](#get-passkey-bridge-options). Fluxer verifies the assertion against the latest challenge and accepts only the ceremony origin in its client data.
-
-A ceremony with no options issued yet, a credential that is unknown, belongs to another account, is replaced, or is not for `fluxer.app`, and a failed verification all return 401 `PASSKEY_AUTHENTICATION_FAILED`. A verified assertion whose reported signature counter cannot be read returns 500 `INVALID_WEBAUTHN_AUTHENTICATION_COUNTER`.
-
-A `login_mfa` ceremony whose ticket has expired returns the field code `SESSION_TIMEOUT` on `ticket`. It draws one attempt from the [login MFA allowances](/topics/rate-limits/#allowances-answering-400), and an exhausted allowance returns the field code `INVALID_CODE` on `ticket`. A `sudo` ceremony draws one attempt from the sudo allowance, and an exhausted allowance returns the field code `INVALID_MFA_CODE` on `mfa_code`.
-
-:::note[A failed completion leaves the ceremony pending]
-The runner can fetch new options and try again, or cancel. The MFA allowances bound the retries.
-:::
-
-### Response
-
-| Status | Body | Condition |
-| --- | --- | --- |
-| 200 | [passkey bridge finish](#passkey-bridge-finish-object) object | The assertion was accepted |
-| 400 | [error response](/http-api/#error-response) | The body, ceremony ID, or ticket is invalid, or an MFA allowance is exhausted |
-| 401 | [error response](/http-api/#error-response) | Challenge or assertion verification fails |
-| 403 | [error response](/http-api/#error-response) | The `Origin` is refused, or the ticket resolves to a bot account |
-| 404 | [error response](/http-api/#error-response) | The ceremony is not pending, returning `UNKNOWN_PASSKEY_BRIDGE` |
-| 429 | [rate limit response](/topics/rate-limits/#rate-limit-response-object) | Route or global bucket denies the request |
-| 500 | [error response](/http-api/#error-response) | The verified assertion reported no readable signature counter, or the request could not be completed |
-| 503 | [error response](/http-api/#error-response) | The instance is at its in-flight request ceiling |
-
-### Side effects
-
-Success consumes the challenge, advances the credential's signature counter, sets its last use, and stores the completion code's digest with the ceremony. It creates no session and consumes no MFA ticket. No Gateway Dispatch is emitted.
-
-### Rate limit
-
-20 requests per minute, on the shared `auth:passkey_bridge:ceremony` bucket.
-
-## Cancel passkey bridge
-
-<RouteHeader method="POST" path="/v1/auth/passkey-bridge/{ceremony_id}/cancel" unauthenticated />
-
-Marks a [passkey bridge](#passkey-bridge) ceremony cancelled so the new origin can stop waiting. Authentication is not required. Returns a [passkey bridge finish](#passkey-bridge-finish-object) object.
-
-### Path parameters
-
-| Field | Type | Description |
-| --- | --- | --- |
-| ceremony_id | string | The identifier from the start response, 43 base64url characters |
-
-The request has no body, and the `Origin` rule is that of [get passkey bridge options](#get-passkey-bridge-options). Cancelling a cancelled ceremony succeeds again with a new completion code. A completed, unknown, or expired ceremony returns 404 `UNKNOWN_PASSKEY_BRIDGE`.
-
-### Response
-
-| Status | Body | Condition |
-| --- | --- | --- |
-| 200 | [passkey bridge finish](#passkey-bridge-finish-object) object | The ceremony is cancelled |
-| 400 | [error response](/http-api/#error-response) | The ceremony ID is malformed |
-| 403 | [error response](/http-api/#error-response) | The `Origin` is refused, returning `INVALID_API_ORIGIN` |
-| 404 | [error response](/http-api/#error-response) | The ceremony is completed or does not exist, returning `UNKNOWN_PASSKEY_BRIDGE` |
-| 429 | [rate limit response](/topics/rate-limits/#rate-limit-response-object) | Route or global bucket denies the request |
-| 500 | [error response](/http-api/#error-response) | Unexpected internal failure occurs |
-| 503 | [error response](/http-api/#error-response) | The instance is at its in-flight request ceiling |
-
-### Side effects
-
-The ceremony stores the digest of the new completion code. No account state changes and no Gateway Dispatch is emitted.
-
-### Rate limit
-
-20 requests per minute, on the shared `auth:passkey_bridge:ceremony` bucket.
-
-## Redeem passkey bridge sign-in
-
-<RouteHeader method="POST" path="/v1/auth/passkey-bridge/{ceremony_id}/redeem" unauthenticated />
-
-Redeems a finished `login` or `login_mfa` [passkey bridge](#passkey-bridge) ceremony once. Authentication is not required. Returns a [passkey bridge sign-in redemption](#passkey-bridge-sign-in-redemption-object) object.
-
-### Path parameters
-
-| Field | Type | Description |
-| --- | --- | --- |
-| ceremony_id | string | The identifier from the start response, 43 base64url characters |
-
-### JSON body
-
-| Field | Type | Description |
-| --- | --- | --- |
-| nonce | string | The nonce whose digest started the ceremony, as base64url, 16 to 256 characters |
-| completion_code | string | The completion code from the return fragment or the finish response, 43 base64url characters |
-
-The `Origin` MUST be the new origin that started the ceremony, or the request returns 403 `INVALID_API_ORIGIN`. A pending ceremony and a `sudo` ceremony return 404 `UNKNOWN_PASSKEY_BRIDGE` and stay in place, as does an unknown or expired identifier. A wrong nonce or completion code returns 400 `INVALID_PASSKEY_BRIDGE_NONCE`.
-
-:::caution[A wrong secret consumes the ceremony]
-Fluxer deletes the ceremony before it answers a wrong nonce or completion code, so the new origin MUST start a new one.
-:::
-
-A cancelled ceremony returns `cancelled`. A completed `login` ceremony creates a session under the policy of [authenticate with WebAuthn](#authenticate-with-webauthn), so a suspended, bot, or unadmitted account gets the same 403 codes. A completed `login_mfa` ceremony needs its ticket once more, and an expired one returns the field code `SESSION_TIMEOUT` on `ticket`. An account that no longer counts passkeys as its second factor returns 400 `TWO_FACTOR_REQUIRED`.
-
-### Response
-
-| Status | Body | Condition |
-| --- | --- | --- |
-| 200 | [passkey bridge sign-in redemption](#passkey-bridge-sign-in-redemption-object) object | The ceremony was redeemed |
-| 400 | [error response](/http-api/#error-response) | The body, ceremony ID, or ticket is invalid, a secret does not match, or passkeys are no longer the second factor |
-| 403 | [error response](/http-api/#error-response) | SSO enforcement, the `Origin`, account suspension, a bot account, or an unadmitted registration rejects the request |
-| 404 | [error response](/http-api/#error-response) | No redeemable sign-in ceremony has this identifier, returning `UNKNOWN_PASSKEY_BRIDGE` |
-| 429 | [rate limit response](/topics/rate-limits/#rate-limit-response-object) | Route or global bucket denies the request |
-| 500 | [error response](/http-api/#error-response) | Unexpected internal failure occurs |
-| 503 | [error response](/http-api/#error-response) | The instance is at its in-flight request ceiling |
-
-### Side effects
-
-A redemption that gets past the secret check deletes the ceremony, whatever happens next. A completed ceremony creates one authentication session, and for `login_mfa` it also consumes the ticket and clears the login MFA allowances. When the request comes from a new origin and the domain migration switch is on, Fluxer opens a [passkey update](/http-api/users/mfa/#passkey-updates) for the new session. No Gateway Dispatch is emitted.
-
-### Rate limit
-
-60 requests per minute, on the `auth:passkey_bridge:redeem` bucket.
diff --git a/fluxer_docs/src/content/docs/topics/captcha.md b/fluxer_docs/src/content/docs/topics/captcha.md
index 04467b799..fb800cf85 100644
--- a/fluxer_docs/src/content/docs/topics/captcha.md
+++ b/fluxer_docs/src/content/docs/topics/captcha.md
@@ -31,6 +31,16 @@ Each challenge is accepted once and expires 10 minutes after it is issued. A rep
The route rate limit on registration, login, password recovery and account recovery runs before the check. The challenge response and the retry each use one request from that allowance.
+## Rising cost
+
+Some operations raise the cost of their challenge with recent use. Each step doubles `cost`, up to 6 steps, which is 64 times the base cost. The challenge in the error response always has the cost the retry needs, and a token solved for a cheaper challenge returns `INVALID_CAPTCHA`.
+
+| Operation | What raises the cost |
+| --- | --- |
+| Sign-up without an email through [register an account](/http-api/authentication/#register-an-account) or the website | Each such account from the IP address in the last hour, and instance-wide volume |
+| Registration with an email address and [identify an account](/http-api/authentication/#identify-an-account) | Each lookup of the same address past 10 in an hour |
+| [Send an email code](/http-api/authentication/#send-an-email-code) | Each code to the same address past 5 in an hour |
+
## Token format
The token is the base64 encoding of the UTF-8 JSON object `{"challenge": {"parameters": ..., "signature": ...}, "solution": {"counter": ..., "derivedKey": ...}}`. The solution can also have `time`. Copy `parameters` and `signature` unchanged from `altcha_challenge`. A token longer than 4096 characters, or one that does not decode to this shape, returns `INVALID_CAPTCHA`.
@@ -42,6 +52,7 @@ The following operations verify a CAPTCHA while the check is on.
| Method | Route | Operation |
| --- | --- | --- |
| POST | /v1/auth/register | [Register an account](/http-api/authentication/#register-an-account) |
+| POST | /v1/auth/register/handoff | [Start an account for the website](/http-api/authentication/#start-an-account-for-the-website) |
| POST | /v1/auth/login | [Log in with a password](/http-api/authentication/#log-in-with-a-password) |
| POST | /v1/auth/forgot | [Request password recovery](/http-api/authentication/#request-password-recovery) |
| POST | /v1/auth/recover | [Recover an account](/http-api/authentication/#recover-an-account) |
@@ -50,6 +61,8 @@ The following operations verify a CAPTCHA while the check is on.
| POST | /v1/users/@me/channels | [Create private channel](/http-api/users/private-channels/#create-private-channel) |
| PUT | /v1/channels/{channel_id}/recipients/{user_id} | [Add group direct message recipient](/http-api/channels/#add-group-direct-message-recipient) |
+[Identify an account](/http-api/authentication/#identify-an-account) and [send an email code](/http-api/authentication/#send-an-email-code) ask for a challenge only after heavy use, as described on each, and a sign-up through send an email code always asks for one.
+
Create private channel is gated only on the group direct message path, where the request body has a `recipients` member. A one-to-one direct message request omits the field and is never gated.
## Exemption