@softistx/alxia-react-router 0.0.0-stage → 0.83.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +2085 -2
- package/dist/api-keys/api-keys.d.ts +93 -0
- package/dist/api-keys/api-keys.d.ts.map +1 -0
- package/dist/api-keys/index.d.ts +9 -0
- package/dist/api-keys/index.d.ts.map +1 -0
- package/dist/api-keys/index.js +66 -0
- package/dist/api-keys/index.js.map +10 -0
- package/dist/assets.d.ts +14 -0
- package/dist/assets.d.ts.map +1 -0
- package/dist/chunks/index-0786n4qe.js +25 -0
- package/dist/chunks/index-0786n4qe.js.map +10 -0
- package/dist/chunks/index-1nw5yeek.js +169 -0
- package/dist/chunks/index-1nw5yeek.js.map +11 -0
- package/dist/chunks/index-59vhfj6n.js +10 -0
- package/dist/chunks/index-59vhfj6n.js.map +10 -0
- package/dist/chunks/index-5gqcpyyg.js +34 -0
- package/dist/chunks/index-5gqcpyyg.js.map +10 -0
- package/dist/chunks/index-6jf7zpxz.js +119 -0
- package/dist/chunks/index-6jf7zpxz.js.map +11 -0
- package/dist/chunks/index-8as4j8m3.js +340 -0
- package/dist/chunks/index-8as4j8m3.js.map +16 -0
- package/dist/chunks/index-9xv2a8et.js +108 -0
- package/dist/chunks/index-9xv2a8et.js.map +11 -0
- package/dist/chunks/index-ajtvyq35.js +16 -0
- package/dist/chunks/index-ajtvyq35.js.map +10 -0
- package/dist/chunks/index-c55hxgr5.js +124 -0
- package/dist/chunks/index-c55hxgr5.js.map +14 -0
- package/dist/chunks/index-d42p3mdp.js +19 -0
- package/dist/chunks/index-d42p3mdp.js.map +10 -0
- package/dist/chunks/index-gac44rs5.js +42 -0
- package/dist/chunks/index-gac44rs5.js.map +11 -0
- package/dist/chunks/index-j4ktpcke.js +62 -0
- package/dist/chunks/index-j4ktpcke.js.map +10 -0
- package/dist/chunks/index-mscfme4r.js +12 -0
- package/dist/chunks/index-mscfme4r.js.map +10 -0
- package/dist/chunks/index-pghmb2dm.js +30 -0
- package/dist/chunks/index-pghmb2dm.js.map +10 -0
- package/dist/chunks/index-rfr02vg4.js +40 -0
- package/dist/chunks/index-rfr02vg4.js.map +10 -0
- package/dist/chunks/index-sfhshxqz.js +31 -0
- package/dist/chunks/index-sfhshxqz.js.map +10 -0
- package/dist/chunks/index-skwypsjz.js +357 -0
- package/dist/chunks/index-skwypsjz.js.map +12 -0
- package/dist/chunks/index-sxh06ged.js +118 -0
- package/dist/chunks/index-sxh06ged.js.map +11 -0
- package/dist/chunks/index-t2ph23wk.js +96 -0
- package/dist/chunks/index-t2ph23wk.js.map +13 -0
- package/dist/chunks/index-thyabr5n.js +19 -0
- package/dist/chunks/index-thyabr5n.js.map +10 -0
- package/dist/chunks/index-tx36swjx.js +134 -0
- package/dist/chunks/index-tx36swjx.js.map +11 -0
- package/dist/chunks/index-v2z5k640.js +54 -0
- package/dist/chunks/index-v2z5k640.js.map +11 -0
- package/dist/chunks/index-vr82typq.js +23 -0
- package/dist/chunks/index-vr82typq.js.map +11 -0
- package/dist/chunks/index-whj6h5eg.js +9 -0
- package/dist/chunks/index-whj6h5eg.js.map +10 -0
- package/dist/chunks/index-wyypkfdv.js +130 -0
- package/dist/chunks/index-wyypkfdv.js.map +13 -0
- package/dist/chunks/index-xd5aqy3g.js +90 -0
- package/dist/chunks/index-xd5aqy3g.js.map +10 -0
- package/dist/chunks/index-zdbqzcjp.js +97 -0
- package/dist/chunks/index-zdbqzcjp.js.map +12 -0
- package/dist/chunks/index-zyg8amjc.js +23 -0
- package/dist/chunks/index-zyg8amjc.js.map +10 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +215 -0
- package/dist/cli/index.js.map +13 -0
- package/dist/cli/main.d.ts +13 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/reveal.d.ts +18 -0
- package/dist/cli/reveal.d.ts.map +1 -0
- package/dist/cli/template.d.ts +8 -0
- package/dist/cli/template.d.ts.map +1 -0
- package/dist/context.d.ts +104 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/document/index.d.ts +11 -0
- package/dist/document/index.d.ts.map +1 -0
- package/dist/document/index.js +19 -0
- package/dist/document/index.js.map +9 -0
- package/dist/document/inline-script.d.ts +27 -0
- package/dist/document/inline-script.d.ts.map +1 -0
- package/dist/document/language-store.d.ts +8 -0
- package/dist/document/language-store.d.ts.map +1 -0
- package/dist/document/nonce.d.ts +34 -0
- package/dist/document/nonce.d.ts.map +1 -0
- package/dist/document/page-language.d.ts +39 -0
- package/dist/document/page-language.d.ts.map +1 -0
- package/dist/document/text-direction.d.ts +10 -0
- package/dist/document/text-direction.d.ts.map +1 -0
- package/dist/entry/abort.d.ts +21 -0
- package/dist/entry/abort.d.ts.map +1 -0
- package/dist/entry/create-entry.d.ts +41 -0
- package/dist/entry/create-entry.d.ts.map +1 -0
- package/dist/entry/index.d.ts +8 -0
- package/dist/entry/index.d.ts.map +1 -0
- package/dist/entry/index.js +154 -0
- package/dist/entry/index.js.map +13 -0
- package/dist/entry/root-data.d.ts +27 -0
- package/dist/entry/root-data.d.ts.map +1 -0
- package/dist/entry/whole-page.d.ts +10 -0
- package/dist/entry/whole-page.d.ts.map +1 -0
- package/dist/errors/api-error.d.ts +117 -0
- package/dist/errors/api-error.d.ts.map +1 -0
- package/dist/errors/api-errors.d.ts +122 -0
- package/dist/errors/api-errors.d.ts.map +1 -0
- package/dist/errors/call-failure.d.ts +45 -0
- package/dist/errors/call-failure.d.ts.map +1 -0
- package/dist/errors/catalogue-check.d.ts +24 -0
- package/dist/errors/catalogue-check.d.ts.map +1 -0
- package/dist/errors/catalogue-read.d.ts +33 -0
- package/dist/errors/catalogue-read.d.ts.map +1 -0
- package/dist/errors/catalogue.d.ts +59 -0
- package/dist/errors/catalogue.d.ts.map +1 -0
- package/dist/errors/code-resolver.d.ts +44 -0
- package/dist/errors/code-resolver.d.ts.map +1 -0
- package/dist/errors/cross-site.d.ts +8 -0
- package/dist/errors/cross-site.d.ts.map +1 -0
- package/dist/errors/describe-refusal.d.ts +6 -0
- package/dist/errors/describe-refusal.d.ts.map +1 -0
- package/dist/errors/describe.d.ts +3 -0
- package/dist/errors/describe.d.ts.map +1 -0
- package/dist/errors/fetcher-result.d.ts +33 -0
- package/dist/errors/fetcher-result.d.ts.map +1 -0
- package/dist/errors/field-placement.d.ts +12 -0
- package/dist/errors/field-placement.d.ts.map +1 -0
- package/dist/errors/form-errors.d.ts +8 -0
- package/dist/errors/form-errors.d.ts.map +1 -0
- package/dist/errors/form-refusal.d.ts +25 -0
- package/dist/errors/form-refusal.d.ts.map +1 -0
- package/dist/errors/index.d.ts +21 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +588 -0
- package/dist/errors/index.js.map +26 -0
- package/dist/errors/json-actions.d.ts +38 -0
- package/dist/errors/json-actions.d.ts.map +1 -0
- package/dist/errors/log.d.ts +8 -0
- package/dist/errors/log.d.ts.map +1 -0
- package/dist/errors/message-values.d.ts +11 -0
- package/dist/errors/message-values.d.ts.map +1 -0
- package/dist/errors/messages.d.ts +63 -0
- package/dist/errors/messages.d.ts.map +1 -0
- package/dist/errors/page-path.d.ts +9 -0
- package/dist/errors/page-path.d.ts.map +1 -0
- package/dist/errors/problem-error.d.ts +50 -0
- package/dist/errors/problem-error.d.ts.map +1 -0
- package/dist/errors/provider.d.ts +20 -0
- package/dist/errors/provider.d.ts.map +1 -0
- package/dist/errors/request-id.d.ts +5 -0
- package/dist/errors/request-id.d.ts.map +1 -0
- package/dist/errors/route-error.d.ts +33 -0
- package/dist/errors/route-error.d.ts.map +1 -0
- package/dist/errors/route-refusal.d.ts +20 -0
- package/dist/errors/route-refusal.d.ts.map +1 -0
- package/dist/errors/same-site.d.ts +49 -0
- package/dist/errors/same-site.d.ts.map +1 -0
- package/dist/errors/section-action.d.ts +46 -0
- package/dist/errors/section-action.d.ts.map +1 -0
- package/dist/errors/standard-schema.d.ts +34 -0
- package/dist/errors/standard-schema.d.ts.map +1 -0
- package/dist/errors/submit-form.d.ts +16 -0
- package/dist/errors/submit-form.d.ts.map +1 -0
- package/dist/errors/upstream-headers.d.ts +18 -0
- package/dist/errors/upstream-headers.d.ts.map +1 -0
- package/dist/errors/use-json-fetcher.d.ts +18 -0
- package/dist/errors/use-json-fetcher.d.ts.map +1 -0
- package/dist/fetcher/auth-refusal.d.ts +29 -0
- package/dist/fetcher/auth-refusal.d.ts.map +1 -0
- package/dist/fetcher/index.d.ts +20 -0
- package/dist/fetcher/index.d.ts.map +1 -0
- package/dist/fetcher/index.js +392 -0
- package/dist/fetcher/index.js.map +21 -0
- package/dist/fetcher/section-form.d.ts +24 -0
- package/dist/fetcher/section-form.d.ts.map +1 -0
- package/dist/fetcher/section-reload.d.ts +17 -0
- package/dist/fetcher/section-reload.d.ts.map +1 -0
- package/dist/fetcher/section-save.d.ts +29 -0
- package/dist/fetcher/section-save.d.ts.map +1 -0
- package/dist/fetcher/use-debounced-fetcher.d.ts +57 -0
- package/dist/fetcher/use-debounced-fetcher.d.ts.map +1 -0
- package/dist/fetcher/use-fetcher-answer.d.ts +16 -0
- package/dist/fetcher/use-fetcher-answer.d.ts.map +1 -0
- package/dist/fetcher/use-fetcher-done.d.ts +15 -0
- package/dist/fetcher/use-fetcher-done.d.ts.map +1 -0
- package/dist/fetcher/use-fetcher-promise.d.ts +48 -0
- package/dist/fetcher/use-fetcher-promise.d.ts.map +1 -0
- package/dist/fetcher/use-form-refusal.d.ts +20 -0
- package/dist/fetcher/use-form-refusal.d.ts.map +1 -0
- package/dist/fetcher/use-revalidate-on-focus.d.ts +20 -0
- package/dist/fetcher/use-revalidate-on-focus.d.ts.map +1 -0
- package/dist/fetcher/use-row-save.d.ts +32 -0
- package/dist/fetcher/use-row-save.d.ts.map +1 -0
- package/dist/fetcher/use-section-save.d.ts +46 -0
- package/dist/fetcher/use-section-save.d.ts.map +1 -0
- package/dist/fetcher/use-visible-interval.d.ts +24 -0
- package/dist/fetcher/use-visible-interval.d.ts.map +1 -0
- package/dist/fetcher/use-visible-revalidation.d.ts +10 -0
- package/dist/fetcher/use-visible-revalidation.d.ts.map +1 -0
- package/dist/health.d.ts +21 -0
- package/dist/health.d.ts.map +1 -0
- package/dist/help/check/check.d.ts +35 -0
- package/dist/help/check/check.d.ts.map +1 -0
- package/dist/help/check/index.d.ts +8 -0
- package/dist/help/check/index.d.ts.map +1 -0
- package/dist/help/check/index.js +17 -0
- package/dist/help/check/index.js.map +9 -0
- package/dist/help/check/routes.d.ts +22 -0
- package/dist/help/check/routes.d.ts.map +1 -0
- package/dist/help/guide.d.ts +33 -0
- package/dist/help/guide.d.ts.map +1 -0
- package/dist/help/index.d.ts +16 -0
- package/dist/help/index.d.ts.map +1 -0
- package/dist/help/index.js +192 -0
- package/dist/help/index.js.map +14 -0
- package/dist/help/load.d.ts +39 -0
- package/dist/help/load.d.ts.map +1 -0
- package/dist/help/panel.d.ts +69 -0
- package/dist/help/panel.d.ts.map +1 -0
- package/dist/help/parse-flow.d.ts +27 -0
- package/dist/help/parse-flow.d.ts.map +1 -0
- package/dist/help/react.d.ts +12 -0
- package/dist/help/react.d.ts.map +1 -0
- package/dist/help/resolve.d.ts +24 -0
- package/dist/help/resolve.d.ts.map +1 -0
- package/dist/help/types.d.ts +50 -0
- package/dist/help/types.d.ts.map +1 -0
- package/dist/help/yaml.d.ts +18 -0
- package/dist/help/yaml.d.ts.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +197 -0
- package/dist/index.js.map +14 -0
- package/dist/link/index.d.ts +7 -0
- package/dist/link/index.d.ts.map +1 -0
- package/dist/link/index.js +16 -0
- package/dist/link/index.js.map +10 -0
- package/dist/link/router-link.d.ts +27 -0
- package/dist/link/router-link.d.ts.map +1 -0
- package/dist/lists/connection-page.d.ts +50 -0
- package/dist/lists/connection-page.d.ts.map +1 -0
- package/dist/lists/index.d.ts +13 -0
- package/dist/lists/index.d.ts.map +1 -0
- package/dist/lists/index.js +205 -0
- package/dist/lists/index.js.map +15 -0
- package/dist/lists/newest-first.d.ts +5 -0
- package/dist/lists/newest-first.d.ts.map +1 -0
- package/dist/lists/nodes-of.d.ts +21 -0
- package/dist/lists/nodes-of.d.ts.map +1 -0
- package/dist/lists/or-failed.d.ts +19 -0
- package/dist/lists/or-failed.d.ts.map +1 -0
- package/dist/lists/use-paged-rows.d.ts +40 -0
- package/dist/lists/use-paged-rows.d.ts.map +1 -0
- package/dist/lists/use-same-route-loading.d.ts +8 -0
- package/dist/lists/use-same-route-loading.d.ts.map +1 -0
- package/dist/lists/use-search-change.d.ts +20 -0
- package/dist/lists/use-search-change.d.ts.map +1 -0
- package/dist/mcp/index.d.ts +8 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +105 -0
- package/dist/mcp/index.js.map +11 -0
- package/dist/mcp/mcp-relay.d.ts +58 -0
- package/dist/mcp/mcp-relay.d.ts.map +1 -0
- package/dist/mcp/relay.d.ts +38 -0
- package/dist/mcp/relay.d.ts.map +1 -0
- package/dist/media/client/error.d.ts +29 -0
- package/dist/media/client/error.d.ts.map +1 -0
- package/dist/media/client/index.d.ts +8 -0
- package/dist/media/client/index.d.ts.map +1 -0
- package/dist/media/client/index.js +133 -0
- package/dist/media/client/index.js.map +11 -0
- package/dist/media/client/upload.d.ts +32 -0
- package/dist/media/client/upload.d.ts.map +1 -0
- package/dist/media/forward.d.ts +14 -0
- package/dist/media/forward.d.ts.map +1 -0
- package/dist/media/headers.d.ts +11 -0
- package/dist/media/headers.d.ts.map +1 -0
- package/dist/media/index.d.ts +9 -0
- package/dist/media/index.d.ts.map +1 -0
- package/dist/media/index.js +396 -0
- package/dist/media/index.js.map +16 -0
- package/dist/media/options.d.ts +114 -0
- package/dist/media/options.d.ts.map +1 -0
- package/dist/media/path.d.ts +12 -0
- package/dist/media/path.d.ts.map +1 -0
- package/dist/media/read.d.ts +11 -0
- package/dist/media/read.d.ts.map +1 -0
- package/dist/media/refusal.d.ts +11 -0
- package/dist/media/refusal.d.ts.map +1 -0
- package/dist/media/respond.d.ts +8 -0
- package/dist/media/respond.d.ts.map +1 -0
- package/dist/media/write.d.ts +13 -0
- package/dist/media/write.d.ts.map +1 -0
- package/dist/navigation/index.d.ts +9 -0
- package/dist/navigation/index.d.ts.map +1 -0
- package/dist/navigation/index.js +48 -0
- package/dist/navigation/index.js.map +11 -0
- package/dist/navigation/use-focus-on-navigate.d.ts +16 -0
- package/dist/navigation/use-focus-on-navigate.d.ts.map +1 -0
- package/dist/navigation/use-route-transition.d.ts +19 -0
- package/dist/navigation/use-route-transition.d.ts.map +1 -0
- package/dist/nonce.d.ts +16 -0
- package/dist/nonce.d.ts.map +1 -0
- package/dist/oauth/answer.d.ts +33 -0
- package/dist/oauth/answer.d.ts.map +1 -0
- package/dist/oauth/binding.d.ts +43 -0
- package/dist/oauth/binding.d.ts.map +1 -0
- package/dist/oauth/consent.d.ts +134 -0
- package/dist/oauth/consent.d.ts.map +1 -0
- package/dist/oauth/grants.d.ts +88 -0
- package/dist/oauth/grants.d.ts.map +1 -0
- package/dist/oauth/index.d.ts +16 -0
- package/dist/oauth/index.d.ts.map +1 -0
- package/dist/oauth/index.js +207 -0
- package/dist/oauth/index.js.map +12 -0
- package/dist/oauth/model.d.ts +13 -0
- package/dist/oauth/model.d.ts.map +1 -0
- package/dist/oauth/react/index.d.ts +7 -0
- package/dist/oauth/react/index.d.ts.map +1 -0
- package/dist/oauth/react/index.js +99 -0
- package/dist/oauth/react/index.js.map +10 -0
- package/dist/oauth/react/use-consent.d.ts +52 -0
- package/dist/oauth/react/use-consent.d.ts.map +1 -0
- package/dist/oidc/dpop.d.ts +80 -0
- package/dist/oidc/dpop.d.ts.map +1 -0
- package/dist/oidc/errors.d.ts +16 -0
- package/dist/oidc/errors.d.ts.map +1 -0
- package/dist/oidc/flow.d.ts +59 -0
- package/dist/oidc/flow.d.ts.map +1 -0
- package/dist/oidc/index.d.ts +11 -0
- package/dist/oidc/index.d.ts.map +1 -0
- package/dist/oidc/index.js +742 -0
- package/dist/oidc/index.js.map +15 -0
- package/dist/oidc/oidc.d.ts +132 -0
- package/dist/oidc/oidc.d.ts.map +1 -0
- package/dist/oidc/revoke.d.ts +28 -0
- package/dist/oidc/revoke.d.ts.map +1 -0
- package/dist/oidc/seal.d.ts +20 -0
- package/dist/oidc/seal.d.ts.map +1 -0
- package/dist/pwa/build/build-worker.d.ts +41 -0
- package/dist/pwa/build/build-worker.d.ts.map +1 -0
- package/dist/pwa/build/index.d.ts +9 -0
- package/dist/pwa/build/index.d.ts.map +1 -0
- package/dist/pwa/build/index.js +9 -0
- package/dist/pwa/build/index.js.map +9 -0
- package/dist/pwa/build/precache.d.ts +17 -0
- package/dist/pwa/build/precache.d.ts.map +1 -0
- package/dist/pwa/index.d.ts +16 -0
- package/dist/pwa/index.d.ts.map +1 -0
- package/dist/pwa/index.js +110 -0
- package/dist/pwa/index.js.map +12 -0
- package/dist/pwa/model/caching.d.ts +46 -0
- package/dist/pwa/model/caching.d.ts.map +1 -0
- package/dist/pwa/model/clear-app-caches.d.ts +9 -0
- package/dist/pwa/model/clear-app-caches.d.ts.map +1 -0
- package/dist/pwa/model/font-precache.d.ts +15 -0
- package/dist/pwa/model/font-precache.d.ts.map +1 -0
- package/dist/pwa/model/manifest.d.ts +80 -0
- package/dist/pwa/model/manifest.d.ts.map +1 -0
- package/dist/pwa/model/precache-list.d.ts +40 -0
- package/dist/pwa/model/precache-list.d.ts.map +1 -0
- package/dist/pwa/model/registration.d.ts +39 -0
- package/dist/pwa/model/registration.d.ts.map +1 -0
- package/dist/pwa/model/start-service-worker.d.ts +24 -0
- package/dist/pwa/model/start-service-worker.d.ts.map +1 -0
- package/dist/pwa/model/storable.d.ts +8 -0
- package/dist/pwa/model/storable.d.ts.map +1 -0
- package/dist/pwa/model/theme-color.d.ts +20 -0
- package/dist/pwa/model/theme-color.d.ts.map +1 -0
- package/dist/pwa/model/update-notice.d.ts +38 -0
- package/dist/pwa/model/update-notice.d.ts.map +1 -0
- package/dist/pwa/model/worker-contract.d.ts +61 -0
- package/dist/pwa/model/worker-contract.d.ts.map +1 -0
- package/dist/pwa/react/index.d.ts +9 -0
- package/dist/pwa/react/index.d.ts.map +1 -0
- package/dist/pwa/react/index.js +75 -0
- package/dist/pwa/react/index.js.map +13 -0
- package/dist/pwa/react/use-online.d.ts +6 -0
- package/dist/pwa/react/use-online.d.ts.map +1 -0
- package/dist/pwa/react/use-service-worker.d.ts +33 -0
- package/dist/pwa/react/use-service-worker.d.ts.map +1 -0
- package/dist/pwa/react/use-update-notice.d.ts +14 -0
- package/dist/pwa/react/use-update-notice.d.ts.map +1 -0
- package/dist/pwa/server/index.d.ts +7 -0
- package/dist/pwa/server/index.d.ts.map +1 -0
- package/dist/pwa/server/index.js +18 -0
- package/dist/pwa/server/index.js.map +10 -0
- package/dist/pwa/server/no-cache.d.ts +22 -0
- package/dist/pwa/server/no-cache.d.ts.map +1 -0
- package/dist/pwa/worker/index.d.ts +9 -0
- package/dist/pwa/worker/index.d.ts.map +1 -0
- package/dist/pwa/worker/index.js +144 -0
- package/dist/pwa/worker/index.js.map +12 -0
- package/dist/pwa/worker/injected.d.ts +15 -0
- package/dist/pwa/worker/injected.d.ts.map +1 -0
- package/dist/pwa/worker/plan.d.ts +65 -0
- package/dist/pwa/worker/plan.d.ts.map +1 -0
- package/dist/pwa/worker/scope.d.ts +18 -0
- package/dist/pwa/worker/scope.d.ts.map +1 -0
- package/dist/pwa/worker/start-worker.d.ts +17 -0
- package/dist/pwa/worker/start-worker.d.ts.map +1 -0
- package/dist/react-router.d.ts +68 -0
- package/dist/react-router.d.ts.map +1 -0
- package/dist/server.d.ts +127 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/session/codes.d.ts +9 -0
- package/dist/session/codes.d.ts.map +1 -0
- package/dist/session/cookies.d.ts +128 -0
- package/dist/session/cookies.d.ts.map +1 -0
- package/dist/session/flow-types.d.ts +235 -0
- package/dist/session/flow-types.d.ts.map +1 -0
- package/dist/session/guard.d.ts +10 -0
- package/dist/session/guard.d.ts.map +1 -0
- package/dist/session/index.d.ts +22 -0
- package/dist/session/index.d.ts.map +1 -0
- package/dist/session/index.js +1090 -0
- package/dist/session/index.js.map +27 -0
- package/dist/session/land.d.ts +28 -0
- package/dist/session/land.d.ts.map +1 -0
- package/dist/session/link-json.d.ts +22 -0
- package/dist/session/link-json.d.ts.map +1 -0
- package/dist/session/link-land.d.ts +20 -0
- package/dist/session/link-land.d.ts.map +1 -0
- package/dist/session/link-token.d.ts +24 -0
- package/dist/session/link-token.d.ts.map +1 -0
- package/dist/session/link-types.d.ts +142 -0
- package/dist/session/link-types.d.ts.map +1 -0
- package/dist/session/links.d.ts +14 -0
- package/dist/session/links.d.ts.map +1 -0
- package/dist/session/model/index.d.ts +8 -0
- package/dist/session/model/index.d.ts.map +1 -0
- package/dist/session/model/index.js +35 -0
- package/dist/session/model/index.js.map +9 -0
- package/dist/session/model/link-post.d.ts +35 -0
- package/dist/session/model/link-post.d.ts.map +1 -0
- package/dist/session/model/paths.d.ts +24 -0
- package/dist/session/model/paths.d.ts.map +1 -0
- package/dist/session/model/safe-next.d.ts +15 -0
- package/dist/session/model/safe-next.d.ts.map +1 -0
- package/dist/session/model/second-factor.d.ts +16 -0
- package/dist/session/model/second-factor.d.ts.map +1 -0
- package/dist/session/model/site-path.d.ts +10 -0
- package/dist/session/model/site-path.d.ts.map +1 -0
- package/dist/session/model/step-up-answers.d.ts +45 -0
- package/dist/session/model/step-up-answers.d.ts.map +1 -0
- package/dist/session/model/step-up-props.d.ts +22 -0
- package/dist/session/model/step-up-props.d.ts.map +1 -0
- package/dist/session/model/step-up.d.ts +48 -0
- package/dist/session/model/step-up.d.ts.map +1 -0
- package/dist/session/react/index.d.ts +13 -0
- package/dist/session/react/index.d.ts.map +1 -0
- package/dist/session/react/index.js +196 -0
- package/dist/session/react/index.js.map +14 -0
- package/dist/session/react/step-up/answers.d.ts +9 -0
- package/dist/session/react/step-up/answers.d.ts.map +1 -0
- package/dist/session/react/step-up/dialog-props.d.ts +27 -0
- package/dist/session/react/step-up/dialog-props.d.ts.map +1 -0
- package/dist/session/react/step-up/index.d.ts +7 -0
- package/dist/session/react/step-up/index.d.ts.map +1 -0
- package/dist/session/react/step-up/pending-runs.d.ts +21 -0
- package/dist/session/react/step-up/pending-runs.d.ts.map +1 -0
- package/dist/session/react/step-up/phase.d.ts +8 -0
- package/dist/session/react/step-up/phase.d.ts.map +1 -0
- package/dist/session/react/step-up/use-step-up-replay.d.ts +59 -0
- package/dist/session/react/step-up/use-step-up-replay.d.ts.map +1 -0
- package/dist/session/react/step-up/use-step-up-runner.d.ts +70 -0
- package/dist/session/react/step-up/use-step-up-runner.d.ts.map +1 -0
- package/dist/session/react/step-up/use-step-up.d.ts +51 -0
- package/dist/session/react/step-up/use-step-up.d.ts.map +1 -0
- package/dist/session/react/use-code-field.d.ts +37 -0
- package/dist/session/react/use-code-field.d.ts.map +1 -0
- package/dist/session/react/use-link-fragment.d.ts +22 -0
- package/dist/session/react/use-link-fragment.d.ts.map +1 -0
- package/dist/session/react/use-link-param.d.ts +26 -0
- package/dist/session/react/use-link-param.d.ts.map +1 -0
- package/dist/session/react/use-link-post.d.ts +39 -0
- package/dist/session/react/use-link-post.d.ts.map +1 -0
- package/dist/session/react/use-sign-out.d.ts +46 -0
- package/dist/session/react/use-sign-out.d.ts.map +1 -0
- package/dist/session/second-factor.d.ts +22 -0
- package/dist/session/second-factor.d.ts.map +1 -0
- package/dist/session/serialize.d.ts +42 -0
- package/dist/session/serialize.d.ts.map +1 -0
- package/dist/session/sign-in.d.ts +19 -0
- package/dist/session/sign-in.d.ts.map +1 -0
- package/dist/session/signed.d.ts +44 -0
- package/dist/session/signed.d.ts.map +1 -0
- package/dist/session/social-flow.d.ts +22 -0
- package/dist/session/social-flow.d.ts.map +1 -0
- package/dist/session/social-land.d.ts +31 -0
- package/dist/session/social-land.d.ts.map +1 -0
- package/dist/session/social-types.d.ts +136 -0
- package/dist/session/social-types.d.ts.map +1 -0
- package/dist/session/social.d.ts +32 -0
- package/dist/session/social.d.ts.map +1 -0
- package/dist/session/step-up-codes.d.ts +9 -0
- package/dist/session/step-up-codes.d.ts.map +1 -0
- package/dist/session/step-up-signed-out.d.ts +21 -0
- package/dist/session/step-up-signed-out.d.ts.map +1 -0
- package/dist/session/step-up-types.d.ts +127 -0
- package/dist/session/step-up-types.d.ts.map +1 -0
- package/dist/session/step-up.d.ts +17 -0
- package/dist/session/step-up.d.ts.map +1 -0
- package/dist/session/step.d.ts +22 -0
- package/dist/session/step.d.ts.map +1 -0
- package/dist/session/throttle.d.ts +73 -0
- package/dist/session/throttle.d.ts.map +1 -0
- package/dist/session/timed-wait.d.ts +4 -0
- package/dist/session/timed-wait.d.ts.map +1 -0
- package/dist/session/viewer.d.ts +34 -0
- package/dist/session/viewer.d.ts.map +1 -0
- package/dist/subscription/documents.d.ts +3 -0
- package/dist/subscription/documents.d.ts.map +1 -0
- package/dist/subscription/index.d.ts +7 -0
- package/dist/subscription/index.d.ts.map +1 -0
- package/dist/subscription/index.js +359 -0
- package/dist/subscription/index.js.map +14 -0
- package/dist/subscription/proxy.d.ts +54 -0
- package/dist/subscription/proxy.d.ts.map +1 -0
- package/dist/subscription/react/backoff.d.ts +8 -0
- package/dist/subscription/react/backoff.d.ts.map +1 -0
- package/dist/subscription/react/classify.d.ts +15 -0
- package/dist/subscription/react/classify.d.ts.map +1 -0
- package/dist/subscription/react/controller.d.ts +40 -0
- package/dist/subscription/react/controller.d.ts.map +1 -0
- package/dist/subscription/react/fake-timers.d.ts +8 -0
- package/dist/subscription/react/fake-timers.d.ts.map +1 -0
- package/dist/subscription/react/index.d.ts +15 -0
- package/dist/subscription/react/index.d.ts.map +1 -0
- package/dist/subscription/react/index.js +227 -0
- package/dist/subscription/react/index.js.map +17 -0
- package/dist/subscription/react/reconnect.d.ts +9 -0
- package/dist/subscription/react/reconnect.d.ts.map +1 -0
- package/dist/subscription/react/scheduler.d.ts +13 -0
- package/dist/subscription/react/scheduler.d.ts.map +1 -0
- package/dist/subscription/react/timers.d.ts +7 -0
- package/dist/subscription/react/timers.d.ts.map +1 -0
- package/dist/subscription/react/use-live-subscription.d.ts +36 -0
- package/dist/subscription/react/use-live-subscription.d.ts.map +1 -0
- package/dist/subscription/react/versions.d.ts +6 -0
- package/dist/subscription/react/versions.d.ts.map +1 -0
- package/dist/subscription/read.d.ts +17 -0
- package/dist/subscription/read.d.ts.map +1 -0
- package/dist/subscription/refusal.d.ts +11 -0
- package/dist/subscription/refusal.d.ts.map +1 -0
- package/dist/subscription/relay.d.ts +16 -0
- package/dist/subscription/relay.d.ts.map +1 -0
- package/dist/vite/bun.d.ts +21 -0
- package/dist/vite/bun.d.ts.map +1 -0
- package/dist/vite/bundle.d.ts +33 -0
- package/dist/vite/bundle.d.ts.map +1 -0
- package/dist/vite/compress.d.ts +18 -0
- package/dist/vite/compress.d.ts.map +1 -0
- package/dist/vite/config.d.ts +33 -0
- package/dist/vite/config.d.ts.map +1 -0
- package/dist/vite/dev.d.ts +28 -0
- package/dist/vite/dev.d.ts.map +1 -0
- package/dist/vite/entry.d.ts +20 -0
- package/dist/vite/entry.d.ts.map +1 -0
- package/dist/vite/hosts.d.ts +16 -0
- package/dist/vite/hosts.d.ts.map +1 -0
- package/dist/vite/index.d.ts +68 -0
- package/dist/vite/index.d.ts.map +1 -0
- package/dist/vite/index.js +635 -0
- package/dist/vite/index.js.map +22 -0
- package/dist/vite/inline.d.ts +18 -0
- package/dist/vite/inline.d.ts.map +1 -0
- package/dist/vite/node.d.ts +16 -0
- package/dist/vite/node.d.ts.map +1 -0
- package/dist/vite/preview.d.ts +8 -0
- package/dist/vite/preview.d.ts.map +1 -0
- package/dist/vite/runtime.d.ts +8 -0
- package/dist/vite/runtime.d.ts.map +1 -0
- package/dist/vite/socket.d.ts +75 -0
- package/dist/vite/socket.d.ts.map +1 -0
- package/dist/vite/worker.d.ts +16 -0
- package/dist/vite/worker.d.ts.map +1 -0
- package/dist/with-alxia.d.ts +36 -0
- package/dist/with-alxia.d.ts.map +1 -0
- package/docs/README.md +42 -0
- package/docs/guide/api-keys.md +216 -0
- package/docs/guide/beside-the-pages.md +201 -0
- package/docs/guide/csp-nonce.md +166 -0
- package/docs/guide/customising-the-server.md +324 -0
- package/docs/guide/deploying.md +102 -0
- package/docs/guide/document.md +334 -0
- package/docs/guide/errors.md +1147 -0
- package/docs/guide/fetcher.md +355 -0
- package/docs/guide/getting-started.md +112 -0
- package/docs/guide/help.md +325 -0
- package/docs/guide/how-it-works.md +274 -0
- package/docs/guide/link.md +32 -0
- package/docs/guide/lists.md +225 -0
- package/docs/guide/mcp.md +173 -0
- package/docs/guide/media.md +273 -0
- package/docs/guide/navigation.md +52 -0
- package/docs/guide/oauth.md +342 -0
- package/docs/guide/oidc.md +262 -0
- package/docs/guide/openapi.md +51 -0
- package/docs/guide/pwa.md +670 -0
- package/docs/guide/session.md +2105 -0
- package/docs/guide/subscriptions.md +211 -0
- package/docs/guide/testing.md +42 -0
- package/docs/guide/typing-the-loaders.md +311 -0
- package/docs/guide.md +82 -0
- package/docs/roadmap.md +474 -0
- package/docs/troubleshooting.md +3837 -0
- package/package.json +301 -5
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/media/refusal.ts", "../src/media/headers.ts", "../src/media/path.ts", "../src/media/forward.ts", "../src/media/respond.ts", "../src/media/read.ts", "../src/media/write.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"/**\n * The proxy's own refusals, in the shape `@softistx/alxia-media` answers with:\n * `{ \"error\": \"<code>\", ...extras }`, `limit` on a 413. The API's own\n * answers come back untouched; these are the ones the proxy gives before or\n * instead of the API's.\n */\n/** The responses `refuse` made: a refusal of the proxy itself, as opposed to the API's. */\nexport const ownRefusals = new WeakSet<Response>();\n\nexport function refuse(\n\tstatus: number,\n\tcode: string,\n\textras: Readonly<Record<string, unknown>> = {},\n\theaders: HeadersInit = {},\n): Response {\n\tconst response = new Response(JSON.stringify({ error: code, ...extras }), {\n\t\tstatus,\n\t\theaders: {\n\t\t\t'content-type': 'application/json',\n\t\t\t'cache-control': 'no-store',\n\t\t\t'x-content-type-options': 'nosniff',\n\t\t\t...headers,\n\t\t},\n\t});\n\townRefusals.add(response);\n\treturn response;\n}\n\nexport const notFound = (): Response => refuse(404, 'not_found');\n",
|
|
6
|
+
"import { extraHeaders, usableToken } from '../errors/upstream-headers';\nimport type { MediaArgs, MediaProxyOptions } from './options';\nimport { refuse } from './refusal';\n\n/** Request headers that reach the API, besides the proxy's own: a conditional or ranged read, an upload's type and length. */\nexport const READ_HEADERS = [\n\t'range',\n\t'if-none-match',\n\t'if-range',\n\t'accept',\n] as const;\nexport const WRITE_HEADERS = ['content-type', 'content-length'] as const;\n\n/**\n * The only response headers that reach the browser. Anything else the API\n * (or a proxy before it) adds stays behind: `set-cookie`, `www-authenticate`,\n * `alt-svc`, `access-control-*`, `server`, `link`, `content-location`.\n */\nconst ANSWERED = new Set([\n\t'content-type',\n\t'content-length',\n\t'content-range',\n\t'accept-ranges',\n\t'etag',\n\t'last-modified',\n\t'cache-control',\n\t'content-disposition',\n\t'x-content-type-options',\n\t'cross-origin-resource-policy',\n\t'content-security-policy',\n\t'retry-after',\n\t'vary',\n]);\n\n/** The API's response headers the browser may see. */\nexport function answerHeaders(upstream: Headers): Headers {\n\tconst headers = new Headers();\n\tfor (const [name, value] of upstream) {\n\t\tif (ANSWERED.has(name)) headers.append(name, value);\n\t}\n\t// fetch has decoded a body it was told is encoded: the length is not the API's.\n\tif (upstream.has('content-encoding')) headers.delete('content-length');\n\treturn headers;\n}\n\n/** The headers sent to the API, or the 500 that says the app's `headers` or `getToken` is broken. */\nexport async function build(\n\toptions: MediaProxyOptions<never>,\n\targs: MediaArgs,\n\ttoken: string | undefined,\n\tforwarded: readonly string[],\n): Promise<Headers | Response> {\n\ttry {\n\t\tconst out = await extraHeaders(\n\t\t\toptions.headers,\n\t\t\targs.request,\n\t\t\targs as MediaArgs<never>,\n\t\t);\n\t\t// Only what the media routes use is copied from the browser: its cookies,\n\t\t// its Authorization and any API key never go.\n\t\tfor (const name of forwarded) {\n\t\t\tconst value = args.request.headers.get(name);\n\t\t\tif (value !== null) out.set(name, value);\n\t\t}\n\t\tif (token !== undefined) out.set('authorization', `Bearer ${token}`);\n\t\treturn out;\n\t} catch {\n\t\treturn misconfigured(\n\t\t\t\"The proxy's upstream headers are not valid (a name or a value no header can hold, or the headers function threw).\",\n\t\t);\n\t}\n}\n\n/** The session's token: `undefined` for none, or the 500 for a `getToken` that throws. */\nexport async function tokenOf(\n\toptions: MediaProxyOptions<never>,\n\trequest: Request,\n): Promise<string | undefined | Response> {\n\ttry {\n\t\treturn usableToken(await options.getToken(request));\n\t} catch {\n\t\treturn misconfigured(\"The proxy's getToken threw.\");\n\t}\n}\n\nfunction misconfigured(message: string): Response {\n\treturn refuse(500, 'proxy_misconfigured', { message });\n}\n",
|
|
7
|
+
"import { isCrossSite } from '../errors/cross-site';\nimport type { MediaArgs, MediaKindLimit, MediaProxyOptions } from './options';\nimport { notFound, refuse } from './refusal';\n\nconst KEY = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;\nconst SIZE = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\nexport const prefixOf = (value: string | undefined, fallback: string): string =>\n\t(value ?? fallback).replace(/\\/+$/, '');\n\nexport interface Target {\n\treadonly kind: string;\n\treadonly limit: MediaKindLimit;\n\t/** The path under the prefix, after the kind: empty, or `/<key>[/<size>]`. */\n\treadonly rest: string;\n\treadonly key: string | undefined;\n}\n\n/** The kind, key and size a path names, or `undefined` for a path that is not one of the media routes. */\nfunction parse(\n\trequest: Request,\n\toptions: MediaProxyOptions<never>,\n): Target | undefined {\n\tconst prefix = prefixOf(options.prefix, '/media');\n\tconst { pathname } = new URL(request.url);\n\tif (!pathname.startsWith(`${prefix}/`)) return undefined;\n\tconst [kind, key, size, ...extra] = pathname\n\t\t.slice(prefix.length + 1)\n\t\t.split('/');\n\tif (kind === undefined || !Object.hasOwn(options.kinds, kind)) {\n\t\treturn undefined;\n\t}\n\tconst limit = options.kinds[kind] as MediaKindLimit;\n\tif (key === undefined) return { kind, limit, rest: '', key: undefined };\n\tif (extra.length > 0 || !KEY.test(key)) return undefined;\n\tif (size === undefined) return { kind, limit, rest: `/${key}`, key };\n\tif (!SIZE.test(size)) return undefined;\n\treturn { kind, limit, rest: `/${key}/${size}`, key };\n}\n\n/** The method, the origin and the path checked: the target, or the refusal. */\nexport function checked(\n\toptions: MediaProxyOptions<never>,\n\targs: MediaArgs,\n\tmethods: readonly string[],\n): Response | Target {\n\tconst { request } = args;\n\tif (!methods.includes(request.method)) {\n\t\treturn refuse(405, 'method_not_allowed', {}, { allow: methods.join(', ') });\n\t}\n\tconst origin =\n\t\ttypeof options.origin === 'function' ? options.origin() : options.origin;\n\tif (isCrossSite(request, origin)) return refuse(403, 'forbidden');\n\treturn parse(request, options) ?? notFound();\n}\n",
|
|
8
|
+
"import { answerHeaders } from './headers';\nimport type { MediaProxyOptions } from './options';\nimport { prefixOf, type Target } from './path';\nimport { refuse } from './refusal';\n\n/** The longest delay a timer holds. */\nconst MAX_TIMER = 2_147_483_647;\n\n/** Whether `timeout` is `Infinity` or a delay a timer can hold. */\nconst validTimeout = (wait: number): boolean =>\n\twait === Number.POSITIVE_INFINITY ||\n\t(Number.isFinite(wait) && wait > 0 && wait <= MAX_TIMER);\n\n/** Milliseconds the API has to send its response's headers. */\nconst TIMEOUT = 60_000;\n\nexport interface Upstream {\n\treadonly method: string;\n\treadonly headers: Headers;\n\treadonly body?: ReadableStream | null;\n}\n\n/** The API's answer for the browser: no redirect, the allowed headers, the body streamed. */\nfunction answer(upstream: Response, abort: AbortController): Response {\n\t// The media routes never redirect: a 3xx would send the browser to the API's address.\n\tif (\n\t\tupstream.status >= 300 &&\n\t\tupstream.status < 400 &&\n\t\tupstream.status !== 304\n\t) {\n\t\tabort.abort();\n\t\treturn refuse(502, 'unavailable');\n\t}\n\tconst headers = answerHeaders(upstream.headers);\n\tif (upstream.body === null || upstream.status === 304) {\n\t\tabort.abort();\n\t\treturn new Response(null, { status: upstream.status, headers });\n\t}\n\treturn new Response(upstream.body, { status: upstream.status, headers });\n}\n\n/**\n * Sends the request to the API and answers with its response. One\n * `AbortController` is the client's way out (it aborts when the client leaves),\n * the deadline's and the answer's: whichever fires cuts the upstream request.\n */\nexport async function forward(\n\toptions: MediaProxyOptions<never>,\n\trequest: Request,\n\ttarget: Target,\n\tinit: Upstream,\n): Promise<Response> {\n\tif (options.timeout !== undefined && !validTimeout(options.timeout)) {\n\t\treturn refuse(500, 'proxy_misconfigured', {\n\t\t\tmessage:\n\t\t\t\t'The proxy timeout must be Infinity or a number of milliseconds above 0 and at most 2147483647.',\n\t\t});\n\t}\n\tconst abort = new AbortController();\n\tif (request.signal.aborted) abort.abort();\n\telse {\n\t\trequest.signal.addEventListener('abort', () => abort.abort(), {\n\t\t\tonce: true,\n\t\t});\n\t}\n\tconst url = new URL(\n\t\t`${prefixOf(options.apiPrefix ?? options.prefix, '/media')}/${target.kind}${target.rest}`,\n\t\toptions.api,\n\t);\n\tconst query = options.forwardQuery;\n\tif (query !== undefined) {\n\t\tconst incoming = new URL(request.url).searchParams;\n\t\tfor (const [name, value] of incoming) {\n\t\t\tif (query === true || query.includes(name)) {\n\t\t\t\turl.searchParams.append(name, value);\n\t\t\t}\n\t\t}\n\t}\n\tconst upstreamFetch = options.fetch ?? ((r: Request) => fetch(r));\n\tlet expired = false;\n\tconst wait = options.timeout ?? TIMEOUT;\n\t// `Infinity` is no deadline; anything else must fit a timer.\n\tconst timer =\n\t\twait === Number.POSITIVE_INFINITY\n\t\t\t? undefined\n\t\t\t: setTimeout(() => {\n\t\t\t\t\texpired = true;\n\t\t\t\t\tabort.abort();\n\t\t\t\t}, wait);\n\tlet upstream: Response;\n\ttry {\n\t\tupstream = await upstreamFetch(\n\t\t\tnew Request(url, {\n\t\t\t\tmethod: init.method,\n\t\t\t\theaders: init.headers,\n\t\t\t\tsignal: abort.signal,\n\t\t\t\tredirect: 'manual',\n\t\t\t\t...(init.body ? { body: init.body, duplex: 'half' } : {}),\n\t\t\t} as RequestInit),\n\t\t);\n\t} catch {\n\t\treturn expired ? refuse(504, 'unavailable') : refuse(502, 'unavailable');\n\t} finally {\n\t\t// The headers are here, or the call failed: a long body still streams.\n\t\tif (timer !== undefined) clearTimeout(timer);\n\t}\n\treturn answer(upstream, abort);\n}\n",
|
|
9
|
+
"import type {\n\tMediaHookResult,\n\tMediaProxyOptions,\n\tMediaRefusal,\n\tMediaSuccess,\n} from './options';\nimport { ownRefusals, refuse } from './refusal';\n\n/** The most an API error body the hooks read may hold. */\nconst MAX_BODY = 65_536;\n\nconst isJson = (headers: Headers): boolean =>\n\t/json/i.test(headers.get('content-type') ?? '');\n\n/** The code a refusal body names: `error`, else a problem's or an `errors[0]`'s `code`. */\nfunction codeOf(body: unknown): string | undefined {\n\tconst text = (value: unknown, name: string): string | undefined => {\n\t\tif (typeof value !== 'object' || value === null) return undefined;\n\t\tconst found = (value as { [key: string]: unknown })[name];\n\t\treturn typeof found === 'string' ? found : undefined;\n\t};\n\tconst errors = (body as { [key: string]: unknown } | null)?.['errors'];\n\tconst first = Array.isArray(errors) ? (errors[0] as unknown) : undefined;\n\treturn (\n\t\ttext(body, 'error') ??\n\t\ttext(body, 'code') ??\n\t\ttext(first, 'code') ??\n\t\ttext(first, 'error')\n\t);\n}\n\n/** What `readCapped` read of an answer's body, and how to give it back or drop it. */\ninterface Read {\n\t/** The parsed JSON; `undefined` when the body was not JSON, over the cap, or empty. */\n\treadonly body: unknown;\n\t/** The answer as it was: the bytes already read, then the rest of the stream. */\n\treadonly keep: () => Response;\n\t/** Releases the upstream body when a hook replaces the answer. */\n\treadonly cancel: () => Promise<void>;\n}\n\n/**\n * Reads a JSON body for a hook, never more than `MAX_BODY` bytes: the count\n * runs while streaming, so a chunked or compressed body (no usable\n * `Content-Length`) is capped too. Past the cap the hook gets no body and\n * `keep` re-emits what was read plus the rest.\n */\nasync function readCapped(response: Response): Promise<Read> {\n\tconst source = response.body;\n\tconst untouched: Read = {\n\t\tbody: undefined,\n\t\tkeep: () => response,\n\t\tcancel: async () => {\n\t\t\tawait source?.cancel();\n\t\t},\n\t};\n\tconst declared = Number(response.headers.get('content-length') ?? 0);\n\tif (source === null || !isJson(response.headers) || declared > MAX_BODY) {\n\t\treturn untouched;\n\t}\n\tconst reader = source.getReader();\n\tconst chunks: Uint8Array[] = [];\n\tlet total = 0;\n\tfor (;;) {\n\t\tconst { done, value } = await reader.read();\n\t\tif (done) break;\n\t\tchunks.push(value);\n\t\ttotal += value.byteLength;\n\t\tif (total > MAX_BODY) {\n\t\t\tconst rest = new ReadableStream<Uint8Array>({\n\t\t\t\tstart(controller) {\n\t\t\t\t\tfor (const chunk of chunks) controller.enqueue(chunk);\n\t\t\t\t},\n\t\t\t\tasync pull(controller) {\n\t\t\t\t\tconst next = await reader.read();\n\t\t\t\t\tif (next.done) controller.close();\n\t\t\t\t\telse controller.enqueue(next.value);\n\t\t\t\t},\n\t\t\t\tcancel: (reason) => reader.cancel(reason),\n\t\t\t});\n\t\t\treturn {\n\t\t\t\tbody: undefined,\n\t\t\t\tkeep: () =>\n\t\t\t\t\tnew Response(rest, {\n\t\t\t\t\t\tstatus: response.status,\n\t\t\t\t\t\theaders: response.headers,\n\t\t\t\t\t}),\n\t\t\t\tcancel: () => reader.cancel(),\n\t\t\t};\n\t\t}\n\t}\n\tconst bytes = new Uint8Array(total);\n\tlet at = 0;\n\tfor (const chunk of chunks) {\n\t\tbytes.set(chunk, at);\n\t\tat += chunk.byteLength;\n\t}\n\tlet body: unknown;\n\ttry {\n\t\tbody = JSON.parse(new TextDecoder().decode(bytes));\n\t} catch {}\n\treturn {\n\t\tbody,\n\t\tkeep: () =>\n\t\t\tnew Response(bytes, {\n\t\t\t\tstatus: response.status,\n\t\t\t\theaders: response.headers,\n\t\t\t}),\n\t\tcancel: async () => {},\n\t};\n}\n\nfunction toResponse(\n\tresult: Exclude<MediaHookResult, undefined | void>,\n\tstatusOf: number,\n\theaders: Headers,\n): Response {\n\tif (result instanceof Response) return result;\n\tlet status = statusOf;\n\tconst out = new Headers(headers);\n\tout.delete('content-length');\n\t// A 204 or 205 cannot carry a body (`new Response(body, { status: 204 })` throws): data is a 200.\n\tif (status === 204 || status === 205) status = 200;\n\tout.set('content-type', 'application/json');\n\tif (status >= 400) out.set('cache-control', 'no-store');\n\treturn new Response(JSON.stringify(result), { status, headers: out });\n}\n\n/**\n * Runs `relay` and gives `onRefusal` (answers of 400 and above) and\n * `onSuccess` (a write's 2xx) their say. With neither option the answer is\n * returned untouched, its body still streaming.\n */\nexport async function respond(\n\toptions: MediaProxyOptions<never>,\n\trequest: Request,\n\twrite: boolean,\n\trelay: () => Promise<Response>,\n): Promise<Response> {\n\tconst response = await relay();\n\tconst refused = response.status >= 400;\n\tconst hook = refused\n\t\t? options.onRefusal\n\t\t: write && response.status >= 200 && response.status < 300\n\t\t\t? options.onSuccess\n\t\t\t: undefined;\n\tif (hook === undefined) return response;\n\tlet read: Read;\n\ttry {\n\t\tread = await readCapped(response);\n\t} catch {\n\t\treturn refuse(502, 'unavailable');\n\t}\n\tconst common = {\n\t\tstatus: response.status,\n\t\tbody: read.body,\n\t\theaders: response.headers,\n\t};\n\tlet result: MediaHookResult;\n\ttry {\n\t\tresult = refused\n\t\t\t? await options.onRefusal?.(\n\t\t\t\t\t{\n\t\t\t\t\t\t...common,\n\t\t\t\t\t\tsource: ownRefusals.has(response) ? 'proxy' : 'api',\n\t\t\t\t\t\tcode: codeOf(read.body),\n\t\t\t\t\t} satisfies MediaRefusal,\n\t\t\t\t\trequest,\n\t\t\t\t)\n\t\t\t: await options.onSuccess?.(common satisfies MediaSuccess, request);\n\t} catch {\n\t\tawait read.cancel().catch(() => {});\n\t\treturn refuse(500, 'proxy_misconfigured', {\n\t\t\tmessage: refused\n\t\t\t\t? \"The proxy's onRefusal threw.\"\n\t\t\t\t: \"The proxy's onSuccess threw.\",\n\t\t});\n\t}\n\tif (result !== undefined && result !== null) {\n\t\tawait read.cancel().catch(() => {});\n\t\treturn toResponse(result, response.status, response.headers);\n\t}\n\treturn read.keep();\n}\n",
|
|
10
|
+
"import { forward } from './forward';\nimport { build, READ_HEADERS, tokenOf } from './headers';\nimport type { MediaArgs, MediaProxyOptions } from './options';\nimport { checked } from './path';\nimport { notFound } from './refusal';\nimport { respond } from './respond';\n\n/**\n * A resource route's `loader`: `GET` and `HEAD` of `<prefix>/<kind>/<key>`\n * and `<prefix>/<kind>/<key>/<size>`, relayed to the API with the session's\n * Bearer. `Range`, `If-None-Match` and `If-Range` go up; the status (`200`,\n * `206`, `304`, `404`, `416`, ...) and the allowed headers come back, the body\n * streamed, never held. Without a session the read still goes (a public kind\n * needs none) and the API answers `404` for the rest.\n */\nexport async function proxyMediaRead<Context = unknown>(\n\targs: MediaArgs<Context>,\n\toptions: MediaProxyOptions<Context>,\n): Promise<Response> {\n\treturn respond(options as MediaProxyOptions<never>, args.request, false, () =>\n\t\trelay(args, options),\n\t);\n}\n\nasync function relay<Context>(\n\targs: MediaArgs<Context>,\n\toptions: MediaProxyOptions<Context>,\n): Promise<Response> {\n\tconst opts = options as MediaProxyOptions<never>;\n\tconst target = checked(opts, args, ['GET', 'HEAD']);\n\tif (target instanceof Response) return target;\n\tif (target.key === undefined) return notFound();\n\tconst token = await tokenOf(opts, args.request);\n\tif (token instanceof Response) return token;\n\tconst headers = await build(opts, args, token, READ_HEADERS);\n\tif (headers instanceof Response) return headers;\n\treturn forward(opts, args.request, target, {\n\t\tmethod: args.request.method,\n\t\theaders,\n\t});\n}\n",
|
|
11
|
+
"import { forward } from './forward';\nimport { build, tokenOf, WRITE_HEADERS } from './headers';\nimport type { MediaArgs, MediaProxyOptions } from './options';\nimport { checked } from './path';\nimport { notFound, refuse } from './refusal';\nimport { respond } from './respond';\n\n/**\n * A resource route's `action`: `PUT <prefix>/<kind>` with the raw file as the\n * body, and `DELETE <prefix>/<kind>/<key>` for a kind that allows it. A\n * session is required (401). An upload with no `Content-Length` is a 411\n * (unless `allowUnsized`), a malformed one a 400 `size_mismatch`, and one\n * over the kind's `maxBytes` a 413 `too_large` before the API is called; the\n * body is streamed to the API, never held. The API's answer (`{ key,\n * contentType, size }`, or a 400, 403, 408, 413, 415, 422, 429, 503) comes\n * back as it is.\n */\nexport async function proxyMediaWrite<Context = unknown>(\n\targs: MediaArgs<Context>,\n\toptions: MediaProxyOptions<Context>,\n): Promise<Response> {\n\treturn respond(options as MediaProxyOptions<never>, args.request, true, () =>\n\t\trelay(args, options),\n\t);\n}\n\nasync function relay<Context>(\n\targs: MediaArgs<Context>,\n\toptions: MediaProxyOptions<Context>,\n): Promise<Response> {\n\tconst opts = options as MediaProxyOptions<never>;\n\tconst { request } = args;\n\tconst target = checked(opts, args, ['PUT', 'DELETE']);\n\tif (target instanceof Response) return target;\n\tconst isPut = request.method === 'PUT';\n\tif (isPut !== (target.key === undefined)) return notFound();\n\tif (target.rest.split('/').length > 2) return notFound();\n\ttry {\n\t\tfor (const [name, expected] of Object.entries(opts.requireHeaders ?? {})) {\n\t\t\tif (request.headers.get(name) !== expected) {\n\t\t\t\treturn refuse(403, 'header_required');\n\t\t\t}\n\t\t}\n\t} catch {\n\t\treturn refuse(500, 'proxy_misconfigured', {\n\t\t\tmessage: \"The proxy's requireHeaders names a header no request can hold.\",\n\t\t});\n\t}\n\tconst token = await tokenOf(opts, request);\n\tif (token instanceof Response) return token;\n\tif (token === undefined) return refuse(401, 'unauthenticated');\n\tif (isPut) {\n\t\tconst declared = request.headers.get('content-length');\n\t\tif (declared === null) {\n\t\t\tif (opts.allowUnsized !== true) return refuse(411, 'length_required');\n\t\t} else {\n\t\t\tif (!/^\\d+$/.test(declared)) return refuse(400, 'size_mismatch');\n\t\t\tif (Number(declared) > target.limit.maxBytes) {\n\t\t\t\treturn refuse(413, 'too_large', { limit: target.limit.maxBytes });\n\t\t\t}\n\t\t}\n\t}\n\tconst headers = await build(opts, args, token, isPut ? WRITE_HEADERS : []);\n\tif (headers instanceof Response) return headers;\n\treturn forward(opts, request, target, {\n\t\tmethod: request.method,\n\t\theaders,\n\t\tbody: isPut ? request.body : null,\n\t});\n}\n"
|
|
12
|
+
],
|
|
13
|
+
"mappings": ";;;;;;;;;AAOO,IAAM,cAAc,IAAI;AAExB,SAAS,MAAM,CACrB,QACA,MACA,SAA4C,CAAC,GAC7C,UAAuB,CAAC,GACb;AAAA,EACX,MAAM,WAAW,IAAI,SAAS,KAAK,UAAU,EAAE,OAAO,SAAS,OAAO,CAAC,GAAG;AAAA,IACzE;AAAA,IACA,SAAS;AAAA,MACR,gBAAgB;AAAA,MAChB,iBAAiB;AAAA,MACjB,0BAA0B;AAAA,SACvB;AAAA,IACJ;AAAA,EACD,CAAC;AAAA,EACD,YAAY,IAAI,QAAQ;AAAA,EACxB,OAAO;AAAA;AAGD,IAAM,WAAW,MAAgB,OAAO,KAAK,WAAW;;;ACvBxD,IAAM,eAAe;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AACO,IAAM,gBAAgB,CAAC,gBAAgB,gBAAgB;AAO9D,IAAM,WAAW,IAAI,IAAI;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,CAAC;AAGM,SAAS,aAAa,CAAC,UAA4B;AAAA,EACzD,MAAM,UAAU,IAAI;AAAA,EACpB,YAAY,MAAM,UAAU,UAAU;AAAA,IACrC,IAAI,SAAS,IAAI,IAAI;AAAA,MAAG,QAAQ,OAAO,MAAM,KAAK;AAAA,EACnD;AAAA,EAEA,IAAI,SAAS,IAAI,kBAAkB;AAAA,IA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QAAQ;AAAA,QAAG,OAAO,OAAO,KAAK,eAAe;AAAA,MAC/D,IAAI,OAAO,QAAQ,IAAI,OAAO,MAAM,UAAU;AAAA,QAC7C,OAAO,OAAO,KAAK,aAAa,EAAE,OAAO,OAAO,MAAM,SAAS,CAAC;AAAA,MACjE;AAAA;AAAA,EAEF;AAAA,EACA,MAAM,UAAU,MAAM,MAAM,MAAM,MAAM,OAAO,QAAQ,gBAAgB,CAAC,CAAC;AAAA,EACzE,IAAI,mBAAmB;AAAA,IAAU,OAAO;AAAA,EACxC,OAAO,QAAQ,MAAM,SAAS,QAAQ;AAAA,IACrC,QAAQ,QAAQ;AAAA,IAChB;AAAA,IACA,MAAM,QAAQ,QAAQ,OAAO;AAAA,EAC9B,CAAC;AAAA;",
|
|
14
|
+
"debugId": "AD04888A858C253D64756E2164756E21",
|
|
15
|
+
"names": []
|
|
16
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import type { HeaderValues } from '../errors/upstream-headers';
|
|
2
|
+
/**
|
|
3
|
+
* What React Router gives a resource route's `loader` and `action`: the
|
|
4
|
+
* request and, for the `headers` function, the route's `context` and
|
|
5
|
+
* `params`. Both are optional so a call with the request alone type-checks.
|
|
6
|
+
*/
|
|
7
|
+
export interface MediaArgs<Context = unknown> {
|
|
8
|
+
readonly request: Request;
|
|
9
|
+
readonly context?: Context;
|
|
10
|
+
readonly params?: Readonly<Record<string, string | undefined>>;
|
|
11
|
+
}
|
|
12
|
+
/** What the proxy knows about a kind: the most bytes an upload may declare. */
|
|
13
|
+
export interface MediaKindLimit {
|
|
14
|
+
readonly maxBytes: number;
|
|
15
|
+
}
|
|
16
|
+
/** An answer of 400 and above, the proxy's own or the API's, as `onRefusal` receives it. */
|
|
17
|
+
export interface MediaRefusal {
|
|
18
|
+
readonly status: number;
|
|
19
|
+
/** `proxy` for a refusal the proxy gave itself, `api` for the API's answer. */
|
|
20
|
+
readonly source: 'proxy' | 'api';
|
|
21
|
+
/**
|
|
22
|
+
* The refusal's code: the body's `error` (the proxy's and `@softistx/alxia-media`'s),
|
|
23
|
+
* else the `code` of a problem or of the first entry of an `errors` array.
|
|
24
|
+
* `undefined` when the body gives none.
|
|
25
|
+
*/
|
|
26
|
+
readonly code: string | undefined;
|
|
27
|
+
/** The JSON body, parsed; `undefined` when the API's was not JSON or was over 64 KiB. */
|
|
28
|
+
readonly body: unknown;
|
|
29
|
+
/** The headers that would be sent (the proxy's, or the API's allowed ones). */
|
|
30
|
+
readonly headers: Headers;
|
|
31
|
+
}
|
|
32
|
+
/** The API's 2xx answer to a `PUT` or `DELETE`, as `onSuccess` receives it. */
|
|
33
|
+
export interface MediaSuccess {
|
|
34
|
+
readonly status: number;
|
|
35
|
+
/** The JSON body (`{ key, contentType, size }` for a `PUT`); `undefined` when it was not JSON. */
|
|
36
|
+
readonly body: unknown;
|
|
37
|
+
readonly headers: Headers;
|
|
38
|
+
}
|
|
39
|
+
/** What a hook returns: a `Response` sent as it is, data sent as JSON with the status it replaces, or `undefined` to keep the default. */
|
|
40
|
+
export type MediaHookResult = Response | Readonly<Record<string, unknown>> | unknown[] | undefined | void;
|
|
41
|
+
export interface MediaProxyOptions<Context = unknown> {
|
|
42
|
+
/** The API's origin, an absolute `http://` or `https://` URL. */
|
|
43
|
+
readonly api: string | URL;
|
|
44
|
+
/**
|
|
45
|
+
* The kinds the browser may reach, each with the `maxBytes` of its
|
|
46
|
+
* `@softistx/alxia-media` kind. A path naming another kind is a 404; an upload that
|
|
47
|
+
* declares more than `maxBytes` is a 413 before the API is called.
|
|
48
|
+
*/
|
|
49
|
+
readonly kinds: Readonly<Record<string, MediaKindLimit>>;
|
|
50
|
+
/**
|
|
51
|
+
* The session's token, from the request: `(request) => cookies.token(request)`.
|
|
52
|
+
* Empty is a 401 for a write; a read goes on without it. A function that
|
|
53
|
+
* throws is a 500 `proxy_misconfigured`.
|
|
54
|
+
*/
|
|
55
|
+
readonly getToken: (request: Request) => string | null | undefined | Promise<string | null | undefined>;
|
|
56
|
+
/**
|
|
57
|
+
* Extra upstream headers (client name, proxy secret, `X-Forwarded-For`),
|
|
58
|
+
* fixed or built per request from the request and the route's arguments.
|
|
59
|
+
* A `null` or `undefined` value is left out. They reach the API only.
|
|
60
|
+
*/
|
|
61
|
+
readonly headers?: HeaderValues | ((request: Request, args: MediaArgs<Context>) => HeaderValues | Promise<HeaderValues>);
|
|
62
|
+
/** The app's own origin for the cross-site check; the request's own by default. */
|
|
63
|
+
readonly origin?: string | (() => string | undefined);
|
|
64
|
+
/** The path the route is mounted at on the app: `/media` by default. */
|
|
65
|
+
readonly prefix?: `/${string}`;
|
|
66
|
+
/** The path `mediaRoutes` is mounted at on the API: the same as `prefix` by default. */
|
|
67
|
+
readonly apiPrefix?: `/${string}`;
|
|
68
|
+
/** The `fetch` used upstream. The global `fetch` by default. */
|
|
69
|
+
readonly fetch?: (request: Request) => Promise<Response>;
|
|
70
|
+
/**
|
|
71
|
+
* Milliseconds the API has to send its response's headers: 60 000 by
|
|
72
|
+
* default; past it, a 504 `unavailable` and the upstream request is
|
|
73
|
+
* aborted. The timer stops when the headers arrive, so a long download
|
|
74
|
+
* still streams. An upload is answered after its body, so raise it for
|
|
75
|
+
* large files. `Infinity` sets no deadline; any other value that is not
|
|
76
|
+
* above 0 and at most 2147483647 is a 500 `proxy_misconfigured`.
|
|
77
|
+
*/
|
|
78
|
+
readonly timeout?: number;
|
|
79
|
+
/**
|
|
80
|
+
* Let a `PUT` with no `Content-Length` (a chunked body) go on, the API
|
|
81
|
+
* capping the stream. Off by default: such an upload is a 411
|
|
82
|
+
* `length_required` at the proxy, so the size is checked before a byte is
|
|
83
|
+
* sent.
|
|
84
|
+
*/
|
|
85
|
+
readonly allowUnsized?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* Words a refusal in the app's own shape. Called for every answer of 400
|
|
88
|
+
* and above, the proxy's (`source: 'proxy'`) and the API's, on reads and
|
|
89
|
+
* writes. Return a `Response` to send it as it is, data to send it as JSON
|
|
90
|
+
* with the refusal's status (and `no-store`), or `undefined` to keep the
|
|
91
|
+
* default. A hook that throws is a 500 `proxy_misconfigured`.
|
|
92
|
+
*/
|
|
93
|
+
readonly onRefusal?: (refusal: MediaRefusal, request: Request) => MediaHookResult | Promise<MediaHookResult>;
|
|
94
|
+
/**
|
|
95
|
+
* Shapes the API's 2xx JSON answer to a `PUT` or `DELETE` (a read streams a
|
|
96
|
+
* file and is never touched): `({ body }) => ({ ok: true, key: body.key })`.
|
|
97
|
+
* Same return rules as `onRefusal`; data keeps the API's status.
|
|
98
|
+
*/
|
|
99
|
+
readonly onSuccess?: (success: MediaSuccess, request: Request) => MediaHookResult | Promise<MediaHookResult>;
|
|
100
|
+
/**
|
|
101
|
+
* The query parameters of the incoming request that go to the API, on reads
|
|
102
|
+
* and writes: a list of names (`['x', 'y', 'size']`), or `true` for all of
|
|
103
|
+
* them. None by default. Names not listed are dropped.
|
|
104
|
+
*/
|
|
105
|
+
readonly forwardQuery?: true | readonly string[];
|
|
106
|
+
/**
|
|
107
|
+
* Headers a write must carry, name to expected value (names compared
|
|
108
|
+
* without case, values exactly), in addition to the same-site check. A
|
|
109
|
+
* missing or different one is a 403 `header_required` before the API is
|
|
110
|
+
* called. `PUT` and `DELETE` only.
|
|
111
|
+
*/
|
|
112
|
+
readonly requireHeaders?: Readonly<Record<string, string>>;
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../src/media/options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D;;;;GAIG;AACH,MAAM,WAAW,SAAS,CAAC,OAAO,GAAG,OAAO;IAC3C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAA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3D"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { MediaArgs, MediaKindLimit, MediaProxyOptions } from './options';
|
|
2
|
+
export declare const prefixOf: (value: string | undefined, fallback: string) => string;
|
|
3
|
+
export interface Target {
|
|
4
|
+
readonly kind: string;
|
|
5
|
+
readonly limit: MediaKindLimit;
|
|
6
|
+
/** The path under the prefix, after the kind: empty, or `/<key>[/<size>]`. */
|
|
7
|
+
readonly rest: string;
|
|
8
|
+
readonly key: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
/** The method, the origin and the path checked: the target, or the refusal. */
|
|
11
|
+
export declare function checked(options: MediaProxyOptions<never>, args: MediaArgs, methods: readonly string[]): Response | Target;
|
|
12
|
+
//# sourceMappingURL=path.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../src/media/path.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAM9E,eAAO,MAAM,QAAQ,GAAI,OAAO,MAAM,GAAG,SAAS,EAAE,UAAU,MAAM,KAAG,MAC/B,CAAC;AAEzC,MAAM,WAAW,MAAM;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,8EAA8E;IAC9E,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAwBD,+EAA+E;AAC/E,wBAAgB,OAAO,CACtB,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,EACjC,IAAI,EAAE,SAAS,EACf,OAAO,EAAE,SAAS,MAAM,EAAE,GACxB,QAAQ,GAAG,MAAM,CASnB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MediaArgs, MediaProxyOptions } from './options';
|
|
2
|
+
/**
|
|
3
|
+
* A resource route's `loader`: `GET` and `HEAD` of `<prefix>/<kind>/<key>`
|
|
4
|
+
* and `<prefix>/<kind>/<key>/<size>`, relayed to the API with the session's
|
|
5
|
+
* Bearer. `Range`, `If-None-Match` and `If-Range` go up; the status (`200`,
|
|
6
|
+
* `206`, `304`, `404`, `416`, ...) and the allowed headers come back, the body
|
|
7
|
+
* streamed, never held. Without a session the read still goes (a public kind
|
|
8
|
+
* needs none) and the API answers `404` for the rest.
|
|
9
|
+
*/
|
|
10
|
+
export declare function proxyMediaRead<Context = unknown>(args: MediaArgs<Context>, options: MediaProxyOptions<Context>): Promise<Response>;
|
|
11
|
+
//# sourceMappingURL=read.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read.d.ts","sourceRoot":"","sources":["../../src/media/read.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAK9D;;;;;;;GAOG;AACH,wBAAsB,cAAc,CAAC,OAAO,GAAG,OAAO,EACrD,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,EACxB,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,GACjC,OAAO,CAAC,QAAQ,CAAC,CAInB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The proxy's own refusals, in the shape `@softistx/alxia-media` answers with:
|
|
3
|
+
* `{ "error": "<code>", ...extras }`, `limit` on a 413. The API's own
|
|
4
|
+
* answers come back untouched; these are the ones the proxy gives before or
|
|
5
|
+
* instead of the API's.
|
|
6
|
+
*/
|
|
7
|
+
/** The responses `refuse` made: a refusal of the proxy itself, as opposed to the API's. */
|
|
8
|
+
export declare const ownRefusals: WeakSet<Response>;
|
|
9
|
+
export declare function refuse(status: number, code: string, extras?: Readonly<Record<string, unknown>>, headers?: HeadersInit): Response;
|
|
10
|
+
export declare const notFound: () => Response;
|
|
11
|
+
//# sourceMappingURL=refusal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refusal.d.ts","sourceRoot":"","sources":["../../src/media/refusal.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,2FAA2F;AAC3F,eAAO,MAAM,WAAW,mBAA0B,CAAC;AAEnD,wBAAgB,MAAM,CACrB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAM,EAC9C,OAAO,GAAE,WAAgB,GACvB,QAAQ,CAYV;AAED,eAAO,MAAM,QAAQ,QAAO,QAAoC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MediaProxyOptions } from './options';
|
|
2
|
+
/**
|
|
3
|
+
* Runs `relay` and gives `onRefusal` (answers of 400 and above) and
|
|
4
|
+
* `onSuccess` (a write's 2xx) their say. With neither option the answer is
|
|
5
|
+
* returned untouched, its body still streaming.
|
|
6
|
+
*/
|
|
7
|
+
export declare function respond(options: MediaProxyOptions<never>, request: Request, write: boolean, relay: () => Promise<Response>): Promise<Response>;
|
|
8
|
+
//# sourceMappingURL=respond.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"respond.d.ts","sourceRoot":"","sources":["../../src/media/respond.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEX,iBAAiB,EAGjB,MAAM,WAAW,CAAC;AA2HnB;;;;GAIG;AACH,wBAAsB,OAAO,CAC5B,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC,EACjC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,OAAO,EACd,KAAK,EAAE,MAAM,OAAO,CAAC,QAAQ,CAAC,GAC5B,OAAO,CAAC,QAAQ,CAAC,CA6CnB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { MediaArgs, MediaProxyOptions } from './options';
|
|
2
|
+
/**
|
|
3
|
+
* A resource route's `action`: `PUT <prefix>/<kind>` with the raw file as the
|
|
4
|
+
* body, and `DELETE <prefix>/<kind>/<key>` for a kind that allows it. A
|
|
5
|
+
* session is required (401). An upload with no `Content-Length` is a 411
|
|
6
|
+
* (unless `allowUnsized`), a malformed one a 400 `size_mismatch`, and one
|
|
7
|
+
* over the kind's `maxBytes` a 413 `too_large` before the API is called; the
|
|
8
|
+
* body is streamed to the API, never held. The API's answer (`{ key,
|
|
9
|
+
* contentType, size }`, or a 400, 403, 408, 413, 415, 422, 429, 503) comes
|
|
10
|
+
* back as it is.
|
|
11
|
+
*/
|
|
12
|
+
export declare function proxyMediaWrite<Context = unknown>(args: MediaArgs<Context>, options: MediaProxyOptions<Context>): Promise<Response>;
|
|
13
|
+
//# sourceMappingURL=write.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../src/media/write.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAK9D;;;;;;;;;GASG;AACH,wBAAsB,eAAe,CAAC,OAAO,GAAG,OAAO,EACtD,IAAI,EAAE,SAAS,CAAC,OAAO,CAAC,EACxB,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC,GACjC,OAAO,CAAC,QAAQ,CAAC,CAInB"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@softistx/alxia-react-router/navigation`: the two behaviours every layout rewrites,
|
|
3
|
+
* focus on the page heading after a client navigation and a fade only when the
|
|
4
|
+
* pathname changes. `react` and `react-router` are its only imports, and both
|
|
5
|
+
* hooks render on the server.
|
|
6
|
+
*/
|
|
7
|
+
export { useFocusOnNavigate } from './use-focus-on-navigate';
|
|
8
|
+
export { DEFAULT_TRANSITION_MS, type RouteTransition, useRouteTransition, } from './use-route-transition';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/navigation/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EACN,qBAAqB,EACrB,KAAK,eAAe,EACpB,kBAAkB,GAClB,MAAM,wBAAwB,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// src/navigation/use-focus-on-navigate.ts
|
|
2
|
+
import { useEffect, useRef } from "react";
|
|
3
|
+
import { useLocation, useNavigationType } from "react-router";
|
|
4
|
+
var lastPathname;
|
|
5
|
+
function useFocusOnNavigate() {
|
|
6
|
+
const ref = useRef(null);
|
|
7
|
+
const { pathname } = useLocation();
|
|
8
|
+
const navigationType = useNavigationType();
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const previous = lastPathname;
|
|
11
|
+
lastPathname = pathname;
|
|
12
|
+
if (previous === undefined || previous === pathname)
|
|
13
|
+
return;
|
|
14
|
+
if (navigationType === "REPLACE")
|
|
15
|
+
return;
|
|
16
|
+
const element = ref.current;
|
|
17
|
+
if (!element)
|
|
18
|
+
return;
|
|
19
|
+
if (!element.hasAttribute("tabindex"))
|
|
20
|
+
element.tabIndex = -1;
|
|
21
|
+
element.focus();
|
|
22
|
+
}, [pathname, navigationType]);
|
|
23
|
+
return ref;
|
|
24
|
+
}
|
|
25
|
+
// src/navigation/use-route-transition.ts
|
|
26
|
+
import { useEffect as useEffect2, useState } from "react";
|
|
27
|
+
import { useLocation as useLocation2 } from "react-router";
|
|
28
|
+
var DEFAULT_TRANSITION_MS = 200;
|
|
29
|
+
function useRouteTransition(duration = DEFAULT_TRANSITION_MS) {
|
|
30
|
+
const { pathname } = useLocation2();
|
|
31
|
+
const [settled, setSettled] = useState(pathname);
|
|
32
|
+
const transitioning = settled !== pathname;
|
|
33
|
+
useEffect2(() => {
|
|
34
|
+
if (settled === pathname)
|
|
35
|
+
return;
|
|
36
|
+
const timer = setTimeout(() => setSettled(pathname), duration);
|
|
37
|
+
return () => clearTimeout(timer);
|
|
38
|
+
}, [settled, pathname, duration]);
|
|
39
|
+
return { pathname, transitioning };
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
DEFAULT_TRANSITION_MS,
|
|
43
|
+
useFocusOnNavigate,
|
|
44
|
+
useRouteTransition
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
//# debugId=CDFF9513DC9C430564756E2164756E21
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/navigation/use-focus-on-navigate.ts", "../src/navigation/use-route-transition.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { type RefObject, useEffect, useRef } from 'react';\nimport { useLocation, useNavigationType } from 'react-router';\n\n/**\n * The pathname the last mounted hook saw, kept across instances so a heading\n * rendered by each route (which mounts fresh on a navigation) still knows the\n * page changed. Effects run on the client only, so the server never sets it.\n */\nlet lastPathname: string | undefined;\n\n/** Forgets the last pathname (for specs). */\nexport function resetNavigationFocus(): void {\n\tlastPathname = undefined;\n}\n\n/**\n * Moves focus to the element the returned ref is on (the page heading) after a\n * client navigation: a `PUSH` or a `POP` that changed the pathname. It does\n * nothing on the first render (a load or a reload), on a `REPLACE` (even to\n * another pathname) and when only the search or the hash changed. It works in a\n * layout that stays mounted and in a heading each route renders.\n *\n * The element gets `tabIndex={-1}` when it has none, so a heading can take\n * focus without joining the tab order. `preventScroll` is `false`: the page\n * scrolls to the heading, as after a full page load.\n */\nexport function useFocusOnNavigate<\n\tT extends HTMLElement = HTMLHeadingElement,\n>(): RefObject<T | null> {\n\tconst ref = useRef<T | null>(null);\n\tconst { pathname } = useLocation();\n\tconst navigationType = useNavigationType();\n\n\tuseEffect(() => {\n\t\tconst previous = lastPathname;\n\t\tlastPathname = pathname;\n\t\tif (previous === undefined || previous === pathname) return;\n\t\tif (navigationType === 'REPLACE') return;\n\t\tconst element = ref.current;\n\t\tif (!element) return;\n\t\tif (!element.hasAttribute('tabindex')) element.tabIndex = -1;\n\t\telement.focus();\n\t}, [pathname, navigationType]);\n\n\treturn ref;\n}\n",
|
|
6
|
+
"import { useEffect, useState } from 'react';\nimport { useLocation } from 'react-router';\n\n/** Default length of the transition, in milliseconds. */\nexport const DEFAULT_TRANSITION_MS = 200;\n\nexport interface RouteTransition {\n\t/** The pathname the page is on. */\n\tpathname: string;\n\t/**\n\t * `true` for `duration` ms after the pathname changed; `false` on the first\n\t * render and when only the search or the hash changed. Put the fade class on\n\t * the content while it is `true`; `pathname` makes a fitting `key`.\n\t */\n\ttransitioning: boolean;\n}\n\n/**\n * Tells a layout when to fade its content: only when the pathname changes,\n * never for a search change of the same page or on the first render, so a\n * server-rendered page paints without a flash. It renders on the server.\n */\nexport function useRouteTransition(\n\tduration: number = DEFAULT_TRANSITION_MS,\n): RouteTransition {\n\tconst { pathname } = useLocation();\n\tconst [settled, setSettled] = useState(pathname);\n\tconst transitioning = settled !== pathname;\n\n\tuseEffect(() => {\n\t\tif (settled === pathname) return;\n\t\tconst timer = setTimeout(() => setSettled(pathname), duration);\n\t\treturn () => clearTimeout(timer);\n\t}, [settled, pathname, duration]);\n\n\treturn { pathname, transitioning };\n}\n"
|
|
7
|
+
],
|
|
8
|
+
"mappings": ";AAAA;AACA;AAOA,IAAI;AAkBG,SAAS,kBAEf,GAAwB;AAAA,EACxB,MAAM,MAAM,OAAiB,IAAI;AAAA,EACjC,QAAQ,aAAa,YAAY;AAAA,EACjC,MAAM,iBAAiB,kBAAkB;AAAA,EAEzC,UAAU,MAAM;AAAA,IACf,MAAM,WAAW;AAAA,IACjB,eAAe;AAAA,IACf,IAAI,aAAa,aAAa,aAAa;AAAA,MAAU;AAAA,IACrD,IAAI,mBAAmB;AAAA,MAAW;AAAA,IAClC,MAAM,UAAU,IAAI;AAAA,IACpB,IAAI,CAAC;AAAA,MAAS;AAAA,IACd,IAAI,CAAC,QAAQ,aAAa,UAAU;AAAA,MAAG,QAAQ,WAAW;AAAA,IAC1D,QAAQ,MAAM;AAAA,KACZ,CAAC,UAAU,cAAc,CAAC;AAAA,EAE7B,OAAO;AAAA;;AC5CR,sBAAS;AACT,wBAAS;AAGF,IAAM,wBAAwB;AAkB9B,SAAS,kBAAkB,CACjC,WAAmB,uBACD;AAAA,EAClB,QAAQ,aAAa,aAAY;AAAA,EACjC,OAAO,SAAS,cAAc,SAAS,QAAQ;AAAA,EAC/C,MAAM,gBAAgB,YAAY;AAAA,EAElC,WAAU,MAAM;AAAA,IACf,IAAI,YAAY;AAAA,MAAU;AAAA,IAC1B,MAAM,QAAQ,WAAW,MAAM,WAAW,QAAQ,GAAG,QAAQ;AAAA,IAC7D,OAAO,MAAM,aAAa,KAAK;AAAA,KAC7B,CAAC,SAAS,UAAU,QAAQ,CAAC;AAAA,EAEhC,OAAO,EAAE,UAAU,cAAc;AAAA;",
|
|
9
|
+
"debugId": "CDFF9513DC9C430564756E2164756E21",
|
|
10
|
+
"names": []
|
|
11
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type RefObject } from 'react';
|
|
2
|
+
/** Forgets the last pathname (for specs). */
|
|
3
|
+
export declare function resetNavigationFocus(): void;
|
|
4
|
+
/**
|
|
5
|
+
* Moves focus to the element the returned ref is on (the page heading) after a
|
|
6
|
+
* client navigation: a `PUSH` or a `POP` that changed the pathname. It does
|
|
7
|
+
* nothing on the first render (a load or a reload), on a `REPLACE` (even to
|
|
8
|
+
* another pathname) and when only the search or the hash changed. It works in a
|
|
9
|
+
* layout that stays mounted and in a heading each route renders.
|
|
10
|
+
*
|
|
11
|
+
* The element gets `tabIndex={-1}` when it has none, so a heading can take
|
|
12
|
+
* focus without joining the tab order. `preventScroll` is `false`: the page
|
|
13
|
+
* scrolls to the heading, as after a full page load.
|
|
14
|
+
*/
|
|
15
|
+
export declare function useFocusOnNavigate<T extends HTMLElement = HTMLHeadingElement>(): RefObject<T | null>;
|
|
16
|
+
//# sourceMappingURL=use-focus-on-navigate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-focus-on-navigate.d.ts","sourceRoot":"","sources":["../../src/navigation/use-focus-on-navigate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAqB,MAAM,OAAO,CAAC;AAU1D,6CAA6C;AAC7C,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CACjC,CAAC,SAAS,WAAW,GAAG,kBAAkB,KACtC,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,CAiBvB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** Default length of the transition, in milliseconds. */
|
|
2
|
+
export declare const DEFAULT_TRANSITION_MS = 200;
|
|
3
|
+
export interface RouteTransition {
|
|
4
|
+
/** The pathname the page is on. */
|
|
5
|
+
pathname: string;
|
|
6
|
+
/**
|
|
7
|
+
* `true` for `duration` ms after the pathname changed; `false` on the first
|
|
8
|
+
* render and when only the search or the hash changed. Put the fade class on
|
|
9
|
+
* the content while it is `true`; `pathname` makes a fitting `key`.
|
|
10
|
+
*/
|
|
11
|
+
transitioning: boolean;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Tells a layout when to fade its content: only when the pathname changes,
|
|
15
|
+
* never for a search change of the same page or on the first render, so a
|
|
16
|
+
* server-rendered page paints without a flash. It renders on the server.
|
|
17
|
+
*/
|
|
18
|
+
export declare function useRouteTransition(duration?: number): RouteTransition;
|
|
19
|
+
//# sourceMappingURL=use-route-transition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-route-transition.d.ts","sourceRoot":"","sources":["../../src/navigation/use-route-transition.ts"],"names":[],"mappings":"AAGA,yDAAyD;AACzD,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC,MAAM,WAAW,eAAe;IAC/B,mCAAmC;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;OAIG;IACH,aAAa,EAAE,OAAO,CAAC;CACvB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CACjC,QAAQ,GAAE,MAA8B,GACtC,eAAe,CAYjB"}
|
package/dist/nonce.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** `nonceOf`: the request's CSP nonce, read from alxia's context if a middleware set one. */
|
|
2
|
+
import { type ProviderLike } from './context';
|
|
3
|
+
/**
|
|
4
|
+
* This request's CSP nonce, for `entry.server.tsx`: the `nonce` alxia's
|
|
5
|
+
* middlewares put on the context — `secureHeaders({ nonce: true })` from
|
|
6
|
+
* `@softistx/alxia-secure-headers`, or a `derive` of your own — or `undefined` when
|
|
7
|
+
* none did, or when the request did not come through alxia. It reads the
|
|
8
|
+
* key if present: neither package depends on the other.
|
|
9
|
+
*
|
|
10
|
+
* ```tsx
|
|
11
|
+
* const nonce = nonceOf(loadContext);
|
|
12
|
+
* <ServerRouter context={routerContext} url={request.url} nonce={nonce} />
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
export declare function nonceOf(context: ProviderLike): string | undefined;
|
|
16
|
+
//# sourceMappingURL=nonce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nonce.d.ts","sourceRoot":"","sources":["../src/nonce.ts"],"names":[],"mappings":"AAAA,6FAA6F;AAC7F,OAAO,EAAgB,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAE5D;;;;;;;;;;;GAWG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAMjE"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/** The decision of a consent screen, as the page posts it. */
|
|
2
|
+
export type ConsentDecisionIntent = 'approve' | 'deny';
|
|
3
|
+
/**
|
|
4
|
+
* What a grant is bound to: the one workspace, account or tenant the viewer
|
|
5
|
+
* chose in the consent page's picker, as janus stores it (`{ type, id }`).
|
|
6
|
+
* A type only, as the answer is.
|
|
7
|
+
*/
|
|
8
|
+
export interface ConsentBound {
|
|
9
|
+
readonly type: string;
|
|
10
|
+
readonly id: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* What the consent action answers a page's fetcher, and what the page's
|
|
14
|
+
* `useConsent` reads. A type only: it is erased from both bundles.
|
|
15
|
+
*/
|
|
16
|
+
export type ConsentAnswer = {
|
|
17
|
+
readonly ok: true;
|
|
18
|
+
readonly intent: ConsentDecisionIntent;
|
|
19
|
+
readonly id: string;
|
|
20
|
+
/** Where the browser goes next: the client's callback, an http(s) address. */
|
|
21
|
+
readonly redirectTo: string;
|
|
22
|
+
} | {
|
|
23
|
+
readonly ok: false;
|
|
24
|
+
readonly intent: ConsentDecisionIntent;
|
|
25
|
+
readonly id: string;
|
|
26
|
+
/** The session is not confirmed lately: the page steps up and posts again. */
|
|
27
|
+
readonly stepUp: boolean;
|
|
28
|
+
/** The request is unknown, decided, lapsed or not the viewer's. */
|
|
29
|
+
readonly expired: boolean;
|
|
30
|
+
/** The worded refusal; empty for `stepUp` and `expired`. */
|
|
31
|
+
readonly error: string;
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=answer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"answer.d.ts","sourceRoot":"","sources":["../../src/oauth/answer.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,MAAM,MAAM,qBAAqB,GAAG,SAAS,GAAG,MAAM,CAAC;AAEvD;;;;GAIG;AACH,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,MAAM,MAAM,aAAa,GACtB;IACA,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC3B,GACD;IACA,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAC;IACvC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,8EAA8E;IAC9E,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,mEAAmE;IACnE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,4DAA4D;IAC5D,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACtB,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Binding a pending consent request to the browser that opened it. The
|
|
3
|
+
* relay (`@softistx/alxia-react-router/mcp`) sets the cookie when the API's
|
|
4
|
+
* `/oauth/authorize` sends the browser to the consent page; the consent route
|
|
5
|
+
* (`oauthConsent`) reads it. No import: both entry points share this file.
|
|
6
|
+
*/
|
|
7
|
+
/** The app's consent page, where the API's `/oauth/authorize` sends the browser. */
|
|
8
|
+
export declare const CONSENT_PATH = "/oauth/consent";
|
|
9
|
+
/** The cookie over HTTPS (`__Host-`: Secure, Path=/, no Domain). */
|
|
10
|
+
export declare const CONSENT_COOKIE = "__Host-alxia_oauth_request";
|
|
11
|
+
/** The cookie over plain HTTP (a development server). */
|
|
12
|
+
export declare const CONSENT_COOKIE_PLAIN = "alxia_oauth_request";
|
|
13
|
+
/** The header `oauthConsent` hands its `caller` to name the request this browser opened. */
|
|
14
|
+
export declare const CONSENT_REQUEST_HEADER = "x-alxia-oauth-request";
|
|
15
|
+
/** Seconds the cookie lives: a pending request is short-lived. */
|
|
16
|
+
export declare const CONSENT_COOKIE_MAX_AGE: number;
|
|
17
|
+
/** What `oauthConsent` hands the `caller` of its options. */
|
|
18
|
+
export interface ConsentBinding {
|
|
19
|
+
/** The request this browser opened, or `undefined`. */
|
|
20
|
+
readonly requestId: string | undefined;
|
|
21
|
+
/** `{ [header]: requestId }` to forward to the API, empty without a binding. */
|
|
22
|
+
readonly headers: Readonly<Record<string, string>>;
|
|
23
|
+
}
|
|
24
|
+
/** The cookie's name: `__Host-` over HTTPS, a plain one over plain HTTP. */
|
|
25
|
+
export declare const consentCookieName: (secure: boolean) => string;
|
|
26
|
+
/**
|
|
27
|
+
* The pending request an API answer sends the browser to consent to, or
|
|
28
|
+
* `undefined`. Only a 3xx to `origin`'s own `path` counts (an absolute
|
|
29
|
+
* location or a relative one): an error redirect to a client's `redirect_uri`
|
|
30
|
+
* that ends in `/oauth/consent` names nothing.
|
|
31
|
+
*/
|
|
32
|
+
export declare function consentRequestOf(response: Response, origin: string, path?: string): string | undefined;
|
|
33
|
+
/** The `Set-Cookie` value binding request `id` to this browser. */
|
|
34
|
+
export declare function consentBindingCookie(id: string, secure: boolean): string;
|
|
35
|
+
/**
|
|
36
|
+
* The request this browser opened, or `undefined`: the binding cookie named
|
|
37
|
+
* by the scheme of `origin` when given (the one the relay wrote it with),
|
|
38
|
+
* else by the request's own scheme.
|
|
39
|
+
*/
|
|
40
|
+
export declare function boundConsentRequest(request: Request, origin?: string): string | undefined;
|
|
41
|
+
/** The binding of `request`: the id its cookie names, and that id in `header`. */
|
|
42
|
+
export declare function consentBindingOf(request: Request, header?: string, origin?: string): ConsentBinding;
|
|
43
|
+
//# sourceMappingURL=binding.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../../src/oauth/binding.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,oFAAoF;AACpF,eAAO,MAAM,YAAY,mBAAmB,CAAC;AAE7C,oEAAoE;AACpE,eAAO,MAAM,cAAc,+BAA+B,CAAC;AAE3D,yDAAyD;AACzD,eAAO,MAAM,oBAAoB,wBAAwB,CAAC;AA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