@softistx/alxia-react-router 0.89.4 → 0.90.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -2
- package/dist/chunks/{index-1nw5yeek.js → index-qkyt0bka.js} +3 -3
- package/dist/chunks/{index-1nw5yeek.js.map → index-qkyt0bka.js.map} +1 -1
- package/dist/chunks/index-w61bjnkw.js +1019 -0
- package/dist/chunks/index-w61bjnkw.js.map +27 -0
- package/dist/clavix/api-url.d.ts +43 -0
- package/dist/clavix/api-url.d.ts.map +1 -0
- package/dist/clavix/client.d.ts +22 -0
- package/dist/clavix/client.d.ts.map +1 -0
- package/dist/clavix/core.d.ts +39 -0
- package/dist/clavix/core.d.ts.map +1 -0
- package/dist/clavix/env.d.ts +26 -0
- package/dist/clavix/env.d.ts.map +1 -0
- package/dist/clavix/index.d.ts +19 -0
- package/dist/clavix/index.d.ts.map +1 -0
- package/dist/clavix/index.js +673 -0
- package/dist/clavix/index.js.map +22 -0
- package/dist/clavix/landing.d.ts +67 -0
- package/dist/clavix/landing.d.ts.map +1 -0
- package/dist/clavix/messages.d.ts +53 -0
- package/dist/clavix/messages.d.ts.map +1 -0
- package/dist/clavix/notice.d.ts +32 -0
- package/dist/clavix/notice.d.ts.map +1 -0
- package/dist/clavix/refusal.d.ts +29 -0
- package/dist/clavix/refusal.d.ts.map +1 -0
- package/dist/clavix/relay.d.ts +41 -0
- package/dist/clavix/relay.d.ts.map +1 -0
- package/dist/clavix/routes.d.ts +5 -0
- package/dist/clavix/routes.d.ts.map +1 -0
- package/dist/clavix/send.d.ts +32 -0
- package/dist/clavix/send.d.ts.map +1 -0
- package/dist/clavix/state.d.ts +20 -0
- package/dist/clavix/state.d.ts.map +1 -0
- package/dist/clavix/types.d.ts +97 -0
- package/dist/clavix/types.d.ts.map +1 -0
- package/dist/clavix/viewer.d.ts +12 -0
- package/dist/clavix/viewer.d.ts.map +1 -0
- package/dist/fetcher/auth-refusal.d.ts +5 -1
- package/dist/fetcher/auth-refusal.d.ts.map +1 -1
- package/dist/fetcher/index.js +2 -5
- package/dist/fetcher/index.js.map +3 -3
- package/dist/oidc/index.js +23 -1025
- package/dist/oidc/index.js.map +3 -21
- package/dist/session/index.js +1 -1
- package/docs/README.md +2 -1
- package/docs/guide/clavix.md +332 -0
- package/docs/guide/fetcher.md +4 -0
- package/docs/guide/oidc.md +3 -0
- package/docs/roadmap.md +6 -0
- package/docs/troubleshooting.md +41 -0
- package/package.json +8 -2
package/README.md
CHANGED
|
@@ -98,7 +98,7 @@ Vite's preview server, as `bun run start` would: the pages, `/api`, the
|
|
|
98
98
|
client's files and the app's middlewares. So does React Router's prerendering.
|
|
99
99
|
|
|
100
100
|
`@softistx/alxia` and `react-router` 8 are peers, and `vite` 7 or 8 is an
|
|
101
|
-
optional peer, for `/vite`; `react` 19 is an optional peer, for `/pwa/react`, `/fetcher`, `/lists`, `/navigation` and `/oauth/react`; `jose` 6 is an optional peer, for `/oidc`. The six `workbox-*`
|
|
101
|
+
optional peer, for `/vite`; `react` 19 is an optional peer, for `/pwa/react`, `/fetcher`, `/lists`, `/navigation` and `/oauth/react`; `jose` 6 is an optional peer, for `/oidc` and `/clavix`. The six `workbox-*`
|
|
102
102
|
packages (`workbox-core`, `workbox-expiration`, `workbox-navigation-preload`,
|
|
103
103
|
`workbox-precaching`, `workbox-routing`, `workbox-strategies`) are optional
|
|
104
104
|
peers too, for `/pwa/worker` (the [PWA section](#installable-and-offline-pwa) has the install line). `@softistx/alxia-proxy` is an optional peer, for `/mcp` (`bun add @softistx/alxia-proxy`); `/mcp` also reads `@softistx/alxia`'s `MCP_RELAY_PATHS`. `react-hook-form` (7.55 or later) is an optional peer: `SectionForm`, the form `useSectionSave` and `useRowSave` take from `/fetcher`, is the shape of its `useForm()` result. `@softistx/graphql-client` (`^0.9.0 || ^0.10.0 || ^0.11.0 || ^0.12.0 || ^0.13.0`) is an optional peer, for `/subscription/react` (`bun add @softistx/graphql-client`). `/errors` imports `react-router`, a required peer that is already installed. The package declares no dependency.
|
|
@@ -1781,6 +1781,25 @@ export async function loader({ request }: LoaderFunctionArgs) {
|
|
|
1781
1781
|
announces one, else ends the local session only. See the
|
|
1782
1782
|
[OIDC guide](https://github.com/softistx/alxia/blob/develop/packages/react-router/docs/guide/oidc.md#less-glue).
|
|
1783
1783
|
|
|
1784
|
+
### Signing in with Clavix: `clavixRoutes`
|
|
1785
|
+
|
|
1786
|
+
`@softistx/alxia-react-router/clavix` (over `/oidc`; `react-router` and `jose` only) is the whole BFF side of a sign-in with Clavix: PAR, DPoP, the sign-in, callback and sign-out routes, provider-only by default (no page with a lone button), the refusal notices with a support reference, and the relays for `/media` (the `/media` subpath) and `/live`. Env is read at start-up and a bad one throws one `OidcEnvError`.
|
|
1787
|
+
|
|
1788
|
+
```ts no-check
|
|
1789
|
+
// app/clavix.server.ts
|
|
1790
|
+
import { clavixRoutes } from '@softistx/alxia-react-router/clavix';
|
|
1791
|
+
|
|
1792
|
+
export const clavix = clavixRoutes({
|
|
1793
|
+
secure: !import.meta.env.DEV,
|
|
1794
|
+
api: { publicUrl: 'https://api.example.com', internalUrl: 'http://api:3000' },
|
|
1795
|
+
appOrigin: () => 'https://app.example.com',
|
|
1796
|
+
});
|
|
1797
|
+
// routes: clavix.routes.start, clavix.routes.callback, clavix.routes.signOut,
|
|
1798
|
+
// `clavix.landing(request)` in the sign-in loader, `clavix.viewer(request, viewerOf)` for the user
|
|
1799
|
+
```
|
|
1800
|
+
|
|
1801
|
+
See the [Clavix guide](https://github.com/softistx/alxia/blob/develop/packages/react-router/docs/guide/clavix.md).
|
|
1802
|
+
|
|
1784
1803
|
## Traps
|
|
1785
1804
|
|
|
1786
1805
|
- **A context key made in `app/` reaches the loaders only through the
|
|
@@ -2054,6 +2073,15 @@ From `@softistx/alxia-react-router/oauth` (`react-router` is its only package im
|
|
|
2054
2073
|
| `isRouteRefusal(value)`, `routeRefusalStatus(value)`, `RouteRefusal`, `DataRefusal` | re-exported from `/errors`, to recognise what the consent action throws and read its status |
|
|
2055
2074
|
| `ConsentAnswer`, `ConsentDecisionIntent` | the types of the action's answer and of `'approve' \| 'deny'` |
|
|
2056
2075
|
|
|
2076
|
+
From `@softistx/alxia-react-router/clavix` (`react-router`, `/session`'s cookies and `jose`, an optional peer; see [the guide](docs/guide/clavix.md)):
|
|
2077
|
+
|
|
2078
|
+
| export | |
|
|
2079
|
+
| --- | --- |
|
|
2080
|
+
| `clavixRoutes(options)`, `ClavixRoutesOptions`, `ClavixRoutes`, `ClavixPaths`, `ClavixRelay` | the sign-in, callback and sign-out routes, `landing`, `sendOf`, `viewer`, `relay`, `apiUrl`, `withRefreshedCookies`, `ready` |
|
|
2081
|
+
| `SessionExpired`, `isExpiredAnswer`, `ClavixOriginError` | an ended session (its `answer` is the redirect or the 401) and the refusal of a call outside `api.publicUrl` and `api.internalUrl` |
|
|
2082
|
+
| `appendSetCookies`, `rewritingFetch`, `ApiUrls`, `Send` | cookie and fetch helpers, and the types of `sendOf` |
|
|
2083
|
+
| `clavixRefusalOf`, `needsReference`, `supportReference`, `isSupportReference`, `clavixNoticeOf`, `clavixToneOf`, `clavixNoticeText`, `clavixMessages`, `CLAVIX_PARAMS`, `CLAVIX_REFUSALS`, `ClavixLanding`, `LandingOptions`, `ClavixNotice`, `ClavixTone`, `ClavixRefusal`, `ClavixMessages` | Clavix's refusals and notices, worded for the page |
|
|
2084
|
+
|
|
2057
2085
|
From `@softistx/alxia-react-router/oidc` (`react-router`, `/session`'s cookies and `jose`, an optional peer):
|
|
2058
2086
|
|
|
2059
2087
|
| export | |
|
|
@@ -2091,7 +2119,7 @@ From `@softistx/alxia-react-router/fetcher` (`react` and `react-router` are its
|
|
|
2091
2119
|
| --- | --- |
|
|
2092
2120
|
| `useFetcherAnswer(fetcher, onAnswer?)`, `AnswerSource` | `onAnswer(answer)` once per answer that arrives while the fetcher is idle and differs from the last one seen (the data present at mount counts as seen); the handler is read from a ref; returns the latest answer handed over, `undefined` before the first |
|
|
2093
2121
|
| `useFetcherDone(fetcher, isDone, onDone)` | `onDone()` once per new answer that `isDone(data)` accepts, while the fetcher is idle (a save done: close the dialog); the data present at mount counts as handled, so a dialog that reopens does not fire again; `isDone` and `onDone` are read from refs |
|
|
2094
|
-
| `authRefusal(answer, fields)`, `AuthAnswer`, `AuthRefusal` | maps an auth route action's answer `{ sent?, formError?, retryAfter?, fieldErrors? }` to the refusal an auth form's `onSubmit` returns, `{ form, retryAfter, <field> }` for the listed `fields
|
|
2122
|
+
| `authRefusal(answer, fields)`, `AuthAnswer`, `AuthRefusal` | maps an auth route action's answer `{ sent?, formError?, retryAfter?, fieldErrors? }` to the refusal an auth form's `onSubmit` returns, `{ form, retryAfter, <field> }` for the listed `fields` (no `form` when `retryAfter` is set: the forms word the wait), or `undefined` when `sent` is true |
|
|
2095
2123
|
| `useFetcherPromise(fetcher, { refusal? }?)`, `FetcherPromiseOptions`, `FetcherPromiseAborted`, `FetcherPromiseNoAnswer` | returns a stable `run(submit)` that calls `submit` (`() => fetcher.submit(...)`) and returns a Promise settled by the fetcher's next new answer: resolved with it, or rejected with an `Error` when `refusal(answer)` returns a message (or your own `Error`); an answer held before the call never settles it; a second `run` while one is pending rejects the older with `FetcherPromiseAborted` (`reason: 'superseded'`); an unmount rejects the pending one (`'unmounted'`); a submission that ends idle with no new answer (`null`, `undefined` or the same data) rejects with `FetcherPromiseNoAnswer`; a `submit` that throws rejects with its error |
|
|
2096
2124
|
| `useFormRefusal(result)`, `FormRefusalResult` | `useFormRefusal(fetcher.data)` returns the `FormErrors` of a fetcher answer that carries `fieldErrors` (`apiErrors.formRefusal`'s), `undefined` for no answer, a done step or a refusal without them; stable for one answer |
|
|
2097
2125
|
| `useVisibleInterval(callback, ms, { enabled?, runOnVisible? }?)`, `VisibleIntervalOptions` | runs `callback` every `ms` only while `document.visibilityState` is `'visible'` (a tick while hidden is skipped); when a hidden page becomes visible after at least `ms` since the last run it runs at once (`runOnVisible`, default `true`); `enabled: false` stops it; the callback is read from a ref, so a new function never restarts the timer; the timer and listener are cleared on unmount; nothing starts on the server |
|
|
@@ -2147,6 +2175,7 @@ The `alxia-react-router` bin, run with `bunx`:
|
|
|
2147
2175
|
## Documentation
|
|
2148
2176
|
|
|
2149
2177
|
- [Documentation index](https://github.com/softistx/alxia/blob/develop/packages/react-router/docs/README.md): every page, and when to read it.
|
|
2178
|
+
- [A BFF signing in with Clavix](https://github.com/softistx/alxia/blob/develop/packages/react-router/docs/guide/clavix.md): `clavixRoutes`, the sign-in landing, the refusal notices and the relays.
|
|
2150
2179
|
- [A relying party of an OIDC issuer](https://github.com/softistx/alxia/blob/develop/packages/react-router/docs/guide/oidc.md): `oidcClient`, `oidcFromEnv`, the route helpers, `dpopFetch`, the options and the limits.
|
|
2151
2180
|
- [Flow docs per role](https://github.com/softistx/alxia/blob/develop/packages/react-router/docs/guide/help.md): the `docs/flows` format, loading, `useHelpFlows`, the lazy `HelpPanel`, `useGuideRole` and the coverage check.
|
|
2152
2181
|
- [Getting started](https://github.com/softistx/alxia/blob/develop/packages/react-router/docs/guide/getting-started.md): a new app, the official template or an existing app.
|
|
@@ -163,7 +163,7 @@ function challengeCleared(cookies) {
|
|
|
163
163
|
return cookies.destroyChallenge ? [cookies.destroyChallenge()] : [];
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
export { checkSameSite, isCookieName, serializeCookie2, readCookie2, millisOf, secondsUntil2, sessionCookies2, challengeCleared };
|
|
166
|
+
export { checkSameSite, isCookieName, serializeCookie2, readCookie2, hasCookie, millisOf, secondsUntil2, sessionCookies2, challengeCleared };
|
|
167
167
|
|
|
168
|
-
//# debugId=
|
|
169
|
-
//# sourceMappingURL=index-
|
|
168
|
+
//# debugId=B1FB818E94B94E5364756E2164756E21
|
|
169
|
+
//# sourceMappingURL=index-qkyt0bka.js.map
|
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
"import {\n\tcheckSameSite,\n\thasCookie,\n\tisCookieName,\n\tisCookiePath,\n\tmillisOf,\n\treadCookie,\n\ttype SameSite,\n\tsecondsUntil,\n\tserializeCookie,\n} from './serialize';\n\n/** What every `sessionCookies` call takes, with or without a second factor. */\nexport interface SessionCookiesBaseOptions {\n\t/**\n\t * The base name of the session cookie, e.g. `'my-app_session'`. With\n\t * `secure`, the cookie is named `__Host-my-app_session`.\n\t */\n\treadonly session: string;\n\t/**\n\t * The app is served over HTTPS. Required, and never read from the\n\t * environment: pass `!import.meta.env.DEV`. `false` drops `Secure` and the\n\t * prefixes (Safari drops a `Secure` cookie over `http://localhost`).\n\t */\n\treadonly secure: boolean;\n\t/**\n\t * The `SameSite` attribute of every cookie written. `'lax'` by default;\n\t * `'strict'` for an app no other site links into signed in; `'none'`\n\t * needs `secure`.\n\t */\n\treadonly sameSite?: SameSite | undefined;\n}\n\n/** The options of an app with no second factor: no challenge cookie. */\nexport interface SessionCookiesWithoutChallengeOptions\n\textends SessionCookiesBaseOptions {\n\treadonly challenge?: undefined;\n\treadonly challengePath?: undefined;\n\treadonly challengeHostPrefix?: undefined;\n\treadonly challengeSeconds?: undefined;\n}\n\n/** The options of an app with a second factor: the challenge cookie's name is given. */\nexport interface SessionCookiesOptions extends SessionCookiesBaseOptions {\n\t/**\n\t * The base name of the second-factor challenge's cookie. With `secure`, it\n\t * is named `__Secure-<name>`.\n\t */\n\treadonly challenge: string;\n\t/** Where the browser sends the challenge. `'/sign-in'` by default. */\n\treadonly challengePath?: string | undefined;\n\t/**\n\t * Name the challenge cookie `__Host-<name>` instead of `__Secure-<name>`\n\t * (with `secure`). `__Host-` also forbids a `Domain`, so a sibling\n\t * subdomain cannot plant a cookie of the same name: pick it for an app on\n\t * per-tenant subdomains. It needs `Path=/`, so `challengePath: '/'` must\n\t * be passed too, else a `TypeError`. `false` by default.\n\t */\n\treadonly challengeHostPrefix?: boolean | undefined;\n\t/** The most the challenge lives. 300, `@softistx/janus`'s lifetime, by default. */\n\treadonly challengeSeconds?: number | undefined;\n}\n\n/** What the session cookie holds: the token, and the expiry (ms) it was last set to. */\nexport interface CookieSession {\n\treadonly token: string;\n\treadonly expiresAt: number;\n}\n\n/** The cookies every BFF has: the session's. */\nexport interface SessionCookiesBase {\n\t/** The names as sent, prefixes included. */\n\treadonly names: { readonly session: string };\n\t/** The session cookie of the request; `null` when absent or not `<ms>.<token>`. */\n\tread(request: Request): CookieSession | null;\n\t/** The session token of the request, or `null`. */\n\ttoken(request: Request): string | null;\n\t/**\n\t * Whether the request carries the session cookie at all, readable or not: a\n\t * guest page clears an unreadable one with `destroy()`.\n\t */\n\tpresent(request: Request): boolean;\n\t/** A `Set-Cookie` value keeping `token` until `expiresAt`. */\n\tcommit(token: string, expiresAt: string | Date, now?: number): string;\n\t/** A `Set-Cookie` value removing the session cookie. */\n\tdestroy(): string;\n\t/** The `Set-Cookie` header that keeps the cookie as long as the session lives; empty when the expiry did not move, or is absent or not a date. */\n\trefreshed(\n\t\tsession: CookieSession,\n\t\texpiresAt: string | Date | null,\n\t): HeadersInit;\n\t/**\n\t * What a signed-out visit of the sign-in page sets: a dead session's\n\t * cookie when `deadSession` (and, with a second factor, the challenge\n\t * cleared blind: a client navigation fetches `/sign-in.data`, which the\n\t * cookie's path does not match, so the request never shows it).\n\t */\n\tsignInPageHeaders(deadSession: boolean): Headers;\n}\n\n/** The challenge cookie's helpers, present when `challenge` was given. */\nexport interface ChallengeCookies {\n\treadonly names: { readonly challenge: string };\n\t/** The challenge cookie of the request, or `null`. */\n\tchallengeOf(request: Request): string | null;\n\t/** A `Set-Cookie` value keeping the challenge for the code page. */\n\tcommitChallenge(\n\t\tchallenge: string,\n\t\texpiresAt?: string | Date | null,\n\t\tnow?: number,\n\t): string;\n\t/** A `Set-Cookie` value removing the challenge. */\n\tdestroyChallenge(): string;\n}\n\n/**\n * The cookies `sessionCookies` returns: with the challenge helpers (the\n * default) when `challenge` was given, `SessionCookies<false>` without.\n */\nexport type SessionCookies<WithChallenge extends boolean = true> =\n\tWithChallenge extends true\n\t\t? SessionCookiesBase & ChallengeCookies\n\t\t: SessionCookiesBase & NoChallengeCookies;\n\n/**\n * What `SessionCookies<false>` says of the challenge helpers: they are\n * absent. Declared as `undefined` so that a set with a challenge is not\n * assignable to it (a flow with no second factor refuses one at compile time).\n */\nexport interface NoChallengeCookies {\n\treadonly challengeOf?: undefined;\n\treadonly commitChallenge?: undefined;\n\treadonly destroyChallenge?: undefined;\n}\n\nconst PREFIX = /^__(?:Host|Secure)-/;\n\nfunction checkName(label: string, name: string): void {\n\tif (!isCookieName(name)) {\n\t\tthrow new TypeError(\n\t\t\t`sessionCookies(): the ${label} name ${JSON.stringify(name)} is not a cookie name (an RFC 6265 token: letters, digits and ! # $ % & ' * + - . ^ _ \\` | ~). Pass a name such as \"my-app_${label}\".`,\n\t\t);\n\t}\n\tif (PREFIX.test(name)) {\n\t\tthrow new TypeError(\n\t\t\t`sessionCookies(): the ${label} name ${JSON.stringify(name)} already carries a prefix. Pass the base name: the package adds __Host- (session) or __Secure- (challenge) when secure is true.`,\n\t\t);\n\t}\n}\n\n/**\n * The cookies of a BFF's session and, when `challenge` is given, of its\n * second-factor challenge. Without `challenge`, the result has no challenge\n * helpers and the type says so.\n *\n * @example\n * const cookies = sessionCookies({ session: 'my-app_session', secure: true });\n */\nexport function sessionCookies(\n\toptions: SessionCookiesOptions,\n): SessionCookies<true>;\nexport function sessionCookies(\n\toptions: SessionCookiesWithoutChallengeOptions,\n): SessionCookies<false>;\nexport function sessionCookies(\n\toptions: SessionCookiesBaseOptions & {\n\t\treadonly challenge?: string | undefined;\n\t\treadonly challengePath?: string | undefined;\n\t\treadonly challengeHostPrefix?: boolean | undefined;\n\t\treadonly challengeSeconds?: number | undefined;\n\t},\n): SessionCookies<boolean>;\nexport function sessionCookies(\n\toptions: SessionCookiesBaseOptions & {\n\t\treadonly challenge?: string | undefined;\n\t\treadonly challengePath?: string | undefined;\n\t\treadonly challengeHostPrefix?: boolean | undefined;\n\t\treadonly challengeSeconds?: number | undefined;\n\t},\n): SessionCookies<boolean> {\n\tconst {\n\t\tsecure,\n\t\tsameSite = 'lax',\n\t\tchallengePath = '/sign-in',\n\t\tchallengeHostPrefix = false,\n\t\tchallengeSeconds = 5 * 60,\n\t} = options;\n\tcheckSameSite('sessionCookies():', sameSite, secure);\n\tcheckName('session', options.session);\n\tif (options.challenge !== undefined)\n\t\tcheckName('challenge', options.challenge);\n\tif (!Number.isInteger(challengeSeconds) || challengeSeconds <= 0) {\n\t\tthrow new TypeError(\n\t\t\t`sessionCookies(): challengeSeconds must be a positive integer; got ${String(challengeSeconds)}.`,\n\t\t);\n\t}\n\tif (!isCookiePath(challengePath)) {\n\t\tthrow new TypeError(\n\t\t\t`sessionCookies(): challengePath must start with \"/\" and hold no \";\" or control character; got ${JSON.stringify(challengePath)}.`,\n\t\t);\n\t}\n\tif (challengeHostPrefix && options.challenge !== undefined) {\n\t\tif (options.challengePath !== '/') {\n\t\t\tthrow new TypeError(\n\t\t\t\t`sessionCookies(): challengeHostPrefix needs challengePath: \"/\" (a __Host- cookie must have Path=/); got ${JSON.stringify(options.challengePath)}.`,\n\t\t\t);\n\t\t}\n\t}\n\t// `__Host-` holds only with `Path=/` and no `Domain`: the session cookie\n\t// sets neither option.\n\tconst session = secure ? `__Host-${options.session}` : options.session;\n\tconst challengeName =\n\t\toptions.challenge === undefined\n\t\t\t? undefined\n\t\t\t: secure\n\t\t\t\t? `${challengeHostPrefix ? '__Host-' : '__Secure-'}${options.challenge}`\n\t\t\t\t: options.challenge;\n\tconst clear = (name: string, path?: string) =>\n\t\tserializeCookie(name, '', {\n\t\t\tmaxAge: 0,\n\t\t\tsecure,\n\t\t\tsameSite,\n\t\t\t...(path && { path }),\n\t\t});\n\n\tconst read = (request: Request): CookieSession | null => {\n\t\tconst value = readCookie(request, session);\n\t\tconst dot = value?.indexOf('.') ?? -1;\n\t\tif (!value || dot < 1) return null;\n\t\tconst digits = value.slice(0, dot);\n\t\tconst expiresAt = Number(digits);\n\t\tconst token = value.slice(dot + 1);\n\t\treturn token && /^\\d+$/.test(digits) && Number.isSafeInteger(expiresAt)\n\t\t\t? { token, expiresAt }\n\t\t\t: null;\n\t};\n\t// The value is `<expiry ms>.<token>`: the expiry only tells a later request\n\t// whether the API moved it, so the cookie is set again then. It is never\n\t// trusted: the API alone decides whether a session is valid.\n\tconst commit = (token: string, expiresAt: string | Date, now?: number) =>\n\t\tserializeCookie(session, `${millisOf(expiresAt)}.${token}`, {\n\t\t\tmaxAge: secondsUntil(expiresAt, now),\n\t\t\tsecure,\n\t\t\tsameSite,\n\t\t});\n\n\tconst base: SessionCookiesBase = {\n\t\tnames: { session },\n\t\tread,\n\t\ttoken: (request) => read(request)?.token ?? null,\n\t\tpresent: (request) => hasCookie(request, session),\n\t\tcommit,\n\t\tdestroy: () => clear(session),\n\t\trefreshed(current, expiresAt) {\n\t\t\t// An expiry that is not a date is garbage, not an end: keep the cookie.\n\t\t\tconst end = expiresAt ? millisOf(expiresAt) : 0;\n\t\t\tif (!expiresAt || end === 0 || end === current.expiresAt) return {};\n\t\t\treturn { 'Set-Cookie': commit(current.token, expiresAt) };\n\t\t},\n\t\tsignInPageHeaders(deadSession) {\n\t\t\tconst headers = new Headers();\n\t\t\tif (challengeName) {\n\t\t\t\theaders.append('Set-Cookie', clear(challengeName, challengePath));\n\t\t\t}\n\t\t\tif (deadSession) headers.append('Set-Cookie', clear(session));\n\t\t\treturn headers;\n\t\t},\n\t};\n\tif (challengeName === undefined) return base;\n\tconst challengeCookies: ChallengeCookies = {\n\t\tnames: { challenge: challengeName },\n\t\tchallengeOf: (request) => readCookie(request, challengeName),\n\t\tcommitChallenge: (value, expiresAt, now) =>\n\t\t\tserializeCookie(challengeName, value, {\n\t\t\t\tmaxAge: Math.min(\n\t\t\t\t\tchallengeSeconds,\n\t\t\t\t\texpiresAt ? secondsUntil(expiresAt, now) : challengeSeconds,\n\t\t\t\t),\n\t\t\t\tpath: challengePath,\n\t\t\t\tsecure,\n\t\t\t\tsameSite,\n\t\t\t}),\n\t\tdestroyChallenge: () => clear(challengeName, challengePath),\n\t};\n\treturn {\n\t\t...base,\n\t\t...challengeCookies,\n\t\tnames: { session, challenge: challengeName },\n\t};\n}\n\n/** The `Set-Cookie` values that clear the challenge: none without a second factor. */\nexport function challengeCleared(cookies: SessionCookies<boolean>): string[] {\n\treturn cookies.destroyChallenge ? [cookies.destroyChallenge()] : [];\n}\n"
|
|
7
7
|
],
|
|
8
8
|
"mappings": ";AAqBA,IAAM,YAAY,EAAE,KAAK,OAAO,QAAQ,UAAU,MAAM,OAAO;AAGxD,SAAS,aAAa,CAC5B,QACA,UACA,QAC+B;AAAA,EAC/B,IAAI,CAAC,OAAO,OAAO,WAAW,QAAQ,GAAG;AAAA,IACxC,MAAM,IAAI,UACT,GAAG,2DAA2D,KAAK,UAAU,QAAQ,IACtF;AAAA,EACD;AAAA,EACA,IAAI,aAAa,UAAU,CAAC,QAAQ;AAAA,IACnC,MAAM,IAAI,UACT,GAAG,0GACJ;AAAA,EACD;AAAA;AAID,IAAM,QAAQ;AAGd,IAAM,OAAO;AAGN,IAAM,eAAe,CAAC,SAA0B,MAAM,KAAK,IAAI;AAE/D,IAAM,eAAe,CAAC,SAA0B,KAAK,KAAK,IAAI;AAO9D,SAAS,gBAAe,CAC9B,MACA,SACE,QAAQ,OAAO,KAAK,QAAQ,WAAW,SAChC;AAAA,EACT,IAAI,CAAC,aAAa,IAAI,GAAG;AAAA,IACxB,MAAM,IAAI,UACT,+BAA+B,KAAK,UAAU,IAAI,6CACnD;AAAA,EACD;AAAA,EACA,IAAI,CAAC,aAAa,IAAI,GAAG;AAAA,IACxB,MAAM,IAAI,UACT,+BAA+B,KAAK,UAAU,IAAI,sFACnD;AAAA,EACD;AAAA,EACA,cAAc,sBAAsB,UAAU,MAAM;AAAA,EACpD,OAAO;AAAA,IACN,GAAG,QAAQ,mBAAmB,KAAK;AAAA,IACnC,WAAW,OAAO,SAAS,MAAM,IAAI,KAAK,IAAI,GAAG,KAAK,MAAM,MAAM,CAAC,IAAI;AAAA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