auth/account_route_schema.ts

Hono-free wire schemas + route shapes for the account REST routes.

Split from account_routes.ts (whose handlers pull hono/cookie via session_middleware) so cross-process test suites can build the account route shapes — and assert on the POST /login / GET /api/account/status response shapes — without dragging the in-process Hono session handler, and its optional hono peer, onto a backend-spawning consumer. account_routes.ts imports these back and attaches the live handlers; single source of truth for the wire shape.

view source

Declarations
#

14 declarations

account_status_route_shape
#

auth/account_route_schema.ts view source

{ method: "GET"; path: string; auth: { account: "none"; actor: "none"; }; description: string; input: ZodNull; output: ZodObject<{ account: ZodObject<{ id: $ZodBranded<ZodUUID, "Uuid", "out">; username: ZodPipe<...>; email: ZodNullable<...>; email_verified: ZodBoolean; created_at: ZodString; }, $strict>; actor: ZodN... import {account_status_route_shape} from '@fuzdev/fuz_app/auth/account_route_schema.js';

The GET /status route shape minus its handler — pure hono-free data. create_account_status_route_spec spreads this and attaches the live handler (which reads the account id off the request context); surface generation spreads it with a stub handler.

The path is relative like the sibling account shapes (/login, /verify), so it composes under prefix_route_specs('/api/account', …) into /api/account/status. create_account_route_specs bundles it (so every account surface serves /status, matching the Rust account_router); mirror Rust by mounting it as part of the account family, not separately.

AccountRouteShapeOptions
#

auth/account_route_schema.ts view source

AccountRouteShapeOptions import type {AccountRouteShapeOptions} from '@fuzdev/fuz_app/auth/account_route_schema.js';

Option inputs that shape the account route metadata (not its handlers).

login_account_rate_limited

Whether a per-account login rate limiter is wired — toggles /password's rate_limit.

type boolean

AccountStatusInput
#

auth/account_route_schema.ts view source

ZodNull import type {AccountStatusInput} from '@fuzdev/fuz_app/auth/account_route_schema.js';

Input for GET /api/account/status. No parameters — caller is the subject.

AccountStatusOutput
#

auth/account_route_schema.ts view source

ZodObject<{ account: ZodObject<{ id: $ZodBranded<ZodUUID, "Uuid", "out">; username: ZodPipe<ZodString, ZodTransform<string, string>>; email: ZodNullable<...>; email_verified: ZodBoolean; created_at: ZodString; }, $strict>; actor: ZodNullable<...>; role_grants: ZodArray<...>; }, $strict> import type {AccountStatusOutput} from '@fuzdev/fuz_app/auth/account_route_schema.js';

Output for GET /api/account/status.

AccountStatusUnauthenticatedError
#

auth/account_route_schema.ts view source

ZodObject<{ error: ZodLiteral<"authentication_required">; bootstrap_available: ZodOptional<ZodBoolean>; }, $loose> import type {AccountStatusUnauthenticatedError} from '@fuzdev/fuz_app/auth/account_route_schema.js';

Error body for GET /api/account/status on the unauthenticated path.

create_account_route_shapes
#

auth/account_route_schema.ts view source

(options: AccountRouteShapeOptions): [Omit<RouteSpec, "handler">, Omit<RouteSpec, "handler">, Omit<RouteSpec, "handler">, Omit<...>] import {create_account_route_shapes} from '@fuzdev/fuz_app/auth/account_route_schema.js';

The four account route shapes (/verify, /login, /logout, /password) minus their handlers — pure hono-free data. create_account_route_specs spreads each and attaches the live handler; cross-process surface builders spread them with stub handlers. Single source of truth — the shapes can't drift between the live routes and the surface.

Returns a fixed 4-tuple [verify, login, logout, password] so destructuring yields non-optional shapes under noUncheckedIndexedAccess.

options

returns

[Omit<RouteSpec, "handler">, Omit<RouteSpec, "handler">, Omit<RouteSpec, "handler">, Omit<RouteSpec, "handler">]

DEFAULT_MAX_SESSIONS
#

DEFAULT_MAX_TOKENS
#

LoginInput
#

auth/account_route_schema.ts view source

ZodObject<{ username: ZodPipe<ZodString, ZodTransform<string, string>>; password: ZodString; }, $strict> import type {LoginInput} from '@fuzdev/fuz_app/auth/account_route_schema.js';

Input for POST /login. Accepts a username or email in the username field.

LoginOutput
#

auth/account_route_schema.ts view source

ZodObject<{ ok: ZodLiteral<true>; }, $strict> import type {LoginOutput} from '@fuzdev/fuz_app/auth/account_route_schema.js';

Output for POST /login. Session cookie is the operative side effect.

LogoutInput
#

auth/account_route_schema.ts view source

ZodNull import type {LogoutInput} from '@fuzdev/fuz_app/auth/account_route_schema.js';

Input for POST /logout. Session identity flows through the cookie.

LogoutOutput
#

auth/account_route_schema.ts view source

ZodObject<{ ok: ZodLiteral<true>; username: ZodString; }, $strict> import type {LogoutOutput} from '@fuzdev/fuz_app/auth/account_route_schema.js';

Output for POST /logout. Includes the revoked account's username for UI redraw.

PasswordChangeInput
#

auth/account_route_schema.ts view source

ZodObject<{ current_password: ZodString; new_password: ZodString; }, $strict> import type {PasswordChangeInput} from '@fuzdev/fuz_app/auth/account_route_schema.js';

Input for POST /password. current_password is minimally validated; new_password enforces the full policy.

PasswordChangeOutput
#

auth/account_route_schema.ts view source

ZodObject<{ ok: ZodLiteral<true>; sessions_revoked: ZodNumber; tokens_revoked: ZodNumber; }, $strict> import type {PasswordChangeOutput} from '@fuzdev/fuz_app/auth/account_route_schema.js';

Output for POST /password. Counts are returned so the UI can summarize the revoke-all cascade.

Depends on
#

Imported by
#