@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,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/oidc/dpop.ts", "../src/oidc/seal.ts", "../src/oidc/errors.ts", "../src/oidc/oidc.ts", "../src/oidc/flow.ts", "../src/oidc/revoke.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import {\n\tcalculateJwkThumbprint,\n\texportJWK,\n\tgenerateKeyPair,\n\timportJWK,\n\ttype JWK,\n\tSignJWT,\n} from 'jose';\nimport { randomToken, toBase64Url } from './seal';\n\n/** The signature algorithms of a DPoP key (RFC 9449). */\nexport type DpopAlgorithm = 'ES256' | 'EdDSA';\n\n/** A DPoP key pair as it is stored with the session: the private JWK and its algorithm. */\nexport interface DpopKey {\n\treadonly alg: DpopAlgorithm;\n\treadonly jwk: JWK;\n}\n\n/** What a proof is signed for. */\nexport interface DpopProofInput {\n\t/** The HTTP method of the request the proof goes with. */\n\treadonly method: string;\n\t/** The request's URL; its query and fragment are dropped (`htu`). */\n\treadonly url: string | URL;\n\t/** The access token the proof is bound to (`ath`), for a call to a resource. */\n\treadonly accessToken?: string | undefined;\n\t/** The server's last `DPoP-Nonce`. */\n\treadonly nonce?: string | undefined;\n\t/** The clock, in ms; `Date.now` by default. */\n\treadonly now?: (() => number) | undefined;\n}\n\nconst encoder = new TextEncoder();\n\n/** A fresh DPoP key pair (ES256 by default), the private half as a JWK. */\nexport async function generateDpopKey(\n\talg: DpopAlgorithm = 'ES256',\n): Promise<DpopKey> {\n\tconst { privateKey } = await generateKeyPair(alg, { extractable: true });\n\treturn {\n\t\talg,\n\t\tjwk: pick(await exportJWK(privateKey), ['kty', 'crv', 'x', 'y', 'd']),\n\t};\n}\n\n/** Only the named members of a JWK that are set. */\nconst pick = (jwk: JWK, names: readonly (keyof JWK)[]): JWK =>\n\tObject.fromEntries(\n\t\tnames.flatMap((name) =>\n\t\t\tjwk[name] === undefined ? [] : [[name, jwk[name]]],\n\t\t),\n\t) as JWK;\n\nconst publicOf = (jwk: JWK): JWK => pick(jwk, ['kty', 'crv', 'x', 'y']);\n\n/** The RFC 7638 thumbprint of the key's public half (the `jkt` a server binds a token to). */\nexport const dpopThumbprint = (key: DpopKey): Promise<string> =>\n\tcalculateJwkThumbprint(publicOf(key.jwk), 'sha256');\n\n/** The URL a proof names: no query, no fragment. */\nexport function dpopTarget(url: string | URL): string {\n\tconst target = new URL(url);\n\ttarget.search = '';\n\ttarget.hash = '';\n\treturn target.toString();\n}\n\n/**\n * A DPoP proof (RFC 9449 section 4): a JWT of type `dpop+jwt` carrying the\n * key's public half, signed for one method and URL, with `ath` when it goes\n * with an access token and `nonce` when the server asked for one.\n */\nexport async function signDpopProof(\n\tkey: DpopKey,\n\tinput: DpopProofInput,\n): Promise<string> {\n\tconst signer = await importJWK(key.jwk, key.alg);\n\tconst iat = Math.floor((input.now ?? Date.now)() / 1000);\n\tconst ath =\n\t\tinput.accessToken === undefined\n\t\t\t? undefined\n\t\t\t: toBase64Url(\n\t\t\t\t\tnew Uint8Array(\n\t\t\t\t\t\tawait crypto.subtle.digest(\n\t\t\t\t\t\t\t'SHA-256',\n\t\t\t\t\t\t\tencoder.encode(input.accessToken),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t);\n\treturn new SignJWT({\n\t\thtm: input.method.toUpperCase(),\n\t\thtu: dpopTarget(input.url),\n\t\tjti: randomToken(16),\n\t\tiat,\n\t\t...(input.nonce !== undefined && { nonce: input.nonce }),\n\t\t...(ath !== undefined && { ath }),\n\t})\n\t\t.setProtectedHeader({\n\t\t\ttyp: 'dpop+jwt',\n\t\t\talg: key.alg,\n\t\t\tjwk: publicOf(key.jwk),\n\t\t})\n\t\t.sign(signer);\n}\n\n/** The last `DPoP-Nonce` each server sent, by origin (RFC 9449 section 8: a nonce belongs to one server). */\nexport interface NonceMemory {\n\tget(url: string | URL): string | undefined;\n\tset(url: string | URL, nonce: string): void;\n}\n\nexport function nonceMemory(): NonceMemory {\n\tconst nonces = new Map<string, string>();\n\treturn {\n\t\tget: (url) => nonces.get(new URL(url).origin),\n\t\tset: (url, nonce) => void nonces.set(new URL(url).origin, nonce),\n\t};\n}\n\n/** Whether a response asks for a (new) nonce: 400 `use_dpop_nonce` at an endpoint, 401 `WWW-Authenticate` at a resource. */\nexport async function wantsNonce(response: Response): Promise<boolean> {\n\tif (!response.headers.get('dpop-nonce')) return false;\n\tif (response.status === 401) {\n\t\treturn /use_dpop_nonce/.test(\n\t\t\tresponse.headers.get('www-authenticate') ?? '',\n\t\t);\n\t}\n\tif (response.status !== 400) return false;\n\tconst body: unknown = await response\n\t\t.clone()\n\t\t.json()\n\t\t.catch(() => null);\n\treturn (\n\t\ttypeof body === 'object' &&\n\t\tbody !== null &&\n\t\t(body as Record<string, unknown>)['error'] === 'use_dpop_nonce'\n\t);\n}\n\n/**\n * The DPoP side of a signed-in user: signs proofs for calls to a resource with\n * the session's key, bound to its access token.\n */\nexport interface DpopBinding {\n\t/** The key's thumbprint (`jkt`). */\n\treadonly thumbprint: string;\n\t/** A proof for one call (`htm`, `htu`, `ath`), with the nonce the server last sent unless one is given. */\n\tproof(input: {\n\t\treadonly method: string;\n\t\treadonly url: string | URL;\n\t\treadonly nonce?: string | undefined;\n\t}): Promise<string>;\n\t/** The two headers of a call: `Authorization: DPoP <token>` and `DPoP: <proof>`. */\n\theaders(input: {\n\t\treadonly method: string;\n\t\treadonly url: string | URL;\n\t\treadonly nonce?: string | undefined;\n\t}): Promise<{ readonly authorization: string; readonly dpop: string }>;\n\t/**\n\t * `fetch` with both headers set and the nonce retry: on `401` with\n\t * `WWW-Authenticate: DPoP error=\"use_dpop_nonce\"` it signs again with the\n\t * `DPoP-Nonce` header and retries once. Give a string or bytes as `body`,\n\t * since a stream cannot be sent twice.\n\t */\n\tfetch(input: string | URL, init?: RequestInit): Promise<Response>;\n}\n\nexport function dpopBinding(config: {\n\treadonly key: DpopKey;\n\treadonly thumbprint: string;\n\treadonly accessToken: string;\n\treadonly nonces: NonceMemory;\n\treadonly fetch: (input: string, init?: RequestInit) => Promise<Response>;\n\treadonly now: () => number;\n}): DpopBinding {\n\tconst { key, accessToken, nonces } = config;\n\tconst proof: DpopBinding['proof'] = ({ method, url, nonce }) =>\n\t\tsignDpopProof(key, {\n\t\t\tmethod,\n\t\t\turl,\n\t\t\taccessToken,\n\t\t\tnonce: nonce ?? nonces.get(url),\n\t\t\tnow: config.now,\n\t\t});\n\treturn {\n\t\tthumbprint: config.thumbprint,\n\t\tproof,\n\t\tasync headers(input) {\n\t\t\treturn {\n\t\t\t\tauthorization: `DPoP ${accessToken}`,\n\t\t\t\tdpop: await proof(input),\n\t\t\t};\n\t\t},\n\t\tasync fetch(input, init) {\n\t\t\tconst url = String(input);\n\t\t\tconst method = init?.method ?? 'GET';\n\t\t\tconst send = async (nonce?: string) => {\n\t\t\t\tconst headers = new Headers(init?.headers);\n\t\t\t\theaders.set('authorization', `DPoP ${accessToken}`);\n\t\t\t\theaders.set('dpop', await proof({ method, url, nonce }));\n\t\t\t\tconst response = await config.fetch(url, { ...init, headers });\n\t\t\t\tconst sent = response.headers.get('dpop-nonce');\n\t\t\t\tif (sent) nonces.set(url, sent);\n\t\t\t\treturn response;\n\t\t\t};\n\t\t\tconst first = await send();\n\t\t\tif (!(await wantsNonce(first))) return first;\n\t\t\treturn send(first.headers.get('dpop-nonce') ?? undefined);\n\t\t},\n\t};\n}\n",
|
|
6
|
+
"const encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\n/** Bytes as unpadded base64url. */\nexport const toBase64Url = (bytes: Uint8Array): string => {\n\tlet binary = '';\n\tfor (const byte of bytes) binary += String.fromCharCode(byte);\n\treturn btoa(binary)\n\t\t.replaceAll('+', '-')\n\t\t.replaceAll('/', '_')\n\t\t.replaceAll('=', '');\n};\n\nconst fromBase64Url = (text: string): Uint8Array<ArrayBuffer> => {\n\tconst padded = text.replaceAll('-', '+').replaceAll('_', '/');\n\tconst binary = atob(padded + '='.repeat((4 - (padded.length % 4)) % 4));\n\treturn Uint8Array.from(binary, (char) => char.charCodeAt(0));\n};\n\n/** `bytes` random bytes as base64url. */\nexport const randomToken = (bytes = 32): string =>\n\ttoBase64Url(crypto.getRandomValues(new Uint8Array(bytes)));\n\n/** Whether two strings are equal, comparing every byte whatever the first difference. */\nexport function sameText(a: string, b: string): boolean {\n\tconst left = encoder.encode(a);\n\tconst right = encoder.encode(b);\n\tlet difference = left.length ^ right.length;\n\tfor (let index = 0; index < Math.max(left.length, right.length); index++) {\n\t\tdifference |= (left[index] ?? 0) ^ (right[index] ?? 0);\n\t}\n\treturn difference === 0;\n}\n\n/** The base64url S256 challenge of a PKCE verifier. */\nexport async function s256(verifier: string): Promise<string> {\n\treturn toBase64Url(\n\t\tnew Uint8Array(\n\t\t\tawait crypto.subtle.digest('SHA-256', encoder.encode(verifier)),\n\t\t),\n\t);\n}\n\n/**\n * An AES-256-GCM sealer keyed from the session secret and a purpose, so a\n * challenge cookie cannot be replayed as a token cookie: the value is\n * encrypted (the tokens stay unreadable) and authenticated (nobody can forge\n * or edit it).\n */\nexport function sealer(secret: string, purpose: string) {\n\tconst key = crypto.subtle\n\t\t.digest('SHA-256', encoder.encode(`alxia-oidc/${purpose}/${secret}`))\n\t\t.then((raw) =>\n\t\t\tcrypto.subtle.importKey('raw', raw, 'AES-GCM', false, [\n\t\t\t\t'encrypt',\n\t\t\t\t'decrypt',\n\t\t\t]),\n\t\t);\n\tconst additionalData = encoder.encode(purpose);\n\treturn {\n\t\tasync seal(value: unknown): Promise<string> {\n\t\t\tconst iv = crypto.getRandomValues(new Uint8Array(12));\n\t\t\tconst data = new Uint8Array(\n\t\t\t\tawait crypto.subtle.encrypt(\n\t\t\t\t\t{ name: 'AES-GCM', iv, additionalData },\n\t\t\t\t\tawait key,\n\t\t\t\t\tencoder.encode(JSON.stringify(value)),\n\t\t\t\t),\n\t\t\t);\n\t\t\tconst out = new Uint8Array(iv.length + data.length);\n\t\t\tout.set(iv);\n\t\t\tout.set(data, iv.length);\n\t\t\treturn toBase64Url(out);\n\t\t},\n\t\t/** The value, or `null` when the text was not sealed with this secret and purpose. */\n\t\tasync open(text: string): Promise<unknown> {\n\t\t\ttry {\n\t\t\t\tconst bytes = fromBase64Url(text);\n\t\t\t\tif (bytes.length < 29) return null;\n\t\t\t\tconst plain = await crypto.subtle.decrypt(\n\t\t\t\t\t{ name: 'AES-GCM', iv: bytes.slice(0, 12), additionalData },\n\t\t\t\t\tawait key,\n\t\t\t\t\tbytes.slice(12),\n\t\t\t\t);\n\t\t\t\treturn JSON.parse(decoder.decode(plain));\n\t\t\t} catch {\n\t\t\t\treturn null;\n\t\t\t}\n\t\t},\n\t};\n}\n",
|
|
7
|
+
"/** Why a relying-party step refused. */\nexport type OidcErrorCode =\n\t| 'discovery-failed'\n\t| 'missing-challenge'\n\t| 'challenge-expired'\n\t| 'provider-error'\n\t| 'issuer-mismatch'\n\t| 'state-mismatch'\n\t| 'missing-code'\n\t| 'token-exchange-failed'\n\t| 'invalid-id-token'\n\t| 'nonce-mismatch'\n\t| 'refresh-failed'\n\t| 'par-failed'\n\t| 'revoke-failed'\n\t| 'token-cookie-too-large';\n\n/**\n * What `callback` throws. `headers` holds the `Set-Cookie` that clears the\n * spent challenge: pass it when the route answers the failure, e.g.\n * `redirect('/sign-in?error=' + error.code, { headers: error.headers })`.\n */\nexport class OidcError extends Error {\n\toverride readonly name = 'OidcError';\n\tconstructor(\n\t\treadonly code: OidcErrorCode,\n\t\tmessage: string,\n\t\treadonly headers: Headers = new Headers(),\n\t\toptions?: { readonly cause?: unknown },\n\t) {\n\t\tsuper(message, options);\n\t}\n}\n",
|
|
8
|
+
"import type { JWTPayload } from 'jose';\nimport { redirect } from 'react-router';\nimport { sessionCookies } from '../session/cookies';\nimport { safeNext } from '../session/model/safe-next';\nimport {\n\ttype DpopAlgorithm,\n\ttype DpopBinding,\n\ttype DpopKey,\n\tdpopBinding,\n\tdpopThumbprint,\n\tgenerateDpopKey,\n\tnonceMemory,\n} from './dpop';\nimport { OidcError } from './errors';\nimport {\n\tdecodeJwt,\n\ttype Fetcher,\n\tissuerClient,\n\tpushRequest,\n\ttype TokenResponse,\n\ttokenRequest,\n} from './flow';\nimport { revokeTokens } from './revoke';\nimport { randomToken, s256, sameText, sealer } from './seal';\n\n/** What `oidcClient` takes. */\nexport interface OidcOptions {\n\t/** The issuer's identifier, exactly as its discovery document names it (no trailing slash needed). */\n\treadonly issuer: string;\n\treadonly clientId: string;\n\t/** The secret of a confidential client, sent as `client_secret_basic`. Omit it for a public client. */\n\treadonly clientSecret?: string | undefined;\n\t/** The absolute URL of the route that calls `callback`; registered with the issuer. */\n\treadonly redirectUri: string;\n\t/** `['openid', 'profile', 'email']` by default; `openid` is always sent. Add `offline_access` for a refresh token. */\n\treadonly scopes?: readonly string[] | undefined;\n\t/** Seals the cookies (AES-256-GCM): at least 32 characters, from the environment, never committed. Changing it signs everyone out. */\n\treadonly secret: string;\n\t/** The base name of the cookies, e.g. `'my-app_oidc'`; `__Host-` is added when `secure`. */\n\treadonly name: string;\n\t/** The app is served over HTTPS. Required, never read from the environment: pass `!import.meta.env.DEV`. */\n\treadonly secure: boolean;\n\t/** The route that starts the sign-in (it calls `signIn`). `'/sign-in'` by default. */\n\treadonly signInPath?: string | undefined;\n\t/** Where the issuer sends the browser after `logout`; it must be registered with the issuer. */\n\treadonly postLogoutRedirectUri?: string | undefined;\n\t/** How long the token cookie lives when there is a refresh token. 30 days by default; otherwise it ends with the access token. */\n\treadonly sessionSeconds?: number | undefined;\n\t/** Refresh when the access token ends within this many seconds. 60 by default. */\n\treadonly refreshSkewSeconds?: number | undefined;\n\t/** Clock difference accepted on `exp` and `iat`. 30 by default. */\n\treadonly clockToleranceSeconds?: number | undefined;\n\t/** Id token signature algorithms accepted. `RS256`, `PS256`, `ES256` and `EdDSA` by default. */\n\treadonly algorithms?: readonly string[] | undefined;\n\t/** Extra parameters of the authorization request, e.g. `{ prompt: 'login' }`. */\n\treadonly authorizationParams?: Readonly<Record<string, string>> | undefined;\n\t/**\n\t * Extra parameters of the token request, sent on the code exchange and on every refresh,\n\t * e.g. `{ resource: 'https://api.example' }` (RFC 8707). The parameters the flow owns\n\t * (`grant_type`, `code`, `redirect_uri`, `code_verifier`, `refresh_token`, `scope`) win over these, and `client_id` and `client_secret` are ignored.\n\t */\n\treadonly tokenParams?: Readonly<Record<string, string>> | undefined;\n\t/**\n\t * Pushed authorization requests (RFC 9126): the authorization request is POSTed to the issuer's\n\t * `pushed_authorization_request_endpoint` with the client's authentication, and the browser is\n\t * redirected with `client_id` and `request_uri` alone.\n\t * `'auto'` (default) pushes when discovery says `require_pushed_authorization_requests: true`;\n\t * `'always'` pushes whatever discovery says (and fails with `par-failed` without an endpoint);\n\t * `'never'` always sends the parameters in the redirect.\n\t */\n\treadonly par?: 'auto' | 'always' | 'never' | undefined;\n\t/**\n\t * Binds the tokens to a key with DPoP (RFC 9449). Off by default. A key pair per sign-in\n\t * (`ES256` by default, or `EdDSA`) is made at `signIn` and kept in the sealed cookies with the\n\t * session; the token endpoint (code and refresh) gets a proof, a `use_dpop_nonce` answer is\n\t * retried once with the nonce sent, and `OidcUser.dpop` signs the proofs of calls to a resource.\n\t */\n\treadonly dpop?: { readonly alg?: DpopAlgorithm | undefined } | undefined;\n\t/**\n\t * Revoke the refresh token and the access token at `logout` (RFC 7009). Off by default.\n\t * When on and discovery has a `revocation_endpoint`, `logout` POSTs the refresh token\n\t * (`token_type_hint=refresh_token`) then the access token (`token_type_hint=access_token`),\n\t * with the client's authentication and the DPoP proof of the token endpoint. A failure\n\t * (network error, non-2xx) never blocks the logout: the cookie is cleared and the redirect\n\t * sent, and the failure goes to `onRevokeError`.\n\t */\n\treadonly revokeOnLogout?: boolean | undefined;\n\t/** The most `logout` waits for the revocations, in ms, both together. 3000 by default. A stalled endpoint is aborted and reported as `revoke-failed`; the sign-out goes on. */\n\treadonly revokeTimeoutMs?: number | undefined;\n\t/** Called with each revocation failure at `logout` (an `OidcError` with code `revoke-failed`, or `discovery-failed`). Nothing by default. */\n\treadonly onRevokeError?: ((error: OidcError) => void) | undefined;\n\t/** The `fetch` used for discovery, the keys and the token endpoint; global `fetch` by default. */\n\treadonly fetch?: Fetcher | undefined;\n\t/** The clock, in ms; `Date.now` by default. */\n\treadonly now?: (() => number) | undefined;\n}\n\n/** The signed-in user a loader reads. */\nexport interface OidcUser {\n\t/** The id token's claims. */\n\treadonly claims: JWTPayload;\n\treadonly accessToken: string;\n\treadonly idToken: string;\n\t/** When the access token ends, in ms. */\n\treadonly expiresAt: number;\n\t/** `Set-Cookie` when the tokens were refreshed, else empty: pass it with the loader's answer. */\n\treadonly headers: Headers;\n\t/** Signs the proofs of calls to a resource when the tokens are DPoP-bound (`dpop` option, and the issuer sent `token_type: DPoP`), else `null`. */\n\treadonly dpop: DpopBinding | null;\n}\n\n/** The relying party `oidcClient` returns. */\nexport interface OidcClient {\n\t/** The route action or loader that starts the sign-in: a redirect to the issuer. `?next=` is kept, through `safeNext`. */\n\tsignIn(request: Request): Promise<Response>;\n\t/** The redirect route: checks state, exchanges the code, validates the id token, sets the token cookie and redirects to `next`. Throws `OidcError`. */\n\tcallback(request: Request): Promise<Response>;\n\t/** The signed-in user (refreshed if due), or `null`. */\n\toidcUser(request: Request): Promise<OidcUser | null>;\n\t/** Like `oidcUser`, but throws a redirect to the sign-in route (with a safe `next`) when there is none. */\n\trequireOidcUser(request: Request): Promise<OidcUser>;\n\t/** Clears the token cookie (after revoking the tokens with `revokeOnLogout`) and redirects to the issuer's `end_session_endpoint` (with `id_token_hint`), else to `postLogoutRedirectUri` or `/`. Call it from an action. */\n\tlogout(request: Request): Promise<Response>;\n\t/** The cookie names as sent, prefixes included. */\n\treadonly names: { readonly session: string; readonly challenge: string };\n}\n\ninterface Flow {\n\treadonly state: string;\n\treadonly nonce: string;\n\treadonly verifier: string;\n\treadonly next: string;\n\treadonly exp: number;\n\treadonly dpop?: DpopKey | undefined;\n}\n\ninterface Stored {\n\treadonly idToken: string;\n\treadonly accessToken: string;\n\treadonly refreshToken?: string | undefined;\n\treadonly expiresAt: number;\n\treadonly dpop?: DpopKey | undefined;\n}\n\nconst DEFAULT_ALGORITHMS = ['RS256', 'PS256', 'ES256', 'EdDSA'];\nconst CHALLENGE_SECONDS = 600;\nconst SAME_FLIGHT_MS = 10_000;\n\nconst isFlow = (value: unknown): value is Flow =>\n\ttypeof value === 'object' &&\n\tvalue !== null &&\n\t['state', 'nonce', 'verifier', 'next'].every(\n\t\t(key) => typeof (value as Record<string, unknown>)[key] === 'string',\n\t) &&\n\ttypeof (value as Record<string, unknown>)['exp'] === 'number' &&\n\t((value as Record<string, unknown>)['dpop'] === undefined ||\n\t\tisKey((value as Record<string, unknown>)['dpop']));\n\nconst isKey = (value: unknown): value is DpopKey =>\n\ttypeof value === 'object' &&\n\tvalue !== null &&\n\t['ES256', 'EdDSA'].includes(\n\t\t(value as Record<string, unknown>)['alg'] as string,\n\t) &&\n\ttypeof (value as Record<string, unknown>)['jwk'] === 'object';\n\nconst isStored = (value: unknown): value is Stored =>\n\ttypeof value === 'object' &&\n\tvalue !== null &&\n\ttypeof (value as Record<string, unknown>)['idToken'] === 'string' &&\n\ttypeof (value as Record<string, unknown>)['accessToken'] === 'string' &&\n\ttypeof (value as Record<string, unknown>)['expiresAt'] === 'number' &&\n\t((value as Record<string, unknown>)['dpop'] === undefined ||\n\t\tisKey((value as Record<string, unknown>)['dpop']));\n\n/**\n * A BFF as the relying party of an external OpenID Connect issuer:\n * authorization code with PKCE (S256), state and nonce in a short-lived\n * `__Host-` challenge cookie, discovery (cached), the code exchange, the id\n * token validated against the issuer's keys (`jose`, an optional peer), the\n * tokens in a sealed `__Host-` cookie, a single-flight refresh and\n * RP-initiated logout.\n *\n * @example\n * export const oidc = oidcClient({\n * issuer: 'https://id.example.com',\n * clientId: 'my-app',\n * clientSecret: process.env.OIDC_CLIENT_SECRET,\n * redirectUri: 'https://app.example.com/auth/callback',\n * scopes: ['openid', 'profile', 'email', 'offline_access'],\n * secret: process.env.SESSION_SECRET!,\n * name: 'my-app_oidc',\n * secure: !import.meta.env.DEV,\n * });\n * // routes/auth.callback.ts: export const loader = ({ request }) => oidc.callback(request);\n * // any loader: const { claims, headers } = await oidc.requireOidcUser(request);\n */\nexport function oidcClient(options: OidcOptions): OidcClient {\n\tconst {\n\t\tissuer,\n\t\tclientId,\n\t\tclientSecret,\n\t\tredirectUri,\n\t\tsecret,\n\t\tsignInPath = '/sign-in',\n\t\tsessionSeconds = 30 * 24 * 3600,\n\t\trefreshSkewSeconds = 60,\n\t\tclockToleranceSeconds = 30,\n\t} = options;\n\tfor (const [label, value] of [\n\t\t['issuer', issuer],\n\t\t['clientId', clientId],\n\t\t['redirectUri', redirectUri],\n\t] as const) {\n\t\tif (!value) throw new TypeError(`oidcClient(): ${label} is required.`);\n\t}\n\tif (typeof secret !== 'string' || secret.length < 32) {\n\t\tthrow new TypeError(\n\t\t\t'oidcClient(): secret must be a string of at least 32 characters.',\n\t\t);\n\t}\n\t// Client credentials travel by the client's authentication method, never as extras.\n\tconst {\n\t\tclient_id: _id,\n\t\tclient_secret: _secret,\n\t\t...extraTokenParams\n\t} = options.tokenParams ?? {};\n\tconst now = options.now ?? Date.now;\n\tconst scopes = [\n\t\t...new Set(['openid', ...(options.scopes ?? ['profile', 'email'])]),\n\t];\n\tconst cookies = sessionCookies({\n\t\tsession: options.name,\n\t\tchallenge: `${options.name}_flow`,\n\t\tchallengePath: '/',\n\t\tchallengeHostPrefix: true,\n\t\tchallengeSeconds: CHALLENGE_SECONDS,\n\t\tsecure: options.secure,\n\t\tsameSite: 'lax',\n\t});\n\tconst flowSeal = sealer(secret, 'flow');\n\tconst tokenSeal = sealer(secret, 'tokens');\n\tconst issuerApi = issuerClient({\n\t\tissuer,\n\t\tfetch: options.fetch ?? ((input, init) => fetch(input, init)),\n\t\tnow,\n\t\talgorithms: [...(options.algorithms ?? DEFAULT_ALGORITHMS)],\n\t\tclockToleranceSeconds,\n\t});\n\tconst fetcher: Fetcher =\n\t\toptions.fetch ?? ((input, init) => fetch(input, init));\n\tconst client = { id: clientId, secret: clientSecret };\n\tconst par = options.par ?? 'auto';\n\tif (!['auto', 'always', 'never'].includes(par)) {\n\t\tthrow new TypeError(\n\t\t\t\"oidcClient(): par must be 'auto', 'always' or 'never'.\",\n\t\t);\n\t}\n\tconst dpopAlg = options.dpop ? (options.dpop.alg ?? 'ES256') : undefined;\n\tif (dpopAlg !== undefined && !['ES256', 'EdDSA'].includes(dpopAlg)) {\n\t\tthrow new TypeError(\"oidcClient(): dpop.alg must be 'ES256' or 'EdDSA'.\");\n\t}\n\tif (\n\t\toptions.revokeTimeoutMs !== undefined &&\n\t\t!(Number.isFinite(options.revokeTimeoutMs) && options.revokeTimeoutMs > 0)\n\t) {\n\t\tthrow new TypeError(\n\t\t\t'oidcClient(): revokeTimeoutMs must be a positive finite number of milliseconds.',\n\t\t);\n\t}\n\tconst nonces = nonceMemory();\n\tconst signing = (key: DpopKey | undefined) =>\n\t\tkey ? { key, nonces, now } : undefined;\n\n\tconst flights = new Map<string, Promise<Stored>>();\n\n\tconst setCookie = (headers: Headers, value: string) =>\n\t\theaders.append('Set-Cookie', value);\n\n\tasync function toStored(\n\t\tresponse: TokenResponse,\n\t\tnonce: string | undefined,\n\t\tprevious?: Stored,\n\t\tkey?: DpopKey,\n\t): Promise<{ stored: Stored; claims: JWTPayload }> {\n\t\t// Only a token the issuer says is DPoP-bound keeps the key.\n\t\tconst dpop =\n\t\t\tkey &&\n\t\t\t(String(response.token_type).toLowerCase() === 'dpop' ||\n\t\t\t\t(previous?.dpop !== undefined && response.token_type === undefined))\n\t\t\t\t? key\n\t\t\t\t: undefined;\n\t\tif (!response.id_token && previous) {\n\t\t\t// A refresh may omit the id token (OIDC Core 12.2): keep the one verified\n\t\t\t// at sign-in, in the sealed cookie, though it has expired since.\n\t\t\tconst kept = decodeJwt(previous.idToken);\n\t\t\treturn {\n\t\t\t\tclaims: kept,\n\t\t\t\tstored: {\n\t\t\t\t\tidToken: previous.idToken,\n\t\t\t\t\tdpop,\n\t\t\t\t\taccessToken: response.access_token,\n\t\t\t\t\trefreshToken: response.refresh_token ?? previous.refreshToken,\n\t\t\t\t\texpiresAt:\n\t\t\t\t\t\ttypeof response.expires_in === 'number'\n\t\t\t\t\t\t\t? now() + response.expires_in * 1000\n\t\t\t\t\t\t\t: now() + 300_000,\n\t\t\t\t},\n\t\t\t};\n\t\t}\n\t\tconst idToken = response.id_token;\n\t\tif (!idToken) {\n\t\t\tthrow new OidcError(\n\t\t\t\t'invalid-id-token',\n\t\t\t\t'The token endpoint sent no id token.',\n\t\t\t);\n\t\t}\n\t\tconst claims = await issuerApi.verifyIdToken(idToken, clientId, nonce);\n\t\tif (previous && decodeJwt(previous.idToken).sub !== claims.sub) {\n\t\t\tthrow new OidcError('invalid-id-token', 'A refresh changed the user.');\n\t\t}\n\t\tconst expiresAt =\n\t\t\ttypeof response.expires_in === 'number'\n\t\t\t\t? now() + response.expires_in * 1000\n\t\t\t\t: (claims['exp'] ?? 0) * 1000;\n\t\treturn {\n\t\t\tclaims,\n\t\t\tstored: {\n\t\t\t\tidToken,\n\t\t\t\tdpop,\n\t\t\t\taccessToken: response.access_token,\n\t\t\t\trefreshToken: response.refresh_token ?? previous?.refreshToken,\n\t\t\t\texpiresAt,\n\t\t\t},\n\t\t};\n\t}\n\n\tasync function commit(headers: Headers, stored: Stored): Promise<void> {\n\t\tconst lifetime = stored.refreshToken\n\t\t\t? sessionSeconds\n\t\t\t: Math.max(0, (stored.expiresAt - now()) / 1000);\n\t\tconst cookie = cookies.commit(\n\t\t\tawait tokenSeal.seal(stored),\n\t\t\tnew Date(now() + lifetime * 1000),\n\t\t\tnow(),\n\t\t);\n\t\t// A browser silently drops a cookie over 4096 bytes: fail loudly instead.\n\t\tif (cookie.length > 4096) {\n\t\t\tthrow new OidcError(\n\t\t\t\t'token-cookie-too-large',\n\t\t\t\t`The token cookie is ${cookie.length} bytes, over the 4096 a browser keeps. Ask the issuer for fewer claims or a shorter access token.`,\n\t\t\t);\n\t\t}\n\t\tsetCookie(headers, cookie);\n\t}\n\n\tconst toSignIn = (request: Request, headers: Headers): never => {\n\t\tconst url = new URL(request.url);\n\t\tconst next = safeNext(`${url.pathname}${url.search}`);\n\t\tconst target = new URL(signInPath, url);\n\t\ttarget.searchParams.set('next', next);\n\t\tthrow redirect(`${target.pathname}${target.search}`, { headers });\n\t};\n\n\tfunction refreshing(stored: Stored): Promise<Stored> {\n\t\tconst key = stored.refreshToken as string;\n\t\tconst flying = flights.get(key);\n\t\tif (flying) return flying;\n\t\tconst flight = (async () => {\n\t\t\tconst document = await issuerApi.discover();\n\t\t\tconst answer = await tokenRequest(\n\t\t\t\tfetcher,\n\t\t\t\tdocument.token_endpoint,\n\t\t\t\tclient,\n\t\t\t\t{\n\t\t\t\t\t...extraTokenParams,\n\t\t\t\t\tgrant_type: 'refresh_token',\n\t\t\t\t\trefresh_token: key,\n\t\t\t\t\tscope: scopes.join(' '),\n\t\t\t\t},\n\t\t\t\t'refresh-failed',\n\t\t\t\tsigning(stored.dpop),\n\t\t\t);\n\t\t\treturn (await toStored(answer, undefined, stored, stored.dpop)).stored;\n\t\t})();\n\t\tflights.set(key, flight);\n\t\t// Rotation: parallel requests still carry the spent refresh token for a moment.\n\t\tconst forget = () => setTimeout(() => flights.delete(key), SAME_FLIGHT_MS);\n\t\tflight.then(forget, () => flights.delete(key));\n\t\treturn flight;\n\t}\n\n\tasync function oidcUser(request: Request): Promise<OidcUser | null> {\n\t\tconst headers = new Headers();\n\t\tconst sealed = cookies.token(request);\n\t\tif (!sealed) return null;\n\t\tconst opened = await tokenSeal.open(sealed);\n\t\tif (!isStored(opened)) {\n\t\t\tsetCookie(headers, cookies.destroy());\n\t\t\treturn null;\n\t\t}\n\t\tlet stored: Stored = opened;\n\t\tif (stored.expiresAt - refreshSkewSeconds * 1000 <= now()) {\n\t\t\ttry {\n\t\t\t\tif (!stored.refreshToken) throw new Error('no refresh token');\n\t\t\t\tstored = await refreshing(stored);\n\t\t\t\tawait commit(headers, stored);\n\t\t\t} catch {\n\t\t\t\t// A transient failure keeps a still-valid access token going.\n\t\t\t\tif (stored.expiresAt <= now()) return null;\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tclaims: decodeJwt(stored.idToken),\n\t\t\taccessToken: stored.accessToken,\n\t\t\tidToken: stored.idToken,\n\t\t\texpiresAt: stored.expiresAt,\n\t\t\theaders,\n\t\t\tdpop: stored.dpop\n\t\t\t\t? dpopBinding({\n\t\t\t\t\t\tkey: stored.dpop,\n\t\t\t\t\t\tthumbprint: await dpopThumbprint(stored.dpop),\n\t\t\t\t\t\taccessToken: stored.accessToken,\n\t\t\t\t\t\tnonces,\n\t\t\t\t\t\tfetch: fetcher,\n\t\t\t\t\t\tnow,\n\t\t\t\t\t})\n\t\t\t\t: null,\n\t\t};\n\t}\n\n\treturn {\n\t\tnames: cookies.names,\n\t\toidcUser,\n\t\tasync requireOidcUser(request) {\n\t\t\tconst user = await oidcUser(request);\n\t\t\tif (user) return user;\n\t\t\tconst headers = new Headers();\n\t\t\tif (cookies.token(request)) setCookie(headers, cookies.destroy());\n\t\t\treturn toSignIn(request, headers);\n\t\t},\n\t\tasync signIn(request) {\n\t\t\tconst document = await issuerApi.discover();\n\t\t\tconst url = new URL(request.url);\n\t\t\tconst flow: Flow = {\n\t\t\t\tstate: randomToken(),\n\t\t\t\tnonce: randomToken(),\n\t\t\t\tverifier: randomToken(48),\n\t\t\t\tnext: safeNext(url.searchParams.get('next')),\n\t\t\t\texp: now() + CHALLENGE_SECONDS * 1000,\n\t\t\t\tdpop: dpopAlg ? await generateDpopKey(dpopAlg) : undefined,\n\t\t\t};\n\t\t\tconst authRequest: Record<string, string> = {\n\t\t\t\t...options.authorizationParams,\n\t\t\t\tresponse_type: 'code',\n\t\t\t\tclient_id: clientId,\n\t\t\t\tredirect_uri: redirectUri,\n\t\t\t\tscope: scopes.join(' '),\n\t\t\t\tstate: flow.state,\n\t\t\t\tnonce: flow.nonce,\n\t\t\t\tcode_challenge: await s256(flow.verifier),\n\t\t\t\tcode_challenge_method: 'S256',\n\t\t\t\t...(flow.dpop && { dpop_jkt: await dpopThumbprint(flow.dpop) }),\n\t\t\t};\n\t\t\tconst endpoint = document.pushed_authorization_request_endpoint;\n\t\t\tconst push =\n\t\t\t\tpar === 'always' ||\n\t\t\t\t(par === 'auto' &&\n\t\t\t\t\tdocument.require_pushed_authorization_requests === true);\n\t\t\tconst target = new URL(document.authorization_endpoint);\n\t\t\tif (push) {\n\t\t\t\tif (!endpoint) {\n\t\t\t\t\tthrow new OidcError(\n\t\t\t\t\t\t'par-failed',\n\t\t\t\t\t\t'Pushed authorization requests are required but the issuer publishes no pushed_authorization_request_endpoint.',\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tconst requestUri = await pushRequest(\n\t\t\t\t\tfetcher,\n\t\t\t\t\tendpoint,\n\t\t\t\t\tclient,\n\t\t\t\t\tauthRequest,\n\t\t\t\t\tsigning(flow.dpop),\n\t\t\t\t);\n\t\t\t\ttarget.searchParams.set('client_id', clientId);\n\t\t\t\ttarget.searchParams.set('request_uri', requestUri);\n\t\t\t} else {\n\t\t\t\tfor (const [key, value] of Object.entries(authRequest)) {\n\t\t\t\t\ttarget.searchParams.set(key, value);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst headers = new Headers({ 'Cache-Control': 'no-store' });\n\t\t\tsetCookie(\n\t\t\t\theaders,\n\t\t\t\tcookies.commitChallenge(await flowSeal.seal(flow), null, now()),\n\t\t\t);\n\t\t\theaders.set('Location', target.toString());\n\t\t\treturn new Response(null, { status: 302, headers });\n\t\t},\n\t\tasync callback(request) {\n\t\t\tconst cleared = () => {\n\t\t\t\tconst headers = new Headers();\n\t\t\t\tsetCookie(headers, cookies.destroyChallenge());\n\t\t\t\treturn headers;\n\t\t\t};\n\t\t\tconst fail = (\n\t\t\t\tcode: ConstructorParameters<typeof OidcError>[0],\n\t\t\t\tmessage: string,\n\t\t\t) => new OidcError(code, message, cleared());\n\t\t\tconst url = new URL(request.url);\n\t\t\tconst sealed = cookies.challengeOf(request);\n\t\t\tconst flow = sealed ? await flowSeal.open(sealed) : null;\n\t\t\tif (!isFlow(flow)) {\n\t\t\t\tthrow fail(\n\t\t\t\t\t'missing-challenge',\n\t\t\t\t\t'The sign-in challenge cookie is missing or unreadable (a second tab, an expired page or a blocked cookie).',\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (flow.exp <= now()) {\n\t\t\t\tthrow fail(\n\t\t\t\t\t'challenge-expired',\n\t\t\t\t\t'The sign-in took too long; start again.',\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst returned = url.searchParams.get('state');\n\t\t\tif (returned === null || !sameText(returned, flow.state)) {\n\t\t\t\tthrow fail(\n\t\t\t\t\t'state-mismatch',\n\t\t\t\t\t'The returned state is not the one this sign-in sent.',\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst failure = url.searchParams.get('error');\n\t\t\tif (failure) {\n\t\t\t\tconst description = url.searchParams.get('error_description');\n\t\t\t\tthrow fail(\n\t\t\t\t\t'provider-error',\n\t\t\t\t\t`The issuer refused: ${failure}${description ? ` (${description})` : ''}.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tconst claimedIssuer = url.searchParams.get('iss');\n\t\t\tif (claimedIssuer !== null && claimedIssuer !== issuer) {\n\t\t\t\tthrow fail('issuer-mismatch', 'The callback names another issuer.');\n\t\t\t}\n\t\t\tconst code = url.searchParams.get('code');\n\t\t\tif (!code) throw fail('missing-code', 'The callback carries no code.');\n\t\t\ttry {\n\t\t\t\tconst document = await issuerApi.discover();\n\t\t\t\tconst answer = await tokenRequest(\n\t\t\t\t\tfetcher,\n\t\t\t\t\tdocument.token_endpoint,\n\t\t\t\t\tclient,\n\t\t\t\t\t{\n\t\t\t\t\t\t...extraTokenParams,\n\t\t\t\t\t\tgrant_type: 'authorization_code',\n\t\t\t\t\t\tcode,\n\t\t\t\t\t\tredirect_uri: redirectUri,\n\t\t\t\t\t\tcode_verifier: flow.verifier,\n\t\t\t\t\t},\n\t\t\t\t\t'token-exchange-failed',\n\t\t\t\t\tsigning(flow.dpop),\n\t\t\t\t);\n\t\t\t\tconst { stored } = await toStored(\n\t\t\t\t\tanswer,\n\t\t\t\t\tflow.nonce,\n\t\t\t\t\tundefined,\n\t\t\t\t\tflow.dpop,\n\t\t\t\t);\n\t\t\t\tconst headers = cleared();\n\t\t\t\tawait commit(headers, stored);\n\t\t\t\theaders.set('Location', safeNext(flow.next));\n\t\t\t\theaders.set('Cache-Control', 'no-store');\n\t\t\t\treturn new Response(null, { status: 302, headers });\n\t\t\t} catch (error) {\n\t\t\t\tif (error instanceof OidcError) {\n\t\t\t\t\tfor (const value of cleared().getSetCookie()) {\n\t\t\t\t\t\terror.headers.append('Set-Cookie', value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t\tasync logout(request) {\n\t\t\tconst report = (error: OidcError): void => {\n\t\t\t\ttry {\n\t\t\t\t\toptions.onRevokeError?.(error);\n\t\t\t\t} catch {\n\t\t\t\t\t// A failing hook never blocks the logout.\n\t\t\t\t}\n\t\t\t};\n\t\t\tconst headers = new Headers({ 'Cache-Control': 'no-store' });\n\t\t\tsetCookie(headers, cookies.destroy());\n\t\t\tconst sealed = cookies.token(request);\n\t\t\tconst opened = sealed ? await tokenSeal.open(sealed) : null;\n\t\t\tconst document = await issuerApi.discover().catch((cause) => {\n\t\t\t\tif (options.revokeOnLogout) {\n\t\t\t\t\treport(\n\t\t\t\t\t\tnew OidcError(\n\t\t\t\t\t\t\t'discovery-failed',\n\t\t\t\t\t\t\t'Discovery failed at logout, so the tokens were not revoked.',\n\t\t\t\t\t\t\tundefined,\n\t\t\t\t\t\t\t{ cause },\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\treturn null;\n\t\t\t});\n\t\t\tif (\n\t\t\t\toptions.revokeOnLogout &&\n\t\t\t\tdocument?.revocation_endpoint &&\n\t\t\t\tisStored(opened)\n\t\t\t) {\n\t\t\t\tawait revokeTokens({\n\t\t\t\t\tfetcher,\n\t\t\t\t\tclient,\n\t\t\t\t\tendpoint: document.revocation_endpoint,\n\t\t\t\t\tstored: opened,\n\t\t\t\t\tsigning,\n\t\t\t\t\ttimeoutMs: options.revokeTimeoutMs ?? 3000,\n\t\t\t\t\treport,\n\t\t\t\t});\n\t\t\t}\n\t\t\tconst endpoint = document?.end_session_endpoint;\n\t\t\tif (!endpoint) {\n\t\t\t\theaders.set('Location', options.postLogoutRedirectUri ?? '/');\n\t\t\t\treturn new Response(null, { status: 302, headers });\n\t\t\t}\n\t\t\tconst target = new URL(endpoint);\n\t\t\tif (isStored(opened))\n\t\t\t\ttarget.searchParams.set('id_token_hint', opened.idToken);\n\t\t\ttarget.searchParams.set('client_id', clientId);\n\t\t\tif (options.postLogoutRedirectUri) {\n\t\t\t\ttarget.searchParams.set(\n\t\t\t\t\t'post_logout_redirect_uri',\n\t\t\t\t\toptions.postLogoutRedirectUri,\n\t\t\t\t);\n\t\t\t}\n\t\t\theaders.set('Location', target.toString());\n\t\t\treturn new Response(null, { status: 302, headers });\n\t\t},\n\t};\n}\n",
|
|
9
|
+
"import {\n\tcreateLocalJWKSet,\n\tdecodeJwt,\n\ttype JSONWebKeySet,\n\ttype JWTPayload,\n\terrors as joseErrors,\n\tjwtVerify,\n} from 'jose';\nimport {\n\ttype DpopKey,\n\ttype NonceMemory,\n\tsignDpopProof,\n\twantsNonce,\n} from './dpop';\nimport { OidcError, type OidcErrorCode } from './errors';\n\n/** The fields of the issuer's discovery document the flow reads. */\nexport interface DiscoveryDocument {\n\treadonly issuer: string;\n\treadonly authorization_endpoint: string;\n\treadonly token_endpoint: string;\n\treadonly jwks_uri: string;\n\treadonly end_session_endpoint?: string;\n\treadonly revocation_endpoint?: string;\n\treadonly pushed_authorization_request_endpoint?: string;\n\treadonly require_pushed_authorization_requests?: boolean;\n}\n\n/** What the issuer's token endpoint answers. */\nexport interface TokenResponse {\n\treadonly access_token: string;\n\treadonly id_token?: string;\n\treadonly refresh_token?: string;\n\treadonly expires_in?: number;\n\treadonly token_type?: string;\n}\n\nexport type Fetcher = (input: string, init?: RequestInit) => Promise<Response>;\n\nconst DISCOVERY_TTL = 60 * 60 * 1000;\nconst JWKS_TTL = 10 * 60 * 1000;\n\nconst isRecord = (value: unknown): value is Record<string, unknown> =>\n\ttypeof value === 'object' && value !== null;\n\nconst text = (value: unknown): value is string =>\n\ttypeof value === 'string' && value !== '';\n\n/** Discovery and the issuer's keys, cached; one per relying party. */\nexport function issuerClient(config: {\n\treadonly issuer: string;\n\treadonly fetch: Fetcher;\n\treadonly now: () => number;\n\treadonly algorithms: string[];\n\treadonly clockToleranceSeconds: number;\n}) {\n\tconst { issuer, now } = config;\n\tlet discovery: { at: number; value: Promise<DiscoveryDocument> } | undefined;\n\tlet keys: { at: number; value: Promise<JSONWebKeySet> } | undefined;\n\n\tasync function getJson(url: string, code: OidcErrorCode): Promise<unknown> {\n\t\tlet response: Response;\n\t\ttry {\n\t\t\tresponse = await config.fetch(url, {\n\t\t\t\theaders: { accept: 'application/json' },\n\t\t\t});\n\t\t} catch (cause) {\n\t\t\tthrow new OidcError(code, `Could not reach ${url}.`, undefined, {\n\t\t\t\tcause,\n\t\t\t});\n\t\t}\n\t\tif (!response.ok) {\n\t\t\tthrow new OidcError(code, `${url} answered ${response.status}.`);\n\t\t}\n\t\treturn response.json().catch(() => {\n\t\t\tthrow new OidcError(code, `${url} did not answer JSON.`);\n\t\t});\n\t}\n\n\tasync function loadDiscovery(): Promise<DiscoveryDocument> {\n\t\tconst url = `${issuer.replace(/\\/$/, '')}/.well-known/openid-configuration`;\n\t\tconst body = await getJson(url, 'discovery-failed');\n\t\tif (\n\t\t\t!isRecord(body) ||\n\t\t\t!text(body['authorization_endpoint']) ||\n\t\t\t!text(body['token_endpoint']) ||\n\t\t\t!text(body['jwks_uri'])\n\t\t) {\n\t\t\tthrow new OidcError(\n\t\t\t\t'discovery-failed',\n\t\t\t\t`${url} lacks authorization_endpoint, token_endpoint or jwks_uri.`,\n\t\t\t);\n\t\t}\n\t\tfor (const key of [\n\t\t\t'authorization_endpoint',\n\t\t\t'token_endpoint',\n\t\t\t'jwks_uri',\n\t\t]) {\n\t\t\tconst endpoint = new URL(String(body[key]));\n\t\t\tconst loopback = ['localhost', '127.0.0.1', '[::1]'].includes(\n\t\t\t\tendpoint.hostname,\n\t\t\t);\n\t\t\tif (\n\t\t\t\tendpoint.protocol !== 'https:' &&\n\t\t\t\t!(loopback && endpoint.protocol === 'http:')\n\t\t\t) {\n\t\t\t\tthrow new OidcError(\n\t\t\t\t\t'discovery-failed',\n\t\t\t\t\t`${url} gives a ${key} that is not https.`,\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t\tif (body['issuer'] !== issuer) {\n\t\t\tthrow new OidcError(\n\t\t\t\t'issuer-mismatch',\n\t\t\t\t`${url} names the issuer ${JSON.stringify(body['issuer'])}, not ${JSON.stringify(issuer)}.`,\n\t\t\t);\n\t\t}\n\t\treturn body as unknown as DiscoveryDocument;\n\t}\n\n\tconst discover = (): Promise<DiscoveryDocument> => {\n\t\tif (!discovery || now() - discovery.at > DISCOVERY_TTL) {\n\t\t\tconst value = loadDiscovery();\n\t\t\tconst entry = { at: now(), value };\n\t\t\tdiscovery = entry;\n\t\t\tvalue.catch(() => {\n\t\t\t\tif (discovery === entry) discovery = undefined;\n\t\t\t});\n\t\t}\n\t\treturn discovery.value;\n\t};\n\n\tasync function jwks(force: boolean): Promise<JSONWebKeySet> {\n\t\tif (force || !keys || now() - keys.at > JWKS_TTL) {\n\t\t\tconst value = discover().then(\n\t\t\t\tasync (document) =>\n\t\t\t\t\t(await getJson(\n\t\t\t\t\t\tdocument.jwks_uri,\n\t\t\t\t\t\t'invalid-id-token',\n\t\t\t\t\t)) as JSONWebKeySet,\n\t\t\t);\n\t\t\tconst entry = { at: now(), value };\n\t\t\tkeys = entry;\n\t\t\tvalue.catch(() => {\n\t\t\t\tif (keys === entry) keys = undefined;\n\t\t\t});\n\t\t}\n\t\treturn keys.value;\n\t}\n\n\t/**\n\t * Verify an id token: signature against the issuer's keys (refetched once\n\t * when the `kid` is unknown), `iss`, `aud` (and `azp` when several), `exp`.\n\t * `nonce` is checked when given (the code exchange, not a refresh).\n\t */\n\tasync function verifyIdToken(\n\t\tidToken: string,\n\t\tclientId: string,\n\t\tnonce?: string,\n\t): Promise<JWTPayload> {\n\t\tconst document = await discover();\n\t\tconst check = async (force: boolean) =>\n\t\t\tjwtVerify(idToken, createLocalJWKSet(await jwks(force)), {\n\t\t\t\tissuer: document.issuer,\n\t\t\t\taudience: clientId,\n\t\t\t\talgorithms: config.algorithms,\n\t\t\t\tclockTolerance: config.clockToleranceSeconds,\n\t\t\t\tcurrentDate: new Date(now()),\n\t\t\t\trequiredClaims: ['exp', 'iat', 'sub'],\n\t\t\t});\n\t\tlet payload: JWTPayload;\n\t\ttry {\n\t\t\ttry {\n\t\t\t\t({ payload } = await check(false));\n\t\t\t} catch (error) {\n\t\t\t\tif (!(error instanceof joseErrors.JWKSNoMatchingKey)) throw error;\n\t\t\t\t({ payload } = await check(true));\n\t\t\t}\n\t\t} catch (cause) {\n\t\t\tif (cause instanceof OidcError) throw cause;\n\t\t\tthrow new OidcError(\n\t\t\t\t'invalid-id-token',\n\t\t\t\t`The id token was refused: ${cause instanceof Error ? cause.message : String(cause)}`,\n\t\t\t\tundefined,\n\t\t\t\t{ cause },\n\t\t\t);\n\t\t}\n\t\tif (\n\t\t\tArray.isArray(payload.aud) &&\n\t\t\tpayload.aud.length > 1 &&\n\t\t\tpayload['azp'] !== clientId\n\t\t) {\n\t\t\tthrow new OidcError(\n\t\t\t\t'invalid-id-token',\n\t\t\t\t'The id token has several audiences and its azp is not this client.',\n\t\t\t);\n\t\t}\n\t\tif (nonce !== undefined && payload['nonce'] !== nonce) {\n\t\t\tthrow new OidcError(\n\t\t\t\t'nonce-mismatch',\n\t\t\t\t'The id token nonce is not the one this sign-in sent.',\n\t\t\t);\n\t\t}\n\t\treturn payload;\n\t}\n\n\treturn { discover, verifyIdToken };\n}\n\n/** What a request to the issuer needs to carry a DPoP proof: the session's key and the nonces seen. */\nexport interface DpopSigning {\n\treadonly key: DpopKey;\n\treadonly nonces: NonceMemory;\n\treadonly now: () => number;\n}\n\ntype Client = { readonly id: string; readonly secret?: string | undefined };\n\n/**\n * POST a form to the issuer with the client's authentication (basic for a\n * confidential client, `client_id` in the body for a public one) and, with\n * `dpop`, a DPoP proof; a `use_dpop_nonce` answer is retried once with the\n * nonce the issuer sent, which is remembered for the next call.\n */\nasync function postForm(\n\tfetcher: Fetcher,\n\tendpoint: string,\n\tclient: Client,\n\tparams: Record<string, string>,\n\tcode: OidcErrorCode,\n\twhat: string,\n\tdpop?: DpopSigning,\n\tsignal?: AbortSignal,\n): Promise<{ response: Response; answer: unknown }> {\n\tconst body = new URLSearchParams(params);\n\tconst headers: Record<string, string> = {\n\t\t'content-type': 'application/x-www-form-urlencoded',\n\t\taccept: 'application/json',\n\t};\n\tif (client.secret === undefined) {\n\t\tbody.set('client_id', client.id);\n\t} else {\n\t\t// client_secret_basic: both parts form-urlencoded first (RFC 6749 2.3.1).\n\t\tconst pair = `${encodeURIComponent(client.id)}:${encodeURIComponent(client.secret)}`;\n\t\theaders['authorization'] = `Basic ${btoa(pair)}`;\n\t}\n\tconst send = async (nonce: string | undefined): Promise<Response> => {\n\t\tconst sent = dpop\n\t\t\t? {\n\t\t\t\t\t...headers,\n\t\t\t\t\tdpop: await signDpopProof(dpop.key, {\n\t\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\t\turl: endpoint,\n\t\t\t\t\t\tnonce,\n\t\t\t\t\t\tnow: dpop.now,\n\t\t\t\t\t}),\n\t\t\t\t}\n\t\t\t: headers;\n\t\ttry {\n\t\t\tconst response = await fetcher(endpoint, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders: sent,\n\t\t\t\tbody,\n\t\t\t\t...(signal && { signal }),\n\t\t\t});\n\t\t\tconst given = response.headers.get('dpop-nonce');\n\t\t\tif (dpop && given) dpop.nonces.set(endpoint, given);\n\t\t\treturn response;\n\t\t} catch (cause) {\n\t\t\tthrow new OidcError(\n\t\t\t\tcode,\n\t\t\t\t`The ${what} could not be reached.`,\n\t\t\t\tundefined,\n\t\t\t\t{ cause },\n\t\t\t);\n\t\t}\n\t};\n\tlet response = await send(dpop?.nonces.get(endpoint));\n\tif (dpop && (await wantsNonce(response))) {\n\t\tawait response.body?.cancel().catch(() => undefined);\n\t\tresponse = await send(response.headers.get('dpop-nonce') ?? undefined);\n\t}\n\tconst answer: unknown = await response.json().catch(() => null);\n\treturn { response, answer };\n}\n\nconst detailOf = (answer: unknown): string =>\n\tisRecord(answer)\n\t\t? [answer['error'], answer['error_description']].filter(text).join(': ')\n\t\t: '';\n\n/** POST to the token endpoint; `error` and `description` come from the issuer. */\nexport async function tokenRequest(\n\tfetcher: Fetcher,\n\tendpoint: string,\n\tclient: Client,\n\tparams: Record<string, string>,\n\tcode: OidcErrorCode,\n\tdpop?: DpopSigning,\n): Promise<TokenResponse> {\n\tconst { response, answer } = await postForm(\n\t\tfetcher,\n\t\tendpoint,\n\t\tclient,\n\t\tparams,\n\t\tcode,\n\t\t'token endpoint',\n\t\tdpop,\n\t);\n\tif (!response.ok || !isRecord(answer) || !text(answer['access_token'])) {\n\t\tconst detail = detailOf(answer);\n\t\tthrow new OidcError(\n\t\t\tcode,\n\t\t\t`The token endpoint answered ${response.status}${detail ? ` (${detail})` : ''}.`,\n\t\t);\n\t}\n\tconst type = String(answer['token_type'] ?? 'bearer').toLowerCase();\n\tif (type !== 'bearer' && !(dpop && type === 'dpop')) {\n\t\tthrow new OidcError(\n\t\t\tcode,\n\t\t\t'The token endpoint did not issue a bearer token.',\n\t\t);\n\t}\n\treturn answer as unknown as TokenResponse;\n}\n\n/**\n * POST one token to the revocation endpoint (RFC 7009), with the client's authentication\n * and the DPoP proof when the tokens are bound. Throws `OidcError('revoke-failed')` on a\n * network error or a non-2xx answer.\n */\nexport async function revokeRequest(\n\tfetcher: Fetcher,\n\tendpoint: string,\n\tclient: Client,\n\tparams: { readonly token: string; readonly token_type_hint: string },\n\tdpop?: DpopSigning,\n\tsignal?: AbortSignal,\n): Promise<void> {\n\tconst { response, answer } = await postForm(\n\t\tfetcher,\n\t\tendpoint,\n\t\tclient,\n\t\tparams,\n\t\t'revoke-failed',\n\t\t'revocation endpoint',\n\t\tdpop,\n\t\tsignal,\n\t);\n\tif (!response.ok) {\n\t\tconst detail = detailOf(answer);\n\t\tthrow new OidcError(\n\t\t\t'revoke-failed',\n\t\t\t`The revocation endpoint answered ${response.status}${detail ? ` (${detail})` : ''}.`,\n\t\t);\n\t}\n}\n\n/** POST the authorization request to the pushed authorization request endpoint (RFC 9126): the `request_uri` to redirect with. */\nexport async function pushRequest(\n\tfetcher: Fetcher,\n\tendpoint: string,\n\tclient: Client,\n\tparams: Record<string, string>,\n\tdpop?: DpopSigning,\n): Promise<string> {\n\tconst { response, answer } = await postForm(\n\t\tfetcher,\n\t\tendpoint,\n\t\tclient,\n\t\tparams,\n\t\t'par-failed',\n\t\t'pushed authorization request endpoint',\n\t\tdpop,\n\t);\n\tif (!response.ok || !isRecord(answer) || !text(answer['request_uri'])) {\n\t\tconst detail = detailOf(answer);\n\t\tthrow new OidcError(\n\t\t\t'par-failed',\n\t\t\t`The pushed authorization request endpoint answered ${response.status}${detail ? ` (${detail})` : ''}.`,\n\t\t);\n\t}\n\treturn answer['request_uri'];\n}\n\nexport { decodeJwt };\n",
|
|
10
|
+
"import type { DpopKey } from './dpop';\nimport { OidcError } from './errors';\nimport type { DpopSigning, Fetcher } from './flow';\nimport { revokeRequest } from './flow';\n\n/** What `revokeTokens` needs: the sealed session's tokens and, when bound, its DPoP key. */\ninterface Revocable {\n\treadonly accessToken: string;\n\treadonly refreshToken?: string | undefined;\n\treadonly dpop?: DpopKey | undefined;\n}\n\n/**\n * Revoke the refresh token, then the access token (RFC 7009). Each failure is passed to\n * `report`, none is thrown. `timeoutMs` bounds both calls together: past it, the pending\n * call is aborted and reported as `revoke-failed`, and the other is not attempted.\n */\nexport async function revokeTokens(input: {\n\treadonly fetcher: Fetcher;\n\treadonly client: {\n\t\treadonly id: string;\n\t\treadonly secret?: string | undefined;\n\t};\n\treadonly endpoint: string;\n\treadonly stored: Revocable;\n\treadonly signing: (key: DpopKey | undefined) => DpopSigning | undefined;\n\treadonly timeoutMs: number;\n\treadonly report: (error: OidcError) => void;\n}): Promise<void> {\n\tconst { stored } = input;\n\tconst signal = AbortSignal.timeout(input.timeoutMs);\n\tconst timedOut = new Promise<never>((_, reject) => {\n\t\tsignal.addEventListener(\n\t\t\t'abort',\n\t\t\t() =>\n\t\t\t\treject(\n\t\t\t\t\tnew OidcError(\n\t\t\t\t\t\t'revoke-failed',\n\t\t\t\t\t\t`The revocation endpoint did not answer within ${input.timeoutMs} ms.`,\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t{ once: true },\n\t\t);\n\t});\n\ttimedOut.catch(() => undefined);\n\tconst tokens = [\n\t\t...(stored.refreshToken\n\t\t\t? ([[stored.refreshToken, 'refresh_token']] as const)\n\t\t\t: []),\n\t\t[stored.accessToken, 'access_token'] as const,\n\t];\n\tfor (const [token, hint] of tokens) {\n\t\ttry {\n\t\t\t// The race also ends a fetcher that ignores the signal.\n\t\t\tawait Promise.race([\n\t\t\t\trevokeRequest(\n\t\t\t\t\tinput.fetcher,\n\t\t\t\t\tinput.endpoint,\n\t\t\t\t\tinput.client,\n\t\t\t\t\t{ token, token_type_hint: hint },\n\t\t\t\t\tinput.signing(stored.dpop),\n\t\t\t\t\tsignal,\n\t\t\t\t),\n\t\t\t\ttimedOut,\n\t\t\t]);\n\t\t} catch (error) {\n\t\t\tinput.report(\n\t\t\t\terror instanceof OidcError\n\t\t\t\t\t? error\n\t\t\t\t\t: new OidcError('revoke-failed', 'Revocation failed.', undefined, {\n\t\t\t\t\t\t\tcause: error,\n\t\t\t\t\t\t}),\n\t\t\t);\n\t\t\tif (signal.aborted) return;\n\t\t}\n\t}\n}\n"
|
|
11
|
+
],
|
|
12
|
+
"mappings": ";;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAM,UAAU,IAAI;AACpB,IAAM,UAAU,IAAI;AAGb,IAAM,cAAc,CAAC,UAA8B;AAAA,EACzD,IAAI,SAAS;AAAA,EACb,WAAW,QAAQ;AAAA,IAAO,UAAU,OAAO,aAAa,IAAI;AAAA,EAC5D,OAAO,KAAK,MAAM,EAChB,WAAW,KAAK,GAAG,EACnB,WAAW,KAAK,GAAG,EACnB,WAAW,KAAK,EAAE;AAAA;AAGrB,IAAM,gBAAgB,CAAC,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;AAAA,QACd,QAAQ,IAAI,YAAY,QAAQ,yBAAyB,GAAG;AAAA,QAC5D,OAAO,IAAI,SAAS,MAAM,EAAE,QAAQ,KAAK,QAAQ,CAAC;AAAA,MACnD;AAAA,MACA,MAAM,SAAS,IAAI,IAAI,QAAQ;AAAA,MAC/B,IAAI,SAAS,MAAM;AAAA,QAClB,OAAO,aAAa,IAAI,iBAAiB,OAAO,OAAO;AAAA,MACxD,OAAO,aAAa,IAAI,aAAa,QAAQ;AAAA,MAC7C,IAAI,QAAQ,uBAAuB;AAAA,QAClC,OAAO,aAAa,IACnB,4BACA,QAAQ,qBACT;AAAA,MACD;AAAA,MACA,QAAQ,IAAI,YAAY,OAAO,SAAS,CAAC;AAAA,MACzC,OAAO,IAAI,SAAS,MAAM,EAAE,QAAQ,KAAK,QAAQ,CAAC;AAAA;AAAA,EAEpD;AAAA;",
|
|
13
|
+
"debugId": "4C0ACB0CB06F933D64756E2164756E21",
|
|
14
|
+
"names": []
|
|
15
|
+
}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { JWTPayload } from 'jose';
|
|
2
|
+
import { type DpopAlgorithm, type DpopBinding } from './dpop';
|
|
3
|
+
import { OidcError } from './errors';
|
|
4
|
+
import { type Fetcher } from './flow';
|
|
5
|
+
/** What `oidcClient` takes. */
|
|
6
|
+
export interface OidcOptions {
|
|
7
|
+
/** The issuer's identifier, exactly as its discovery document names it (no trailing slash needed). */
|
|
8
|
+
readonly issuer: string;
|
|
9
|
+
readonly clientId: string;
|
|
10
|
+
/** The secret of a confidential client, sent as `client_secret_basic`. Omit it for a public client. */
|
|
11
|
+
readonly clientSecret?: string | undefined;
|
|
12
|
+
/** The absolute URL of the route that calls `callback`; registered with the issuer. */
|
|
13
|
+
readonly redirectUri: string;
|
|
14
|
+
/** `['openid', 'profile', 'email']` by default; `openid` is always sent. Add `offline_access` for a refresh token. */
|
|
15
|
+
readonly scopes?: readonly string[] | undefined;
|
|
16
|
+
/** Seals the cookies (AES-256-GCM): at least 32 characters, from the environment, never committed. Changing it signs everyone out. */
|
|
17
|
+
readonly secret: string;
|
|
18
|
+
/** The base name of the cookies, e.g. `'my-app_oidc'`; `__Host-` is added when `secure`. */
|
|
19
|
+
readonly name: string;
|
|
20
|
+
/** The app is served over HTTPS. Required, never read from the environment: pass `!import.meta.env.DEV`. */
|
|
21
|
+
readonly secure: boolean;
|
|
22
|
+
/** The route that starts the sign-in (it calls `signIn`). `'/sign-in'` by default. */
|
|
23
|
+
readonly signInPath?: string | undefined;
|
|
24
|
+
/** Where the issuer sends the browser after `logout`; it must be registered with the issuer. */
|
|
25
|
+
readonly postLogoutRedirectUri?: string | undefined;
|
|
26
|
+
/** How long the token cookie lives when there is a refresh token. 30 days by default; otherwise it ends with the access token. */
|
|
27
|
+
readonly sessionSeconds?: number | undefined;
|
|
28
|
+
/** Refresh when the access token ends within this many seconds. 60 by default. */
|
|
29
|
+
readonly refreshSkewSeconds?: number | undefined;
|
|
30
|
+
/** Clock difference accepted on `exp` and `iat`. 30 by default. */
|
|
31
|
+
readonly clockToleranceSeconds?: number | undefined;
|
|
32
|
+
/** Id token signature algorithms accepted. `RS256`, `PS256`, `ES256` and `EdDSA` by default. */
|
|
33
|
+
readonly algorithms?: readonly string[] | undefined;
|
|
34
|
+
/** Extra parameters of the authorization request, e.g. `{ prompt: 'login' }`. */
|
|
35
|
+
readonly authorizationParams?: Readonly<Record<string, string>> | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Extra parameters of the token request, sent on the code exchange and on every refresh,
|
|
38
|
+
* e.g. `{ resource: 'https://api.example' }` (RFC 8707). The parameters the flow owns
|
|
39
|
+
* (`grant_type`, `code`, `redirect_uri`, `code_verifier`, `refresh_token`, `scope`) win over these, and `client_id` and `client_secret` are ignored.
|
|
40
|
+
*/
|
|
41
|
+
readonly tokenParams?: Readonly<Record<string, string>> | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Pushed authorization requests (RFC 9126): the authorization request is POSTed to the issuer's
|
|
44
|
+
* `pushed_authorization_request_endpoint` with the client's authentication, and the browser is
|
|
45
|
+
* redirected with `client_id` and `request_uri` alone.
|
|
46
|
+
* `'auto'` (default) pushes when discovery says `require_pushed_authorization_requests: true`;
|
|
47
|
+
* `'always'` pushes whatever discovery says (and fails with `par-failed` without an endpoint);
|
|
48
|
+
* `'never'` always sends the parameters in the redirect.
|
|
49
|
+
*/
|
|
50
|
+
readonly par?: 'auto' | 'always' | 'never' | undefined;
|
|
51
|
+
/**
|
|
52
|
+
* Binds the tokens to a key with DPoP (RFC 9449). Off by default. A key pair per sign-in
|
|
53
|
+
* (`ES256` by default, or `EdDSA`) is made at `signIn` and kept in the sealed cookies with the
|
|
54
|
+
* session; the token endpoint (code and refresh) gets a proof, a `use_dpop_nonce` answer is
|
|
55
|
+
* retried once with the nonce sent, and `OidcUser.dpop` signs the proofs of calls to a resource.
|
|
56
|
+
*/
|
|
57
|
+
readonly dpop?: {
|
|
58
|
+
readonly alg?: DpopAlgorithm | undefined;
|
|
59
|
+
} | undefined;
|
|
60
|
+
/**
|
|
61
|
+
* Revoke the refresh token and the access token at `logout` (RFC 7009). Off by default.
|
|
62
|
+
* When on and discovery has a `revocation_endpoint`, `logout` POSTs the refresh token
|
|
63
|
+
* (`token_type_hint=refresh_token`) then the access token (`token_type_hint=access_token`),
|
|
64
|
+
* with the client's authentication and the DPoP proof of the token endpoint. A failure
|
|
65
|
+
* (network error, non-2xx) never blocks the logout: the cookie is cleared and the redirect
|
|
66
|
+
* sent, and the failure goes to `onRevokeError`.
|
|
67
|
+
*/
|
|
68
|
+
readonly revokeOnLogout?: boolean | undefined;
|
|
69
|
+
/** The most `logout` waits for the revocations, in ms, both together. 3000 by default. A stalled endpoint is aborted and reported as `revoke-failed`; the sign-out goes on. */
|
|
70
|
+
readonly revokeTimeoutMs?: number | undefined;
|
|
71
|
+
/** Called with each revocation failure at `logout` (an `OidcError` with code `revoke-failed`, or `discovery-failed`). Nothing by default. */
|
|
72
|
+
readonly onRevokeError?: ((error: OidcError) => void) | undefined;
|
|
73
|
+
/** The `fetch` used for discovery, the keys and the token endpoint; global `fetch` by default. */
|
|
74
|
+
readonly fetch?: Fetcher | undefined;
|
|
75
|
+
/** The clock, in ms; `Date.now` by default. */
|
|
76
|
+
readonly now?: (() => number) | undefined;
|
|
77
|
+
}
|
|
78
|
+
/** The signed-in user a loader reads. */
|
|
79
|
+
export interface OidcUser {
|
|
80
|
+
/** The id token's claims. */
|
|
81
|
+
readonly claims: JWTPayload;
|
|
82
|
+
readonly accessToken: string;
|
|
83
|
+
readonly idToken: string;
|
|
84
|
+
/** When the access token ends, in ms. */
|
|
85
|
+
readonly expiresAt: number;
|
|
86
|
+
/** `Set-Cookie` when the tokens were refreshed, else empty: pass it with the loader's answer. */
|
|
87
|
+
readonly headers: Headers;
|
|
88
|
+
/** Signs the proofs of calls to a resource when the tokens are DPoP-bound (`dpop` option, and the issuer sent `token_type: DPoP`), else `null`. */
|
|
89
|
+
readonly dpop: DpopBinding | null;
|
|
90
|
+
}
|
|
91
|
+
/** The relying party `oidcClient` returns. */
|
|
92
|
+
export interface OidcClient {
|
|
93
|
+
/** The route action or loader that starts the sign-in: a redirect to the issuer. `?next=` is kept, through `safeNext`. */
|
|
94
|
+
signIn(request: Request): Promise<Response>;
|
|
95
|
+
/** The redirect route: checks state, exchanges the code, validates the id token, sets the token cookie and redirects to `next`. Throws `OidcError`. */
|
|
96
|
+
callback(request: Request): Promise<Response>;
|
|
97
|
+
/** The signed-in user (refreshed if due), or `null`. */
|
|
98
|
+
oidcUser(request: Request): Promise<OidcUser | null>;
|
|
99
|
+
/** Like `oidcUser`, but throws a redirect to the sign-in route (with a safe `next`) when there is none. */
|
|
100
|
+
requireOidcUser(request: Request): Promise<OidcUser>;
|
|
101
|
+
/** Clears the token cookie (after revoking the tokens with `revokeOnLogout`) and redirects to the issuer's `end_session_endpoint` (with `id_token_hint`), else to `postLogoutRedirectUri` or `/`. Call it from an action. */
|
|
102
|
+
logout(request: Request): Promise<Response>;
|
|
103
|
+
/** The cookie names as sent, prefixes included. */
|
|
104
|
+
readonly names: {
|
|
105
|
+
readonly session: string;
|
|
106
|
+
readonly challenge: string;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* A BFF as the relying party of an external OpenID Connect issuer:
|
|
111
|
+
* authorization code with PKCE (S256), state and nonce in a short-lived
|
|
112
|
+
* `__Host-` challenge cookie, discovery (cached), the code exchange, the id
|
|
113
|
+
* token validated against the issuer's keys (`jose`, an optional peer), the
|
|
114
|
+
* tokens in a sealed `__Host-` cookie, a single-flight refresh and
|
|
115
|
+
* RP-initiated logout.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* export const oidc = oidcClient({
|
|
119
|
+
* issuer: 'https://id.example.com',
|
|
120
|
+
* clientId: 'my-app',
|
|
121
|
+
* clientSecret: process.env.OIDC_CLIENT_SECRET,
|
|
122
|
+
* redirectUri: 'https://app.example.com/auth/callback',
|
|
123
|
+
* scopes: ['openid', 'profile', 'email', 'offline_access'],
|
|
124
|
+
* secret: process.env.SESSION_SECRET!,
|
|
125
|
+
* name: 'my-app_oidc',
|
|
126
|
+
* secure: !import.meta.env.DEV,
|
|
127
|
+
* });
|
|
128
|
+
* // routes/auth.callback.ts: export const loader = ({ request }) => oidc.callback(request);
|
|
129
|
+
* // any loader: const { claims, headers } = await oidc.requireOidcUser(request);
|
|
130
|
+
*/
|
|
131
|
+
export declare function oidcClient(options: OidcOptions): OidcClient;
|
|
132
|
+
//# sourceMappingURL=oidc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oidc.d.ts","sourceRoot":"","sources":["../../src/oidc/oidc.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAIvC,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,WAAW,EAMhB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,SAAS,E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AW,UAAU;IAC1B,0HAA0H;IAC1H,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC5C,uJAAuJ;IACvJ,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC9C,wDAAwD;IACxD,QAAQ,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC;IACrD,2GAA2G;IAC3G,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IACrD,6NAA6N;IAC7N,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC5C,mDAAmD;IACnD,QAAQ,CAAC,KAAK,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CACzE;AAkDD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,WAAW,GAAG,UAAU,CA2b3D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { DpopKey } from './dpop';
|
|
2
|
+
import { OidcError } from './errors';
|
|
3
|
+
import type { DpopSigning, Fetcher } from './flow';
|
|
4
|
+
/** What `revokeTokens` needs: the sealed session's tokens and, when bound, its DPoP key. */
|
|
5
|
+
interface Revocable {
|
|
6
|
+
readonly accessToken: string;
|
|
7
|
+
readonly refreshToken?: string | undefined;
|
|
8
|
+
readonly dpop?: DpopKey | undefined;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Revoke the refresh token, then the access token (RFC 7009). Each failure is passed to
|
|
12
|
+
* `report`, none is thrown. `timeoutMs` bounds both calls together: past it, the pending
|
|
13
|
+
* call is aborted and reported as `revoke-failed`, and the other is not attempted.
|
|
14
|
+
*/
|
|
15
|
+
export declare function revokeTokens(input: {
|
|
16
|
+
readonly fetcher: Fetcher;
|
|
17
|
+
readonly client: {
|
|
18
|
+
readonly id: string;
|
|
19
|
+
readonly secret?: string | undefined;
|
|
20
|
+
};
|
|
21
|
+
readonly endpoint: string;
|
|
22
|
+
readonly stored: Revocable;
|
|
23
|
+
readonly signing: (key: DpopKey | undefined) => DpopSigning | undefined;
|
|
24
|
+
readonly timeoutMs: number;
|
|
25
|
+
readonly report: (error: OidcError) => void;
|
|
26
|
+
}): Promise<void>;
|
|
27
|
+
export {};
|
|
28
|
+
//# sourceMappingURL=revoke.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"revoke.d.ts","sourceRoot":"","sources":["../../src/oidc/revoke.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAGnD,4FAA4F;AAC5F,UAAU,SAAS;IAClB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACpC;AAED;;;;GAIG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE;IACzC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE;QAChB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;KACrC,CAAC;IACF,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,OAAO,GAAG,SAAS,KAAK,WAAW,GAAG,SAAS,CAAC;IACxE,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,CAAC;CAC5C,GAAG,OAAO,CAAC,IAAI,CAAC,CAgDhB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Bytes as unpadded base64url. */
|
|
2
|
+
export declare const toBase64Url: (bytes: Uint8Array) => string;
|
|
3
|
+
/** `bytes` random bytes as base64url. */
|
|
4
|
+
export declare const randomToken: (bytes?: number) => string;
|
|
5
|
+
/** Whether two strings are equal, comparing every byte whatever the first difference. */
|
|
6
|
+
export declare function sameText(a: string, b: string): boolean;
|
|
7
|
+
/** The base64url S256 challenge of a PKCE verifier. */
|
|
8
|
+
export declare function s256(verifier: string): Promise<string>;
|
|
9
|
+
/**
|
|
10
|
+
* An AES-256-GCM sealer keyed from the session secret and a purpose, so a
|
|
11
|
+
* challenge cookie cannot be replayed as a token cookie: the value is
|
|
12
|
+
* encrypted (the tokens stay unreadable) and authenticated (nobody can forge
|
|
13
|
+
* or edit it).
|
|
14
|
+
*/
|
|
15
|
+
export declare function sealer(secret: string, purpose: string): {
|
|
16
|
+
seal(value: unknown): Promise<string>;
|
|
17
|
+
/** The value, or `null` when the text was not sealed with this secret and purpose. */
|
|
18
|
+
open(text: string): Promise<unknown>;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=seal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"seal.d.ts","sourceRoot":"","sources":["../../src/oidc/seal.ts"],"names":[],"mappings":"AAGA,mCAAmC;AACnC,eAAO,MAAM,WAAW,GAAI,OAAO,UAAU,KAAG,MAO/C,CAAC;AAQF,yCAAyC;AACzC,eAAO,MAAM,WAAW,GAAI,cAAU,KAAG,MACkB,CAAC;AAE5D,yFAAyF;AACzF,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAQtD;AAED,uDAAuD;AACvD,wBAAsB,IAAI,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAM5D;AAED;;;;;GAKG;AACH,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;gBAWlC,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;IAc3C,sFAAsF;eACrE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;EAe3C"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { PrecacheEntry } from '../model/precache-list';
|
|
2
|
+
import { type WorkerContract } from '../model/worker-contract';
|
|
3
|
+
export interface BuildWorkerOptions {
|
|
4
|
+
/**
|
|
5
|
+
* The worker's source, relative to `root`: `app/service-worker.ts`. Named
|
|
6
|
+
* `file`, not `entry`: `reveal` reads `alxia({ entry })`.
|
|
7
|
+
*/
|
|
8
|
+
file: string;
|
|
9
|
+
/** `process.cwd()` by default. */
|
|
10
|
+
root?: string;
|
|
11
|
+
/** The client build, relative to `root`: `build/client` by default. */
|
|
12
|
+
client?: string;
|
|
13
|
+
/** Where the worker is written and which offline page is precached. */
|
|
14
|
+
contract?: Pick<WorkerContract, 'serviceWorkerUrl' | 'offlineUrl'>;
|
|
15
|
+
/** Precache the offline page, which must then exist. `true` by default. */
|
|
16
|
+
offline?: boolean;
|
|
17
|
+
/** More files of `assets/` to precache, such as fonts: the app's regex. */
|
|
18
|
+
precacheAssets?: RegExp;
|
|
19
|
+
/** `true` by default. */
|
|
20
|
+
minify?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface WorkerBuild {
|
|
23
|
+
/** The absolute path of the worker written. */
|
|
24
|
+
file: string;
|
|
25
|
+
precache: PrecacheEntry[];
|
|
26
|
+
/** The precached files' size, before compression. */
|
|
27
|
+
precacheBytes: number;
|
|
28
|
+
/** The worker's own size. */
|
|
29
|
+
bytes: number;
|
|
30
|
+
}
|
|
31
|
+
/** Not `requireBun` of `vite/`: `/pwa/build` imports Node's built-ins only. */
|
|
32
|
+
export declare function assertBun(onBun?: boolean): void;
|
|
33
|
+
/**
|
|
34
|
+
* Bundles the worker (Workbox included) into the client build, after
|
|
35
|
+
* `react-router build`, with the precache list written in: the offline page
|
|
36
|
+
* by its content, every route's code and `precacheAssets`. A new build
|
|
37
|
+
* changes the list, so the worker's bytes, so the browser installs it.
|
|
38
|
+
* Runs on Bun; the only imports of this module are Node's built-ins.
|
|
39
|
+
*/
|
|
40
|
+
export declare function buildWorker(options: BuildWorkerOptions): Promise<WorkerBuild>;
|
|
41
|
+
//# sourceMappingURL=build-worker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-worker.d.ts","sourceRoot":"","sources":["../../../src/pwa/build/build-worker.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAGN,KAAK,cAAc,EACnB,MAAM,0BAA0B,CAAC;AAIlC,MAAM,WAAW,kBAAkB;IAClC;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uEAAuE;IACvE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,kBAAkB,GAAG,YAAY,CAAC,CAAC;IACnE,2EAA2E;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,2EAA2E;IAC3E,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,yBAAyB;IACzB,MAAM,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC3B,+CAA+C;IAC/C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,aAAa,EAAE,CAAC;IAC1B,qDAAqD;IACrD,aAAa,EAAE,MAAM,CAAC;IACtB,6BAA6B;IAC7B,KAAK,EAAE,MAAM,CAAC;CACd;AAED,+EAA+E;AAC/E,wBAAgB,SAAS,CACxB,KAAK,UAAsD,GACzD,IAAI,CAKN;AAoBD;;;;;;GAMG;AACH,wBAAsB,WAAW,CAChC,OAAO,EAAE,kBAAkB,GACzB,OAAO,CAAC,WAAW,CAAC,CAgEtB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@softistx/alxia-react-router/pwa/build`: bundles the service worker into the
|
|
3
|
+
* client build with its precache list. Run it on Bun, after
|
|
4
|
+
* `react-router build`. Node's built-ins are its only imports, and Bun's
|
|
5
|
+
* global is read inside the function, never at load.
|
|
6
|
+
*/
|
|
7
|
+
export type { BuildWorkerOptions, WorkerBuild } from './build-worker';
|
|
8
|
+
export { buildWorker } from './build-worker';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/pwa/build/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,YAAY,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACtE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type PrecacheEntry } from '../model/precache-list';
|
|
2
|
+
/** The one React Router browser manifest among the names in build/client/assets. */
|
|
3
|
+
export declare function browserManifestFile(files: readonly string[]): string;
|
|
4
|
+
/** A file's revision: the first 16 hex characters of its sha256. */
|
|
5
|
+
export declare function revisionOf(bytes: Uint8Array): string;
|
|
6
|
+
/**
|
|
7
|
+
* The worker's precache list: the offline page (revisioned by its content),
|
|
8
|
+
* every route's code, then the asset files `include` matches. Each URL once,
|
|
9
|
+
* the first kept.
|
|
10
|
+
*/
|
|
11
|
+
export declare function workerPrecache(input: {
|
|
12
|
+
manifestSource: string;
|
|
13
|
+
assetFiles: readonly string[];
|
|
14
|
+
offline?: PrecacheEntry | undefined;
|
|
15
|
+
include?: RegExp | undefined;
|
|
16
|
+
}): PrecacheEntry[];
|
|
17
|
+
//# sourceMappingURL=precache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"precache.d.ts","sourceRoot":"","sources":["../../../src/pwa/build/precache.ts"],"names":[],"mappings":"AACA,OAAO,EAEN,KAAK,aAAa,EAGlB,MAAM,wBAAwB,CAAC;AAEhC,oFAAoF;AACpF,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,GAAG,MAAM,CASpE;AAED,oEAAoE;AACpE,wBAAgB,UAAU,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE;IACrC,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,OAAO,CAAC,EAAE,aAAa,GAAG,SAAS,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC7B,GAAG,aAAa,EAAE,CAQlB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@softistx/alxia-react-router/pwa`: the code with no UI an installable app shares.
|
|
3
|
+
* No import at all, so the page, the service worker, a build script and the
|
|
4
|
+
* server can each import it.
|
|
5
|
+
*/
|
|
6
|
+
export { type Caching, type CachingOptions, cachingFor, type RequestFacts, } from './model/caching';
|
|
7
|
+
export { clearAppCaches } from './model/clear-app-caches';
|
|
8
|
+
export { fontPrecachePattern } from './model/font-precache';
|
|
9
|
+
export { MANIFEST_HEADERS, MANIFEST_PATH, type ManifestIcon, MINIMAL_2023_ICONS, manifestHref, manifestLanguage, type WebAppManifest, type WebAppManifestOptions, webAppManifest, } from './model/manifest';
|
|
10
|
+
export { assetPrecache, type BrowserManifest, type PrecacheEntry, parseBrowserManifest, precacheList, } from './model/precache-list';
|
|
11
|
+
export { type ApplyUpdate, afterLoad, createUpdater, type RegisterOptions, registerServiceWorker, type ServiceWorkerContainerLike, watchForUpdates, } from './model/registration';
|
|
12
|
+
export { isStorable } from './model/storable';
|
|
13
|
+
export { themeColorHex, themeColors } from './model/theme-color';
|
|
14
|
+
export { createUpdateNotice, type NoticeStorage, sessionStore, UPDATE_LATER_KEY, type UpdateNotice, type UpdateNoticeStore, } from './model/update-notice';
|
|
15
|
+
export { type CacheNames, defineWorkerContract, OFFLINE_URL, SERVICE_WORKER_URL, SKIP_WAITING, type WorkerContract, type WorkerContractOptions, } from './model/worker-contract';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/pwa/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACN,KAAK,OAAO,EACZ,KAAK,cAAc,EACnB,UAAU,EACV,KAAK,YAAY,GACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EACN,gBAAgB,EAChB,aAAa,EACb,KAAK,YAAY,EACjB,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,EAChB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,cAAc,GACd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACN,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,aAAa,EAClB,oBAAoB,EACpB,YAAY,GACZ,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,KAAK,WAAW,EAChB,SAAS,EACT,aAAa,EACb,KAAK,eAAe,EACpB,qBAAqB,EACrB,KAAK,0BAA0B,EAC/B,eAAe,GACf,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EACN,kBAAkB,EAClB,KAAK,aAAa,EAClB,YAAY,EACZ,gBAAgB,EAChB,KAAK,YAAY,EACjB,KAAK,iBAAiB,GACtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACN,KAAK,UAAU,EACf,oBAAoB,EACpB,WAAW,EACX,kBAAkB,EAClB,YAAY,EACZ,KAAK,cAAc,EACnB,KAAK,qBAAqB,GAC1B,MAAM,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MANIFEST_PATH2,
|
|
3
|
+
MANIFEST_HEADERS2,
|
|
4
|
+
manifestHref2,
|
|
5
|
+
manifestLanguage2,
|
|
6
|
+
MINIMAL_2023_ICONS2,
|
|
7
|
+
webAppManifest2,
|
|
8
|
+
cachingFor2,
|
|
9
|
+
isStorable2
|
|
10
|
+
} from "../chunks/index-zdbqzcjp.js";
|
|
11
|
+
import {
|
|
12
|
+
parseBrowserManifest2,
|
|
13
|
+
precacheList2,
|
|
14
|
+
assetPrecache2
|
|
15
|
+
} from "../chunks/index-5gqcpyyg.js";
|
|
16
|
+
import {
|
|
17
|
+
watchForUpdates2,
|
|
18
|
+
createUpdater2,
|
|
19
|
+
afterLoad2,
|
|
20
|
+
registerServiceWorker2,
|
|
21
|
+
UPDATE_LATER_KEY2,
|
|
22
|
+
createUpdateNotice2,
|
|
23
|
+
sessionStore2
|
|
24
|
+
} from "../chunks/index-9xv2a8et.js";
|
|
25
|
+
import {
|
|
26
|
+
SERVICE_WORKER_URL2,
|
|
27
|
+
OFFLINE_URL2,
|
|
28
|
+
SKIP_WAITING2,
|
|
29
|
+
defineWorkerContract2
|
|
30
|
+
} from "../chunks/index-rfr02vg4.js";
|
|
31
|
+
// src/pwa/model/clear-app-caches.ts
|
|
32
|
+
async function clearAppCaches(contract) {
|
|
33
|
+
if (typeof caches === "undefined")
|
|
34
|
+
return;
|
|
35
|
+
const names = contract.clearableCaches(await caches.keys());
|
|
36
|
+
await Promise.all(names.map((name) => caches.delete(name)));
|
|
37
|
+
}
|
|
38
|
+
// src/pwa/model/font-precache.ts
|
|
39
|
+
function fontPrecachePattern(families) {
|
|
40
|
+
if (families.length === 0) {
|
|
41
|
+
throw new Error("fontPrecachePattern(): give at least one font family file stem.");
|
|
42
|
+
}
|
|
43
|
+
const stems = families.map((family) => family.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"));
|
|
44
|
+
return new RegExp(`^(?:${stems.join("|")})-[\\w-]{8}\\.woff2$`);
|
|
45
|
+
}
|
|
46
|
+
// src/pwa/model/theme-color.ts
|
|
47
|
+
var HEX = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
48
|
+
var OKLCH = /^oklch\(\s*([\d.]+)(%?)\s+([\d.]+)\s+([\d.]+)(?:deg)?\s*(?:\/\s*[\d.]+%?\s*)?\)$/i;
|
|
49
|
+
var channel = (linear) => {
|
|
50
|
+
const clamped = Math.min(1, Math.max(0, linear));
|
|
51
|
+
const encoded = clamped <= 0.0031308 ? 12.92 * clamped : 1.055 * clamped ** (1 / 2.4) - 0.055;
|
|
52
|
+
return Math.round(encoded * 255).toString(16).padStart(2, "0");
|
|
53
|
+
};
|
|
54
|
+
function themeColorHex(token) {
|
|
55
|
+
const value = token.trim();
|
|
56
|
+
if (HEX.test(value)) {
|
|
57
|
+
const digits = value.slice(1).toLowerCase();
|
|
58
|
+
return digits.length === 3 ? `#${[...digits].map((d) => d + d).join("")}` : `#${digits}`;
|
|
59
|
+
}
|
|
60
|
+
const match = OKLCH.exec(value);
|
|
61
|
+
if (!match) {
|
|
62
|
+
throw new Error(`themeColorHex(): "${token}" is neither #rgb, #rrggbb nor oklch(L C H).`);
|
|
63
|
+
}
|
|
64
|
+
const lightness = Number(match[1]) / (match[2] === "%" ? 100 : 1);
|
|
65
|
+
const chroma = Number(match[3]);
|
|
66
|
+
const hue = Number(match[4]) * Math.PI / 180;
|
|
67
|
+
const a = chroma * Math.cos(hue);
|
|
68
|
+
const b = chroma * Math.sin(hue);
|
|
69
|
+
const l = (lightness + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
70
|
+
const m = (lightness - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
71
|
+
const s = (lightness - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
72
|
+
const red = 4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s;
|
|
73
|
+
const green = -1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s;
|
|
74
|
+
const blue = -0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s;
|
|
75
|
+
return `#${channel(red)}${channel(green)}${channel(blue)}`;
|
|
76
|
+
}
|
|
77
|
+
function themeColors(tokens) {
|
|
78
|
+
return Object.fromEntries(Object.entries(tokens).map(([key, token]) => [key, themeColorHex(token)]));
|
|
79
|
+
}
|
|
80
|
+
export {
|
|
81
|
+
MANIFEST_HEADERS2 as MANIFEST_HEADERS,
|
|
82
|
+
MANIFEST_PATH2 as MANIFEST_PATH,
|
|
83
|
+
MINIMAL_2023_ICONS2 as MINIMAL_2023_ICONS,
|
|
84
|
+
OFFLINE_URL2 as OFFLINE_URL,
|
|
85
|
+
SERVICE_WORKER_URL2 as SERVICE_WORKER_URL,
|
|
86
|
+
SKIP_WAITING2 as SKIP_WAITING,
|
|
87
|
+
UPDATE_LATER_KEY2 as UPDATE_LATER_KEY,
|
|
88
|
+
afterLoad2 as afterLoad,
|
|
89
|
+
assetPrecache2 as assetPrecache,
|
|
90
|
+
cachingFor2 as cachingFor,
|
|
91
|
+
clearAppCaches,
|
|
92
|
+
createUpdateNotice2 as createUpdateNotice,
|
|
93
|
+
createUpdater2 as createUpdater,
|
|
94
|
+
defineWorkerContract2 as defineWorkerContract,
|
|
95
|
+
fontPrecachePattern,
|
|
96
|
+
isStorable2 as isStorable,
|
|
97
|
+
manifestHref2 as manifestHref,
|
|
98
|
+
manifestLanguage2 as manifestLanguage,
|
|
99
|
+
parseBrowserManifest2 as parseBrowserManifest,
|
|
100
|
+
precacheList2 as precacheList,
|
|
101
|
+
registerServiceWorker2 as registerServiceWorker,
|
|
102
|
+
sessionStore2 as sessionStore,
|
|
103
|
+
themeColorHex,
|
|
104
|
+
themeColors,
|
|
105
|
+
watchForUpdates2 as watchForUpdates,
|
|
106
|
+
webAppManifest2 as webAppManifest
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
//# debugId=680F9D91EEDD64A064756E2164756E21
|
|
110
|
+
//# sourceMappingURL=index.js.map
|