auth/credential_headers.ts

The grammar of the three credential headers — the session cookie in Cookie, the API token in Authorization: Bearer, the daemon token in X-Daemon-Token — as pure readers over header lines.

One spelling per credential, the Rust spine's fuz_auth::credential_headers reading the same one: a value either reads exactly, or it is not that credential. Nothing is decoded, unquoted, or repaired — a lenient side would authenticate a request the other refuses. The shared table testing/cross_backend/credential_conformance.json holds both to the same rows.

Each reader takes the header's lines — one field value per header line, in the order sent, outer SP and HTAB already stripped (get_header_lines of http/header_lines.ts on a request) — so "sent twice" is something a reader can see and decide on.

Hono-free: the middleware legs call these, and so does the _testing_credential_read action.

view source

Declarations
#

3 declarations

read_bearer_token
#

auth/credential_headers.ts view source

(authorization_lines: readonly string[]): string | null import {read_bearer_token} from '@fuzdev/fuz_app/auth/credential_headers.js';

Read the API token out of the request's Authorization lines.

The header must be exactly one line: the scheme Bearer in any ASCII case, one SP, and a value is_api_token_shaped accepts — nothing before, between, or after. A header sent twice is discarded whatever its lines hold, never resolved to one of them.

A runtime that shows no per-line view (get_header_lines) hands repeated lines over as one, joined with , . No token holds a comma, so the join fails the shape and is discarded as the repeat it is; a lone line that happens to hold , reads the same on both spines.

authorization_lines

the Authorization header's lines

type readonly string[]

returns

string | null

the token to look up, or null when the header carries none

read_daemon_token
#

auth/credential_headers.ts view source

(daemon_token_lines: readonly string[]): string | null import {read_daemon_token} from '@fuzdev/fuz_app/auth/credential_headers.js';

Read the daemon token out of the request's X-Daemon-Token lines.

The header must be exactly one line holding a value is_daemon_token_shaped accepts. A header sent twice is discarded — an empty second line included — and, as for read_bearer_token, a join with , fails the shape.

daemon_token_lines

the X-Daemon-Token header's lines

type readonly string[]

returns

string | null

the token to compare, or null when the header carries none

read_session_cookie_value
#

Depends on
#

Imported by
#