4. fleetmesh-auth Wire Protocol Specification#

This document specifies the HTTP interface mounted under /api/fauth/*, the request and response payloads exchanged on those endpoints, and the portable cross-site pass format.

The authoritative machine-readable artifacts for this specification are:

  • Test vectors: core/vectors/web-auth.json

  • JSON Schema definitions: schema/schemas/identity/fleetmesh-auth.schema.json

  • Protocol constants: the web_auth section of schema/schema/constants.json

In the event of any discrepancy between this prose specification and the test vectors, the test vectors are authoritative.

The reference implementation is fleetmesh_auth, built on fleetmesh_core.identity.web_auth and fleetmesh_core.identity.auth_wire. Independent implementations (such as the Rust node or third-party providers in other languages) require only the test vectors, the JSON schemas, and this specification.

4.1. Conventions#

  • Every JSON response is an object containing a boolean ok field.

  • Timestamps are integer Unix seconds (UTC).

  • Hexadecimal encodings are lowercase. <hex64> denotes 32 bytes (64 hex characters); <hex128> denotes 64 bytes (128 hex characters).

  • Nostr events are NIP-01 objects {id, pubkey, created_at, kind, tags, content, sig} signed with BIP-340 Schnorr signatures.

4.2. 1. Routes#

Method

Path

Purpose

Response

GET or POST

/api/fauth/challenge

Issue a single-use authentication challenge

§3 authChallenge

POST

/api/fauth/login (alias /api/fauth/verify)

Verify credentials and establish a session

§4 authLoginResponse or §7 authError (401)

GET

/api/fauth/session

Inspect an active session token

§5 authSessionResponse or authError (401)

POST

/api/fauth/logout

Revoke an active session token

§5 authLogoutResponse

POST

/api/fauth/register

Create an account via a provider and establish a session

§4.5 authLoginResponse or authError (400/401)

GET

/api/fauth/register/check?provider=&handle=

Query handle availability for registration

§4.6 authHandleCheck or authError (400/401)

GET

/api/fauth/providers

List registered authentication providers

{ok:true, providers:[providerDescribe]} (§9)

GET

/api/fauth/config?preset=

Retrieve sign-in widget configuration

{ok:true, config: authWidgetConfig} (§10)

GET

/api/fauth/widget.js?preset=

Retrieve the sign-in widget script

application/javascript

Any

Other /api/fauth/*

Unrecognized authentication endpoint

authError unknown_fauth_endpoint (404)

The reference standalone server additionally exposes GET /healthz ({ok:true, service: "fleetmesh-auth"}) on the main listener and, when FLEETMESH_AUTH_ADMIN_ADDR is configured, GET /healthz, GET /readyz (200 or 503, {ok, ready}), and GET /metrics (Prometheus text exposition format) on the administrative listener. Operational endpoints are outside the client wire protocol.

4.2.1. HTTP Status Codes#

  • 200: Request succeeded (ok: true).

  • 401: Authentication, authorization, or session verification failed.

  • 400: Malformed or unreadable request body (invalid_json, invalid_content_length, payload_too_large), or form/selection validation errors on registration endpoints (§4.5, §4.6).

  • 404: Unrecognized endpoint.

Clients MUST branch on the JSON ok and error fields rather than relying solely on the HTTP status code.

4.2.2. Session Token Extraction#

Endpoints that accept a session token (/api/fauth/session, /api/fauth/logout, and protected host application routes) extract the token in the following precedence order:

  1. HTTP headers: X-Fleetmesh-Auth, Authorization (stripping a leading Bearer prefix), X-Admin-Token, X-Session-Token, X-FleetMesh-Key.

  2. Query parameter: token=.

  3. JSON request body fields: token, session_token, api_key.

Session tokens begin with the prefix fmauth_ followed by 24 random bytes encoded as base64url, and remain valid for session.ttl_sec = 604800 seconds (7 days).

4.3. 2. Constants#

Defined under web_auth in schema/schema/constants.json (and pinned by webauth.constants in the test vectors):

Name

Value

Challenge scheme minted

fleetmesh-auth-v1

Challenge schemes accepted

fleetmesh-auth-v1

Challenge ID

24 random bytes encoded as 48 lowercase hex characters

Challenge TTL

600 s on the engine (the standalone core verifier defaults to 300 s)

Accepted auth_event kinds

27235 (NIP-98), 22242 (NIP-42)

auth_event created_at skew

max(challenge ttl, 120) s

Ticket prefix minted

fmpass_

Ticket prefixes accepted

fmpass_

Ticket auth_event kind

27235

Ticket content

fleetmesh-cross-site-login:<pubkey>:<expires_at>

Ticket TTL

clamp(requested, 30, 3600), default 300 s

Ticket future skew

120 s

Session token prefix

fmauth_

Session TTL

604800 s

4.4. 3. Challenge#

GET /api/fauth/challenge[?domain=] or POST /api/fauth/challenge with optional JSON body {"domain": ...} (defaulting to the node’s configured domain) issues a single-use challenge:

{
  "ok": true,
  "challenge_id": "<hex48>",
  "challenge": "<hex48>",
  "challenge_text": "fleetmesh-auth-v1:<hex48>:https://node.example",
  "auth_message": "fleetmesh-auth-v1:<hex48>:https://node.example",
  "auth_message_sha256": "<hex64>",
  "domain": "node.example",
  "instance_url": "https://node.example",
  "expires_at": 1700000600
}

challenge_id and challenge contain identical values; challenge_text is a legacy alias for auth_message. Both pairs are retained for backward compatibility.

The canonical challenge message is <scheme>:<challenge>:<origin_url>, where origin_url is the node’s https://host origin with no trailing slash (webauth.challenge_message). In a direct challenge login, the client signs sha256(message) as the 32-byte BIP-340 message digest.

Challenges are stored with their expires_at timestamp and consumed upon first verification attempt. Replay or submission after expiration fails with challenge_invalid_or_expired.

4.4.1. Challenge Scheme Verification#

The node mints challenges using fleetmesh-auth-v1 exclusively. When verifying a direct challenge signature, the verifier computes the digest under each accepted scheme for the given challenge and origin (webauth.challenge_message returns digests), checks the minted scheme first, and accepts the first valid signature. The verified result records the matched scheme (scheme in webauth.verify). Signatures over unrecognized scheme strings are rejected with signature_invalid.

4.5. 4. Login#

POST /api/fauth/login (or /api/fauth/verify) accepts a JSON object carrying a credential. Optional fields accepted on any login payload are provider (or provider_id), required_role, app_preset (or preset, defaulting to standard), identity_event (a NIP-01 kind 0 event signed by the same key), home_instance_url, and home_node_did.

4.5.1. 4.1 Payload Normalization (auth.normalize_payload)#

Before routing to providers, the engine normalizes incoming request payloads as follows:

  • If auth_method is absent and method is present, method is copied to auth_method using the alias mapping nip07_ext→nip07_extension, schnorr_key→private_key, did_challenge→did, and service_provider→service_login.

  • Short field names are copied to their canonical names when the canonical field is absent: signature→signature_hex, challenge→challenge_id, and pubkey→pubkey_hex.

Existing fields are never removed or overwritten; synthesized fields are appended in the order listed above.

4.5.2. 4.2 Provider Routing#

Providers are selected and evaluated in the following order:

  1. Explicit provider: Only the named provider is evaluated. An unregistered name fails with unknown_provider; a disabled provider fails with provider_not_enabled.

  2. Cryptographic key, DID, or passkey payload: Any key/DID/passkey method or any presence of bunker_uri, secret_key, private_key, signature(_hex), auth_event, credential_id, or passkey_credential_id routes to sovereign_key.

  3. Prefixed token: A token present in portable_ticket, ticket, token, or api_key routes to the provider(s) claiming its prefix (fmpass_ routes to sovereign_key; plugin prefixes route to their declaring plugin).

  4. method == portable_ticket: Routes to sovereign_key.

  5. Operator token: operator_token method or field routes to local_operator, followed by other account providers.

  6. API key or bearer token: method set to api_key or token routes to every provider supporting that method.

  7. Default fallback: Every provider supporting service_login is evaluated in registration order (key providers first, external plugins in load order, local_operator last).

The engine returns the first successful result (ok: true). When a provider returns ok: false, its error code is retained as evaluation continues; if all candidate providers fail, the engine returns the last refusal code (authentication_failed if no code was supplied, or no_provider_for_this_login if no provider matched routing). Unhandled provider exceptions produce provider_error. If authentication succeeds but the resulting auth_method is disallowed by the active preset, the engine refuses with method_not_enabled.

4.5.3. 4.3 Login Payloads by Method#

4.5.3.1. Direct Challenge Signature (NIP-07 Extension, DID, or Key)#

{"method": "nip07_ext", "pubkey": "<hex64>", "challenge": "<hex48>", "signature": "<hex128>"}
{"method": "did", "did": "did:nostr:<hex64>", "challenge": "<hex48>", "signature": "<hex128>"}
{"pubkey_hex": "<hex64>", "challenge_id": "<hex48>", "signature_hex": "<hex128>"}

signature MUST be a valid BIP-340 signature over sha256(<scheme>:<challenge>:<origin_url>) under an accepted scheme. Verification produces method: "challenge_signature" and principal auth_method set to nip07_extension (or did / private_key when requested).

Refusal codes: credentials_malformed (non-hex64 pubkey, missing challenge, or non-hex128 signature), identity_malformed (unparseable DID), challenge_invalid_or_expired, and signature_invalid.

4.5.3.2. Signed Auth Event (NIP-98 or NIP-42)#

{"auth_event": {"kind": 27235, "pubkey": "<hex64>", "created_at": 1700000000,
                "tags": [["u", "https://node.example/api/fauth/login"], ["method", "POST"],
                         ["challenge", "<hex48>"]],
                "content": "<anything; the vector uses the auth_message>", "id": "...", "sig": "..."}}

Verification checks are applied in strict order:

  1. Valid BIP-340 event signature (auth_event_signature_invalid).

  2. Event kind in {27235, 22242} (auth_event_wrong_kind).

  3. |now - created_at| <= max(challenge ttl, 120) (auth_event_timestamp_skew).

  4. If a NIP-40 expiration tag is present, it has not elapsed (auth_event_expired).

  5. A non-empty challenge tag is present (auth_event_challenge_mismatch).

  6. Challenge exists, has not expired, and is consumed (challenge_invalid_or_expired).

  7. Event id has not previously been seen (auth_event_replayed; seen IDs are retained for 600 s).

Verification produces method: "auth_event" and principal auth_method set to nip07_extension or did.

4.5.3.3. NIP-46 Bunker#

{"bunker_uri": "bunker://<hex64>?relay=wss://...", "challenge_id": "<hex48>", "signature_hex": "<hex128>"}

The bunker:// or nostrconnect:// URI identifies the signing key; authentication requires a valid challenge signature produced by the remote signer. Missing signatures fail with bunker_requires_challenge_signature; unparseable URIs fail with bunker_uri_malformed. The resulting principal sets auth_method to nip46_bunker and populates bunker_relay.

4.5.3.4. Portable Ticket (§6)#

{"portable_ticket": "fmpass_<base64url>"}

Both the verified method and principal auth_method are portable_ticket.

4.5.3.5. Passkey (WebAuthn)#

Passkey assertions carry credential_id, challenge_id, client_data_json (base64url-encoded JSON whose challenge matches the issued challenge ID as UTF-8 or raw bytes), and authenticator_data (base64url-encoded, at least 37 bytes, with the user-presence UP flag set). Authentication (webauthn.get) additionally requires passkey_signature; registration (webauthn.create) carries attestation_object and public_key_spki. Refusal codes are the passkey_*, *_authenticator_data, and invalid_webauthn_type entries in §7.

4.5.3.6. Operator Token (local_operator)#

{"method": "operator_token", "operator_token": "<the node's configured token>", "username": "operator"}

password and token are also accepted as token fields. Refusal codes: operator_token_not_configured, missing_operator_token, and invalid_operator_credentials. Successful verification grants roles including node_operator.

4.5.3.7. Account Provider Plugin (service_login)#

Account plugins accept the fields declared in their login_form (typically username, password, and optionally service_url) or provider-issued API keys in api_key or token (§9).

4.5.3.8. Prohibited Secret Key Transmission#

Submitting a raw secret key (secret_key or private_key) in any request body is unconditionally rejected with private_key_not_accepted. Signing MUST occur exclusively on the client.

4.5.4. 4.4 Login Response#

{
  "ok": true,
  "session_token": "fmauth_<base64url>",
  "token": "fmauth_<base64url>",
  "expires_at": 1700604800,
  "principal": { ...authPrincipal (§8) }
}

token duplicates session_token for backward compatibility with older clients. If required_role is specified (in the request body or by the route) and the authenticated principal does not satisfy it, the response is:

{"ok": false, "error": "insufficient_role", "detail": "The principal lacks the required role",
 "required_role": "admin", "roles": ["viewer", "creator", "broadcaster"]}

4.5.5. 4.5 Account Registration#

POST /api/fauth/register creates a new account through a provider reporting providerDescribe.supports_registration: true (§9) and establishes a session for the resulting principal. The request body carries provider, the provider’s register_form fields, and an optional app_preset:

{"provider": "acme", "username": "ann", "password": "...", "email": "ann@example.org", "app_preset": "standard"}

provider MAY be omitted if exactly one registered provider supports registration. On success, the response matches the login response format (§4.4), with principal.auth_method set to service_login unless overridden by the provider.

Refusal codes:

  • HTTP 400: handle_taken, invalid_handle, weak_password, invalid_email, provider_required (multiple providers support registration and none was named), unknown_provider, registration_unsupported (the specified provider—or every registered provider—does not implement registration).

  • HTTP 401: provider_not_enabled, method_not_enabled (none of the provider’s methods is enabled), insufficient_role (when required_role is unsatisfied), and provider_error.

4.5.6. 4.6 Handle Availability Check#

GET /api/fauth/register/check?provider=<id>&handle=<h>[&preset=<p>] queries a provider whose providerDescribe.supports_handle_check (§9) is true to determine whether handle is available for registration. The success response (authHandleCheck) MUST contain strictly these keys:

{"ok": true, "available": false, "reason": "handle_taken"}

reason is null when available is true, and otherwise handle_taken or invalid_handle. Before querying the provider, the server trims whitespace, removes at most one leading @, and immediately returns invalid_handle for empty strings, values longer than 64 characters, or characters outside [A-Za-z0-9._-].

Refusal responses use authError (§7):

  • HTTP 400: provider_required, unknown_provider, handle_check_unsupported, and registration_unsupported.

  • HTTP 401: provider_not_enabled and provider_error.

No additional account attributes are disclosed. Because this endpoint is unauthenticated and indicates handle existence by design, deployments MUST apply edge rate limiting equivalent to /api/fauth/register.

4.6. 5. Session Inspection and Logout#

GET /api/fauth/session[?required_role=] validates the session token extracted per §1:

{"ok": true, "principal": { ...authPrincipal }}

Refusal codes: missing_session_token (no token supplied), expired_session_token (known token past expires_at; the expired record is deleted), invalid_session_token (unknown or revoked token), and insufficient_role (including required_role and roles). Tokens issued natively by a co-hosted application’s own session store are resolved via the engine’s UserDirectory and returned in the same format.

POST /api/fauth/logout revokes the supplied session token and returns {"ok": true} unconditionally, regardless of whether the token existed. It returns missing_session_token only when no token is provided. Subsequent requests presenting a revoked token fail with invalid_session_token.

4.6.1. Multi-Replica Deployment Requirement#

Single-use challenges (§3), replay-tracking records, and sessions (§5) are stored in the engine’s AuthStore. Under the default SQLite backend, this state is local to a single process: load-balancing across multiple SQLite-backed replicas causes challenge verification to fail with challenge_invalid_or_expired and limits session validity to the issuing replica. Any deployment operating multiple replicas behind a single hostname MUST configure all replicas to share a PostgreSQL store (--store-url postgres://... or FLEETMESH_AUTH_STORE_URL), ensuring database-wide, exactly-once challenge consumption and event replay protection.

4.7. 6. Portable Ticket (fmpass_)#

A portable ticket is a self-contained, user-signed NIP-98 event wrapped in a base64url envelope, enabling a user authenticated on one site to sign in to another node without a pre-existing account on the target node. Its exact byte representation is pinned by webauth.ticket_mint, webauth.ticket_decode, and the ticket, wildcard_ticket, and legacy_ticket sections of core/vectors/web-auth.json.

4.7.1. Minting Procedure (encode_portable_ticket)#

  1. Inputs: secret key sk (hex64, lowercase), home_instance_url (origin URL of the minting site, trailing slash stripped; may be empty), home_node_did (may be empty), target_url (target origin URL, trailing slash stripped; empty string becomes *), ttl_sec, now, a 12-byte nonce encoded as 24 lowercase hex characters, and an optional identity_event (signed kind 0 event from the same key).

  2. Key and expiration: pk = pubkey(sk); ttl = clamp(ttl_sec or 300, 30, 3600); expires_at = now + ttl.

  3. Tags (in exact order): ["u", target_url], ["method", "POST"], ["expiration", str(expires_at)], ["home", home_instance_url], ["nonce", nonce_hex].

  4. Auth event: Construct a NIP-01 event with kind = 27235, created_at = now, the tags from step 3, and content = "fleetmesh-cross-site-login:<pk>:<expires_at>", then sign with sk. The nonce tag guarantees distinct event IDs when two tickets are minted by the same key within the same second, enabling replay protection by event ID.

  5. Bundle construction (keys in exact order):

    {"version": 1, "home_instance_url": "...", "home_node_did": "...", "target_url": "...",
     "expires_at": 1700003600, "identity_event": null, "auth_event": { ...step 4 }}
    
  6. JSON serialization: Serialize as compact UTF-8 JSON with , and : separators, no extraneous whitespace, preserved key insertion order, and non-ASCII characters escaped as \uXXXX (matching Python json.dumps defaults).

  7. Encoding: Base64url-encode (RFC 4648 §5) with trailing = padding removed.

  8. Prefixing: Prepend fmpass_. The minting result object is {portable_ticket, bundle, expires_at, target_url, pubkey, did} where did = did:nostr:<pk>.

4.7.2. Decoding (webauth.ticket_decode)#

Strip the accepted prefix (fmpass_), restore base64url padding, decode to UTF-8, and parse JSON. Any decoding failure or non-object JSON value fails with ticket_malformed. Login payloads MAY alternatively supply the decoded bundle object directly in portable_ticket.

4.7.3. Verification Procedure#

Ticket verification executes the following checks in strict order:

  1. auth_event is present and has a valid BIP-340 signature; otherwise ticket_signature_invalid.

  2. auth_event.kind == 27235; otherwise ticket_wrong_kind.

  3. expiration tag is present and strictly greater than now; otherwise ticket_expired.

  4. auth_event.created_at <= now + 120; otherwise ticket_future_timestamp.

  5. u tag equals "" or * (matching any origin), or equals the verifying node’s origin_url (trailing slash stripped); otherwise ticket_host_mismatch.

  6. If identity_event is present (in the bundle, or falling back to the request body), it MUST be a JSON object (identity_event_malformed), validly signed by the same pubkey (ticket_identity_mismatch), and of the expected event kind when enforced by the node (identity_event_wrong_kind).

  7. auth_event.id has not previously been redeemed; otherwise ticket_replayed. Seen event IDs are retained until the ticket’s expiration timestamp.

Successful verification yields: {pubkey, did, method: "portable_ticket", home_instance_url, home_node_did, identity_event, auth_event_id, scheme: ""}.

4.7.4. Compatibility and Minting Responsibility#

For legacy compatibility, the reference decoder also accepts unprefixed base64url strings; clients MUST NOT rely on this behavior and MUST emit the fmpass_ prefix.

The server engine never mints portable tickets during login because tickets require the user’s private signing key. Tickets are minted client-side in the browser sign-in panel (via a user key or NIP-07 extension) or programmatically via FederatedWebAuth.create_portable_ticket / webauth.ticket_mint.

4.8. 7. Refusals and Error Codes#

Every error response uses the following structure:

{"ok": false, "error": "<snake_code>", "detail": "<one English sentence>"}

The error field is the normative programmatic contract: a stable snake_case identifier matching ^[a-z][a-z0-9_]*$ drawn from the registry below (ERRORS in fleetmesh_core.identity.web_auth, pinned by the errors map in the test vectors). The detail field is a human-readable diagnostic message and is not part of the programmatic contract; its wording may change across releases. Certain refusals include supplementary fields such as required_role, roles, or path. Implementations MAY define additional error codes but MUST NOT rename the standard codes listed below.

Code

Meaning

challenge_invalid_or_expired

Challenge is unknown, already consumed, or past its TTL

credentials_malformed

Direct login missing a hex64 pubkey, challenge, or hex128 signature

signature_invalid

BIP-340 signature fails verification under all accepted schemes

ticket_malformed

Ticket does not decode from <prefix>base64url(JSON object)

ticket_signature_invalid

Ticket auth_event is missing or has an invalid signature

ticket_wrong_kind

Ticket auth_event kind is not 27235

ticket_expired

Ticket lacks an expiration tag or has expired

ticket_future_timestamp

Ticket created_at exceeds now + 120 s

ticket_host_mismatch

Ticket u tag targets a different origin

ticket_replayed

Ticket auth_event.id has already been redeemed

ticket_identity_mismatch

identity_event is not validly signed by the ticket’s key

identity_event_malformed

identity_event is not a JSON object

identity_event_wrong_kind

identity_event kind does not match the node’s requirement

auth_event_signature_invalid

auth_event signature is invalid

auth_event_wrong_kind

auth_event kind is neither 27235 nor 22242

auth_event_timestamp_skew

auth_event.created_at falls outside max(challenge ttl, 120) s of now

auth_event_expired

auth_event expiration tag has elapsed

auth_event_challenge_mismatch

auth_event lacks a non-empty challenge tag

auth_event_replayed

auth_event.id has already been seen

bunker_uri_malformed

bunker:// or nostrconnect:// URI is unparseable

identity_malformed

Public key or DID cannot be parsed

auth_event_malformed

auth_event is not a valid signed Nostr event object

challenge_verifier_unavailable

Node is not configured with a challenge store

portable_ticket_unavailable

Node does not accept portable tickets

operator_token_not_configured

No operator token is configured on the node

missing_operator_token

Operator login omitted the token

invalid_operator_credentials

Submitted operator token does not match

unknown_provider

provider does not match any registered provider

provider_error

Provider raised an unhandled exception or encountered an internal failure

bunker_requires_challenge_signature

Bunker URI submitted without a challenge signature

private_key_not_accepted

Request included a raw secret key

provider_not_enabled

Provider is disabled for the active preset or node

method_not_enabled

Resulting auth_method is disabled for the active preset or node

insufficient_role

Authenticated principal lacks the required_role

no_provider_for_this_login

No registered provider matched the login payload

authentication_failed

All evaluated providers refused without supplying a specific error code

missing_session_token

No session token found in headers, query string, or body

expired_session_token

Session has passed expires_at

invalid_session_token

Session token is unknown or has been revoked

missing_sovereign_key_credentials

sovereign_key found no recognizable credential in the payload

did_requires_challenge_signature_or_secret_key

DID submitted without a challenge signature

missing_passkey_assertion

Missing credential_id, challenge_id, or client_data_json

invalid_passkey_client_data

client_data_json is not valid base64url-encoded JSON

invalid_webauthn_type

clientData.type is neither webauthn.get nor webauthn.create

invalid_passkey_challenge_encoding

clientData.challenge is not valid base64url

passkey_challenge_mismatch

clientData.challenge does not match the issued challenge

missing_authenticator_data

webauthn.get assertion lacks authenticator_data

invalid_authenticator_data

authenticator_data is not valid base64url

authenticator_data_too_short

Decoded authenticator_data is shorter than 37 bytes

passkey_user_not_present

User-presence (UP) flag is unset in authenticator_data

missing_passkey_signature

webauthn.get assertion lacks passkey_signature

registration_unsupported

Provider (or all providers) does not implement register (400)

provider_required

Registration or handle check omitted provider when required (400)

handle_taken

Registration: requested handle is already registered (400)

invalid_handle

Registration or handle check: handle fails syntax validation (400)

weak_password

Registration: password does not satisfy provider policy (400)

invalid_email

Registration: email address is malformed (400)

handle_check_unsupported

Handle check: provider does not implement check_handle (400)

unknown_fauth_endpoint

Unrecognized /api/fauth/* route (404)

not_found

Unrecognized route on the reference server (404)

invalid_json

Request body is not a valid JSON object (400)

invalid_content_length

Content-Length header is missing or not a valid integer (400)

payload_too_large

Request body exceeds the configured size limit (400)

4.9. 8. Principal and Roles#

An authPrincipal object, as derived by auth.principal (principal_dict in fleetmesh_core.identity.auth_wire), has the following structure:

{
  "principal_id": "did:nostr:<hex64>",
  "did": "did:nostr:<hex64>",
  "pubkey": "<hex64>", "pubkey_hex": "<hex64>",
  "username": "nostr:ab5d2e79cfd6", "handle": "nostr:ab5d2e79cfd6", "display_name": "nostr:ab5d2e79cfd6",
  "auth_method": "nip07_extension",
  "provider_id": "sovereign_key", "provider": "sovereign_key",
  "roles": ["viewer", "creator", "broadcaster"],
  "scopes": ["*"],
  "session_token": "fmauth_...", "admin_token": "",
  "portable_ticket": "", "bunker_relay": "",
  "issued_at": 1700000000, "expires_at": 1700604800,
  "metadata": {"signature_verified": true, "user_id": "", "identity_id": ""}
}

4.9.1. Normalization Rules#

  • pubkey/pubkey_hex and provider/provider_id are synchronized alias pairs.

  • A 64-character hex pubkey is lowercased.

  • username falls back to handle, then to principal_id; display_name falls back to handle.

  • auth_method defaults to service_login.

  • scopes are deduplicated while preserving insertion order, defaulting to ["read", "content", "streams"].

  • portable_ticket falls back to metadata.portable_ticket.

  • admin_token is populated with session_token when roles contains admin, moderator, or node_operator; otherwise it is "".

4.9.2. Role Closure (auth.expand_roles)#

Canonical role ordering: viewer, creator, broadcaster, moderator, admin, node_operator. Each role implies itself in addition to the roles listed below:

Role

Implied Roles

viewer

—

creator

viewer, broadcaster

broadcaster

viewer, creator

moderator

viewer, creator, broadcaster

admin

viewer, creator, broadcaster, moderator, node_operator

node_operator

viewer, creator, broadcaster, admin

Input roles are trimmed and lowercased. Unrecognized custom roles are preserved in sorted order after the canonical roles. An empty role set expands to ["viewer"]. A required_role check (has_required_role) succeeds when the required role appears in the expanded closure (an omitted required_role defaults to viewer). Note that admin and node_operator mutually imply one another, whereas moderator implies neither.

4.10. 9. Provider Plugin Interface (API Version 1)#

Each provider verifies one category of credential. The engine includes sovereign_key and local_operator; external providers are loaded as plugins (in Python, subclasses of fleetmesh_auth.AuthProviderPlugin discovered via the fleetmesh_auth.providers entry point or FLEETMESH_AUTH_PLUGINS; see docs/PLUGINS.md). Implementations in other languages (such as the Rust node) MUST expose the equivalent interface.

4.10.1. Provider Metadata (providerDescribe)#

Public metadata returned by GET /api/fauth/providers and embedded in config.providers_detail:

{
  "provider_id": "acme",                  // ^[a-z][a-z0-9_]{0,63}$, stable
  "display_name": "Acme",
  "description": "Sign in with your Acme account",
  "supported_methods": ["service_login", "api_key"],   // §4 authMethod values
  "token_prefixes": ["fmk_"],             // tokens it issues; routes token/api_key/ticket to it
  "login_form": {"title": "...", "submit": "...", "hint": "...",
                 "fields": [{"name": "username", "label": "Username", "type": "text", "autocomplete": "username"}]},
  "register_form": null,                  // same shape as login_form, for providers that create accounts
  "supports_registration": false,         // true when the provider implements register (§4.5)
  "supports_handle_check": false,         // true when the provider implements check_handle (§4.6)
  "api_version": 1
}

login_form is null when the provider does not require an interactive credential form. Declaring service_login in supported_methods registers the provider as an account provider eligible for login requests that omit provider.

4.10.2. Provider Behavior#

  • claims_token(token) -> bool: Returns true if token begins with any prefix in token_prefixes, and false otherwise.

  • authenticate(payload, context) -> result: Evaluates the normalized payload (§4.1). context supplies now (the engine clock), web_auth (challenge, ticket, and replay verification), host and directory (the optional co-hosted application and its user store), domain, app_preset, allow_any_sovereign_key, and passkey_store. Returns {"ok": true, "principal": <principal fields>} or {"ok": false, "error": "<code>", "detail": "<sentence>"} (detail is optional; the engine supplies a default message for known codes). Providers MUST NOT raise exceptions for invalid credentials; returning ok: false allows the engine to proceed to the next candidate provider. Raising AuthRefused(code) is equivalent to returning the corresponding refusal dictionary; any other exception is caught and reported as provider_error.

  • register(payload, context) -> result (optional, §4.5): Returns the same result structure as authenticate. The default implementation refuses with registration_unsupported.

  • check_handle(handle) -> result (optional, §4.6): Returns strictly {"ok": true, "available": bool, "reason": null | "handle_taken" | "invalid_handle"}, or {"ok": false, "error": "<code>"} if the check cannot be completed. Invoked only when supports_handle_check is true, after the engine has trimmed and validated the handle syntax (§4.6).

  • Configuration (from_settings): Reads environment variables prefixed with FLEETMESH_AUTH_<PROVIDER_ID>_<NAME>.

  • Determinism: Providers MUST use context.now and the engine-provided token source rather than the system wall clock or independent randomness so that protocol exchanges remain reproducible against conformance vectors.

Python providers are verified with fleetmesh_auth.plugin_testing.check_provider; implementations in other languages are validated against the logins section of core/vectors/web-auth.json.

4.11. 10. Sign-In Panel Configuration#

GET /api/fauth/config?preset=standard returns {ok: true, config}, where config (authWidgetConfig) contains preset branding (app_id, app_title, app_subtitle, mode as gate or modal, brand_*, accent_*, logo_variant), required_role, method and provider allow/deny lists, providers, providers_detail (§9), and login_options. Each entry in login_options describes an interactive option:

{"option_id": "bunker", "method_id": "bunker_nip07", "label": "Bunker / NIP-07",
 "button_label": "Bunker / NIP-07", "description": "...", "icon_id": "bunker",
 "tier": "expert", "provider_id": "sovereign_key", "enabled": true,
 "sub_methods": {"nip07_extension": true, "nip46_bunker": true}}

4.11.1. Presets#

Built-in presets are standard, admin, and ops (with alias meshnode-ops). Host applications can register or override presets programmatically using fleetmesh_auth.register_widget_preset(name, overrides, base="standard") and remove them with unregister_widget_preset(name). Registered presets take precedence over built-in presets, allowing a host to customize admin.

Supported override fields in authWidgetConfig are app_id, app_title, app_subtitle, mode, brand_name, brand_badge, accent_primary, accent_secondary, logo_variant, required_role, enabled_methods, disabled_methods, primary_methods, enabled_providers, disabled_providers, primary_actions, more_options_label, and signup_provider. Unrecognized keys are logged and ignored, and app_id defaults to the preset name.

Standalone servers accept equivalent preset definitions via the environment variable FLEETMESH_AUTH_PRESETS_JSON='{"acme": {"base": "ops", "app_title": "Acme"}}' (mapping {name: {base?, ...overrides}}), loaded on package import. Unrecognized preset= query values resolve by substring fallback: names containing admin resolve to admin, names containing ops resolve to ops, and all others resolve to standard.

4.11.2. Method Catalog#

Canonical catalog method_id values are: service_provider (any service_login plugin), bunker_nip07, private_key, did, api_key, passkey, portable_ticket, and operator_token. A plugin’s login option is included only when that plugin is registered.

4.12. 11. Conformance#

core/vectors/web-auth.json pins every wire representation defined in this specification using deterministic fixtures: fixed keys (a1*32 for the user, b2*32 for an alternate key, c3*32 for the node), now = 1700000000, challenge ID 00112233...4556677, nonce 0badcafe..., session token fmauth_vvv..., and zeroed BIP-340 auxiliary randomness for reproducible signatures.

To regenerate the vector file:

cd mesh-py/core && PYTHONPATH=.:../auth:../../schema python3 scripts/gen-web-auth-vectors.py

4.12.1. Conformance Operations#

Defined in schema/schema/conformance.json, implemented in fleetmesh_core.conformance.conformance_ops, and executed against candidate implementations by fleetmesh.org/scripts/conform.py:

Operation

Specification Coverage

webauth.constants

§2 constants and §7 error-code registry

webauth.issue_challenge

§3 challenge response for a fixed challenge ID and clock

webauth.challenge_message

Challenge message, SHA-256 digest, and digests across accepted schemes

webauth.ticket_mint

§6 minting steps 1–8 from sk, home, did, target, ttl, now, nonce

webauth.ticket_decode

§6 decoding across accepted prefixes, or ticket_malformed

webauth.verify

§4.3/§6 verification given issued challenges and seen event IDs; yields verified result or {refused: <code>}

auth.normalize_payload

§4.1 payload normalization

auth.expand_roles

§8 role closure

auth.principal

§8 principal serialization

4.12.2. Vector Sections and Verification Suites#

  • constants, errors, challenge, challenge_signature, auth_event, ticket, wildcard_ticket, legacy_ticket, principal, expand_roles, normalize_payload, and refusals: verified via the conformance operations above (core/tests/test_web_auth_vectors.py, conform.py).

  • logins (17 request payloads with full expected responses), session, ticket_replay, and challenge_replay: verified end-to-end through the HTTP route handlers (tests/test_conformance_vectors.py) with injected clock and token sources (FleetmeshAuthEngine(clock=, token_source=)) and reset_replay_state() invoked between test cases.

  • All wire payloads in the vector file are validated against schema/schemas/identity/fleetmesh-auth.schema.json via schema/scripts/validate-schemas.py.

An implementation is conformant when conform.py passes every web-auth/* test case and its HTTP layer reproduces every logins, session, and *_replay response byte-for-byte under the fixed fixture inputs.