@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,134 @@
|
|
|
1
|
+
import { data, type ShouldRevalidateFunctionArgs } from 'react-router';
|
|
2
|
+
import { type ApiErrorLike } from '../errors/api-error';
|
|
3
|
+
import type { ApiErrors } from '../errors/api-errors';
|
|
4
|
+
import type { JsonActions } from '../errors/json-actions';
|
|
5
|
+
import type { ConsentAnswer, ConsentBound, ConsentDecisionIntent } from './answer';
|
|
6
|
+
import { type ConsentBinding } from './binding';
|
|
7
|
+
/** Where a decided request sends the browser, as `OAuthDecision` of `@softistx/janus-oauth/graphql` has it. */
|
|
8
|
+
export interface ConsentRedirect {
|
|
9
|
+
readonly redirectTo: string;
|
|
10
|
+
}
|
|
11
|
+
/** The decision a page posted, once checked. */
|
|
12
|
+
export interface ConsentInput {
|
|
13
|
+
readonly intent: ConsentDecisionIntent;
|
|
14
|
+
readonly id: string;
|
|
15
|
+
/** The scopes allowed; all the asked ones when absent. */
|
|
16
|
+
readonly scopes?: readonly string[] | undefined;
|
|
17
|
+
/** What the grant is bound to, when the page has a picker; never on a denial. */
|
|
18
|
+
readonly bound?: ConsentBound | undefined;
|
|
19
|
+
}
|
|
20
|
+
export interface ConsentOptions<L extends string, Caller, Viewer, Pending extends object, Choice extends object = never> {
|
|
21
|
+
/** The app's `jsonActions()`: the same-site and JSON checks of the action. */
|
|
22
|
+
readonly json: Pick<JsonActions, 'readJson' | 'requireJsonPost'>;
|
|
23
|
+
/** The app's `createApiErrors()`: words the refusals. */
|
|
24
|
+
readonly errors: Pick<ApiErrors<L>, 'apiRefusal'>;
|
|
25
|
+
/**
|
|
26
|
+
* The signed-in viewer, or a thrown redirect to sign in that comes back to
|
|
27
|
+
* this very address, request id included (`SessionFlow.signInRedirect`
|
|
28
|
+
* does). `headers` are added to the answer (a refreshed session cookie).
|
|
29
|
+
*/
|
|
30
|
+
viewer(request: Request): Promise<{
|
|
31
|
+
readonly viewer: Viewer;
|
|
32
|
+
readonly headers?: HeadersInit;
|
|
33
|
+
}>;
|
|
34
|
+
/**
|
|
35
|
+
* The caller that carries the request's session to the API. `binding`
|
|
36
|
+
* names the request this browser opened (the cookie `mcpRelay` set): put
|
|
37
|
+
* `binding.headers` on the API call so the server can check it.
|
|
38
|
+
*/
|
|
39
|
+
caller(request: Request, binding: ConsentBinding): Caller;
|
|
40
|
+
/** `oauthRequest(id)`: the pending request, or `null` when the API has none. */
|
|
41
|
+
find(id: string, caller: Caller): Promise<Pending | null | undefined>;
|
|
42
|
+
/** `approveOAuthRequest(id, scopes, bound)`: `bound` is there when the page posted one. */
|
|
43
|
+
approve(input: {
|
|
44
|
+
readonly id: string;
|
|
45
|
+
readonly scopes?: readonly string[];
|
|
46
|
+
readonly bound?: ConsentBound;
|
|
47
|
+
}, caller: Caller): Promise<ConsentRedirect>;
|
|
48
|
+
/** `denyOAuthRequest(id)`. */
|
|
49
|
+
deny(input: {
|
|
50
|
+
readonly id: string;
|
|
51
|
+
}, caller: Caller): Promise<ConsentRedirect>;
|
|
52
|
+
/**
|
|
53
|
+
* Whether an API refusal means the request is unknown, decided, lapsed or
|
|
54
|
+
* not the viewer's (the API cannot tell which). Default: a 404.
|
|
55
|
+
*/
|
|
56
|
+
notFound?(error: ApiErrorLike): boolean;
|
|
57
|
+
/** The API's step-up code. Default `STEP_UP_REQUIRED`. */
|
|
58
|
+
stepUpRequired?: string;
|
|
59
|
+
/**
|
|
60
|
+
* What the page's picker offers to bind the grant to (the viewer's
|
|
61
|
+
* workspaces), loaded beside a pending request and answered as the
|
|
62
|
+
* loader's `choices`. Without it, `choices` is empty.
|
|
63
|
+
*/
|
|
64
|
+
choices?(caller: Caller, viewer: Viewer): Promise<readonly Choice[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Whether an approval must name what the grant is bound to: one without
|
|
67
|
+
* `bound` is then a 400. `false` by default. The API still checks the
|
|
68
|
+
* viewer may bind it there.
|
|
69
|
+
*/
|
|
70
|
+
readonly requireBound?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Whether a request this browser did not open is refused here: the id in
|
|
73
|
+
* the address must be the one the binding cookie names, else the loader
|
|
74
|
+
* answers the expired state (a 404) and the action an expired refusal,
|
|
75
|
+
* without asking the API. `false` by default, so an app that does not
|
|
76
|
+
* bind yet is unchanged; turn it on once `mcpRelay` sets the cookie.
|
|
77
|
+
*/
|
|
78
|
+
readonly requireBinding?: boolean;
|
|
79
|
+
/** The header of `binding.headers`. Default `CONSENT_REQUEST_HEADER`. */
|
|
80
|
+
readonly bindingHeader?: string;
|
|
81
|
+
/**
|
|
82
|
+
* The app's public origin (`https://app.example`), the one given to
|
|
83
|
+
* `mcpRelay({ consent: { origin } })`: its scheme picks the binding
|
|
84
|
+
* cookie's name (`__Host-` over HTTPS, plain over HTTP), as it does for the
|
|
85
|
+
* relay that wrote it. Default: the request's own scheme, which is `http:`
|
|
86
|
+
* behind a proxy that ends TLS without a trusted `X-Forwarded-Proto`, so
|
|
87
|
+
* the cookie is not found and every consent reads as expired.
|
|
88
|
+
*/
|
|
89
|
+
readonly origin?: string;
|
|
90
|
+
}
|
|
91
|
+
export interface ConsentRoute<L extends string, Viewer, Pending extends object, Choice extends object = never> {
|
|
92
|
+
/**
|
|
93
|
+
* The route's loader: the viewer, the pending request (`null` for an
|
|
94
|
+
* unknown one or none in the address, answered with a 404 so the page shows
|
|
95
|
+
* its expired state) and the picker's `choices` (empty without a pending
|
|
96
|
+
* request or a `choices` option). Never cached: it names a one-time
|
|
97
|
+
* request.
|
|
98
|
+
*/
|
|
99
|
+
loader(request: Request): Promise<ReturnType<typeof data<{
|
|
100
|
+
pending: Pending | null;
|
|
101
|
+
viewer: Viewer;
|
|
102
|
+
choices: readonly Choice[];
|
|
103
|
+
}>>>;
|
|
104
|
+
/**
|
|
105
|
+
* The route's action: approves or denies the JSON `{ intent, id, scopes?,
|
|
106
|
+
* bound? }` and answers a `ConsentAnswer` for the page's fetcher.
|
|
107
|
+
*/
|
|
108
|
+
action(request: Request, language: L): Promise<ConsentAnswer | ReturnType<typeof data<ConsentAnswer>>>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* The server side of the screen where a viewer allows or denies an OAuth
|
|
112
|
+
* client (`oauthRequest`, `approveOAuthRequest` and `denyOAuthRequest` of
|
|
113
|
+
* `@softistx/janus-oauth/graphql`): a loader and an action for one route, the
|
|
114
|
+
* GraphQL calls passed in. The page reads `useConsent`
|
|
115
|
+
* (`@softistx/alxia-react-router/oauth/react`).
|
|
116
|
+
*
|
|
117
|
+
* With `choices`, the loader also answers what the page's picker offers
|
|
118
|
+
* (the viewer's workspaces), and the page posts the one chosen as `bound`,
|
|
119
|
+
* which `approve` passes on; `requireBound` refuses an approval without one.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* const consent = oauthConsent({ json, errors, viewer, caller, find, approve, deny });
|
|
123
|
+
* export const loader = ({ request }) => consent.loader(request);
|
|
124
|
+
* export const action = ({ request }) => consent.action(request, language);
|
|
125
|
+
*/
|
|
126
|
+
export declare function oauthConsent<L extends string, Caller, Viewer, Pending extends object, Choice extends object = never>(options: ConsentOptions<L, Caller, Viewer, Pending, Choice>): ConsentRoute<L, Viewer, Pending, Choice>;
|
|
127
|
+
/**
|
|
128
|
+
* `shouldRevalidate` of the consent route: never reload after a decision.
|
|
129
|
+
* The decision spends the request, so the loader would answer "expired"
|
|
130
|
+
* while the browser is on its way to the client's callback. Any other change
|
|
131
|
+
* (another `request_id`, a navigation) reloads as usual.
|
|
132
|
+
*/
|
|
133
|
+
export declare function consentShouldRevalidate({ formMethod, defaultShouldRevalidate, }: Pick<ShouldRevalidateFunctionArgs, 'formMethod' | 'defaultShouldRevalidate'>): boolean;
|
|
134
|
+
//# sourceMappingURL=consent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"consent.d.ts","sourceRoot":"","sources":["../../src/oauth/consent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,4BAA4B,EAAE,MAAM,cAAc,CAAC;AACvE,OAAO,EAAE,KAAK,YAAY,EAAkB,MAAM,qBAAqB,CAAC;AACxE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAE1D,OAAO,KAAK,EACX,aAAa,EACb,YAAY,EACZ,qBAAqB,EACrB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,KAAK,cAAc,EAAoB,MAAM,WAAW,CAAC;AAGlE,+GAA+G;AAC/G,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED,gDAAgD;AAChD,MAAM,WAAW,YAAY;IAC5B,QAAQ,CAAC,MAAM,EAA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;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAC3B,CAAC,SAAS,MAAM,EAChB,MAAM,EACN,MAAM,EACN,OAAO,SAAS,MAAM,EACtB,MAAM,SAAS,MAAM,GAAG,KAAK,EAE7B,OAAO,EAAE,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,GACzD,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,CAsG1C;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,EACvC,UAAU,EACV,uBAAuB,GACvB,EAAE,IAAI,CACN,4BAA4B,EAC5B,YAAY,GAAG,yBAAyB,CACxC,GAAG,OAAO,CAEV"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { type ApiErrorLike } from '../errors/api-error';
|
|
2
|
+
/**
|
|
3
|
+
* What an app knows about one scope the API names. `K` is the type of its
|
|
4
|
+
* keys: `oauthGrants` infers it from the `scopes` table, so a literal table
|
|
5
|
+
* gives a literal union; `string` otherwise.
|
|
6
|
+
*/
|
|
7
|
+
export interface GrantScopeInfo<K extends string = string> {
|
|
8
|
+
/** The app's own i18n key for the scope (`read`, `write`, …). */
|
|
9
|
+
readonly key?: K;
|
|
10
|
+
/** What the scope lets the client do, for a card's tone and word. */
|
|
11
|
+
readonly access?: 'read' | 'write';
|
|
12
|
+
}
|
|
13
|
+
/** One scope of a grant: the API's name and label, plus what the app's table knows of it. */
|
|
14
|
+
export interface GrantScope<K extends string = string> {
|
|
15
|
+
readonly id: string;
|
|
16
|
+
/** The API's own label: what shows when the app has no words for the scope. */
|
|
17
|
+
readonly label: string;
|
|
18
|
+
readonly key?: K;
|
|
19
|
+
readonly access?: 'read' | 'write';
|
|
20
|
+
}
|
|
21
|
+
/** The least a grant must have (`OAuthConnectedApp` of `@softistx/janus-oauth/graphql`). */
|
|
22
|
+
export interface GrantLike {
|
|
23
|
+
readonly createdAt: string;
|
|
24
|
+
readonly scopes: readonly {
|
|
25
|
+
readonly name: string;
|
|
26
|
+
readonly label: string;
|
|
27
|
+
}[];
|
|
28
|
+
}
|
|
29
|
+
/** A grant as `list` answers it: the scopes mapped, the rest as the API sent it. */
|
|
30
|
+
export type ListedGrant<G extends GrantLike, K extends string = string> = Omit<G, 'scopes'> & {
|
|
31
|
+
readonly scopes: readonly GrantScope<K>[];
|
|
32
|
+
};
|
|
33
|
+
/** What `revoke` answers; a refusal other than these is thrown. */
|
|
34
|
+
export type RevokeResult = {
|
|
35
|
+
readonly status: 'revoked';
|
|
36
|
+
readonly id: string;
|
|
37
|
+
}
|
|
38
|
+
/** The API no longer knows the grant: what the user wanted is done. */
|
|
39
|
+
| {
|
|
40
|
+
readonly status: 'already-revoked';
|
|
41
|
+
readonly id: string;
|
|
42
|
+
}
|
|
43
|
+
/** The session is not confirmed lately: step up, then call `revoke` again. */
|
|
44
|
+
| {
|
|
45
|
+
readonly status: 'step-up';
|
|
46
|
+
readonly id: string;
|
|
47
|
+
};
|
|
48
|
+
export interface GrantsOptions<Ctx, G extends GrantLike, K extends string = string> {
|
|
49
|
+
/**
|
|
50
|
+
* The grants of the viewer (or, with a `ctx` that names it, of another
|
|
51
|
+
* account), in the order the API gives (oldest first).
|
|
52
|
+
*/
|
|
53
|
+
list(ctx: Ctx): Promise<readonly G[]>;
|
|
54
|
+
/** The revoking mutation for one grant. */
|
|
55
|
+
revoke(ctx: Ctx, id: string): Promise<unknown>;
|
|
56
|
+
/** The scopes the app words itself, by the API's scope name. */
|
|
57
|
+
readonly scopes?: Readonly<Record<string, GrantScopeInfo<K>>>;
|
|
58
|
+
/**
|
|
59
|
+
* Whether a refusal of `revoke` means the grant is unknown (revoked
|
|
60
|
+
* elsewhere). Default: a 404.
|
|
61
|
+
*/
|
|
62
|
+
notFound?(error: ApiErrorLike): boolean;
|
|
63
|
+
/** The API's step-up code. Default `STEP_UP_REQUIRED`. */
|
|
64
|
+
readonly stepUpRequired?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface GrantsRoute<Ctx, G extends GrantLike, K extends string = string> {
|
|
67
|
+
/** The grants, newest first by `createdAt`, their scopes mapped. */
|
|
68
|
+
list(ctx: Ctx): Promise<ListedGrant<G, K>[]>;
|
|
69
|
+
/** Revokes one grant; see `RevokeResult`. */
|
|
70
|
+
revoke(ctx: Ctx, id: string): Promise<RevokeResult>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The server side of an account's connected apps (the OAuth grants of
|
|
74
|
+
* `@softistx/janus-oauth/graphql`): a sorted, mapped list for a loader and a
|
|
75
|
+
* revoke step for an action, over the app's own GraphQL calls. `Ctx` is
|
|
76
|
+
* whatever the app's functions need (a caller, a user id). The page's
|
|
77
|
+
* step-up replay is `useStepUpReplay` (see the session guide).
|
|
78
|
+
*
|
|
79
|
+
* `K` is inferred from the keys of the `scopes` table: declare it `as const`
|
|
80
|
+
* and a listed scope's `key` is `K | undefined` (`'read' | 'write' | undefined`),
|
|
81
|
+
* with no cast; without a literal table it stays `string`.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* const grants = oauthGrants({ list: (c) => connectedApps(c), revoke: (c, id) => revokeApp(c, id) });
|
|
85
|
+
* export const loader = async ({ request }) => ({ apps: await grants.list(caller(request)) });
|
|
86
|
+
*/
|
|
87
|
+
export declare function oauthGrants<Ctx, G extends GrantLike, K extends string = string>(options: GrantsOptions<Ctx, G, K>): GrantsRoute<Ctx, G, K>;
|
|
88
|
+
//# sourceMappingURL=grants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grants.d.ts","sourceRoot":"","sources":["../../src/oauth/grants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAkB,MAAM,qBAAqB,CAAC;AAIxE;;;;GAIG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,SAAS,MAAM,GAAG,MAAM;IACxD,iEAAiE;IACjE,QAAQ,CAAC,GAAG,CAAC,EA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/alxia-react-router/oauth`: the server side of the screen where a viewer
|
|
3
|
+
* allows or denies an OAuth client, and the account's connected apps (the
|
|
4
|
+
* GraphQL of `@softistx/janus-oauth/graphql`): `oauthConsent`'s loader and action
|
|
5
|
+
* and `oauthGrants`' list and revoke, over the app's own GraphQL calls, and
|
|
6
|
+
* the pure helpers they use. It may import `react-router`, `/errors`' files
|
|
7
|
+
* and `/session`'s step-up code, nothing else. The page's hook is
|
|
8
|
+
* `/oauth/react`.
|
|
9
|
+
*/
|
|
10
|
+
export { type DataRefusal, isRouteRefusal, type RouteRefusal, routeRefusalStatus, } from '../errors/route-refusal';
|
|
11
|
+
export type { ConsentAnswer, ConsentBound, ConsentDecisionIntent, } from './answer';
|
|
12
|
+
export { boundConsentRequest, CONSENT_COOKIE, CONSENT_COOKIE_MAX_AGE, CONSENT_COOKIE_PLAIN, CONSENT_PATH, CONSENT_REQUEST_HEADER, type ConsentBinding, consentBindingCookie, consentBindingOf, consentCookieName, consentRequestOf, } from './binding';
|
|
13
|
+
export { type ConsentInput, type ConsentOptions, type ConsentRedirect, type ConsentRoute, consentShouldRevalidate, oauthConsent, } from './consent';
|
|
14
|
+
export { type GrantLike, type GrantScope, type GrantScopeInfo, type GrantsOptions, type GrantsRoute, type ListedGrant, oauthGrants, type RevokeResult, } from './grants';
|
|
15
|
+
export { followableRedirect, requestIdOf } from './model';
|
|
16
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/oauth/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACN,KAAK,WAAW,EAChB,cAAc,EACd,KAAK,YAAY,EACjB,kBAAkB,GAClB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EACX,aAAa,EACb,YAAY,EACZ,qBAAqB,GACrB,MAAM,UAAU,CAAC;AAClB,OAAO,EACN,mBAAmB,EACnB,cAAc,EACd,sBAAsB,EACtB,oBAAoB,EACpB,YAAY,EACZ,sBAAsB,EACtB,KAAK,cAAc,EACnB,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GAChB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,uBAAuB,EACvB,YAAY,GACZ,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,WAAW,EACX,KAAK,YAAY,GACjB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CONSENT_PATH2,
|
|
3
|
+
CONSENT_COOKIE2,
|
|
4
|
+
CONSENT_COOKIE_PLAIN2,
|
|
5
|
+
CONSENT_REQUEST_HEADER2,
|
|
6
|
+
CONSENT_COOKIE_MAX_AGE2,
|
|
7
|
+
consentCookieName2,
|
|
8
|
+
consentRequestOf2,
|
|
9
|
+
consentBindingCookie2,
|
|
10
|
+
boundConsentRequest2,
|
|
11
|
+
consentBindingOf2
|
|
12
|
+
} from "../chunks/index-j4ktpcke.js";
|
|
13
|
+
import {
|
|
14
|
+
isApiErrorLike2
|
|
15
|
+
} from "../chunks/index-wyypkfdv.js";
|
|
16
|
+
import {
|
|
17
|
+
fetcherRefusal
|
|
18
|
+
} from "../chunks/index-pghmb2dm.js";
|
|
19
|
+
import {
|
|
20
|
+
STEP_UP_REQUIRED2
|
|
21
|
+
} from "../chunks/index-vr82typq.js";
|
|
22
|
+
import {
|
|
23
|
+
newestFirst
|
|
24
|
+
} from "../chunks/index-whj6h5eg.js";
|
|
25
|
+
import {
|
|
26
|
+
isRouteRefusal2,
|
|
27
|
+
routeRefusalStatus2
|
|
28
|
+
} from "../chunks/index-thyabr5n.js";
|
|
29
|
+
// src/oauth/consent.ts
|
|
30
|
+
import { data } from "react-router";
|
|
31
|
+
|
|
32
|
+
// src/oauth/model.ts
|
|
33
|
+
function requestIdOf(url) {
|
|
34
|
+
const id = url.searchParams.get("request_id") ?? url.searchParams.get("request");
|
|
35
|
+
const trimmed = id?.trim();
|
|
36
|
+
return trimmed ? trimmed : undefined;
|
|
37
|
+
}
|
|
38
|
+
function followableRedirect(value) {
|
|
39
|
+
if (typeof value !== "string")
|
|
40
|
+
return;
|
|
41
|
+
let url;
|
|
42
|
+
try {
|
|
43
|
+
url = new URL(value);
|
|
44
|
+
} catch {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
return url.protocol === "https:" || url.protocol === "http:" ? url.href : undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// src/oauth/consent.ts
|
|
51
|
+
var isStrings = (value) => Array.isArray(value) && value.every((item) => typeof item === "string" && item.length > 0);
|
|
52
|
+
var isText = (value) => typeof value === "string" && value.length > 0;
|
|
53
|
+
function boundOf(value) {
|
|
54
|
+
if (value === undefined)
|
|
55
|
+
return;
|
|
56
|
+
const { type, id } = typeof value === "object" && value !== null ? value : {};
|
|
57
|
+
if (!isText(type) || !isText(id))
|
|
58
|
+
throw data("Bad consent request", { status: 400 });
|
|
59
|
+
return { type, id };
|
|
60
|
+
}
|
|
61
|
+
function inputOf(body, requireBound) {
|
|
62
|
+
const raw = typeof body === "object" && body !== null ? body : {};
|
|
63
|
+
const { intent, id, scopes } = raw;
|
|
64
|
+
if (intent !== "approve" && intent !== "deny" || !isText(id) || scopes !== undefined && !isStrings(scopes)) {
|
|
65
|
+
throw data("Bad consent request", { status: 400 });
|
|
66
|
+
}
|
|
67
|
+
if (intent === "deny")
|
|
68
|
+
return { intent, id, scopes };
|
|
69
|
+
const bound = boundOf(raw["bound"]);
|
|
70
|
+
if (requireBound && bound === undefined)
|
|
71
|
+
throw data("Bad consent request", { status: 400 });
|
|
72
|
+
return { intent, id, scopes, bound };
|
|
73
|
+
}
|
|
74
|
+
function oauthConsent(options) {
|
|
75
|
+
const notFound = options.notFound ?? ((error) => error.status === 404);
|
|
76
|
+
const stepUpCode = options.stepUpRequired ?? STEP_UP_REQUIRED2;
|
|
77
|
+
const origin = options.origin;
|
|
78
|
+
if (origin !== undefined && !(URL.canParse(origin) && /^https?:$/.test(new URL(origin).protocol))) {
|
|
79
|
+
throw new TypeError(`oauthConsent: origin must be an http(s) origin, got "${origin}"`);
|
|
80
|
+
}
|
|
81
|
+
const unbound = (id, binding) => options.requireBinding === true && binding.requestId !== id;
|
|
82
|
+
async function loader(request) {
|
|
83
|
+
const { viewer, headers: viewerHeaders } = await options.viewer(request);
|
|
84
|
+
const headers = new Headers(viewerHeaders);
|
|
85
|
+
headers.set("Cache-Control", "no-store");
|
|
86
|
+
const id = requestIdOf(new URL(request.url));
|
|
87
|
+
let pending = null;
|
|
88
|
+
let choices = [];
|
|
89
|
+
const binding = consentBindingOf2(request, options.bindingHeader, origin);
|
|
90
|
+
if (id && !unbound(id, binding)) {
|
|
91
|
+
const caller = options.caller(request, binding);
|
|
92
|
+
try {
|
|
93
|
+
pending = await options.find(id, caller) ?? null;
|
|
94
|
+
} catch (error) {
|
|
95
|
+
if (!(isApiErrorLike2(error) && notFound(error)))
|
|
96
|
+
throw error;
|
|
97
|
+
}
|
|
98
|
+
if (pending && options.choices)
|
|
99
|
+
choices = await options.choices(caller, viewer);
|
|
100
|
+
}
|
|
101
|
+
return data({ pending, viewer, choices }, pending ? { headers } : { status: 404, headers });
|
|
102
|
+
}
|
|
103
|
+
async function action(request, language) {
|
|
104
|
+
options.json.requireJsonPost(request);
|
|
105
|
+
const input = inputOf(await options.json.readJson(request), options.requireBound === true);
|
|
106
|
+
const about = { intent: input.intent, id: input.id };
|
|
107
|
+
const binding = consentBindingOf2(request, options.bindingHeader, origin);
|
|
108
|
+
if (unbound(input.id, binding)) {
|
|
109
|
+
return data({
|
|
110
|
+
ok: false,
|
|
111
|
+
...about,
|
|
112
|
+
stepUp: false,
|
|
113
|
+
expired: true,
|
|
114
|
+
error: ""
|
|
115
|
+
}, { status: 404 });
|
|
116
|
+
}
|
|
117
|
+
const caller = options.caller(request, binding);
|
|
118
|
+
try {
|
|
119
|
+
const { redirectTo } = input.intent === "approve" ? await options.approve({
|
|
120
|
+
id: input.id,
|
|
121
|
+
...input.scopes && { scopes: input.scopes },
|
|
122
|
+
...input.bound && { bound: input.bound }
|
|
123
|
+
}, caller) : await options.deny({ id: input.id }, caller);
|
|
124
|
+
const next = followableRedirect(redirectTo);
|
|
125
|
+
if (!next) {
|
|
126
|
+
throw new Error("The API answered a redirect that is not an address");
|
|
127
|
+
}
|
|
128
|
+
return { ok: true, ...about, redirectTo: next };
|
|
129
|
+
} catch (error) {
|
|
130
|
+
const code = isApiErrorLike2(error) ? error.code : undefined;
|
|
131
|
+
const { message, status } = fetcherRefusal(options.errors, error, language);
|
|
132
|
+
const stepUp = code === stepUpCode;
|
|
133
|
+
const expired = isApiErrorLike2(error) && !stepUp && notFound(error);
|
|
134
|
+
return data({
|
|
135
|
+
ok: false,
|
|
136
|
+
...about,
|
|
137
|
+
stepUp,
|
|
138
|
+
expired,
|
|
139
|
+
error: stepUp || expired ? "" : message
|
|
140
|
+
}, { status });
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return { loader, action };
|
|
144
|
+
}
|
|
145
|
+
function consentShouldRevalidate({
|
|
146
|
+
formMethod,
|
|
147
|
+
defaultShouldRevalidate
|
|
148
|
+
}) {
|
|
149
|
+
return formMethod ? false : defaultShouldRevalidate;
|
|
150
|
+
}
|
|
151
|
+
// src/oauth/grants.ts
|
|
152
|
+
function oauthGrants(options) {
|
|
153
|
+
const notFound = options.notFound ?? ((error) => error.status === 404);
|
|
154
|
+
const stepUpCode = options.stepUpRequired ?? STEP_UP_REQUIRED2;
|
|
155
|
+
const table = options.scopes ?? {};
|
|
156
|
+
async function list(ctx) {
|
|
157
|
+
return newestFirst(await options.list(ctx)).map((grant) => ({
|
|
158
|
+
...grant,
|
|
159
|
+
scopes: grant.scopes.map(({ name, label }) => {
|
|
160
|
+
const info = Object.hasOwn(table, name) ? table[name] : undefined;
|
|
161
|
+
return {
|
|
162
|
+
id: name,
|
|
163
|
+
label,
|
|
164
|
+
...info?.key !== undefined && { key: info.key },
|
|
165
|
+
...info?.access !== undefined && { access: info.access }
|
|
166
|
+
};
|
|
167
|
+
})
|
|
168
|
+
}));
|
|
169
|
+
}
|
|
170
|
+
async function revoke(ctx, id) {
|
|
171
|
+
try {
|
|
172
|
+
await options.revoke(ctx, id);
|
|
173
|
+
return { status: "revoked", id };
|
|
174
|
+
} catch (error) {
|
|
175
|
+
if (isApiErrorLike2(error)) {
|
|
176
|
+
if (error.code === stepUpCode)
|
|
177
|
+
return { status: "step-up", id };
|
|
178
|
+
if (notFound(error))
|
|
179
|
+
return { status: "already-revoked", id };
|
|
180
|
+
}
|
|
181
|
+
throw error;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return { list, revoke };
|
|
185
|
+
}
|
|
186
|
+
export {
|
|
187
|
+
CONSENT_COOKIE2 as CONSENT_COOKIE,
|
|
188
|
+
CONSENT_COOKIE_MAX_AGE2 as CONSENT_COOKIE_MAX_AGE,
|
|
189
|
+
CONSENT_COOKIE_PLAIN2 as CONSENT_COOKIE_PLAIN,
|
|
190
|
+
CONSENT_PATH2 as CONSENT_PATH,
|
|
191
|
+
CONSENT_REQUEST_HEADER2 as CONSENT_REQUEST_HEADER,
|
|
192
|
+
boundConsentRequest2 as boundConsentRequest,
|
|
193
|
+
consentBindingCookie2 as consentBindingCookie,
|
|
194
|
+
consentBindingOf2 as consentBindingOf,
|
|
195
|
+
consentCookieName2 as consentCookieName,
|
|
196
|
+
consentRequestOf2 as consentRequestOf,
|
|
197
|
+
consentShouldRevalidate,
|
|
198
|
+
followableRedirect,
|
|
199
|
+
isRouteRefusal2 as isRouteRefusal,
|
|
200
|
+
oauthConsent,
|
|
201
|
+
oauthGrants,
|
|
202
|
+
requestIdOf,
|
|
203
|
+
routeRefusalStatus2 as routeRefusalStatus
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
//# debugId=8010B04824A5255B64756E2164756E21
|
|
207
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/oauth/consent.ts", "../src/oauth/model.ts", "../src/oauth/grants.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import { data, type ShouldRevalidateFunctionArgs } from 'react-router';\nimport { type ApiErrorLike, isApiErrorLike } from '../errors/api-error';\nimport type { ApiErrors } from '../errors/api-errors';\nimport { fetcherRefusal } from '../errors/fetcher-result';\nimport type { JsonActions } from '../errors/json-actions';\nimport { STEP_UP_REQUIRED } from '../session/step-up-codes';\nimport type {\n\tConsentAnswer,\n\tConsentBound,\n\tConsentDecisionIntent,\n} from './answer';\nimport { type ConsentBinding, consentBindingOf } from './binding';\nimport { followableRedirect, requestIdOf } from './model';\n\n/** Where a decided request sends the browser, as `OAuthDecision` of `@softistx/janus-oauth/graphql` has it. */\nexport interface ConsentRedirect {\n\treadonly redirectTo: string;\n}\n\n/** The decision a page posted, once checked. */\nexport interface ConsentInput {\n\treadonly intent: ConsentDecisionIntent;\n\treadonly id: string;\n\t/** The scopes allowed; all the asked ones when absent. */\n\treadonly scopes?: readonly string[] | undefined;\n\t/** What the grant is bound to, when the page has a picker; never on a denial. */\n\treadonly bound?: ConsentBound | undefined;\n}\n\nexport interface ConsentOptions<\n\tL extends string,\n\tCaller,\n\tViewer,\n\tPending extends object,\n\tChoice extends object = never,\n> {\n\t/** The app's `jsonActions()`: the same-site and JSON checks of the action. */\n\treadonly json: Pick<JsonActions, 'readJson' | 'requireJsonPost'>;\n\t/** The app's `createApiErrors()`: words the refusals. */\n\treadonly errors: Pick<ApiErrors<L>, 'apiRefusal'>;\n\t/**\n\t * The signed-in viewer, or a thrown redirect to sign in that comes back to\n\t * this very address, request id included (`SessionFlow.signInRedirect`\n\t * does). `headers` are added to the answer (a refreshed session cookie).\n\t */\n\tviewer(\n\t\trequest: Request,\n\t): Promise<{ readonly viewer: Viewer; readonly headers?: HeadersInit }>;\n\t/**\n\t * The caller that carries the request's session to the API. `binding`\n\t * names the request this browser opened (the cookie `mcpRelay` set): put\n\t * `binding.headers` on the API call so the server can check it.\n\t */\n\tcaller(request: Request, binding: ConsentBinding): Caller;\n\t/** `oauthRequest(id)`: the pending request, or `null` when the API has none. */\n\tfind(id: string, caller: Caller): Promise<Pending | null | undefined>;\n\t/** `approveOAuthRequest(id, scopes, bound)`: `bound` is there when the page posted one. */\n\tapprove(\n\t\tinput: {\n\t\t\treadonly id: string;\n\t\t\treadonly scopes?: readonly string[];\n\t\t\treadonly bound?: ConsentBound;\n\t\t},\n\t\tcaller: Caller,\n\t): Promise<ConsentRedirect>;\n\t/** `denyOAuthRequest(id)`. */\n\tdeny(\n\t\tinput: { readonly id: string },\n\t\tcaller: Caller,\n\t): Promise<ConsentRedirect>;\n\t/**\n\t * Whether an API refusal means the request is unknown, decided, lapsed or\n\t * not the viewer's (the API cannot tell which). Default: a 404.\n\t */\n\tnotFound?(error: ApiErrorLike): boolean;\n\t/** The API's step-up code. Default `STEP_UP_REQUIRED`. */\n\tstepUpRequired?: string;\n\t/**\n\t * What the page's picker offers to bind the grant to (the viewer's\n\t * workspaces), loaded beside a pending request and answered as the\n\t * loader's `choices`. Without it, `choices` is empty.\n\t */\n\tchoices?(caller: Caller, viewer: Viewer): Promise<readonly Choice[]>;\n\t/**\n\t * Whether an approval must name what the grant is bound to: one without\n\t * `bound` is then a 400. `false` by default. The API still checks the\n\t * viewer may bind it there.\n\t */\n\treadonly requireBound?: boolean;\n\t/**\n\t * Whether a request this browser did not open is refused here: the id in\n\t * the address must be the one the binding cookie names, else the loader\n\t * answers the expired state (a 404) and the action an expired refusal,\n\t * without asking the API. `false` by default, so an app that does not\n\t * bind yet is unchanged; turn it on once `mcpRelay` sets the cookie.\n\t */\n\treadonly requireBinding?: boolean;\n\t/** The header of `binding.headers`. Default `CONSENT_REQUEST_HEADER`. */\n\treadonly bindingHeader?: string;\n\t/**\n\t * The app's public origin (`https://app.example`), the one given to\n\t * `mcpRelay({ consent: { origin } })`: its scheme picks the binding\n\t * cookie's name (`__Host-` over HTTPS, plain over HTTP), as it does for the\n\t * relay that wrote it. Default: the request's own scheme, which is `http:`\n\t * behind a proxy that ends TLS without a trusted `X-Forwarded-Proto`, so\n\t * the cookie is not found and every consent reads as expired.\n\t */\n\treadonly origin?: string;\n}\n\nexport interface ConsentRoute<\n\tL extends string,\n\tViewer,\n\tPending extends object,\n\tChoice extends object = never,\n> {\n\t/**\n\t * The route's loader: the viewer, the pending request (`null` for an\n\t * unknown one or none in the address, answered with a 404 so the page shows\n\t * its expired state) and the picker's `choices` (empty without a pending\n\t * request or a `choices` option). Never cached: it names a one-time\n\t * request.\n\t */\n\tloader(request: Request): Promise<\n\t\tReturnType<\n\t\t\ttypeof data<{\n\t\t\t\tpending: Pending | null;\n\t\t\t\tviewer: Viewer;\n\t\t\t\tchoices: readonly Choice[];\n\t\t\t}>\n\t\t>\n\t>;\n\t/**\n\t * The route's action: approves or denies the JSON `{ intent, id, scopes?,\n\t * bound? }` and answers a `ConsentAnswer` for the page's fetcher.\n\t */\n\taction(\n\t\trequest: Request,\n\t\tlanguage: L,\n\t): Promise<ConsentAnswer | ReturnType<typeof data<ConsentAnswer>>>;\n}\n\nconst isStrings = (value: unknown): value is string[] =>\n\tArray.isArray(value) &&\n\tvalue.every((item) => typeof item === 'string' && item.length > 0);\n\nconst isText = (value: unknown): value is string =>\n\ttypeof value === 'string' && value.length > 0;\n\n// Kept twice: `react/use-consent.ts` has the page's copy, which drops what is\n// no bound (a click event) where this one refuses it; `/oauth/react` shares\n// no chunk with `/oauth` (src/pwa/boundary.spec.ts).\nfunction boundOf(value: unknown): ConsentBound | undefined {\n\tif (value === undefined) return undefined;\n\tconst { type, id } = (\n\t\ttypeof value === 'object' && value !== null ? value : {}\n\t) as Record<string, unknown>;\n\tif (!isText(type) || !isText(id))\n\t\tthrow data('Bad consent request', { status: 400 });\n\treturn { type, id };\n}\n\nfunction inputOf(body: unknown, requireBound: boolean): ConsentInput {\n\tconst raw = (typeof body === 'object' && body !== null ? body : {}) as Record<\n\t\tstring,\n\t\tunknown\n\t>;\n\tconst { intent, id, scopes } = raw;\n\tif (\n\t\t(intent !== 'approve' && intent !== 'deny') ||\n\t\t!isText(id) ||\n\t\t(scopes !== undefined && !isStrings(scopes))\n\t) {\n\t\tthrow data('Bad consent request', { status: 400 });\n\t}\n\t// A denial binds nothing: what it carries is not read.\n\tif (intent === 'deny') return { intent, id, scopes };\n\tconst bound = boundOf(raw['bound']);\n\tif (requireBound && bound === undefined)\n\t\tthrow data('Bad consent request', { status: 400 });\n\treturn { intent, id, scopes, bound };\n}\n\n/**\n * The server side of the screen where a viewer allows or denies an OAuth\n * client (`oauthRequest`, `approveOAuthRequest` and `denyOAuthRequest` of\n * `@softistx/janus-oauth/graphql`): a loader and an action for one route, the\n * GraphQL calls passed in. The page reads `useConsent`\n * (`@softistx/alxia-react-router/oauth/react`).\n *\n * With `choices`, the loader also answers what the page's picker offers\n * (the viewer's workspaces), and the page posts the one chosen as `bound`,\n * which `approve` passes on; `requireBound` refuses an approval without one.\n *\n * @example\n * const consent = oauthConsent({ json, errors, viewer, caller, find, approve, deny });\n * export const loader = ({ request }) => consent.loader(request);\n * export const action = ({ request }) => consent.action(request, language);\n */\nexport function oauthConsent<\n\tL extends string,\n\tCaller,\n\tViewer,\n\tPending extends object,\n\tChoice extends object = never,\n>(\n\toptions: ConsentOptions<L, Caller, Viewer, Pending, Choice>,\n): ConsentRoute<L, Viewer, Pending, Choice> {\n\tconst notFound =\n\t\toptions.notFound ?? ((error: ApiErrorLike) => error.status === 404);\n\tconst stepUpCode = options.stepUpRequired ?? STEP_UP_REQUIRED;\n\tconst origin = options.origin;\n\tif (\n\t\torigin !== undefined &&\n\t\t!(URL.canParse(origin) && /^https?:$/.test(new URL(origin).protocol))\n\t) {\n\t\tthrow new TypeError(\n\t\t\t`oauthConsent: origin must be an http(s) origin, got \"${origin}\"`,\n\t\t);\n\t}\n\n\tconst unbound = (id: string, binding: ConsentBinding) =>\n\t\toptions.requireBinding === true && binding.requestId !== id;\n\n\tasync function loader(request: Request) {\n\t\tconst { viewer, headers: viewerHeaders } = await options.viewer(request);\n\t\tconst headers = new Headers(viewerHeaders);\n\t\theaders.set('Cache-Control', 'no-store');\n\t\tconst id = requestIdOf(new URL(request.url));\n\t\tlet pending: Pending | null = null;\n\t\tlet choices: readonly Choice[] = [];\n\t\tconst binding = consentBindingOf(request, options.bindingHeader, origin);\n\t\tif (id && !unbound(id, binding)) {\n\t\t\tconst caller = options.caller(request, binding);\n\t\t\ttry {\n\t\t\t\tpending = (await options.find(id, caller)) ?? null;\n\t\t\t} catch (error) {\n\t\t\t\tif (!(isApiErrorLike(error) && notFound(error))) throw error;\n\t\t\t}\n\t\t\tif (pending && options.choices)\n\t\t\t\tchoices = await options.choices(caller, viewer);\n\t\t}\n\t\treturn data(\n\t\t\t{ pending, viewer, choices },\n\t\t\tpending ? { headers } : { status: 404, headers },\n\t\t);\n\t}\n\n\tasync function action(request: Request, language: L) {\n\t\toptions.json.requireJsonPost(request);\n\t\tconst input = inputOf(\n\t\t\tawait options.json.readJson(request),\n\t\t\toptions.requireBound === true,\n\t\t);\n\t\tconst about = { intent: input.intent, id: input.id } as const;\n\t\tconst binding = consentBindingOf(request, options.bindingHeader, origin);\n\t\tif (unbound(input.id, binding)) {\n\t\t\treturn data(\n\t\t\t\t{\n\t\t\t\t\tok: false as const,\n\t\t\t\t\t...about,\n\t\t\t\t\tstepUp: false,\n\t\t\t\t\texpired: true,\n\t\t\t\t\terror: '',\n\t\t\t\t},\n\t\t\t\t{ status: 404 },\n\t\t\t);\n\t\t}\n\t\tconst caller = options.caller(request, binding);\n\t\ttry {\n\t\t\tconst { redirectTo } =\n\t\t\t\tinput.intent === 'approve'\n\t\t\t\t\t? await options.approve(\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tid: input.id,\n\t\t\t\t\t\t\t\t...(input.scopes && { scopes: input.scopes }),\n\t\t\t\t\t\t\t\t...(input.bound && { bound: input.bound }),\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tcaller,\n\t\t\t\t\t\t)\n\t\t\t\t\t: await options.deny({ id: input.id }, caller);\n\t\t\tconst next = followableRedirect(redirectTo);\n\t\t\tif (!next) {\n\t\t\t\tthrow new Error('The API answered a redirect that is not an address');\n\t\t\t}\n\t\t\treturn { ok: true as const, ...about, redirectTo: next };\n\t\t} catch (error) {\n\t\t\tconst code = isApiErrorLike(error) ? error.code : undefined;\n\t\t\tconst { message, status } = fetcherRefusal(\n\t\t\t\toptions.errors,\n\t\t\t\terror,\n\t\t\t\tlanguage,\n\t\t\t);\n\t\t\tconst stepUp = code === stepUpCode;\n\t\t\tconst expired = isApiErrorLike(error) && !stepUp && notFound(error);\n\t\t\treturn data(\n\t\t\t\t{\n\t\t\t\t\tok: false as const,\n\t\t\t\t\t...about,\n\t\t\t\t\tstepUp,\n\t\t\t\t\texpired,\n\t\t\t\t\terror: stepUp || expired ? '' : message,\n\t\t\t\t},\n\t\t\t\t{ status },\n\t\t\t);\n\t\t}\n\t}\n\n\treturn { loader, action };\n}\n\n/**\n * `shouldRevalidate` of the consent route: never reload after a decision.\n * The decision spends the request, so the loader would answer \"expired\"\n * while the browser is on its way to the client's callback. Any other change\n * (another `request_id`, a navigation) reloads as usual.\n */\nexport function consentShouldRevalidate({\n\tformMethod,\n\tdefaultShouldRevalidate,\n}: Pick<\n\tShouldRevalidateFunctionArgs,\n\t'formMethod' | 'defaultShouldRevalidate'\n>): boolean {\n\treturn formMethod ? false : defaultShouldRevalidate;\n}\n",
|
|
6
|
+
"/**\n * The request an authorization link names: `request_id` (what the API sends\n * the browser with), else `request`. Empty or absent: `undefined`.\n */\nexport function requestIdOf(url: URL): string | undefined {\n\tconst id =\n\t\turl.searchParams.get('request_id') ?? url.searchParams.get('request');\n\tconst trimmed = id?.trim();\n\treturn trimmed ? trimmed : undefined;\n}\n\n/**\n * Where the browser is sent once a request is decided: the client's own\n * callback, normalised. Only http(s) is followed (a loopback callback is\n * http), never a `javascript:` or `data:` address. Anything else:\n * `undefined`.\n */\nexport function followableRedirect(value: unknown): string | undefined {\n\tif (typeof value !== 'string') return undefined;\n\tlet url: URL;\n\ttry {\n\t\turl = new URL(value);\n\t} catch {\n\t\treturn undefined;\n\t}\n\treturn url.protocol === 'https:' || url.protocol === 'http:'\n\t\t? url.href\n\t\t: undefined;\n}\n",
|
|
7
|
+
"import { type ApiErrorLike, isApiErrorLike } from '../errors/api-error';\nimport { newestFirst } from '../lists/newest-first';\nimport { STEP_UP_REQUIRED } from '../session/step-up-codes';\n\n/**\n * What an app knows about one scope the API names. `K` is the type of its\n * keys: `oauthGrants` infers it from the `scopes` table, so a literal table\n * gives a literal union; `string` otherwise.\n */\nexport interface GrantScopeInfo<K extends string = string> {\n\t/** The app's own i18n key for the scope (`read`, `write`, …). */\n\treadonly key?: K;\n\t/** What the scope lets the client do, for a card's tone and word. */\n\treadonly access?: 'read' | 'write';\n}\n\n/** One scope of a grant: the API's name and label, plus what the app's table knows of it. */\nexport interface GrantScope<K extends string = string> {\n\treadonly id: string;\n\t/** The API's own label: what shows when the app has no words for the scope. */\n\treadonly label: string;\n\treadonly key?: K;\n\treadonly access?: 'read' | 'write';\n}\n\n/** The least a grant must have (`OAuthConnectedApp` of `@softistx/janus-oauth/graphql`). */\nexport interface GrantLike {\n\treadonly createdAt: string;\n\treadonly scopes: readonly { readonly name: string; readonly label: string }[];\n}\n\n/** A grant as `list` answers it: the scopes mapped, the rest as the API sent it. */\nexport type ListedGrant<G extends GrantLike, K extends string = string> = Omit<\n\tG,\n\t'scopes'\n> & {\n\treadonly scopes: readonly GrantScope<K>[];\n};\n\n/** What `revoke` answers; a refusal other than these is thrown. */\nexport type RevokeResult =\n\t| { readonly status: 'revoked'; readonly id: string }\n\t/** The API no longer knows the grant: what the user wanted is done. */\n\t| { readonly status: 'already-revoked'; readonly id: string }\n\t/** The session is not confirmed lately: step up, then call `revoke` again. */\n\t| { readonly status: 'step-up'; readonly id: string };\n\nexport interface GrantsOptions<\n\tCtx,\n\tG extends GrantLike,\n\tK extends string = string,\n> {\n\t/**\n\t * The grants of the viewer (or, with a `ctx` that names it, of another\n\t * account), in the order the API gives (oldest first).\n\t */\n\tlist(ctx: Ctx): Promise<readonly G[]>;\n\t/** The revoking mutation for one grant. */\n\trevoke(ctx: Ctx, id: string): Promise<unknown>;\n\t/** The scopes the app words itself, by the API's scope name. */\n\treadonly scopes?: Readonly<Record<string, GrantScopeInfo<K>>>;\n\t/**\n\t * Whether a refusal of `revoke` means the grant is unknown (revoked\n\t * elsewhere). Default: a 404.\n\t */\n\tnotFound?(error: ApiErrorLike): boolean;\n\t/** The API's step-up code. Default `STEP_UP_REQUIRED`. */\n\treadonly stepUpRequired?: string;\n}\n\nexport interface GrantsRoute<\n\tCtx,\n\tG extends GrantLike,\n\tK extends string = string,\n> {\n\t/** The grants, newest first by `createdAt`, their scopes mapped. */\n\tlist(ctx: Ctx): Promise<ListedGrant<G, K>[]>;\n\t/** Revokes one grant; see `RevokeResult`. */\n\trevoke(ctx: Ctx, id: string): Promise<RevokeResult>;\n}\n\n/**\n * The server side of an account's connected apps (the OAuth grants of\n * `@softistx/janus-oauth/graphql`): a sorted, mapped list for a loader and a\n * revoke step for an action, over the app's own GraphQL calls. `Ctx` is\n * whatever the app's functions need (a caller, a user id). The page's\n * step-up replay is `useStepUpReplay` (see the session guide).\n *\n * `K` is inferred from the keys of the `scopes` table: declare it `as const`\n * and a listed scope's `key` is `K | undefined` (`'read' | 'write' | undefined`),\n * with no cast; without a literal table it stays `string`.\n *\n * @example\n * const grants = oauthGrants({ list: (c) => connectedApps(c), revoke: (c, id) => revokeApp(c, id) });\n * export const loader = async ({ request }) => ({ apps: await grants.list(caller(request)) });\n */\nexport function oauthGrants<\n\tCtx,\n\tG extends GrantLike,\n\tK extends string = string,\n>(options: GrantsOptions<Ctx, G, K>): GrantsRoute<Ctx, G, K> {\n\tconst notFound =\n\t\toptions.notFound ?? ((error: ApiErrorLike) => error.status === 404);\n\tconst stepUpCode = options.stepUpRequired ?? STEP_UP_REQUIRED;\n\tconst table = options.scopes ?? {};\n\n\tasync function list(ctx: Ctx) {\n\t\treturn newestFirst(await options.list(ctx)).map(\n\t\t\t// the cast: TypeScript cannot prove `{ ...G, scopes }` is `Omit<G, 'scopes'> & { scopes }` for a generic G\n\t\t\t(grant) =>\n\t\t\t\t({\n\t\t\t\t\t...grant,\n\t\t\t\t\tscopes: grant.scopes.map(({ name, label }) => {\n\t\t\t\t\t\tconst info = Object.hasOwn(table, name) ? table[name] : undefined;\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tid: name,\n\t\t\t\t\t\t\tlabel,\n\t\t\t\t\t\t\t...(info?.key !== undefined && { key: info.key }),\n\t\t\t\t\t\t\t...(info?.access !== undefined && { access: info.access }),\n\t\t\t\t\t\t};\n\t\t\t\t\t}),\n\t\t\t\t}) as ListedGrant<G, K>,\n\t\t);\n\t}\n\n\tasync function revoke(ctx: Ctx, id: string): Promise<RevokeResult> {\n\t\ttry {\n\t\t\tawait options.revoke(ctx, id);\n\t\t\treturn { status: 'revoked', id };\n\t\t} catch (error) {\n\t\t\tif (isApiErrorLike(error)) {\n\t\t\t\tif (error.code === stepUpCode) return { status: 'step-up', id };\n\t\t\t\tif (notFound(error)) return { status: 'already-revoked', id };\n\t\t\t}\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\treturn { list, revoke };\n}\n"
|
|
8
|
+
],
|
|
9
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;ACIO,SAAS,WAAW,CAAC,KAA8B;AAAA,EACz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AAA,IAClE,IAAI;AAAA,MACH,MAAM,QAAQ,OAAO,KAAK,EAAE;AAAA,MAC5B,OAAO,EAAE,QAAQ,WAAW,GAAG;AAAA,MAC9B,OAAO,OAAO;AAAA,MACf,IAAI,gBAAe,KAAK,GAAG;AAAA,QAC1B,IAAI,MAAM,SAAS;AAAA,UAAY,OAAO,EAAE,QAAQ,WAAW,GAAG;AAAA,QAC9D,IAAI,SAAS,KAAK;AAAA,UAAG,OAAO,EAAE,QAAQ,mBAAmB,GAAG;AAAA,MAC7D;AAAA,MACA,MAAM;AAAA;AAAA;AAAA,EAIR,OAAO,EAAE,MAAM,OAAO;AAAA;",
|
|
10
|
+
"debugId": "8010B04824A5255B64756E2164756E21",
|
|
11
|
+
"names": []
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The request an authorization link names: `request_id` (what the API sends
|
|
3
|
+
* the browser with), else `request`. Empty or absent: `undefined`.
|
|
4
|
+
*/
|
|
5
|
+
export declare function requestIdOf(url: URL): string | undefined;
|
|
6
|
+
/**
|
|
7
|
+
* Where the browser is sent once a request is decided: the client's own
|
|
8
|
+
* callback, normalised. Only http(s) is followed (a loopback callback is
|
|
9
|
+
* http), never a `javascript:` or `data:` address. Anything else:
|
|
10
|
+
* `undefined`.
|
|
11
|
+
*/
|
|
12
|
+
export declare function followableRedirect(value: unknown): string | undefined;
|
|
13
|
+
//# sourceMappingURL=model.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../src/oauth/model.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,GAAG,SAAS,CAKxD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAWrE"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@softistx/alxia-react-router/oauth/react`: the hook of the screen where a viewer
|
|
3
|
+
* allows or denies an OAuth client. `react` and `react-router` are its only
|
|
4
|
+
* imports; it shares nothing with the server side of `/oauth`.
|
|
5
|
+
*/
|
|
6
|
+
export { type UseConsentOptions, useConsent } from './use-consent';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/oauth/react/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
|