@xtandard/kit 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +71 -2
- package/bin/xtandard-kit.mjs +3 -0
- package/dist/base-path-BJugWLNO.cjs +42 -0
- package/dist/base-path-BJugWLNO.cjs.map +1 -0
- package/dist/base-path-CDb4In5E.mjs +31 -0
- package/dist/base-path-CDb4In5E.mjs.map +1 -0
- package/dist/basic-Qtriv0xS.mjs +176 -0
- package/dist/basic-Qtriv0xS.mjs.map +1 -0
- package/dist/basic-ZaO92-lB.cjs +199 -0
- package/dist/basic-ZaO92-lB.cjs.map +1 -0
- package/dist/bin.cjs +126 -0
- package/dist/bin.cjs.map +1 -0
- package/dist/bin.d.cts +20 -0
- package/dist/bin.d.mts +20 -0
- package/dist/bin.mjs +125 -0
- package/dist/bin.mjs.map +1 -0
- package/dist/cas-CuPSaXBV.cjs +23 -0
- package/dist/cas-CuPSaXBV.cjs.map +1 -0
- package/dist/cas-CzA-yECx.mjs +18 -0
- package/dist/cas-CzA-yECx.mjs.map +1 -0
- package/dist/chunk-DakpK96I.cjs +43 -0
- package/dist/contract-B3UPXXLx.d.cts +30 -0
- package/dist/contract-B3UPXXLx.d.mts +30 -0
- package/dist/contract-BDPNvjtp.d.mts +64 -0
- package/dist/contract-BEdfGTPs.mjs +85 -0
- package/dist/contract-BEdfGTPs.mjs.map +1 -0
- package/dist/contract-BIVzAn4f.d.cts +64 -0
- package/dist/contract-BvgtswLX.d.cts +75 -0
- package/dist/contract-BvgtswLX.d.mts +75 -0
- package/dist/contract-DUj9P3Vt.d.cts +72 -0
- package/dist/contract-DUj9P3Vt.d.mts +72 -0
- package/dist/contract-wAEMDmYG.cjs +132 -0
- package/dist/contract-wAEMDmYG.cjs.map +1 -0
- package/dist/drizzle-BElCHWri.d.mts +115 -0
- package/dist/drizzle-BXaQXCr0.cjs +232 -0
- package/dist/drizzle-BXaQXCr0.cjs.map +1 -0
- package/dist/drizzle-CEpahWQB.d.cts +115 -0
- package/dist/drizzle-DxnelsPT.mjs +197 -0
- package/dist/drizzle-DxnelsPT.mjs.map +1 -0
- package/dist/duration-7WpAK-xe.mjs +52 -0
- package/dist/duration-7WpAK-xe.mjs.map +1 -0
- package/dist/duration-DVA0Fzkx.cjs +63 -0
- package/dist/duration-DVA0Fzkx.cjs.map +1 -0
- package/dist/duration-FPwbmWIU.d.cts +35 -0
- package/dist/duration-FPwbmWIU.d.mts +35 -0
- package/dist/entry-adapters-bun.cjs +10 -0
- package/dist/entry-adapters-bun.cjs.map +1 -0
- package/dist/entry-adapters-bun.d.cts +10 -0
- package/dist/entry-adapters-bun.d.mts +10 -0
- package/dist/entry-adapters-bun.mjs +9 -0
- package/dist/entry-adapters-bun.mjs.map +1 -0
- package/dist/entry-adapters-elysia.cjs +54 -0
- package/dist/entry-adapters-elysia.cjs.map +1 -0
- package/dist/entry-adapters-elysia.d.cts +38 -0
- package/dist/entry-adapters-elysia.d.mts +38 -0
- package/dist/entry-adapters-elysia.mjs +53 -0
- package/dist/entry-adapters-elysia.mjs.map +1 -0
- package/dist/entry-adapters-express.cjs +27 -0
- package/dist/entry-adapters-express.cjs.map +1 -0
- package/dist/entry-adapters-express.d.cts +24 -0
- package/dist/entry-adapters-express.d.mts +24 -0
- package/dist/entry-adapters-express.mjs +26 -0
- package/dist/entry-adapters-express.mjs.map +1 -0
- package/dist/entry-adapters-hono.cjs +33 -0
- package/dist/entry-adapters-hono.cjs.map +1 -0
- package/dist/entry-adapters-hono.d.cts +36 -0
- package/dist/entry-adapters-hono.d.mts +36 -0
- package/dist/entry-adapters-hono.mjs +30 -0
- package/dist/entry-adapters-hono.mjs.map +1 -0
- package/dist/entry-adapters-next.cjs +19 -0
- package/dist/entry-adapters-next.cjs.map +1 -0
- package/dist/entry-adapters-next.d.cts +35 -0
- package/dist/entry-adapters-next.d.mts +35 -0
- package/dist/entry-adapters-next.mjs +18 -0
- package/dist/entry-adapters-next.mjs.map +1 -0
- package/dist/entry-adapters-node.cjs +7 -0
- package/dist/entry-adapters-node.d.cts +2 -0
- package/dist/entry-adapters-node.d.mts +2 -0
- package/dist/entry-adapters-node.mjs +2 -0
- package/dist/entry-auth-basic.cjs +5 -0
- package/dist/entry-auth-basic.d.cts +83 -0
- package/dist/entry-auth-basic.d.mts +83 -0
- package/dist/entry-auth-basic.mjs +2 -0
- package/dist/entry-auth-delegated.cjs +28 -0
- package/dist/entry-auth-delegated.cjs.map +1 -0
- package/dist/entry-auth-delegated.d.cts +36 -0
- package/dist/entry-auth-delegated.d.mts +36 -0
- package/dist/entry-auth-delegated.mjs +27 -0
- package/dist/entry-auth-delegated.mjs.map +1 -0
- package/dist/entry-auth-none.cjs +4 -0
- package/dist/entry-auth-none.d.cts +25 -0
- package/dist/entry-auth-none.d.mts +25 -0
- package/dist/entry-auth-none.mjs +2 -0
- package/dist/entry-auth.cjs +0 -0
- package/dist/entry-auth.d.cts +2 -0
- package/dist/entry-auth.d.mts +2 -0
- package/dist/entry-auth.mjs +1 -0
- package/dist/entry-authorization-delegated.cjs +27 -0
- package/dist/entry-authorization-delegated.cjs.map +1 -0
- package/dist/entry-authorization-delegated.d.cts +31 -0
- package/dist/entry-authorization-delegated.d.mts +31 -0
- package/dist/entry-authorization-delegated.mjs +26 -0
- package/dist/entry-authorization-delegated.mjs.map +1 -0
- package/dist/entry-authorization-none.cjs +3 -0
- package/dist/entry-authorization-none.d.cts +18 -0
- package/dist/entry-authorization-none.d.mts +18 -0
- package/dist/entry-authorization-none.mjs +2 -0
- package/dist/entry-authorization-roles.cjs +3 -0
- package/dist/entry-authorization-roles.d.cts +2 -0
- package/dist/entry-authorization-roles.d.mts +2 -0
- package/dist/entry-authorization-roles.mjs +2 -0
- package/dist/entry-authorization.cjs +35 -0
- package/dist/entry-authorization.cjs.map +1 -0
- package/dist/entry-authorization.d.cts +2 -0
- package/dist/entry-authorization.d.mts +2 -0
- package/dist/entry-authorization.mjs +34 -0
- package/dist/entry-authorization.mjs.map +1 -0
- package/dist/entry-build.cjs +481 -0
- package/dist/entry-build.cjs.map +1 -0
- package/dist/entry-build.d.cts +355 -0
- package/dist/entry-build.d.mts +355 -0
- package/dist/entry-build.mjs +460 -0
- package/dist/entry-build.mjs.map +1 -0
- package/dist/entry-cli.cjs +368 -0
- package/dist/entry-cli.cjs.map +1 -0
- package/dist/entry-cli.d.cts +275 -0
- package/dist/entry-cli.d.mts +275 -0
- package/dist/entry-cli.mjs +355 -0
- package/dist/entry-cli.mjs.map +1 -0
- package/dist/entry-drizzle-mysql.cjs +36 -0
- package/dist/entry-drizzle-mysql.cjs.map +1 -0
- package/dist/entry-drizzle-mysql.d.cts +55 -0
- package/dist/entry-drizzle-mysql.d.mts +55 -0
- package/dist/entry-drizzle-mysql.mjs +34 -0
- package/dist/entry-drizzle-mysql.mjs.map +1 -0
- package/dist/entry-drizzle-pg.cjs +38 -0
- package/dist/entry-drizzle-pg.cjs.map +1 -0
- package/dist/entry-drizzle-pg.d.cts +78 -0
- package/dist/entry-drizzle-pg.d.mts +78 -0
- package/dist/entry-drizzle-pg.mjs +36 -0
- package/dist/entry-drizzle-pg.mjs.map +1 -0
- package/dist/entry-drizzle-sqlite.cjs +20 -0
- package/dist/entry-drizzle-sqlite.cjs.map +1 -0
- package/dist/entry-drizzle-sqlite.d.cts +22 -0
- package/dist/entry-drizzle-sqlite.d.mts +22 -0
- package/dist/entry-drizzle-sqlite.mjs +19 -0
- package/dist/entry-drizzle-sqlite.mjs.map +1 -0
- package/dist/entry-hooks-log.cjs +32 -0
- package/dist/entry-hooks-log.cjs.map +1 -0
- package/dist/entry-hooks-log.d.cts +36 -0
- package/dist/entry-hooks-log.d.mts +36 -0
- package/dist/entry-hooks-log.mjs +31 -0
- package/dist/entry-hooks-log.mjs.map +1 -0
- package/dist/entry-hooks.cjs +10 -0
- package/dist/entry-hooks.d.cts +2 -0
- package/dist/entry-hooks.d.mts +2 -0
- package/dist/entry-hooks.mjs +2 -0
- package/dist/entry-server-router.cjs +235 -0
- package/dist/entry-server-router.cjs.map +1 -0
- package/dist/entry-server-router.d.cts +193 -0
- package/dist/entry-server-router.d.mts +193 -0
- package/dist/entry-server-router.mjs +228 -0
- package/dist/entry-server-router.mjs.map +1 -0
- package/dist/entry-server.cjs +344 -0
- package/dist/entry-server.cjs.map +1 -0
- package/dist/entry-server.d.cts +230 -0
- package/dist/entry-server.d.mts +230 -0
- package/dist/entry-server.mjs +322 -0
- package/dist/entry-server.mjs.map +1 -0
- package/dist/entry-site.cjs +1083 -0
- package/dist/entry-site.cjs.map +1 -0
- package/dist/entry-site.d.cts +336 -0
- package/dist/entry-site.d.mts +336 -0
- package/dist/entry-site.mjs +1060 -0
- package/dist/entry-site.mjs.map +1 -0
- package/dist/entry-storage-cloudflare-kv.cjs +51 -0
- package/dist/entry-storage-cloudflare-kv.cjs.map +1 -0
- package/dist/entry-storage-cloudflare-kv.d.cts +52 -0
- package/dist/entry-storage-cloudflare-kv.d.mts +52 -0
- package/dist/entry-storage-cloudflare-kv.mjs +50 -0
- package/dist/entry-storage-cloudflare-kv.mjs.map +1 -0
- package/dist/entry-storage-drizzle-internals.cjs +6 -0
- package/dist/entry-storage-drizzle-internals.d.cts +2 -0
- package/dist/entry-storage-drizzle-internals.d.mts +2 -0
- package/dist/entry-storage-drizzle-internals.mjs +2 -0
- package/dist/entry-storage-drizzle.cjs +4 -0
- package/dist/entry-storage-drizzle.d.cts +3 -0
- package/dist/entry-storage-drizzle.d.mts +3 -0
- package/dist/entry-storage-drizzle.mjs +2 -0
- package/dist/entry-storage-file.cjs +306 -0
- package/dist/entry-storage-file.cjs.map +1 -0
- package/dist/entry-storage-file.d.cts +76 -0
- package/dist/entry-storage-file.d.mts +76 -0
- package/dist/entry-storage-file.mjs +301 -0
- package/dist/entry-storage-file.mjs.map +1 -0
- package/dist/entry-storage-libsql-internals.cjs +7 -0
- package/dist/entry-storage-libsql-internals.d.cts +3 -0
- package/dist/entry-storage-libsql-internals.d.mts +3 -0
- package/dist/entry-storage-libsql-internals.mjs +3 -0
- package/dist/entry-storage-libsql.cjs +3 -0
- package/dist/entry-storage-libsql.d.cts +2 -0
- package/dist/entry-storage-libsql.d.mts +2 -0
- package/dist/entry-storage-libsql.mjs +2 -0
- package/dist/entry-storage-memory.cjs +78 -0
- package/dist/entry-storage-memory.cjs.map +1 -0
- package/dist/entry-storage-memory.d.cts +35 -0
- package/dist/entry-storage-memory.d.mts +35 -0
- package/dist/entry-storage-memory.mjs +77 -0
- package/dist/entry-storage-memory.mjs.map +1 -0
- package/dist/entry-storage-mongodb-internals.cjs +5 -0
- package/dist/entry-storage-mongodb-internals.d.cts +2 -0
- package/dist/entry-storage-mongodb-internals.d.mts +2 -0
- package/dist/entry-storage-mongodb-internals.mjs +2 -0
- package/dist/entry-storage-mongodb.cjs +3 -0
- package/dist/entry-storage-mongodb.d.cts +2 -0
- package/dist/entry-storage-mongodb.d.mts +2 -0
- package/dist/entry-storage-mongodb.mjs +2 -0
- package/dist/entry-storage-postgres-internals.cjs +6 -0
- package/dist/entry-storage-postgres-internals.d.cts +2 -0
- package/dist/entry-storage-postgres-internals.d.mts +2 -0
- package/dist/entry-storage-postgres-internals.mjs +2 -0
- package/dist/entry-storage-postgres.cjs +4 -0
- package/dist/entry-storage-postgres.d.cts +2 -0
- package/dist/entry-storage-postgres.d.mts +2 -0
- package/dist/entry-storage-postgres.mjs +2 -0
- package/dist/entry-storage-redis-internals.cjs +7 -0
- package/dist/entry-storage-redis-internals.d.cts +2 -0
- package/dist/entry-storage-redis-internals.d.mts +2 -0
- package/dist/entry-storage-redis-internals.mjs +2 -0
- package/dist/entry-storage-redis.cjs +4 -0
- package/dist/entry-storage-redis.d.cts +2 -0
- package/dist/entry-storage-redis.d.mts +2 -0
- package/dist/entry-storage-redis.mjs +2 -0
- package/dist/entry-storage-sqlite-internals.cjs +7 -0
- package/dist/entry-storage-sqlite-internals.d.cts +3 -0
- package/dist/entry-storage-sqlite-internals.d.mts +3 -0
- package/dist/entry-storage-sqlite-internals.mjs +3 -0
- package/dist/entry-storage-sqlite.cjs +3 -0
- package/dist/entry-storage-sqlite.d.cts +2 -0
- package/dist/entry-storage-sqlite.d.mts +2 -0
- package/dist/entry-storage-sqlite.mjs +2 -0
- package/dist/entry-storage-testing.cjs +801 -0
- package/dist/entry-storage-testing.cjs.map +1 -0
- package/dist/entry-storage-testing.d.cts +150 -0
- package/dist/entry-storage-testing.d.mts +150 -0
- package/dist/entry-storage-testing.mjs +790 -0
- package/dist/entry-storage-testing.mjs.map +1 -0
- package/dist/entry-storage-unstorage.cjs +78 -0
- package/dist/entry-storage-unstorage.cjs.map +1 -0
- package/dist/entry-storage-unstorage.d.cts +30 -0
- package/dist/entry-storage-unstorage.d.mts +30 -0
- package/dist/entry-storage-unstorage.mjs +77 -0
- package/dist/entry-storage-unstorage.mjs.map +1 -0
- package/dist/entry-storage.cjs +114 -0
- package/dist/entry-storage.cjs.map +1 -0
- package/dist/entry-storage.d.cts +152 -0
- package/dist/entry-storage.d.mts +152 -0
- package/dist/entry-storage.mjs +91 -0
- package/dist/entry-storage.mjs.map +1 -0
- package/dist/entry-testing.cjs +79 -0
- package/dist/entry-testing.cjs.map +1 -0
- package/dist/entry-testing.d.cts +55 -0
- package/dist/entry-testing.d.mts +55 -0
- package/dist/entry-testing.mjs +77 -0
- package/dist/entry-testing.mjs.map +1 -0
- package/dist/entry-tokens.cjs +4 -0
- package/dist/entry-tokens.d.cts +85 -0
- package/dist/entry-tokens.d.mts +85 -0
- package/dist/entry-tokens.mjs +2 -0
- package/dist/entry-ui-embed.cjs +131 -0
- package/dist/entry-ui-embed.cjs.map +1 -0
- package/dist/entry-ui-embed.d.cts +87 -0
- package/dist/entry-ui-embed.d.mts +87 -0
- package/dist/entry-ui-embed.mjs +127 -0
- package/dist/entry-ui-embed.mjs.map +1 -0
- package/dist/entry-ui.cjs +795 -0
- package/dist/entry-ui.cjs.map +1 -0
- package/dist/entry-ui.d.cts +574 -0
- package/dist/entry-ui.d.mts +574 -0
- package/dist/entry-ui.mjs +731 -0
- package/dist/entry-ui.mjs.map +1 -0
- package/dist/entry-util.cjs +145 -0
- package/dist/entry-util.cjs.map +1 -0
- package/dist/entry-util.d.cts +85 -0
- package/dist/entry-util.d.mts +85 -0
- package/dist/entry-util.mjs +130 -0
- package/dist/entry-util.mjs.map +1 -0
- package/dist/http-B_rTnLW9.cjs +235 -0
- package/dist/http-B_rTnLW9.cjs.map +1 -0
- package/dist/http-CxYM7kPT.d.mts +133 -0
- package/dist/http-DVdVI6kJ.mjs +164 -0
- package/dist/http-DVdVI6kJ.mjs.map +1 -0
- package/dist/http-XBVRk8uo.d.cts +133 -0
- package/dist/index.cjs +8 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +6 -0
- package/dist/index.d.mts +6 -0
- package/dist/index.mjs +7 -0
- package/dist/index.mjs.map +1 -0
- package/dist/json-CCyzstIm.d.cts +44 -0
- package/dist/json-CCyzstIm.d.mts +44 -0
- package/dist/json-CM7TwYQ7.cjs +92 -0
- package/dist/json-CM7TwYQ7.cjs.map +1 -0
- package/dist/json-CmM1M5Kz.mjs +63 -0
- package/dist/json-CmM1M5Kz.mjs.map +1 -0
- package/dist/keys-Bwubabk0.mjs +73 -0
- package/dist/keys-Bwubabk0.mjs.map +1 -0
- package/dist/keys-DQrwxDKI.cjs +126 -0
- package/dist/keys-DQrwxDKI.cjs.map +1 -0
- package/dist/kv-sqlite-B6iTLOx2.d.cts +20 -0
- package/dist/kv-sqlite-CHOdIMJ-.cjs +77 -0
- package/dist/kv-sqlite-CHOdIMJ-.cjs.map +1 -0
- package/dist/kv-sqlite-DIIPfflJ.mjs +66 -0
- package/dist/kv-sqlite-DIIPfflJ.mjs.map +1 -0
- package/dist/kv-sqlite-Tx4UedJs.d.mts +20 -0
- package/dist/libsql-0160BubR.d.mts +65 -0
- package/dist/libsql-BZmRZIqt.d.cts +65 -0
- package/dist/libsql-CiBfVtbS.cjs +103 -0
- package/dist/libsql-CiBfVtbS.cjs.map +1 -0
- package/dist/libsql-CkOjQINi.mjs +86 -0
- package/dist/libsql-CkOjQINi.mjs.map +1 -0
- package/dist/mongodb--Cuj7V_9.cjs +150 -0
- package/dist/mongodb--Cuj7V_9.cjs.map +1 -0
- package/dist/mongodb-DGtsolQ2.d.cts +61 -0
- package/dist/mongodb-JMizy4Wg.mjs +127 -0
- package/dist/mongodb-JMizy4Wg.mjs.map +1 -0
- package/dist/mongodb-xGEU5Gwz.d.mts +61 -0
- package/dist/node-B1Djcwfi.d.cts +57 -0
- package/dist/node-B1Djcwfi.d.mts +57 -0
- package/dist/node-BYjocCbU.mjs +167 -0
- package/dist/node-BYjocCbU.mjs.map +1 -0
- package/dist/node-DFFqYRk-.cjs +201 -0
- package/dist/node-DFFqYRk-.cjs.map +1 -0
- package/dist/none-BEY7Kc_-.mjs +33 -0
- package/dist/none-BEY7Kc_-.mjs.map +1 -0
- package/dist/none-BoQ6-30P.cjs +33 -0
- package/dist/none-BoQ6-30P.cjs.map +1 -0
- package/dist/none-CHwVkQL-.cjs +49 -0
- package/dist/none-CHwVkQL-.cjs.map +1 -0
- package/dist/none-yu3qC47E.mjs +23 -0
- package/dist/none-yu3qC47E.mjs.map +1 -0
- package/dist/peer-BIjBFzwQ.cjs +56 -0
- package/dist/peer-BIjBFzwQ.cjs.map +1 -0
- package/dist/peer-CTHMzOdn.mjs +40 -0
- package/dist/peer-CTHMzOdn.mjs.map +1 -0
- package/dist/portal-container-CJIcau3B.mjs +610 -0
- package/dist/portal-container-CJIcau3B.mjs.map +1 -0
- package/dist/portal-container-Ca1NxrLE.cjs +774 -0
- package/dist/portal-container-Ca1NxrLE.cjs.map +1 -0
- package/dist/postgres-BJzxKBk0.d.cts +72 -0
- package/dist/postgres-CA8_XcAE.cjs +164 -0
- package/dist/postgres-CA8_XcAE.cjs.map +1 -0
- package/dist/postgres-RfQMgAsj.d.mts +72 -0
- package/dist/postgres-aDiBmNzr.mjs +135 -0
- package/dist/postgres-aDiBmNzr.mjs.map +1 -0
- package/dist/redis-B2AS4xAQ.cjs +259 -0
- package/dist/redis-B2AS4xAQ.cjs.map +1 -0
- package/dist/redis-B362ofBw.d.cts +159 -0
- package/dist/redis-CahNAVTW.d.mts +159 -0
- package/dist/redis-hdoKymfG.mjs +218 -0
- package/dist/redis-hdoKymfG.mjs.map +1 -0
- package/dist/roles-7JPrQXZa.mjs +46 -0
- package/dist/roles-7JPrQXZa.mjs.map +1 -0
- package/dist/roles-B_8QqJ3j.cjs +56 -0
- package/dist/roles-B_8QqJ3j.cjs.map +1 -0
- package/dist/roles-DLISB4T3.d.mts +41 -0
- package/dist/roles-DQbbtUPW.d.cts +41 -0
- package/dist/rolldown-runtime-D7D4PA-g.mjs +13 -0
- package/dist/scope-css-BN3jf0ly.cjs +315 -0
- package/dist/scope-css-BN3jf0ly.cjs.map +1 -0
- package/dist/scope-css-BuJfRCsE.mjs +256 -0
- package/dist/scope-css-BuJfRCsE.mjs.map +1 -0
- package/dist/scoped-BRoE1W1x.cjs +175 -0
- package/dist/scoped-BRoE1W1x.cjs.map +1 -0
- package/dist/scoped-cFBbotCh.mjs +164 -0
- package/dist/scoped-cFBbotCh.mjs.map +1 -0
- package/dist/sqlite-B2g1JJz1.d.cts +47 -0
- package/dist/sqlite-BIPIlxfj.d.mts +47 -0
- package/dist/sqlite-BntoYaXZ.cjs +79 -0
- package/dist/sqlite-BntoYaXZ.cjs.map +1 -0
- package/dist/sqlite-DYJDcu7p.mjs +62 -0
- package/dist/sqlite-DYJDcu7p.mjs.map +1 -0
- package/dist/table-BrioFSra.d.cts +11 -0
- package/dist/table-BrioFSra.d.mts +11 -0
- package/dist/theme-context-DzZ1otaD.d.cts +270 -0
- package/dist/theme-context-J65pythD.d.mts +270 -0
- package/dist/ui/styles.css +239 -0
- package/dist/util-Dnj5T-yw.mjs +39 -0
- package/dist/util-Dnj5T-yw.mjs.map +1 -0
- package/dist/util-dAnTK9x-.cjs +74 -0
- package/dist/util-dAnTK9x-.cjs.map +1 -0
- package/dist/validation-B-atP968.mjs +191 -0
- package/dist/validation-B-atP968.mjs.map +1 -0
- package/dist/validation-BJifGoB2.d.mts +122 -0
- package/dist/validation-DLnzBVJr.cjs +258 -0
- package/dist/validation-DLnzBVJr.cjs.map +1 -0
- package/dist/validation-tfV2qhbD.d.cts +122 -0
- package/package.json +715 -4
- package/tsconfig/assets.d.ts +21 -0
- package/tsconfig/base.json +21 -0
- package/tsconfig/react.json +9 -0
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
//#region src/adapters/node.ts
|
|
3
|
+
var node_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
+
headersFrom: () => headersFrom,
|
|
5
|
+
requestUrl: () => requestUrl,
|
|
6
|
+
toNodeHandler: () => toNodeHandler,
|
|
7
|
+
toWebRequest: () => toWebRequest,
|
|
8
|
+
writeWebResponse: () => writeWebResponse
|
|
9
|
+
});
|
|
10
|
+
/** Copy Node headers into `Headers`, appending each value of a multi-value header. */
|
|
11
|
+
function headersFrom(req) {
|
|
12
|
+
const headers = new Headers();
|
|
13
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
14
|
+
if (value === void 0) continue;
|
|
15
|
+
if (Array.isArray(value)) for (const v of value) headers.append(key, v);
|
|
16
|
+
else headers.set(key, value);
|
|
17
|
+
}
|
|
18
|
+
return headers;
|
|
19
|
+
}
|
|
20
|
+
/** The absolute URL of a Node request; `originalUrl` keeps an Express mount prefix. */
|
|
21
|
+
function requestUrl(req, origin) {
|
|
22
|
+
const path = req.originalUrl ?? req.url ?? "/";
|
|
23
|
+
if (origin) return `${origin.replace(/\/$/, "")}${path}`;
|
|
24
|
+
const encrypted = req.socket?.encrypted === true;
|
|
25
|
+
return `${req.protocol || (encrypted ? "https" : "http")}://${req.headers.host ?? "localhost"}${path}`;
|
|
26
|
+
}
|
|
27
|
+
/** A body already consumed and parsed by middleware, re-serialised; `undefined` when there is none. */
|
|
28
|
+
function parsedBody(req) {
|
|
29
|
+
const body = req.body;
|
|
30
|
+
if (body === void 0 || body === null) return void 0;
|
|
31
|
+
if (typeof body === "string") return new TextEncoder().encode(body);
|
|
32
|
+
if (body instanceof Uint8Array) return new Uint8Array(body);
|
|
33
|
+
if (body instanceof ArrayBuffer) return new Uint8Array(body);
|
|
34
|
+
if (typeof body === "object" && Object.keys(body).length === 0 && !hasContent(req)) return;
|
|
35
|
+
const text = String(req.headers["content-type"] ?? "").includes("application/x-www-form-urlencoded") ? new URLSearchParams(body).toString() : JSON.stringify(body);
|
|
36
|
+
return new TextEncoder().encode(text);
|
|
37
|
+
}
|
|
38
|
+
const hasContent = (req) => Number(req.headers["content-length"] ?? 0) > 0 || req.headers["transfer-encoding"] !== void 0;
|
|
39
|
+
async function readAll(req) {
|
|
40
|
+
const chunks = [];
|
|
41
|
+
let size = 0;
|
|
42
|
+
for await (const chunk of req) {
|
|
43
|
+
const bytes = typeof chunk === "string" ? new TextEncoder().encode(chunk) : chunk;
|
|
44
|
+
chunks.push(bytes);
|
|
45
|
+
size += bytes.byteLength;
|
|
46
|
+
}
|
|
47
|
+
if (size === 0) return void 0;
|
|
48
|
+
const out = new Uint8Array(size);
|
|
49
|
+
let offset = 0;
|
|
50
|
+
for (const c of chunks) {
|
|
51
|
+
out.set(c, offset);
|
|
52
|
+
offset += c.byteLength;
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
/** A body stream that only pulls from `req` when someone reads it. */
|
|
57
|
+
function lazyStream(req) {
|
|
58
|
+
let iterator;
|
|
59
|
+
return new ReadableStream({
|
|
60
|
+
async pull(controller) {
|
|
61
|
+
iterator ??= req[Symbol.asyncIterator]();
|
|
62
|
+
const { value, done } = await iterator.next();
|
|
63
|
+
if (done) controller.close();
|
|
64
|
+
else controller.enqueue(typeof value === "string" ? new TextEncoder().encode(value) : new Uint8Array(value));
|
|
65
|
+
},
|
|
66
|
+
async cancel() {
|
|
67
|
+
await iterator?.return?.();
|
|
68
|
+
}
|
|
69
|
+
}, { highWaterMark: 0 });
|
|
70
|
+
}
|
|
71
|
+
/** Convert a Node (or Express) request into a web `Request`. */
|
|
72
|
+
async function toWebRequest(req, options = {}) {
|
|
73
|
+
const method = (req.method ?? "GET").toUpperCase();
|
|
74
|
+
const init = {
|
|
75
|
+
method,
|
|
76
|
+
headers: headersFrom(req)
|
|
77
|
+
};
|
|
78
|
+
if (method !== "GET" && method !== "HEAD") if (req.readableEnded || req.body !== void 0) {
|
|
79
|
+
const body = parsedBody(req);
|
|
80
|
+
if (body) init.body = body;
|
|
81
|
+
} else if (options.lazyBody) {
|
|
82
|
+
init.body = lazyStream(req);
|
|
83
|
+
init.duplex = "half";
|
|
84
|
+
} else {
|
|
85
|
+
const body = await readAll(req);
|
|
86
|
+
if (body) init.body = body;
|
|
87
|
+
}
|
|
88
|
+
if (init.body !== void 0 && !(init.body instanceof ReadableStream)) {
|
|
89
|
+
init.headers.delete("content-length");
|
|
90
|
+
init.headers.delete("transfer-encoding");
|
|
91
|
+
}
|
|
92
|
+
return new Request(requestUrl(req, options.origin), init);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Write a web `Response` to a Node `ServerResponse`, streaming the body with
|
|
96
|
+
* backpressure. Stops reading (and cancels the body) when the client
|
|
97
|
+
* disconnects.
|
|
98
|
+
*/
|
|
99
|
+
async function writeWebResponse(res, response, request) {
|
|
100
|
+
res.statusCode = response.status;
|
|
101
|
+
if (response.statusText) res.statusMessage = response.statusText;
|
|
102
|
+
const cookies = response.headers.getSetCookie?.() ?? [];
|
|
103
|
+
response.headers.forEach((value, key) => {
|
|
104
|
+
if (key !== "set-cookie") res.setHeader(key, value);
|
|
105
|
+
});
|
|
106
|
+
if (cookies.length) res.setHeader("set-cookie", cookies);
|
|
107
|
+
else if (response.headers.has("set-cookie")) res.setHeader("set-cookie", response.headers.get("set-cookie"));
|
|
108
|
+
if (!response.body || (request?.method ?? "").toUpperCase() === "HEAD") {
|
|
109
|
+
await response.body?.cancel().catch(() => void 0);
|
|
110
|
+
res.end();
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const reader = response.body.getReader();
|
|
114
|
+
let closed = false;
|
|
115
|
+
const onClose = () => {
|
|
116
|
+
closed = true;
|
|
117
|
+
reader.cancel().catch(() => void 0);
|
|
118
|
+
};
|
|
119
|
+
res.once("close", onClose);
|
|
120
|
+
try {
|
|
121
|
+
for (;;) {
|
|
122
|
+
if (closed || res.destroyed) break;
|
|
123
|
+
const { value, done } = await reader.read();
|
|
124
|
+
if (done) break;
|
|
125
|
+
if (!res.write(value)) await new Promise((resolve) => {
|
|
126
|
+
const done = () => {
|
|
127
|
+
res.off("drain", done);
|
|
128
|
+
res.off("close", done);
|
|
129
|
+
resolve();
|
|
130
|
+
};
|
|
131
|
+
res.once("drain", done);
|
|
132
|
+
res.once("close", done);
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
if (!closed && !res.destroyed) res.end();
|
|
136
|
+
} finally {
|
|
137
|
+
res.off("close", onClose);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Wrap a fetch handler as a `node:http` request listener.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* import { createServer } from "node:http";
|
|
146
|
+
* createServer(toNodeHandler(panel.fetch)).listen(3000);
|
|
147
|
+
* ```
|
|
148
|
+
*/
|
|
149
|
+
function toNodeHandler(fetch, options = {}) {
|
|
150
|
+
return (req, res) => {
|
|
151
|
+
(async () => {
|
|
152
|
+
const request = await toWebRequest(req, options);
|
|
153
|
+
await writeWebResponse(res, await fetch(request), request);
|
|
154
|
+
})().catch((error) => {
|
|
155
|
+
if (options.onError) return options.onError(error, req, res);
|
|
156
|
+
if (!res.headersSent) {
|
|
157
|
+
res.statusCode = 500;
|
|
158
|
+
res.setHeader("content-type", "text/plain; charset=utf-8");
|
|
159
|
+
}
|
|
160
|
+
res.end(`Internal error: ${error instanceof Error ? error.message : String(error)}`);
|
|
161
|
+
});
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
//#endregion
|
|
165
|
+
export { toWebRequest as a, toNodeHandler as i, node_exports as n, writeWebResponse as o, requestUrl as r, headersFrom as t };
|
|
166
|
+
|
|
167
|
+
//# sourceMappingURL=node-BYjocCbU.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-BYjocCbU.mjs","names":[],"sources":["../src/adapters/node.ts"],"sourcesContent":["/**\n * The one Fetch ↔ Node bridge, shared by the Express adapter and the CLI's\n * Node server: it turns a `node:http` request into a web `Request` and writes\n * a web `Response` back.\n *\n * - Multi-value request headers are appended one by one (not joined).\n * - A body already parsed by middleware (`express.json()`, `express.text()`,\n * `express.raw()`, `express.urlencoded()`) is re-serialised; otherwise the\n * stream is read (or, with `lazyBody`, read only when the handler pulls it).\n * - Every `Set-Cookie` header is kept (`getSetCookie`), not collapsed into one.\n * - Response bodies are **streamed** with backpressure (`drain`), and the\n * reader is cancelled when the client goes away — SSE and exports work and\n * don't buffer in memory.\n *\n * No runtime import of `node:http`: only its types.\n *\n * @module\n */\n\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\n\n/** A web-standard fetch handler. */\nexport type FetchHandler = (request: Request) => Response | Promise<Response>;\n\n/** A Node request, possibly decorated by Express (`originalUrl`, `protocol`, `body`). */\nexport type NodeRequest = IncomingMessage & {\n originalUrl?: string;\n protocol?: string;\n body?: unknown;\n};\n\n/** Options for {@link toWebRequest}. */\nexport interface ToWebRequestOptions {\n /**\n * Stream the request body to the handler only when it reads it, instead of\n * buffering it first. Lets later middleware see an untouched stream when the\n * handler ignores the body. Default `false`.\n */\n lazyBody?: boolean;\n /** Override the origin (`https://example.com`); default: protocol + `Host` header. */\n origin?: string;\n}\n\n/** Copy Node headers into `Headers`, appending each value of a multi-value header. */\nexport function headersFrom(req: IncomingMessage): Headers {\n const headers = new Headers();\n for (const [key, value] of Object.entries(req.headers)) {\n if (value === undefined) continue;\n if (Array.isArray(value)) for (const v of value) headers.append(key, v);\n else headers.set(key, value);\n }\n return headers;\n}\n\n/** The absolute URL of a Node request; `originalUrl` keeps an Express mount prefix. */\nexport function requestUrl(req: NodeRequest, origin?: string): string {\n const path = req.originalUrl ?? req.url ?? \"/\";\n if (origin) return `${origin.replace(/\\/$/, \"\")}${path}`;\n const encrypted = (req.socket as { encrypted?: boolean } | undefined)?.encrypted === true;\n const protocol = req.protocol || (encrypted ? \"https\" : \"http\");\n return `${protocol}://${req.headers.host ?? \"localhost\"}${path}`;\n}\n\n/** A body already consumed and parsed by middleware, re-serialised; `undefined` when there is none. */\nfunction parsedBody(req: NodeRequest): Uint8Array | undefined {\n const body = req.body;\n if (body === undefined || body === null) return undefined;\n if (typeof body === \"string\") return new TextEncoder().encode(body);\n if (body instanceof Uint8Array) return new Uint8Array(body);\n if (body instanceof ArrayBuffer) return new Uint8Array(body);\n if (typeof body === \"object\" && Object.keys(body).length === 0 && !hasContent(req)) {\n return undefined; // express.json() sets `{}` when there was no body at all\n }\n const type = String(req.headers[\"content-type\"] ?? \"\");\n const text = type.includes(\"application/x-www-form-urlencoded\")\n ? new URLSearchParams(body as Record<string, string>).toString()\n : JSON.stringify(body);\n return new TextEncoder().encode(text);\n}\n\nconst hasContent = (req: IncomingMessage): boolean =>\n Number(req.headers[\"content-length\"] ?? 0) > 0 || req.headers[\"transfer-encoding\"] !== undefined;\n\nasync function readAll(req: IncomingMessage): Promise<Uint8Array | undefined> {\n const chunks: Uint8Array[] = [];\n let size = 0;\n for await (const chunk of req as AsyncIterable<Uint8Array | string>) {\n const bytes = typeof chunk === \"string\" ? new TextEncoder().encode(chunk) : chunk;\n chunks.push(bytes);\n size += bytes.byteLength;\n }\n if (size === 0) return undefined;\n const out = new Uint8Array(size);\n let offset = 0;\n for (const c of chunks) {\n out.set(c, offset);\n offset += c.byteLength;\n }\n return out;\n}\n\n/** A body stream that only pulls from `req` when someone reads it. */\nfunction lazyStream(req: IncomingMessage): ReadableStream<Uint8Array> {\n let iterator: AsyncIterator<Uint8Array | string> | undefined;\n return new ReadableStream<Uint8Array>(\n {\n async pull(controller) {\n iterator ??= (req as AsyncIterable<Uint8Array | string>)[Symbol.asyncIterator]();\n const { value, done } = await iterator.next();\n if (done) controller.close();\n else\n controller.enqueue(\n typeof value === \"string\" ? new TextEncoder().encode(value) : new Uint8Array(value),\n );\n },\n async cancel() {\n await iterator?.return?.();\n },\n },\n { highWaterMark: 0 },\n );\n}\n\n/** Convert a Node (or Express) request into a web `Request`. */\nexport async function toWebRequest(\n req: NodeRequest,\n options: ToWebRequestOptions = {},\n): Promise<Request> {\n const method = (req.method ?? \"GET\").toUpperCase();\n const init: RequestInit & { duplex?: \"half\" } = { method, headers: headersFrom(req) };\n if (method !== \"GET\" && method !== \"HEAD\") {\n if (req.readableEnded || req.body !== undefined) {\n const body = parsedBody(req);\n if (body) init.body = body as BodyInit;\n } else if (options.lazyBody) {\n init.body = lazyStream(req);\n init.duplex = \"half\";\n } else {\n const body = await readAll(req);\n if (body) init.body = body as BodyInit;\n }\n }\n if (init.body !== undefined && !(init.body instanceof ReadableStream)) {\n // The body was re-serialised: the original length no longer applies.\n (init.headers as Headers).delete(\"content-length\");\n (init.headers as Headers).delete(\"transfer-encoding\");\n }\n return new Request(requestUrl(req, options.origin), init);\n}\n\n/**\n * Write a web `Response` to a Node `ServerResponse`, streaming the body with\n * backpressure. Stops reading (and cancels the body) when the client\n * disconnects.\n */\nexport async function writeWebResponse(\n res: ServerResponse,\n response: Response,\n request?: { method?: string },\n): Promise<void> {\n res.statusCode = response.status;\n if (response.statusText) res.statusMessage = response.statusText;\n const cookies = response.headers.getSetCookie?.() ?? [];\n response.headers.forEach((value, key) => {\n if (key !== \"set-cookie\") res.setHeader(key, value);\n });\n if (cookies.length) res.setHeader(\"set-cookie\", cookies);\n else if (response.headers.has(\"set-cookie\")) {\n res.setHeader(\"set-cookie\", response.headers.get(\"set-cookie\") as string);\n }\n\n if (!response.body || (request?.method ?? \"\").toUpperCase() === \"HEAD\") {\n await response.body?.cancel().catch(() => undefined);\n res.end();\n return;\n }\n const reader = response.body.getReader();\n let closed = false;\n const onClose = () => {\n closed = true;\n void reader.cancel().catch(() => undefined);\n };\n res.once(\"close\", onClose);\n try {\n for (;;) {\n if (closed || res.destroyed) break;\n const { value, done } = await reader.read();\n if (done) break;\n if (!res.write(value)) {\n await new Promise<void>((resolve) => {\n const done = () => {\n res.off(\"drain\", done);\n res.off(\"close\", done);\n resolve();\n };\n res.once(\"drain\", done);\n res.once(\"close\", done);\n });\n }\n }\n if (!closed && !res.destroyed) res.end();\n } finally {\n res.off(\"close\", onClose);\n }\n}\n\n/** Options for {@link toNodeHandler}. */\nexport interface NodeHandlerOptions extends ToWebRequestOptions {\n /**\n * Called when the handler throws. Default: a plain `500` (when headers have\n * not been sent yet).\n */\n onError?: (error: unknown, req: IncomingMessage, res: ServerResponse) => void;\n}\n\n/**\n * Wrap a fetch handler as a `node:http` request listener.\n *\n * @example\n * ```ts\n * import { createServer } from \"node:http\";\n * createServer(toNodeHandler(panel.fetch)).listen(3000);\n * ```\n */\nexport function toNodeHandler(\n fetch: FetchHandler,\n options: NodeHandlerOptions = {},\n): (req: IncomingMessage, res: ServerResponse) => void {\n return (req, res) => {\n void (async () => {\n const request = await toWebRequest(req, options);\n await writeWebResponse(res, await fetch(request), request);\n })().catch((error: unknown) => {\n if (options.onError) return options.onError(error, req, res);\n if (!res.headersSent) {\n res.statusCode = 500;\n res.setHeader(\"content-type\", \"text/plain; charset=utf-8\");\n }\n res.end(`Internal error: ${error instanceof Error ? error.message : String(error)}`);\n });\n };\n}\n"],"mappings":";;;;;;;;;;AA4CA,SAAgB,YAAY,KAA+B;CACzD,MAAM,UAAU,IAAI,QAAQ;CAC5B,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,IAAI,OAAO,GAAG;EACtD,IAAI,UAAU,K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;AACF;;;;;;;;;;AAoBA,SAAgB,cACd,OACA,UAA8B,CAAC,GACsB;CACrD,QAAQ,KAAK,QAAQ;EACnB,CAAM,YAAY;GAChB,MAAM,UAAU,MAAM,aAAa,KAAK,OAAO;GAC/C,MAAM,iBAAiB,KAAK,MAAM,MAAM,OAAO,GAAG,OAAO;EAC3D,GAAG,EAAE,OAAO,UAAmB;GAC7B,IAAI,QAAQ,SAAS,OAAO,QAAQ,QAAQ,OAAO,KAAK,GAAG;GAC3D,IAAI,CAAC,IAAI,aAAa;IACpB,IAAI,aAAa;IACjB,IAAI,UAAU,gBAAgB,2BAA2B;GAC3D;GACA,IAAI,IAAI,mBAAmB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG;EACrF,CAAC;CACH;AACF"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
//#region src/adapters/node.ts
|
|
2
|
+
var node_exports = /* @__PURE__ */ require("./chunk-DakpK96I.cjs").__exportAll({
|
|
3
|
+
headersFrom: () => headersFrom,
|
|
4
|
+
requestUrl: () => requestUrl,
|
|
5
|
+
toNodeHandler: () => toNodeHandler,
|
|
6
|
+
toWebRequest: () => toWebRequest,
|
|
7
|
+
writeWebResponse: () => writeWebResponse
|
|
8
|
+
});
|
|
9
|
+
/** Copy Node headers into `Headers`, appending each value of a multi-value header. */
|
|
10
|
+
function headersFrom(req) {
|
|
11
|
+
const headers = new Headers();
|
|
12
|
+
for (const [key, value] of Object.entries(req.headers)) {
|
|
13
|
+
if (value === void 0) continue;
|
|
14
|
+
if (Array.isArray(value)) for (const v of value) headers.append(key, v);
|
|
15
|
+
else headers.set(key, value);
|
|
16
|
+
}
|
|
17
|
+
return headers;
|
|
18
|
+
}
|
|
19
|
+
/** The absolute URL of a Node request; `originalUrl` keeps an Express mount prefix. */
|
|
20
|
+
function requestUrl(req, origin) {
|
|
21
|
+
const path = req.originalUrl ?? req.url ?? "/";
|
|
22
|
+
if (origin) return `${origin.replace(/\/$/, "")}${path}`;
|
|
23
|
+
const encrypted = req.socket?.encrypted === true;
|
|
24
|
+
return `${req.protocol || (encrypted ? "https" : "http")}://${req.headers.host ?? "localhost"}${path}`;
|
|
25
|
+
}
|
|
26
|
+
/** A body already consumed and parsed by middleware, re-serialised; `undefined` when there is none. */
|
|
27
|
+
function parsedBody(req) {
|
|
28
|
+
const body = req.body;
|
|
29
|
+
if (body === void 0 || body === null) return void 0;
|
|
30
|
+
if (typeof body === "string") return new TextEncoder().encode(body);
|
|
31
|
+
if (body instanceof Uint8Array) return new Uint8Array(body);
|
|
32
|
+
if (body instanceof ArrayBuffer) return new Uint8Array(body);
|
|
33
|
+
if (typeof body === "object" && Object.keys(body).length === 0 && !hasContent(req)) return;
|
|
34
|
+
const text = String(req.headers["content-type"] ?? "").includes("application/x-www-form-urlencoded") ? new URLSearchParams(body).toString() : JSON.stringify(body);
|
|
35
|
+
return new TextEncoder().encode(text);
|
|
36
|
+
}
|
|
37
|
+
const hasContent = (req) => Number(req.headers["content-length"] ?? 0) > 0 || req.headers["transfer-encoding"] !== void 0;
|
|
38
|
+
async function readAll(req) {
|
|
39
|
+
const chunks = [];
|
|
40
|
+
let size = 0;
|
|
41
|
+
for await (const chunk of req) {
|
|
42
|
+
const bytes = typeof chunk === "string" ? new TextEncoder().encode(chunk) : chunk;
|
|
43
|
+
chunks.push(bytes);
|
|
44
|
+
size += bytes.byteLength;
|
|
45
|
+
}
|
|
46
|
+
if (size === 0) return void 0;
|
|
47
|
+
const out = new Uint8Array(size);
|
|
48
|
+
let offset = 0;
|
|
49
|
+
for (const c of chunks) {
|
|
50
|
+
out.set(c, offset);
|
|
51
|
+
offset += c.byteLength;
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
/** A body stream that only pulls from `req` when someone reads it. */
|
|
56
|
+
function lazyStream(req) {
|
|
57
|
+
let iterator;
|
|
58
|
+
return new ReadableStream({
|
|
59
|
+
async pull(controller) {
|
|
60
|
+
iterator ??= req[Symbol.asyncIterator]();
|
|
61
|
+
const { value, done } = await iterator.next();
|
|
62
|
+
if (done) controller.close();
|
|
63
|
+
else controller.enqueue(typeof value === "string" ? new TextEncoder().encode(value) : new Uint8Array(value));
|
|
64
|
+
},
|
|
65
|
+
async cancel() {
|
|
66
|
+
await iterator?.return?.();
|
|
67
|
+
}
|
|
68
|
+
}, { highWaterMark: 0 });
|
|
69
|
+
}
|
|
70
|
+
/** Convert a Node (or Express) request into a web `Request`. */
|
|
71
|
+
async function toWebRequest(req, options = {}) {
|
|
72
|
+
const method = (req.method ?? "GET").toUpperCase();
|
|
73
|
+
const init = {
|
|
74
|
+
method,
|
|
75
|
+
headers: headersFrom(req)
|
|
76
|
+
};
|
|
77
|
+
if (method !== "GET" && method !== "HEAD") if (req.readableEnded || req.body !== void 0) {
|
|
78
|
+
const body = parsedBody(req);
|
|
79
|
+
if (body) init.body = body;
|
|
80
|
+
} else if (options.lazyBody) {
|
|
81
|
+
init.body = lazyStream(req);
|
|
82
|
+
init.duplex = "half";
|
|
83
|
+
} else {
|
|
84
|
+
const body = await readAll(req);
|
|
85
|
+
if (body) init.body = body;
|
|
86
|
+
}
|
|
87
|
+
if (init.body !== void 0 && !(init.body instanceof ReadableStream)) {
|
|
88
|
+
init.headers.delete("content-length");
|
|
89
|
+
init.headers.delete("transfer-encoding");
|
|
90
|
+
}
|
|
91
|
+
return new Request(requestUrl(req, options.origin), init);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Write a web `Response` to a Node `ServerResponse`, streaming the body with
|
|
95
|
+
* backpressure. Stops reading (and cancels the body) when the client
|
|
96
|
+
* disconnects.
|
|
97
|
+
*/
|
|
98
|
+
async function writeWebResponse(res, response, request) {
|
|
99
|
+
res.statusCode = response.status;
|
|
100
|
+
if (response.statusText) res.statusMessage = response.statusText;
|
|
101
|
+
const cookies = response.headers.getSetCookie?.() ?? [];
|
|
102
|
+
response.headers.forEach((value, key) => {
|
|
103
|
+
if (key !== "set-cookie") res.setHeader(key, value);
|
|
104
|
+
});
|
|
105
|
+
if (cookies.length) res.setHeader("set-cookie", cookies);
|
|
106
|
+
else if (response.headers.has("set-cookie")) res.setHeader("set-cookie", response.headers.get("set-cookie"));
|
|
107
|
+
if (!response.body || (request?.method ?? "").toUpperCase() === "HEAD") {
|
|
108
|
+
await response.body?.cancel().catch(() => void 0);
|
|
109
|
+
res.end();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
const reader = response.body.getReader();
|
|
113
|
+
let closed = false;
|
|
114
|
+
const onClose = () => {
|
|
115
|
+
closed = true;
|
|
116
|
+
reader.cancel().catch(() => void 0);
|
|
117
|
+
};
|
|
118
|
+
res.once("close", onClose);
|
|
119
|
+
try {
|
|
120
|
+
for (;;) {
|
|
121
|
+
if (closed || res.destroyed) break;
|
|
122
|
+
const { value, done } = await reader.read();
|
|
123
|
+
if (done) break;
|
|
124
|
+
if (!res.write(value)) await new Promise((resolve) => {
|
|
125
|
+
const done = () => {
|
|
126
|
+
res.off("drain", done);
|
|
127
|
+
res.off("close", done);
|
|
128
|
+
resolve();
|
|
129
|
+
};
|
|
130
|
+
res.once("drain", done);
|
|
131
|
+
res.once("close", done);
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
if (!closed && !res.destroyed) res.end();
|
|
135
|
+
} finally {
|
|
136
|
+
res.off("close", onClose);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Wrap a fetch handler as a `node:http` request listener.
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```ts
|
|
144
|
+
* import { createServer } from "node:http";
|
|
145
|
+
* createServer(toNodeHandler(panel.fetch)).listen(3000);
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
function toNodeHandler(fetch, options = {}) {
|
|
149
|
+
return (req, res) => {
|
|
150
|
+
(async () => {
|
|
151
|
+
const request = await toWebRequest(req, options);
|
|
152
|
+
await writeWebResponse(res, await fetch(request), request);
|
|
153
|
+
})().catch((error) => {
|
|
154
|
+
if (options.onError) return options.onError(error, req, res);
|
|
155
|
+
if (!res.headersSent) {
|
|
156
|
+
res.statusCode = 500;
|
|
157
|
+
res.setHeader("content-type", "text/plain; charset=utf-8");
|
|
158
|
+
}
|
|
159
|
+
res.end(`Internal error: ${error instanceof Error ? error.message : String(error)}`);
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
//#endregion
|
|
164
|
+
Object.defineProperty(exports, "headersFrom", {
|
|
165
|
+
enumerable: true,
|
|
166
|
+
get: function() {
|
|
167
|
+
return headersFrom;
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
Object.defineProperty(exports, "node_exports", {
|
|
171
|
+
enumerable: true,
|
|
172
|
+
get: function() {
|
|
173
|
+
return node_exports;
|
|
174
|
+
}
|
|
175
|
+
});
|
|
176
|
+
Object.defineProperty(exports, "requestUrl", {
|
|
177
|
+
enumerable: true,
|
|
178
|
+
get: function() {
|
|
179
|
+
return requestUrl;
|
|
180
|
+
}
|
|
181
|
+
});
|
|
182
|
+
Object.defineProperty(exports, "toNodeHandler", {
|
|
183
|
+
enumerable: true,
|
|
184
|
+
get: function() {
|
|
185
|
+
return toNodeHandler;
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
Object.defineProperty(exports, "toWebRequest", {
|
|
189
|
+
enumerable: true,
|
|
190
|
+
get: function() {
|
|
191
|
+
return toWebRequest;
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
Object.defineProperty(exports, "writeWebResponse", {
|
|
195
|
+
enumerable: true,
|
|
196
|
+
get: function() {
|
|
197
|
+
return writeWebResponse;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
//# sourceMappingURL=node-DFFqYRk-.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node-DFFqYRk-.cjs","names":[],"sources":["../src/adapters/node.ts"],"sourcesContent":["/**\n * The one Fetch ↔ Node bridge, shared by the Express adapter and the CLI's\n * Node server: it turns a `node:http` request into a web `Request` and writes\n * a web `Response` back.\n *\n * - Multi-value request headers are appended one by one (not joined).\n * - A body already parsed by middleware (`express.json()`, `express.text()`,\n * `express.raw()`, `express.urlencoded()`) is re-serialised; otherwise the\n * stream is read (or, with `lazyBody`, read only when the handler pulls it).\n * - Every `Set-Cookie` header is kept (`getSetCookie`), not collapsed into one.\n * - Response bodies are **streamed** with backpressure (`drain`), and the\n * reader is cancelled when the client goes away — SSE and exports work and\n * don't buffer in memory.\n *\n * No runtime import of `node:http`: only its types.\n *\n * @module\n */\n\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\n\n/** A web-standard fetch handler. */\nexport type FetchHandler = (request: Request) => Response | Promise<Response>;\n\n/** A Node request, possibly decorated by Express (`originalUrl`, `protocol`, `body`). */\nexport type NodeRequest = IncomingMessage & {\n originalUrl?: string;\n protocol?: string;\n body?: unknown;\n};\n\n/** Options for {@link toWebRequest}. */\nexport interface ToWebRequestOptions {\n /**\n * Stream the request body to the handler only when it reads it, instead of\n * buffering it first. Lets later middleware see an untouched stream when the\n * handler ignores the body. Default `false`.\n */\n lazyBody?: boolean;\n /** Override the origin (`https://example.com`); default: protocol + `Host` header. */\n origin?: string;\n}\n\n/** Copy Node headers into `Headers`, appending each value of a multi-value header. */\nexport function headersFrom(req: IncomingMessage): Headers {\n const headers = new Headers();\n for (const [key, value] of Object.entries(req.headers)) {\n if (value === undefined) continue;\n if (Array.isArray(value)) for (const v of value) headers.append(key, v);\n else headers.set(key, value);\n }\n return headers;\n}\n\n/** The absolute URL of a Node request; `originalUrl` keeps an Express mount prefix. */\nexport function requestUrl(req: NodeRequest, origin?: string): string {\n const path = req.originalUrl ?? req.url ?? \"/\";\n if (origin) return `${origin.replace(/\\/$/, \"\")}${path}`;\n const encrypted = (req.socket as { encrypted?: boolean } | undefined)?.encrypted === true;\n const protocol = req.protocol || (encrypted ? \"https\" : \"http\");\n return `${protocol}://${req.headers.host ?? \"localhost\"}${path}`;\n}\n\n/** A body already consumed and parsed by middleware, re-serialised; `undefined` when there is none. */\nfunction parsedBody(req: NodeRequest): Uint8Array | undefined {\n const body = req.body;\n if (body === undefined || body === null) return undefined;\n if (typeof body === \"string\") return new TextEncoder().encode(body);\n if (body instanceof Uint8Array) return new Uint8Array(body);\n if (body instanceof ArrayBuffer) return new Uint8Array(body);\n if (typeof body === \"object\" && Object.keys(body).length === 0 && !hasContent(req)) {\n return undefined; // express.json() sets `{}` when there was no body at all\n }\n const type = String(req.headers[\"content-type\"] ?? \"\");\n const text = type.includes(\"application/x-www-form-urlencoded\")\n ? new URLSearchParams(body as Record<string, string>).toString()\n : JSON.stringify(body);\n return new TextEncoder().encode(text);\n}\n\nconst hasContent = (req: IncomingMessage): boolean =>\n Number(req.headers[\"content-length\"] ?? 0) > 0 || req.headers[\"transfer-encoding\"] !== undefined;\n\nasync function readAll(req: IncomingMessage): Promise<Uint8Array | undefined> {\n const chunks: Uint8Array[] = [];\n let size = 0;\n for await (const chunk of req as AsyncIterable<Uint8Array | string>) {\n const bytes = typeof chunk === \"string\" ? new TextEncoder().encode(chunk) : chunk;\n chunks.push(bytes);\n size += bytes.byteLength;\n }\n if (size === 0) return undefined;\n const out = new Uint8Array(size);\n let offset = 0;\n for (const c of chunks) {\n out.set(c, offset);\n offset += c.byteLength;\n }\n return out;\n}\n\n/** A body stream that only pulls from `req` when someone reads it. */\nfunction lazyStream(req: IncomingMessage): ReadableStream<Uint8Array> {\n let iterator: AsyncIterator<Uint8Array | string> | undefined;\n return new ReadableStream<Uint8Array>(\n {\n async pull(controller) {\n iterator ??= (req as AsyncIterable<Uint8Array | string>)[Symbol.asyncIterator]();\n const { value, done } = await iterator.next();\n if (done) controller.close();\n else\n controller.enqueue(\n typeof value === \"string\" ? new TextEncoder().encode(value) : new Uint8Array(value),\n );\n },\n async cancel() {\n await iterator?.return?.();\n },\n },\n { highWaterMark: 0 },\n );\n}\n\n/** Convert a Node (or Express) request into a web `Request`. */\nexport async function toWebRequest(\n req: NodeRequest,\n options: ToWebRequestOptions = {},\n): Promise<Request> {\n const method = (req.method ?? \"GET\").toUpperCase();\n const init: RequestInit & { duplex?: \"half\" } = { method, headers: headersFrom(req) };\n if (method !== \"GET\" && method !== \"HEAD\") {\n if (req.readableEnded || req.body !== undefined) {\n const body = parsedBody(req);\n if (body) init.body = body as BodyInit;\n } else if (options.lazyBody) {\n init.body = lazyStream(req);\n init.duplex = \"half\";\n } else {\n const body = await readAll(req);\n if (body) init.body = body as BodyInit;\n }\n }\n if (init.body !== undefined && !(init.body instanceof ReadableStream)) {\n // The body was re-serialised: the original length no longer applies.\n (init.headers as Headers).delete(\"content-length\");\n (init.headers as Headers).delete(\"transfer-encoding\");\n }\n return new Request(requestUrl(req, options.origin), init);\n}\n\n/**\n * Write a web `Response` to a Node `ServerResponse`, streaming the body with\n * backpressure. Stops reading (and cancels the body) when the client\n * disconnects.\n */\nexport async function writeWebResponse(\n res: ServerResponse,\n response: Response,\n request?: { method?: string },\n): Promise<void> {\n res.statusCode = response.status;\n if (response.statusText) res.statusMessage = response.statusText;\n const cookies = response.headers.getSetCookie?.() ?? [];\n response.headers.forEach((value, key) => {\n if (key !== \"set-cookie\") res.setHeader(key, value);\n });\n if (cookies.length) res.setHeader(\"set-cookie\", cookies);\n else if (response.headers.has(\"set-cookie\")) {\n res.setHeader(\"set-cookie\", response.headers.get(\"set-cookie\") as string);\n }\n\n if (!response.body || (request?.method ?? \"\").toUpperCase() === \"HEAD\") {\n await response.body?.cancel().catch(() => undefined);\n res.end();\n return;\n }\n const reader = response.body.getReader();\n let closed = false;\n const onClose = () => {\n closed = true;\n void reader.cancel().catch(() => undefined);\n };\n res.once(\"close\", onClose);\n try {\n for (;;) {\n if (closed || res.destroyed) break;\n const { value, done } = await reader.read();\n if (done) break;\n if (!res.write(value)) {\n await new Promise<void>((resolve) => {\n const done = () => {\n res.off(\"drain\", done);\n res.off(\"close\", done);\n resolve();\n };\n res.once(\"drain\", done);\n res.once(\"close\", done);\n });\n }\n }\n if (!closed && !res.destroyed) res.end();\n } finally {\n res.off(\"close\", onClose);\n }\n}\n\n/** Options for {@link toNodeHandler}. */\nexport interface NodeHandlerOptions extends ToWebRequestOptions {\n /**\n * Called when the handler throws. Default: a plain `500` (when headers have\n * not been sent yet).\n */\n onError?: (error: unknown, req: IncomingMessage, res: ServerResponse) => void;\n}\n\n/**\n * Wrap a fetch handler as a `node:http` request listener.\n *\n * @example\n * ```ts\n * import { createServer } from \"node:http\";\n * createServer(toNodeHandler(panel.fetch)).listen(3000);\n * ```\n */\nexport function toNodeHandler(\n fetch: FetchHandler,\n options: NodeHandlerOptions = {},\n): (req: IncomingMessage, res: ServerResponse) => void {\n return (req, res) => {\n void (async () => {\n const request = await toWebRequest(req, options);\n await writeWebResponse(res, await fetch(request), request);\n })().catch((error: unknown) => {\n if (options.onError) return options.onError(error, req, res);\n if (!res.headersSent) {\n res.statusCode = 500;\n res.setHeader(\"content-type\", \"text/plain; charset=utf-8\");\n }\n res.end(`Internal error: ${error instanceof Error ? error.message : String(error)}`);\n });\n };\n}\n"],"mappings":";;;;;;;;;AA4CA,SAAgB,YAAY,KAA+B;CACzD,MAAM,UAAU,IAAI,QAAQ;CAC5B,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,IAAI,OAAO,GAAG;EACtD,IAAI,UAAU,KAAA,GAAW;EACzB,IAAI,MAAM,QAAQ,KAAK,GAAG,KAAK,MAAM,KAAK,OAAO,QAAQ,OAAO,KAAK,CAAC;OACjE,QAAQ,IAAI,KAAK,KAAK;CAC7B;CACA,OAAO;AACT;;AAGA,SAAgB,WAAW,KAAkB,QAAyB;CACpE,MAAM,OAAO,IAAI,eAAe,IAAI,OAAO;CAC3C,IAAI,QAAQ,OAAO,GAAG,OAAO,QAAQ,OAAO,EAAE,IAAI;CAClD,MAAM,YAAa,IAAI,QAAgD,cAAc;CAErF,OAAO,GADU,IAAI,aAAa,YAAY,UAAU,QAC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AgB,2BAA2B;GAC3D;GACA,IAAI,IAAI,mBAAmB,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GAAG;EACrF,CAAC;CACH;AACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
//#region src/auth/none.ts
|
|
3
|
+
var none_exports = /* @__PURE__ */ __exportAll({
|
|
4
|
+
ANONYMOUS_PRINCIPAL: () => ANONYMOUS_PRINCIPAL,
|
|
5
|
+
noAuth: () => noAuth
|
|
6
|
+
});
|
|
7
|
+
/** The fixed principal returned by {@link noAuth}. */
|
|
8
|
+
const ANONYMOUS_PRINCIPAL = { id: "anonymous" };
|
|
9
|
+
/**
|
|
10
|
+
* Create an {@link AuthProvider} that performs no authentication and resolves
|
|
11
|
+
* every request to the shared {@link ANONYMOUS_PRINCIPAL}.
|
|
12
|
+
*
|
|
13
|
+
* Because it never returns `null`, the request is always "authenticated" — use
|
|
14
|
+
* an {@link AuthorizationProvider} to control what the anonymous principal may
|
|
15
|
+
* actually do.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { noAuth } from "@xtandard/kit/auth/none";
|
|
20
|
+
*
|
|
21
|
+
* const auth = noAuth();
|
|
22
|
+
* await auth.authenticate(request); // → { id: "anonymous" }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
function noAuth() {
|
|
26
|
+
return { async authenticate(_request) {
|
|
27
|
+
return ANONYMOUS_PRINCIPAL;
|
|
28
|
+
} };
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { noAuth as n, none_exports as r, ANONYMOUS_PRINCIPAL as t };
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=none-BEY7Kc_-.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"none-BEY7Kc_-.mjs","names":[],"sources":["../src/auth/none.ts"],"sourcesContent":["/**\n * The \"no authentication\" {@link AuthProvider}. Treats every request as a single\n * anonymous principal.\n *\n * This does **not** mean \"reject everyone\" — it means the server performs no\n * credential checks at all. A fixed `{ id: \"anonymous\" }` principal is returned\n * for every request so that downstream {@link AuthorizationProvider authorization}\n * can still run (and, for example, deny mutating actions in readonly mode).\n *\n * Suitable for embedded usage, local development, or deployments fronted by an\n * external auth layer (a gateway, mTLS, a VPN, etc.). Pair it with\n * `noAuthorization()` to allow everything, or with `rolesAuthorization()` to\n * still gate actions.\n *\n * @module\n */\n\nimport type { AuthProvider, Principal } from \"./contract.ts\";\n\n/** The fixed principal returned by {@link noAuth}. */\nexport const ANONYMOUS_PRINCIPAL: Principal = { id: \"anonymous\" };\n\n/**\n * Create an {@link AuthProvider} that performs no authentication and resolves\n * every request to the shared {@link ANONYMOUS_PRINCIPAL}.\n *\n * Because it never returns `null`, the request is always \"authenticated\" — use\n * an {@link AuthorizationProvider} to control what the anonymous principal may\n * actually do.\n *\n * @example\n * ```ts\n * import { noAuth } from \"@xtandard/kit/auth/none\";\n *\n * const auth = noAuth();\n * await auth.authenticate(request); // → { id: \"anonymous\" }\n * ```\n */\nexport function noAuth(): AuthProvider {\n return {\n async authenticate(_request: Request): Promise<Principal | null> {\n return ANONYMOUS_PRINCIPAL;\n },\n };\n}\n"],"mappings":";;;;;;;AAoBA,MAAa,sBAAiC,EAAE,IAAI,YAAY;;;;;;;;;;;;;;;;;AAkBhE,SAAgB,SAAuB;CACrC,OAAO,EACL,MAAM,aAAa,UAA8C;EAC/D,OAAO;CACT,EACF;AACF"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/authorization/none.ts
|
|
2
|
+
var none_exports = /* @__PURE__ */ require("./chunk-DakpK96I.cjs").__exportAll({ noAuthorization: () => noAuthorization });
|
|
3
|
+
/**
|
|
4
|
+
* Create an {@link AuthorizationProvider} that authorizes everything.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* import { noAuthorization } from "@xtandard/kit/authorization/none";
|
|
9
|
+
*
|
|
10
|
+
* const authz = noAuthorization();
|
|
11
|
+
* await authz.authorize(input); // → true, always
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
function noAuthorization() {
|
|
15
|
+
return { async authorize(_input) {
|
|
16
|
+
return true;
|
|
17
|
+
} };
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
Object.defineProperty(exports, "noAuthorization", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function() {
|
|
23
|
+
return noAuthorization;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "none_exports", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function() {
|
|
29
|
+
return none_exports;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
//# sourceMappingURL=none-BoQ6-30P.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"none-BoQ6-30P.cjs","names":[],"sources":["../src/authorization/none.ts"],"sourcesContent":["/**\n * The \"no authorization\" {@link AuthorizationProvider}. Every action is allowed.\n *\n * This grants unconditional access regardless of the principal (even `null`) or\n * the action/resource. It is the right choice for embedded usage and local\n * development where the admin API is not exposed to untrusted callers — commonly\n * paired with `noAuth()`.\n *\n * Do **not** use it for a network-exposed admin surface; reach for\n * `rolesAuthorization()` (or a delegated provider) instead.\n *\n * @module\n */\n\nimport type { AuthorizationProvider, AuthorizeInput } from \"./contract.ts\";\n\n/**\n * Create an {@link AuthorizationProvider} that authorizes everything.\n *\n * @example\n * ```ts\n * import { noAuthorization } from \"@xtandard/kit/authorization/none\";\n *\n * const authz = noAuthorization();\n * await authz.authorize(input); // → true, always\n * ```\n */\nexport function noAuthorization<\n Action extends string = string,\n Resource = unknown,\n>(): AuthorizationProvider<Action, Resource> {\n return {\n async authorize(_input: AuthorizeInput<Action, Resource>): Promise<boolean> {\n return true;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;AA2BA,SAAgB,kBAG6B;CAC3C,OAAO,EACL,MAAM,UAAU,QAA4D;EAC1E,OAAO;CACT,EACF;AACF"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
//#region src/auth/none.ts
|
|
2
|
+
var none_exports = /* @__PURE__ */ require("./chunk-DakpK96I.cjs").__exportAll({
|
|
3
|
+
ANONYMOUS_PRINCIPAL: () => ANONYMOUS_PRINCIPAL,
|
|
4
|
+
noAuth: () => noAuth
|
|
5
|
+
});
|
|
6
|
+
/** The fixed principal returned by {@link noAuth}. */
|
|
7
|
+
const ANONYMOUS_PRINCIPAL = { id: "anonymous" };
|
|
8
|
+
/**
|
|
9
|
+
* Create an {@link AuthProvider} that performs no authentication and resolves
|
|
10
|
+
* every request to the shared {@link ANONYMOUS_PRINCIPAL}.
|
|
11
|
+
*
|
|
12
|
+
* Because it never returns `null`, the request is always "authenticated" — use
|
|
13
|
+
* an {@link AuthorizationProvider} to control what the anonymous principal may
|
|
14
|
+
* actually do.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* import { noAuth } from "@xtandard/kit/auth/none";
|
|
19
|
+
*
|
|
20
|
+
* const auth = noAuth();
|
|
21
|
+
* await auth.authenticate(request); // → { id: "anonymous" }
|
|
22
|
+
* ```
|
|
23
|
+
*/
|
|
24
|
+
function noAuth() {
|
|
25
|
+
return { async authenticate(_request) {
|
|
26
|
+
return ANONYMOUS_PRINCIPAL;
|
|
27
|
+
} };
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
Object.defineProperty(exports, "ANONYMOUS_PRINCIPAL", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function() {
|
|
33
|
+
return ANONYMOUS_PRINCIPAL;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
Object.defineProperty(exports, "noAuth", {
|
|
37
|
+
enumerable: true,
|
|
38
|
+
get: function() {
|
|
39
|
+
return noAuth;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(exports, "none_exports", {
|
|
43
|
+
enumerable: true,
|
|
44
|
+
get: function() {
|
|
45
|
+
return none_exports;
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
//# sourceMappingURL=none-CHwVkQL-.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"none-CHwVkQL-.cjs","names":[],"sources":["../src/auth/none.ts"],"sourcesContent":["/**\n * The \"no authentication\" {@link AuthProvider}. Treats every request as a single\n * anonymous principal.\n *\n * This does **not** mean \"reject everyone\" — it means the server performs no\n * credential checks at all. A fixed `{ id: \"anonymous\" }` principal is returned\n * for every request so that downstream {@link AuthorizationProvider authorization}\n * can still run (and, for example, deny mutating actions in readonly mode).\n *\n * Suitable for embedded usage, local development, or deployments fronted by an\n * external auth layer (a gateway, mTLS, a VPN, etc.). Pair it with\n * `noAuthorization()` to allow everything, or with `rolesAuthorization()` to\n * still gate actions.\n *\n * @module\n */\n\nimport type { AuthProvider, Principal } from \"./contract.ts\";\n\n/** The fixed principal returned by {@link noAuth}. */\nexport const ANONYMOUS_PRINCIPAL: Principal = { id: \"anonymous\" };\n\n/**\n * Create an {@link AuthProvider} that performs no authentication and resolves\n * every request to the shared {@link ANONYMOUS_PRINCIPAL}.\n *\n * Because it never returns `null`, the request is always \"authenticated\" — use\n * an {@link AuthorizationProvider} to control what the anonymous principal may\n * actually do.\n *\n * @example\n * ```ts\n * import { noAuth } from \"@xtandard/kit/auth/none\";\n *\n * const auth = noAuth();\n * await auth.authenticate(request); // → { id: \"anonymous\" }\n * ```\n */\nexport function noAuth(): AuthProvider {\n return {\n async authenticate(_request: Request): Promise<Principal | null> {\n return ANONYMOUS_PRINCIPAL;\n },\n };\n}\n"],"mappings":";;;;;;AAoBA,MAAa,sBAAiC,EAAE,IAAI,YAAY;;;;;;;;;;;;;;;;;AAkBhE,SAAgB,SAAuB;CACrC,OAAO,EACL,MAAM,aAAa,UAA8C;EAC/D,OAAO;CACT,EACF;AACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
|
|
2
|
+
//#region src/authorization/none.ts
|
|
3
|
+
var none_exports = /* @__PURE__ */ __exportAll({ noAuthorization: () => noAuthorization });
|
|
4
|
+
/**
|
|
5
|
+
* Create an {@link AuthorizationProvider} that authorizes everything.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { noAuthorization } from "@xtandard/kit/authorization/none";
|
|
10
|
+
*
|
|
11
|
+
* const authz = noAuthorization();
|
|
12
|
+
* await authz.authorize(input); // → true, always
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
function noAuthorization() {
|
|
16
|
+
return { async authorize(_input) {
|
|
17
|
+
return true;
|
|
18
|
+
} };
|
|
19
|
+
}
|
|
20
|
+
//#endregion
|
|
21
|
+
export { none_exports as n, noAuthorization as t };
|
|
22
|
+
|
|
23
|
+
//# sourceMappingURL=none-yu3qC47E.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"none-yu3qC47E.mjs","names":[],"sources":["../src/authorization/none.ts"],"sourcesContent":["/**\n * The \"no authorization\" {@link AuthorizationProvider}. Every action is allowed.\n *\n * This grants unconditional access regardless of the principal (even `null`) or\n * the action/resource. It is the right choice for embedded usage and local\n * development where the admin API is not exposed to untrusted callers — commonly\n * paired with `noAuth()`.\n *\n * Do **not** use it for a network-exposed admin surface; reach for\n * `rolesAuthorization()` (or a delegated provider) instead.\n *\n * @module\n */\n\nimport type { AuthorizationProvider, AuthorizeInput } from \"./contract.ts\";\n\n/**\n * Create an {@link AuthorizationProvider} that authorizes everything.\n *\n * @example\n * ```ts\n * import { noAuthorization } from \"@xtandard/kit/authorization/none\";\n *\n * const authz = noAuthorization();\n * await authz.authorize(input); // → true, always\n * ```\n */\nexport function noAuthorization<\n Action extends string = string,\n Resource = unknown,\n>(): AuthorizationProvider<Action, Resource> {\n return {\n async authorize(_input: AuthorizeInput<Action, Resource>): Promise<boolean> {\n return true;\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;AA2BA,SAAgB,kBAG6B;CAC3C,OAAO,EACL,MAAM,UAAU,QAA4D;EAC1E,OAAO;CACT,EACF;AACF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
//#region src/internal/peer.ts
|
|
2
|
+
var peer_exports = /* @__PURE__ */ require("./chunk-DakpK96I.cjs").__exportAll({
|
|
3
|
+
importPeer: () => importPeer,
|
|
4
|
+
requirePeer: () => requirePeer
|
|
5
|
+
});
|
|
6
|
+
/**
|
|
7
|
+
* Optional-peer helpers shared by every subpath that needs a driver, framework or tool package.
|
|
8
|
+
*
|
|
9
|
+
* @module
|
|
10
|
+
*/
|
|
11
|
+
/**
|
|
12
|
+
* Throw a clear, actionable error for a missing optional peer. The message names the package to
|
|
13
|
+
* install (what the user needs) and the kit subpath that asked for it.
|
|
14
|
+
*/
|
|
15
|
+
function requirePeer(name, subpath) {
|
|
16
|
+
throw new Error(`${subpath} requires the optional peer "${name}". Install it with: bun add ${name} (or npm install ${name})`);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* `import(name)` an optional peer, turning a module-not-found error into {@link requirePeer}'s
|
|
20
|
+
* message. Other errors (a broken install, a throwing module) propagate unchanged.
|
|
21
|
+
*/
|
|
22
|
+
async function importPeer(name, subpath, load) {
|
|
23
|
+
try {
|
|
24
|
+
return await load();
|
|
25
|
+
} catch (error) {
|
|
26
|
+
if (isModuleNotFound(error, name)) requirePeer(name, subpath);
|
|
27
|
+
throw error;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function isModuleNotFound(error, name) {
|
|
31
|
+
if (!error || typeof error !== "object") return false;
|
|
32
|
+
const { code, message } = error;
|
|
33
|
+
if (code === "ERR_MODULE_NOT_FOUND" || code === "MODULE_NOT_FOUND") return true;
|
|
34
|
+
return typeof message === "string" && /cannot find (module|package)/i.test(message) && message.includes(name);
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
Object.defineProperty(exports, "importPeer", {
|
|
38
|
+
enumerable: true,
|
|
39
|
+
get: function() {
|
|
40
|
+
return importPeer;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
Object.defineProperty(exports, "peer_exports", {
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: function() {
|
|
46
|
+
return peer_exports;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
Object.defineProperty(exports, "requirePeer", {
|
|
50
|
+
enumerable: true,
|
|
51
|
+
get: function() {
|
|
52
|
+
return requirePeer;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
//# sourceMappingURL=peer-BIjBFzwQ.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"peer-BIjBFzwQ.cjs","names":[],"sources":["../src/internal/peer.ts"],"sourcesContent":["/**\n * Optional-peer helpers shared by every subpath that needs a driver, framework or tool package.\n *\n * @module\n */\n\n/**\n * Throw a clear, actionable error for a missing optional peer. The message names the package to\n * install (what the user needs) and the kit subpath that asked for it.\n */\nexport function requirePeer(name: string, subpath: string): never {\n throw new Error(\n `${subpath} requires the optional peer \"${name}\". Install it with: bun add ${name} (or npm install ${name})`,\n );\n}\n\n/**\n * `import(name)` an optional peer, turning a module-not-found error into {@link requirePeer}'s\n * message. Other errors (a broken install, a throwing module) propagate unchanged.\n */\nexport async function importPeer<T>(\n name: string,\n subpath: string,\n load: () => Promise<T>,\n): Promise<T> {\n try {\n return await load();\n } catch (error) {\n if (isModuleNotFound(error, name)) requirePeer(name, subpath);\n throw error;\n }\n}\n\nfunction isModuleNotFound(error: unknown, name: string): boolean {\n if (!error || typeof error !== \"object\") return false;\n const { code, message } = error as { code?: unknown; message?: unknown };\n if (code === \"ERR_MODULE_NOT_FOUND\" || code === \"MODULE_NOT_FOUND\") return true;\n return (\n typeof message === \"string\" &&\n /cannot find (module|package)/i.test(message) &&\n message.includes(name)\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAUA,SAAgB,YAAY,MAAc,SAAwB;CAChE,MAAM,IAAI,MACR,GAAG,QAAQ,+BAA+B,KAAK,8BAA8B,KAAK,mBAAmB,KAAK,EAC5G;AACF;;;;;AAMA,eAAsB,WACpB,MACA,SACA,MACY;CACZ,IAAI;EACF,OAAO,MAAM,KAAK;CACpB,SAAS,OAAO;EACd,IAAI,iBAAiB,OAAO,IAAI,GAAG,YAAY,MAAM,OAAO;EAC5D,MAAM;CACR;AACF;AAEA,SAAS,iBAAiB,OAAgB,MAAuB;CAC/D,IAAI,CAAC,SAAS,OAAO,UAAU,UAAU,OAAO;CAChD,MAAM,EAAE,MAAM,YAAY;CAC1B,IAAI,SAAS,0BAA0B,SAAS,oBAAoB,OAAO;CAC3E,OACE,OAAO,YAAY,YACnB,gCAAgC,KAAK,OAAO,KAC5C,QAAQ,SAAS,IAAI;AAEzB"}
|