AuthContextOptions
Type Parameters
Section titled “Type Parameters”U extends AuthUser = AuthUser
A = unknown
Properties
Section titled “Properties”
readonlyauth:TrpcAuth<U,A>
The createAuth(...) result.
clientIpHeader?
Section titled “clientIpHeader?”
readonlyoptionalclientIpHeader?:string
A single-address header your edge sets, such as cf-connecting-ip.
Needs trustedHops as a list naming the edge (or hops that accept
traffic only from it); read only when the socket address is inside that
list and the value is exactly one IP, otherwise X-Forwarded-For
decides. Off by default.
readonlycsrf:CsrfOptions
revalidateSubscriptions?
Section titled “revalidateSubscriptions?”
readonlyoptionalrevalidateSubscriptions?:false|Duration
How long a subscription behind a session check (authed, freshAuth,
role, protectedProcedure, the nestjs-trpc guard) may go on sending
events on the session it opened with. tRPC builds the context once per
HTTP request, and an SSE subscription is one request that stays open, so
its session is validated once. Before an event leaves, when the last
check is older than this, the session is validated again (without
counting as activity) and its user loaded; when either is gone, or the
session became enrollment-only, the stream ends with session_expired
(or two_factor_enrollment_required) instead of the event. 0 checks
before every event. false turns it off. Default 30s.
roles?
Section titled “roles?”
readonlyoptionalroles?: (user) => readonlystring[] |Promise<readonlystring[]>
The user’s roles, for role(...). Called on every call that needs a
role, with the user just loaded from the store, so a role change takes
effect on the next request.
Parameters
Section titled “Parameters”U
Returns
Section titled “Returns”readonly string[] | Promise<readonly string[]>
touch?
Section titled “touch?”
readonlyoptionaltouch?:boolean| ((path) =>boolean)
Whether a request counts as activity for the session’s idle timeout.
true (the default) refreshes the session’s last-active time, at most
once per touchInterval, on every request. A predicate is asked about
each procedure path of the request (notifications.count), before the
session is validated: return false for procedures the page calls on its
own (a poll on a timer, a status check), so an idle session still
expires while only they are called. A procedure whose meta says
touch: false is passive too. A batch touches when any of its
procedures is active. false touches on no request. A passive request
is still answered with its session, and the CSRF verdict and the
guarded procedures’ decisions do not change.
trustedHops
Section titled “trustedHops”
readonlytrustedHops:TrustedHops
How many reverse proxies sit in front of the server, counted from the
right of X-Forwarded-For (the core’s clientIp rule), 0 when none; or
a list of proxy addresses, CIDR ranges and the presets loopback,
linklocal and uniquelocal, trusted by the socket address.