@builtbyfriends/bwf 0.0.0-stage → 1.9.2
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/AGENTS_TEMPLATE.md +4 -0
- package/LICENSE +22 -0
- package/README.md +48 -2
- package/dist/account-cmd-Ddt8lGeL.mjs +45 -0
- package/dist/agents-BLiMq9E1.mjs +113 -0
- package/dist/application-analysis-C9Ck2Yeg.mjs +1498 -0
- package/dist/application-routing-DbR-W5lG.mjs +25 -0
- package/dist/atomic-write-DA6eD1Kp.mjs +17 -0
- package/dist/auth-BKsUmWbT.d.mts +77 -0
- package/dist/auth-DkvoW5hB.mjs +33 -0
- package/dist/auth-aKyIWkdS.mjs +1 -0
- package/dist/auth-client-6-Ft9i9T.d.mts +5 -0
- package/dist/auth-client-DwCdwKbw.mjs +5 -0
- package/dist/auth-client-react-CJdeErvM.mjs +5 -0
- package/dist/auth-client-react-DvQLe5Zb.d.mts +5 -0
- package/dist/auth-link-CCl-hJol.mjs +26 -0
- package/dist/auth-migrations-DDeifS3v.mjs +206 -0
- package/dist/auth-router-BG74WFUf.mjs +66 -0
- package/dist/auth-xnkmpZUl.mjs +311 -0
- package/dist/base64-ikl9yBy3.mjs +15 -0
- package/dist/better-auth-shared-Br6TNaYJ.mjs +473 -0
- package/dist/better-auth-shared-CsBNvPOU.d.mts +56 -0
- package/dist/build-cmd-BnZezraT.mjs +153 -0
- package/dist/build-output-dir-Clj_unKN.mjs +402 -0
- package/dist/cancel-deploy-DKAj5U1Z.mjs +57 -0
- package/dist/cf-access-Bhz9wX6p.mjs +131 -0
- package/dist/cf-access-CUP5L08W.mjs +67 -0
- package/dist/cf-build-output-DA6uJomQ.mjs +1 -0
- package/dist/cf-build-output-DNQTwMNU.mjs +438 -0
- package/dist/cf-command-values-2kOtxMo1.mjs +26 -0
- package/dist/cf-config-migrate-COOCi4Ge.mjs +330 -0
- package/dist/cf-worker-settings-CIh4t_yG.mjs +41 -0
- package/dist/cli/cli.d.mts +1 -0
- package/dist/cli/cli.mjs +88 -0
- package/dist/cli/cloudflare-operation-process.d.mts +1 -0
- package/dist/cli/cloudflare-operation-process.mjs +1284 -0
- package/dist/cli/env-schema-probe.d.mts +43 -0
- package/dist/cli/env-schema-probe.mjs +165 -0
- package/dist/cli-main-BfYf6fnB.mjs +1846 -0
- package/dist/client-D3D5RM5h.mjs +940 -0
- package/dist/client-VF2Nzc7Z.mjs +1 -0
- package/dist/cloudflare-auth-DzkU9H6r.mjs +152 -0
- package/dist/cloudflare-cmd-Bm6UhzAQ.mjs +59 -0
- package/dist/cloudflare-config-i8yanry0.mjs +186 -0
- package/dist/cloudflare-connect-B4ItSbJi.mjs +55 -0
- package/dist/cloudflare-operations-BcK849ue.mjs +1 -0
- package/dist/cloudflare-operations-DGF7xH7O.mjs +627 -0
- package/dist/cloudflare-process-tThIjEB2.mjs +309 -0
- package/dist/cloudflare-user-output-CqONaAbP.mjs +19 -0
- package/dist/collect-8i0wU63d.mjs +1 -0
- package/dist/collect-C6Blu9yw.mjs +48 -0
- package/dist/config-CN_RFRkS.mjs +86 -0
- package/dist/config-D5G-Tx6o.mjs +1 -0
- package/dist/config-DOaFIK3w.mjs +88 -0
- package/dist/config-entry.d.mts +202 -0
- package/dist/config-entry.mjs +6 -0
- package/dist/config-tNx0HlFv.mjs +516 -0
- package/dist/connect-CSNWKLzB.mjs +84 -0
- package/dist/create-project-B35ux-LA.mjs +126 -0
- package/dist/create-project-tJ1KwNss.mjs +1 -0
- package/dist/database-provider-DkZo4VwN.mjs +5 -0
- package/dist/database-provider.d.mts +25 -0
- package/dist/database-provider.mjs +1 -0
- package/dist/db-SOv4E9wr.mjs +1735 -0
- package/dist/delete-BSKI7V23.mjs +65 -0
- package/dist/deploy-BCSQoKC0.mjs +2 -0
- package/dist/deploy-CWJ3JJs_.mjs +6512 -0
- package/dist/deploy.d.mts +31 -0
- package/dist/deploy.mjs +118 -0
- package/dist/dev-inbox-I0nqTCdf.mjs +216 -0
- package/dist/discover-DJPmQcL5.mjs +36 -0
- package/dist/discover-EVuydEoM.mjs +1 -0
- package/dist/dist-B6eN80gc.mjs +1612 -0
- package/dist/dist-Cp4b1_T9.mjs +1 -0
- package/dist/dist-DMYe8CZJ.mjs +48 -0
- package/dist/dist-STQXl8ck.mjs +1878 -0
- package/dist/domain-BJaAbxuQ.mjs +149 -0
- package/dist/dotenv-4NdUCXbB.mjs +156 -0
- package/dist/drizzle-DqVFXtlc.mjs +306 -0
- package/dist/drizzle-Ds5P0n-S.mjs +1 -0
- package/dist/edge.d.mts +2 -0
- package/dist/edge.mjs +1 -0
- package/dist/email-C_ATvNIG.mjs +2865 -0
- package/dist/email-cloudflare-oXk2G1G3.mjs +854 -0
- package/dist/email-protocol-CZ0bAkI8.mjs +81 -0
- package/dist/email-rIfZgVAB.mjs +742 -0
- package/dist/env-BGTu3KWZ.mjs +73 -0
- package/dist/env-DUyTzroe.mjs +88 -0
- package/dist/env-Dl4Wggec.mjs +71 -0
- package/dist/env-helpers-BX0APszT.mjs +135 -0
- package/dist/env-helpers-U56xuFgL.d.mts +20 -0
- package/dist/env-mask-BsHxq3R8.mjs +46 -0
- package/dist/env-public-Cw_xPi1D.d.mts +119 -0
- package/dist/env-raw-Bo6TtrHU.mjs +41 -0
- package/dist/env-types-Bg-dTh8u.mjs +56 -0
- package/dist/env-validation-BlXzGgLZ.mjs +1 -0
- package/dist/env-validation-DeqFUSKg.mjs +488 -0
- package/dist/fetch-CBgyyhzm.d.mts +87 -0
- package/dist/fetch-error-DmlRM6e4.mjs +264 -0
- package/dist/fetch-stream-2GUN3YN1.mjs +102 -0
- package/dist/fetch-stream-bUXynOyZ.d.mts +32 -0
- package/dist/fetch-tpPiSK10.mjs +25 -0
- package/dist/gen-dc13IRXh.mjs +509 -0
- package/dist/gen-kQqhFyOP.mjs +1 -0
- package/dist/generate-BgtlYpKg.mjs +1 -0
- package/dist/generate-Da9mWKzU.mjs +80 -0
- package/dist/generated-wrangler-config-CoDaaFsA.mjs +17 -0
- package/dist/git-metadata-Cukp5kV5.mjs +82 -0
- package/dist/github-cmd-DT5Onu6E.mjs +690 -0
- package/dist/handler-B_ocHStk.d.mts +279 -0
- package/dist/handler-CNq7aSs1.mjs +161 -0
- package/dist/help-BK35YcRa.mjs +1946 -0
- package/dist/help-DaRezBj7.mjs +1 -0
- package/dist/inbound-CqubE-9T.d.mts +311 -0
- package/dist/inbound-lHugZPuK.mjs +509 -0
- package/dist/index.d.mts +64 -0
- package/dist/index.mjs +4163 -0
- package/dist/info-CLQoCenb.mjs +109 -0
- package/dist/init-CXanf5ck.mjs +2486 -0
- package/dist/limits-CMmYT2l8.d.mts +16 -0
- package/dist/limits-D27Lp6FP.mjs +46 -0
- package/dist/link-DinwJnon.mjs +52 -0
- package/dist/list-B1WAE9Wt.mjs +130 -0
- package/dist/live-KkEeda1Z.d.mts +105 -0
- package/dist/live-saC8barp.mjs +410 -0
- package/dist/load-user-env-g0ahkZcj.mjs +34 -0
- package/dist/local-d1-bUoAtFUe.mjs +103 -0
- package/dist/log-JDnPc0cF.mjs +23 -0
- package/dist/login-BUzyiyHV.mjs +1 -0
- package/dist/login-Dbv_T3Ru.mjs +87 -0
- package/dist/logs-BjMJooJQ.mjs +129 -0
- package/dist/migrate-DjW9_-sS.mjs +1 -0
- package/dist/migrate-DtcfKqPW.mjs +125 -0
- package/dist/migration-handler-22qiuWPq.mjs +469 -0
- package/dist/migration-handler-Bb2BJh6g.d.mts +38 -0
- package/dist/mime-BMUN_QKG.mjs +1004 -0
- package/dist/mysql-migration-sql-CNuBSqdx.mjs +239 -0
- package/dist/neon-CJzQSycr.mjs +52 -0
- package/dist/node-tfv-3v0V.mjs +64 -0
- package/dist/operator-ai-logging-Ay7M4KWw.mjs +121 -0
- package/dist/operator-args-BiGmSlZx.mjs +722 -0
- package/dist/operator-auth-DdYZYEkO.mjs +47 -0
- package/dist/operator-client-DBujdELO.mjs +82 -0
- package/dist/operator-cmd-BsHKYJYt.mjs +1 -0
- package/dist/operator-cmd-DTIkOAnP.mjs +443 -0
- package/dist/output-Bb34lF0w.mjs +173 -0
- package/dist/output-CVolXKC1.mjs +1 -0
- package/dist/package-BX_giUBX.mjs +1444 -0
- package/dist/package-json-DvS6IFRv.mjs +43 -0
- package/dist/pg-DoyPxa_X.mjs +15 -0
- package/dist/picocolors-D1NxSLw-.mjs +71 -0
- package/dist/plan-BHNt1QhK.mjs +1 -0
- package/dist/plan-DX4_-OM5.mjs +58 -0
- package/dist/platform-args-C-DyuCNX.mjs +1 -0
- package/dist/platform-args-CyeQWaZ7.mjs +538 -0
- package/dist/platform-auth-config-BfXqKSyZ.mjs +371 -0
- package/dist/platform-auth-protection-5FR6qoP_.mjs +231 -0
- package/dist/platform-auth-recovery-B5ZlqA8K.mjs +309 -0
- package/dist/platform-cmd-CcFDxtrl.mjs +1 -0
- package/dist/platform-cmd-ChXeBrRH.mjs +193 -0
- package/dist/platform-discovery-Bxg9aZXU.mjs +40 -0
- package/dist/platform-domain-CwatS3cz.mjs +256 -0
- package/dist/platform-lifecycle-0cXTmMsh.mjs +8928 -0
- package/dist/platform-lifecycle-BcoBAMux.mjs +1 -0
- package/dist/platform-management-6Wbdbob5.mjs +1607 -0
- package/dist/platform-management-hhnczOzr.mjs +1 -0
- package/dist/platform-plans-config-CkbUKFpm.mjs +447 -0
- package/dist/platform-recovery-DgIwlqB-.mjs +96 -0
- package/dist/platform-registry-x1m9HBxf.mjs +450 -0
- package/dist/platform-runtime-logs-kkoiYFpF.mjs +72 -0
- package/dist/platform-setup-DX8y_6Kh.mjs +306 -0
- package/dist/prepare-B9mB47T5.mjs +84 -0
- package/dist/prepare-DNIq07so.mjs +13 -0
- package/dist/prepare-LHkyJqxi.mjs +1 -0
- package/dist/project-CC7eN00D.mjs +141 -0
- package/dist/project-DcSd4BeI.mjs +1 -0
- package/dist/project-cmd-BydRwr-x.mjs +109 -0
- package/dist/project-paths-iXHKRTTQ.mjs +159 -0
- package/dist/project-slug-BUy0lmyR.mjs +1 -0
- package/dist/project-slug-CO6ci9XG.mjs +7 -0
- package/dist/project-team-CvdLhDF2.mjs +129 -0
- package/dist/project-token-CwZdUEGu.mjs +70 -0
- package/dist/project-tsconfig-P9X952KG.mjs +98 -0
- package/dist/project-zero-trust-CKDoPdN1.mjs +64 -0
- package/dist/providers-Cd3c7wi0.mjs +64 -0
- package/dist/providers-Df69hb_X.d.mts +5 -0
- package/dist/provision-BA59NCPO.mjs +1 -0
- package/dist/provision-C90fULHJ.mjs +1814 -0
- package/dist/queues-Bc3FsBQT.d.mts +5 -0
- package/dist/r2-conditions-DSLmkiR5.mjs +60 -0
- package/dist/requests-DNhfyF3l.mjs +52 -0
- package/dist/resolve-project-BCsAMDRA.mjs +47 -0
- package/dist/resolve-project-DhU9_lIo.mjs +1 -0
- package/dist/resource-name-DlJ9QXzg.mjs +10 -0
- package/dist/response-HmNjB30w.mjs +29 -0
- package/dist/rollback-wi6WK5T6.mjs +150 -0
- package/dist/rolldown-runtime-uD8oG6U2.mjs +24 -0
- package/dist/route-types-CRWhr93D.mjs +592 -0
- package/dist/route-url-BIDZT78M.mjs +58 -0
- package/dist/route-url-Bla3Upsy.d.mts +42 -0
- package/dist/routes-stub.d.mts +24 -0
- package/dist/routes-stub.mjs +1 -0
- package/dist/routing-assets-CSheDWWM.mjs +54 -0
- package/dist/rpc-DcByS_q0.d.mts +39 -0
- package/dist/rpc-DtxIN9Tv.mjs +19 -0
- package/dist/runner-CPerdjIl.mjs +163 -0
- package/dist/runner-CUNtS5x7.mjs +1 -0
- package/dist/runner-mysql-BjSoQ-mW.mjs +1 -0
- package/dist/runner-mysql-BmTI2EiF.mjs +145 -0
- package/dist/runner-pg-2pjltt0t.mjs +1 -0
- package/dist/runner-pg-mYc75KfH.mjs +61 -0
- package/dist/runtime/ai.d.mts +50 -0
- package/dist/runtime/ai.mjs +455 -0
- package/dist/runtime/auth-client-react.d.mts +2 -0
- package/dist/runtime/auth-client-react.mjs +1 -0
- package/dist/runtime/auth-client.d.mts +2 -0
- package/dist/runtime/auth-client.mjs +1 -0
- package/dist/runtime/auth.d.mts +2 -0
- package/dist/runtime/auth.mjs +1 -0
- package/dist/runtime/better-auth-mysql.d.mts +5 -0
- package/dist/runtime/better-auth-mysql.mjs +21 -0
- package/dist/runtime/better-auth-pg.d.mts +5 -0
- package/dist/runtime/better-auth-pg.mjs +21 -0
- package/dist/runtime/better-auth.d.mts +6 -0
- package/dist/runtime/better-auth.mjs +22 -0
- package/dist/runtime/client-react.d.mts +5 -0
- package/dist/runtime/client-react.mjs +5 -0
- package/dist/runtime/client.d.mts +5 -0
- package/dist/runtime/client.mjs +5 -0
- package/dist/runtime/db-mysql.d.mts +2 -0
- package/dist/runtime/db-mysql.mjs +1 -0
- package/dist/runtime/db-pg.d.mts +2 -0
- package/dist/runtime/db-pg.mjs +1 -0
- package/dist/runtime/db.d.mts +17 -0
- package/dist/runtime/db.mjs +36 -0
- package/dist/runtime/drizzle-arktype.d.mts +1 -0
- package/dist/runtime/drizzle-arktype.mjs +2 -0
- package/dist/runtime/drizzle-valibot.d.mts +1 -0
- package/dist/runtime/drizzle-valibot.mjs +2 -0
- package/dist/runtime/drizzle-zod.d.mts +1 -0
- package/dist/runtime/drizzle-zod.mjs +2 -0
- package/dist/runtime/durable.d.mts +64 -0
- package/dist/runtime/durable.mjs +165 -0
- package/dist/runtime/email/testing.d.mts +108 -0
- package/dist/runtime/email/testing.mjs +268 -0
- package/dist/runtime/email-protocol.d.mts +25 -0
- package/dist/runtime/email-protocol.mjs +1 -0
- package/dist/runtime/email.d.mts +26 -0
- package/dist/runtime/email.mjs +524 -0
- package/dist/runtime/env-public-client.d.mts +19 -0
- package/dist/runtime/env-public-client.mjs +55 -0
- package/dist/runtime/env-public.d.mts +4 -0
- package/dist/runtime/env-public.mjs +277 -0
- package/dist/runtime/env.d.mts +12 -0
- package/dist/runtime/env.mjs +1 -0
- package/dist/runtime/fetch-server.d.mts +6 -0
- package/dist/runtime/fetch-server.mjs +29 -0
- package/dist/runtime/fetch-stream.d.mts +3 -0
- package/dist/runtime/fetch-stream.mjs +3 -0
- package/dist/runtime/fetch.d.mts +2 -0
- package/dist/runtime/fetch.mjs +3 -0
- package/dist/runtime/handler.d.mts +3 -0
- package/dist/runtime/handler.mjs +1 -0
- package/dist/runtime/kv.d.mts +45 -0
- package/dist/runtime/kv.mjs +103 -0
- package/dist/runtime/limits.d.mts +2 -0
- package/dist/runtime/limits.mjs +1 -0
- package/dist/runtime/live-client.d.mts +40 -0
- package/dist/runtime/live-client.mjs +282 -0
- package/dist/runtime/live-server.d.mts +11 -0
- package/dist/runtime/live-server.mjs +419 -0
- package/dist/runtime/live.d.mts +3 -0
- package/dist/runtime/live.mjs +1 -0
- package/dist/runtime/log.d.mts +24 -0
- package/dist/runtime/log.mjs +57 -0
- package/dist/runtime/migration-handler-mysql.d.mts +2 -0
- package/dist/runtime/migration-handler-mysql.mjs +111 -0
- package/dist/runtime/migration-handler-pg.d.mts +2 -0
- package/dist/runtime/migration-handler-pg.mjs +94 -0
- package/dist/runtime/migration-handler.d.mts +2 -0
- package/dist/runtime/migration-handler.mjs +1 -0
- package/dist/runtime/procedure.d.mts +27 -0
- package/dist/runtime/procedure.mjs +36 -0
- package/dist/runtime/procedures.d.mts +24 -0
- package/dist/runtime/procedures.mjs +56 -0
- package/dist/runtime/queues.d.mts +2 -0
- package/dist/runtime/queues.mjs +8 -0
- package/dist/runtime/remote/binding-handler.d.mts +11 -0
- package/dist/runtime/remote/binding-handler.mjs +227 -0
- package/dist/runtime/remote/index.d.mts +12 -0
- package/dist/runtime/remote/index.mjs +467 -0
- package/dist/runtime/response.d.mts +11 -0
- package/dist/runtime/response.mjs +1 -0
- package/dist/runtime/route-url.d.mts +2 -0
- package/dist/runtime/route-url.mjs +1 -0
- package/dist/runtime/routing.d.mts +53 -0
- package/dist/runtime/routing.mjs +425 -0
- package/dist/runtime/rpc-react.d.mts +16 -0
- package/dist/runtime/rpc-react.mjs +50 -0
- package/dist/runtime/rpc.d.mts +2 -0
- package/dist/runtime/rpc.mjs +1 -0
- package/dist/runtime/sandbox-container.d.mts +3 -0
- package/dist/runtime/sandbox-container.mjs +1 -0
- package/dist/runtime/sandbox.d.mts +5 -0
- package/dist/runtime/sandbox.mjs +196 -0
- package/dist/runtime/schema-d1.d.mts +1 -0
- package/dist/runtime/schema-d1.mjs +2 -0
- package/dist/runtime/schema-mysql.d.mts +1 -0
- package/dist/runtime/schema-mysql.mjs +2 -0
- package/dist/runtime/schema-pg.d.mts +1 -0
- package/dist/runtime/schema-pg.mjs +2 -0
- package/dist/runtime/seed.d.mts +34 -0
- package/dist/runtime/seed.mjs +5 -0
- package/dist/runtime/sse-client.d.mts +31 -0
- package/dist/runtime/sse-client.mjs +42 -0
- package/dist/runtime/sse.d.mts +32 -0
- package/dist/runtime/sse.mjs +1 -0
- package/dist/runtime/storage.d.mts +4 -0
- package/dist/runtime/storage.mjs +13 -0
- package/dist/runtime/validator.d.mts +2 -0
- package/dist/runtime/validator.mjs +1 -0
- package/dist/runtime/ws-server.d.mts +26 -0
- package/dist/runtime/ws-server.mjs +297 -0
- package/dist/runtime/ws.d.mts +2 -0
- package/dist/runtime/ws.mjs +108 -0
- package/dist/sandbox-CWDjoEG2.d.mts +50 -0
- package/dist/sandbox-container-BqamdFCx.d.mts +73 -0
- package/dist/sandbox-container-d1AHLpgn.mjs +291 -0
- package/dist/secret-D5XrWshs.mjs +146 -0
- package/dist/skills-Dr3AjuBF.mjs +63 -0
- package/dist/sqlite-validation-CLJXXN93.mjs +24 -0
- package/dist/sse-CxR30yMF.mjs +174 -0
- package/dist/standard-schema-CuDawHOC.d.mts +40 -0
- package/dist/static-asset-marker-mWMX2dLa.mjs +38 -0
- package/dist/subcommand-prompt-B9yUo--u.mjs +370 -0
- package/dist/terminal-log-text-DNsWJREL.mjs +31 -0
- package/dist/types-D7-4tBu7.d.mts +1 -0
- package/dist/untrusted-env-lL7RkYiC.mjs +50 -0
- package/dist/validate-B-zsjhiz.mjs +162 -0
- package/dist/validate-DbqGdPPY.mjs +1 -0
- package/dist/validator-8-NZs2Xr.mjs +168 -0
- package/dist/version-metadata-DPhqnpaa.mjs +23 -0
- package/dist/wrangler-C3uyPadQ.mjs +1 -0
- package/dist/wrangler-TqTvJFWS.mjs +1452 -0
- package/dist/ws-DZRiIpYw.d.mts +137 -0
- package/dist/yarn-pnp-DgWbE7z5.mjs +91 -0
- package/docs/guide/ai.md +273 -0
- package/docs/guide/app-types.md +101 -0
- package/docs/guide/auth.md +255 -0
- package/docs/guide/database/d1.md +86 -0
- package/docs/guide/database/mysql.md +72 -0
- package/docs/guide/database/postgresql.md +94 -0
- package/docs/guide/database.md +454 -0
- package/docs/guide/deployment.md +124 -0
- package/docs/guide/durable-state.md +192 -0
- package/docs/guide/edge/headers.md +47 -0
- package/docs/guide/edge/redirects.md +85 -0
- package/docs/guide/edge/rewrites.md +119 -0
- package/docs/guide/edge/static-assets.md +94 -0
- package/docs/guide/email/domains.md +119 -0
- package/docs/guide/email/receiving.md +142 -0
- package/docs/guide/email/sending.md +262 -0
- package/docs/guide/email.md +23 -0
- package/docs/guide/env-vars.md +115 -0
- package/docs/guide/index.md +37 -0
- package/docs/guide/jobs.md +80 -0
- package/docs/guide/kv.md +100 -0
- package/docs/guide/live.md +181 -0
- package/docs/guide/platform/administration/access.md +165 -0
- package/docs/guide/platform/administration/connected-apps.md +84 -0
- package/docs/guide/platform/administration/email.md +169 -0
- package/docs/guide/platform/administration/operations.md +100 -0
- package/docs/guide/platform/administration/plans.md +156 -0
- package/docs/guide/platform/administration/projects.md +74 -0
- package/docs/guide/platform/administration/zero-trust.md +205 -0
- package/docs/guide/platform/development/local.md +122 -0
- package/docs/guide/platform/development/runtime.md +115 -0
- package/docs/guide/platform/development/schema-ci.md +44 -0
- package/docs/guide/platform/installation/ci.md +62 -0
- package/docs/guide/platform/installation/credentials.md +140 -0
- package/docs/guide/platform/installation/domains.md +120 -0
- package/docs/guide/platform/installation/first-deployment.md +95 -0
- package/docs/guide/platform/installation/maintenance.md +250 -0
- package/docs/guide/platform/installation/prerequisites.md +176 -0
- package/docs/guide/platform/installation/setup.md +300 -0
- package/docs/guide/platform/installation/uninstall.md +110 -0
- package/docs/guide/platform-administration.md +19 -0
- package/docs/guide/platform-development.md +16 -0
- package/docs/guide/procedures.md +48 -0
- package/docs/guide/project-collaboration.md +99 -0
- package/docs/guide/queues.md +149 -0
- package/docs/guide/quickstart.md +129 -0
- package/docs/guide/remote-dev.md +67 -0
- package/docs/guide/sandboxes.md +134 -0
- package/docs/guide/self-hosted-platform.md +45 -0
- package/docs/guide/server-routing.md +283 -0
- package/docs/guide/sse.md +174 -0
- package/docs/guide/storage.md +82 -0
- package/docs/guide/testing.md +64 -0
- package/docs/guide/type-safety.md +270 -0
- package/docs/guide/typed-fetch.md +98 -0
- package/docs/guide/websockets.md +230 -0
- package/docs/index.md +102 -0
- package/docs/integrations/agents.md +38 -0
- package/docs/integrations/cloudflare.md +241 -0
- package/docs/integrations/hono.md +127 -0
- package/docs/reference/api/auth.md +195 -0
- package/docs/reference/api/client.md +90 -0
- package/docs/reference/api/database.md +118 -0
- package/docs/reference/api/deploy.md +63 -0
- package/docs/reference/api/durable.md +47 -0
- package/docs/reference/api/env.md +51 -0
- package/docs/reference/api/handlers.md +189 -0
- package/docs/reference/api/plugin.md +40 -0
- package/docs/reference/api/resources.md +116 -0
- package/docs/reference/api/rewrites.md +111 -0
- package/docs/reference/api/types.md +126 -0
- package/docs/reference/api.md +71 -0
- package/docs/reference/cli/auth.md +87 -0
- package/docs/reference/cli/database.md +159 -0
- package/docs/reference/cli/deploy.md +117 -0
- package/docs/reference/cli/domains.md +42 -0
- package/docs/reference/cli/email.md +145 -0
- package/docs/reference/cli/generate.md +113 -0
- package/docs/reference/cli/github.md +181 -0
- package/docs/reference/cli/platform-config.md +93 -0
- package/docs/reference/cli/platform-email.md +81 -0
- package/docs/reference/cli/platform-installation.md +166 -0
- package/docs/reference/cli/platform-operations.md +90 -0
- package/docs/reference/cli/platform-users.md +159 -0
- package/docs/reference/cli/platform-zero-trust.md +60 -0
- package/docs/reference/cli/platform.md +78 -0
- package/docs/reference/cli/project.md +208 -0
- package/docs/reference/cli/secrets.md +79 -0
- package/docs/reference/cli/setup.md +88 -0
- package/docs/reference/cli.md +115 -0
- package/docs/reference/config.md +478 -0
- package/docs/reference/resource-inference.md +72 -0
- package/docs/reference/structure.md +138 -0
- package/package.json +389 -3
- package/sandbox.Dockerfile +4 -0
- package/schema.json +353 -0
- package/skills/bwf/SKILL.md +100 -0
- package/skills/migrate-vite-cloudflare-to-bwf/SKILL.md +53 -0
- package/templates/assets/bwf.svg +5 -0
- package/templates/assets/icons.svg +49 -0
- package/templates/assets/react.svg +1 -0
- package/templates/assets/stack.svg +35 -0
|
@@ -0,0 +1,509 @@
|
|
|
1
|
+
import { t as base64ToBytes } from "./base64-ikl9yBy3.mjs";
|
|
2
|
+
import { o as withTimeout } from "./email-protocol-CZ0bAkI8.mjs";
|
|
3
|
+
import { i as getRawRuntimeEnv } from "./env-raw-Bo6TtrHU.mjs";
|
|
4
|
+
import { a as normalizeEmail, c as fitsHeaderLine, l as replyReferences, n as MimeError, r as buildMime, s as validateAddressParts, u as threadingId } from "./mime-BMUN_QKG.mjs";
|
|
5
|
+
import { EMAIL_MAX_ACTIONS, EMAIL_MAX_INBOUND_BYTES, EMAIL_MAX_INBOUND_HEADERS, EMAIL_MAX_METADATA_BYTES, EMAIL_MAX_REPLY_BYTES, EMAIL_MAX_RESPONSE_BYTES } from "@builtbyfriends/platform/email-protocol";
|
|
6
|
+
// src/runtime/email/inbound.ts
|
|
7
|
+
const MAX_ACTIONS = EMAIL_MAX_ACTIONS;
|
|
8
|
+
const MAX_ACTION_METADATA_BYTES = EMAIL_MAX_METADATA_BYTES;
|
|
9
|
+
/** Bounds on a forward's headers. */
|
|
10
|
+
const MAX_FORWARD_HEADERS = 32;
|
|
11
|
+
const MAX_FORWARD_HEADER_LENGTH = 1024;
|
|
12
|
+
/** Maximum normalized SMTP rejection reason length. */
|
|
13
|
+
const MAX_REJECT_REASON_LENGTH = 1e3;
|
|
14
|
+
/** Inbound admission limits also applied by the handler test harness. */
|
|
15
|
+
const MAX_INBOUND_BYTES = EMAIL_MAX_INBOUND_BYTES;
|
|
16
|
+
const MAX_INBOUND_HEADERS = EMAIL_MAX_INBOUND_HEADERS;
|
|
17
|
+
const MAX_REPLY_BYTES = EMAIL_MAX_REPLY_BYTES;
|
|
18
|
+
const EMAIL_STREAM_DEADLINE_MS = 15e3;
|
|
19
|
+
const EMAIL_ACTION_TERMINAL_BYTES = 5;
|
|
20
|
+
const INBOUND_PROVIDER_DEADLINE_MS = 3e4;
|
|
21
|
+
const INBOUND_ACTION_BATCH_DEADLINE_MS = 6e4;
|
|
22
|
+
const actionEncoder = new TextEncoder();
|
|
23
|
+
function emailActionWireSize(action) {
|
|
24
|
+
return 5 + actionEncoder.encode(JSON.stringify(action.type === "reply" ? {
|
|
25
|
+
type: action.type,
|
|
26
|
+
from: action.from,
|
|
27
|
+
to: action.to
|
|
28
|
+
} : action)).byteLength + (action.type === "reply" ? 5 + action.raw.byteLength : 0);
|
|
29
|
+
}
|
|
30
|
+
/** The raw env, or `undefined` outside a worker or SSR request. */
|
|
31
|
+
function tryGetRawRuntimeEnv() {
|
|
32
|
+
try {
|
|
33
|
+
return getRawRuntimeEnv();
|
|
34
|
+
} catch {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/** A non-empty string env var. */
|
|
39
|
+
function readEnvString(name) {
|
|
40
|
+
const raw = tryGetRawRuntimeEnv()?.[name];
|
|
41
|
+
return typeof raw === "string" && raw.length > 0 ? raw : void 0;
|
|
42
|
+
}
|
|
43
|
+
const VALID_SLUG = /^[a-z0-9](?:[a-z0-9-]{0,54}[a-z0-9])?$/;
|
|
44
|
+
/** `__NOSAM_PROJECT_SLUG` when it can head a sender address. */
|
|
45
|
+
function readProjectSlug() {
|
|
46
|
+
const raw = readEnvString("__NOSAM_PROJECT_SLUG");
|
|
47
|
+
return raw !== void 0 && VALID_SLUG.test(raw) ? raw : void 0;
|
|
48
|
+
}
|
|
49
|
+
function readRelayDomain(message) {
|
|
50
|
+
const raw = message.__nosamRelayDomain;
|
|
51
|
+
return typeof raw === "string" && raw.length > 0 ? raw : void 0;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Identity helper that types the inbound email handler. Use as the default
|
|
55
|
+
* export of `email/<address>.ts` or `email/_default.ts`.
|
|
56
|
+
*/
|
|
57
|
+
function defineEmail(handler) {
|
|
58
|
+
return handler;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Typed error thrown by `parseEmail`. Lets handler authors distinguish
|
|
62
|
+
* "too big" from "malformed body" without string-matching error messages.
|
|
63
|
+
*/
|
|
64
|
+
var ParseEmailError = class extends Error {
|
|
65
|
+
code;
|
|
66
|
+
constructor(code, message, options) {
|
|
67
|
+
super(message, options);
|
|
68
|
+
this.name = "ParseEmailError";
|
|
69
|
+
this.code = code;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Parse a `ForwardableEmailMessage` into structured fields with postal-mime,
|
|
74
|
+
* loaded on first use. A native Cloudflare message's `raw` stream is
|
|
75
|
+
* one-shot, so parse it once.
|
|
76
|
+
*/
|
|
77
|
+
async function parseEmail(message) {
|
|
78
|
+
if (message.rawSize > MAX_INBOUND_BYTES) throw new ParseEmailError("INBOUND_TOO_LARGE", `parseEmail: message size ${message.rawSize} bytes exceeds maximum of ${MAX_INBOUND_BYTES} bytes.`);
|
|
79
|
+
const { default: PostalMime } = await import("postal-mime");
|
|
80
|
+
const cached = proxyRawCache.get(message);
|
|
81
|
+
try {
|
|
82
|
+
const source = cached ? await cached.read() : message.raw;
|
|
83
|
+
return await PostalMime.parse(source);
|
|
84
|
+
} catch (cause) {
|
|
85
|
+
throw new ParseEmailError("PARSE_FAILED", `parseEmail: could not parse the message body. ${cause instanceof Error ? cause.message : String(cause)}`, { cause });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const proxyRawCache = /* @__PURE__ */ new WeakMap();
|
|
89
|
+
/** Remove a leading `<slug>+` (case-insensitive) from the local part. */
|
|
90
|
+
function stripSlugFromAddress(address, slug) {
|
|
91
|
+
if (!slug) return address;
|
|
92
|
+
const atIdx = address.indexOf("@");
|
|
93
|
+
if (atIdx <= 0) return address;
|
|
94
|
+
const localPart = address.slice(0, atIdx);
|
|
95
|
+
const domain = address.slice(atIdx);
|
|
96
|
+
const prefix = `${slug.toLowerCase()}+`;
|
|
97
|
+
if (localPart.toLowerCase().startsWith(prefix)) return localPart.slice(prefix.length) + domain;
|
|
98
|
+
return address;
|
|
99
|
+
}
|
|
100
|
+
function replyTooLarge(size) {
|
|
101
|
+
return new MimeError("MIME_ERROR", `reply: message size ${size} bytes exceeds bwf's sending limit of ${MAX_REPLY_BYTES} bytes.`);
|
|
102
|
+
}
|
|
103
|
+
function replyBudgetExhausted(size) {
|
|
104
|
+
return new MimeError("MIME_ERROR", `reply: serialized actions would use ${size} bytes, over this delivery's ${EMAIL_MAX_RESPONSE_BYTES}-byte response budget.`);
|
|
105
|
+
}
|
|
106
|
+
function queueFull() {
|
|
107
|
+
return new MimeError("MIME_ERROR", `email: handler queued more than ${MAX_ACTIONS} actions for one message.`);
|
|
108
|
+
}
|
|
109
|
+
function addressTooLong(field, length) {
|
|
110
|
+
return new MimeError(field === "from" ? "INVALID_FROM" : "INVALID_TO", `${field} address is ${length} characters, over the 320-character limit.`);
|
|
111
|
+
}
|
|
112
|
+
function invalidForwardHeaders(cause) {
|
|
113
|
+
const detail = cause instanceof Error ? cause.message.slice(0, 320) : "not a valid header set";
|
|
114
|
+
return new MimeError("MIME_ERROR", `forward: invalid header — ${detail}`);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* The router's `forwardHeadersWithinBounds`, as a throw: the router drops the
|
|
118
|
+
* whole action list on a violation, so refuse it at the handler's own call.
|
|
119
|
+
* Counts the record as stored (a `Headers` has already folded duplicates).
|
|
120
|
+
*/
|
|
121
|
+
function assertForwardHeadersWithinBounds(headers) {
|
|
122
|
+
const names = Object.keys(headers);
|
|
123
|
+
if (names.length > MAX_FORWARD_HEADERS) throw new MimeError("MIME_ERROR", `forward: ${names.length} headers, over the ${MAX_FORWARD_HEADERS}-header limit.`);
|
|
124
|
+
for (const name of names) {
|
|
125
|
+
if (name.length > MAX_FORWARD_HEADER_LENGTH) throw new MimeError("MIME_ERROR", `forward: header name is ${name.length} characters, over the ${MAX_FORWARD_HEADER_LENGTH}-character limit.`);
|
|
126
|
+
const value = headers[name];
|
|
127
|
+
if (typeof value !== "string") throw new MimeError("MIME_ERROR", `forward: header "${name.slice(0, 64)}" value is not a string.`);
|
|
128
|
+
if (value.length > MAX_FORWARD_HEADER_LENGTH) throw new MimeError("MIME_ERROR", `forward: header "${name.slice(0, 64)}" value is ${value.length} characters, over the ${MAX_FORWARD_HEADER_LENGTH}-character limit.`);
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* The router's reject-reason rule, applied at record time so native replay
|
|
133
|
+
* sends the same string. Normalized rather than refused, since a throw would
|
|
134
|
+
* drop the reject; slice before replace to bound the work.
|
|
135
|
+
*/
|
|
136
|
+
function normalizeRejectReason(reason) {
|
|
137
|
+
const raw = typeof reason === "string" ? reason : "";
|
|
138
|
+
if (raw.length === 0) return "rejected by handler";
|
|
139
|
+
return raw.slice(0, MAX_REJECT_REASON_LENGTH).replace(/[\x00-\x1f\x7f]+/g, " ");
|
|
140
|
+
}
|
|
141
|
+
async function readStreamToBytes(stream, limit = Infinity, onOverflow = replyTooLarge) {
|
|
142
|
+
const reader = stream.getReader();
|
|
143
|
+
const chunks = [];
|
|
144
|
+
let total = 0;
|
|
145
|
+
const deadline = Date.now() + EMAIL_STREAM_DEADLINE_MS;
|
|
146
|
+
try {
|
|
147
|
+
for (;;) {
|
|
148
|
+
const { value, done } = await withTimeout(deadline - Date.now(), () => reader.read(), () => new MimeError("MIME_ERROR", "email stream timed out"));
|
|
149
|
+
if (done) break;
|
|
150
|
+
total += value.byteLength;
|
|
151
|
+
if (total > limit) throw onOverflow(total);
|
|
152
|
+
chunks.push(value);
|
|
153
|
+
}
|
|
154
|
+
} catch (error) {
|
|
155
|
+
reader.cancel().catch(() => {});
|
|
156
|
+
throw error;
|
|
157
|
+
} finally {
|
|
158
|
+
try {
|
|
159
|
+
reader.releaseLock();
|
|
160
|
+
} catch {}
|
|
161
|
+
}
|
|
162
|
+
const out = new Uint8Array(total);
|
|
163
|
+
let offset = 0;
|
|
164
|
+
for (const c of chunks) {
|
|
165
|
+
out.set(c, offset);
|
|
166
|
+
offset += c.byteLength;
|
|
167
|
+
}
|
|
168
|
+
return out;
|
|
169
|
+
}
|
|
170
|
+
function bytesToReadableStream(bytes) {
|
|
171
|
+
return new ReadableStream({ start(controller) {
|
|
172
|
+
controller.enqueue(bytes);
|
|
173
|
+
controller.close();
|
|
174
|
+
} });
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Build the message a handler sees from an envelope. `setReject`, `forward`
|
|
178
|
+
* and `reply` record `EmailAction`s instead of dispatching; the caller enacts
|
|
179
|
+
* them after the handler returns. `reply()` takes `{ from, to, raw }`, which
|
|
180
|
+
* `replyEmail()` passes: a native `EmailMessage` has no readable body.
|
|
181
|
+
*/
|
|
182
|
+
function createMessageProxy(envelope, opts = {}) {
|
|
183
|
+
const actions = [];
|
|
184
|
+
const headers = new Headers(envelope.headers);
|
|
185
|
+
const slug = envelope.viaDomain === void 0 || envelope.viaDomain === "" ? opts.slug : void 0;
|
|
186
|
+
const userVisibleTo = stripSlugFromAddress(envelope.to, slug);
|
|
187
|
+
let cachedRaw;
|
|
188
|
+
let bufferingPromise;
|
|
189
|
+
function readRawOnce() {
|
|
190
|
+
if (cachedRaw) return Promise.resolve(cachedRaw);
|
|
191
|
+
if (bufferingPromise) return bufferingPromise;
|
|
192
|
+
const source = envelope.raw;
|
|
193
|
+
if (source instanceof Uint8Array) {
|
|
194
|
+
cachedRaw = source;
|
|
195
|
+
return Promise.resolve(cachedRaw);
|
|
196
|
+
}
|
|
197
|
+
bufferingPromise = readStreamToBytes(source).then((bytes) => {
|
|
198
|
+
cachedRaw = bytes;
|
|
199
|
+
return bytes;
|
|
200
|
+
});
|
|
201
|
+
return bufferingPromise;
|
|
202
|
+
}
|
|
203
|
+
if (envelope.raw instanceof Uint8Array) cachedRaw = envelope.raw;
|
|
204
|
+
let rejected = false;
|
|
205
|
+
let actionWireBytesUsed = EMAIL_ACTION_TERMINAL_BYTES;
|
|
206
|
+
let pendingReplies = 0;
|
|
207
|
+
let replyRecordingTail = Promise.resolve();
|
|
208
|
+
function recordAction(action) {
|
|
209
|
+
if (rejected) return false;
|
|
210
|
+
if (actions.length >= MAX_ACTIONS) throw queueFull();
|
|
211
|
+
const nextSize = actionWireBytesUsed + emailActionWireSize(action);
|
|
212
|
+
if (nextSize > EMAIL_MAX_RESPONSE_BYTES) throw replyBudgetExhausted(nextSize);
|
|
213
|
+
actions.push(action);
|
|
214
|
+
actionWireBytesUsed = nextSize;
|
|
215
|
+
return true;
|
|
216
|
+
}
|
|
217
|
+
function assertQueueHasRoom() {
|
|
218
|
+
if (actions.length + pendingReplies >= MAX_ACTIONS) throw queueFull();
|
|
219
|
+
}
|
|
220
|
+
const message = {
|
|
221
|
+
from: envelope.from,
|
|
222
|
+
to: userVisibleTo,
|
|
223
|
+
headers,
|
|
224
|
+
get raw() {
|
|
225
|
+
if (cachedRaw) return bytesToReadableStream(cachedRaw);
|
|
226
|
+
const pending = readRawOnce();
|
|
227
|
+
return new ReadableStream({ async start(controller) {
|
|
228
|
+
const bytes = await pending;
|
|
229
|
+
controller.enqueue(bytes);
|
|
230
|
+
controller.close();
|
|
231
|
+
} });
|
|
232
|
+
},
|
|
233
|
+
rawSize: envelope.rawSize,
|
|
234
|
+
setReject(reason) {
|
|
235
|
+
if (rejected) return;
|
|
236
|
+
rejected = true;
|
|
237
|
+
let dropped = 0;
|
|
238
|
+
for (let i = actions.length - 1; i >= 0; i--) {
|
|
239
|
+
const a = actions[i];
|
|
240
|
+
if (a.type === "forward" || a.type === "reply") {
|
|
241
|
+
actions.splice(i, 1);
|
|
242
|
+
dropped++;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
if (dropped > 0) console.warn(`[bwf/email] setReject() after ${dropped} forward/reply call(s) — those actions were dropped. CF rejects are terminal: anything queued before setReject() never runs. Move the reject earlier in the handler.`);
|
|
246
|
+
const action = {
|
|
247
|
+
type: "reject",
|
|
248
|
+
reason: normalizeRejectReason(reason)
|
|
249
|
+
};
|
|
250
|
+
actions.push(action);
|
|
251
|
+
actionWireBytesUsed = EMAIL_ACTION_TERMINAL_BYTES + emailActionWireSize(action);
|
|
252
|
+
},
|
|
253
|
+
async forward(to, fwdHeaders) {
|
|
254
|
+
if (rejected) {
|
|
255
|
+
console.warn("[bwf/email] forward() called after setReject() — ignored. CF rejects are terminal: nothing else runs once setReject fires.");
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
assertQueueHasRoom();
|
|
259
|
+
if (to.length > 320) throw addressTooLong("to", to.length);
|
|
260
|
+
validateAddressParts("to", to);
|
|
261
|
+
let headersObj;
|
|
262
|
+
if (fwdHeaders instanceof Headers) headersObj = Object.fromEntries(fwdHeaders.entries());
|
|
263
|
+
else if (fwdHeaders) {
|
|
264
|
+
try {
|
|
265
|
+
new Headers(fwdHeaders);
|
|
266
|
+
} catch (e) {
|
|
267
|
+
throw invalidForwardHeaders(e);
|
|
268
|
+
}
|
|
269
|
+
headersObj = { ...fwdHeaders };
|
|
270
|
+
}
|
|
271
|
+
if (headersObj) assertForwardHeadersWithinBounds(headersObj);
|
|
272
|
+
const action = {
|
|
273
|
+
type: "forward",
|
|
274
|
+
to,
|
|
275
|
+
...headersObj ? { headers: headersObj } : {}
|
|
276
|
+
};
|
|
277
|
+
if (new TextEncoder().encode(JSON.stringify(action)).byteLength > MAX_ACTION_METADATA_BYTES) throw new MimeError("MIME_ERROR", `forward: action metadata exceeds ${MAX_ACTION_METADATA_BYTES} bytes.`);
|
|
278
|
+
recordAction(action);
|
|
279
|
+
},
|
|
280
|
+
async reply(reply) {
|
|
281
|
+
if (rejected) {
|
|
282
|
+
console.warn("[bwf/email] reply() called after setReject() — ignored. CF rejects are terminal: nothing else runs once setReject fires.");
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
assertQueueHasRoom();
|
|
286
|
+
if (reply.from.length > 320) throw addressTooLong("from", reply.from.length);
|
|
287
|
+
if (reply.to.length > 320) throw addressTooLong("to", reply.to.length);
|
|
288
|
+
validateAddressParts("from", reply.from);
|
|
289
|
+
validateAddressParts("to", reply.to);
|
|
290
|
+
pendingReplies++;
|
|
291
|
+
const previousReply = replyRecordingTail;
|
|
292
|
+
let releaseReply;
|
|
293
|
+
replyRecordingTail = new Promise((resolve) => {
|
|
294
|
+
releaseReply = resolve;
|
|
295
|
+
});
|
|
296
|
+
await previousReply;
|
|
297
|
+
try {
|
|
298
|
+
if (rejected) {
|
|
299
|
+
console.warn("[bwf/email] reply() completed after setReject() — ignored. CF rejects are terminal: nothing else runs once setReject fires.");
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
const replyFrameBytes = emailActionWireSize({
|
|
303
|
+
type: "reply",
|
|
304
|
+
from: reply.from,
|
|
305
|
+
to: reply.to,
|
|
306
|
+
raw: /* @__PURE__ */ new Uint8Array()
|
|
307
|
+
});
|
|
308
|
+
const remaining = EMAIL_MAX_RESPONSE_BYTES - actionWireBytesUsed - replyFrameBytes;
|
|
309
|
+
if (remaining < 0) throw replyBudgetExhausted(EMAIL_MAX_RESPONSE_BYTES - remaining);
|
|
310
|
+
let rawBytes;
|
|
311
|
+
if (reply.raw instanceof Uint8Array) {
|
|
312
|
+
if (reply.raw.byteLength > MAX_REPLY_BYTES) throw replyTooLarge(reply.raw.byteLength);
|
|
313
|
+
if (reply.raw.byteLength > remaining) throw replyBudgetExhausted(actionWireBytesUsed + replyFrameBytes + reply.raw.byteLength);
|
|
314
|
+
rawBytes = reply.raw;
|
|
315
|
+
} else {
|
|
316
|
+
const raw = reply.raw;
|
|
317
|
+
if (typeof raw !== "object" || raw === null || typeof raw.getReader !== "function") throw new MimeError("MIME_ERROR", "reply: expected { from, to, raw } with raw as a Uint8Array or ReadableStream. A native EmailMessage cannot be replayed from a bwf handler — its body has no public accessor. Use replyEmail() from bwf/email, or pass the MIME bytes as raw.");
|
|
318
|
+
const limit = Math.min(MAX_REPLY_BYTES, remaining);
|
|
319
|
+
rawBytes = await readStreamToBytes(reply.raw, limit, (total) => limit === MAX_REPLY_BYTES ? replyTooLarge(total) : replyBudgetExhausted(actionWireBytesUsed + replyFrameBytes + total));
|
|
320
|
+
}
|
|
321
|
+
if (!recordAction({
|
|
322
|
+
type: "reply",
|
|
323
|
+
from: reply.from,
|
|
324
|
+
to: reply.to,
|
|
325
|
+
raw: rawBytes
|
|
326
|
+
})) console.warn("[bwf/email] reply() completed after setReject() — ignored. CF rejects are terminal: nothing else runs once setReject fires.");
|
|
327
|
+
} finally {
|
|
328
|
+
pendingReplies--;
|
|
329
|
+
releaseReply();
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
};
|
|
333
|
+
if (envelope.to !== userVisibleTo) Object.defineProperty(message, "__nosamPlatformTo", {
|
|
334
|
+
value: envelope.to,
|
|
335
|
+
enumerable: false,
|
|
336
|
+
writable: false,
|
|
337
|
+
configurable: false
|
|
338
|
+
});
|
|
339
|
+
if (typeof envelope.viaDomain === "string" && envelope.viaDomain.length > 0) Object.defineProperty(message, "__nosamRelayDomain", {
|
|
340
|
+
value: envelope.viaDomain,
|
|
341
|
+
enumerable: false,
|
|
342
|
+
writable: false,
|
|
343
|
+
configurable: false
|
|
344
|
+
});
|
|
345
|
+
proxyRawCache.set(message, { read: readRawOnce });
|
|
346
|
+
return {
|
|
347
|
+
message,
|
|
348
|
+
getActions: () => [...actions]
|
|
349
|
+
};
|
|
350
|
+
}
|
|
351
|
+
/**
|
|
352
|
+
* Longest decoded inbound subject the default reply subject is built from;
|
|
353
|
+
* longer falls back to a bare `Re:`. Real subjects are far shorter, and the
|
|
354
|
+
* bound keeps the control-character replacement cheap.
|
|
355
|
+
*/
|
|
356
|
+
const MAX_REPLY_SUBJECT_CHARS = 4096;
|
|
357
|
+
function prefixReplySubject(original) {
|
|
358
|
+
const decoded = decodeRfc2047(original);
|
|
359
|
+
if (decoded.length > MAX_REPLY_SUBJECT_CHARS) return "Re:";
|
|
360
|
+
const cleaned = decoded.replace(/[\x00-\x1f\x7f]+/g, " ").replace(/ {2,}/g, " ").trim();
|
|
361
|
+
if (!cleaned) return "Re:";
|
|
362
|
+
const prefixed = /^re:/i.test(cleaned) ? cleaned : `Re: ${cleaned}`;
|
|
363
|
+
if (/^[\x20-\x7e]*$/.test(prefixed) && !fitsHeaderLine("Subject", prefixed)) return "Re:";
|
|
364
|
+
return prefixed;
|
|
365
|
+
}
|
|
366
|
+
/**
|
|
367
|
+
* Minimal RFC 2047 decoder for the reply subject: B and Q encoded-words,
|
|
368
|
+
* unknown charsets read as UTF-8, malformed input returned unchanged.
|
|
369
|
+
*/
|
|
370
|
+
function decodeRfc2047(value) {
|
|
371
|
+
if (!value.includes("=?")) return value;
|
|
372
|
+
try {
|
|
373
|
+
const parts = [];
|
|
374
|
+
let last = 0;
|
|
375
|
+
for (const m of value.matchAll(/=\?([\w-]+)\?([BbQq])\?([^?]*)\?=(?:\s+(?==\?))?/g)) {
|
|
376
|
+
const [match, charset, enc, payload] = m;
|
|
377
|
+
const bytes = enc.toUpperCase() === "B" ? base64ToBytes(payload) : quotedPrintableDecode(payload);
|
|
378
|
+
let decoder;
|
|
379
|
+
try {
|
|
380
|
+
decoder = new TextDecoder(charset || "utf-8", { fatal: false });
|
|
381
|
+
} catch {
|
|
382
|
+
decoder = new TextDecoder("utf-8", { fatal: false });
|
|
383
|
+
}
|
|
384
|
+
parts.push(value.slice(last, m.index), decoder.decode(bytes));
|
|
385
|
+
last = m.index + match.length;
|
|
386
|
+
}
|
|
387
|
+
parts.push(value.slice(last));
|
|
388
|
+
return parts.join("");
|
|
389
|
+
} catch {
|
|
390
|
+
return value;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
function quotedPrintableDecode(qp) {
|
|
394
|
+
const out = new Uint8Array(qp.length);
|
|
395
|
+
let kept = 0;
|
|
396
|
+
for (let i = 0; i < qp.length; i++) {
|
|
397
|
+
const ch = qp.charCodeAt(i);
|
|
398
|
+
if (ch === 95) out[kept++] = 32;
|
|
399
|
+
else if (ch === 61 && i + 2 < qp.length) {
|
|
400
|
+
const hex = qp.slice(i + 1, i + 3);
|
|
401
|
+
if (/^[0-9A-Fa-f]{2}$/.test(hex)) {
|
|
402
|
+
out[kept++] = parseInt(hex, 16);
|
|
403
|
+
i += 2;
|
|
404
|
+
} else out[kept++] = ch;
|
|
405
|
+
} else out[kept++] = ch;
|
|
406
|
+
}
|
|
407
|
+
return out.subarray(0, kept);
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Build the reply MIME for `replyEmail`: `Re:` subject and best-effort
|
|
411
|
+
* `In-Reply-To` / `References` threading from the inbound message.
|
|
412
|
+
*/
|
|
413
|
+
async function buildReplyMessage(message, opts) {
|
|
414
|
+
const headers = message.headers;
|
|
415
|
+
const originalSubject = headers.get("Subject") ?? "";
|
|
416
|
+
const originalMessageId = headers.get("Message-ID") ?? "";
|
|
417
|
+
const originalReferences = headers.get("References") ?? "";
|
|
418
|
+
let fromAddr;
|
|
419
|
+
if (opts.from !== void 0) fromAddr = opts.from;
|
|
420
|
+
else if (readRelayDomain(message) !== void 0) fromAddr = message.to;
|
|
421
|
+
else {
|
|
422
|
+
const slug = readProjectSlug();
|
|
423
|
+
if (slug) {
|
|
424
|
+
const domain = readEnvString("__NOSAM_EMAIL_DOMAIN");
|
|
425
|
+
if (!domain) throw new Error("replyEmail: 'from' is required when __NOSAM_PROJECT_SLUG is set but __NOSAM_EMAIL_DOMAIN is not. Set `from` explicitly, or deploy via bwf so the platform-injected __NOSAM_PROJECT_SLUG and __NOSAM_EMAIL_DOMAIN can default it to <slug>+noreply@<domain>.");
|
|
426
|
+
fromAddr = `${slug}+noreply@${domain}`;
|
|
427
|
+
} else if (readEnvString("__NOSAM_PROJECT_SLUG") !== void 0) throw new Error("replyEmail: 'from' is required — this project's slug cannot build a default reply sender (`<slug>+noreply@<domain>` must stay within the 64-octet local part, so the slug must be at most 56 characters). Set `from` explicitly.");
|
|
428
|
+
else fromAddr = message.to;
|
|
429
|
+
}
|
|
430
|
+
const toAddr = opts.to ?? message.from;
|
|
431
|
+
const subject = opts.subject ?? prefixReplySubject(originalSubject);
|
|
432
|
+
const threading = {};
|
|
433
|
+
const messageId = threadingId("In-Reply-To", originalMessageId);
|
|
434
|
+
if (messageId) threading.inReplyTo = messageId;
|
|
435
|
+
const references = replyReferences(originalReferences, messageId);
|
|
436
|
+
if (references) threading.references = references;
|
|
437
|
+
const normalized = await normalizeEmail({
|
|
438
|
+
from: fromAddr,
|
|
439
|
+
to: toAddr,
|
|
440
|
+
subject,
|
|
441
|
+
text: opts.text,
|
|
442
|
+
html: opts.html,
|
|
443
|
+
headers: opts.headers,
|
|
444
|
+
attachments: opts.attachments,
|
|
445
|
+
threading: threading.inReplyTo || threading.references ? threading : void 0
|
|
446
|
+
});
|
|
447
|
+
const { raw } = buildMime(normalized);
|
|
448
|
+
return {
|
|
449
|
+
from: normalized.from.email,
|
|
450
|
+
to: normalized.to[0].email,
|
|
451
|
+
raw,
|
|
452
|
+
subject
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Send a threading-aware reply to an inbound message. Builds the reply MIME
|
|
457
|
+
* (correct `In-Reply-To` / `References` / `Subject: Re: …`) and records a
|
|
458
|
+
* reply intent on the message proxy. Delivery follows handler completion and,
|
|
459
|
+
* on the platform, authoritative admission.
|
|
460
|
+
*
|
|
461
|
+
* The threading headers are best-effort, since the inbound values they are
|
|
462
|
+
* built from are remote-sender controlled: an id no header line can carry
|
|
463
|
+
* is dropped, and a `References` chain over 8 KiB keeps only its newest
|
|
464
|
+
* ids. The reply is sent either way.
|
|
465
|
+
*/
|
|
466
|
+
async function replyEmail(message, opts) {
|
|
467
|
+
const { from, to, raw } = await buildReplyMessage(message, opts);
|
|
468
|
+
await message.reply({
|
|
469
|
+
from,
|
|
470
|
+
to,
|
|
471
|
+
raw
|
|
472
|
+
});
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Recognize native email operations. This structural check is not an
|
|
476
|
+
* authentication boundary; managed entrypoints require receipt authentication.
|
|
477
|
+
*/
|
|
478
|
+
function isForwardableEmailMessage(value) {
|
|
479
|
+
if (typeof value !== "object" || value === null) return false;
|
|
480
|
+
const m = value;
|
|
481
|
+
return typeof m.setReject === "function" && typeof m.forward === "function" && typeof m.reply === "function";
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Replay recorded actions on a native message, in order. The proxy already
|
|
485
|
+
* made `setReject` terminal and validated the rest. `reply` needs a real
|
|
486
|
+
* `EmailMessage`, so `cloudflare:email` loads only when one was recorded.
|
|
487
|
+
*/
|
|
488
|
+
async function enactEmailActions(message, actions) {
|
|
489
|
+
const deadline = Date.now() + INBOUND_ACTION_BATCH_DEADLINE_MS;
|
|
490
|
+
const submit = async (run) => {
|
|
491
|
+
const remaining = Math.min(INBOUND_PROVIDER_DEADLINE_MS, deadline - Date.now());
|
|
492
|
+
if (remaining <= 0) throw new Error("email action batch deadline elapsed before provider submission");
|
|
493
|
+
return withTimeout(remaining, run, () => /* @__PURE__ */ new Error("email action provider timed out; outcome unknown, do not retry automatically"));
|
|
494
|
+
};
|
|
495
|
+
for (const action of actions) switch (action.type) {
|
|
496
|
+
case "reject":
|
|
497
|
+
message.setReject(action.reason);
|
|
498
|
+
break;
|
|
499
|
+
case "forward":
|
|
500
|
+
await submit(() => message.forward(action.to, action.headers ? new Headers(action.headers) : void 0));
|
|
501
|
+
break;
|
|
502
|
+
case "reply": {
|
|
503
|
+
const { EmailMessage } = await import("cloudflare:email");
|
|
504
|
+
await submit(() => message.reply(new EmailMessage(action.from, action.to, bytesToReadableStream(action.raw))));
|
|
505
|
+
break;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
export { createMessageProxy as a, isForwardableEmailMessage as c, readProjectSlug as d, replyEmail as f, bytesToReadableStream as i, parseEmail as l, MAX_INBOUND_HEADERS as n, defineEmail as o, tryGetRawRuntimeEnv as p, ParseEmailError as r, enactEmailActions as s, MAX_INBOUND_BYTES as t, readEnvString as u };
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { _ as HandlerInput, a as CloudContextVariables, c as QueueMessage, d as TypedQueueHandler, f as basicAuth, g as defineScheduled, h as defineQueue, i as CloudContext, l as QueueRetryOptions, m as defineMiddleware, n as BwfAssetRewriteError, o as CloudEnv, p as defineHandler, r as CloudBindings, s as QueueBatch, t as BasicAuthOptions, u as TypedHandler, v as ValidatorSlots } from "./handler-B_ocHStk.mjs";
|
|
2
|
+
import { i as AuthUser } from "./auth-BKsUmWbT.mjs";
|
|
3
|
+
import { t as QueueMap } from "./queues-Bc3FsBQT.mjs";
|
|
4
|
+
import { Plugin } from "vite";
|
|
5
|
+
import { convertToWranglerConfig } from "@cloudflare/config";
|
|
6
|
+
import { PluginConfig } from "@cloudflare/vite-plugin";
|
|
7
|
+
/** bwf keeps its Wrangler-shaped public options independently of the upstream plugin. */
|
|
8
|
+
type WorkerConfig = ReturnType<typeof convertToWranglerConfig>;
|
|
9
|
+
type AuxiliaryConfig = Partial<WorkerConfig> | ((config: WorkerConfig, context: {
|
|
10
|
+
entryWorkerConfig: WorkerConfig;
|
|
11
|
+
}) => Partial<WorkerConfig> | void);
|
|
12
|
+
type AuxiliaryWorkerConfig = ({
|
|
13
|
+
configPath: string;
|
|
14
|
+
config?: AuxiliaryConfig;
|
|
15
|
+
} | {
|
|
16
|
+
configPath?: string;
|
|
17
|
+
config: AuxiliaryConfig;
|
|
18
|
+
}) & {
|
|
19
|
+
viteEnvironment?: PluginConfig["viteEnvironment"];
|
|
20
|
+
devOnly?: boolean | (() => boolean);
|
|
21
|
+
};
|
|
22
|
+
type RouteEnvironment = "dev" | "prod";
|
|
23
|
+
/**
|
|
24
|
+
* Decide whether to inject the `bwf dev` email-inbox loopback var.
|
|
25
|
+
*
|
|
26
|
+
* The dev inbox buffer lives in the Vite dev server's Node process;
|
|
27
|
+
* `sendEmail` runs in workerd and reaches it by fetching the inbox capture
|
|
28
|
+
* endpoint through the worker's assets binding, which
|
|
29
|
+
* `@cloudflare/vite-plugin` wires straight into the dev server's middleware
|
|
30
|
+
* stack. The var carries that binding's NAME (`ASSETS` for a bwf app) and its
|
|
31
|
+
* presence is what arms the dev path at runtime — so it must never reach a
|
|
32
|
+
* production build's `wrangler.json`, exactly like the `__NOSAM_TOKEN`
|
|
33
|
+
* credential gate.
|
|
34
|
+
*
|
|
35
|
+
* Gated on `routeEnvironment`, not on `command`: `vite preview` also reports
|
|
36
|
+
* `command: 'serve'`, but it runs the BUILT worker whose assets binding is a
|
|
37
|
+
* real asset directory rather than a dev-server loopback. `routeEnvironment`
|
|
38
|
+
* is the existing `command === 'serve' && !isPreview` distinction.
|
|
39
|
+
*
|
|
40
|
+
* Without an assets binding there is no loopback, so injecting the var would
|
|
41
|
+
* only arm a path that must then fail; gate on it instead.
|
|
42
|
+
*/
|
|
43
|
+
export declare function shouldInjectEmailDevInboxVar(routeEnvironment: RouteEnvironment, needsEmail: boolean | undefined, assetsBinding: string | undefined): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Decide whether to inject a Workers AI binding into the built wrangler config.
|
|
46
|
+
*
|
|
47
|
+
* Builds use the production binding. During dev, a project explicitly saved
|
|
48
|
+
* with the direct Cloudflare destination uses Cloudflare's remote binding;
|
|
49
|
+
* managed and unsaved projects keep using the bwf HTTPS proxy.
|
|
50
|
+
*
|
|
51
|
+
* `!resolvedAi` is load-bearing: mergeBindings' return is defu-merged over the
|
|
52
|
+
* resolved root-wrangler config and wins, so skipping when the user already
|
|
53
|
+
* declared an `ai` binding avoids clobbering theirs. `!resultAi` is harmless
|
|
54
|
+
* defense-in-depth (nothing else in mergeBindings sets `result.ai`).
|
|
55
|
+
*/
|
|
56
|
+
export declare function shouldBindWorkersAi(command: string, needsAI: boolean, resolvedAi: unknown, resultAi: unknown, directCloudflareDev?: boolean): boolean;
|
|
57
|
+
/** Resolve the runtime Workers AI binding, preserving a root Wrangler declaration. */
|
|
58
|
+
export declare function resolveWorkersAiBindingName(resolvedAi: unknown, configuredName?: string): string;
|
|
59
|
+
/** Returns the Vite plugins that build and serve a bwf app on Cloudflare. */
|
|
60
|
+
export declare function bwfPlugin(options?: {
|
|
61
|
+
persistTo?: string;
|
|
62
|
+
auxiliaryWorkers?: Array<AuxiliaryWorkerConfig>;
|
|
63
|
+
}): Array<Plugin>;
|
|
64
|
+
export { type AuthUser, type BasicAuthOptions, BwfAssetRewriteError, type CloudBindings, type CloudContext, type CloudContextVariables, type CloudEnv, type HandlerInput, type QueueBatch, type QueueMap, type QueueMessage, type QueueRetryOptions, type TypedHandler, type TypedQueueHandler, type ValidatorSlots, basicAuth, defineHandler, defineMiddleware, defineQueue, defineScheduled };
|