@softistx/alxia-react-router 0.0.0-stage → 0.83.1
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,742 @@
|
|
|
1
|
+
import {
|
|
2
|
+
sessionCookies2
|
|
3
|
+
} from "../chunks/index-1nw5yeek.js";
|
|
4
|
+
import {
|
|
5
|
+
safeNext2
|
|
6
|
+
} from "../chunks/index-0786n4qe.js";
|
|
7
|
+
|
|
8
|
+
// src/oidc/dpop.ts
|
|
9
|
+
import {
|
|
10
|
+
calculateJwkThumbprint,
|
|
11
|
+
exportJWK,
|
|
12
|
+
generateKeyPair,
|
|
13
|
+
importJWK,
|
|
14
|
+
SignJWT
|
|
15
|
+
} from "jose";
|
|
16
|
+
|
|
17
|
+
// src/oidc/seal.ts
|
|
18
|
+
var encoder = new TextEncoder;
|
|
19
|
+
var decoder = new TextDecoder;
|
|
20
|
+
var toBase64Url = (bytes) => {
|
|
21
|
+
let binary = "";
|
|
22
|
+
for (const byte of bytes)
|
|
23
|
+
binary += String.fromCharCode(byte);
|
|
24
|
+
return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
|
|
25
|
+
};
|
|
26
|
+
var fromBase64Url = (text) => {
|
|
27
|
+
const padded = text.replaceAll("-", "+").replaceAll("_", "/");
|
|
28
|
+
const binary = atob(padded + "=".repeat((4 - padded.length % 4) % 4));
|
|
29
|
+
return Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
30
|
+
};
|
|
31
|
+
var randomToken = (bytes = 32) => toBase64Url(crypto.getRandomValues(new Uint8Array(bytes)));
|
|
32
|
+
function sameText(a, b) {
|
|
33
|
+
const left = encoder.encode(a);
|
|
34
|
+
const right = encoder.encode(b);
|
|
35
|
+
let difference = left.length ^ right.length;
|
|
36
|
+
for (let index = 0;index < Math.max(left.length, right.length); index++) {
|
|
37
|
+
difference |= (left[index] ?? 0) ^ (right[index] ?? 0);
|
|
38
|
+
}
|
|
39
|
+
return difference === 0;
|
|
40
|
+
}
|
|
41
|
+
async function s256(verifier) {
|
|
42
|
+
return toBase64Url(new Uint8Array(await crypto.subtle.digest("SHA-256", encoder.encode(verifier))));
|
|
43
|
+
}
|
|
44
|
+
function sealer(secret, purpose) {
|
|
45
|
+
const key = crypto.subtle.digest("SHA-256", encoder.encode(`alxia-oidc/${purpose}/${secret}`)).then((raw) => crypto.subtle.importKey("raw", raw, "AES-GCM", false, [
|
|
46
|
+
"encrypt",
|
|
47
|
+
"decrypt"
|
|
48
|
+
]));
|
|
49
|
+
const additionalData = encoder.encode(purpose);
|
|
50
|
+
return {
|
|
51
|
+
async seal(value) {
|
|
52
|
+
const iv = crypto.getRandomValues(new Uint8Array(12));
|
|
53
|
+
const data = new Uint8Array(await crypto.subtle.encrypt({ name: "AES-GCM", iv, additionalData }, await key, encoder.encode(JSON.stringify(value))));
|
|
54
|
+
const out = new Uint8Array(iv.length + data.length);
|
|
55
|
+
out.set(iv);
|
|
56
|
+
out.set(data, iv.length);
|
|
57
|
+
return toBase64Url(out);
|
|
58
|
+
},
|
|
59
|
+
async open(text) {
|
|
60
|
+
try {
|
|
61
|
+
const bytes = fromBase64Url(text);
|
|
62
|
+
if (bytes.length < 29)
|
|
63
|
+
return null;
|
|
64
|
+
const plain = await crypto.subtle.decrypt({ name: "AES-GCM", iv: bytes.slice(0, 12), additionalData }, await key, bytes.slice(12));
|
|
65
|
+
return JSON.parse(decoder.decode(plain));
|
|
66
|
+
} catch {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// src/oidc/dpop.ts
|
|
74
|
+
var encoder2 = new TextEncoder;
|
|
75
|
+
async function generateDpopKey(alg = "ES256") {
|
|
76
|
+
const { privateKey } = await generateKeyPair(alg, { extractable: true });
|
|
77
|
+
return {
|
|
78
|
+
alg,
|
|
79
|
+
jwk: pick(await exportJWK(privateKey), ["kty", "crv", "x", "y", "d"])
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
var pick = (jwk, names) => Object.fromEntries(names.flatMap((name) => jwk[name] === undefined ? [] : [[name, jwk[name]]]));
|
|
83
|
+
var publicOf = (jwk) => pick(jwk, ["kty", "crv", "x", "y"]);
|
|
84
|
+
var dpopThumbprint = (key) => calculateJwkThumbprint(publicOf(key.jwk), "sha256");
|
|
85
|
+
function dpopTarget(url) {
|
|
86
|
+
const target = new URL(url);
|
|
87
|
+
target.search = "";
|
|
88
|
+
target.hash = "";
|
|
89
|
+
return target.toString();
|
|
90
|
+
}
|
|
91
|
+
async function signDpopProof(key, input) {
|
|
92
|
+
const signer = await importJWK(key.jwk, key.alg);
|
|
93
|
+
const iat = Math.floor((input.now ?? Date.now)() / 1000);
|
|
94
|
+
const ath = input.accessToken === undefined ? undefined : toBase64Url(new Uint8Array(await crypto.subtle.digest("SHA-256", encoder2.encode(input.accessToken))));
|
|
95
|
+
return new SignJWT({
|
|
96
|
+
htm: input.method.toUpperCase(),
|
|
97
|
+
htu: dpopTarget(input.url),
|
|
98
|
+
jti: randomToken(16),
|
|
99
|
+
iat,
|
|
100
|
+
...input.nonce !== undefined && { nonce: input.nonce },
|
|
101
|
+
...ath !== undefined && { ath }
|
|
102
|
+
}).setProtectedHeader({
|
|
103
|
+
typ: "dpop+jwt",
|
|
104
|
+
alg: key.alg,
|
|
105
|
+
jwk: publicOf(key.jwk)
|
|
106
|
+
}).sign(signer);
|
|
107
|
+
}
|
|
108
|
+
function nonceMemory() {
|
|
109
|
+
const nonces = new Map;
|
|
110
|
+
return {
|
|
111
|
+
get: (url) => nonces.get(new URL(url).origin),
|
|
112
|
+
set: (url, nonce) => void nonces.set(new URL(url).origin, nonce)
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
async function wantsNonce(response) {
|
|
116
|
+
if (!response.headers.get("dpop-nonce"))
|
|
117
|
+
return false;
|
|
118
|
+
if (response.status === 401) {
|
|
119
|
+
return /use_dpop_nonce/.test(response.headers.get("www-authenticate") ?? "");
|
|
120
|
+
}
|
|
121
|
+
if (response.status !== 400)
|
|
122
|
+
return false;
|
|
123
|
+
const body = await response.clone().json().catch(() => null);
|
|
124
|
+
return typeof body === "object" && body !== null && body["error"] === "use_dpop_nonce";
|
|
125
|
+
}
|
|
126
|
+
function dpopBinding(config) {
|
|
127
|
+
const { key, accessToken, nonces } = config;
|
|
128
|
+
const proof = ({ method, url, nonce }) => signDpopProof(key, {
|
|
129
|
+
method,
|
|
130
|
+
url,
|
|
131
|
+
accessToken,
|
|
132
|
+
nonce: nonce ?? nonces.get(url),
|
|
133
|
+
now: config.now
|
|
134
|
+
});
|
|
135
|
+
return {
|
|
136
|
+
thumbprint: config.thumbprint,
|
|
137
|
+
proof,
|
|
138
|
+
async headers(input) {
|
|
139
|
+
return {
|
|
140
|
+
authorization: `DPoP ${accessToken}`,
|
|
141
|
+
dpop: await proof(input)
|
|
142
|
+
};
|
|
143
|
+
},
|
|
144
|
+
async fetch(input, init) {
|
|
145
|
+
const url = String(input);
|
|
146
|
+
const method = init?.method ?? "GET";
|
|
147
|
+
const send = async (nonce) => {
|
|
148
|
+
const headers = new Headers(init?.headers);
|
|
149
|
+
headers.set("authorization", `DPoP ${accessToken}`);
|
|
150
|
+
headers.set("dpop", await proof({ method, url, nonce }));
|
|
151
|
+
const response = await config.fetch(url, { ...init, headers });
|
|
152
|
+
const sent = response.headers.get("dpop-nonce");
|
|
153
|
+
if (sent)
|
|
154
|
+
nonces.set(url, sent);
|
|
155
|
+
return response;
|
|
156
|
+
};
|
|
157
|
+
const first = await send();
|
|
158
|
+
if (!await wantsNonce(first))
|
|
159
|
+
return first;
|
|
160
|
+
return send(first.headers.get("dpop-nonce") ?? undefined);
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
// src/oidc/errors.ts
|
|
165
|
+
class OidcError extends Error {
|
|
166
|
+
code;
|
|
167
|
+
headers;
|
|
168
|
+
name = "OidcError";
|
|
169
|
+
constructor(code, message, headers = new Headers, options) {
|
|
170
|
+
super(message, options);
|
|
171
|
+
this.code = code;
|
|
172
|
+
this.headers = headers;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
// src/oidc/oidc.ts
|
|
176
|
+
import { redirect } from "react-router";
|
|
177
|
+
|
|
178
|
+
// src/oidc/flow.ts
|
|
179
|
+
import {
|
|
180
|
+
createLocalJWKSet,
|
|
181
|
+
decodeJwt,
|
|
182
|
+
errors as joseErrors,
|
|
183
|
+
jwtVerify
|
|
184
|
+
} from "jose";
|
|
185
|
+
var DISCOVERY_TTL = 60 * 60 * 1000;
|
|
186
|
+
var JWKS_TTL = 10 * 60 * 1000;
|
|
187
|
+
var isRecord = (value) => typeof value === "object" && value !== null;
|
|
188
|
+
var text = (value) => typeof value === "string" && value !== "";
|
|
189
|
+
function issuerClient(config) {
|
|
190
|
+
const { issuer, now } = config;
|
|
191
|
+
let discovery;
|
|
192
|
+
let keys;
|
|
193
|
+
async function getJson(url, code) {
|
|
194
|
+
let response;
|
|
195
|
+
try {
|
|
196
|
+
response = await config.fetch(url, {
|
|
197
|
+
headers: { accept: "application/json" }
|
|
198
|
+
});
|
|
199
|
+
} catch (cause) {
|
|
200
|
+
throw new OidcError(code, `Could not reach ${url}.`, undefined, {
|
|
201
|
+
cause
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
if (!response.ok) {
|
|
205
|
+
throw new OidcError(code, `${url} answered ${response.status}.`);
|
|
206
|
+
}
|
|
207
|
+
return response.json().catch(() => {
|
|
208
|
+
throw new OidcError(code, `${url} did not answer JSON.`);
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
async function loadDiscovery() {
|
|
212
|
+
const url = `${issuer.replace(/\/$/, "")}/.well-known/openid-configuration`;
|
|
213
|
+
const body = await getJson(url, "discovery-failed");
|
|
214
|
+
if (!isRecord(body) || !text(body["authorization_endpoint"]) || !text(body["token_endpoint"]) || !text(body["jwks_uri"])) {
|
|
215
|
+
throw new OidcError("discovery-failed", `${url} lacks authorization_endpoint, token_endpoint or jwks_uri.`);
|
|
216
|
+
}
|
|
217
|
+
for (const key of [
|
|
218
|
+
"authorization_endpoint",
|
|
219
|
+
"token_endpoint",
|
|
220
|
+
"jwks_uri"
|
|
221
|
+
]) {
|
|
222
|
+
const endpoint = new URL(String(body[key]));
|
|
223
|
+
const loopback = ["localhost", "127.0.0.1", "[::1]"].includes(endpoint.hostname);
|
|
224
|
+
if (endpoint.protocol !== "https:" && !(loopback && endpoint.protocol === "http:")) {
|
|
225
|
+
throw new OidcError("discovery-failed", `${url} gives a ${key} that is not https.`);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (body["issuer"] !== issuer) {
|
|
229
|
+
throw new OidcError("issuer-mismatch", `${url} names the issuer ${JSON.stringify(body["issuer"])}, not ${JSON.stringify(issuer)}.`);
|
|
230
|
+
}
|
|
231
|
+
return body;
|
|
232
|
+
}
|
|
233
|
+
const discover = () => {
|
|
234
|
+
if (!discovery || now() - discovery.at > DISCOVERY_TTL) {
|
|
235
|
+
const value = loadDiscovery();
|
|
236
|
+
const entry = { at: now(), value };
|
|
237
|
+
discovery = entry;
|
|
238
|
+
value.catch(() => {
|
|
239
|
+
if (discovery === entry)
|
|
240
|
+
discovery = undefined;
|
|
241
|
+
});
|
|
242
|
+
}
|
|
243
|
+
return discovery.value;
|
|
244
|
+
};
|
|
245
|
+
async function jwks(force) {
|
|
246
|
+
if (force || !keys || now() - keys.at > JWKS_TTL) {
|
|
247
|
+
const value = discover().then(async (document) => await getJson(document.jwks_uri, "invalid-id-token"));
|
|
248
|
+
const entry = { at: now(), value };
|
|
249
|
+
keys = entry;
|
|
250
|
+
value.catch(() => {
|
|
251
|
+
if (keys === entry)
|
|
252
|
+
keys = undefined;
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
return keys.value;
|
|
256
|
+
}
|
|
257
|
+
async function verifyIdToken(idToken, clientId, nonce) {
|
|
258
|
+
const document = await discover();
|
|
259
|
+
const check = async (force) => jwtVerify(idToken, createLocalJWKSet(await jwks(force)), {
|
|
260
|
+
issuer: document.issuer,
|
|
261
|
+
audience: clientId,
|
|
262
|
+
algorithms: config.algorithms,
|
|
263
|
+
clockTolerance: config.clockToleranceSeconds,
|
|
264
|
+
currentDate: new Date(now()),
|
|
265
|
+
requiredClaims: ["exp", "iat", "sub"]
|
|
266
|
+
});
|
|
267
|
+
let payload;
|
|
268
|
+
try {
|
|
269
|
+
try {
|
|
270
|
+
({ payload } = await check(false));
|
|
271
|
+
} catch (error) {
|
|
272
|
+
if (!(error instanceof joseErrors.JWKSNoMatchingKey))
|
|
273
|
+
throw error;
|
|
274
|
+
({ payload } = await check(true));
|
|
275
|
+
}
|
|
276
|
+
} catch (cause) {
|
|
277
|
+
if (cause instanceof OidcError)
|
|
278
|
+
throw cause;
|
|
279
|
+
throw new OidcError("invalid-id-token", `The id token was refused: ${cause instanceof Error ? cause.message : String(cause)}`, undefined, { cause });
|
|
280
|
+
}
|
|
281
|
+
if (Array.isArray(payload.aud) && payload.aud.length > 1 && payload["azp"] !== clientId) {
|
|
282
|
+
throw new OidcError("invalid-id-token", "The id token has several audiences and its azp is not this client.");
|
|
283
|
+
}
|
|
284
|
+
if (nonce !== undefined && payload["nonce"] !== nonce) {
|
|
285
|
+
throw new OidcError("nonce-mismatch", "The id token nonce is not the one this sign-in sent.");
|
|
286
|
+
}
|
|
287
|
+
return payload;
|
|
288
|
+
}
|
|
289
|
+
return { discover, verifyIdToken };
|
|
290
|
+
}
|
|
291
|
+
async function postForm(fetcher, endpoint, client, params, code, what, dpop, signal) {
|
|
292
|
+
const body = new URLSearchParams(params);
|
|
293
|
+
const headers = {
|
|
294
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
295
|
+
accept: "application/json"
|
|
296
|
+
};
|
|
297
|
+
if (client.secret === undefined) {
|
|
298
|
+
body.set("client_id", client.id);
|
|
299
|
+
} else {
|
|
300
|
+
const pair = `${encodeURIComponent(client.id)}:${encodeURIComponent(client.secret)}`;
|
|
301
|
+
headers["authorization"] = `Basic ${btoa(pair)}`;
|
|
302
|
+
}
|
|
303
|
+
const send = async (nonce) => {
|
|
304
|
+
const sent = dpop ? {
|
|
305
|
+
...headers,
|
|
306
|
+
dpop: await signDpopProof(dpop.key, {
|
|
307
|
+
method: "POST",
|
|
308
|
+
url: endpoint,
|
|
309
|
+
nonce,
|
|
310
|
+
now: dpop.now
|
|
311
|
+
})
|
|
312
|
+
} : headers;
|
|
313
|
+
try {
|
|
314
|
+
const response = await fetcher(endpoint, {
|
|
315
|
+
method: "POST",
|
|
316
|
+
headers: sent,
|
|
317
|
+
body,
|
|
318
|
+
...signal && { signal }
|
|
319
|
+
});
|
|
320
|
+
const given = response.headers.get("dpop-nonce");
|
|
321
|
+
if (dpop && given)
|
|
322
|
+
dpop.nonces.set(endpoint, given);
|
|
323
|
+
return response;
|
|
324
|
+
} catch (cause) {
|
|
325
|
+
throw new OidcError(code, `The ${what} could not be reached.`, undefined, { cause });
|
|
326
|
+
}
|
|
327
|
+
};
|
|
328
|
+
let response = await send(dpop?.nonces.get(endpoint));
|
|
329
|
+
if (dpop && await wantsNonce(response)) {
|
|
330
|
+
await response.body?.cancel().catch(() => {
|
|
331
|
+
return;
|
|
332
|
+
});
|
|
333
|
+
response = await send(response.headers.get("dpop-nonce") ?? undefined);
|
|
334
|
+
}
|
|
335
|
+
const answer = await response.json().catch(() => null);
|
|
336
|
+
return { response, answer };
|
|
337
|
+
}
|
|
338
|
+
var detailOf = (answer) => isRecord(answer) ? [answer["error"], answer["error_description"]].filter(text).join(": ") : "";
|
|
339
|
+
async function tokenRequest(fetcher, endpoint, client, params, code, dpop) {
|
|
340
|
+
const { response, answer } = await postForm(fetcher, endpoint, client, params, code, "token endpoint", dpop);
|
|
341
|
+
if (!response.ok || !isRecord(answer) || !text(answer["access_token"])) {
|
|
342
|
+
const detail = detailOf(answer);
|
|
343
|
+
throw new OidcError(code, `The token endpoint answered ${response.status}${detail ? ` (${detail})` : ""}.`);
|
|
344
|
+
}
|
|
345
|
+
const type = String(answer["token_type"] ?? "bearer").toLowerCase();
|
|
346
|
+
if (type !== "bearer" && !(dpop && type === "dpop")) {
|
|
347
|
+
throw new OidcError(code, "The token endpoint did not issue a bearer token.");
|
|
348
|
+
}
|
|
349
|
+
return answer;
|
|
350
|
+
}
|
|
351
|
+
async function revokeRequest(fetcher, endpoint, client, params, dpop, signal) {
|
|
352
|
+
const { response, answer } = await postForm(fetcher, endpoint, client, params, "revoke-failed", "revocation endpoint", dpop, signal);
|
|
353
|
+
if (!response.ok) {
|
|
354
|
+
const detail = detailOf(answer);
|
|
355
|
+
throw new OidcError("revoke-failed", `The revocation endpoint answered ${response.status}${detail ? ` (${detail})` : ""}.`);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
async function pushRequest(fetcher, endpoint, client, params, dpop) {
|
|
359
|
+
const { response, answer } = await postForm(fetcher, endpoint, client, params, "par-failed", "pushed authorization request endpoint", dpop);
|
|
360
|
+
if (!response.ok || !isRecord(answer) || !text(answer["request_uri"])) {
|
|
361
|
+
const detail = detailOf(answer);
|
|
362
|
+
throw new OidcError("par-failed", `The pushed authorization request endpoint answered ${response.status}${detail ? ` (${detail})` : ""}.`);
|
|
363
|
+
}
|
|
364
|
+
return answer["request_uri"];
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// src/oidc/revoke.ts
|
|
368
|
+
async function revokeTokens(input) {
|
|
369
|
+
const { stored } = input;
|
|
370
|
+
const signal = AbortSignal.timeout(input.timeoutMs);
|
|
371
|
+
const timedOut = new Promise((_, reject) => {
|
|
372
|
+
signal.addEventListener("abort", () => reject(new OidcError("revoke-failed", `The revocation endpoint did not answer within ${input.timeoutMs} ms.`)), { once: true });
|
|
373
|
+
});
|
|
374
|
+
timedOut.catch(() => {
|
|
375
|
+
return;
|
|
376
|
+
});
|
|
377
|
+
const tokens = [
|
|
378
|
+
...stored.refreshToken ? [[stored.refreshToken, "refresh_token"]] : [],
|
|
379
|
+
[stored.accessToken, "access_token"]
|
|
380
|
+
];
|
|
381
|
+
for (const [token, hint] of tokens) {
|
|
382
|
+
try {
|
|
383
|
+
await Promise.race([
|
|
384
|
+
revokeRequest(input.fetcher, input.endpoint, input.client, { token, token_type_hint: hint }, input.signing(stored.dpop), signal),
|
|
385
|
+
timedOut
|
|
386
|
+
]);
|
|
387
|
+
} catch (error) {
|
|
388
|
+
input.report(error instanceof OidcError ? error : new OidcError("revoke-failed", "Revocation failed.", undefined, {
|
|
389
|
+
cause: error
|
|
390
|
+
}));
|
|
391
|
+
if (signal.aborted)
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
// src/oidc/oidc.ts
|
|
398
|
+
var DEFAULT_ALGORITHMS = ["RS256", "PS256", "ES256", "EdDSA"];
|
|
399
|
+
var CHALLENGE_SECONDS = 600;
|
|
400
|
+
var SAME_FLIGHT_MS = 1e4;
|
|
401
|
+
var isFlow = (value) => typeof value === "object" && value !== null && ["state", "nonce", "verifier", "next"].every((key) => typeof value[key] === "string") && typeof value["exp"] === "number" && (value["dpop"] === undefined || isKey(value["dpop"]));
|
|
402
|
+
var isKey = (value) => typeof value === "object" && value !== null && ["ES256", "EdDSA"].includes(value["alg"]) && typeof value["jwk"] === "object";
|
|
403
|
+
var isStored = (value) => typeof value === "object" && value !== null && typeof value["idToken"] === "string" && typeof value["accessToken"] === "string" && typeof value["expiresAt"] === "number" && (value["dpop"] === undefined || isKey(value["dpop"]));
|
|
404
|
+
function oidcClient(options) {
|
|
405
|
+
const {
|
|
406
|
+
issuer,
|
|
407
|
+
clientId,
|
|
408
|
+
clientSecret,
|
|
409
|
+
redirectUri,
|
|
410
|
+
secret,
|
|
411
|
+
signInPath = "/sign-in",
|
|
412
|
+
sessionSeconds = 30 * 24 * 3600,
|
|
413
|
+
refreshSkewSeconds = 60,
|
|
414
|
+
clockToleranceSeconds = 30
|
|
415
|
+
} = options;
|
|
416
|
+
for (const [label, value] of [
|
|
417
|
+
["issuer", issuer],
|
|
418
|
+
["clientId", clientId],
|
|
419
|
+
["redirectUri", redirectUri]
|
|
420
|
+
]) {
|
|
421
|
+
if (!value)
|
|
422
|
+
throw new TypeError(`oidcClient(): ${label} is required.`);
|
|
423
|
+
}
|
|
424
|
+
if (typeof secret !== "string" || secret.length < 32) {
|
|
425
|
+
throw new TypeError("oidcClient(): secret must be a string of at least 32 characters.");
|
|
426
|
+
}
|
|
427
|
+
const {
|
|
428
|
+
client_id: _id,
|
|
429
|
+
client_secret: _secret,
|
|
430
|
+
...extraTokenParams
|
|
431
|
+
} = options.tokenParams ?? {};
|
|
432
|
+
const now = options.now ?? Date.now;
|
|
433
|
+
const scopes = [
|
|
434
|
+
...new Set(["openid", ...options.scopes ?? ["profile", "email"]])
|
|
435
|
+
];
|
|
436
|
+
const cookies = sessionCookies2({
|
|
437
|
+
session: options.name,
|
|
438
|
+
challenge: `${options.name}_flow`,
|
|
439
|
+
challengePath: "/",
|
|
440
|
+
challengeHostPrefix: true,
|
|
441
|
+
challengeSeconds: CHALLENGE_SECONDS,
|
|
442
|
+
secure: options.secure,
|
|
443
|
+
sameSite: "lax"
|
|
444
|
+
});
|
|
445
|
+
const flowSeal = sealer(secret, "flow");
|
|
446
|
+
const tokenSeal = sealer(secret, "tokens");
|
|
447
|
+
const issuerApi = issuerClient({
|
|
448
|
+
issuer,
|
|
449
|
+
fetch: options.fetch ?? ((input, init) => fetch(input, init)),
|
|
450
|
+
now,
|
|
451
|
+
algorithms: [...options.algorithms ?? DEFAULT_ALGORITHMS],
|
|
452
|
+
clockToleranceSeconds
|
|
453
|
+
});
|
|
454
|
+
const fetcher = options.fetch ?? ((input, init) => fetch(input, init));
|
|
455
|
+
const client = { id: clientId, secret: clientSecret };
|
|
456
|
+
const par = options.par ?? "auto";
|
|
457
|
+
if (!["auto", "always", "never"].includes(par)) {
|
|
458
|
+
throw new TypeError("oidcClient(): par must be 'auto', 'always' or 'never'.");
|
|
459
|
+
}
|
|
460
|
+
const dpopAlg = options.dpop ? options.dpop.alg ?? "ES256" : undefined;
|
|
461
|
+
if (dpopAlg !== undefined && !["ES256", "EdDSA"].includes(dpopAlg)) {
|
|
462
|
+
throw new TypeError("oidcClient(): dpop.alg must be 'ES256' or 'EdDSA'.");
|
|
463
|
+
}
|
|
464
|
+
if (options.revokeTimeoutMs !== undefined && !(Number.isFinite(options.revokeTimeoutMs) && options.revokeTimeoutMs > 0)) {
|
|
465
|
+
throw new TypeError("oidcClient(): revokeTimeoutMs must be a positive finite number of milliseconds.");
|
|
466
|
+
}
|
|
467
|
+
const nonces = nonceMemory();
|
|
468
|
+
const signing = (key) => key ? { key, nonces, now } : undefined;
|
|
469
|
+
const flights = new Map;
|
|
470
|
+
const setCookie = (headers, value) => headers.append("Set-Cookie", value);
|
|
471
|
+
async function toStored(response, nonce, previous, key) {
|
|
472
|
+
const dpop = key && (String(response.token_type).toLowerCase() === "dpop" || previous?.dpop !== undefined && response.token_type === undefined) ? key : undefined;
|
|
473
|
+
if (!response.id_token && previous) {
|
|
474
|
+
const kept = decodeJwt(previous.idToken);
|
|
475
|
+
return {
|
|
476
|
+
claims: kept,
|
|
477
|
+
stored: {
|
|
478
|
+
idToken: previous.idToken,
|
|
479
|
+
dpop,
|
|
480
|
+
accessToken: response.access_token,
|
|
481
|
+
refreshToken: response.refresh_token ?? previous.refreshToken,
|
|
482
|
+
expiresAt: typeof response.expires_in === "number" ? now() + response.expires_in * 1000 : now() + 300000
|
|
483
|
+
}
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
const idToken = response.id_token;
|
|
487
|
+
if (!idToken) {
|
|
488
|
+
throw new OidcError("invalid-id-token", "The token endpoint sent no id token.");
|
|
489
|
+
}
|
|
490
|
+
const claims = await issuerApi.verifyIdToken(idToken, clientId, nonce);
|
|
491
|
+
if (previous && decodeJwt(previous.idToken).sub !== claims.sub) {
|
|
492
|
+
throw new OidcError("invalid-id-token", "A refresh changed the user.");
|
|
493
|
+
}
|
|
494
|
+
const expiresAt = typeof response.expires_in === "number" ? now() + response.expires_in * 1000 : (claims["exp"] ?? 0) * 1000;
|
|
495
|
+
return {
|
|
496
|
+
claims,
|
|
497
|
+
stored: {
|
|
498
|
+
idToken,
|
|
499
|
+
dpop,
|
|
500
|
+
accessToken: response.access_token,
|
|
501
|
+
refreshToken: response.refresh_token ?? previous?.refreshToken,
|
|
502
|
+
expiresAt
|
|
503
|
+
}
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
async function commit(headers, stored) {
|
|
507
|
+
const lifetime = stored.refreshToken ? sessionSeconds : Math.max(0, (stored.expiresAt - now()) / 1000);
|
|
508
|
+
const cookie = cookies.commit(await tokenSeal.seal(stored), new Date(now() + lifetime * 1000), now());
|
|
509
|
+
if (cookie.length > 4096) {
|
|
510
|
+
throw new OidcError("token-cookie-too-large", `The token cookie is ${cookie.length} bytes, over the 4096 a browser keeps. Ask the issuer for fewer claims or a shorter access token.`);
|
|
511
|
+
}
|
|
512
|
+
setCookie(headers, cookie);
|
|
513
|
+
}
|
|
514
|
+
const toSignIn = (request, headers) => {
|
|
515
|
+
const url = new URL(request.url);
|
|
516
|
+
const next = safeNext2(`${url.pathname}${url.search}`);
|
|
517
|
+
const target = new URL(signInPath, url);
|
|
518
|
+
target.searchParams.set("next", next);
|
|
519
|
+
throw redirect(`${target.pathname}${target.search}`, { headers });
|
|
520
|
+
};
|
|
521
|
+
function refreshing(stored) {
|
|
522
|
+
const key = stored.refreshToken;
|
|
523
|
+
const flying = flights.get(key);
|
|
524
|
+
if (flying)
|
|
525
|
+
return flying;
|
|
526
|
+
const flight = (async () => {
|
|
527
|
+
const document = await issuerApi.discover();
|
|
528
|
+
const answer = await tokenRequest(fetcher, document.token_endpoint, client, {
|
|
529
|
+
...extraTokenParams,
|
|
530
|
+
grant_type: "refresh_token",
|
|
531
|
+
refresh_token: key,
|
|
532
|
+
scope: scopes.join(" ")
|
|
533
|
+
}, "refresh-failed", signing(stored.dpop));
|
|
534
|
+
return (await toStored(answer, undefined, stored, stored.dpop)).stored;
|
|
535
|
+
})();
|
|
536
|
+
flights.set(key, flight);
|
|
537
|
+
const forget = () => setTimeout(() => flights.delete(key), SAME_FLIGHT_MS);
|
|
538
|
+
flight.then(forget, () => flights.delete(key));
|
|
539
|
+
return flight;
|
|
540
|
+
}
|
|
541
|
+
async function oidcUser(request) {
|
|
542
|
+
const headers = new Headers;
|
|
543
|
+
const sealed = cookies.token(request);
|
|
544
|
+
if (!sealed)
|
|
545
|
+
return null;
|
|
546
|
+
const opened = await tokenSeal.open(sealed);
|
|
547
|
+
if (!isStored(opened)) {
|
|
548
|
+
setCookie(headers, cookies.destroy());
|
|
549
|
+
return null;
|
|
550
|
+
}
|
|
551
|
+
let stored = opened;
|
|
552
|
+
if (stored.expiresAt - refreshSkewSeconds * 1000 <= now()) {
|
|
553
|
+
try {
|
|
554
|
+
if (!stored.refreshToken)
|
|
555
|
+
throw new Error("no refresh token");
|
|
556
|
+
stored = await refreshing(stored);
|
|
557
|
+
await commit(headers, stored);
|
|
558
|
+
} catch {
|
|
559
|
+
if (stored.expiresAt <= now())
|
|
560
|
+
return null;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
return {
|
|
564
|
+
claims: decodeJwt(stored.idToken),
|
|
565
|
+
accessToken: stored.accessToken,
|
|
566
|
+
idToken: stored.idToken,
|
|
567
|
+
expiresAt: stored.expiresAt,
|
|
568
|
+
headers,
|
|
569
|
+
dpop: stored.dpop ? dpopBinding({
|
|
570
|
+
key: stored.dpop,
|
|
571
|
+
thumbprint: await dpopThumbprint(stored.dpop),
|
|
572
|
+
accessToken: stored.accessToken,
|
|
573
|
+
nonces,
|
|
574
|
+
fetch: fetcher,
|
|
575
|
+
now
|
|
576
|
+
}) : null
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
return {
|
|
580
|
+
names: cookies.names,
|
|
581
|
+
oidcUser,
|
|
582
|
+
async requireOidcUser(request) {
|
|
583
|
+
const user = await oidcUser(request);
|
|
584
|
+
if (user)
|
|
585
|
+
return user;
|
|
586
|
+
const headers = new Headers;
|
|
587
|
+
if (cookies.token(request))
|
|
588
|
+
setCookie(headers, cookies.destroy());
|
|
589
|
+
return toSignIn(request, headers);
|
|
590
|
+
},
|
|
591
|
+
async signIn(request) {
|
|
592
|
+
const document = await issuerApi.discover();
|
|
593
|
+
const url = new URL(request.url);
|
|
594
|
+
const flow = {
|
|
595
|
+
state: randomToken(),
|
|
596
|
+
nonce: randomToken(),
|
|
597
|
+
verifier: randomToken(48),
|
|
598
|
+
next: safeNext2(url.searchParams.get("next")),
|
|
599
|
+
exp: now() + CHALLENGE_SECONDS * 1000,
|
|
600
|
+
dpop: dpopAlg ? await generateDpopKey(dpopAlg) : undefined
|
|
601
|
+
};
|
|
602
|
+
const authRequest = {
|
|
603
|
+
...options.authorizationParams,
|
|
604
|
+
response_type: "code",
|
|
605
|
+
client_id: clientId,
|
|
606
|
+
redirect_uri: redirectUri,
|
|
607
|
+
scope: scopes.join(" "),
|
|
608
|
+
state: flow.state,
|
|
609
|
+
nonce: flow.nonce,
|
|
610
|
+
code_challenge: await s256(flow.verifier),
|
|
611
|
+
code_challenge_method: "S256",
|
|
612
|
+
...flow.dpop && { dpop_jkt: await dpopThumbprint(flow.dpop) }
|
|
613
|
+
};
|
|
614
|
+
const endpoint = document.pushed_authorization_request_endpoint;
|
|
615
|
+
const push = par === "always" || par === "auto" && document.require_pushed_authorization_requests === true;
|
|
616
|
+
const target = new URL(document.authorization_endpoint);
|
|
617
|
+
if (push) {
|
|
618
|
+
if (!endpoint) {
|
|
619
|
+
throw new OidcError("par-failed", "Pushed authorization requests are required but the issuer publishes no pushed_authorization_request_endpoint.");
|
|
620
|
+
}
|
|
621
|
+
const requestUri = await pushRequest(fetcher, endpoint, client, authRequest, signing(flow.dpop));
|
|
622
|
+
target.searchParams.set("client_id", clientId);
|
|
623
|
+
target.searchParams.set("request_uri", requestUri);
|
|
624
|
+
} else {
|
|
625
|
+
for (const [key, value] of Object.entries(authRequest)) {
|
|
626
|
+
target.searchParams.set(key, value);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
const headers = new Headers({ "Cache-Control": "no-store" });
|
|
630
|
+
setCookie(headers, cookies.commitChallenge(await flowSeal.seal(flow), null, now()));
|
|
631
|
+
headers.set("Location", target.toString());
|
|
632
|
+
return new Response(null, { status: 302, headers });
|
|
633
|
+
},
|
|
634
|
+
async callback(request) {
|
|
635
|
+
const cleared = () => {
|
|
636
|
+
const headers = new Headers;
|
|
637
|
+
setCookie(headers, cookies.destroyChallenge());
|
|
638
|
+
return headers;
|
|
639
|
+
};
|
|
640
|
+
const fail = (code, message) => new OidcError(code, message, cleared());
|
|
641
|
+
const url = new URL(request.url);
|
|
642
|
+
const sealed = cookies.challengeOf(request);
|
|
643
|
+
const flow = sealed ? await flowSeal.open(sealed) : null;
|
|
644
|
+
if (!isFlow(flow)) {
|
|
645
|
+
throw fail("missing-challenge", "The sign-in challenge cookie is missing or unreadable (a second tab, an expired page or a blocked cookie).");
|
|
646
|
+
}
|
|
647
|
+
if (flow.exp <= now()) {
|
|
648
|
+
throw fail("challenge-expired", "The sign-in took too long; start again.");
|
|
649
|
+
}
|
|
650
|
+
const returned = url.searchParams.get("state");
|
|
651
|
+
if (returned === null || !sameText(returned, flow.state)) {
|
|
652
|
+
throw fail("state-mismatch", "The returned state is not the one this sign-in sent.");
|
|
653
|
+
}
|
|
654
|
+
const failure = url.searchParams.get("error");
|
|
655
|
+
if (failure) {
|
|
656
|
+
const description = url.searchParams.get("error_description");
|
|
657
|
+
throw fail("provider-error", `The issuer refused: ${failure}${description ? ` (${description})` : ""}.`);
|
|
658
|
+
}
|
|
659
|
+
const claimedIssuer = url.searchParams.get("iss");
|
|
660
|
+
if (claimedIssuer !== null && claimedIssuer !== issuer) {
|
|
661
|
+
throw fail("issuer-mismatch", "The callback names another issuer.");
|
|
662
|
+
}
|
|
663
|
+
const code = url.searchParams.get("code");
|
|
664
|
+
if (!code)
|
|
665
|
+
throw fail("missing-code", "The callback carries no code.");
|
|
666
|
+
try {
|
|
667
|
+
const document = await issuerApi.discover();
|
|
668
|
+
const answer = await tokenRequest(fetcher, document.token_endpoint, client, {
|
|
669
|
+
...extraTokenParams,
|
|
670
|
+
grant_type: "authorization_code",
|
|
671
|
+
code,
|
|
672
|
+
redirect_uri: redirectUri,
|
|
673
|
+
code_verifier: flow.verifier
|
|
674
|
+
}, "token-exchange-failed", signing(flow.dpop));
|
|
675
|
+
const { stored } = await toStored(answer, flow.nonce, undefined, flow.dpop);
|
|
676
|
+
const headers = cleared();
|
|
677
|
+
await commit(headers, stored);
|
|
678
|
+
headers.set("Location", safeNext2(flow.next));
|
|
679
|
+
headers.set("Cache-Control", "no-store");
|
|
680
|
+
return new Response(null, { status: 302, headers });
|
|
681
|
+
} catch (error) {
|
|
682
|
+
if (error instanceof OidcError) {
|
|
683
|
+
for (const value of cleared().getSetCookie()) {
|
|
684
|
+
error.headers.append("Set-Cookie", value);
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
throw error;
|
|
688
|
+
}
|
|
689
|
+
},
|
|
690
|
+
async logout(request) {
|
|
691
|
+
const report = (error) => {
|
|
692
|
+
try {
|
|
693
|
+
options.onRevokeError?.(error);
|
|
694
|
+
} catch {}
|
|
695
|
+
};
|
|
696
|
+
const headers = new Headers({ "Cache-Control": "no-store" });
|
|
697
|
+
setCookie(headers, cookies.destroy());
|
|
698
|
+
const sealed = cookies.token(request);
|
|
699
|
+
const opened = sealed ? await tokenSeal.open(sealed) : null;
|
|
700
|
+
const document = await issuerApi.discover().catch((cause) => {
|
|
701
|
+
if (options.revokeOnLogout) {
|
|
702
|
+
report(new OidcError("discovery-failed", "Discovery failed at logout, so the tokens were not revoked.", undefined, { cause }));
|
|
703
|
+
}
|
|
704
|
+
return null;
|
|
705
|
+
});
|
|
706
|
+
if (options.revokeOnLogout && document?.revocation_endpoint && isStored(opened)) {
|
|
707
|
+
await revokeTokens({
|
|
708
|
+
fetcher,
|
|
709
|
+
client,
|
|
710
|
+
endpoint: document.revocation_endpoint,
|
|
711
|
+
stored: opened,
|
|
712
|
+
signing,
|
|
713
|
+
timeoutMs: options.revokeTimeoutMs ?? 3000,
|
|
714
|
+
report
|
|
715
|
+
});
|
|
716
|
+
}
|
|
717
|
+
const endpoint = document?.end_session_endpoint;
|
|
718
|
+
if (!endpoint) {
|
|
719
|
+
headers.set("Location", options.postLogoutRedirectUri ?? "/");
|
|
720
|
+
return new Response(null, { status: 302, headers });
|
|
721
|
+
}
|
|
722
|
+
const target = new URL(endpoint);
|
|
723
|
+
if (isStored(opened))
|
|
724
|
+
target.searchParams.set("id_token_hint", opened.idToken);
|
|
725
|
+
target.searchParams.set("client_id", clientId);
|
|
726
|
+
if (options.postLogoutRedirectUri) {
|
|
727
|
+
target.searchParams.set("post_logout_redirect_uri", options.postLogoutRedirectUri);
|
|
728
|
+
}
|
|
729
|
+
headers.set("Location", target.toString());
|
|
730
|
+
return new Response(null, { status: 302, headers });
|
|
731
|
+
}
|
|
732
|
+
};
|
|
733
|
+
}
|
|
734
|
+
export {
|
|
735
|
+
OidcError,
|
|
736
|
+
generateDpopKey,
|
|
737
|
+
oidcClient,
|
|
738
|
+
signDpopProof
|
|
739
|
+
};
|
|
740
|
+
|
|
741
|
+
//# debugId=4C0ACB0CB06F933D64756E2164756E21
|
|
742
|
+
//# sourceMappingURL=index.js.map
|