void 0.20.2 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/agents-gni4eqBu.mjs +111 -0
- package/dist/auth-3sGB0zJ1.mjs +22 -0
- package/dist/{auth-DPl6kck4.mjs → auth-B9_D6ygs.mjs} +6 -241
- package/dist/auth-CAw7zHqj.mjs +2 -0
- package/dist/auth-client-BWBT8HLp.mjs +6 -0
- package/dist/auth-client-Bawdj38n.d.mts +7 -0
- package/dist/auth-client-react-7GFffu8R.d.mts +7 -0
- package/dist/auth-client-react-CMLwT2xI.mjs +6 -0
- package/dist/auth-client-solid-DyTFL4cq.d.mts +7 -0
- package/dist/auth-client-solid-UoreJWZG.mjs +6 -0
- package/dist/auth-client-svelte-Cv_WvrRk.mjs +6 -0
- package/dist/auth-client-svelte-zetW0KIH.d.mts +7 -0
- package/dist/auth-client-vue-CFk7Xbv3.mjs +6 -0
- package/dist/auth-client-vue-bChShbQP.d.mts +7 -0
- package/dist/{auth-cmd-gniL2fNt.mjs → auth-cmd-MkBG2u1f.mjs} +5 -5
- package/dist/{auth-link-NZdjCmSc.mjs → auth-link-Devmv96E.mjs} +5 -5
- package/dist/{better-auth-shared-DSCeohOK.d.mts → better-auth-shared-BoVwA5Vm.d.mts} +1 -6
- package/dist/{better-auth-shared-CYw1T3k4.mjs → better-auth-shared-syGYYmnY.mjs} +1 -1
- package/dist/{build-cmd-sI18tX_O.mjs → build-cmd-DsBGwtfs.mjs} +6 -4
- package/dist/{cache-IHn5MwBC.mjs → cache-BMw8eMyF.mjs} +6 -4
- package/dist/{cancel-deploy-C5qTOdLi.mjs → cancel-deploy-B3_s9NIN.mjs} +5 -3
- package/dist/cf-access-rAZxzMkL.mjs +181 -0
- package/dist/cf-build-output-CTdlo6Rt.mjs +520 -0
- package/dist/cli/cf-compat.d.mts +1 -0
- package/dist/cli/cf-compat.mjs +934 -0
- package/dist/cli/cli.mjs +61 -38
- package/dist/cli/env-schema-probe.mjs +3 -3
- package/dist/client-DAAivdid.mjs +2 -0
- package/dist/{client-dHfSJvAN.mjs → client-PdAJ-F0t.mjs} +148 -89
- package/dist/{cloudflare-auth-6M5llVPC.mjs → cloudflare-auth-BCmTc1X_.mjs} +13 -44
- package/dist/{cloudflare-cmd-4RPGN3KB.mjs → cloudflare-cmd-D6PrKn7o.mjs} +4 -7
- package/dist/{cloudflare-connect-t1UU5svD.mjs → cloudflare-connect-DloREDlc.mjs} +6 -6
- package/dist/cloudflare-operations-BHNJVDbN.mjs +2 -0
- package/dist/{cloudflare-operations-BzWnlC1_.mjs → cloudflare-operations-CPEdHYhM.mjs} +37 -39
- package/dist/cloudflare-user-output-Q-k0QoNQ.mjs +20 -0
- package/dist/collect-DAUItMDS.mjs +2 -0
- package/dist/collect-DXHNWHcT.mjs +48 -0
- package/dist/config--T87TD8T.mjs +2 -0
- package/dist/{config-NOG_U1aK.mjs → config-BSe70f4T.mjs} +4 -6
- package/dist/config-DDIFxQYx.mjs +2 -0
- package/dist/{config-uNGuFsI2.mjs → config-Dxr6cTXn.mjs} +22 -37
- package/dist/config-DywxBLQC.d.mts +185 -0
- package/dist/config-entry.d.mts +6 -0
- package/dist/config-entry.mjs +7 -0
- package/dist/config-uP7ZDtVZ.mjs +21 -0
- package/dist/config-write-y3CBI_ux.mjs +60 -0
- package/dist/{connect-Bfk31O_8.mjs → connect-BvC9kolB.mjs} +8 -6
- package/dist/{create-project-Bk9Z0-Jg.mjs → create-project-C9lQhRzj.mjs} +9 -25
- package/dist/create-project-CI-17RVJ.mjs +2 -0
- package/dist/database-provider-Cx525bwX.mjs +6 -0
- package/dist/database-provider.mjs +1 -5
- package/dist/{db-BkRoptAt.mjs → db-R7IQgOv5.mjs} +48 -44
- package/dist/{delete-DouASY9P.mjs → delete-CghI_NXn.mjs} +6 -4
- package/dist/deploy-CYPymbtG.mjs +2 -0
- package/dist/{deploy-DTaWUS1S.mjs → deploy-H968Lo4T.mjs} +765 -197
- package/dist/discover-BBzDZe_o.mjs +2 -0
- package/dist/{discover-xvfrgJeo.mjs → discover-C4O6YxVS.mjs} +3 -8
- package/dist/{dist-BrsS7cai.mjs → dist-4WkAWhWx.mjs} +1 -15
- package/dist/{dist-m40_XgNh.mjs → dist-Bn8Kodjp.mjs} +1 -1
- package/dist/dist-C5fND3R0.mjs +2 -0
- package/dist/dist-D7-nEOXi.mjs +2 -0
- package/dist/{output-B0cfNSx5.mjs → dist-Dn6nn2IU.mjs} +3 -926
- package/dist/{domain-1RhhOVrC.mjs → domain-CITt8lC-.mjs} +7 -5
- package/dist/{route-types-Da-DpyUp.mjs → drizzle-Beb2Am5S.mjs} +1 -280
- package/dist/{email-Ce6SQq-i.mjs → email-C5kaZXzJ.mjs} +2 -2
- package/dist/{email-C-lGh51B.mjs → email-_8VmyX7V.mjs} +14 -12
- package/dist/{entry-DU3oDoQ3.mjs → entry-DdRFGK0y.mjs} +2 -2
- package/dist/{env-DJHsPE7Z.mjs → env-DV4r3nHz.mjs} +9 -7
- package/dist/{env-DBKmK4vc.mjs → env-DX_v-Q-v.mjs} +1 -1
- package/dist/env-Yz4HcvHs.mjs +78 -0
- package/dist/env-helpers--wFmQ_5Q.mjs +136 -0
- package/dist/{env-types-BNPhro-M.mjs → env-types-CWDtqHgw.mjs} +6 -2
- package/dist/{env-validation-CF6KvTRf.mjs → env-validation-BsFEXps5.mjs} +19 -28
- package/dist/env-validation-DIDGM7h4.mjs +2 -0
- package/dist/fetch-CXDChK7B.mjs +18 -0
- package/dist/fetch-_SeGZao9.d.mts +57 -0
- package/dist/fetch-stream-AOByI7Ki.mjs +81 -0
- package/dist/fetch-stream-Bjf0hoZb.d.mts +49 -0
- package/dist/gen-BBiIZw6g.mjs +2 -0
- package/dist/{gen-B_wPnVTK.mjs → gen-CFOEEc-t.mjs} +13 -11
- package/dist/{generate-RTK8_kK1.mjs → generate-C0VY6RVf.mjs} +2 -2
- package/dist/{github-cmd-PW7ZnWTp.mjs → github-cmd-jYjha2LO.mjs} +18 -22
- package/dist/{handler-D1hLsObx.d.mts → handler-BXJTXd02.d.mts} +6 -1
- package/dist/handler-DghKr6dU.mjs +150 -0
- package/dist/head-D_QRR5Yd.mjs +112 -0
- package/dist/head-client-DzmJGN4C.mjs +90 -0
- package/dist/{headers-BAHwgHdW.mjs → headers-B_HBMgi0.mjs} +2 -2
- package/dist/{help-CwOX-zmI.mjs → help-C46mnlUS.mjs} +17 -12
- package/dist/help-CS_nAsWu.mjs +2 -0
- package/dist/index.d.mts +2 -20
- package/dist/index.mjs +116 -60
- package/dist/{init-BWZ7q5Z4.mjs → init-CSXmvxKu.mjs} +49 -50
- package/dist/{link-Rmvu2Wl_.mjs → link-DxMOALXk.mjs} +7 -5
- package/dist/{list-DEE2S6mY.mjs → list-0wQs0oYg.mjs} +7 -5
- package/dist/live-CB1y5IuC.mjs +411 -0
- package/dist/live-CKiJilLr.d.mts +105 -0
- package/dist/local-d1-DzykTWY8.mjs +104 -0
- package/dist/{login-Uvferzmm.mjs → login-CKk5NX4d.mjs} +6 -11
- package/dist/login-Ch9cgWRF.mjs +2 -0
- package/dist/{logs-27FenuiC.mjs → logs-hxWBSoej.mjs} +6 -4
- package/dist/migrate-CLty4mZR.mjs +2 -0
- package/dist/migrate-DcW8F2W8.mjs +285 -0
- package/dist/migration-handler-DM4clYj5.d.mts +51 -0
- package/dist/{neon-DHwd2zvC.mjs → neon-n74ta1Pr.mjs} +1 -1
- package/dist/{node-Ez5KW5rn.mjs → node-Cupyf7-s.mjs} +6 -6
- package/dist/{operator-auth-B3e08unv.mjs → operator-auth-BkVgJqv-.mjs} +2 -2
- package/dist/{operator-client-LUZnlnYk.mjs → operator-client-A0iex2yi.mjs} +2 -1
- package/dist/{operator-cmd-CjOTmAYE.mjs → operator-cmd-BEUYhaHB.mjs} +6 -6
- package/dist/output-urU86XeT.mjs +146 -0
- package/dist/{package-json-CPoWX79C.mjs → package-json-iCbMg5XF.mjs} +1 -1
- package/dist/pages/client.d.mts +5 -2
- package/dist/pages/client.mjs +5 -3
- package/dist/pages/head-client.mjs +1 -89
- package/dist/pages/head.mjs +1 -111
- package/dist/pages/index.d.mts +2 -3
- package/dist/pages/index.mjs +7 -7
- package/dist/pages/islands-plugin.mjs +2 -2
- package/dist/pages/prefetch.d.mts +2 -30
- package/dist/pages/prefetch.mjs +1 -89
- package/dist/pages/protocol.d.mts +2 -2
- package/dist/pages/protocol.mjs +3 -3
- package/dist/pages/serialize.d.mts +2 -9
- package/dist/pages/serialize.mjs +1 -13
- package/dist/plan-BEZ8VJW0.mjs +256 -0
- package/dist/plan-DpuOr14e.mjs +2 -0
- package/dist/{platform-auth-config-DrbQXXiW.mjs → platform-auth-config-Df6yVw-e.mjs} +6 -6
- package/dist/{platform-auth-protection-Bhtvp0B_.mjs → platform-auth-protection-Jb0yftay.mjs} +7 -5
- package/dist/{platform-auth-recovery-CeOKGVeJ.mjs → platform-auth-recovery-DmRyIfW0.mjs} +6 -5
- package/dist/platform-cmd-C9Vt7m-d.mjs +2 -0
- package/dist/{platform-cmd-BFhieCdV.mjs → platform-cmd-DRxCOTwy.mjs} +8 -5
- package/dist/{platform-domain-C74PULqV.mjs → platform-domain-IjiXgrXJ.mjs} +4 -3
- package/dist/{platform-lifecycle-BwAIgz-t.mjs → platform-lifecycle-BquAaU-5.mjs} +263 -56
- package/dist/platform-lifecycle-CuJIZNvA.mjs +2 -0
- package/dist/{platform-management-COogu_Se.mjs → platform-management-CCQKGsq4.mjs} +12 -7
- package/dist/platform-management-Cgyed0WY.mjs +2 -0
- package/dist/{platform-recovery-ewqLefp1.mjs → platform-recovery-DS8ih1SW.mjs} +3 -3
- package/dist/platform-registry-BJbgZLS1.mjs +431 -0
- package/dist/{plugin-inference-BDRfZngg.mjs → plugin-inference-DsvtJLll.mjs} +4 -4
- package/dist/prefetch-Bsc_Pb6c.mjs +90 -0
- package/dist/prefetch-Ce6la4EI.d.mts +31 -0
- package/dist/{prepare-blNRQvQl.mjs → prepare-CaUxODOU.mjs} +3 -2
- package/dist/prepare-D4CkM3_v.mjs +2 -0
- package/dist/{prepare-CtDJjoOj.mjs → prepare-pcWcxSCh.mjs} +13 -11
- package/dist/prerender-render-Cf_WDE9W.mjs +111 -0
- package/dist/prerender-render.mjs +1 -110
- package/dist/{preset-lAy0B0BQ.mjs → preset-Dowh9tTt.mjs} +16 -118
- package/dist/project-BEBFDFLz.mjs +2 -0
- package/dist/project-CWNIPoXc.mjs +209 -0
- package/dist/{project-cmd-DmZK9Hxf.mjs → project-cmd-2lN--YAX.mjs} +18 -16
- package/dist/{project-paths-SK8nMHPp.mjs → project-paths-CKQ-Q5JS.mjs} +47 -14
- package/dist/project-slug-23TpquG4.mjs +8 -0
- package/dist/project-slug-DofjTFd-.mjs +2 -0
- package/dist/{project-team-D8jOJMUJ.mjs → project-team-Dapn9HZn.mjs} +9 -5
- package/dist/{project-token-DA34bf-C.mjs → project-token-C90v9SJK.mjs} +6 -4
- package/dist/{project-tsconfig-Ql2XsSQp.mjs → project-tsconfig-CwfqUnVp.mjs} +2 -2
- package/dist/{protocol-C-pqYJjE.d.mts → protocol-ZH3jP4a7.d.mts} +1 -1
- package/dist/providers-BNKRacMr.d.mts +7 -0
- package/dist/provision-CNgEBkVA.mjs +3 -0
- package/dist/{provision-CSJOjjQk.mjs → provision-Cck2m3jJ.mjs} +11 -25
- package/dist/queues-BWKt1Xo4.d.mts +7 -0
- package/dist/{requests-CUExwGQQ.mjs → requests-CzX46I0i.mjs} +5 -3
- package/dist/resolve-project-BTotl8Nn.mjs +2 -0
- package/dist/{resolve-project--Vxawf7z.mjs → resolve-project-Xvis70DG.mjs} +2 -8
- package/dist/response-Tn7rU0MV.mjs +30 -0
- package/dist/{rollback-CDNGU1gr.mjs → rollback-BEeyc73H.mjs} +6 -4
- package/dist/{rolldown-runtime-rQ84J-ij.mjs → rolldown-runtime-DXIUcv95.mjs} +1 -10
- package/dist/route-types-Id82-veQ.mjs +280 -0
- package/dist/{local-d1-D2I6Ox5F.mjs → runner-BGVsGgkb.mjs} +6 -114
- package/dist/runner-CQs_cDSG.mjs +2 -0
- package/dist/runner-mysql-1o47achK.mjs +2 -0
- package/dist/{runner-mysql-7BPUNGmL.mjs → runner-mysql-BhwMk2Bm.mjs} +2 -9
- package/dist/{runner-pg-BkEza-dX.mjs → runner-pg-CJ_JeGF6.mjs} +2 -9
- package/dist/runner-pg-D7z01mQS.mjs +2 -0
- package/dist/runtime/ai.mjs +1 -1
- package/dist/runtime/auth-client-react.d.mts +2 -6
- package/dist/runtime/auth-client-react.mjs +1 -5
- package/dist/runtime/auth-client-solid.d.mts +2 -6
- package/dist/runtime/auth-client-solid.mjs +1 -5
- package/dist/runtime/auth-client-svelte.d.mts +2 -6
- package/dist/runtime/auth-client-svelte.mjs +1 -5
- package/dist/runtime/auth-client-vue.d.mts +2 -6
- package/dist/runtime/auth-client-vue.mjs +1 -5
- package/dist/runtime/auth-client.d.mts +2 -6
- package/dist/runtime/auth-client.mjs +1 -5
- package/dist/runtime/auth.mjs +1 -21
- package/dist/runtime/better-auth-mysql.d.mts +1 -1
- package/dist/runtime/better-auth-mysql.mjs +1 -1
- package/dist/runtime/better-auth-pg.d.mts +1 -1
- package/dist/runtime/better-auth-pg.mjs +1 -1
- package/dist/runtime/better-auth.d.mts +1 -1
- package/dist/runtime/better-auth.mjs +1 -1
- package/dist/runtime/client-react.d.mts +3 -3
- package/dist/runtime/client-react.mjs +3 -3
- package/dist/runtime/client-solid.d.mts +3 -3
- package/dist/runtime/client-solid.mjs +3 -3
- package/dist/runtime/client-svelte.d.mts +3 -3
- package/dist/runtime/client-svelte.mjs +3 -3
- package/dist/runtime/client-vue.d.mts +3 -3
- package/dist/runtime/client-vue.mjs +3 -3
- package/dist/runtime/client.d.mts +3 -3
- package/dist/runtime/client.mjs +3 -3
- package/dist/runtime/db.mjs +1 -1
- package/dist/runtime/durable.mjs +1 -1
- package/dist/runtime/email/testing.mjs +1 -1
- package/dist/runtime/env-helpers.mjs +1 -135
- package/dist/runtime/env-public-client.mjs +1 -1
- package/dist/runtime/env-public.mjs +2 -2
- package/dist/runtime/env.mjs +1 -77
- package/dist/runtime/fetch-stream.d.mts +2 -49
- package/dist/runtime/fetch-stream.mjs +2 -80
- package/dist/runtime/fetch.d.mts +2 -57
- package/dist/runtime/fetch.mjs +2 -17
- package/dist/runtime/handler.d.mts +1 -1
- package/dist/runtime/handler.mjs +1 -149
- package/dist/runtime/kv.mjs +1 -1
- package/dist/runtime/live-client.d.mts +1 -1
- package/dist/runtime/live-server.mjs +2 -2
- package/dist/runtime/live.d.mts +2 -104
- package/dist/runtime/live.mjs +1 -410
- package/dist/runtime/migration-handler-mysql.d.mts +1 -1
- package/dist/runtime/migration-handler-pg.d.mts +1 -1
- package/dist/runtime/migration-handler.d.mts +2 -50
- package/dist/runtime/queues.d.mts +2 -6
- package/dist/runtime/queues.mjs +1 -1
- package/dist/runtime/remote/index.mjs +49 -8
- package/dist/runtime/response.mjs +1 -29
- package/dist/runtime/sandbox.d.mts +4 -56
- package/dist/runtime/sandbox.mjs +82 -221
- package/dist/runtime/sse.mjs +1 -171
- package/dist/runtime/storage.mjs +1 -1
- package/dist/runtime/validator.d.mts +1 -1
- package/dist/runtime/validator.mjs +1 -71
- package/dist/runtime/ws-server.d.mts +2 -2
- package/dist/runtime/ws-server.mjs +2 -2
- package/dist/runtime/ws.d.mts +2 -121
- package/dist/{scan-CpK-57ug.mjs → scan-DJbooZm2.mjs} +3 -3
- package/dist/{scan-BMH4rzlv.mjs → scan-DdDvRCU1.mjs} +8 -26
- package/dist/{secret-Bzzi2e9E.mjs → secret-wnTel5Yw.mjs} +8 -6
- package/dist/serialize-BPvnNQuA.mjs +14 -0
- package/dist/serialize-CfSwWfF2.d.mts +10 -0
- package/dist/{skills-C0RvGjeE.mjs → skills-B-690E7h.mjs} +3 -2
- package/dist/sse-BaC1jXko.mjs +172 -0
- package/dist/{subcommand-prompt-Bmyn5Rlc.mjs → subcommand-prompt-Gj3VzLIh.mjs} +2 -1
- package/dist/sveltekit.d.mts +2 -1
- package/dist/sveltekit.mjs +3 -2
- package/dist/validate-DqJ33oHj.mjs +2 -0
- package/dist/validate-qNhV00PD.mjs +180 -0
- package/dist/validator-BTOu0fB0.mjs +72 -0
- package/dist/{wrangler--imS8n0d.mjs → wrangler-D01qs6VB.mjs} +259 -71
- package/dist/ws-BwcqizuH.d.mts +122 -0
- package/dist/{yarn-pnp-DxSInkzL.mjs → yarn-pnp-CVEc3gE7.mjs} +1 -1
- package/package.json +19 -8
- package/skills/void/SKILL.md +7 -5
- package/skills/void/docs/guide/ai.md +3 -3
- package/skills/void/docs/guide/app-types.md +12 -11
- package/skills/void/docs/guide/auth.md +2 -2
- package/skills/void/docs/guide/database/d1.md +1 -1
- package/skills/void/docs/guide/database/mysql.md +1 -1
- package/skills/void/docs/guide/database/postgresql.md +3 -3
- package/skills/void/docs/guide/deployment.md +16 -16
- package/skills/void/docs/guide/durable-state.md +2 -2
- package/skills/void/docs/guide/edge/headers.md +3 -3
- package/skills/void/docs/guide/edge/prerendering.md +1 -1
- package/skills/void/docs/guide/edge/redirects.md +4 -4
- package/skills/void/docs/guide/edge/revalidation.md +6 -6
- package/skills/void/docs/guide/edge/rewrites.md +28 -27
- package/skills/void/docs/guide/edge/static-assets.md +1 -1
- package/skills/void/docs/guide/email.md +27 -25
- package/skills/void/docs/guide/env-migration.md +1 -1
- package/skills/void/docs/guide/index.md +1 -1
- package/skills/void/docs/guide/pages-routing/head.md +1 -1
- package/skills/void/docs/guide/platform/administration/access.md +171 -0
- package/skills/void/docs/guide/platform/administration/email.md +121 -0
- package/skills/void/docs/guide/platform/administration/operations.md +97 -0
- package/skills/void/docs/guide/platform/administration/projects.md +56 -0
- package/skills/void/docs/guide/platform/development/local.md +119 -0
- package/skills/void/docs/guide/platform/development/runtime.md +124 -0
- package/skills/void/docs/guide/platform/development/schema-ci.md +95 -0
- package/skills/void/docs/guide/platform/installation/ci.md +58 -0
- package/skills/void/docs/guide/platform/installation/credentials.md +90 -0
- package/skills/void/docs/guide/platform/installation/domains.md +68 -0
- package/skills/void/docs/guide/platform/installation/first-deployment.md +82 -0
- package/skills/void/docs/guide/platform/installation/maintenance.md +137 -0
- package/skills/void/docs/guide/platform/installation/prerequisites.md +88 -0
- package/skills/void/docs/guide/platform/installation/setup.md +169 -0
- package/skills/void/docs/guide/platform/installation/uninstall.md +54 -0
- package/skills/void/docs/guide/platform-administration.md +6 -414
- package/skills/void/docs/guide/platform-development.md +5 -316
- package/skills/void/docs/guide/project-collaboration.md +1 -1
- package/skills/void/docs/guide/remote-dev.md +2 -2
- package/skills/void/docs/guide/sandboxes.md +10 -25
- package/skills/void/docs/guide/self-hosted-platform.md +11 -694
- package/skills/void/docs/guide/ssg.md +1 -1
- package/skills/void/docs/guide/websockets.md +1 -1
- package/skills/void/docs/integrations/cloudflare.md +86 -84
- package/skills/void/docs/integrations/frameworks/analog.md +14 -9
- package/skills/void/docs/integrations/frameworks/astro.md +14 -10
- package/skills/void/docs/integrations/frameworks/nuxt.md +14 -9
- package/skills/void/docs/integrations/frameworks/overview.md +35 -29
- package/skills/void/docs/integrations/frameworks/react-router.md +1 -1
- package/skills/void/docs/integrations/frameworks/sveltekit.md +33 -30
- package/skills/void/docs/integrations/frameworks/tanstack-start.md +1 -1
- package/skills/void/docs/integrations/nodejs-bun-deno.md +5 -5
- package/skills/void/docs/reference/api.md +55 -38
- package/skills/void/docs/reference/cli.md +60 -34
- package/skills/void/docs/reference/config.md +57 -34
- package/skills/void/docs/reference/resource-inference.md +10 -10
- package/skills/void/docs/reference/structure.md +2 -2
- package/dist/validate-tBBN_dXH.mjs +0 -505
package/dist/runtime/handler.mjs
CHANGED
|
@@ -1,151 +1,3 @@
|
|
|
1
|
-
import { convertReturnValue } from "./response.mjs";
|
|
2
|
-
import { runValidation } from "./validator.mjs";
|
|
3
1
|
import { i as ValidationError, n as defer } from "../defer-YsYDUoii.mjs";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Thrown when `c.rewrite()` is called with a destination whose final path
|
|
7
|
-
* segment ends in a known static-asset extension (e.g. `/hero.png`,
|
|
8
|
-
* `/app.css`). Runtime rewrites only reach routes and SSR entries inside
|
|
9
|
-
* the worker — static asset handlers run in front of the worker, so a
|
|
10
|
-
* `c.rewrite()` into an asset path re-enters the Hono router, matches
|
|
11
|
-
* nothing, and returns a 404. Fail at the call site so users reach for
|
|
12
|
-
* static `routing.rewrites` instead of debugging a mystery 404.
|
|
13
|
-
*/
|
|
14
|
-
var VoidAssetRewriteError = class extends Error {
|
|
15
|
-
name = "VoidAssetRewriteError";
|
|
16
|
-
constructor(destination) {
|
|
17
|
-
super(`c.rewrite() cannot re-dispatch to a static asset path (${JSON.stringify(destination)}). Runtime rewrites only reach routes and SSR entries inside the worker — static asset handlers run in front of the worker. To rewrite into an asset, use a static \`routing.rewrites\` rule in void.json or a \`200!\` entry in _redirects. See https://void.dev/guide/edge/rewrites#runtime-rewrites-cannot-reach-static-assets`);
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
function defineHandler(...args) {
|
|
21
|
-
if (args.length === 1) return args[0];
|
|
22
|
-
const middlewares = args.slice(0, -1);
|
|
23
|
-
const handler = args[args.length - 1];
|
|
24
|
-
return (async (c) => {
|
|
25
|
-
let index = 0;
|
|
26
|
-
const dispatch = async () => {
|
|
27
|
-
if (index < middlewares.length) {
|
|
28
|
-
const middleware = middlewares[index++];
|
|
29
|
-
const middlewareResponse = await middleware(c, dispatch);
|
|
30
|
-
if (middlewareResponse instanceof Response) c.res = middlewareResponse;
|
|
31
|
-
} else c.res = convertReturnValue(await handler(c));
|
|
32
|
-
};
|
|
33
|
-
await dispatch();
|
|
34
|
-
return c.res;
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
(function(_defineHandler) {
|
|
38
|
-
function withValidator(validators) {
|
|
39
|
-
return (handler) => {
|
|
40
|
-
return (async (c) => {
|
|
41
|
-
const result = await runValidation(validators, c);
|
|
42
|
-
if (!result.ok) return result.response;
|
|
43
|
-
return convertReturnValue(await handler(c, result.input));
|
|
44
|
-
});
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
_defineHandler.withValidator = withValidator;
|
|
48
|
-
})(defineHandler || (defineHandler = {}));
|
|
49
|
-
/**
|
|
50
|
-
* Identity function that provides type inference for middleware.
|
|
51
|
-
* At runtime it simply returns the function passed to it.
|
|
52
|
-
*/
|
|
53
|
-
function defineMiddleware(handler) {
|
|
54
|
-
return handler;
|
|
55
|
-
}
|
|
56
|
-
const basicAuthEncoder = new TextEncoder();
|
|
57
|
-
const basicAuthDecoder = new TextDecoder("utf-8", { fatal: true });
|
|
58
|
-
function parseBasicAuthHeader(authorization) {
|
|
59
|
-
if (!authorization?.toLowerCase().startsWith("basic ")) return null;
|
|
60
|
-
try {
|
|
61
|
-
const encoded = authorization.slice(6).trim();
|
|
62
|
-
const binary = atob(encoded);
|
|
63
|
-
const bytes = Uint8Array.from(binary, (char) => char.charCodeAt(0));
|
|
64
|
-
const decoded = basicAuthDecoder.decode(bytes);
|
|
65
|
-
const separator = decoded.indexOf(":");
|
|
66
|
-
if (separator === -1) return null;
|
|
67
|
-
return {
|
|
68
|
-
username: decoded.slice(0, separator),
|
|
69
|
-
password: decoded.slice(separator + 1)
|
|
70
|
-
};
|
|
71
|
-
} catch {
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
function timingSafeStringEqual(actual, expected) {
|
|
76
|
-
const actualBytes = basicAuthEncoder.encode(actual);
|
|
77
|
-
const expectedBytes = basicAuthEncoder.encode(expected);
|
|
78
|
-
let difference = actualBytes.length ^ expectedBytes.length;
|
|
79
|
-
for (let i = 0; i < expectedBytes.length; i++) difference |= (actualBytes[i] ?? 0) ^ expectedBytes[i];
|
|
80
|
-
return difference === 0;
|
|
81
|
-
}
|
|
82
|
-
function isVoidInternalPath(pathname) {
|
|
83
|
-
return pathname === "/__void" || pathname.startsWith("/__void/");
|
|
84
|
-
}
|
|
85
|
-
function basicAuthChallenge(realm, message) {
|
|
86
|
-
const escapedRealm = realm.replace(/["\\]/g, "\\$&");
|
|
87
|
-
return new Response(message, {
|
|
88
|
-
status: 401,
|
|
89
|
-
headers: {
|
|
90
|
-
"Cache-Control": "no-store",
|
|
91
|
-
"WWW-Authenticate": `Basic realm="${escapedRealm}", charset="UTF-8"`
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
function resolveBasicAuthOption(value, fallback) {
|
|
96
|
-
if (value === void 0) return fallback;
|
|
97
|
-
return typeof value === "function" ? value() : value;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Create Basic authentication middleware for temporary site gates and
|
|
101
|
-
* pre-launch protection.
|
|
102
|
-
*
|
|
103
|
-
* Void internal endpoints under `/__void` are always excluded so deploy-time
|
|
104
|
-
* migrations, prerendering, cron/queue dispatch, and remote binding helpers
|
|
105
|
-
* continue to reach Void's own internal-token checks.
|
|
106
|
-
*/
|
|
107
|
-
function basicAuth(options) {
|
|
108
|
-
return defineMiddleware(async (c, next) => {
|
|
109
|
-
if (isVoidInternalPath(c.req.path)) {
|
|
110
|
-
await next();
|
|
111
|
-
return;
|
|
112
|
-
}
|
|
113
|
-
const username = resolveBasicAuthOption(options.username, "");
|
|
114
|
-
const password = resolveBasicAuthOption(options.password, "");
|
|
115
|
-
const credentials = parseBasicAuthHeader(c.req.raw.headers.get("Authorization"));
|
|
116
|
-
const usernameMatches = credentials && timingSafeStringEqual(credentials.username, username);
|
|
117
|
-
const passwordMatches = credentials && timingSafeStringEqual(credentials.password, password);
|
|
118
|
-
if (!usernameMatches || !passwordMatches) return basicAuthChallenge(resolveBasicAuthOption(options.realm, "Restricted"), resolveBasicAuthOption(options.message, "Authentication required"));
|
|
119
|
-
await next();
|
|
120
|
-
});
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Identity function that provides type inference for scheduled jobs.
|
|
124
|
-
* At runtime it simply returns the function passed to it.
|
|
125
|
-
*/
|
|
126
|
-
function defineScheduled(handler) {
|
|
127
|
-
return handler;
|
|
128
|
-
}
|
|
129
|
-
/**
|
|
130
|
-
* Identity function that provides type inference for SSR render entry.
|
|
131
|
-
* The second argument includes asset tags for client scripts/styles.
|
|
132
|
-
*/
|
|
133
|
-
function defineRender(handler) {
|
|
134
|
-
return handler;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Identity function that provides type inference for page `head()` exports.
|
|
138
|
-
* At runtime it simply returns the function passed to it.
|
|
139
|
-
*/
|
|
140
|
-
function defineHead(handler) {
|
|
141
|
-
return handler;
|
|
142
|
-
}
|
|
143
|
-
/**
|
|
144
|
-
* Identity function that provides type inference for queue consumers.
|
|
145
|
-
* At runtime it simply returns the function passed to it.
|
|
146
|
-
*/
|
|
147
|
-
function defineQueue(handler) {
|
|
148
|
-
return handler;
|
|
149
|
-
}
|
|
150
|
-
//#endregion
|
|
2
|
+
import { a as defineMiddleware, c as defineScheduled, i as defineHead, n as basicAuth, o as defineQueue, r as defineHandler, s as defineRender, t as VoidAssetRewriteError } from "../handler-DghKr6dU.mjs";
|
|
151
3
|
export { ValidationError, VoidAssetRewriteError, basicAuth, defer, defineHandler, defineHead, defineMiddleware, defineQueue, defineRender, defineScheduled };
|
package/dist/runtime/kv.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { eventStream } from "
|
|
2
|
-
import { __getLiveBindingName } from "
|
|
1
|
+
import { n as eventStream } from "../sse-BaC1jXko.mjs";
|
|
2
|
+
import { t as __getLiveBindingName } from "../live-CB1y5IuC.mjs";
|
|
3
3
|
//#region src/runtime/live-server.ts
|
|
4
4
|
const GENERATION_KEY = "connection:generation";
|
|
5
5
|
const TOPIC_PRUNE_ALARM_DELAY_MS = 6e4;
|
package/dist/runtime/live.d.mts
CHANGED
|
@@ -1,105 +1,3 @@
|
|
|
1
1
|
/// <reference types="@cloudflare/workers-types" />
|
|
2
|
-
import { r as
|
|
3
|
-
|
|
4
|
-
//#region src/runtime/live.d.ts
|
|
5
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
6
|
-
export type LiveControlRequest = {
|
|
7
|
-
connectionId: string;
|
|
8
|
-
operations: Array<LiveControlOperation>;
|
|
9
|
-
};
|
|
10
|
-
export type LiveControlOperation = {
|
|
11
|
-
kind: "subscribe";
|
|
12
|
-
id: string;
|
|
13
|
-
topic: string;
|
|
14
|
-
lastEventId?: string;
|
|
15
|
-
} | {
|
|
16
|
-
kind: "unsubscribe";
|
|
17
|
-
id: string;
|
|
18
|
-
};
|
|
19
|
-
export type LiveControlErrorCode = "BAD_REQUEST" | "CONNECTION_CLOSED" | "CONNECTION_NOT_FOUND" | "FORBIDDEN" | "INVALID_SUBSCRIPTION_ID" | "INVALID_TOPIC" | "OWNER_MISMATCH" | "SUBSCRIPTION_LIMIT" | "TOPIC_FULL" | "PAYLOAD_TOO_LARGE" | "INTERNAL_ERROR";
|
|
20
|
-
export type LiveControlError = {
|
|
21
|
-
code: LiveControlErrorCode;
|
|
22
|
-
message: string;
|
|
23
|
-
};
|
|
24
|
-
export type LiveControlOperationResult = {
|
|
25
|
-
ok: true;
|
|
26
|
-
kind: "subscribe" | "unsubscribe";
|
|
27
|
-
id: string;
|
|
28
|
-
topic?: string;
|
|
29
|
-
} | {
|
|
30
|
-
ok: false;
|
|
31
|
-
kind: "subscribe" | "unsubscribe";
|
|
32
|
-
id: string;
|
|
33
|
-
error: LiveControlError;
|
|
34
|
-
};
|
|
35
|
-
export type LiveControlResponse = {
|
|
36
|
-
accepted: true;
|
|
37
|
-
connectionId: string;
|
|
38
|
-
results: Array<LiveControlOperationResult>;
|
|
39
|
-
} | {
|
|
40
|
-
accepted: false;
|
|
41
|
-
error: LiveControlError;
|
|
42
|
-
};
|
|
43
|
-
export type LiveClientEvent<Data = unknown> = {
|
|
44
|
-
subscriptionId: string;
|
|
45
|
-
topic: string;
|
|
46
|
-
type?: string;
|
|
47
|
-
eventId?: string;
|
|
48
|
-
data: Data;
|
|
49
|
-
};
|
|
50
|
-
export type LivePublishOptions = {
|
|
51
|
-
type?: string;
|
|
52
|
-
eventId?: string;
|
|
53
|
-
};
|
|
54
|
-
export type LiveConnectOptions = {
|
|
55
|
-
owner?: string | null;
|
|
56
|
-
user?: unknown;
|
|
57
|
-
};
|
|
58
|
-
export type LiveControlOptions = LiveConnectOptions;
|
|
59
|
-
export type LiveHookContext = {
|
|
60
|
-
request: Request;
|
|
61
|
-
env: CloudEnv["Bindings"];
|
|
62
|
-
user: AuthUser | unknown | null;
|
|
63
|
-
owner: string | null;
|
|
64
|
-
};
|
|
65
|
-
export type LiveConnectHookContext = LiveHookContext & {
|
|
66
|
-
connection: {
|
|
67
|
-
id: string;
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
export type LiveSubscribeHookContext = LiveHookContext & {
|
|
71
|
-
connection: {
|
|
72
|
-
id: string;
|
|
73
|
-
};
|
|
74
|
-
subscription: {
|
|
75
|
-
id: string;
|
|
76
|
-
};
|
|
77
|
-
topic: string;
|
|
78
|
-
lastEventId?: string;
|
|
79
|
-
};
|
|
80
|
-
export type LiveStreamOptions = {
|
|
81
|
-
id: string;
|
|
82
|
-
allowAnonymousControl?: boolean;
|
|
83
|
-
identifyConnection?: (ctx: LiveHookContext) => MaybePromise<string | null | undefined>;
|
|
84
|
-
onConnect?: (ctx: LiveConnectHookContext) => MaybePromise<Response | void>;
|
|
85
|
-
onSubscribe?: (ctx: LiveSubscribeHookContext) => MaybePromise<Response | void>;
|
|
86
|
-
limits?: Partial<LiveLimits>;
|
|
87
|
-
};
|
|
88
|
-
export type LiveLimits = {
|
|
89
|
-
maxSubscriptionsPerConnection: number;
|
|
90
|
-
maxSubscriptionsPerTopic: number;
|
|
91
|
-
maxOperationsPerControlRequest: number;
|
|
92
|
-
maxQueuedEventsPerConnection: number;
|
|
93
|
-
maxEncodedEventSize: number;
|
|
94
|
-
deliveryAttemptTimeoutMs: number;
|
|
95
|
-
};
|
|
96
|
-
export type LiveStream = {
|
|
97
|
-
connect(ctx: CloudContext, options?: LiveConnectOptions): Promise<Response>;
|
|
98
|
-
control(ctx: CloudContext, options?: LiveControlOptions): Promise<Response>;
|
|
99
|
-
publish(topic: string, data: unknown, options?: LivePublishOptions): Promise<void>;
|
|
100
|
-
withEnv(env: unknown): Pick<LiveStream, "publish">;
|
|
101
|
-
};
|
|
102
|
-
export declare function __setLiveBindingName(name: string): void;
|
|
103
|
-
export declare function __getLiveBindingName(): string;
|
|
104
|
-
export declare function defineLiveStream(options: LiveStreamOptions): LiveStream;
|
|
105
|
-
//#endregion
|
|
2
|
+
import { _ as __getLiveBindingName, a as LiveControlErrorCode, c as LiveControlOptions, d as LiveHookContext, f as LiveLimits, g as LiveSubscribeHookContext, h as LiveStreamOptions, i as LiveControlError, l as LiveControlRequest, m as LiveStream, n as LiveConnectHookContext, o as LiveControlOperation, p as LivePublishOptions, r as LiveConnectOptions, s as LiveControlOperationResult, t as LiveClientEvent, u as LiveControlResponse, v as __setLiveBindingName, y as defineLiveStream } from "../live-CKiJilLr.mjs";
|
|
3
|
+
export { LiveClientEvent, LiveConnectHookContext, LiveConnectOptions, LiveControlError, LiveControlErrorCode, LiveControlOperation, LiveControlOperationResult, LiveControlOptions, LiveControlRequest, LiveControlResponse, LiveHookContext, LiveLimits, LivePublishOptions, LiveStream, LiveStreamOptions, LiveSubscribeHookContext, __getLiveBindingName, __setLiveBindingName, defineLiveStream };
|
package/dist/runtime/live.mjs
CHANGED
|
@@ -1,411 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { getUser } from "./auth.mjs";
|
|
3
|
-
//#region src/runtime/live.ts
|
|
4
|
-
let liveBindingName = "VOID_LIVE";
|
|
5
|
-
const registeredStreamIds = /* @__PURE__ */ new Set();
|
|
6
|
-
const DEFAULT_LIMITS = {
|
|
7
|
-
maxSubscriptionsPerConnection: 256,
|
|
8
|
-
maxSubscriptionsPerTopic: 256,
|
|
9
|
-
maxOperationsPerControlRequest: 100,
|
|
10
|
-
maxQueuedEventsPerConnection: 100,
|
|
11
|
-
maxEncodedEventSize: 65536,
|
|
12
|
-
deliveryAttemptTimeoutMs: 1500
|
|
13
|
-
};
|
|
14
|
-
const MAX_SUBSCRIPTIONS_PER_TOPIC = 256;
|
|
15
|
-
function __setLiveBindingName(name) {
|
|
16
|
-
liveBindingName = assertBindingName(name);
|
|
17
|
-
}
|
|
18
|
-
function __getLiveBindingName() {
|
|
19
|
-
return liveBindingName;
|
|
20
|
-
}
|
|
21
|
-
function defineLiveStream(options) {
|
|
22
|
-
const streamId = assertStreamId(options.id);
|
|
23
|
-
const limits = resolveLiveLimits(options.limits);
|
|
24
|
-
if (registeredStreamIds.has(streamId)) throw new Error(`live: duplicate stream id "${streamId}".`);
|
|
25
|
-
registeredStreamIds.add(streamId);
|
|
26
|
-
async function resolveOwner(ctx, request, connectOptions) {
|
|
27
|
-
const resolvedUser = connectOptions && "user" in connectOptions ? connectOptions.user : getContextUser(ctx) ?? getUser();
|
|
28
|
-
const hookContext = {
|
|
29
|
-
request,
|
|
30
|
-
env: ctx.env,
|
|
31
|
-
user: resolvedUser ?? null,
|
|
32
|
-
owner: connectOptions?.owner ?? null
|
|
33
|
-
};
|
|
34
|
-
const owner = (connectOptions && "owner" in connectOptions ? connectOptions.owner : await options.identifyConnection?.(hookContext)) ?? defaultOwner(resolvedUser);
|
|
35
|
-
if (owner == null && !options.allowAnonymousControl) throw liveResponseError("FORBIDDEN", "live: anonymous control is not enabled.", 403);
|
|
36
|
-
assertOwner(owner);
|
|
37
|
-
return {
|
|
38
|
-
owner,
|
|
39
|
-
user: resolvedUser ?? null
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
async function publishWithEnv(env, topic, data, publishOptions = {}) {
|
|
43
|
-
const binding = getLiveBinding(env);
|
|
44
|
-
assertTopic(topic);
|
|
45
|
-
assertOptionalString("type", publishOptions.type);
|
|
46
|
-
assertOptionalString("eventId", publishOptions.eventId);
|
|
47
|
-
assertJsonSerializable(data);
|
|
48
|
-
const topicKey = await topicDigest(streamId, topic);
|
|
49
|
-
const id = binding.idFromName(topicInstanceName(streamId, topicKey));
|
|
50
|
-
const response = await binding.get(id).fetch(internalUrl("/publish"), {
|
|
51
|
-
method: "POST",
|
|
52
|
-
body: JSON.stringify({
|
|
53
|
-
streamId,
|
|
54
|
-
topic,
|
|
55
|
-
topicKey,
|
|
56
|
-
data,
|
|
57
|
-
type: publishOptions.type,
|
|
58
|
-
eventId: publishOptions.eventId,
|
|
59
|
-
limits
|
|
60
|
-
})
|
|
61
|
-
});
|
|
62
|
-
if (!response.ok) {
|
|
63
|
-
const body = await response.text();
|
|
64
|
-
const parsed = parseLiveControlResponse(body);
|
|
65
|
-
if (parsed && !parsed.accepted) throw new Error(`${parsed.error.code}: ${parsed.error.message}`);
|
|
66
|
-
throw new Error(body || response.statusText);
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
return {
|
|
70
|
-
async connect(ctx, connectOptions) {
|
|
71
|
-
try {
|
|
72
|
-
const request = ctx.req.raw;
|
|
73
|
-
const connectionId = getConnectionId(request);
|
|
74
|
-
const { owner, user } = await resolveOwner(ctx, request, connectOptions);
|
|
75
|
-
const decision = await options.onConnect?.({
|
|
76
|
-
request,
|
|
77
|
-
env: ctx.env,
|
|
78
|
-
user,
|
|
79
|
-
owner,
|
|
80
|
-
connection: { id: connectionId }
|
|
81
|
-
});
|
|
82
|
-
if (decision instanceof Response) return decision;
|
|
83
|
-
const binding = getLiveBinding(ctx.env);
|
|
84
|
-
const id = binding.idFromName(connectionInstanceName(streamId, connectionId));
|
|
85
|
-
return binding.get(id).fetch(internalUrl("/connect"), {
|
|
86
|
-
method: "POST",
|
|
87
|
-
body: JSON.stringify({
|
|
88
|
-
streamId,
|
|
89
|
-
connectionId,
|
|
90
|
-
owner,
|
|
91
|
-
limits
|
|
92
|
-
})
|
|
93
|
-
});
|
|
94
|
-
} catch (error) {
|
|
95
|
-
return errorToResponse(error);
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
async control(ctx, controlOptions) {
|
|
99
|
-
try {
|
|
100
|
-
const request = ctx.req.raw;
|
|
101
|
-
const body = await readControlRequest(request, limits);
|
|
102
|
-
const { owner, user } = await resolveOwner(ctx, request, controlOptions);
|
|
103
|
-
const authorized = [];
|
|
104
|
-
const results = [];
|
|
105
|
-
for (const entry of body.operations) {
|
|
106
|
-
if (!entry.ok) {
|
|
107
|
-
results[entry.index] = entry.result;
|
|
108
|
-
continue;
|
|
109
|
-
}
|
|
110
|
-
const { operation, index } = entry;
|
|
111
|
-
if (operation.kind === "unsubscribe") {
|
|
112
|
-
authorized.push({
|
|
113
|
-
operation,
|
|
114
|
-
index
|
|
115
|
-
});
|
|
116
|
-
continue;
|
|
117
|
-
}
|
|
118
|
-
const decision = await options.onSubscribe?.({
|
|
119
|
-
request,
|
|
120
|
-
env: ctx.env,
|
|
121
|
-
user,
|
|
122
|
-
owner,
|
|
123
|
-
connection: { id: body.connectionId },
|
|
124
|
-
subscription: { id: operation.id },
|
|
125
|
-
topic: operation.topic,
|
|
126
|
-
lastEventId: operation.lastEventId
|
|
127
|
-
});
|
|
128
|
-
if (decision instanceof Response) {
|
|
129
|
-
results[index] = {
|
|
130
|
-
ok: false,
|
|
131
|
-
kind: "subscribe",
|
|
132
|
-
id: operation.id,
|
|
133
|
-
error: await responseToControlError(decision)
|
|
134
|
-
};
|
|
135
|
-
continue;
|
|
136
|
-
}
|
|
137
|
-
authorized.push({
|
|
138
|
-
operation,
|
|
139
|
-
index
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
if (authorized.length > 0) {
|
|
143
|
-
const binding = getLiveBinding(ctx.env);
|
|
144
|
-
const id = binding.idFromName(connectionInstanceName(streamId, body.connectionId));
|
|
145
|
-
const response = await binding.get(id).fetch(internalUrl("/control"), {
|
|
146
|
-
method: "POST",
|
|
147
|
-
body: JSON.stringify({
|
|
148
|
-
streamId,
|
|
149
|
-
connectionId: body.connectionId,
|
|
150
|
-
owner,
|
|
151
|
-
operations: authorized.map((entry) => entry.operation),
|
|
152
|
-
limits
|
|
153
|
-
})
|
|
154
|
-
});
|
|
155
|
-
const controlResponse = await response.json();
|
|
156
|
-
if (!controlResponse.accepted) return Response.json(controlResponse, { status: response.status });
|
|
157
|
-
for (const [resultIndex, result] of controlResponse.results.entries()) {
|
|
158
|
-
const operation = authorized[resultIndex];
|
|
159
|
-
if (operation) results[operation.index] = result;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
for (const entry of body.operations) {
|
|
163
|
-
if (!entry.ok) continue;
|
|
164
|
-
const { operation, index } = entry;
|
|
165
|
-
results[index] ??= {
|
|
166
|
-
ok: false,
|
|
167
|
-
kind: operation.kind,
|
|
168
|
-
id: operation.id,
|
|
169
|
-
error: {
|
|
170
|
-
code: "INTERNAL_ERROR",
|
|
171
|
-
message: "live: missing control result."
|
|
172
|
-
}
|
|
173
|
-
};
|
|
174
|
-
}
|
|
175
|
-
return Response.json({
|
|
176
|
-
accepted: true,
|
|
177
|
-
connectionId: body.connectionId,
|
|
178
|
-
results
|
|
179
|
-
});
|
|
180
|
-
} catch (error) {
|
|
181
|
-
return errorToResponse(error);
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
publish(topic, data, publishOptions) {
|
|
185
|
-
let env;
|
|
186
|
-
try {
|
|
187
|
-
env = getRawRuntimeEnv();
|
|
188
|
-
} catch {
|
|
189
|
-
throw new Error("live: publish() was called outside a Void server runtime context. Pass an explicit env with stream.withEnv(env).publish(...).");
|
|
190
|
-
}
|
|
191
|
-
return publishWithEnv(env, topic, data, publishOptions);
|
|
192
|
-
},
|
|
193
|
-
withEnv(env) {
|
|
194
|
-
return { publish(topic, data, publishOptions) {
|
|
195
|
-
return publishWithEnv(env, topic, data, publishOptions);
|
|
196
|
-
} };
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
function defaultOwner(user) {
|
|
201
|
-
if (user && typeof user === "object" && "id" in user && typeof user.id === "string") return `user:${user.id}`;
|
|
202
|
-
return null;
|
|
203
|
-
}
|
|
204
|
-
function getContextUser(ctx) {
|
|
205
|
-
try {
|
|
206
|
-
return ctx.get("user");
|
|
207
|
-
} catch {
|
|
208
|
-
return null;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
function parseLiveControlResponse(body) {
|
|
212
|
-
try {
|
|
213
|
-
const parsed = JSON.parse(body);
|
|
214
|
-
return typeof parsed === "object" && parsed !== null && "accepted" in parsed ? parsed : null;
|
|
215
|
-
} catch {
|
|
216
|
-
return null;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
async function readControlRequest(request, limits) {
|
|
220
|
-
let body;
|
|
221
|
-
try {
|
|
222
|
-
body = await request.json();
|
|
223
|
-
} catch {
|
|
224
|
-
throw liveResponseError("BAD_REQUEST", "live: control request body must be JSON.", 400);
|
|
225
|
-
}
|
|
226
|
-
if (typeof body !== "object" || body === null || Array.isArray(body)) throw liveResponseError("BAD_REQUEST", "live: control request body must be an object.", 400);
|
|
227
|
-
const record = body;
|
|
228
|
-
const connectionId = assertConnectionId(record.connectionId);
|
|
229
|
-
if (!Array.isArray(record.operations)) throw liveResponseError("BAD_REQUEST", "live: operations must be an array.", 400);
|
|
230
|
-
if (record.operations.length > limits.maxOperationsPerControlRequest) throw liveResponseError("BAD_REQUEST", "live: too many operations in one control request.", 400);
|
|
231
|
-
return {
|
|
232
|
-
connectionId,
|
|
233
|
-
operations: record.operations.map(parseOperation)
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
function parseOperation(value, index) {
|
|
237
|
-
if (typeof value !== "object" || value === null || Array.isArray(value)) throw liveResponseError("BAD_REQUEST", "live: operation must be an object.", 400);
|
|
238
|
-
const record = value;
|
|
239
|
-
if (record.kind === "subscribe") {
|
|
240
|
-
const id = parseBoundedString(record.id, 1, 256);
|
|
241
|
-
if (id == null) return invalidOperation(index, "subscribe", record.id, "INVALID_SUBSCRIPTION_ID");
|
|
242
|
-
const topic = parseBoundedString(record.topic, 1, 512);
|
|
243
|
-
if (topic == null) return invalidOperation(index, "subscribe", id, "INVALID_TOPIC");
|
|
244
|
-
let lastEventId;
|
|
245
|
-
if (record.lastEventId !== void 0) {
|
|
246
|
-
lastEventId = parseBoundedString(record.lastEventId, 0, 512) ?? void 0;
|
|
247
|
-
if (lastEventId === void 0) return invalidOperation(index, "subscribe", id, "BAD_REQUEST");
|
|
248
|
-
}
|
|
249
|
-
return {
|
|
250
|
-
ok: true,
|
|
251
|
-
index,
|
|
252
|
-
operation: {
|
|
253
|
-
kind: "subscribe",
|
|
254
|
-
id,
|
|
255
|
-
topic,
|
|
256
|
-
...lastEventId !== void 0 && { lastEventId }
|
|
257
|
-
}
|
|
258
|
-
};
|
|
259
|
-
}
|
|
260
|
-
if (record.kind === "unsubscribe") {
|
|
261
|
-
const id = parseBoundedString(record.id, 1, 256);
|
|
262
|
-
if (id == null) return invalidOperation(index, "unsubscribe", record.id, "INVALID_SUBSCRIPTION_ID");
|
|
263
|
-
return {
|
|
264
|
-
ok: true,
|
|
265
|
-
index,
|
|
266
|
-
operation: {
|
|
267
|
-
kind: "unsubscribe",
|
|
268
|
-
id
|
|
269
|
-
}
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
throw liveResponseError("BAD_REQUEST", "live: operation kind is invalid.", 400);
|
|
273
|
-
}
|
|
274
|
-
function invalidOperation(index, kind, id, code) {
|
|
275
|
-
return {
|
|
276
|
-
ok: false,
|
|
277
|
-
index,
|
|
278
|
-
result: {
|
|
279
|
-
ok: false,
|
|
280
|
-
kind,
|
|
281
|
-
id: typeof id === "string" ? id : "",
|
|
282
|
-
error: {
|
|
283
|
-
code,
|
|
284
|
-
message: {
|
|
285
|
-
BAD_REQUEST: "live: invalid control operation.",
|
|
286
|
-
CONNECTION_CLOSED: "live: connection closed.",
|
|
287
|
-
CONNECTION_NOT_FOUND: "live: connection not found.",
|
|
288
|
-
FORBIDDEN: "Forbidden",
|
|
289
|
-
INVALID_SUBSCRIPTION_ID: "live: invalid subscription id.",
|
|
290
|
-
INVALID_TOPIC: "live: invalid topic.",
|
|
291
|
-
OWNER_MISMATCH: "live: owner mismatch.",
|
|
292
|
-
SUBSCRIPTION_LIMIT: "live: subscription limit reached.",
|
|
293
|
-
TOPIC_FULL: "live: topic subscription limit reached.",
|
|
294
|
-
PAYLOAD_TOO_LARGE: "live: payload too large.",
|
|
295
|
-
INTERNAL_ERROR: "live: internal error."
|
|
296
|
-
}[code]
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
}
|
|
301
|
-
function getLiveBinding(env) {
|
|
302
|
-
if (typeof env !== "object" || env === null) throw new Error("live: Cloudflare env is unavailable.");
|
|
303
|
-
const binding = env[liveBindingName];
|
|
304
|
-
if (!binding) throw new Error(`live: Missing Durable Object binding "${liveBindingName}".`);
|
|
305
|
-
return binding;
|
|
306
|
-
}
|
|
307
|
-
function getConnectionId(request) {
|
|
308
|
-
return assertConnectionId(new URL(request.url).searchParams.get("connectionId"));
|
|
309
|
-
}
|
|
310
|
-
function assertStreamId(value) {
|
|
311
|
-
return assertBoundedString("stream id", value, 1, 128);
|
|
312
|
-
}
|
|
313
|
-
function assertBindingName(value) {
|
|
314
|
-
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(value)) throw new Error(`live: invalid Durable Object binding name "${value}".`);
|
|
315
|
-
return value;
|
|
316
|
-
}
|
|
317
|
-
function assertConnectionId(value) {
|
|
318
|
-
return assertBoundedString("connectionId", value, 16, 256);
|
|
319
|
-
}
|
|
320
|
-
function assertTopic(value) {
|
|
321
|
-
return assertBoundedString("topic", value, 1, 512);
|
|
322
|
-
}
|
|
323
|
-
function assertOwner(value) {
|
|
324
|
-
if (value !== null) assertBoundedString("owner", value, 1, 512);
|
|
325
|
-
}
|
|
326
|
-
function assertOptionalString(name, value) {
|
|
327
|
-
if (value !== void 0) assertBoundedString(name, value, 1, 512);
|
|
328
|
-
}
|
|
329
|
-
function resolveLiveLimits(input) {
|
|
330
|
-
const limits = { ...DEFAULT_LIMITS };
|
|
331
|
-
for (const key of Object.keys(limits)) {
|
|
332
|
-
const value = input?.[key];
|
|
333
|
-
if (value === void 0) continue;
|
|
334
|
-
if (!Number.isFinite(value) || !Number.isInteger(value) || value <= 0) throw new Error(`live: limits.${key} must be a positive finite integer.`);
|
|
335
|
-
limits[key] = value;
|
|
336
|
-
}
|
|
337
|
-
if (limits.maxSubscriptionsPerTopic > MAX_SUBSCRIPTIONS_PER_TOPIC) throw new Error(`live: limits.maxSubscriptionsPerTopic must be at most ${MAX_SUBSCRIPTIONS_PER_TOPIC}.`);
|
|
338
|
-
return limits;
|
|
339
|
-
}
|
|
340
|
-
function assertBoundedString(name, value, min, max) {
|
|
341
|
-
const parsed = parseBoundedString(value, min, max);
|
|
342
|
-
if (parsed == null) throw liveResponseError("BAD_REQUEST", `live: invalid ${name}.`, 400);
|
|
343
|
-
return parsed;
|
|
344
|
-
}
|
|
345
|
-
function parseBoundedString(value, min, max) {
|
|
346
|
-
if (typeof value !== "string" || value.length < min || value.length > max || /[\r\n]/.test(value) || value.includes("\0")) return null;
|
|
347
|
-
return value;
|
|
348
|
-
}
|
|
349
|
-
function assertJsonSerializable(value) {
|
|
350
|
-
try {
|
|
351
|
-
if (typeof JSON.stringify(value) !== "string") throw new Error("unsupported value");
|
|
352
|
-
} catch (error) {
|
|
353
|
-
throw new Error(`live: payload must be JSON-serializable. ${error instanceof Error ? error.message : String(error)}`);
|
|
354
|
-
}
|
|
355
|
-
}
|
|
356
|
-
async function topicDigest(streamId, topic) {
|
|
357
|
-
const bytes = new TextEncoder().encode(`${streamId}\u0000${topic}`);
|
|
358
|
-
const digest = await crypto.subtle.digest("SHA-256", bytes);
|
|
359
|
-
const binary = String.fromCharCode(...new Uint8Array(digest));
|
|
360
|
-
return btoa(binary).replaceAll("+", "-").replaceAll("/", "_").replace(/=+$/, "");
|
|
361
|
-
}
|
|
362
|
-
function connectionInstanceName(streamId, connectionId) {
|
|
363
|
-
return `live:${streamId}:connection:${connectionId}`;
|
|
364
|
-
}
|
|
365
|
-
function topicInstanceName(streamId, topicKey) {
|
|
366
|
-
return `live:${streamId}:topic:${topicKey}`;
|
|
367
|
-
}
|
|
368
|
-
function internalUrl(path) {
|
|
369
|
-
return `https://void.live${path}`;
|
|
370
|
-
}
|
|
371
|
-
var LiveResponseError = class extends Error {
|
|
372
|
-
code;
|
|
373
|
-
status;
|
|
374
|
-
constructor(code, message, status) {
|
|
375
|
-
super(message);
|
|
376
|
-
this.code = code;
|
|
377
|
-
this.status = status;
|
|
378
|
-
}
|
|
379
|
-
};
|
|
380
|
-
function liveResponseError(code, message, status) {
|
|
381
|
-
throw new LiveResponseError(code, message, status);
|
|
382
|
-
}
|
|
383
|
-
function errorToResponse(error) {
|
|
384
|
-
if (error instanceof LiveResponseError) return Response.json({
|
|
385
|
-
accepted: false,
|
|
386
|
-
error: {
|
|
387
|
-
code: error.code,
|
|
388
|
-
message: error.message
|
|
389
|
-
}
|
|
390
|
-
}, { status: error.status });
|
|
391
|
-
return Response.json({
|
|
392
|
-
accepted: false,
|
|
393
|
-
error: {
|
|
394
|
-
code: "INTERNAL_ERROR",
|
|
395
|
-
message: error instanceof Error ? error.message : String(error)
|
|
396
|
-
}
|
|
397
|
-
}, { status: 500 });
|
|
398
|
-
}
|
|
399
|
-
async function responseToControlError(response) {
|
|
400
|
-
const message = await response.text().catch(() => "") || response.statusText;
|
|
401
|
-
if (response.status === 403 || response.status === 401) return {
|
|
402
|
-
code: "FORBIDDEN",
|
|
403
|
-
message: message || "Forbidden"
|
|
404
|
-
};
|
|
405
|
-
return {
|
|
406
|
-
code: "BAD_REQUEST",
|
|
407
|
-
message: message || "Subscription rejected"
|
|
408
|
-
};
|
|
409
|
-
}
|
|
410
|
-
//#endregion
|
|
1
|
+
import { n as __setLiveBindingName, r as defineLiveStream, t as __getLiveBindingName } from "../live-CB1y5IuC.mjs";
|
|
411
2
|
export { __getLiveBindingName, __setLiveBindingName, defineLiveStream };
|