Przejdź do głównej zawartości

Interface: StorefrontAuthRouteOptions

Properties

apiUrl

apiUrl: string

Backend base URL (e.g. https://api.doswiftly.pl). The server-to-server namespace is ${apiUrl}/storefront/auth/*.


authBasePath?

optional authBasePath?: string

Base path the route is mounted at (default /api/auth). The refresh cookie's Path is set to it so the cookie reaches both the refresh and logout routes (siblings under this base) but not GraphQL data traffic, which lives on a different path.


fetch?

optional fetch?: {(input, init?): Promise<Response>; (input, init?): Promise<Response>; }

Custom fetch (tests, non-standard runtimes). Defaults to globalThis.fetch.

Call Signature

(input, init?): Promise<Response>

MDN Reference

Parameters
input

RequestInfo | URL

init?

RequestInit

Returns

Promise<Response>

Call Signature

(input, init?): Promise<Response>

MDN Reference

Parameters
input

string | Request | URL

init?

RequestInit

Returns

Promise<Response>


getBuyerIp?

optional getBuyerIp?: (request) => string | Promise<string | null | undefined> | null | undefined

Real buyer IP source for forwarded-IP signing. Defaults to reading the x-doswiftly-client-ip header (set by the platform edge) then cf-connecting-ip from the incoming request. Forwarding the buyer's real IP lets the backend rate-limit per buyer even though the auth call is server-to-server — otherwise every buyer of a shop shares the storefront server's IP and per-IP limits collapse onto it. Override only for non-standard transports. Sync or async.

Parameters

request

Request

Returns

string | Promise<string | null | undefined> | null | undefined


getForwardedIpSecret?

optional getForwardedIpSecret?: () => string | Promise<string | null | undefined> | null | undefined

Forwarded-IP signing secret. Defaults to process.env.DOSWIFTLY_FORWARDED_IP_SECRET (injected into the storefront's server runtime by your DoSwiftly deployment). Forwarding is opt-in on the secret: without it the route signs nothing and the backend keys the connection IP. Server-side only — never expose to the browser. Lazy getter — a rotated secret is picked up without rebuilding the route.

Returns

string | Promise<string | null | undefined> | null | undefined


isTrustedOrigin?

optional isTrustedOrigin?: OriginValidator | null

CSRF defense-in-depth predicate. When the storefront runs behind a reverse proxy that rewrites/strips Host (Cloudflare Workers, Vercel, NGINX), pass trustedForwardedHostValidator. This is NOT the primary control — the backend's protocol controls (rotation + reuse-detection + rate-limit + possession-proof) are. See OriginValidator.


shopSlug

shopSlug: string

Shop slug forwarded as the X-Shop-Slug routing hint (selects the tenant; never binds the rotation family).