@pithy-sh/core 0.1.2 → 0.1.4

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.
Files changed (393) hide show
  1. package/dist/address/address.d.ts +57 -0
  2. package/dist/address/address.d.ts.map +1 -0
  3. package/dist/address/address.js +71 -0
  4. package/dist/audit/auditEvent.d.ts +89 -0
  5. package/dist/audit/auditEvent.d.ts.map +1 -0
  6. package/dist/audit/auditEvent.js +69 -0
  7. package/dist/audit/recorder.d.ts +18 -0
  8. package/dist/audit/recorder.d.ts.map +1 -0
  9. package/dist/audit/recorder.js +8 -0
  10. package/dist/capability/bindings.d.ts +62 -0
  11. package/dist/capability/bindings.d.ts.map +1 -0
  12. package/dist/capability/bindings.js +97 -0
  13. package/dist/capability/capability.d.ts +501 -0
  14. package/dist/capability/capability.d.ts.map +1 -0
  15. package/dist/capability/capability.js +16 -0
  16. package/dist/capability/client.d.ts +70 -0
  17. package/dist/capability/client.d.ts.map +1 -0
  18. package/dist/capability/client.js +86 -0
  19. package/dist/capability/compose.d.ts +25 -0
  20. package/dist/capability/compose.d.ts.map +1 -0
  21. package/dist/capability/compose.js +54 -0
  22. package/dist/capability/composition.d.ts +26 -0
  23. package/dist/capability/composition.d.ts.map +1 -0
  24. package/dist/capability/composition.js +84 -0
  25. package/dist/capability/config.d.ts +7 -0
  26. package/dist/capability/config.d.ts.map +1 -0
  27. package/dist/capability/config.js +14 -0
  28. package/dist/capability/devSecret.d.ts +32 -0
  29. package/dist/capability/devSecret.d.ts.map +1 -0
  30. package/dist/capability/devSecret.js +28 -0
  31. package/dist/capability/manifest.d.ts +298 -0
  32. package/dist/capability/manifest.d.ts.map +1 -0
  33. package/dist/capability/manifest.js +356 -0
  34. package/dist/capability/secretOrigin.d.ts +121 -0
  35. package/dist/capability/secretOrigin.d.ts.map +1 -0
  36. package/dist/capability/secretOrigin.js +134 -0
  37. package/dist/capability/settings.d.ts +119 -0
  38. package/dist/capability/settings.d.ts.map +1 -0
  39. package/dist/capability/settings.js +66 -0
  40. package/dist/capability/validateBindings.d.ts +4 -0
  41. package/dist/capability/validateBindings.d.ts.map +1 -0
  42. package/dist/capability/validateBindings.js +34 -0
  43. package/dist/capability/vanishingKey.d.ts +31 -0
  44. package/dist/capability/vanishingKey.d.ts.map +1 -0
  45. package/dist/capability/vanishingKey.js +79 -0
  46. package/dist/controlPlane/audit/actions.d.ts +70 -0
  47. package/dist/controlPlane/audit/actions.d.ts.map +1 -0
  48. package/dist/controlPlane/audit/actions.js +76 -0
  49. package/dist/controlPlane/capability.d.ts +47 -0
  50. package/dist/controlPlane/capability.d.ts.map +1 -0
  51. package/dist/controlPlane/capability.js +138 -0
  52. package/dist/controlPlane/config/config.d.ts +19 -0
  53. package/dist/controlPlane/config/config.d.ts.map +1 -0
  54. package/dist/controlPlane/config/config.js +85 -0
  55. package/dist/controlPlane/context.d.ts +27 -0
  56. package/dist/controlPlane/context.d.ts.map +1 -0
  57. package/dist/controlPlane/context.js +29 -0
  58. package/dist/controlPlane/data/connection.d.ts +79 -0
  59. package/dist/controlPlane/data/connection.d.ts.map +1 -0
  60. package/dist/controlPlane/data/connection.js +55 -0
  61. package/dist/controlPlane/data/keyLifecycle.d.ts +62 -0
  62. package/dist/controlPlane/data/keyLifecycle.d.ts.map +1 -0
  63. package/dist/controlPlane/data/keyLifecycle.js +126 -0
  64. package/dist/controlPlane/data/replay.d.ts +18 -0
  65. package/dist/controlPlane/data/replay.d.ts.map +1 -0
  66. package/dist/controlPlane/data/replay.js +20 -0
  67. package/dist/controlPlane/data/tables.d.ts +34 -0
  68. package/dist/controlPlane/data/tables.d.ts.map +1 -0
  69. package/dist/controlPlane/data/tables.js +37 -0
  70. package/dist/controlPlane/discovery/adminRoute.d.ts +313 -0
  71. package/dist/controlPlane/discovery/adminRoute.d.ts.map +1 -0
  72. package/dist/controlPlane/discovery/adminRoute.js +136 -0
  73. package/dist/controlPlane/discovery/configuration.d.ts +108 -0
  74. package/dist/controlPlane/discovery/configuration.d.ts.map +1 -0
  75. package/dist/controlPlane/discovery/configuration.js +187 -0
  76. package/dist/controlPlane/discovery/drift.d.ts +64 -0
  77. package/dist/controlPlane/discovery/drift.d.ts.map +1 -0
  78. package/dist/controlPlane/discovery/drift.js +58 -0
  79. package/dist/controlPlane/discovery/health.d.ts +99 -0
  80. package/dist/controlPlane/discovery/health.d.ts.map +1 -0
  81. package/dist/controlPlane/discovery/health.js +151 -0
  82. package/dist/controlPlane/discovery/healthSummary.d.ts +236 -0
  83. package/dist/controlPlane/discovery/healthSummary.d.ts.map +1 -0
  84. package/dist/controlPlane/discovery/healthSummary.js +278 -0
  85. package/dist/controlPlane/error/errors.d.ts +67 -0
  86. package/dist/controlPlane/error/errors.d.ts.map +1 -0
  87. package/dist/controlPlane/error/errors.js +79 -0
  88. package/dist/controlPlane/http/cors.d.ts +112 -0
  89. package/dist/controlPlane/http/cors.d.ts.map +1 -0
  90. package/dist/controlPlane/http/cors.js +192 -0
  91. package/dist/controlPlane/http/guard.d.ts +77 -0
  92. package/dist/controlPlane/http/guard.d.ts.map +1 -0
  93. package/dist/controlPlane/http/guard.js +142 -0
  94. package/dist/controlPlane/http/handlers.d.ts +179 -0
  95. package/dist/controlPlane/http/handlers.d.ts.map +1 -0
  96. package/dist/controlPlane/http/handlers.js +245 -0
  97. package/dist/controlPlane/http/responses.d.ts +99 -0
  98. package/dist/controlPlane/http/responses.d.ts.map +1 -0
  99. package/dist/controlPlane/http/responses.js +63 -0
  100. package/dist/controlPlane/http/routes.d.ts +40 -0
  101. package/dist/controlPlane/http/routes.d.ts.map +1 -0
  102. package/dist/controlPlane/http/routes.js +83 -0
  103. package/dist/controlPlane/http/schemas.d.ts +39 -0
  104. package/dist/controlPlane/http/schemas.d.ts.map +1 -0
  105. package/dist/controlPlane/http/schemas.js +31 -0
  106. package/dist/controlPlane/http/verify.d.ts +84 -0
  107. package/dist/controlPlane/http/verify.d.ts.map +1 -0
  108. package/dist/controlPlane/http/verify.js +65 -0
  109. package/dist/controlPlane/migrations/0001_init.d.ts +51 -0
  110. package/dist/controlPlane/migrations/0001_init.d.ts.map +1 -0
  111. package/dist/controlPlane/migrations/0001_init.js +65 -0
  112. package/dist/controlPlane/replay/d1Guard.d.ts +29 -0
  113. package/dist/controlPlane/replay/d1Guard.d.ts.map +1 -0
  114. package/dist/controlPlane/replay/d1Guard.js +39 -0
  115. package/dist/controlPlane/replay/guard.d.ts +52 -0
  116. package/dist/controlPlane/replay/guard.d.ts.map +1 -0
  117. package/dist/controlPlane/replay/guard.js +0 -0
  118. package/dist/controlPlane/replay/kvGuard.d.ts +99 -0
  119. package/dist/controlPlane/replay/kvGuard.d.ts.map +1 -0
  120. package/dist/controlPlane/replay/kvGuard.js +101 -0
  121. package/dist/controlPlane/scope/scope.d.ts +68 -0
  122. package/dist/controlPlane/scope/scope.d.ts.map +1 -0
  123. package/dist/controlPlane/scope/scope.js +63 -0
  124. package/dist/controlPlane/token/base64url.d.ts +10 -0
  125. package/dist/controlPlane/token/base64url.d.ts.map +1 -0
  126. package/dist/controlPlane/token/base64url.js +48 -0
  127. package/dist/controlPlane/token/claims.d.ts +83 -0
  128. package/dist/controlPlane/token/claims.d.ts.map +1 -0
  129. package/dist/controlPlane/token/claims.js +86 -0
  130. package/dist/controlPlane/token/digest.d.ts +44 -0
  131. package/dist/controlPlane/token/digest.d.ts.map +1 -0
  132. package/dist/controlPlane/token/digest.js +56 -0
  133. package/dist/controlPlane/token/jws.d.ts +52 -0
  134. package/dist/controlPlane/token/jws.d.ts.map +1 -0
  135. package/dist/controlPlane/token/jws.js +65 -0
  136. package/dist/controlPlane/token/mint.d.ts +56 -0
  137. package/dist/controlPlane/token/mint.d.ts.map +1 -0
  138. package/dist/controlPlane/token/mint.js +55 -0
  139. package/dist/controlPlane/wire.d.ts +122 -0
  140. package/dist/controlPlane/wire.d.ts.map +1 -0
  141. package/dist/controlPlane/wire.js +123 -0
  142. package/dist/createBackend.d.ts +58 -0
  143. package/dist/createBackend.d.ts.map +1 -0
  144. package/dist/createBackend.js +170 -0
  145. package/dist/createEntrypoint.d.ts +53 -0
  146. package/dist/createEntrypoint.d.ts.map +1 -0
  147. package/dist/createEntrypoint.js +52 -0
  148. package/dist/data/boundParameters.d.ts +83 -0
  149. package/dist/data/boundParameters.d.ts.map +1 -0
  150. package/dist/data/boundParameters.js +162 -0
  151. package/dist/data/codecs.d.ts +34 -0
  152. package/dist/data/codecs.d.ts.map +1 -0
  153. package/dist/data/codecs.js +135 -0
  154. package/dist/data/cursor.d.ts +81 -0
  155. package/dist/data/cursor.d.ts.map +1 -0
  156. package/dist/data/cursor.js +104 -0
  157. package/dist/data/databases.d.ts +55 -0
  158. package/dist/data/databases.d.ts.map +1 -0
  159. package/dist/data/databases.js +32 -0
  160. package/dist/data/db.d.ts +42 -0
  161. package/dist/data/db.d.ts.map +1 -0
  162. package/dist/data/db.js +24 -0
  163. package/dist/data/withD1Retry.d.ts +91 -0
  164. package/dist/data/withD1Retry.d.ts.map +1 -0
  165. package/dist/data/withD1Retry.js +152 -0
  166. package/dist/entitlement/entitlement.d.ts +118 -0
  167. package/dist/entitlement/entitlement.d.ts.map +1 -0
  168. package/dist/entitlement/entitlement.js +59 -0
  169. package/dist/entitlement/gateScan.d.ts +26 -0
  170. package/dist/entitlement/gateScan.d.ts.map +1 -0
  171. package/dist/entitlement/gateScan.js +96 -0
  172. package/dist/entitlement/require.d.ts +12 -0
  173. package/dist/entitlement/require.d.ts.map +1 -0
  174. package/dist/entitlement/require.js +123 -0
  175. package/dist/env/ambient.d.ts +52 -0
  176. package/dist/env/ambient.d.ts.map +1 -0
  177. package/dist/env/ambient.js +35 -0
  178. package/dist/env/ci.d.ts +36 -0
  179. package/dist/env/ci.d.ts.map +1 -0
  180. package/dist/env/ci.js +40 -0
  181. package/dist/env/stem.d.ts +23 -0
  182. package/dist/env/stem.d.ts.map +1 -0
  183. package/dist/env/stem.js +29 -0
  184. package/dist/error/cause.d.ts +143 -0
  185. package/dist/error/cause.d.ts.map +1 -0
  186. package/dist/error/cause.js +192 -0
  187. package/dist/error/client.d.ts +35 -0
  188. package/dist/error/client.d.ts.map +1 -0
  189. package/dist/error/client.js +38 -0
  190. package/dist/error/extend.d.ts +101 -0
  191. package/dist/error/extend.d.ts.map +1 -0
  192. package/dist/error/extend.js +76 -0
  193. package/dist/error/http.d.ts +1516 -0
  194. package/dist/error/http.d.ts.map +1 -0
  195. package/dist/error/http.js +72 -0
  196. package/dist/error/payload.d.ts +3034 -0
  197. package/dist/error/payload.d.ts.map +1 -0
  198. package/dist/error/payload.js +1110 -0
  199. package/dist/error/pithyError.d.ts +154 -0
  200. package/dist/error/pithyError.d.ts.map +1 -0
  201. package/dist/error/pithyError.js +197 -0
  202. package/dist/error/terminal.d.ts +28 -0
  203. package/dist/error/terminal.d.ts.map +1 -0
  204. package/dist/error/terminal.js +33 -0
  205. package/dist/http/authContext.d.ts +21 -0
  206. package/dist/http/authContext.d.ts.map +1 -0
  207. package/dist/http/authContext.js +23 -0
  208. package/dist/http/routeContract.d.ts +39 -0
  209. package/dist/http/routeContract.d.ts.map +1 -0
  210. package/dist/http/routeContract.js +82 -0
  211. package/dist/http/sameOrigin.d.ts +47 -0
  212. package/dist/http/sameOrigin.d.ts.map +1 -0
  213. package/dist/http/sameOrigin.js +24 -0
  214. package/dist/http/signedWebhook.d.ts +225 -0
  215. package/dist/http/signedWebhook.d.ts.map +1 -0
  216. package/dist/http/signedWebhook.js +247 -0
  217. package/dist/http/validation.d.ts +37 -0
  218. package/dist/http/validation.d.ts.map +1 -0
  219. package/dist/http/validation.js +14 -0
  220. package/dist/http/verification.d.ts +10 -0
  221. package/dist/http/verification.d.ts.map +1 -0
  222. package/dist/http/verification.js +17 -0
  223. package/dist/i18n/acceptLanguage.d.ts +22 -0
  224. package/dist/i18n/acceptLanguage.d.ts.map +1 -0
  225. package/dist/i18n/acceptLanguage.js +55 -0
  226. package/dist/i18n/catalog.d.ts +39 -0
  227. package/dist/i18n/catalog.d.ts.map +1 -0
  228. package/dist/i18n/catalog.js +57 -0
  229. package/dist/i18n/locale.d.ts +74 -0
  230. package/dist/i18n/locale.d.ts.map +1 -0
  231. package/dist/i18n/locale.js +109 -0
  232. package/dist/i18n/localeMarker.d.ts +29 -0
  233. package/dist/i18n/localeMarker.d.ts.map +1 -0
  234. package/dist/i18n/localeMarker.js +112 -0
  235. package/dist/i18n/match.d.ts +26 -0
  236. package/dist/i18n/match.d.ts.map +1 -0
  237. package/dist/i18n/match.js +88 -0
  238. package/dist/i18n/registry.d.ts +25 -0
  239. package/dist/i18n/registry.d.ts.map +1 -0
  240. package/dist/i18n/registry.js +51 -0
  241. package/dist/i18n/translator.d.ts +107 -0
  242. package/dist/i18n/translator.d.ts.map +1 -0
  243. package/dist/i18n/translator.js +80 -0
  244. package/dist/index.d.ts +32 -0
  245. package/dist/index.d.ts.map +1 -0
  246. package/dist/index.js +17 -0
  247. package/dist/kv/kv.d.ts +166 -0
  248. package/dist/kv/kv.d.ts.map +1 -0
  249. package/dist/kv/kv.js +261 -0
  250. package/dist/kv/namespaces.d.ts +58 -0
  251. package/dist/kv/namespaces.d.ts.map +1 -0
  252. package/dist/kv/namespaces.js +40 -0
  253. package/dist/logger/local.d.ts +41 -0
  254. package/dist/logger/local.d.ts.map +1 -0
  255. package/dist/logger/local.js +45 -0
  256. package/dist/logger/logger.d.ts +56 -0
  257. package/dist/logger/logger.d.ts.map +1 -0
  258. package/dist/logger/logger.js +83 -0
  259. package/dist/logger/record.d.ts +919 -0
  260. package/dist/logger/record.d.ts.map +1 -0
  261. package/dist/logger/record.js +79 -0
  262. package/dist/logger/worker.d.ts +74 -0
  263. package/dist/logger/worker.d.ts.map +1 -0
  264. package/dist/logger/worker.js +54 -0
  265. package/dist/migrations/batch.d.ts +10 -0
  266. package/dist/migrations/batch.d.ts.map +1 -0
  267. package/dist/migrations/batch.js +193 -0
  268. package/dist/migrations/bookkeeping.d.ts +24 -0
  269. package/dist/migrations/bookkeeping.d.ts.map +1 -0
  270. package/dist/migrations/bookkeeping.js +57 -0
  271. package/dist/migrations/owner.d.ts +41 -0
  272. package/dist/migrations/owner.d.ts.map +1 -0
  273. package/dist/migrations/owner.js +105 -0
  274. package/dist/migrations/registry.d.ts +36 -0
  275. package/dist/migrations/registry.d.ts.map +1 -0
  276. package/dist/migrations/registry.js +70 -0
  277. package/dist/migrations/runner.d.ts +67 -0
  278. package/dist/migrations/runner.d.ts.map +1 -0
  279. package/dist/migrations/runner.js +218 -0
  280. package/dist/naming/domains.d.ts +108 -0
  281. package/dist/naming/domains.d.ts.map +1 -0
  282. package/dist/naming/domains.js +156 -0
  283. package/dist/naming/environment.d.ts +118 -0
  284. package/dist/naming/environment.d.ts.map +1 -0
  285. package/dist/naming/environment.js +190 -0
  286. package/dist/naming/feature.d.ts +68 -0
  287. package/dist/naming/feature.d.ts.map +1 -0
  288. package/dist/naming/feature.js +106 -0
  289. package/dist/naming/limits.d.ts +229 -0
  290. package/dist/naming/limits.d.ts.map +1 -0
  291. package/dist/naming/limits.js +187 -0
  292. package/dist/naming/provisionScope.d.ts +91 -0
  293. package/dist/naming/provisionScope.d.ts.map +1 -0
  294. package/dist/naming/provisionScope.js +65 -0
  295. package/dist/naming/resource.d.ts +169 -0
  296. package/dist/naming/resource.d.ts.map +1 -0
  297. package/dist/naming/resource.js +220 -0
  298. package/dist/naming/resourceNames.d.ts +83 -0
  299. package/dist/naming/resourceNames.d.ts.map +1 -0
  300. package/dist/naming/resourceNames.js +102 -0
  301. package/dist/naming/segment.d.ts +29 -0
  302. package/dist/naming/segment.d.ts.map +1 -0
  303. package/dist/naming/segment.js +31 -0
  304. package/dist/projection/asRead.d.ts +72 -0
  305. package/dist/projection/asRead.d.ts.map +1 -0
  306. package/dist/projection/asRead.js +169 -0
  307. package/dist/projection/published.d.ts +95 -0
  308. package/dist/projection/published.d.ts.map +1 -0
  309. package/dist/projection/published.js +114 -0
  310. package/dist/schema/describedness.d.ts +55 -0
  311. package/dist/schema/describedness.d.ts.map +1 -0
  312. package/dist/schema/describedness.js +180 -0
  313. package/dist/seed/compose.d.ts +41 -0
  314. package/dist/seed/compose.d.ts.map +1 -0
  315. package/dist/seed/compose.js +51 -0
  316. package/dist/seed/devLogin.d.ts +50 -0
  317. package/dist/seed/devLogin.d.ts.map +1 -0
  318. package/dist/seed/devLogin.js +52 -0
  319. package/dist/seed/exampleIdentities.d.ts +58 -0
  320. package/dist/seed/exampleIdentities.d.ts.map +1 -0
  321. package/dist/seed/exampleIdentities.js +26 -0
  322. package/dist/seed/metadata.d.ts +20 -0
  323. package/dist/seed/metadata.d.ts.map +1 -0
  324. package/dist/seed/metadata.js +27 -0
  325. package/dist/seed/seed.d.ts +264 -0
  326. package/dist/seed/seed.d.ts.map +1 -0
  327. package/dist/seed/seed.js +37 -0
  328. package/dist/seed/seededRows.d.ts +26 -0
  329. package/dist/seed/seededRows.d.ts.map +1 -0
  330. package/dist/seed/seededRows.js +20 -0
  331. package/dist/seed/writeD1.d.ts +43 -0
  332. package/dist/seed/writeD1.d.ts.map +1 -0
  333. package/dist/seed/writeD1.js +73 -0
  334. package/dist/seed/writeKv.d.ts +29 -0
  335. package/dist/seed/writeKv.d.ts.map +1 -0
  336. package/dist/seed/writeKv.js +63 -0
  337. package/dist/semver/semver.d.ts +62 -0
  338. package/dist/semver/semver.d.ts.map +1 -0
  339. package/dist/semver/semver.js +137 -0
  340. package/dist/text/comments.d.ts +62 -0
  341. package/dist/text/comments.d.ts.map +1 -0
  342. package/dist/text/comments.js +161 -0
  343. package/dist/version.generated.d.ts +5 -0
  344. package/dist/version.generated.d.ts.map +1 -0
  345. package/dist/version.generated.js +7 -0
  346. package/dist/worker/health.d.ts +39 -0
  347. package/dist/worker/health.d.ts.map +1 -0
  348. package/dist/worker/health.js +41 -0
  349. package/dist/worker/identity.d.ts +191 -0
  350. package/dist/worker/identity.d.ts.map +1 -0
  351. package/dist/worker/identity.js +162 -0
  352. package/dist/workflow/bindings.d.ts +41 -0
  353. package/dist/workflow/bindings.d.ts.map +1 -0
  354. package/dist/workflow/bindings.js +53 -0
  355. package/dist/workflow/dispatch.d.ts +98 -0
  356. package/dist/workflow/dispatch.d.ts.map +1 -0
  357. package/dist/workflow/dispatch.js +148 -0
  358. package/dist/workflow/dispatchRoute.d.ts +80 -0
  359. package/dist/workflow/dispatchRoute.d.ts.map +1 -0
  360. package/dist/workflow/dispatchRoute.js +134 -0
  361. package/dist/workflow/faults.d.ts +97 -0
  362. package/dist/workflow/faults.d.ts.map +1 -0
  363. package/dist/workflow/faults.js +111 -0
  364. package/dist/workflow/host.d.ts +176 -0
  365. package/dist/workflow/host.d.ts.map +1 -0
  366. package/dist/workflow/host.js +116 -0
  367. package/dist/workflow/hostEntry.d.ts +50 -0
  368. package/dist/workflow/hostEntry.d.ts.map +1 -0
  369. package/dist/workflow/hostEntry.js +24 -0
  370. package/dist/workflow/hostEnv.d.ts +143 -0
  371. package/dist/workflow/hostEnv.d.ts.map +1 -0
  372. package/dist/workflow/hostEnv.js +170 -0
  373. package/dist/workflow/loopback.d.ts +52 -0
  374. package/dist/workflow/loopback.d.ts.map +1 -0
  375. package/dist/workflow/loopback.js +76 -0
  376. package/dist/workflow/naming.d.ts +79 -0
  377. package/dist/workflow/naming.d.ts.map +1 -0
  378. package/dist/workflow/naming.js +138 -0
  379. package/dist/workflow/register.d.ts +19 -0
  380. package/dist/workflow/register.d.ts.map +1 -0
  381. package/dist/workflow/register.js +40 -0
  382. package/dist/workflow/schemas.d.ts +44 -0
  383. package/dist/workflow/schemas.d.ts.map +1 -0
  384. package/dist/workflow/schemas.js +43 -0
  385. package/dist/workflow/spec.d.ts +81 -0
  386. package/dist/workflow/spec.d.ts.map +1 -0
  387. package/dist/workflow/spec.js +0 -0
  388. package/dist/workflow/stepMessage.d.ts +122 -0
  389. package/dist/workflow/stepMessage.d.ts.map +1 -0
  390. package/dist/workflow/stepMessage.js +152 -0
  391. package/package.json +20 -9
  392. package/src/capability/manifest.ts +21 -0
  393. package/src/version.generated.ts +1 -1
@@ -0,0 +1,154 @@
1
+ import type { z } from "zod";
2
+ import type { MessageParams } from "../i18n/catalog";
3
+ import type { ValidationIssue } from "./payload";
4
+ import { ErrorPayload } from "./payload";
5
+ /**
6
+ * `PithyError` is the one throw/catch vehicle. A thrown thing must be `instanceof Error`
7
+ * (for `catch`, stack traces, `cause`); a Zod object is a data shape, not an `Error`. So the
8
+ * class does not extend a schema — it **carries** one. The payload is validated against
9
+ * `ErrorPayload` at construction, so every `PithyError` in flight is either a member of the kit's
10
+ * closed taxonomy or an adopter's own code under a domain the kit does not reserve — nothing else
11
+ * gets thrown. The subclasses below are sugar that default a member's `code`/`status`; they set a
12
+ * payload the union already defines, so there is no second source of truth.
13
+ */
14
+ export declare class PithyError extends Error {
15
+ readonly payload: ErrorPayload;
16
+ constructor(payload: ErrorPayload, options?: {
17
+ cause?: unknown;
18
+ });
19
+ }
20
+ /** Variable parts every subclass accepts; the `code`/`status` are fixed by the subclass. */
21
+ interface ErrorArgs {
22
+ /** Override the public, safe-to-expose message. Defaults to a per-code summary. */
23
+ message?: string;
24
+ /** A remediation hint (CLI action line). */
25
+ action?: string;
26
+ /** Internal context for logs + audit. Never serialized to clients. */
27
+ detail?: string;
28
+ /**
29
+ * Values a translating client interpolates into its own wording for this code. Client-facing, so —
30
+ * unlike `action` and `detail` — these cross the boundary with `message`. The `code` is the catalog
31
+ * key, so a throw site that fills a placeholder states it once, here.
32
+ */
33
+ params?: MessageParams;
34
+ }
35
+ export declare class ValidationError extends PithyError {
36
+ readonly payload: Extract<ErrorPayload, {
37
+ code: "validation/invalid_input";
38
+ }>;
39
+ constructor(args?: ErrorArgs & {
40
+ issues?: ValidationIssue[];
41
+ }, options?: {
42
+ cause?: unknown;
43
+ });
44
+ }
45
+ export declare class UnauthorizedError extends PithyError {
46
+ readonly payload: Extract<ErrorPayload, {
47
+ code: "auth/invalid_token";
48
+ }>;
49
+ constructor(args?: ErrorArgs, options?: {
50
+ cause?: unknown;
51
+ });
52
+ }
53
+ /**
54
+ * One code for every way a `signed-webhook` delivery fails to prove its origin. The step that failed
55
+ * goes in `detail`, which the HTTP codec strips — a forger learns only that it failed, and an operator
56
+ * reading the log learns which check refused it.
57
+ */
58
+ export declare class WebhookUnverifiedError extends PithyError {
59
+ readonly payload: Extract<ErrorPayload, {
60
+ code: "core/webhook_unverified";
61
+ }>;
62
+ constructor(args?: ErrorArgs, options?: {
63
+ cause?: unknown;
64
+ });
65
+ }
66
+ export declare class ForbiddenError extends PithyError {
67
+ readonly payload: Extract<ErrorPayload, {
68
+ code: "auth/forbidden";
69
+ }>;
70
+ constructor(args?: ErrorArgs, options?: {
71
+ cause?: unknown;
72
+ });
73
+ }
74
+ export declare class NotFoundError extends PithyError {
75
+ readonly payload: Extract<ErrorPayload, {
76
+ code: "core/not_found";
77
+ }>;
78
+ constructor(args?: ErrorArgs, options?: {
79
+ cause?: unknown;
80
+ });
81
+ }
82
+ export declare class ConflictError extends PithyError {
83
+ readonly payload: Extract<ErrorPayload, {
84
+ code: "core/conflict";
85
+ }>;
86
+ constructor(args?: ErrorArgs, options?: {
87
+ cause?: unknown;
88
+ });
89
+ }
90
+ export declare class RateLimitError extends PithyError {
91
+ readonly payload: Extract<ErrorPayload, {
92
+ code: "rate_limit/exceeded";
93
+ }>;
94
+ constructor(args?: ErrorArgs, options?: {
95
+ cause?: unknown;
96
+ });
97
+ }
98
+ export declare class InternalError extends PithyError {
99
+ readonly payload: Extract<ErrorPayload, {
100
+ code: "core/internal";
101
+ }>;
102
+ constructor(args?: ErrorArgs, options?: {
103
+ cause?: unknown;
104
+ });
105
+ }
106
+ /**
107
+ * A service this one depends on and does not control failed. Reach for this — never `InternalError`
108
+ * — whenever the thing that broke sits behind a network call: a proxied request, a REST client, a
109
+ * provider. A 500 tells the operator to read *our* logs, and for an upstream outage that is the
110
+ * wrong system. The endpoint and the upstream's own status belong in `detail`.
111
+ */
112
+ export declare class UpstreamError extends PithyError {
113
+ readonly payload: Extract<ErrorPayload, {
114
+ code: "core/upstream_failed";
115
+ }>;
116
+ constructor(args?: ErrorArgs, options?: {
117
+ cause?: unknown;
118
+ });
119
+ }
120
+ /** The same dependency, out of time rather than answered. Retryable, and possibly already applied. */
121
+ export declare class UpstreamTimeoutError extends PithyError {
122
+ readonly payload: Extract<ErrorPayload, {
123
+ code: "core/upstream_timeout";
124
+ }>;
125
+ constructor(args?: ErrorArgs, options?: {
126
+ cause?: unknown;
127
+ });
128
+ }
129
+ /**
130
+ * Map a `ZodError` to a `validation/invalid_input` `PithyError`. Zod is the boundary validator
131
+ * everywhere (HTTP input, KV, env, D1 rows), so this is the most common error path — one place
132
+ * turns any failed parse into the typed family, carrying the field-level issues to the client.
133
+ */
134
+ export declare function fromZodError(error: z.ZodError, args?: ErrorArgs): ValidationError;
135
+ /**
136
+ * The message of an unknown throw, for use as a `PithyError` `detail` — `error.message` for an
137
+ * `Error`, else its string form. One source of truth so every catch site that wants the cause text
138
+ * does it the same way (CLAUDE.md §Errors).
139
+ */
140
+ export declare function messageOf(error: unknown): string;
141
+ /**
142
+ * One caught error as one sentence for a human: its {@link messageOf}, then its `action` when it has
143
+ * one. For a caller that has to *report* a failure rather than re-throw it — a CLI check that must keep
144
+ * running, a diagnostic that collects several.
145
+ *
146
+ * **Both halves, because they answer different questions**: the message says what is wrong and where,
147
+ * the action says what to do about it. A reporter that keeps only the message drops the fix.
148
+ *
149
+ * **Never `detail`.** That is throw-site context, deliberately stripped at the HTTP boundary, and a
150
+ * string built here is printed to a terminal and pasted into issues. Same rule, one line up.
151
+ */
152
+ export declare function sentenceOf(error: unknown): string;
153
+ export {};
154
+ //# sourceMappingURL=pithyError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pithyError.d.ts","sourceRoot":"","sources":["../../src/error/pithyError.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,197 @@
1
+ import { ErrorPayload } from "./payload.js";
2
+ //#region src/error/pithyError.ts
3
+ /**
4
+ * `PithyError` is the one throw/catch vehicle. A thrown thing must be `instanceof Error`
5
+ * (for `catch`, stack traces, `cause`); a Zod object is a data shape, not an `Error`. So the
6
+ * class does not extend a schema — it **carries** one. The payload is validated against
7
+ * `ErrorPayload` at construction, so every `PithyError` in flight is either a member of the kit's
8
+ * closed taxonomy or an adopter's own code under a domain the kit does not reserve — nothing else
9
+ * gets thrown. The subclasses below are sugar that default a member's `code`/`status`; they set a
10
+ * payload the union already defines, so there is no second source of truth.
11
+ */
12
+ var PithyError = class extends Error {
13
+ payload;
14
+ constructor(payload, options) {
15
+ const parsed = ErrorPayload.parse(payload);
16
+ super(parsed.message, options);
17
+ this.payload = parsed;
18
+ this.name = "PithyError";
19
+ }
20
+ };
21
+ var ValidationError = class extends PithyError {
22
+ constructor(args = {}, options) {
23
+ super({
24
+ code: "validation/invalid_input",
25
+ status: 400,
26
+ message: args.message ?? "Invalid input.",
27
+ action: args.action,
28
+ detail: args.detail,
29
+ params: args.params,
30
+ issues: args.issues ?? []
31
+ }, options);
32
+ }
33
+ };
34
+ var UnauthorizedError = class extends PithyError {
35
+ constructor(args = {}, options) {
36
+ super({
37
+ code: "auth/invalid_token",
38
+ status: 401,
39
+ message: args.message ?? "Invalid or expired credentials.",
40
+ action: args.action,
41
+ detail: args.detail,
42
+ params: args.params
43
+ }, options);
44
+ }
45
+ };
46
+ /**
47
+ * One code for every way a `signed-webhook` delivery fails to prove its origin. The step that failed
48
+ * goes in `detail`, which the HTTP codec strips — a forger learns only that it failed, and an operator
49
+ * reading the log learns which check refused it.
50
+ */
51
+ var WebhookUnverifiedError = class extends PithyError {
52
+ constructor(args = {}, options) {
53
+ super({
54
+ code: "core/webhook_unverified",
55
+ status: 401,
56
+ message: args.message ?? "That delivery could not be verified.",
57
+ action: args.action ?? "Sign the request with this endpoint's current secret and send it promptly.",
58
+ detail: args.detail,
59
+ params: args.params
60
+ }, options);
61
+ }
62
+ };
63
+ var ForbiddenError = class extends PithyError {
64
+ constructor(args = {}, options) {
65
+ super({
66
+ code: "auth/forbidden",
67
+ status: 403,
68
+ message: args.message ?? "Forbidden.",
69
+ action: args.action,
70
+ detail: args.detail,
71
+ params: args.params
72
+ }, options);
73
+ }
74
+ };
75
+ var NotFoundError = class extends PithyError {
76
+ constructor(args = {}, options) {
77
+ super({
78
+ code: "core/not_found",
79
+ status: 404,
80
+ message: args.message ?? "Not found.",
81
+ action: args.action,
82
+ detail: args.detail,
83
+ params: args.params
84
+ }, options);
85
+ }
86
+ };
87
+ var ConflictError = class extends PithyError {
88
+ constructor(args = {}, options) {
89
+ super({
90
+ code: "core/conflict",
91
+ status: 409,
92
+ message: args.message ?? "Conflict.",
93
+ action: args.action,
94
+ detail: args.detail,
95
+ params: args.params
96
+ }, options);
97
+ }
98
+ };
99
+ var RateLimitError = class extends PithyError {
100
+ constructor(args = {}, options) {
101
+ super({
102
+ code: "rate_limit/exceeded",
103
+ status: 429,
104
+ message: args.message ?? "Too many requests.",
105
+ action: args.action,
106
+ detail: args.detail,
107
+ params: args.params
108
+ }, options);
109
+ }
110
+ };
111
+ var InternalError = class extends PithyError {
112
+ constructor(args = {}, options) {
113
+ super({
114
+ code: "core/internal",
115
+ status: 500,
116
+ message: args.message ?? "Something unexpected happened.",
117
+ action: args.action,
118
+ detail: args.detail,
119
+ params: args.params
120
+ }, options);
121
+ }
122
+ };
123
+ /**
124
+ * A service this one depends on and does not control failed. Reach for this — never `InternalError`
125
+ * — whenever the thing that broke sits behind a network call: a proxied request, a REST client, a
126
+ * provider. A 500 tells the operator to read *our* logs, and for an upstream outage that is the
127
+ * wrong system. The endpoint and the upstream's own status belong in `detail`.
128
+ */
129
+ var UpstreamError = class extends PithyError {
130
+ constructor(args = {}, options) {
131
+ super({
132
+ code: "core/upstream_failed",
133
+ status: 502,
134
+ message: args.message ?? "An upstream service could not be reached.",
135
+ action: args.action,
136
+ detail: args.detail,
137
+ params: args.params
138
+ }, options);
139
+ }
140
+ };
141
+ /** The same dependency, out of time rather than answered. Retryable, and possibly already applied. */
142
+ var UpstreamTimeoutError = class extends PithyError {
143
+ constructor(args = {}, options) {
144
+ super({
145
+ code: "core/upstream_timeout",
146
+ status: 504,
147
+ message: args.message ?? "An upstream service did not answer in time.",
148
+ action: args.action ?? "Try again in a moment.",
149
+ detail: args.detail,
150
+ params: args.params
151
+ }, options);
152
+ }
153
+ };
154
+ /**
155
+ * Map a `ZodError` to a `validation/invalid_input` `PithyError`. Zod is the boundary validator
156
+ * everywhere (HTTP input, KV, env, D1 rows), so this is the most common error path — one place
157
+ * turns any failed parse into the typed family, carrying the field-level issues to the client.
158
+ */
159
+ function fromZodError(error, args = {}) {
160
+ const issues = error.issues.map((issue) => ({
161
+ path: issue.path.filter((segment) => typeof segment !== "symbol"),
162
+ message: issue.message,
163
+ code: issue.code
164
+ }));
165
+ return new ValidationError({
166
+ message: args.message,
167
+ action: args.action,
168
+ detail: args.detail,
169
+ params: args.params,
170
+ issues
171
+ });
172
+ }
173
+ /**
174
+ * The message of an unknown throw, for use as a `PithyError` `detail` — `error.message` for an
175
+ * `Error`, else its string form. One source of truth so every catch site that wants the cause text
176
+ * does it the same way (CLAUDE.md §Errors).
177
+ */
178
+ function messageOf(error) {
179
+ return error instanceof Error ? error.message : String(error);
180
+ }
181
+ /**
182
+ * One caught error as one sentence for a human: its {@link messageOf}, then its `action` when it has
183
+ * one. For a caller that has to *report* a failure rather than re-throw it — a CLI check that must keep
184
+ * running, a diagnostic that collects several.
185
+ *
186
+ * **Both halves, because they answer different questions**: the message says what is wrong and where,
187
+ * the action says what to do about it. A reporter that keeps only the message drops the fix.
188
+ *
189
+ * **Never `detail`.** That is throw-site context, deliberately stripped at the HTTP boundary, and a
190
+ * string built here is printed to a terminal and pasted into issues. Same rule, one line up.
191
+ */
192
+ function sentenceOf(error) {
193
+ const action = error instanceof PithyError ? error.payload.action : void 0;
194
+ return action ? `${messageOf(error)} ${action}` : messageOf(error);
195
+ }
196
+ //#endregion
197
+ export { ConflictError, ForbiddenError, InternalError, NotFoundError, PithyError, RateLimitError, UnauthorizedError, UpstreamError, UpstreamTimeoutError, ValidationError, WebhookUnverifiedError, fromZodError, messageOf, sentenceOf };
@@ -0,0 +1,28 @@
1
+ import type { ErrorPayload } from "./payload";
2
+ import { PublicErrorPayload } from "./payload";
3
+ /**
4
+ * Render an error for the terminal: the public `message` becomes the problem line and the
5
+ * optional `action` the action line — the two-line brand-voice shape `docs/CLI.md` §3.3 specifies.
6
+ * This unifies the CLI's error output into the one `PithyError` family: the CLI catches a
7
+ * `PithyError`, colorizes the first line via its `style.ts`, and prints this. `detail` is internal
8
+ * and never rendered. The same payload that encodes to HTTP renders here — one error, two surfaces.
9
+ */
10
+ export declare function renderTerminal(payload: ErrorPayload): string;
11
+ /** An error as an operator's machine surface states it: the wire fields, plus the remedy. */
12
+ export type OperatorError = PublicErrorPayload & {
13
+ action?: string;
14
+ };
15
+ /**
16
+ * The machine-readable projection for an **operator's** consumer — the CLI's `--json` error line.
17
+ *
18
+ * The same audience as {@link renderTerminal}, in the shape a script can read. `action` belongs on it
19
+ * for the reason it belongs on the terminal: whoever runs `pithy secrets create --json` is the person
20
+ * who can act on "Bind a D1 database named DB in wrangler.jsonc". Dropping it because the *HTTP*
21
+ * surface must would be classifying the field by the encoder that happened to be reused rather than
22
+ * by who is reading.
23
+ *
24
+ * `detail` is still gone, and gone by the same schema that removes it on the wire — the public parse.
25
+ * One rule, applied twice, rather than a second rule here that could drift from the first.
26
+ */
27
+ export declare function operatorError(payload: ErrorPayload): OperatorError;
28
+ //# sourceMappingURL=terminal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../src/error/terminal.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAE/C;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,YAAY,GAAG,MAAM,CAE5D;AAED,6FAA6F;AAC7F,MAAM,MAAM,aAAa,GAAG,kBAAkB,GAAG;IAAE,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAErE;;;;;;;;;;;GAWG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,aAAa,CAGlE"}
@@ -0,0 +1,33 @@
1
+ import { PublicErrorPayload } from "./payload.js";
2
+ //#region src/error/terminal.ts
3
+ /**
4
+ * Render an error for the terminal: the public `message` becomes the problem line and the
5
+ * optional `action` the action line — the two-line brand-voice shape `docs/CLI.md` §3.3 specifies.
6
+ * This unifies the CLI's error output into the one `PithyError` family: the CLI catches a
7
+ * `PithyError`, colorizes the first line via its `style.ts`, and prints this. `detail` is internal
8
+ * and never rendered. The same payload that encodes to HTTP renders here — one error, two surfaces.
9
+ */
10
+ function renderTerminal(payload) {
11
+ return payload.action ? `${payload.message}\n${payload.action}` : payload.message;
12
+ }
13
+ /**
14
+ * The machine-readable projection for an **operator's** consumer — the CLI's `--json` error line.
15
+ *
16
+ * The same audience as {@link renderTerminal}, in the shape a script can read. `action` belongs on it
17
+ * for the reason it belongs on the terminal: whoever runs `pithy secrets create --json` is the person
18
+ * who can act on "Bind a D1 database named DB in wrangler.jsonc". Dropping it because the *HTTP*
19
+ * surface must would be classifying the field by the encoder that happened to be reused rather than
20
+ * by who is reading.
21
+ *
22
+ * `detail` is still gone, and gone by the same schema that removes it on the wire — the public parse.
23
+ * One rule, applied twice, rather than a second rule here that could drift from the first.
24
+ */
25
+ function operatorError(payload) {
26
+ const wire = PublicErrorPayload.parse(payload);
27
+ return payload.action === void 0 ? wire : {
28
+ ...wire,
29
+ action: payload.action
30
+ };
31
+ }
32
+ //#endregion
33
+ export { operatorError, renderTerminal };
@@ -0,0 +1,21 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * The auth seam. `@pithy-sh/core` defines this shape; `@pithy-sh/auth` populates it on the
4
+ * request via the `bearer`/`session` strategies. Other capabilities depend only on this
5
+ * object (and `requireAuth`), never on auth internals.
6
+ *
7
+ * **`locale` rides here rather than being fetched**, because the session lookup has already loaded the
8
+ * user row and a second read of the same fact would be a query per request for a string auth is
9
+ * holding. It is the `user` link of `@pithy-sh/i18n`'s server chain — the one that makes a reader's
10
+ * stored choice outrank their device's `Accept-Language`. That link read `c.var.locale` at first,
11
+ * which nothing ever wrote, so it silently contributed nothing and the chain degraded to
12
+ * `param → cookie → header → default` while the docs said otherwise.
13
+ */
14
+ export declare const AuthContext: z.ZodObject<{
15
+ userId: z.ZodString;
16
+ sessionId: z.ZodString;
17
+ scopes: z.ZodDefault<z.ZodArray<z.ZodString>>;
18
+ locale: z.ZodOptional<z.ZodNullable<z.ZodString>>;
19
+ }, z.core.$strip>;
20
+ export type AuthContext = z.infer<typeof AuthContext>;
21
+ //# sourceMappingURL=authContext.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authContext.d.ts","sourceRoot":"","sources":["../../src/http/authContext.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,WAAW;;;;;iBASiE,CAAC;AAC1F,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { Locale } from "../i18n/locale.js";
2
+ import { z } from "zod";
3
+ //#region src/http/authContext.ts
4
+ /**
5
+ * The auth seam. `@pithy-sh/core` defines this shape; `@pithy-sh/auth` populates it on the
6
+ * request via the `bearer`/`session` strategies. Other capabilities depend only on this
7
+ * object (and `requireAuth`), never on auth internals.
8
+ *
9
+ * **`locale` rides here rather than being fetched**, because the session lookup has already loaded the
10
+ * user row and a second read of the same fact would be a query per request for a string auth is
11
+ * holding. It is the `user` link of `@pithy-sh/i18n`'s server chain — the one that makes a reader's
12
+ * stored choice outrank their device's `Accept-Language`. That link read `c.var.locale` at first,
13
+ * which nothing ever wrote, so it silently contributed nothing and the chain degraded to
14
+ * `param → cookie → header → default` while the docs said otherwise.
15
+ */
16
+ const AuthContext = z.object({
17
+ userId: z.string().describe("ID of the authenticated user (populated by @pithy-sh/auth)."),
18
+ sessionId: z.string().describe("ID of the active session this request belongs to."),
19
+ scopes: z.array(z.string()).default([]).describe("Permission scopes granted to this session."),
20
+ locale: Locale.nullish().describe("The reader's own stored language, from `pithy_auth_users.locale`; null or absent when they have never chosen.")
21
+ }).describe("Per-request authenticated identity; the seam other capabilities depend on.");
22
+ //#endregion
23
+ export { AuthContext };
@@ -0,0 +1,39 @@
1
+ import type { Hono } from "hono";
2
+ /**
3
+ * Gate 2 of the route request contract (issue #74). Its sibling, the `no-raw-request-input` Biome
4
+ * plugin, covers query and body: with `c.req.query()` and `c.req.json()` unavailable, the only way
5
+ * to read either is `c.req.valid()`, which only exists once a validator declared it. Path params
6
+ * have no such chokepoint — a handler can always reach one through a validator it never declared —
7
+ * so they need a positive check instead of a ban, and this is it.
8
+ *
9
+ * A composed app is the only place the answer lives: `Capability.routes` registers onto the app it
10
+ * is handed, so nothing static can see the finished route table. `app.routes` can — it carries one
11
+ * entry per registered handler, in order, with the path pattern intact.
12
+ *
13
+ * Identifying a param validator is the awkward part. `@hono/zod-validator` returns the same
14
+ * anonymous closure whatever its target, so there is nothing to inspect: no name, no property, no
15
+ * distinguishing shape. What does differ is *behavior* — `hono/validator` reads `c.req.param()`
16
+ * for the `param` target and nothing else does. So each middleware is invoked once against a probe
17
+ * context that records which accessor it touched. It is a real call, which is why only middleware
18
+ * are probed (never the terminal handler) and why every throw is swallowed: a guard meeting an
19
+ * empty context is expected to reject, and a validator meeting empty params is expected to fail
20
+ * validation. Either way the flag has already been set or not.
21
+ */
22
+ /** One route that reads path params without declaring a schema for them. */
23
+ export interface UncoveredRoute {
24
+ /** HTTP method as Hono records it (`GET`, `POST`, `ALL`, …). */
25
+ method: string;
26
+ /** The registered path pattern, e.g. `/leaderboard/:board/entries/:userId`. */
27
+ path: string;
28
+ /** The `:segment` names the path declares. */
29
+ params: string[];
30
+ }
31
+ /** The `:segment` names in a path pattern, in order. */
32
+ export declare function pathParams(path: string): string[];
33
+ /**
34
+ * Every route on this app that declares a `:segment` but registers no param validator for it.
35
+ * An empty array is the contract being met. Feed it a composed app — one that every capability's
36
+ * `routes` has already been applied to.
37
+ */
38
+ export declare function uncoveredParamRoutes(app: Hono<never>): Promise<UncoveredRoute[]>;
39
+ //# sourceMappingURL=routeContract.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routeContract.d.ts","sourceRoot":"","sources":["../../src/http/routeContract.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAW,IAAI,EAAQ,MAAM,MAAM,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,4EAA4E;AAC5E,MAAM,WAAW,cAAc;IAC7B,gEAAgE;IAChE,MAAM,EAAE,MAAM,CAAC;IACf,+EAA+E;IAC/E,IAAI,EAAE,MAAM,CAAC;IACb,8CAA8C;IAC9C,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAED,wDAAwD;AACxD,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAEjD;AA6CD;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAyBtF"}
@@ -0,0 +1,82 @@
1
+ //#region src/http/routeContract.ts
2
+ /** The `:segment` names in a path pattern, in order. */
3
+ function pathParams(path) {
4
+ return [...path.matchAll(/:([A-Za-z0-9_]+)/g)].map((match) => match[1]);
5
+ }
6
+ /**
7
+ * A context that answers every accessor `hono/validator` reaches for, and records the one that
8
+ * identifies a `param` validator. Deliberately minimal: anything a real guard reads is absent, so
9
+ * a guard rejects immediately instead of doing work.
10
+ */
11
+ function probeContext(record) {
12
+ return {
13
+ req: {
14
+ param: () => {
15
+ record();
16
+ return {};
17
+ },
18
+ queries: () => ({}),
19
+ query: () => ({}),
20
+ header: (name) => name === void 0 ? {} : void 0,
21
+ json: async () => ({}),
22
+ parseBody: async () => ({}),
23
+ arrayBuffer: async () => /* @__PURE__ */ new ArrayBuffer(0),
24
+ valid: () => ({}),
25
+ addValidatedData: () => {},
26
+ bodyCache: {},
27
+ url: "http://route-contract.probe/",
28
+ raw: new Request("http://route-contract.probe/")
29
+ },
30
+ env: {},
31
+ var: {},
32
+ get: () => void 0,
33
+ set: () => {}
34
+ };
35
+ }
36
+ /** Does this middleware read `c.req.param()` — i.e. is it a `zValidator("param", …)`? */
37
+ async function readsPathParams(handler) {
38
+ let read = false;
39
+ try {
40
+ await handler(probeContext(() => {
41
+ read = true;
42
+ }), (async () => {}));
43
+ } catch {}
44
+ return read;
45
+ }
46
+ /**
47
+ * Every route on this app that declares a `:segment` but registers no param validator for it.
48
+ * An empty array is the contract being met. Feed it a composed app — one that every capability's
49
+ * `routes` has already been applied to.
50
+ */
51
+ async function uncoveredParamRoutes(app) {
52
+ const grouped = /* @__PURE__ */ new Map();
53
+ for (const route of app.routes) {
54
+ const key = `${route.method} ${route.path}`;
55
+ const entry = grouped.get(key) ?? {
56
+ method: route.method,
57
+ path: route.path,
58
+ handlers: []
59
+ };
60
+ entry.handlers.push(route.handler);
61
+ grouped.set(key, entry);
62
+ }
63
+ const uncovered = [];
64
+ for (const { method, path, handlers } of grouped.values()) {
65
+ const params = pathParams(path);
66
+ if (params.length === 0) continue;
67
+ const middleware = handlers.slice(0, -1);
68
+ let covered = false;
69
+ for (const handler of middleware) if (await readsPathParams(handler)) {
70
+ covered = true;
71
+ break;
72
+ }
73
+ if (!covered) uncovered.push({
74
+ method,
75
+ path,
76
+ params
77
+ });
78
+ }
79
+ return uncovered;
80
+ }
81
+ //#endregion
82
+ export { pathParams, uncoveredParamRoutes };
@@ -0,0 +1,47 @@
1
+ import type { MiddlewareHandler } from "hono";
2
+ import type { PithyHonoEnv } from "../capability/capability";
3
+ /**
4
+ * The same-origin seam — one CSRF decision per Worker, made where the origins are known.
5
+ *
6
+ * ## Why the gate arrives already bound
7
+ *
8
+ * The origins a cookie-authenticated mutation may come from are the composed auth capability's:
9
+ * its `baseURL` plus its `trustedOrigins`. An adopter's own routes need the same rule, and the
10
+ * `routes` hook hands them only the Hono app — so the only way to write the check beside auth's own
11
+ * was to rebuild it from the request and hope the two agreed. They are free not to, and a Worker with
12
+ * two same-origin implementations has the weaker one as its actual policy.
13
+ *
14
+ * So the capability that resolved the origins publishes the gate **already bound** to them, and
15
+ * {@link requireSameOrigin} takes no argument. There is no origin list to pass, therefore no wrong one
16
+ * to pass — which is the failure mode, not the ceremony of passing it.
17
+ *
18
+ * The alternative considered was handing resolved capability config to the `routes` hook. That serves
19
+ * more cases (a base path, a rail toggle) and is worse here: it hands every adopter the raw material
20
+ * for a second, differently-bound copy of a security decision, which is the thing being removed.
21
+ *
22
+ * ## It fails closed
23
+ *
24
+ * With no capability publishing a policy the gate denies, exactly as `requireEntitlement` does with no
25
+ * provider composed. A gate that arrives with a package must not stand open when that package is
26
+ * absent; the denial names the reason in `detail`, where an operator reads it and a client does not.
27
+ */
28
+ /**
29
+ * A same-origin gate, already bound to the origins the composing capability resolved. Published on
30
+ * `c.var.sameOrigin`, consumed by {@link requireSameOrigin}, and null when nothing published one.
31
+ *
32
+ * Deliberately a bound middleware rather than the origin list: a list on the request context is an
33
+ * invitation to build a second checker beside the first, and the point of the seam is that there is
34
+ * one.
35
+ */
36
+ export type SameOriginGate = MiddlewareHandler<PithyHonoEnv>;
37
+ /**
38
+ * Require this request to come from an origin the Worker trusts — the CSRF gate a cookie-authenticated
39
+ * mutating route wears, beside the strategy that says who the caller is.
40
+ *
41
+ * app.post("/organizations", requireAuth(), requireSameOrigin(), zValidator(…), handler)
42
+ *
43
+ * A bearer request carries no ambient credential and is CSRF-exempt; that exemption belongs to the
44
+ * published gate, since the capability that owns the credential model is the one that knows.
45
+ */
46
+ export declare function requireSameOrigin(): MiddlewareHandler<PithyHonoEnv>;
47
+ //# sourceMappingURL=sameOrigin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sameOrigin.d.ts","sourceRoot":"","sources":["../../src/http/sameOrigin.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAG7D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,cAAc,GAAG,iBAAiB,CAAC,YAAY,CAAC,CAAC;AAE7D;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,IAAI,iBAAiB,CAAC,YAAY,CAAC,CAcnE"}