bijectionAuth(options)
From @bijectionhq/library-auth. Returns a subtree to place at auth in the app
tree (app({ auth, … })); its routes, tables and functions take their paths
there.
profile is { name, email, emailVerified, phone, phoneVerified }, each
null (or false) when the method did not supply it. Option errors throw a
TypeError when the declarations are evaluated, so a deploy refuses them.
What the subtree holds
Methods
Email senders
With neither
via nor send, codes go out through the library’s mail slot,
<auth>.mail (send-mail@1): the host’s managed sender unless
the installation’s bindings file binds it to an endpoint
(email delivery).
The managed sender sends from the host’s own address: from keeps only its
display name, and replyTo becomes the Reply-To. A local http://localhost
or http://127.0.0.1 deployment logs the code. A host with no sender
refuses the deploy with PlacementUnavailable.
Native source
The source inbijection/sign-in.ts that bijection auth init writes:
bijection/sign-in.ts
bijection/app.ts. After deploying, trust
the installation’s own issuer for it with
bijection issuer trust bijectionSignIn --issuer-url https://site.example.com/auth --audience bijection --source-id bijection --trust-verified-email
(bijection auth init prints this command). For an HTTPS
issuer, the library declares the matching token receiver under its
oidc.exchange subtree. When the installation advertises the durable
exchange, the native Sessions Task submits the code to that exact URL.
nativeSessions also takes accessTokenLifetimeMs (120000 to 300000,
default 300000), idleLifetimeMs (default 1800000) and absoluteLifetimeMs
(default 28800000, at most 86400000), with access ≤ idle ≤ absolute. These
options are the same for every provider.
Session functions
Called by a signed-in client atapi<typeof App>().auth.session.
Browser client
From@bijectionhq/library-auth/client (non-visual, zero React dependency).
For visual sign-in and account management components, install
@bijection/sign-in,
@bijection/manage-account and @bijection/signed-in-devices from
ui.bijection.com.
Pass bijectionAuth() from @bijectionhq/bijection/client as token and
its httpProof signer to connect. Each browser snapshot reads and renews
credentials for its own session. Its signOut, listSessions, endSession,
and forget actions also stay with the session that issued the snapshot.
After an interrupted sign-out, the signed-out snapshot reports
signOutStatus: "pending". Call signOut() again to recover the original
request and its original scope. An expired token can recover an existing
receipt. If the deployment reports that the receipt is unavailable, the
snapshot reports "unconfirmed". Call abandonSignOut() to explicitly
discard the saved request before starting a new sign-in.
The snapshot uses null for a signed-out sessionId and undefined when
browser custody is unavailable. Credential reads require available custody.
If a provider-renewed session cannot resolve its retained renewal, the
snapshot is signed out and reports
reauthenticationRequired: "ProviderRenewalIndeterminate". Offer
signIn() to start a new ceremony after any pending sign-out is resolved.
While subscribed, the store retries an unavailable custody read. Browser
callback restoration retries transient IndexedDB proof-key reads before
the provider exchange, within the original attempt’s expiration period.
The store keeps observing custody changes during that wait. An unfinished
callback’s error stays visible until it completes or the user starts sign-in
again.
Routes
Under the issuer,<site>/auth.
sub is stable for a person across linking and unlinking.
Limits and lifetimes
CLI
bijection auth init --provider bijection installs and configures the
library (see the quick start).
On a terminal, a first setup without choice flags asks how sign-in emails are
sent and whether they carry magic links. Running
auth init again edits the
existing auth.ts in place.
Refusal codes
Session functions refuse with these codes in the client’sResult. Method
routes answer { ok: false, error, code } to a JSON caller and show the
message on the page. /auth/authorize and /auth/token answer the OAuth
error format, as OIDC clients expect. Codes are stable; messages may be
reworded. AUTH_ERRORS exports the catalog with HTTP statuses and messages.