@softistx/alxia-react-router 0.0.0-stage → 0.83.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/LICENSE +21 -0
- package/README.md +2085 -2
- package/dist/api-keys/api-keys.d.ts +93 -0
- package/dist/api-keys/api-keys.d.ts.map +1 -0
- package/dist/api-keys/index.d.ts +9 -0
- package/dist/api-keys/index.d.ts.map +1 -0
- package/dist/api-keys/index.js +66 -0
- package/dist/api-keys/index.js.map +10 -0
- package/dist/assets.d.ts +14 -0
- package/dist/assets.d.ts.map +1 -0
- package/dist/chunks/index-0786n4qe.js +25 -0
- package/dist/chunks/index-0786n4qe.js.map +10 -0
- package/dist/chunks/index-1nw5yeek.js +169 -0
- package/dist/chunks/index-1nw5yeek.js.map +11 -0
- package/dist/chunks/index-59vhfj6n.js +10 -0
- package/dist/chunks/index-59vhfj6n.js.map +10 -0
- package/dist/chunks/index-5gqcpyyg.js +34 -0
- package/dist/chunks/index-5gqcpyyg.js.map +10 -0
- package/dist/chunks/index-6jf7zpxz.js +119 -0
- package/dist/chunks/index-6jf7zpxz.js.map +11 -0
- package/dist/chunks/index-8as4j8m3.js +340 -0
- package/dist/chunks/index-8as4j8m3.js.map +16 -0
- package/dist/chunks/index-9xv2a8et.js +108 -0
- package/dist/chunks/index-9xv2a8et.js.map +11 -0
- package/dist/chunks/index-ajtvyq35.js +16 -0
- package/dist/chunks/index-ajtvyq35.js.map +10 -0
- package/dist/chunks/index-c55hxgr5.js +124 -0
- package/dist/chunks/index-c55hxgr5.js.map +14 -0
- package/dist/chunks/index-d42p3mdp.js +19 -0
- package/dist/chunks/index-d42p3mdp.js.map +10 -0
- package/dist/chunks/index-gac44rs5.js +42 -0
- package/dist/chunks/index-gac44rs5.js.map +11 -0
- package/dist/chunks/index-j4ktpcke.js +62 -0
- package/dist/chunks/index-j4ktpcke.js.map +10 -0
- package/dist/chunks/index-mscfme4r.js +12 -0
- package/dist/chunks/index-mscfme4r.js.map +10 -0
- package/dist/chunks/index-pghmb2dm.js +30 -0
- package/dist/chunks/index-pghmb2dm.js.map +10 -0
- package/dist/chunks/index-rfr02vg4.js +40 -0
- package/dist/chunks/index-rfr02vg4.js.map +10 -0
- package/dist/chunks/index-sfhshxqz.js +31 -0
- package/dist/chunks/index-sfhshxqz.js.map +10 -0
- package/dist/chunks/index-skwypsjz.js +357 -0
- package/dist/chunks/index-skwypsjz.js.map +12 -0
- package/dist/chunks/index-sxh06ged.js +118 -0
- package/dist/chunks/index-sxh06ged.js.map +11 -0
- package/dist/chunks/index-t2ph23wk.js +96 -0
- package/dist/chunks/index-t2ph23wk.js.map +13 -0
- package/dist/chunks/index-thyabr5n.js +19 -0
- package/dist/chunks/index-thyabr5n.js.map +10 -0
- package/dist/chunks/index-tx36swjx.js +134 -0
- package/dist/chunks/index-tx36swjx.js.map +11 -0
- package/dist/chunks/index-v2z5k640.js +54 -0
- package/dist/chunks/index-v2z5k640.js.map +11 -0
- package/dist/chunks/index-vr82typq.js +23 -0
- package/dist/chunks/index-vr82typq.js.map +11 -0
- package/dist/chunks/index-whj6h5eg.js +9 -0
- package/dist/chunks/index-whj6h5eg.js.map +10 -0
- package/dist/chunks/index-wyypkfdv.js +130 -0
- package/dist/chunks/index-wyypkfdv.js.map +13 -0
- package/dist/chunks/index-xd5aqy3g.js +90 -0
- package/dist/chunks/index-xd5aqy3g.js.map +10 -0
- package/dist/chunks/index-zdbqzcjp.js +97 -0
- package/dist/chunks/index-zdbqzcjp.js.map +12 -0
- package/dist/chunks/index-zyg8amjc.js +23 -0
- package/dist/chunks/index-zyg8amjc.js.map +10 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +215 -0
- package/dist/cli/index.js.map +13 -0
- package/dist/cli/main.d.ts +13 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/reveal.d.ts +18 -0
- package/dist/cli/reveal.d.ts.map +1 -0
- package/dist/cli/template.d.ts +8 -0
- package/dist/cli/template.d.ts.map +1 -0
- package/dist/context.d.ts +104 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/document/index.d.ts +11 -0
- package/dist/document/index.d.ts.map +1 -0
- package/dist/document/index.js +19 -0
- package/dist/document/index.js.map +9 -0
- package/dist/document/inline-script.d.ts +27 -0
- package/dist/document/inline-script.d.ts.map +1 -0
- package/dist/document/language-store.d.ts +8 -0
- package/dist/document/language-store.d.ts.map +1 -0
- package/dist/document/nonce.d.ts +34 -0
- package/dist/document/nonce.d.ts.map +1 -0
- package/dist/document/page-language.d.ts +39 -0
- package/dist/document/page-language.d.ts.map +1 -0
- package/dist/document/text-direction.d.ts +10 -0
- package/dist/document/text-direction.d.ts.map +1 -0
- package/dist/entry/abort.d.ts +21 -0
- package/dist/entry/abort.d.ts.map +1 -0
- package/dist/entry/create-entry.d.ts +41 -0
- package/dist/entry/create-entry.d.ts.map +1 -0
- package/dist/entry/index.d.ts +8 -0
- package/dist/entry/index.d.ts.map +1 -0
- package/dist/entry/index.js +154 -0
- package/dist/entry/index.js.map +13 -0
- package/dist/entry/root-data.d.ts +27 -0
- package/dist/entry/root-data.d.ts.map +1 -0
- package/dist/entry/whole-page.d.ts +10 -0
- package/dist/entry/whole-page.d.ts.map +1 -0
- package/dist/errors/api-error.d.ts +117 -0
- package/dist/errors/api-error.d.ts.map +1 -0
- package/dist/errors/api-errors.d.ts +122 -0
- package/dist/errors/api-errors.d.ts.map +1 -0
- package/dist/errors/call-failure.d.ts +45 -0
- package/dist/errors/call-failure.d.ts.map +1 -0
- package/dist/errors/catalogue-check.d.ts +24 -0
- package/dist/errors/catalogue-check.d.ts.map +1 -0
- package/dist/errors/catalogue-read.d.ts +33 -0
- package/dist/errors/catalogue-read.d.ts.map +1 -0
- package/dist/errors/catalogue.d.ts +59 -0
- package/dist/errors/catalogue.d.ts.map +1 -0
- package/dist/errors/code-resolver.d.ts +44 -0
- package/dist/errors/code-resolver.d.ts.map +1 -0
- package/dist/errors/cross-site.d.ts +8 -0
- package/dist/errors/cross-site.d.ts.map +1 -0
- package/dist/errors/describe-refusal.d.ts +6 -0
- package/dist/errors/describe-refusal.d.ts.map +1 -0
- package/dist/errors/describe.d.ts +3 -0
- package/dist/errors/describe.d.ts.map +1 -0
- package/dist/errors/fetcher-result.d.ts +33 -0
- package/dist/errors/fetcher-result.d.ts.map +1 -0
- package/dist/errors/field-placement.d.ts +12 -0
- package/dist/errors/field-placement.d.ts.map +1 -0
- package/dist/errors/form-errors.d.ts +8 -0
- package/dist/errors/form-errors.d.ts.map +1 -0
- package/dist/errors/form-refusal.d.ts +25 -0
- package/dist/errors/form-refusal.d.ts.map +1 -0
- package/dist/errors/index.d.ts +21 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +588 -0
- package/dist/errors/index.js.map +26 -0
- package/dist/errors/json-actions.d.ts +38 -0
- package/dist/errors/json-actions.d.ts.map +1 -0
- package/dist/errors/log.d.ts +8 -0
- package/dist/errors/log.d.ts.map +1 -0
- package/dist/errors/message-values.d.ts +11 -0
- package/dist/errors/message-values.d.ts.map +1 -0
- package/dist/errors/messages.d.ts +63 -0
- package/dist/errors/messages.d.ts.map +1 -0
- package/dist/errors/page-path.d.ts +9 -0
- package/dist/errors/page-path.d.ts.map +1 -0
- package/dist/errors/problem-error.d.ts +50 -0
- package/dist/errors/problem-error.d.ts.map +1 -0
- package/dist/errors/provider.d.ts +20 -0
- package/dist/errors/provider.d.ts.map +1 -0
- package/dist/errors/request-id.d.ts +5 -0
- package/dist/errors/request-id.d.ts.map +1 -0
- package/dist/errors/route-error.d.ts +33 -0
- package/dist/errors/route-error.d.ts.map +1 -0
- package/dist/errors/route-refusal.d.ts +20 -0
- package/dist/errors/route-refusal.d.ts.map +1 -0
- package/dist/errors/same-site.d.ts +49 -0
- package/dist/errors/same-site.d.ts.map +1 -0
- package/dist/errors/section-action.d.ts +46 -0
- package/dist/errors/section-action.d.ts.map +1 -0
- package/dist/errors/standard-schema.d.ts +34 -0
- package/dist/errors/standard-schema.d.ts.map +1 -0
- package/dist/errors/submit-form.d.ts +16 -0
- package/dist/errors/submit-form.d.ts.map +1 -0
- package/dist/errors/upstream-headers.d.ts +18 -0
- package/dist/errors/upstream-headers.d.ts.map +1 -0
- package/dist/errors/use-json-fetcher.d.ts +18 -0
- package/dist/errors/use-json-fetcher.d.ts.map +1 -0
- package/dist/fetcher/auth-refusal.d.ts +29 -0
- package/dist/fetcher/auth-refusal.d.ts.map +1 -0
- package/dist/fetcher/index.d.ts +20 -0
- package/dist/fetcher/index.d.ts.map +1 -0
- package/dist/fetcher/index.js +392 -0
- package/dist/fetcher/index.js.map +21 -0
- package/dist/fetcher/section-form.d.ts +24 -0
- package/dist/fetcher/section-form.d.ts.map +1 -0
- package/dist/fetcher/section-reload.d.ts +17 -0
- package/dist/fetcher/section-reload.d.ts.map +1 -0
- package/dist/fetcher/section-save.d.ts +29 -0
- package/dist/fetcher/section-save.d.ts.map +1 -0
- package/dist/fetcher/use-debounced-fetcher.d.ts +57 -0
- package/dist/fetcher/use-debounced-fetcher.d.ts.map +1 -0
- package/dist/fetcher/use-fetcher-answer.d.ts +16 -0
- package/dist/fetcher/use-fetcher-answer.d.ts.map +1 -0
- package/dist/fetcher/use-fetcher-done.d.ts +15 -0
- package/dist/fetcher/use-fetcher-done.d.ts.map +1 -0
- package/dist/fetcher/use-fetcher-promise.d.ts +48 -0
- package/dist/fetcher/use-fetcher-promise.d.ts.map +1 -0
- package/dist/fetcher/use-form-refusal.d.ts +20 -0
- package/dist/fetcher/use-form-refusal.d.ts.map +1 -0
- package/dist/fetcher/use-revalidate-on-focus.d.ts +20 -0
- package/dist/fetcher/use-revalidate-on-focus.d.ts.map +1 -0
- package/dist/fetcher/use-row-save.d.ts +32 -0
- package/dist/fetcher/use-row-save.d.ts.map +1 -0
- package/dist/fetcher/use-section-save.d.ts +46 -0
- package/dist/fetcher/use-section-save.d.ts.map +1 -0
- package/dist/fetcher/use-visible-interval.d.ts +24 -0
- package/dist/fetcher/use-visible-interval.d.ts.map +1 -0
- package/dist/fetcher/use-visible-revalidation.d.ts +10 -0
- package/dist/fetcher/use-visible-revalidation.d.ts.map +1 -0
- package/dist/health.d.ts +21 -0
- package/dist/health.d.ts.map +1 -0
- package/dist/help/check/check.d.ts +35 -0
- package/dist/help/check/check.d.ts.map +1 -0
- package/dist/help/check/index.d.ts +8 -0
- package/dist/help/check/index.d.ts.map +1 -0
- package/dist/help/check/index.js +17 -0
- package/dist/help/check/index.js.map +9 -0
- package/dist/help/check/routes.d.ts +22 -0
- package/dist/help/check/routes.d.ts.map +1 -0
- package/dist/help/guide.d.ts +33 -0
- package/dist/help/guide.d.ts.map +1 -0
- package/dist/help/index.d.ts +16 -0
- package/dist/help/index.d.ts.map +1 -0
- package/dist/help/index.js +192 -0
- package/dist/help/index.js.map +14 -0
- package/dist/help/load.d.ts +39 -0
- package/dist/help/load.d.ts.map +1 -0
- package/dist/help/panel.d.ts +69 -0
- package/dist/help/panel.d.ts.map +1 -0
- package/dist/help/parse-flow.d.ts +27 -0
- package/dist/help/parse-flow.d.ts.map +1 -0
- package/dist/help/react.d.ts +12 -0
- package/dist/help/react.d.ts.map +1 -0
- package/dist/help/resolve.d.ts +24 -0
- package/dist/help/resolve.d.ts.map +1 -0
- package/dist/help/types.d.ts +50 -0
- package/dist/help/types.d.ts.map +1 -0
- package/dist/help/yaml.d.ts +18 -0
- package/dist/help/yaml.d.ts.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +197 -0
- package/dist/index.js.map +14 -0
- package/dist/link/index.d.ts +7 -0
- package/dist/link/index.d.ts.map +1 -0
- package/dist/link/index.js +16 -0
- package/dist/link/index.js.map +10 -0
- package/dist/link/router-link.d.ts +27 -0
- package/dist/link/router-link.d.ts.map +1 -0
- package/dist/lists/connection-page.d.ts +50 -0
- package/dist/lists/connection-page.d.ts.map +1 -0
- package/dist/lists/index.d.ts +13 -0
- package/dist/lists/index.d.ts.map +1 -0
- package/dist/lists/index.js +205 -0
- package/dist/lists/index.js.map +15 -0
- package/dist/lists/newest-first.d.ts +5 -0
- package/dist/lists/newest-first.d.ts.map +1 -0
- package/dist/lists/nodes-of.d.ts +21 -0
- package/dist/lists/nodes-of.d.ts.map +1 -0
- package/dist/lists/or-failed.d.ts +19 -0
- package/dist/lists/or-failed.d.ts.map +1 -0
- package/dist/lists/use-paged-rows.d.ts +40 -0
- package/dist/lists/use-paged-rows.d.ts.map +1 -0
- package/dist/lists/use-same-route-loading.d.ts +8 -0
- package/dist/lists/use-same-route-loading.d.ts.map +1 -0
- package/dist/lists/use-search-change.d.ts +20 -0
- package/dist/lists/use-search-change.d.ts.map +1 -0
- package/dist/mcp/index.d.ts +8 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +105 -0
- package/dist/mcp/index.js.map +11 -0
- package/dist/mcp/mcp-relay.d.ts +58 -0
- package/dist/mcp/mcp-relay.d.ts.map +1 -0
- package/dist/mcp/relay.d.ts +38 -0
- package/dist/mcp/relay.d.ts.map +1 -0
- package/dist/media/client/error.d.ts +29 -0
- package/dist/media/client/error.d.ts.map +1 -0
- package/dist/media/client/index.d.ts +8 -0
- package/dist/media/client/index.d.ts.map +1 -0
- package/dist/media/client/index.js +133 -0
- package/dist/media/client/index.js.map +11 -0
- package/dist/media/client/upload.d.ts +32 -0
- package/dist/media/client/upload.d.ts.map +1 -0
- package/dist/media/forward.d.ts +14 -0
- package/dist/media/forward.d.ts.map +1 -0
- package/dist/media/headers.d.ts +11 -0
- package/dist/media/headers.d.ts.map +1 -0
- package/dist/media/index.d.ts +9 -0
- package/dist/media/index.d.ts.map +1 -0
- package/dist/media/index.js +396 -0
- package/dist/media/index.js.map +16 -0
- package/dist/media/options.d.ts +114 -0
- package/dist/media/options.d.ts.map +1 -0
- package/dist/media/path.d.ts +12 -0
- package/dist/media/path.d.ts.map +1 -0
- package/dist/media/read.d.ts +11 -0
- package/dist/media/read.d.ts.map +1 -0
- package/dist/media/refusal.d.ts +11 -0
- package/dist/media/refusal.d.ts.map +1 -0
- package/dist/media/respond.d.ts +8 -0
- package/dist/media/respond.d.ts.map +1 -0
- package/dist/media/write.d.ts +13 -0
- package/dist/media/write.d.ts.map +1 -0
- package/dist/navigation/index.d.ts +9 -0
- package/dist/navigation/index.d.ts.map +1 -0
- package/dist/navigation/index.js +48 -0
- package/dist/navigation/index.js.map +11 -0
- package/dist/navigation/use-focus-on-navigate.d.ts +16 -0
- package/dist/navigation/use-focus-on-navigate.d.ts.map +1 -0
- package/dist/navigation/use-route-transition.d.ts +19 -0
- package/dist/navigation/use-route-transition.d.ts.map +1 -0
- package/dist/nonce.d.ts +16 -0
- package/dist/nonce.d.ts.map +1 -0
- package/dist/oauth/answer.d.ts +33 -0
- package/dist/oauth/answer.d.ts.map +1 -0
- package/dist/oauth/binding.d.ts +43 -0
- package/dist/oauth/binding.d.ts.map +1 -0
- package/dist/oauth/consent.d.ts +134 -0
- package/dist/oauth/consent.d.ts.map +1 -0
- package/dist/oauth/grants.d.ts +88 -0
- package/dist/oauth/grants.d.ts.map +1 -0
- package/dist/oauth/index.d.ts +16 -0
- package/dist/oauth/index.d.ts.map +1 -0
- package/dist/oauth/index.js +207 -0
- package/dist/oauth/index.js.map +12 -0
- package/dist/oauth/model.d.ts +13 -0
- package/dist/oauth/model.d.ts.map +1 -0
- package/dist/oauth/react/index.d.ts +7 -0
- package/dist/oauth/react/index.d.ts.map +1 -0
- package/dist/oauth/react/index.js +99 -0
- package/dist/oauth/react/index.js.map +10 -0
- package/dist/oauth/react/use-consent.d.ts +52 -0
- package/dist/oauth/react/use-consent.d.ts.map +1 -0
- package/dist/oidc/dpop.d.ts +80 -0
- package/dist/oidc/dpop.d.ts.map +1 -0
- package/dist/oidc/errors.d.ts +16 -0
- package/dist/oidc/errors.d.ts.map +1 -0
- package/dist/oidc/flow.d.ts +59 -0
- package/dist/oidc/flow.d.ts.map +1 -0
- package/dist/oidc/index.d.ts +11 -0
- package/dist/oidc/index.d.ts.map +1 -0
- package/dist/oidc/index.js +742 -0
- package/dist/oidc/index.js.map +15 -0
- package/dist/oidc/oidc.d.ts +132 -0
- package/dist/oidc/oidc.d.ts.map +1 -0
- package/dist/oidc/revoke.d.ts +28 -0
- package/dist/oidc/revoke.d.ts.map +1 -0
- package/dist/oidc/seal.d.ts +20 -0
- package/dist/oidc/seal.d.ts.map +1 -0
- package/dist/pwa/build/build-worker.d.ts +41 -0
- package/dist/pwa/build/build-worker.d.ts.map +1 -0
- package/dist/pwa/build/index.d.ts +9 -0
- package/dist/pwa/build/index.d.ts.map +1 -0
- package/dist/pwa/build/index.js +9 -0
- package/dist/pwa/build/index.js.map +9 -0
- package/dist/pwa/build/precache.d.ts +17 -0
- package/dist/pwa/build/precache.d.ts.map +1 -0
- package/dist/pwa/index.d.ts +16 -0
- package/dist/pwa/index.d.ts.map +1 -0
- package/dist/pwa/index.js +110 -0
- package/dist/pwa/index.js.map +12 -0
- package/dist/pwa/model/caching.d.ts +46 -0
- package/dist/pwa/model/caching.d.ts.map +1 -0
- package/dist/pwa/model/clear-app-caches.d.ts +9 -0
- package/dist/pwa/model/clear-app-caches.d.ts.map +1 -0
- package/dist/pwa/model/font-precache.d.ts +15 -0
- package/dist/pwa/model/font-precache.d.ts.map +1 -0
- package/dist/pwa/model/manifest.d.ts +80 -0
- package/dist/pwa/model/manifest.d.ts.map +1 -0
- package/dist/pwa/model/precache-list.d.ts +40 -0
- package/dist/pwa/model/precache-list.d.ts.map +1 -0
- package/dist/pwa/model/registration.d.ts +39 -0
- package/dist/pwa/model/registration.d.ts.map +1 -0
- package/dist/pwa/model/start-service-worker.d.ts +24 -0
- package/dist/pwa/model/start-service-worker.d.ts.map +1 -0
- package/dist/pwa/model/storable.d.ts +8 -0
- package/dist/pwa/model/storable.d.ts.map +1 -0
- package/dist/pwa/model/theme-color.d.ts +20 -0
- package/dist/pwa/model/theme-color.d.ts.map +1 -0
- package/dist/pwa/model/update-notice.d.ts +38 -0
- package/dist/pwa/model/update-notice.d.ts.map +1 -0
- package/dist/pwa/model/worker-contract.d.ts +61 -0
- package/dist/pwa/model/worker-contract.d.ts.map +1 -0
- package/dist/pwa/react/index.d.ts +9 -0
- package/dist/pwa/react/index.d.ts.map +1 -0
- package/dist/pwa/react/index.js +75 -0
- package/dist/pwa/react/index.js.map +13 -0
- package/dist/pwa/react/use-online.d.ts +6 -0
- package/dist/pwa/react/use-online.d.ts.map +1 -0
- package/dist/pwa/react/use-service-worker.d.ts +33 -0
- package/dist/pwa/react/use-service-worker.d.ts.map +1 -0
- package/dist/pwa/react/use-update-notice.d.ts +14 -0
- package/dist/pwa/react/use-update-notice.d.ts.map +1 -0
- package/dist/pwa/server/index.d.ts +7 -0
- package/dist/pwa/server/index.d.ts.map +1 -0
- package/dist/pwa/server/index.js +18 -0
- package/dist/pwa/server/index.js.map +10 -0
- package/dist/pwa/server/no-cache.d.ts +22 -0
- package/dist/pwa/server/no-cache.d.ts.map +1 -0
- package/dist/pwa/worker/index.d.ts +9 -0
- package/dist/pwa/worker/index.d.ts.map +1 -0
- package/dist/pwa/worker/index.js +144 -0
- package/dist/pwa/worker/index.js.map +12 -0
- package/dist/pwa/worker/injected.d.ts +15 -0
- package/dist/pwa/worker/injected.d.ts.map +1 -0
- package/dist/pwa/worker/plan.d.ts +65 -0
- package/dist/pwa/worker/plan.d.ts.map +1 -0
- package/dist/pwa/worker/scope.d.ts +18 -0
- package/dist/pwa/worker/scope.d.ts.map +1 -0
- package/dist/pwa/worker/start-worker.d.ts +17 -0
- package/dist/pwa/worker/start-worker.d.ts.map +1 -0
- package/dist/react-router.d.ts +68 -0
- package/dist/react-router.d.ts.map +1 -0
- package/dist/server.d.ts +127 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/session/codes.d.ts +9 -0
- package/dist/session/codes.d.ts.map +1 -0
- package/dist/session/cookies.d.ts +128 -0
- package/dist/session/cookies.d.ts.map +1 -0
- package/dist/session/flow-types.d.ts +235 -0
- package/dist/session/flow-types.d.ts.map +1 -0
- package/dist/session/guard.d.ts +10 -0
- package/dist/session/guard.d.ts.map +1 -0
- package/dist/session/index.d.ts +22 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +1090 -0
- package/dist/session/index.js.map +27 -0
- package/dist/session/land.d.ts +28 -0
- package/dist/session/land.d.ts.map +1 -0
- package/dist/session/link-json.d.ts +22 -0
- package/dist/session/link-json.d.ts.map +1 -0
- package/dist/session/link-land.d.ts +20 -0
- package/dist/session/link-land.d.ts.map +1 -0
- package/dist/session/link-token.d.ts +24 -0
- package/dist/session/link-token.d.ts.map +1 -0
- package/dist/session/link-types.d.ts +142 -0
- package/dist/session/link-types.d.ts.map +1 -0
- package/dist/session/links.d.ts +14 -0
- package/dist/session/links.d.ts.map +1 -0
- package/dist/session/model/index.d.ts +8 -0
- package/dist/session/model/index.d.ts.map +1 -0
- package/dist/session/model/index.js +35 -0
- package/dist/session/model/index.js.map +9 -0
- package/dist/session/model/link-post.d.ts +35 -0
- package/dist/session/model/link-post.d.ts.map +1 -0
- package/dist/session/model/paths.d.ts +24 -0
- package/dist/session/model/paths.d.ts.map +1 -0
- package/dist/session/model/safe-next.d.ts +15 -0
- package/dist/session/model/safe-next.d.ts.map +1 -0
- package/dist/session/model/second-factor.d.ts +16 -0
- package/dist/session/model/second-factor.d.ts.map +1 -0
- package/dist/session/model/site-path.d.ts +10 -0
- package/dist/session/model/site-path.d.ts.map +1 -0
- package/dist/session/model/step-up-answers.d.ts +45 -0
- package/dist/session/model/step-up-answers.d.ts.map +1 -0
- package/dist/session/model/step-up-props.d.ts +22 -0
- package/dist/session/model/step-up-props.d.ts.map +1 -0
- package/dist/session/model/step-up.d.ts +48 -0
- package/dist/session/model/step-up.d.ts.map +1 -0
- package/dist/session/react/index.d.ts +13 -0
- package/dist/session/react/index.d.ts.map +1 -0
- package/dist/session/react/index.js +196 -0
- package/dist/session/react/index.js.map +14 -0
- package/dist/session/react/step-up/answers.d.ts +9 -0
- package/dist/session/react/step-up/answers.d.ts.map +1 -0
- package/dist/session/react/step-up/dialog-props.d.ts +27 -0
- package/dist/session/react/step-up/dialog-props.d.ts.map +1 -0
- package/dist/session/react/step-up/index.d.ts +7 -0
- package/dist/session/react/step-up/index.d.ts.map +1 -0
- package/dist/session/react/step-up/pending-runs.d.ts +21 -0
- package/dist/session/react/step-up/pending-runs.d.ts.map +1 -0
- package/dist/session/react/step-up/phase.d.ts +8 -0
- package/dist/session/react/step-up/phase.d.ts.map +1 -0
- package/dist/session/react/step-up/use-step-up-replay.d.ts +59 -0
- package/dist/session/react/step-up/use-step-up-replay.d.ts.map +1 -0
- package/dist/session/react/step-up/use-step-up-runner.d.ts +70 -0
- package/dist/session/react/step-up/use-step-up-runner.d.ts.map +1 -0
- package/dist/session/react/step-up/use-step-up.d.ts +51 -0
- package/dist/session/react/step-up/use-step-up.d.ts.map +1 -0
- package/dist/session/react/use-code-field.d.ts +37 -0
- package/dist/session/react/use-code-field.d.ts.map +1 -0
- package/dist/session/react/use-link-fragment.d.ts +22 -0
- package/dist/session/react/use-link-fragment.d.ts.map +1 -0
- package/dist/session/react/use-link-param.d.ts +26 -0
- package/dist/session/react/use-link-param.d.ts.map +1 -0
- package/dist/session/react/use-link-post.d.ts +39 -0
- package/dist/session/react/use-link-post.d.ts.map +1 -0
- package/dist/session/react/use-sign-out.d.ts +46 -0
- package/dist/session/react/use-sign-out.d.ts.map +1 -0
- package/dist/session/second-factor.d.ts +22 -0
- package/dist/session/second-factor.d.ts.map +1 -0
- package/dist/session/serialize.d.ts +42 -0
- package/dist/session/serialize.d.ts.map +1 -0
- package/dist/session/sign-in.d.ts +19 -0
- package/dist/session/sign-in.d.ts.map +1 -0
- package/dist/session/signed.d.ts +44 -0
- package/dist/session/signed.d.ts.map +1 -0
- package/dist/session/social-flow.d.ts +22 -0
- package/dist/session/social-flow.d.ts.map +1 -0
- package/dist/session/social-land.d.ts +31 -0
- package/dist/session/social-land.d.ts.map +1 -0
- package/dist/session/social-types.d.ts +136 -0
- package/dist/session/social-types.d.ts.map +1 -0
- package/dist/session/social.d.ts +32 -0
- package/dist/session/social.d.ts.map +1 -0
- package/dist/session/step-up-codes.d.ts +9 -0
- package/dist/session/step-up-codes.d.ts.map +1 -0
- package/dist/session/step-up-signed-out.d.ts +21 -0
- package/dist/session/step-up-signed-out.d.ts.map +1 -0
- package/dist/session/step-up-types.d.ts +127 -0
- package/dist/session/step-up-types.d.ts.map +1 -0
- package/dist/session/step-up.d.ts +17 -0
- package/dist/session/step-up.d.ts.map +1 -0
- package/dist/session/step.d.ts +22 -0
- package/dist/session/step.d.ts.map +1 -0
- package/dist/session/throttle.d.ts +73 -0
- package/dist/session/throttle.d.ts.map +1 -0
- package/dist/session/timed-wait.d.ts +4 -0
- package/dist/session/timed-wait.d.ts.map +1 -0
- package/dist/session/viewer.d.ts +34 -0
- package/dist/session/viewer.d.ts.map +1 -0
- package/dist/subscription/documents.d.ts +3 -0
- package/dist/subscription/documents.d.ts.map +1 -0
- package/dist/subscription/index.d.ts +7 -0
- package/dist/subscription/index.d.ts.map +1 -0
- package/dist/subscription/index.js +359 -0
- package/dist/subscription/index.js.map +14 -0
- package/dist/subscription/proxy.d.ts +54 -0
- package/dist/subscription/proxy.d.ts.map +1 -0
- package/dist/subscription/react/backoff.d.ts +8 -0
- package/dist/subscription/react/backoff.d.ts.map +1 -0
- package/dist/subscription/react/classify.d.ts +15 -0
- package/dist/subscription/react/classify.d.ts.map +1 -0
- package/dist/subscription/react/controller.d.ts +40 -0
- package/dist/subscription/react/controller.d.ts.map +1 -0
- package/dist/subscription/react/fake-timers.d.ts +8 -0
- package/dist/subscription/react/fake-timers.d.ts.map +1 -0
- package/dist/subscription/react/index.d.ts +15 -0
- package/dist/subscription/react/index.d.ts.map +1 -0
- package/dist/subscription/react/index.js +227 -0
- package/dist/subscription/react/index.js.map +17 -0
- package/dist/subscription/react/reconnect.d.ts +9 -0
- package/dist/subscription/react/reconnect.d.ts.map +1 -0
- package/dist/subscription/react/scheduler.d.ts +13 -0
- package/dist/subscription/react/scheduler.d.ts.map +1 -0
- package/dist/subscription/react/timers.d.ts +7 -0
- package/dist/subscription/react/timers.d.ts.map +1 -0
- package/dist/subscription/react/use-live-subscription.d.ts +36 -0
- package/dist/subscription/react/use-live-subscription.d.ts.map +1 -0
- package/dist/subscription/react/versions.d.ts +6 -0
- package/dist/subscription/react/versions.d.ts.map +1 -0
- package/dist/subscription/read.d.ts +17 -0
- package/dist/subscription/read.d.ts.map +1 -0
- package/dist/subscription/refusal.d.ts +11 -0
- package/dist/subscription/refusal.d.ts.map +1 -0
- package/dist/subscription/relay.d.ts +16 -0
- package/dist/subscription/relay.d.ts.map +1 -0
- package/dist/vite/bun.d.ts +21 -0
- package/dist/vite/bun.d.ts.map +1 -0
- package/dist/vite/bundle.d.ts +33 -0
- package/dist/vite/bundle.d.ts.map +1 -0
- package/dist/vite/compress.d.ts +18 -0
- package/dist/vite/compress.d.ts.map +1 -0
- package/dist/vite/config.d.ts +33 -0
- package/dist/vite/config.d.ts.map +1 -0
- package/dist/vite/dev.d.ts +28 -0
- package/dist/vite/dev.d.ts.map +1 -0
- package/dist/vite/entry.d.ts +20 -0
- package/dist/vite/entry.d.ts.map +1 -0
- package/dist/vite/hosts.d.ts +16 -0
- package/dist/vite/hosts.d.ts.map +1 -0
- package/dist/vite/index.d.ts +68 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +635 -0
- package/dist/vite/index.js.map +22 -0
- package/dist/vite/inline.d.ts +18 -0
- package/dist/vite/inline.d.ts.map +1 -0
- package/dist/vite/node.d.ts +16 -0
- package/dist/vite/node.d.ts.map +1 -0
- package/dist/vite/preview.d.ts +8 -0
- package/dist/vite/preview.d.ts.map +1 -0
- package/dist/vite/runtime.d.ts +8 -0
- package/dist/vite/runtime.d.ts.map +1 -0
- package/dist/vite/socket.d.ts +75 -0
- package/dist/vite/socket.d.ts.map +1 -0
- package/dist/vite/worker.d.ts +16 -0
- package/dist/vite/worker.d.ts.map +1 -0
- package/dist/with-alxia.d.ts +36 -0
- package/dist/with-alxia.d.ts.map +1 -0
- package/docs/README.md +42 -0
- package/docs/guide/api-keys.md +216 -0
- package/docs/guide/beside-the-pages.md +201 -0
- package/docs/guide/csp-nonce.md +166 -0
- package/docs/guide/customising-the-server.md +324 -0
- package/docs/guide/deploying.md +102 -0
- package/docs/guide/document.md +334 -0
- package/docs/guide/errors.md +1147 -0
- package/docs/guide/fetcher.md +355 -0
- package/docs/guide/getting-started.md +112 -0
- package/docs/guide/help.md +325 -0
- package/docs/guide/how-it-works.md +274 -0
- package/docs/guide/link.md +32 -0
- package/docs/guide/lists.md +225 -0
- package/docs/guide/mcp.md +173 -0
- package/docs/guide/media.md +273 -0
- package/docs/guide/navigation.md +52 -0
- package/docs/guide/oauth.md +342 -0
- package/docs/guide/oidc.md +262 -0
- package/docs/guide/openapi.md +51 -0
- package/docs/guide/pwa.md +670 -0
- package/docs/guide/session.md +2105 -0
- package/docs/guide/subscriptions.md +211 -0
- package/docs/guide/testing.md +42 -0
- package/docs/guide/typing-the-loaders.md +311 -0
- package/docs/guide.md +82 -0
- package/docs/roadmap.md +474 -0
- package/docs/troubleshooting.md +3837 -0
- package/package.json +301 -5
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Focus and fade on navigation
|
|
2
|
+
|
|
3
|
+
Two behaviours belong to a layout and every app rewrites them: moving focus to
|
|
4
|
+
the page heading after a client navigation (so a screen reader announces the new
|
|
5
|
+
page and a keyboard user starts at its top), and fading the content only when
|
|
6
|
+
the page changes. `@softistx/alxia-react-router/navigation` holds both. `react` and
|
|
7
|
+
`react-router` are its only imports, and both hooks render on the server.
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
// app/routes/layout.tsx
|
|
11
|
+
import { useFocusOnNavigate, useRouteTransition } from '@softistx/alxia-react-router/navigation';
|
|
12
|
+
import { Outlet } from 'react-router';
|
|
13
|
+
|
|
14
|
+
export default function Layout() {
|
|
15
|
+
const headingRef = useFocusOnNavigate();
|
|
16
|
+
const { pathname, transitioning } = useRouteTransition();
|
|
17
|
+
return (
|
|
18
|
+
<main>
|
|
19
|
+
<h1 ref={headingRef}>Dashboard</h1>
|
|
20
|
+
<div key={pathname} className={transitioning ? 'fade-in' : undefined}>
|
|
21
|
+
<Outlet />
|
|
22
|
+
</div>
|
|
23
|
+
</main>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## `useFocusOnNavigate()`
|
|
29
|
+
|
|
30
|
+
Returns a ref for the element to focus (default type `HTMLHeadingElement`;
|
|
31
|
+
`useFocusOnNavigate<HTMLDivElement>()` for another). Focus moves when the
|
|
32
|
+
navigation type is `PUSH` or `POP` **and** the pathname changed. It does not
|
|
33
|
+
move on the first render (a load or a reload), on a `REPLACE` (the search
|
|
34
|
+
change of a list), or when only the search or the hash changed. The element
|
|
35
|
+
gets `tabIndex={-1}` if it has no `tabindex`, so it takes focus without joining
|
|
36
|
+
the tab order. It works in a layout that stays mounted and in a heading each route renders (the last pathname is kept across instances). A `REPLACE` never focuses, even to another pathname.
|
|
37
|
+
|
|
38
|
+
## `useRouteTransition(duration = 200)`
|
|
39
|
+
|
|
40
|
+
Returns `{ pathname, transitioning }`. `transitioning` is `true` for `duration`
|
|
41
|
+
ms after the pathname changed, and `false` on the first render (a
|
|
42
|
+
server-rendered page paints without a flash) and for a search or hash change.
|
|
43
|
+
Put the animation class on the content while it is `true`:
|
|
44
|
+
|
|
45
|
+
```css
|
|
46
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
47
|
+
.fade-in { animation: fade-in 200ms ease-out; }
|
|
48
|
+
}
|
|
49
|
+
@keyframes fade-in { from { opacity: 0; } }
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Keep `duration` equal to the animation's length.
|
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
# The consent screen of an OAuth server
|
|
2
|
+
|
|
3
|
+
An app that is the OAuth server of other apps (`@softistx/janus-oauth`) asks its
|
|
4
|
+
viewer, on one screen, whether a client may act for them. The API serves the
|
|
5
|
+
three calls (`oauthRequest`, `approveOAuthRequest`, `denyOAuthRequest` of
|
|
6
|
+
`@softistx/janus-oauth/graphql`); the decision logic around them is the same in
|
|
7
|
+
every app, so `@softistx/alxia-react-router` holds it. The screen itself (the card, the
|
|
8
|
+
words, the scopes' labels) stays yours.
|
|
9
|
+
|
|
10
|
+
Two subpaths, so a page never loads the server side:
|
|
11
|
+
|
|
12
|
+
| subpath | holds | imports |
|
|
13
|
+
| --- | --- | --- |
|
|
14
|
+
| `@softistx/alxia-react-router/oauth` | `oauthConsent`, `consentShouldRevalidate`, `oauthGrants`, `requestIdOf`, `followableRedirect`, the [request binding](#bind-the-request-to-the-browser) (`boundConsentRequest`, `consentBindingOf`, `consentRequestOf`, `consentBindingCookie`, `consentCookieName`, `CONSENT_COOKIE`, `CONSENT_COOKIE_PLAIN`, `CONSENT_PATH`, `CONSENT_REQUEST_HEADER`, `CONSENT_COOKIE_MAX_AGE`, the `ConsentBinding` type), `isRouteRefusal`, `routeRefusalStatus`, the `RouteRefusal`, `DataRefusal`, `ConsentAnswer` and `RevokeResult` and `ConsentBound` types | `react-router` (its only package) |
|
|
15
|
+
| `@softistx/alxia-react-router/oauth/react` | `useConsent` | `react`, `react-router` |
|
|
16
|
+
|
|
17
|
+
## The route's server side
|
|
18
|
+
|
|
19
|
+
`oauthConsent` takes your GraphQL calls and returns the route's `loader` and
|
|
20
|
+
`action`. It does not import a GraphQL client: you pass the three operations
|
|
21
|
+
as functions, typed by your own generated documents.
|
|
22
|
+
|
|
23
|
+
```ts
|
|
24
|
+
// app/routes/oauth/consent.tsx
|
|
25
|
+
import { alxiaOf } from '@softistx/alxia-react-router';
|
|
26
|
+
import { consentShouldRevalidate, oauthConsent } from '@softistx/alxia-react-router/oauth';
|
|
27
|
+
import type { Route } from './+types/consent';
|
|
28
|
+
|
|
29
|
+
const consent = oauthConsent({
|
|
30
|
+
json, // your jsonActions()
|
|
31
|
+
errors, // your createApiErrors(...)
|
|
32
|
+
// a guest is redirected to sign in and brought back to this address
|
|
33
|
+
viewer: (request) => requireViewer(request),
|
|
34
|
+
caller: (request) => sessionCaller(request),
|
|
35
|
+
find: async (id, caller) => (await execute(OAuthRequestQuery, { id }, caller)).oauthRequest,
|
|
36
|
+
approve: async ({ id, scopes }, caller) =>
|
|
37
|
+
(await execute(ApproveOAuthRequestMutation, { id, scopes }, caller)).approveOAuthRequest,
|
|
38
|
+
deny: async ({ id }, caller) =>
|
|
39
|
+
(await execute(DenyOAuthRequestMutation, { id }, caller)).denyOAuthRequest,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
export const loader = ({ request }: Route.LoaderArgs) => consent.loader(request);
|
|
43
|
+
export const action = ({ context, request }: Route.ActionArgs) =>
|
|
44
|
+
consent.action(request, alxiaOf(context).language);
|
|
45
|
+
export const shouldRevalidate = consentShouldRevalidate;
|
|
46
|
+
export function headers({ loaderHeaders }: Route.HeadersArgs) {
|
|
47
|
+
return loaderHeaders;
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
The `headers` export is needed: without it React Router copies only `Set-Cookie`
|
|
52
|
+
from the loader, so the document response would lack `Cache-Control: no-store`.
|
|
53
|
+
|
|
54
|
+
What each half does:
|
|
55
|
+
|
|
56
|
+
- **`loader(request)`** runs `viewer` first (a thrown redirect sends a guest to
|
|
57
|
+
sign in and back, request id included), reads the request id from
|
|
58
|
+
`?request_id=` (else `?request=`), asks `find`, and answers
|
|
59
|
+
`{ pending, viewer, choices }` with `Cache-Control: no-store` and the headers `viewer`
|
|
60
|
+
gave (a refreshed cookie). No id, a `null` answer, or an API refusal that
|
|
61
|
+
`notFound` accepts (a 404 by default) answers `pending: null` with a 404
|
|
62
|
+
status: render your expired state. Any other failure is thrown.
|
|
63
|
+
- **`action(request, language)`** takes the JSON `{ intent: 'approve' | 'deny',
|
|
64
|
+
id, scopes?, bound? }` the page posts (`json.requireJsonPost` and `readJson` run
|
|
65
|
+
first: another site is a 403, a bad body a 400), calls `approve` or `deny`,
|
|
66
|
+
and answers a `ConsentAnswer`: `{ ok: true, intent, id, redirectTo }` with the
|
|
67
|
+
callback address (only `http:` and `https:` are followed, any other is
|
|
68
|
+
refused), or `{ ok: false, stepUp, expired, error }`. A session not confirmed
|
|
69
|
+
lately (the API's `STEP_UP_REQUIRED`) is `stepUp: true` with no message; a
|
|
70
|
+
request the API no longer knows is `expired: true`; any other refusal is the
|
|
71
|
+
worded `error` with its HTTP status.
|
|
72
|
+
- The action does not call `viewer`: the session reaches the API through `caller`, and a refreshed cookie is set by the loader's answer only.
|
|
73
|
+
- **`consentShouldRevalidate`** keeps the loader from running after a decision:
|
|
74
|
+
the decision spends the request, so a reload would answer "expired" while the
|
|
75
|
+
browser is on its way to the callback.
|
|
76
|
+
|
|
77
|
+
Options that differ from the defaults: `notFound(error)` (which refusals mean
|
|
78
|
+
"unknown request", a 404 by default), `stepUpRequired` (the API's code,
|
|
79
|
+
`STEP_UP_REQUIRED` by default), `requireBinding`, `bindingHeader` and `origin` ([below](#bind-the-request-to-the-browser)), and `choices` and `requireBound`, below.
|
|
80
|
+
|
|
81
|
+
## Bind the request to the browser
|
|
82
|
+
|
|
83
|
+
`request_id` alone is not a proof that this browser opened the request: any
|
|
84
|
+
signed-in member who learns it could read or approve it. [`mcpRelay`](mcp.md#bind-a-consent-request-to-the-browser)
|
|
85
|
+
sets a cookie naming the request when `/oauth/authorize` redirects to your
|
|
86
|
+
consent page. `oauthConsent` reads it and does two things:
|
|
87
|
+
|
|
88
|
+
1. It hands your `caller` a second argument, the **binding**:
|
|
89
|
+
`{ requestId, headers }`, where `headers` is `{ 'x-alxia-oauth-request': id }`
|
|
90
|
+
(`CONSENT_REQUEST_HEADER`; `bindingHeader` renames it) or `{}` when the
|
|
91
|
+
browser holds no cookie. Put them on your API call, so the server can check
|
|
92
|
+
the request is this browser's (`ownsRequest` of the resolvers in `@softistx/janus-oauth/graphql`).
|
|
93
|
+
2. With `requireBinding: true`, a request id that is not the cookie's reads as
|
|
94
|
+
not found without asking the API: the loader answers `pending: null` with a
|
|
95
|
+
404 (the expired state), the action `{ ok: false, expired: true }`.
|
|
96
|
+
|
|
97
|
+
```ts
|
|
98
|
+
const consent = oauthConsent({
|
|
99
|
+
// …
|
|
100
|
+
requireBinding: true,
|
|
101
|
+
caller: (request, binding) => ({
|
|
102
|
+
token: cookies.token(request),
|
|
103
|
+
headers: binding.headers,
|
|
104
|
+
}),
|
|
105
|
+
});
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Give `oauthConsent` the same `origin` as the relay (`origin: 'https://app.example'`):
|
|
109
|
+
its scheme picks the cookie's name, so the consent route finds the cookie the
|
|
110
|
+
relay wrote even when the request reaches the app as `http://` (a proxy that
|
|
111
|
+
ends TLS and sends no trusted `X-Forwarded-Proto`). Without it the name follows
|
|
112
|
+
the request's own scheme. `oauthConsent` throws a `TypeError` for a value that is not an http(s)
|
|
113
|
+
origin. `boundConsentRequest(request, origin?)` and
|
|
114
|
+
`consentBindingOf(request, header?, origin?)` take it too, unchecked.
|
|
115
|
+
|
|
116
|
+
`requireBinding` is off by default and `binding.headers` is `{}` without a
|
|
117
|
+
cookie: an app that does not bind yet is unchanged (an existing
|
|
118
|
+
`caller(request)` still works; the extra argument is ignored). Turn
|
|
119
|
+
`requireBinding` on once the relay sets the cookie, or the loader answers
|
|
120
|
+
"expired" to every request. Deploy order: the relay first, then
|
|
121
|
+
`requireBinding`; a request opened before that has no cookie and reads as
|
|
122
|
+
expired, the client starts again.
|
|
123
|
+
|
|
124
|
+
## Binding the grant to something the user picks
|
|
125
|
+
|
|
126
|
+
A client's grant often belongs to one of the viewer's workspaces. Give
|
|
127
|
+
`choices` and the loader offers them, beside a pending request; the page posts
|
|
128
|
+
the one chosen as `bound`, and `approve` passes it to your API.
|
|
129
|
+
|
|
130
|
+
```ts
|
|
131
|
+
// app/routes/oauth/consent.tsx
|
|
132
|
+
const consent = oauthConsent({
|
|
133
|
+
json,
|
|
134
|
+
errors,
|
|
135
|
+
viewer: (request) => requireViewer(request),
|
|
136
|
+
caller: (request) => sessionCaller(request),
|
|
137
|
+
find: async (id, caller) => (await execute(OAuthRequestQuery, { id }, caller)).oauthRequest,
|
|
138
|
+
// the workspaces the viewer may bind a grant to, loaded for a pending request only
|
|
139
|
+
choices: async (caller, viewer) =>
|
|
140
|
+
(await execute(WorkspacesQuery, { userId: viewer.id }, caller)).workspaces,
|
|
141
|
+
requireBound: true,
|
|
142
|
+
approve: async ({ id, scopes, bound }, caller) =>
|
|
143
|
+
(await execute(ApproveOAuthRequestMutation, { id, scopes, bound }, caller)).approveOAuthRequest,
|
|
144
|
+
deny: async ({ id }, caller) =>
|
|
145
|
+
(await execute(DenyOAuthRequestMutation, { id }, caller)).denyOAuthRequest,
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
| Option | Type | Default | Effect |
|
|
150
|
+
| --- | --- | --- | --- |
|
|
151
|
+
| `choices` | `(caller, viewer) => Promise<readonly Choice[]>` | none | What the picker offers; the loader answers it as `choices`, `[]` without a pending request or without this option |
|
|
152
|
+
| `requireBound` | `boolean` | `false` | An approval without a `bound` is a 400. A denial never needs one: what it carries is not read |
|
|
153
|
+
|
|
154
|
+
`bound` is `{ type, id }`, two non-empty strings (the `ConsentBound` type); a
|
|
155
|
+
`bound` of another shape is a 400 too. `oauthConsent` does not check that the
|
|
156
|
+
viewer may bind the grant there: your API does, when `approve` calls it.
|
|
157
|
+
|
|
158
|
+
On the page, `approve` takes the choice:
|
|
159
|
+
|
|
160
|
+
```tsx
|
|
161
|
+
import { useState } from 'react';
|
|
162
|
+
import { useConsent } from '@softistx/alxia-react-router/oauth/react';
|
|
163
|
+
import type { Route } from './+types/consent';
|
|
164
|
+
|
|
165
|
+
export default function Consent({ loaderData }: Route.ComponentProps) {
|
|
166
|
+
const { pending: request, choices } = loaderData;
|
|
167
|
+
const [workspace, setWorkspace] = useState(choices[0]?.id ?? '');
|
|
168
|
+
if (!request) return <Expired />;
|
|
169
|
+
const { approve, deny, pending, dialogProps } = useConsent(request.id, {
|
|
170
|
+
request: stepUpRequestChannel,
|
|
171
|
+
confirm: stepUpConfirmChannel,
|
|
172
|
+
});
|
|
173
|
+
return (
|
|
174
|
+
<>
|
|
175
|
+
<select value={workspace} onChange={(event) => setWorkspace(event.target.value)}>
|
|
176
|
+
{choices.map((choice) => (
|
|
177
|
+
<option key={choice.id} value={choice.id}>{choice.name}</option>
|
|
178
|
+
))}
|
|
179
|
+
</select>
|
|
180
|
+
<button
|
|
181
|
+
type="button"
|
|
182
|
+
disabled={Boolean(pending) || workspace === ''}
|
|
183
|
+
onClick={() => approve({ type: 'workspace', id: workspace })}
|
|
184
|
+
>
|
|
185
|
+
Allow
|
|
186
|
+
</button>
|
|
187
|
+
<button type="button" disabled={Boolean(pending)} onClick={deny}>Deny</button>
|
|
188
|
+
<StepUpDialog {...dialogProps} />
|
|
189
|
+
</>
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
Call `approve` from an arrow function, as above. `onClick={approve}` hands it
|
|
195
|
+
the click event, which binds nothing: the hook sends no `bound`, and under
|
|
196
|
+
`requireBound` the action answers 400. The step-up's replay sends the same
|
|
197
|
+
`bound` again.
|
|
198
|
+
|
|
199
|
+
## The page's hook
|
|
200
|
+
|
|
201
|
+
```tsx
|
|
202
|
+
import { useConsent } from '@softistx/alxia-react-router/oauth/react';
|
|
203
|
+
|
|
204
|
+
export default function Consent({ loaderData }: Route.ComponentProps) {
|
|
205
|
+
const { pending: request } = loaderData;
|
|
206
|
+
if (!request) return <Expired />;
|
|
207
|
+
const { approve, deny, pending, expired, error, dialogProps } = useConsent(request.id, {
|
|
208
|
+
request: stepUpRequestChannel, // the step-up channels of useStepUpReplay
|
|
209
|
+
confirm: stepUpConfirmChannel,
|
|
210
|
+
});
|
|
211
|
+
return (
|
|
212
|
+
<>
|
|
213
|
+
<Card request={request} pending={pending} error={error} onAllow={() => approve()} onDeny={deny} />
|
|
214
|
+
<StepUpDialog {...dialogProps} />
|
|
215
|
+
</>
|
|
216
|
+
);
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
`useConsent(requestId, { request, confirm, go?, action? })` posts the decision
|
|
221
|
+
as JSON to the page's action (or `action`), and returns:
|
|
222
|
+
|
|
223
|
+
- `approve(bound?)` and `deny()`: `approve` takes the picker's `{ type, id }`
|
|
224
|
+
([above](#binding-the-grant-to-something-the-user-picks)). Both are ignored while a decision is in flight or the
|
|
225
|
+
browser is leaving.
|
|
226
|
+
- `pending`: the decision in flight (`'approve'` or `'deny'`, `true` while a
|
|
227
|
+
step-up is open before one was chosen), otherwise `false`. After a decision
|
|
228
|
+
lands it stays set until the page is left, since the browser follows the
|
|
229
|
+
callback.
|
|
230
|
+
- `expired`: the API no longer knows the request.
|
|
231
|
+
- `error`: any other refusal's message; cleared by the next decision.
|
|
232
|
+
- `dialogProps`: the step-up dialog's props. `request` and `confirm` are the
|
|
233
|
+
two channels `useStepUpReplay` takes (see the
|
|
234
|
+
[session guide](session.md#the-pages-hooks)); a refused decision opens the
|
|
235
|
+
dialog and is posted again by itself once the session is confirmed. A
|
|
236
|
+
decision carries no one-time code, so nothing is spent. Cancelling the dialog
|
|
237
|
+
frees the card.
|
|
238
|
+
|
|
239
|
+
`go(url)` is a hard navigation by default (`window.location.assign`): the
|
|
240
|
+
callback is another site's, so a client-side navigation would not leave. Pass
|
|
241
|
+
your own to watch it in a test.
|
|
242
|
+
|
|
243
|
+
## Connected apps
|
|
244
|
+
|
|
245
|
+
The other half of an OAuth server is the account's list of apps it allowed.
|
|
246
|
+
`oauthGrants` takes your two GraphQL calls (the list and the revoking
|
|
247
|
+
mutation) and returns `list(ctx)` and `revoke(ctx, id)`. `ctx` is whatever your
|
|
248
|
+
functions need: a caller, or `{ caller, userId }` for an admin's view of another
|
|
249
|
+
account.
|
|
250
|
+
|
|
251
|
+
```ts
|
|
252
|
+
// app/routes/account/security.tsx
|
|
253
|
+
import { data } from 'react-router';
|
|
254
|
+
import { oauthGrants } from '@softistx/alxia-react-router/oauth';
|
|
255
|
+
import type { Route } from './+types/security';
|
|
256
|
+
|
|
257
|
+
const grants = oauthGrants({
|
|
258
|
+
list: async (caller) => (await execute(ConnectedAppsQuery, {}, caller)).connectedApps,
|
|
259
|
+
revoke: (caller, id) => execute(RevokeConnectedAppMutation, { id }, caller),
|
|
260
|
+
// the scopes your app words itself; any other shows the API's label
|
|
261
|
+
scopes: {
|
|
262
|
+
'mcp:read': { key: 'read', access: 'read' },
|
|
263
|
+
'mcp:write': { key: 'write', access: 'write' },
|
|
264
|
+
},
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
export async function loader({ request }: Route.LoaderArgs) {
|
|
268
|
+
const { viewer, headers } = await requireViewer(request);
|
|
269
|
+
const apps = await grants.list(sessionCaller(request));
|
|
270
|
+
return data({ viewer, apps }, { headers: { ...headers, 'Cache-Control': 'no-store' } });
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
// a refreshed cookie set by the loader must reach the browser
|
|
274
|
+
export const headers: Route.HeadersFunction = ({ loaderHeaders }) => loaderHeaders;
|
|
275
|
+
|
|
276
|
+
export async function action({ request }: Route.ActionArgs) {
|
|
277
|
+
const form = await request.formData();
|
|
278
|
+
const result = await grants.revoke(sessionCaller(request), String(form.get('id')));
|
|
279
|
+
// 'revoked' and 'already-revoked' both reload the list;
|
|
280
|
+
// 'step-up' opens the step-up dialog and the page posts again once confirmed
|
|
281
|
+
return data(result, { status: result.status === 'step-up' ? 403 : 200 });
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
- **`list(ctx)`** calls your `list`, sorts the grants **newest first** by
|
|
286
|
+
`createdAt` (the API answers them oldest first; your array is not changed) and
|
|
287
|
+
maps each scope to `{ id, label, key?, access? }`. `id` and `label` are the
|
|
288
|
+
API's; `key` and `access` come from your `scopes` table, the same table the
|
|
289
|
+
consent card reads, so a scope reads the same on both screens. A scope
|
|
290
|
+
missing from the table keeps the API's `label`.
|
|
291
|
+
The type of `key` follows your table: write its keys as literals and a listed
|
|
292
|
+
scope's `key` is `'read' | 'write' | undefined`, so
|
|
293
|
+
`words[scope.key]` on a `Record<'read' | 'write', string>` needs no cast
|
|
294
|
+
(`GrantScopeInfo<K>`, `GrantScope<K>` and `ListedGrant<G, K>` take the key
|
|
295
|
+
type `K extends string`, `string` by default).
|
|
296
|
+
- **`revoke(ctx, id)`** answers `{ status: 'revoked', id }`;
|
|
297
|
+
`{ status: 'already-revoked', id }` when the API no longer knows the grant
|
|
298
|
+
(revoked elsewhere: what the user wanted is done, so it is no failure); or
|
|
299
|
+
`{ status: 'step-up', id }` when the session is not confirmed lately. Any
|
|
300
|
+
other failure is thrown.
|
|
301
|
+
- Options that differ from the defaults: `notFound(error)` (a 404 by default;
|
|
302
|
+
pass `(error) => error.code === '<your API's code>'` when your API words it
|
|
303
|
+
otherwise) and `stepUpRequired` (`STEP_UP_REQUIRED` by default), as for
|
|
304
|
+
`oauthConsent`.
|
|
305
|
+
- `oauthGrants` does not check the viewer or the request: run your sign-in step
|
|
306
|
+
first, as the example does, and your same-site check on the action.
|
|
307
|
+
|
|
308
|
+
## Recognising a refusal
|
|
309
|
+
|
|
310
|
+
The action throws React Router `data(body, { status })` values: a 400 for a bad
|
|
311
|
+
request, and whatever status your `viewer` callback throws (a 401). Test a caught
|
|
312
|
+
value with `isRouteRefusal`, and read the status with `routeRefusalStatus`
|
|
313
|
+
(both also exported from `@softistx/alxia-react-router/errors`):
|
|
314
|
+
|
|
315
|
+
```ts
|
|
316
|
+
import { routeRefusalStatus } from '@softistx/alxia-react-router/oauth';
|
|
317
|
+
|
|
318
|
+
export async function action({ request }: { request: Request }) {
|
|
319
|
+
try {
|
|
320
|
+
return await consent.action(request, 'en');
|
|
321
|
+
} catch (value) {
|
|
322
|
+
if (routeRefusalStatus(value) === 401) return { signedOut: true };
|
|
323
|
+
throw value;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
```
|
|
327
|
+
|
|
328
|
+
## The pure helpers
|
|
329
|
+
|
|
330
|
+
- `requestIdOf(url: URL)`: the request an authorization link names, trimmed;
|
|
331
|
+
`undefined` when empty or absent.
|
|
332
|
+
- `followableRedirect(value)`: the normalised address when it is `http:` or
|
|
333
|
+
`https:` (a loopback callback is `http:`), else `undefined`. Use it for any
|
|
334
|
+
redirect an API hands you.
|
|
335
|
+
|
|
336
|
+
## Testing
|
|
337
|
+
|
|
338
|
+
`oauthConsent` is plain functions over `Request`: call `loader` and `action`
|
|
339
|
+
with a `Request` and fake `find`, `approve` and `deny`. Post a body with
|
|
340
|
+
`content-type: application/json` and an `Origin` of the app. For the hook,
|
|
341
|
+
mount a memory router whose route `action` answers `ConsentAnswer`s, as the
|
|
342
|
+
package's own spec does.
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
# A relying party of an external OpenID Connect issuer
|
|
2
|
+
|
|
3
|
+
A BFF that signs its users in with an issuer it does not own (Keycloak,
|
|
4
|
+
Authentik, Google, Microsoft Entra, an in-house provider) is an OpenID
|
|
5
|
+
Connect *relying party*. The API's own sessions (`/session`) and a social
|
|
6
|
+
sign-in delegated to the API do not cover that: the code flow runs between
|
|
7
|
+
the BFF and the issuer. `@softistx/alxia-react-router/oidc` holds the whole flow, so
|
|
8
|
+
an app writes four small routes and no crypto.
|
|
9
|
+
|
|
10
|
+
| subpath | holds | imports |
|
|
11
|
+
| --- | --- | --- |
|
|
12
|
+
| `@softistx/alxia-react-router/oidc` | `oidcClient`, `OidcError`, `generateDpopKey`, `signDpopProof`, the `OidcOptions`, `OidcClient`, `OidcUser`, `OidcErrorCode`, `DpopKey`, `DpopBinding`, `DpopAlgorithm` and `DpopProofInput` types | `react-router`, `/session`'s cookie helpers, `jose` (optional peer) |
|
|
13
|
+
|
|
14
|
+
Install the peer: `bun add jose`.
|
|
15
|
+
|
|
16
|
+
## What it does
|
|
17
|
+
|
|
18
|
+
- **Authorization code with PKCE (S256).** The verifier, `state` and `nonce`
|
|
19
|
+
are random, sealed (AES-256-GCM, keyed from your session secret) and kept
|
|
20
|
+
ten minutes in a `__Host-<name>_flow` cookie (`HttpOnly`, `Secure`,
|
|
21
|
+
`Path=/`, `SameSite=Lax`, no `Domain`). The verifier never appears in a URL.
|
|
22
|
+
- **Discovery** from `${issuer}/.well-known/openid-configuration`, cached an
|
|
23
|
+
hour; the document's `issuer` must equal yours, else `issuer-mismatch`.
|
|
24
|
+
- **Code exchange** with `client_secret_basic` for a confidential client
|
|
25
|
+
(`clientSecret`), or `client_id` in the body for a public one.
|
|
26
|
+
- **The id token is validated** by `jose` against the issuer's JWKS (cached
|
|
27
|
+
ten minutes, refetched once on an unknown `kid`): signature, `iss`, `aud`
|
|
28
|
+
(and `azp` when there are several audiences), `exp`, `iat`, `sub`, and the
|
|
29
|
+
`nonce` this sign-in sent.
|
|
30
|
+
- **The token cookie** `__Host-<name>` holds the id, access and refresh tokens
|
|
31
|
+
sealed with the same secret: the browser cannot read or edit it.
|
|
32
|
+
- **Refresh** when the access token ends within `refreshSkewSeconds` (60).
|
|
33
|
+
Parallel requests share one refresh (single flight), and for ten seconds
|
|
34
|
+
after it a request still carrying the spent refresh token is answered with
|
|
35
|
+
the rotated result, so a rotating issuer does not sign the user out.
|
|
36
|
+
- **RP-initiated logout** to the issuer's `end_session_endpoint` with
|
|
37
|
+
`id_token_hint` and `post_logout_redirect_uri`.
|
|
38
|
+
|
|
39
|
+
## Set it up
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
// app/oidc.server.ts
|
|
43
|
+
import { oidcClient } from '@softistx/alxia-react-router/oidc';
|
|
44
|
+
|
|
45
|
+
export const oidc = oidcClient({
|
|
46
|
+
issuer: 'https://id.example.com',
|
|
47
|
+
clientId: 'my-app',
|
|
48
|
+
clientSecret: process.env.OIDC_CLIENT_SECRET, // omit for a public client
|
|
49
|
+
redirectUri: 'https://app.example.com/auth/callback',
|
|
50
|
+
scopes: ['profile', 'email', 'offline_access'], // `openid` is always sent
|
|
51
|
+
secret: process.env.SESSION_SECRET!, // 32 characters or more
|
|
52
|
+
name: 'my-app_oidc',
|
|
53
|
+
secure: !import.meta.env.DEV,
|
|
54
|
+
postLogoutRedirectUri: 'https://app.example.com/',
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Register `redirectUri` and `postLogoutRedirectUri` with the issuer. Ask for
|
|
59
|
+
`offline_access` (or whatever your issuer needs) to get a refresh token;
|
|
60
|
+
without one the cookie ends with the access token.
|
|
61
|
+
|
|
62
|
+
## The routes
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
// app/routes/sign-in.ts: starts the flow, keeps ?next=
|
|
66
|
+
import { oidc } from '~/oidc.server';
|
|
67
|
+
export const loader = ({ request }: { request: Request }) => oidc.signIn(request);
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
// app/routes/auth.callback.ts
|
|
72
|
+
import { redirect } from 'react-router';
|
|
73
|
+
import { OidcError } from '@softistx/alxia-react-router/oidc';
|
|
74
|
+
import { oidc } from '~/oidc.server';
|
|
75
|
+
|
|
76
|
+
export async function loader({ request }: { request: Request }) {
|
|
77
|
+
try {
|
|
78
|
+
return await oidc.callback(request); // 302 to `next`, token cookie set
|
|
79
|
+
} catch (error) {
|
|
80
|
+
if (error instanceof OidcError) {
|
|
81
|
+
throw redirect(`/?sign-in-error=${error.code}`, { headers: error.headers });
|
|
82
|
+
}
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
// any protected loader
|
|
90
|
+
import { oidc } from '~/oidc.server';
|
|
91
|
+
|
|
92
|
+
export async function loader({ request }: { request: Request }) {
|
|
93
|
+
const { claims, accessToken, headers } = await oidc.requireOidcUser(request);
|
|
94
|
+
const orders = await listOrders(accessToken);
|
|
95
|
+
return Response.json({ name: claims.name, orders }, { headers });
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
`OidcError.code` is one of `discovery-failed`, `missing-challenge`, `challenge-expired`,
|
|
100
|
+
`provider-error`, `issuer-mismatch`, `state-mismatch`, `missing-code`,
|
|
101
|
+
`token-exchange-failed`, `invalid-id-token`, `nonce-mismatch`, `refresh-failed`, `par-failed`, `revoke-failed` or `token-cookie-too-large`;
|
|
102
|
+
[Troubleshooting](../troubleshooting.md#the-returned-state-is-not-the-one-this-sign-in-sent-and-the-other-oidcerror-messages-oidc)
|
|
103
|
+
explains each.
|
|
104
|
+
|
|
105
|
+
`headers` carries a `Set-Cookie` only when the tokens were just refreshed;
|
|
106
|
+
always pass it with the answer. `oidcUser(request)` is the same without the
|
|
107
|
+
redirect: it answers `null` for a signed-out visitor.
|
|
108
|
+
|
|
109
|
+
```ts
|
|
110
|
+
// app/routes/sign-out.ts: an action (a same-site POST), never a loader, so a link or an image cannot sign the user out
|
|
111
|
+
import { oidc } from '~/oidc.server';
|
|
112
|
+
export const action = ({ request }: { request: Request }) => oidc.logout(request);
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Revoking the tokens at logout
|
|
116
|
+
|
|
117
|
+
By default `logout` clears the cookie and ends the issuer's session, but the
|
|
118
|
+
refresh token stays valid at the issuer: a copy of the cookie keeps refreshing
|
|
119
|
+
until it expires. Set `revokeOnLogout: true` to revoke the tokens too (RFC 7009).
|
|
120
|
+
When discovery has a `revocation_endpoint`, `logout` unseals the session and
|
|
121
|
+
POSTs the refresh token (`token_type_hint=refresh_token`), then the access
|
|
122
|
+
token (`token_type_hint=access_token`). The calls authenticate exactly like
|
|
123
|
+
the token endpoint's (`client_secret_basic`, or `client_id` in the body for a
|
|
124
|
+
public client) and carry a DPoP proof when `dpop` is on.
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
export const oidc = oidcClient({
|
|
128
|
+
// …
|
|
129
|
+
revokeOnLogout: true,
|
|
130
|
+
onRevokeError: (error) => console.warn('oidc revoke', error.code, error.message),
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
A failure never blocks the sign-out: a network error, a non-2xx answer or a
|
|
135
|
+
failed discovery is passed to `onRevokeError` (an `OidcError` with the code
|
|
136
|
+
`revoke-failed`, or `discovery-failed`), then the cookie is cleared and the
|
|
137
|
+
redirect sent. A revocation endpoint that does not answer is aborted after
|
|
138
|
+
`revokeTimeoutMs` (3 seconds by default, both calls together; a positive
|
|
139
|
+
finite number, else `oidcClient` throws) and reported the same way; the access token is then not attempted, so it stays valid at the
|
|
140
|
+
issuer until it expires. Without a `revocation_endpoint`, or without a
|
|
141
|
+
session cookie, nothing is called. A refresh token is revoked only when the session has one
|
|
142
|
+
(`offline_access`).
|
|
143
|
+
|
|
144
|
+
`requireOidcUser` throws a redirect to `signInPath` (`/sign-in` by default)
|
|
145
|
+
with `?next=` set to the current path, through `safeNext`: a path of this site
|
|
146
|
+
only, never an absolute URL.
|
|
147
|
+
|
|
148
|
+
## Options
|
|
149
|
+
|
|
150
|
+
| option | default | |
|
|
151
|
+
| --- | --- | --- |
|
|
152
|
+
| `issuer`, `clientId`, `redirectUri` | required | |
|
|
153
|
+
| `clientSecret` | none | a confidential client; sent as `client_secret_basic` |
|
|
154
|
+
| `scopes` | `profile email` | `openid` is always added |
|
|
155
|
+
| `secret` | required | 32 characters or more; changing it signs everyone out |
|
|
156
|
+
| `name` | required | the cookies' base name; `__Host-` is added when `secure` |
|
|
157
|
+
| `secure` | required | pass `!import.meta.env.DEV` |
|
|
158
|
+
| `signInPath` | `/sign-in` | where `requireOidcUser` redirects |
|
|
159
|
+
| `postLogoutRedirectUri` | none | after `logout`; without it, `/` |
|
|
160
|
+
| `sessionSeconds` | 30 days | the token cookie's life when there is a refresh token |
|
|
161
|
+
| `refreshSkewSeconds` | 60 | refresh this long before the access token ends |
|
|
162
|
+
| `clockToleranceSeconds` | 30 | accepted clock difference on `exp` and `iat` |
|
|
163
|
+
| `algorithms` | `RS256 PS256 ES256 EdDSA` | accepted id token algorithms |
|
|
164
|
+
| `authorizationParams` | none | extra authorization parameters, e.g. `{ prompt: 'login' }` |
|
|
165
|
+
| `tokenParams` | none | extra token request parameters, sent on the code exchange and on every refresh, e.g. `{ resource: 'https://api.example' }` (RFC 8707); the flow's own parameters win; `client_id` and `client_secret` are ignored |
|
|
166
|
+
| `par` | `'auto'` | pushed authorization requests, see below |
|
|
167
|
+
| `dpop` | off | `{ alg?: 'ES256' \| 'EdDSA' }` binds the tokens to a key, see below |
|
|
168
|
+
| `revokeOnLogout` | `false` | revoke the refresh and access tokens at `logout`, see above |
|
|
169
|
+
| `revokeTimeoutMs` | `3000` | the most `logout` waits for both revocations together; past it the call is aborted and reported |
|
|
170
|
+
| `onRevokeError` | none | `(error: OidcError) => void`, called for each revocation failure at `logout` |
|
|
171
|
+
| `fetch`, `now` | global `fetch`, `Date.now` | for tests |
|
|
172
|
+
|
|
173
|
+
## Pushed authorization requests (RFC 9126)
|
|
174
|
+
|
|
175
|
+
Some issuers refuse an authorization request that arrives as query parameters
|
|
176
|
+
(`invalid_request`, "pushed authorization request required"). With `par` the
|
|
177
|
+
relying party POSTs the request to the issuer's
|
|
178
|
+
`pushed_authorization_request_endpoint`, with the same client authentication as
|
|
179
|
+
`/token`, and redirects the browser with `client_id` and `request_uri` alone.
|
|
180
|
+
|
|
181
|
+
| `par` | |
|
|
182
|
+
| --- | --- |
|
|
183
|
+
| `'auto'` (default) | pushes when discovery says `require_pushed_authorization_requests: true`, else sends the query as before |
|
|
184
|
+
| `'always'` | pushes whatever discovery says; throws `par-failed` when the issuer publishes no endpoint |
|
|
185
|
+
| `'never'` | never pushes |
|
|
186
|
+
|
|
187
|
+
```ts
|
|
188
|
+
export const oidc = oidcClient({ /* … */ par: 'always' });
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
An existing app needs no change: only an issuer that requires PAR changes
|
|
192
|
+
behaviour. `signIn` throws `OidcError` with the code `par-failed` when the push
|
|
193
|
+
is refused.
|
|
194
|
+
|
|
195
|
+
## DPoP (RFC 9449)
|
|
196
|
+
|
|
197
|
+
A DPoP-bound access token is useless without the key that asked for it, so a
|
|
198
|
+
stolen cookie or log line is not enough to call the API. Turn it on with
|
|
199
|
+
`dpop`:
|
|
200
|
+
|
|
201
|
+
```ts
|
|
202
|
+
export const oidc = oidcClient({ /* … */ dpop: {} }); // or { alg: 'EdDSA' }
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
- `signIn` makes a key pair per sign-in (`ES256` by default). It travels in the
|
|
206
|
+
sealed challenge cookie, then in the sealed token cookie with the session
|
|
207
|
+
(about 300 bytes more). Because it lives in a cookie it is extractable: a
|
|
208
|
+
non-extractable `CryptoKey` cannot be stored there.
|
|
209
|
+
- `dpop_jkt` (the key's thumbprint) is added to the authorization request, so
|
|
210
|
+
the issuer binds the code to the key.
|
|
211
|
+
- `/token` gets a `DPoP` proof on the code exchange and on every refresh. When
|
|
212
|
+
the issuer answers `400 use_dpop_nonce` with a `DPoP-Nonce` header the proof
|
|
213
|
+
is signed again with that nonce and sent once more; the nonce is remembered
|
|
214
|
+
per server for the next calls. A second refusal is an `OidcError`.
|
|
215
|
+
- The issuer decides whether the tokens are bound: only when it answers
|
|
216
|
+
`token_type: DPoP` does the session keep the key and `user.dpop` is set;
|
|
217
|
+
with `token_type: Bearer` the session is a plain bearer one and `user.dpop`
|
|
218
|
+
is `null`.
|
|
219
|
+
|
|
220
|
+
Call an API with the user's `dpop`:
|
|
221
|
+
|
|
222
|
+
```ts
|
|
223
|
+
const user = await oidc.requireOidcUser(request);
|
|
224
|
+
// the helper sets Authorization: DPoP <token> and a DPoP proof (htm, htu without query, ath),
|
|
225
|
+
// and retries once on 401 WWW-Authenticate: DPoP error="use_dpop_nonce"
|
|
226
|
+
const response = await user.dpop!.fetch('https://api.example.com/orders?page=2');
|
|
227
|
+
// or sign by hand: user.dpop.headers({ method: 'GET', url }) or user.dpop.proof({ method, url, nonce? })
|
|
228
|
+
return data(await response.json(), { headers: user.headers });
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
With `par` and `dpop` both on, the push carries a proof too (and a `use_dpop_nonce` answer there is retried once); a refusal at the push is a `par-failed`.
|
|
232
|
+
|
|
233
|
+
A body given to `dpop.fetch` must be a string or bytes, since a stream cannot
|
|
234
|
+
be sent twice. `generateDpopKey` and `signDpopProof` are exported for code that
|
|
235
|
+
keeps its own key. A DPoP-bound token is sent as `Authorization: DPoP <token>`,
|
|
236
|
+
never `Bearer`.
|
|
237
|
+
|
|
238
|
+
## Testing
|
|
239
|
+
|
|
240
|
+
Pass `fetch` and `now`: a function that answers the discovery document, the
|
|
241
|
+
JWKS and the token endpoint in process, and a clock you move to cross the
|
|
242
|
+
refresh threshold. `jose`'s `generateKeyPair` and `SignJWT` sign the fake
|
|
243
|
+
issuer's id tokens; the package's own spec does exactly that. For PAR and DPoP the
|
|
244
|
+
fake issuer also answers `pushed_authorization_request_endpoint` (a `201` with a
|
|
245
|
+
`request_uri`) and checks the proof with `jose`'s `jwtVerify(proof, EmbeddedJWK)`.
|
|
246
|
+
|
|
247
|
+
## Limits
|
|
248
|
+
|
|
249
|
+
- The three tokens live in one cookie, which browsers cap at about 4 KB. A
|
|
250
|
+
large access token or a long id token (many claims or groups) can pass it: the package then throws an `OidcError` with the code
|
|
251
|
+
`token-cookie-too-large` instead of letting the browser drop the cookie. A
|
|
252
|
+
typical set (a JWT access token, a 300-character refresh token and an id
|
|
253
|
+
token with a dozen groups) is about 3 KB. Ask the issuer for fewer claims or a shorter access token.
|
|
254
|
+
- A refresh that fails (revoked, expired refresh token) with an access token
|
|
255
|
+
already ended signs the user out; with one still valid, the request goes on
|
|
256
|
+
and the next one tries again.
|
|
257
|
+
- The package refuses a discovery document whose endpoints are not `https:` (loopback `http:` is accepted for development).
|
|
258
|
+
- With `dpop`, the key is stored in the cookies, so a leaked cookie leaks the key
|
|
259
|
+
too; DPoP still protects tokens that leak by another path (logs, a proxy).
|
|
260
|
+
- There is no back-channel logout or session check; `logout` ends the local
|
|
261
|
+
session and the issuer's, and revokes the tokens only with `revokeOnLogout`
|
|
262
|
+
(and an issuer that publishes a `revocation_endpoint`).
|