@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,473 @@
|
|
|
1
|
+
import { i as getBwfAuthProviderSettingEnvNames, o as isBwfSocialAuthProvider, r as getBwfAuthProviderEnvNames } from "./providers-Cd3c7wi0.mjs";
|
|
2
|
+
import { i as authDependentRequests, r as SHARED_CACHE_HEADERS, t as isUnchangedStaticAsset } from "./static-asset-marker-mWMX2dLa.mjs";
|
|
3
|
+
import { t as authContext } from "./auth-DkvoW5hB.mjs";
|
|
4
|
+
import { randomBytes, scrypt, timingSafeEqual } from "node:crypto";
|
|
5
|
+
import { betterAuth } from "better-auth";
|
|
6
|
+
import { createAuthMiddleware } from "better-auth/api";
|
|
7
|
+
// src/runtime/better-auth-shared.ts
|
|
8
|
+
function resolveSecret(env, dev) {
|
|
9
|
+
const explicit = typeof env.BETTER_AUTH_SECRET === "string" && env.BETTER_AUTH_SECRET.length > 0 ? env.BETTER_AUTH_SECRET : void 0;
|
|
10
|
+
if (explicit) return explicit;
|
|
11
|
+
if (dev) return "nosam-dev-better-auth-secret-1234567890";
|
|
12
|
+
throw new Error("auth: Missing Better Auth secret. Set BETTER_AUTH_SECRET.");
|
|
13
|
+
}
|
|
14
|
+
function readEnvString(env, key) {
|
|
15
|
+
const value = env[key];
|
|
16
|
+
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
17
|
+
}
|
|
18
|
+
/** Local development uses `DATABASE_URL`; production uses the Hyperdrive binding. */
|
|
19
|
+
function resolveConnectionString(env, database) {
|
|
20
|
+
const hyperdrive = env.HYPERDRIVE?.connectionString;
|
|
21
|
+
const connectionString = readEnvString(env, "DATABASE_URL") ?? (typeof hyperdrive === "string" && hyperdrive.length > 0 ? hyperdrive : void 0);
|
|
22
|
+
if (!connectionString) throw new Error(`auth: Better Auth requires DATABASE_URL for local ${database} dev or HYPERDRIVE in production.`);
|
|
23
|
+
return connectionString;
|
|
24
|
+
}
|
|
25
|
+
const PASSWORD_SALT_LENGTH = 16;
|
|
26
|
+
const SCRYPT_KEY_LENGTH = 64;
|
|
27
|
+
const SCRYPT_OPTIONS = {
|
|
28
|
+
N: 16384,
|
|
29
|
+
maxmem: 67108864,
|
|
30
|
+
p: 1,
|
|
31
|
+
r: 16
|
|
32
|
+
};
|
|
33
|
+
function derivePasswordKey(password, salt) {
|
|
34
|
+
return new Promise((resolve, reject) => {
|
|
35
|
+
scrypt(password.normalize("NFKC"), salt, SCRYPT_KEY_LENGTH, SCRYPT_OPTIONS, (error, key) => {
|
|
36
|
+
if (error) {
|
|
37
|
+
reject(error);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
resolve(key);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
const bwfAuthPassword = {
|
|
45
|
+
async hash(password) {
|
|
46
|
+
const salt = randomBytes(PASSWORD_SALT_LENGTH).toString("hex");
|
|
47
|
+
return `${salt}:${(await derivePasswordKey(password, salt)).toString("hex")}`;
|
|
48
|
+
},
|
|
49
|
+
async verify({ hash, password }) {
|
|
50
|
+
const [salt, key, ...extra] = hash.split(":");
|
|
51
|
+
if (!salt || !key || extra.length > 0) return false;
|
|
52
|
+
const storedKey = Buffer.from(key, "hex");
|
|
53
|
+
if (key.length !== 128 || storedKey.length !== SCRYPT_KEY_LENGTH) return false;
|
|
54
|
+
const targetKey = await derivePasswordKey(password, salt);
|
|
55
|
+
return timingSafeEqual(targetKey, storedKey);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
function resolveEmailAndPassword(configuredProviders) {
|
|
59
|
+
if (!configuredProviders || configuredProviders.includes("email")) return {
|
|
60
|
+
enabled: true,
|
|
61
|
+
password: bwfAuthPassword
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
function resolveSocialProviderCredentials(env, provider) {
|
|
65
|
+
const envNames = getBwfAuthProviderEnvNames(provider);
|
|
66
|
+
const clientId = readEnvString(env, envNames.clientId);
|
|
67
|
+
const clientSecret = readEnvString(env, envNames.clientSecret);
|
|
68
|
+
if (!clientId || !clientSecret) throw new Error(`auth: Missing credentials for provider '${provider}'. Set ${envNames.clientId} and ${envNames.clientSecret}, or remove '${provider}' from auth.providers.`);
|
|
69
|
+
const settings = {};
|
|
70
|
+
for (const [option, envName] of Object.entries(getBwfAuthProviderSettingEnvNames(provider))) {
|
|
71
|
+
const value = readEnvString(env, envName);
|
|
72
|
+
if (value) settings[option] = value;
|
|
73
|
+
}
|
|
74
|
+
return {
|
|
75
|
+
...settings,
|
|
76
|
+
clientId,
|
|
77
|
+
clientSecret
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
/** Fail early when a configured provider still lacks a required setting after auth.ts runs. */
|
|
81
|
+
function assertSocialProviderSettings(options, configuredProviders) {
|
|
82
|
+
const socialProviders = options.socialProviders;
|
|
83
|
+
for (const provider of configuredProviders ?? []) {
|
|
84
|
+
if (!isBwfSocialAuthProvider(provider)) continue;
|
|
85
|
+
const config = socialProviders?.[provider];
|
|
86
|
+
if (typeof config !== "object" || config === null) continue;
|
|
87
|
+
const values = config;
|
|
88
|
+
if (values.enabled === false) continue;
|
|
89
|
+
const missing = Object.entries(getBwfAuthProviderSettingEnvNames(provider)).filter(([option]) => !values[option]);
|
|
90
|
+
if (missing.length > 0) {
|
|
91
|
+
const options = joinNames(missing.map(([option]) => option));
|
|
92
|
+
throw new Error(`auth: Missing ${options} for the ${provider} provider. Set ${joinNames(missing.map(([, envName]) => envName))}, or set ${options} in auth.ts.`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/** `a`, `a and b`, `a, b and c`. */
|
|
97
|
+
function joinNames(names) {
|
|
98
|
+
return names.length > 1 ? `${names.slice(0, -1).join(", ")} and ${names.at(-1)}` : names[0];
|
|
99
|
+
}
|
|
100
|
+
function resolveSocialProviders(env, configuredProviders) {
|
|
101
|
+
if (!configuredProviders) return;
|
|
102
|
+
const providers = {};
|
|
103
|
+
for (const provider of configuredProviders) {
|
|
104
|
+
if (!isBwfSocialAuthProvider(provider)) continue;
|
|
105
|
+
providers[provider] = resolveSocialProviderCredentials(env, provider);
|
|
106
|
+
}
|
|
107
|
+
return Object.keys(providers).length > 0 ? providers : void 0;
|
|
108
|
+
}
|
|
109
|
+
function appendAuthHeaders(c, source, includeCachePolicy, staticAsset) {
|
|
110
|
+
if (!source) return;
|
|
111
|
+
if (staticAsset) {
|
|
112
|
+
source.forEach((value, key) => {
|
|
113
|
+
if (!["cache-control", "pragma"].includes(key.toLowerCase())) c.header(key, value, { append: key.toLowerCase() === "set-cookie" });
|
|
114
|
+
});
|
|
115
|
+
if (includeCachePolicy) {
|
|
116
|
+
c.header("Cache-Control", source.has("set-cookie") ? "private, no-store" : privateCachePolicy(c.res.headers.get("cache-control")));
|
|
117
|
+
dropSharedCachePolicy(c);
|
|
118
|
+
}
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const routeDirectives = bareCacheDirectives(c.res.headers.get("cache-control"));
|
|
122
|
+
const keepRoutePolicy = routeDirectives.has("no-store") || routeDirectives.has("private") && routeDirectives.has("no-cache");
|
|
123
|
+
source.forEach((value, key) => {
|
|
124
|
+
if ((!includeCachePolicy || keepRoutePolicy) && ["cache-control", "pragma"].includes(key.toLowerCase())) return;
|
|
125
|
+
c.header(key, value, { append: key.toLowerCase() === "set-cookie" });
|
|
126
|
+
});
|
|
127
|
+
const sessionDirectives = bareCacheDirectives(source.get("cache-control"));
|
|
128
|
+
if (source.has("set-cookie") && !keepRoutePolicy && ![
|
|
129
|
+
"private",
|
|
130
|
+
"no-store",
|
|
131
|
+
"no-cache"
|
|
132
|
+
].some((directive) => sessionDirectives.has(directive))) c.header("Cache-Control", "private, no-store");
|
|
133
|
+
if (includeCachePolicy || source.has("set-cookie")) dropSharedCachePolicy(c);
|
|
134
|
+
}
|
|
135
|
+
function dropSharedCachePolicy(c) {
|
|
136
|
+
for (const name of SHARED_CACHE_HEADERS) if (c.res.headers.has(name)) c.header(name, void 0);
|
|
137
|
+
}
|
|
138
|
+
function bareCacheDirectives(policy) {
|
|
139
|
+
const directives = (policy ?? "").match(/(?:[^",]|"(?:[^"\\]|\\.)*"?)+/g) ?? [];
|
|
140
|
+
return new Set(directives.map((directive) => directive.trim().toLowerCase()).filter((directive) => !directive.includes("=")));
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The same policy for one browser only: `public`, `proxy-revalidate`,
|
|
144
|
+
* `s-maxage` and a field-scoped `private` give way to a leading `private`.
|
|
145
|
+
* A policy that is already private or no-store stays as it is.
|
|
146
|
+
*/
|
|
147
|
+
/**
|
|
148
|
+
* True when the response sets a Better Auth cookie, such as the session from a
|
|
149
|
+
* sign-in reached through a rewrite or fallback. A cookie the app sets itself
|
|
150
|
+
* keeps the route's own cache policy.
|
|
151
|
+
*/
|
|
152
|
+
function setsAuthCookie(headers, advanced) {
|
|
153
|
+
const prefix = `${advanced?.cookiePrefix || "better-auth"}.`;
|
|
154
|
+
const custom = /* @__PURE__ */ new Set();
|
|
155
|
+
for (const cookie of Object.values(advanced?.cookies ?? {})) if (cookie?.name) custom.add(cookie.name);
|
|
156
|
+
return headers.getSetCookie().some((value) => {
|
|
157
|
+
let name = cookieName(value);
|
|
158
|
+
for (const secure of ["__Secure-", "__Host-"]) if (name.startsWith(secure)) name = name.slice(secure.length);
|
|
159
|
+
return name.startsWith(prefix) || custom.has(name);
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
function privateCachePolicy(policy) {
|
|
163
|
+
const directives = splitCacheDirectives(policy ?? "");
|
|
164
|
+
if (directives.length === 0) return "private, no-store";
|
|
165
|
+
const lowered = directives.map((directive) => directive.toLowerCase());
|
|
166
|
+
if (lowered.includes("private") || lowered.includes("no-store")) return policy;
|
|
167
|
+
return ["private", ...directives.filter((_directive, index) => {
|
|
168
|
+
const directive = lowered[index];
|
|
169
|
+
const equals = directive.indexOf("=");
|
|
170
|
+
const name = (equals === -1 ? directive : directive.slice(0, equals)).trim();
|
|
171
|
+
return ![
|
|
172
|
+
"public",
|
|
173
|
+
"proxy-revalidate",
|
|
174
|
+
"s-maxage",
|
|
175
|
+
"private"
|
|
176
|
+
].includes(name);
|
|
177
|
+
})].join(", ");
|
|
178
|
+
}
|
|
179
|
+
function splitCacheDirectives(policy) {
|
|
180
|
+
const directives = [];
|
|
181
|
+
let start = 0;
|
|
182
|
+
let quoted = false;
|
|
183
|
+
for (let index = 0; index < policy.length; index++) {
|
|
184
|
+
const char = policy[index];
|
|
185
|
+
if (quoted && char === "\\") index++;
|
|
186
|
+
else if (char === "\"") quoted = !quoted;
|
|
187
|
+
else if (char === "," && !quoted) {
|
|
188
|
+
directives.push(policy.slice(start, index));
|
|
189
|
+
start = index + 1;
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
directives.push(policy.slice(start));
|
|
193
|
+
return directives.map((directive) => directive.trim()).filter(Boolean);
|
|
194
|
+
}
|
|
195
|
+
function resolveUserConfig(userConfig, defaults, request, env, dialect) {
|
|
196
|
+
const mergeEmailAndPasswordDefaults = (options) => {
|
|
197
|
+
if (!defaults.emailAndPassword?.password || !options.emailAndPassword) return options;
|
|
198
|
+
return {
|
|
199
|
+
...options,
|
|
200
|
+
emailAndPassword: {
|
|
201
|
+
...options.emailAndPassword,
|
|
202
|
+
password: options.emailAndPassword.password ?? defaults.emailAndPassword.password
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
};
|
|
206
|
+
if (!userConfig) return defaults;
|
|
207
|
+
if (typeof userConfig === "function") return mergeEmailAndPasswordDefaults(userConfig({
|
|
208
|
+
defaults,
|
|
209
|
+
request,
|
|
210
|
+
env,
|
|
211
|
+
dialect
|
|
212
|
+
}));
|
|
213
|
+
return mergeEmailAndPasswordDefaults({
|
|
214
|
+
...defaults,
|
|
215
|
+
...userConfig
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Collects cookies that `auth.api.*` calls set while a request runs. Router
|
|
220
|
+
* calls (`auth.handler`) return their cookies on their own response. Better
|
|
221
|
+
* Auth runs plugin `after` hooks in array order, so the plugin goes last to
|
|
222
|
+
* see cookies set by earlier hooks.
|
|
223
|
+
*/
|
|
224
|
+
function createCookieForwarder() {
|
|
225
|
+
let collecting = false;
|
|
226
|
+
const cookies = [];
|
|
227
|
+
return {
|
|
228
|
+
plugin: {
|
|
229
|
+
id: "nosam-cookies",
|
|
230
|
+
hooks: { after: [{
|
|
231
|
+
matcher: (ctx) => collecting && !("_flag" in ctx && ctx._flag === "router"),
|
|
232
|
+
handler: createAuthMiddleware(async (ctx) => {
|
|
233
|
+
const headers = ctx.context.responseHeaders;
|
|
234
|
+
if (headers instanceof Headers) cookies.push(...headers.getSetCookie());
|
|
235
|
+
})
|
|
236
|
+
}] }
|
|
237
|
+
},
|
|
238
|
+
start() {
|
|
239
|
+
collecting = true;
|
|
240
|
+
},
|
|
241
|
+
cookies: () => cookies
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function cookieName(cookie) {
|
|
245
|
+
const pair = cookie.split(";", 1)[0] ?? "";
|
|
246
|
+
const equals = pair.indexOf("=");
|
|
247
|
+
return (equals === -1 ? pair : pair.slice(0, equals)).trim();
|
|
248
|
+
}
|
|
249
|
+
function cookieKey(cookie, defaultPath) {
|
|
250
|
+
let domain = "";
|
|
251
|
+
let path = defaultPath;
|
|
252
|
+
for (const attribute of cookie.split(";").slice(1)) {
|
|
253
|
+
const equals = attribute.indexOf("=");
|
|
254
|
+
const name = (equals === -1 ? attribute : attribute.slice(0, equals)).trim().toLowerCase();
|
|
255
|
+
const value = equals === -1 ? "" : attribute.slice(equals + 1).trim();
|
|
256
|
+
if (name === "domain") domain = value.replace(/^\./, "").toLowerCase();
|
|
257
|
+
else if (name === "path") path = value.startsWith("/") ? value : defaultPath;
|
|
258
|
+
}
|
|
259
|
+
return `${cookieName(cookie)};${domain};${path}`;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* The session lookup's headers with only the cookies the browser should still
|
|
263
|
+
* receive: the last one for each key. The lookup runs first, then the
|
|
264
|
+
* `auth.api.*` calls in order. A cookie the route sent itself, such as an
|
|
265
|
+
* `asResponse` result, keeps its place among those calls when it came from
|
|
266
|
+
* one; otherwise, as with an `/api/auth` response, it is the latest.
|
|
267
|
+
*/
|
|
268
|
+
function mergeAuthCookies(lookup, forwarded, sent, requestUrl) {
|
|
269
|
+
if (forwarded.length === 0 && !lookup?.has("set-cookie")) return lookup;
|
|
270
|
+
const requestPath = new URL(requestUrl).pathname;
|
|
271
|
+
const lastSlash = requestPath.lastIndexOf("/");
|
|
272
|
+
const defaultPath = lastSlash <= 0 ? "/" : requestPath.slice(0, lastSlash);
|
|
273
|
+
const latest = /* @__PURE__ */ new Map();
|
|
274
|
+
for (const cookie of lookup?.getSetCookie() ?? []) latest.set(cookieKey(cookie, defaultPath), {
|
|
275
|
+
cookie,
|
|
276
|
+
at: -1
|
|
277
|
+
});
|
|
278
|
+
forwarded.forEach((cookie, at) => latest.set(cookieKey(cookie, defaultPath), {
|
|
279
|
+
cookie,
|
|
280
|
+
at
|
|
281
|
+
}));
|
|
282
|
+
const sentByKey = new Map(sent.map((cookie) => [cookieKey(cookie, defaultPath), cookie]));
|
|
283
|
+
const headers = new Headers(lookup);
|
|
284
|
+
headers.delete("set-cookie");
|
|
285
|
+
for (const [key, { cookie, at }] of latest) {
|
|
286
|
+
const routeCookie = sentByKey.get(key);
|
|
287
|
+
const sentAt = routeCookie === void 0 ? -1 : forwarded.lastIndexOf(routeCookie);
|
|
288
|
+
if (routeCookie === void 0 || sentAt !== -1 && at > sentAt) headers.append("set-cookie", cookie);
|
|
289
|
+
}
|
|
290
|
+
return headers;
|
|
291
|
+
}
|
|
292
|
+
const SESSION_SAFE_METHODS = /* @__PURE__ */ new Set([
|
|
293
|
+
"GET",
|
|
294
|
+
"HEAD",
|
|
295
|
+
"OPTIONS"
|
|
296
|
+
]);
|
|
297
|
+
function isRequestOrigin(origin, requestUrl) {
|
|
298
|
+
try {
|
|
299
|
+
const from = new URL(origin);
|
|
300
|
+
const to = new URL(requestUrl);
|
|
301
|
+
return from.host === to.host && (from.protocol === to.protocol || from.protocol === "https:");
|
|
302
|
+
} catch {
|
|
303
|
+
return false;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Headers used to look up the signed-in session for app routes and WebSockets.
|
|
308
|
+
*
|
|
309
|
+
* The session cookie is SameSite=Lax, so a page on another origin of the same
|
|
310
|
+
* site (for example a sibling subdomain) can still send it with a WebSocket
|
|
311
|
+
* handshake or a POST that needs no CORS preflight. For those requests the
|
|
312
|
+
* cookie only counts when the Origin is the request origin or one Better Auth
|
|
313
|
+
* trusts, following Better Auth's own origin check for its endpoints. The
|
|
314
|
+
* request is not rejected; it is resolved without a user.
|
|
315
|
+
*/
|
|
316
|
+
async function sessionHeaders(request, auth) {
|
|
317
|
+
const headers = request.headers;
|
|
318
|
+
if (!headers.has("cookie") || await isTrustedRequestOrigin(request, auth)) return headers;
|
|
319
|
+
const withoutCookie = new Headers(headers);
|
|
320
|
+
withoutCookie.delete("cookie");
|
|
321
|
+
console.warn(`auth: Ignored the session cookie on a ${request.method} request from ${headers.get("origin")}. Add this origin to auth trustedOrigins if it should use the signed-in session.`);
|
|
322
|
+
return withoutCookie;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* True when the request may use and change the signed-in session: a safe
|
|
326
|
+
* method, or a request from its own origin or one Better Auth trusts.
|
|
327
|
+
*/
|
|
328
|
+
async function isTrustedRequestOrigin(request, auth) {
|
|
329
|
+
const headers = request.headers;
|
|
330
|
+
if (SESSION_SAFE_METHODS.has(request.method) && headers.get("upgrade")?.toLowerCase() !== "websocket") return true;
|
|
331
|
+
const origin = headers.get("origin");
|
|
332
|
+
if (!origin || isRequestOrigin(origin, request.url)) return true;
|
|
333
|
+
if (origin === "null" && headers.get("sec-fetch-site") === "same-origin") return true;
|
|
334
|
+
const advanced = auth.options.advanced;
|
|
335
|
+
if (advanced?.disableCSRFCheck === true || advanced?.disableOriginCheck === true && advanced.disableCSRFCheck === void 0) return true;
|
|
336
|
+
const context = await auth.$context;
|
|
337
|
+
if (context.isTrustedOrigin(origin, { allowRelativePaths: false })) return true;
|
|
338
|
+
const trustedOrigins = auth.options.trustedOrigins;
|
|
339
|
+
if (typeof trustedOrigins === "function") {
|
|
340
|
+
const requestOrigins = (await trustedOrigins(request)).filter((value) => Boolean(value));
|
|
341
|
+
if (context.isTrustedOrigin.call({ trustedOrigins: requestOrigins }, origin, { allowRelativePaths: false })) return true;
|
|
342
|
+
}
|
|
343
|
+
return false;
|
|
344
|
+
}
|
|
345
|
+
const LOOPBACK_IP = /^(127\.|::1$|::ffff:127\.)/;
|
|
346
|
+
/**
|
|
347
|
+
* The client IP set by Cloudflare's edge, or null outside a deployed Worker.
|
|
348
|
+
* `request.cf` keeps a client-supplied header from being trusted on Node, Bun
|
|
349
|
+
* or Deno, and local previews report a loopback address.
|
|
350
|
+
*/
|
|
351
|
+
function cloudflareClientIp(request) {
|
|
352
|
+
const cf = request.cf;
|
|
353
|
+
if (typeof cf !== "object" || cf === null) return null;
|
|
354
|
+
const ip = request.headers.get("cf-connecting-ip");
|
|
355
|
+
if (!ip || LOOPBACK_IP.test(ip)) return null;
|
|
356
|
+
return ip;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Better Auth enables rate limiting only when NODE_ENV is "production", which
|
|
360
|
+
* Workers never set. Turn it on for deployed Cloudflare requests and key it by
|
|
361
|
+
* Cloudflare's client IP header. Explicit user settings still win.
|
|
362
|
+
*/
|
|
363
|
+
function applyCloudflareRateLimitDefaults(options) {
|
|
364
|
+
return {
|
|
365
|
+
...options,
|
|
366
|
+
rateLimit: {
|
|
367
|
+
...options.rateLimit,
|
|
368
|
+
enabled: options.rateLimit?.enabled ?? true
|
|
369
|
+
},
|
|
370
|
+
advanced: {
|
|
371
|
+
...options.advanced,
|
|
372
|
+
ipAddress: options.advanced?.ipAddress ?? { ipAddressHeaders: ["cf-connecting-ip"] }
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
function createBwfAuthRuntime(dialect, applyMigrations) {
|
|
377
|
+
function assertDialect(received) {
|
|
378
|
+
if (received !== dialect) throw new Error(`auth: Runtime mismatch. Expected ${dialect}, received '${received}'.`);
|
|
379
|
+
}
|
|
380
|
+
async function resolveBwfAuthOptions(request, env, runtime, database) {
|
|
381
|
+
assertDialect(runtime.dialect);
|
|
382
|
+
const origin = new URL(request.url).origin;
|
|
383
|
+
const emailAndPassword = resolveEmailAndPassword(runtime.providers);
|
|
384
|
+
const socialProviders = resolveSocialProviders(env, runtime.providers);
|
|
385
|
+
const defaults = {
|
|
386
|
+
baseURL: origin,
|
|
387
|
+
basePath: "/api/auth",
|
|
388
|
+
secret: resolveSecret(env, runtime.dev === true),
|
|
389
|
+
database,
|
|
390
|
+
...emailAndPassword ? { emailAndPassword } : {},
|
|
391
|
+
...socialProviders ? { socialProviders } : {},
|
|
392
|
+
trustedOrigins: [origin]
|
|
393
|
+
};
|
|
394
|
+
const resolved = resolveUserConfig(runtime.userConfig, defaults, request, env, dialect);
|
|
395
|
+
assertSocialProviderSettings(resolved, runtime.providers);
|
|
396
|
+
return runtime.dev !== true && cloudflareClientIp(request) ? applyCloudflareRateLimitDefaults(resolved) : resolved;
|
|
397
|
+
}
|
|
398
|
+
async function createBwfAuth(request, env, runtime, database, plugins = []) {
|
|
399
|
+
const options = await resolveBwfAuthOptions(request, env, runtime, database);
|
|
400
|
+
if (plugins.length === 0) return betterAuth(options);
|
|
401
|
+
return betterAuth({
|
|
402
|
+
...options,
|
|
403
|
+
plugins: [...options.plugins ?? [], ...plugins]
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
async function resolveBwfAuthState(request, env, runtime, database) {
|
|
407
|
+
const auth = await createBwfAuth(request, env, runtime, database);
|
|
408
|
+
return (await auth.api.getSession({
|
|
409
|
+
headers: await sessionHeaders(request, auth),
|
|
410
|
+
asResponse: false,
|
|
411
|
+
returnHeaders: true
|
|
412
|
+
})).response ?? null;
|
|
413
|
+
}
|
|
414
|
+
async function runBwfAuthMiddleware(c, next, runtime, database) {
|
|
415
|
+
if (c.req.path.startsWith("/__")) {
|
|
416
|
+
c.set("user", null);
|
|
417
|
+
c.set("session", null);
|
|
418
|
+
return next();
|
|
419
|
+
}
|
|
420
|
+
const requestUrl = c.originalUrl?.()?.href ?? c.req.raw.url;
|
|
421
|
+
const forwarder = createCookieForwarder();
|
|
422
|
+
const auth = await createBwfAuth(c.req.raw, c.env, runtime, database, [forwarder.plugin]);
|
|
423
|
+
c.set("__nosamAuth", auth);
|
|
424
|
+
const result = await auth.api.getSession({
|
|
425
|
+
headers: await sessionHeaders(c.req.raw, auth),
|
|
426
|
+
asResponse: false,
|
|
427
|
+
returnHeaders: true
|
|
428
|
+
});
|
|
429
|
+
const state = result.response ?? null;
|
|
430
|
+
c.set("user", state?.user ?? null);
|
|
431
|
+
c.set("session", state?.session ?? null);
|
|
432
|
+
const authEndpoint = c.req.path === "/api/auth" || c.req.path.startsWith("/api/auth/");
|
|
433
|
+
if (authEndpoint) authDependentRequests.add(c.req.raw);
|
|
434
|
+
forwarder.start();
|
|
435
|
+
await authContext.run({
|
|
436
|
+
user: state?.user ?? null,
|
|
437
|
+
state
|
|
438
|
+
}, async () => {
|
|
439
|
+
await next();
|
|
440
|
+
});
|
|
441
|
+
let forwarded = forwarder.cookies();
|
|
442
|
+
if (forwarded.length > 0 && !await isTrustedRequestOrigin(c.req.raw, auth)) {
|
|
443
|
+
console.warn(`auth: Did not send cookies set by auth.api calls on a ${c.req.method} request from ${c.req.header("origin")}. Add this origin to auth trustedOrigins if it should change the session.`);
|
|
444
|
+
forwarded = [];
|
|
445
|
+
}
|
|
446
|
+
const headers = mergeAuthCookies(result.headers, forwarded, c.res.headers.getSetCookie(), requestUrl);
|
|
447
|
+
const credentialed = [
|
|
448
|
+
"cookie",
|
|
449
|
+
"authorization",
|
|
450
|
+
"cf-access-jwt-assertion"
|
|
451
|
+
].some((header) => c.req.raw.headers.has(header));
|
|
452
|
+
appendAuthHeaders(c, headers, state !== null || credentialed || headers?.has("set-cookie") === true || setsAuthCookie(c.res.headers, auth.options.advanced) || authEndpoint, isUnchangedStaticAsset(c));
|
|
453
|
+
}
|
|
454
|
+
async function handleBwfAuthRequest(c, runtime, database) {
|
|
455
|
+
const existingAuth = c.get("__nosamAuth");
|
|
456
|
+
if (existingAuth) return existingAuth.handler(c.req.raw);
|
|
457
|
+
return (await createBwfAuth(c.req.raw, c.env, runtime, database)).handler(c.req.raw);
|
|
458
|
+
}
|
|
459
|
+
async function runBwfAuthMigrations(env, runtime, migrationSchema) {
|
|
460
|
+
assertDialect(runtime.dialect);
|
|
461
|
+
assertDialect(migrationSchema.dialect);
|
|
462
|
+
await applyMigrations(env, migrationSchema);
|
|
463
|
+
}
|
|
464
|
+
return {
|
|
465
|
+
resolveBwfAuthOptions,
|
|
466
|
+
createBwfAuth,
|
|
467
|
+
resolveBwfAuthState,
|
|
468
|
+
runBwfAuthMiddleware,
|
|
469
|
+
handleBwfAuthRequest,
|
|
470
|
+
runBwfAuthMigrations
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
export { resolveConnectionString as n, createBwfAuthRuntime as t };
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { t as BwfAuthProvider } from "./providers-Df69hb_X.mjs";
|
|
2
|
+
import { a as BwfAuthConfig, r as AuthState } from "./auth-BKsUmWbT.mjs";
|
|
3
|
+
import { BetterAuthOptions, betterAuth } from "better-auth";
|
|
4
|
+
import { Context } from "hono";
|
|
5
|
+
import { DBFieldAttribute } from "better-auth/db";
|
|
6
|
+
type AuthIdStrategy = "serial" | "text" | "uuid";
|
|
7
|
+
type BwfAuthMigrationField = {
|
|
8
|
+
type: DBFieldAttribute["type"];
|
|
9
|
+
required: boolean;
|
|
10
|
+
unique: boolean;
|
|
11
|
+
index: boolean;
|
|
12
|
+
bigint: boolean;
|
|
13
|
+
unbounded?: boolean;
|
|
14
|
+
/** A fixed default of a required field. Adding the column fills rows that exist with it. */
|
|
15
|
+
defaultValue?: string | number | boolean;
|
|
16
|
+
references?: {
|
|
17
|
+
table: string;
|
|
18
|
+
field: string;
|
|
19
|
+
onDelete?: "no action" | "restrict" | "cascade" | "set null" | "set default";
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
type BwfAuthMigrationTable = {
|
|
23
|
+
name: string;
|
|
24
|
+
order: number;
|
|
25
|
+
fields: Record<string, BwfAuthMigrationField>;
|
|
26
|
+
};
|
|
27
|
+
type BwfAuthMigrationSchema = {
|
|
28
|
+
dialect: "sqlite" | "postgresql" | "mysql";
|
|
29
|
+
idStrategy: AuthIdStrategy;
|
|
30
|
+
tables: Array<BwfAuthMigrationTable>;
|
|
31
|
+
};
|
|
32
|
+
type BwfAuthDialect = "sqlite" | "postgresql" | "mysql";
|
|
33
|
+
type BwfAuthRuntimeOptions = {
|
|
34
|
+
dialect: BwfAuthDialect;
|
|
35
|
+
providers: Array<BwfAuthProvider> | null;
|
|
36
|
+
userConfig?: BwfAuthConfig;
|
|
37
|
+
dev?: boolean;
|
|
38
|
+
};
|
|
39
|
+
type BwfAuthEnv = Record<string, unknown> & {
|
|
40
|
+
DB?: D1Database;
|
|
41
|
+
DATABASE_URL?: string;
|
|
42
|
+
HYPERDRIVE?: {
|
|
43
|
+
connectionString?: string;
|
|
44
|
+
};
|
|
45
|
+
BETTER_AUTH_SECRET?: string;
|
|
46
|
+
};
|
|
47
|
+
type AuthDatabase = NonNullable<BetterAuthOptions["database"]>;
|
|
48
|
+
type BwfAuthRuntimeApi = {
|
|
49
|
+
resolveBwfAuthOptions(request: Request, env: BwfAuthEnv, runtime: BwfAuthRuntimeOptions, database: AuthDatabase): Promise<BetterAuthOptions>;
|
|
50
|
+
createBwfAuth(request: Request, env: BwfAuthEnv, runtime: BwfAuthRuntimeOptions, database: AuthDatabase): Promise<ReturnType<typeof betterAuth>>;
|
|
51
|
+
resolveBwfAuthState(request: Request, env: BwfAuthEnv, runtime: BwfAuthRuntimeOptions, database: AuthDatabase): Promise<AuthState | null>;
|
|
52
|
+
runBwfAuthMiddleware(c: Context, next: () => Promise<void>, runtime: BwfAuthRuntimeOptions, database: AuthDatabase): Promise<void>;
|
|
53
|
+
handleBwfAuthRequest(c: Context, runtime: BwfAuthRuntimeOptions, database: AuthDatabase): Promise<Response>;
|
|
54
|
+
runBwfAuthMigrations(env: BwfAuthEnv, runtime: BwfAuthRuntimeOptions, migrationSchema: BwfAuthMigrationSchema): Promise<void>;
|
|
55
|
+
};
|
|
56
|
+
export { BwfAuthRuntimeApi as n, BwfAuthRuntimeOptions as r, BwfAuthEnv as t };
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { H as outro, L as log } from "./dist-STQXl8ck.mjs";
|
|
2
|
+
import { c as getToken } from "./auth-xnkmpZUl.mjs";
|
|
3
|
+
import { n as PlatformApiError, r as PlatformClient } from "./client-D3D5RM5h.mjs";
|
|
4
|
+
import { f as import_picocolors, i as dim, m as printSuccess } from "./output-Bb34lF0w.mjs";
|
|
5
|
+
import { r as readProjectConfig } from "./project-CC7eN00D.mjs";
|
|
6
|
+
import { a as resolveProjectBySlug, t as getRequestedProjectSlug } from "./resolve-project-BCsAMDRA.mjs";
|
|
7
|
+
import { appendFileSync, writeFileSync } from "node:fs";
|
|
8
|
+
// src/cli/build-cmd.ts
|
|
9
|
+
const POLL_MS = 1e3;
|
|
10
|
+
const BUILD_LOG_DRAIN_TIMEOUT_MS = 12e4;
|
|
11
|
+
function isBuildLogComplete(page) {
|
|
12
|
+
if (!page.terminal) return false;
|
|
13
|
+
if (page.logsComplete === null) throw new Error("This platform cannot confirm that the final build logs were captured. Ask its administrator to upgrade the platform runtime, or read the retained logs without --follow.");
|
|
14
|
+
return page.logsComplete === true;
|
|
15
|
+
}
|
|
16
|
+
function sleep(ms) {
|
|
17
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Classifies a `getBuildLogs` failure during a follow/first-page fetch as fatal
|
|
21
|
+
* (surface + exit) vs transient (retry). A client error (4xx) is permanent —
|
|
22
|
+
* the build is gone, access was revoked, or the CLI is too old (426
|
|
23
|
+
* `cli_outdated`) — so retrying can't fix it; it is fatal, matching how the rest
|
|
24
|
+
* of the CLI surfaces 426 (see `deploy-errors.ts`, `github-cmd.ts`). The sole
|
|
25
|
+
* exception is 429 (rate limit), which IS transient. Everything else
|
|
26
|
+
* (5xx/timeout/DO-read blip) is transient and retried through.
|
|
27
|
+
*/
|
|
28
|
+
function isFatalFollowError(err) {
|
|
29
|
+
return err instanceof PlatformApiError && err.status >= 400 && err.status < 500 && err.status !== 429;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Pure follow-loop: repeatedly fetch pages since a cursor, write each new
|
|
33
|
+
* line, and stop when the terminal build confirms its final logs were captured. `fetchPage`,
|
|
34
|
+
* `write`, and `sleep` are injected so this is unit-testable. Returns the
|
|
35
|
+
* final status + terminal flag.
|
|
36
|
+
*
|
|
37
|
+
* A transient `fetchPage` failure (502/timeout/DO-read blip) must NOT kill the
|
|
38
|
+
* live tail: on catch we consult the injected `isFatal` — a fatal error
|
|
39
|
+
* (e.g. 401/403/404) rethrows, otherwise we call `onRetry` and retry from the
|
|
40
|
+
* SAME cursor on the next tick (no cursor advance, no write), so the tail
|
|
41
|
+
* survives blips instead of exiting the CLI.
|
|
42
|
+
*/
|
|
43
|
+
async function followBuildLogs(opts) {
|
|
44
|
+
let cursor = opts.since;
|
|
45
|
+
let status = opts.status;
|
|
46
|
+
let terminalSince = null;
|
|
47
|
+
const pollMs = opts.pollMs ?? POLL_MS;
|
|
48
|
+
for (;;) {
|
|
49
|
+
await opts.sleep(pollMs);
|
|
50
|
+
let pageResult;
|
|
51
|
+
try {
|
|
52
|
+
pageResult = await opts.fetchPage(cursor);
|
|
53
|
+
} catch (err) {
|
|
54
|
+
if (opts.isFatal?.(err)) throw err;
|
|
55
|
+
opts.onRetry?.(err);
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
for (const l of pageResult.lines) opts.write(l.line);
|
|
59
|
+
cursor = pageResult.lastSeq;
|
|
60
|
+
status = pageResult.status;
|
|
61
|
+
if (isBuildLogComplete(pageResult)) return {
|
|
62
|
+
status,
|
|
63
|
+
terminal: true
|
|
64
|
+
};
|
|
65
|
+
if (pageResult.terminal) {
|
|
66
|
+
const now = Date.now();
|
|
67
|
+
terminalSince ??= now;
|
|
68
|
+
if (now - terminalSince >= BUILD_LOG_DRAIN_TIMEOUT_MS) throw new Error("Build finished, but its log producer did not confirm completion. Retry the command to recover the final log tail.");
|
|
69
|
+
} else terminalSince = null;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async function runBuildCommand(root, args) {
|
|
73
|
+
if (args.subcommand === "logs") return runBuildLogsCommand(root, args);
|
|
74
|
+
}
|
|
75
|
+
async function runBuildLogsCommand(root, args) {
|
|
76
|
+
console.log();
|
|
77
|
+
const token = getToken(root);
|
|
78
|
+
if (!token) {
|
|
79
|
+
log.error("Not logged in. Run `bwf account login` first.");
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
const client = new PlatformClient(token, { root });
|
|
83
|
+
let projectId;
|
|
84
|
+
const requestedSlug = getRequestedProjectSlug({ projectSlug: args.projectName });
|
|
85
|
+
if (requestedSlug) {
|
|
86
|
+
const projects = await client.listProjects();
|
|
87
|
+
const resolved = resolveProjectBySlug(projects, requestedSlug);
|
|
88
|
+
if (!resolved) {
|
|
89
|
+
log.error(`build: No project found with slug '${requestedSlug}'.`);
|
|
90
|
+
process.exit(1);
|
|
91
|
+
}
|
|
92
|
+
projectId = resolved.projectId;
|
|
93
|
+
} else {
|
|
94
|
+
const linked = readProjectConfig(root);
|
|
95
|
+
if (!linked) {
|
|
96
|
+
log.error("build: No project specified. Pass a project with --project <slug>, set BWF_PROJECT, or link one with `bwf project link`.");
|
|
97
|
+
process.exit(1);
|
|
98
|
+
}
|
|
99
|
+
projectId = linked.projectId;
|
|
100
|
+
}
|
|
101
|
+
let buildId = args.buildId;
|
|
102
|
+
if (!buildId) {
|
|
103
|
+
const builds = await client.listBuilds(projectId, 1);
|
|
104
|
+
if (builds.length === 0) {
|
|
105
|
+
outro("No builds found. Push to your connected branch to trigger one.");
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
buildId = builds[0].id;
|
|
109
|
+
}
|
|
110
|
+
const write = args.output ? (line) => appendFileSync(args.output, `${line}\n`) : (line) => console.log(line);
|
|
111
|
+
const onRetry = (err) => log.warn(`build: transient error while following (${err instanceof Error ? err.message : String(err)}); retrying…`);
|
|
112
|
+
let first;
|
|
113
|
+
for (;;) try {
|
|
114
|
+
first = await client.getBuildLogs(projectId, buildId, 0);
|
|
115
|
+
break;
|
|
116
|
+
} catch (err) {
|
|
117
|
+
if (isFatalFollowError(err)) {
|
|
118
|
+
if (err instanceof PlatformApiError && err.status === 404) log.error(`build: Build '${buildId}' not found for this project.`);
|
|
119
|
+
else log.error(err instanceof Error ? err.message : String(err));
|
|
120
|
+
process.exit(1);
|
|
121
|
+
}
|
|
122
|
+
if (!args.follow) {
|
|
123
|
+
log.error(err instanceof Error ? err.message : String(err));
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
onRetry(err);
|
|
127
|
+
await sleep(POLL_MS);
|
|
128
|
+
}
|
|
129
|
+
if (first.external) {
|
|
130
|
+
log.message(`This build ran on GitHub Actions. View logs:\n${import_picocolors.default.blue(first.external)}`);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
if (args.output) writeFileSync(args.output, "");
|
|
134
|
+
for (const l of first.lines) write(l.line);
|
|
135
|
+
let status = first.status;
|
|
136
|
+
let terminal = first.terminal;
|
|
137
|
+
if (args.follow && !isBuildLogComplete(first)) ({status, terminal} = await followBuildLogs({
|
|
138
|
+
fetchPage: (since) => client.getBuildLogs(projectId, buildId, since),
|
|
139
|
+
write,
|
|
140
|
+
sleep,
|
|
141
|
+
since: first.lastSeq,
|
|
142
|
+
status,
|
|
143
|
+
isFatal: isFatalFollowError,
|
|
144
|
+
onRetry
|
|
145
|
+
}));
|
|
146
|
+
if (!terminal) {
|
|
147
|
+
outro(dim("Build still running — pass -f to follow."));
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
if (status === "complete") printSuccess("Build succeeded.");
|
|
151
|
+
else outro(dim(`Build ${status}.`));
|
|
152
|
+
}
|
|
153
|
+
export { runBuildCommand };
|