@guren/server 2.15.0 → 2.17.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.
Files changed (302) hide show
  1. package/dist/{DocsViewerServiceProvider-qFCaeiUv.js → DocsViewerServiceProvider-D2cuVgtN.js} +7 -12
  2. package/dist/{Hash-C8aejmi8.js → Hash-D2DFd8xX.js} +7 -57
  3. package/dist/{HttpException-BkS3euNG.js → HttpException-BlQ2yEmT.js} +2 -79
  4. package/dist/{Job-BVT813DO.js → Job-DxQK8h3P.js} +24 -179
  5. package/dist/{McpServiceProvider-BawsYjgN.js → McpServiceProvider-Zihx3Bjq.js} +35 -20
  6. package/dist/{Random-DbIJ22KQ.js → Random-S0OvCuR8.js} +9 -106
  7. package/dist/agent/AgentApprovalRequested.d.ts +11 -39
  8. package/dist/agent/approval-status.d.ts +56 -0
  9. package/dist/agent/approval.d.ts +76 -187
  10. package/dist/agent/audit-emitter.d.ts +16 -44
  11. package/dist/agent/audit.d.ts +20 -56
  12. package/dist/agent/derive.d.ts +32 -66
  13. package/dist/agent/dispatch.d.ts +38 -90
  14. package/dist/agent/events.d.ts +17 -23
  15. package/dist/agent/gate.d.ts +118 -0
  16. package/dist/agent/meta-tools.d.ts +18 -46
  17. package/dist/agent/pipeline.d.ts +234 -0
  18. package/dist/agent/public.d.ts +6 -25
  19. package/dist/agent/public.js +1 -1
  20. package/dist/agent/redact.d.ts +16 -38
  21. package/dist/agent/scopes.d.ts +55 -69
  22. package/dist/auth/AgentPrincipalGuard.d.ts +49 -0
  23. package/dist/auth/AuthManager.d.ts +22 -43
  24. package/dist/auth/AuthenticatableModel.d.ts +2 -2
  25. package/dist/auth/SessionGuard.d.ts +0 -1
  26. package/dist/auth/TokenGuard.d.ts +6 -26
  27. package/dist/auth/api-token.d.ts +16 -148
  28. package/dist/auth/context.d.ts +5 -10
  29. package/dist/auth/email-verification.d.ts +29 -127
  30. package/dist/auth/index.js +1 -1
  31. package/dist/auth/oauth/index.d.ts +35 -57
  32. package/dist/auth/password/DefaultHasher.d.ts +5 -14
  33. package/dist/auth/password/PasswordHasher.d.ts +5 -13
  34. package/dist/auth/password/hash-format.d.ts +5 -13
  35. package/dist/auth/password-reset.d.ts +16 -42
  36. package/dist/auth/providers/ModelUserProvider.d.ts +3 -4
  37. package/dist/auth/providers/UserProvider.d.ts +4 -4
  38. package/dist/auth/signed-token.d.ts +18 -0
  39. package/dist/auth/types.d.ts +9 -32
  40. package/dist/auth/utils.d.ts +6 -27
  41. package/dist/{auth-DkYoAPVn.js → auth-Gg54ppQi.js} +279 -519
  42. package/dist/authorization/Gate.d.ts +9 -145
  43. package/dist/authorization/Policy.d.ts +6 -53
  44. package/dist/authorization/index.js +1 -1
  45. package/dist/authorization/middleware.d.ts +16 -62
  46. package/dist/authorization/types.d.ts +8 -64
  47. package/dist/{authorization-CdfbCj8J.js → authorization-CdEWZZw3.js} +44 -309
  48. package/dist/broadcasting/BroadcastManager.d.ts +29 -149
  49. package/dist/broadcasting/channels/Channel.d.ts +1 -19
  50. package/dist/broadcasting/channels/PresenceChannel.d.ts +1 -55
  51. package/dist/broadcasting/channels/PrivateChannel.d.ts +1 -23
  52. package/dist/broadcasting/drivers/MemoryDriver.d.ts +18 -70
  53. package/dist/broadcasting/drivers/RedisDriver.d.ts +3 -80
  54. package/dist/broadcasting/drivers/index.d.ts +1 -1
  55. package/dist/broadcasting/index.d.ts +1 -1
  56. package/dist/broadcasting/index.js +1 -1
  57. package/dist/broadcasting/types.d.ts +7 -88
  58. package/dist/{broadcasting-BwodCA4q.js → broadcasting-B5RzB0A2.js} +87 -414
  59. package/dist/cache/CacheManager.d.ts +8 -62
  60. package/dist/cache/TaggedCache.d.ts +2 -35
  61. package/dist/cache/index.js +1 -1
  62. package/dist/cache/stores/FileStore.d.ts +2 -36
  63. package/dist/cache/stores/MemoryStore.d.ts +2 -26
  64. package/dist/cache/stores/RedisStore.d.ts +1 -29
  65. package/dist/cache/types.d.ts +21 -128
  66. package/dist/{cache-BYnZf2FR.js → cache-BOOIr324.js} +19 -198
  67. package/dist/client-C4TEr_Dd.js +9 -0
  68. package/dist/console/Command.d.ts +17 -126
  69. package/dist/console/ConsoleKernel.d.ts +2 -74
  70. package/dist/console/Input.d.ts +5 -113
  71. package/dist/console/Output.d.ts +3 -99
  72. package/dist/console/types.d.ts +3 -33
  73. package/dist/container/Container.d.ts +12 -103
  74. package/dist/container/ServiceProvider.d.ts +17 -61
  75. package/dist/container/bindings.d.ts +5 -26
  76. package/dist/container/defineModule.d.ts +16 -54
  77. package/dist/container/definePlugin.d.ts +12 -45
  78. package/dist/container/types.d.ts +2 -34
  79. package/dist/context-CXk_umpT.js +21 -0
  80. package/dist/database/Factory.d.ts +4 -57
  81. package/dist/database/Seeder.d.ts +8 -46
  82. package/dist/database/SeederRunner.d.ts +3 -33
  83. package/dist/database/types.d.ts +3 -24
  84. package/dist/discovery/AutoDiscovery.d.ts +10 -82
  85. package/dist/{dispatch-erOS9epZ.js → dispatch-BAwzftws.js} +32 -79
  86. package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +2 -5
  87. package/dist/docs-viewer/endpoint.d.ts +5 -11
  88. package/dist/encryption/Encrypter.d.ts +5 -71
  89. package/dist/encryption/Hash.d.ts +7 -57
  90. package/dist/encryption/Random.d.ts +6 -99
  91. package/dist/encryption/index.js +3 -3
  92. package/dist/encryption/types.d.ts +10 -72
  93. package/dist/{encryption-D99Vmls3.js → encryption-uwP3Di4D.js} +9 -78
  94. package/dist/{endpoint-D6GIqOpe.js → endpoint-BXipU2Jj.js} +6 -12
  95. package/dist/endpoint-Dsw3Acvq.js +26 -0
  96. package/dist/errors/ExceptionHandler.d.ts +3 -90
  97. package/dist/errors/HttpException.d.ts +2 -79
  98. package/dist/errors/debug-page.d.ts +3 -17
  99. package/dist/errors/error-page.d.ts +1 -0
  100. package/dist/errors/exceptions/AuthenticationException.d.ts +2 -24
  101. package/dist/errors/exceptions/AuthorizationException.d.ts +1 -24
  102. package/dist/errors/exceptions/MethodNotAllowedException.d.ts +1 -23
  103. package/dist/errors/exceptions/NotFoundHttpException.d.ts +1 -27
  104. package/dist/errors/exceptions/ValidationException.d.ts +2 -43
  105. package/dist/errors/types.d.ts +1 -25
  106. package/dist/{errors-BgeOl_DC.js → errors-JpkcCjjn.js} +3 -41
  107. package/dist/events/Event.d.ts +1 -28
  108. package/dist/events/EventManager.d.ts +5 -107
  109. package/dist/events/Listener.d.ts +7 -55
  110. package/dist/events/builtin.d.ts +0 -24
  111. package/dist/events/index.js +1 -1
  112. package/dist/events/types.d.ts +4 -22
  113. package/dist/{events-aIH_bWRx.js → events-DOmAHDeP.js} +11 -191
  114. package/dist/facades/index.d.ts +2 -14
  115. package/dist/health/HealthCheck.d.ts +0 -24
  116. package/dist/health/HealthManager.d.ts +0 -36
  117. package/dist/health/checks/CacheCheck.d.ts +2 -17
  118. package/dist/health/checks/CustomCheck.d.ts +0 -9
  119. package/dist/health/checks/DatabaseCheck.d.ts +2 -17
  120. package/dist/health/checks/MemoryCheck.d.ts +3 -12
  121. package/dist/health/checks/RedisCheck.d.ts +1 -13
  122. package/dist/health/checks/StorageCheck.d.ts +2 -17
  123. package/dist/health/index.js +1 -1
  124. package/dist/health/types.d.ts +4 -24
  125. package/dist/{health-VWdWXRwh.js → health-DQSvUplL.js} +1 -76
  126. package/dist/hot-disposables-B5BXqaIH.js +167 -0
  127. package/dist/hot-reload/hot-disposables.d.ts +22 -74
  128. package/dist/hot-reload/testing.d.ts +4 -9
  129. package/dist/http/Application.d.ts +77 -205
  130. package/dist/http/FormRequest.d.ts +4 -55
  131. package/dist/http/dev-assets.d.ts +13 -31
  132. package/dist/http/dev-banner.d.ts +2 -5
  133. package/dist/http/inertia-assets.d.ts +3 -6
  134. package/dist/http/middleware/capabilities.d.ts +27 -50
  135. package/dist/http/middleware/cors.d.ts +4 -29
  136. package/dist/http/middleware/csp.d.ts +2 -25
  137. package/dist/http/middleware/csrf.d.ts +28 -95
  138. package/dist/http/middleware/detect-locale.d.ts +7 -27
  139. package/dist/http/middleware/force-https.d.ts +6 -24
  140. package/dist/http/middleware/host-authorization.d.ts +2 -12
  141. package/dist/http/middleware/index.d.ts +1 -1
  142. package/dist/http/middleware/loopback-guard.d.ts +15 -33
  143. package/dist/http/middleware/rate-limit.d.ts +29 -126
  144. package/dist/http/middleware/redirect-safety.d.ts +2 -20
  145. package/dist/http/middleware/request-id.d.ts +1 -14
  146. package/dist/http/middleware/request-logging.d.ts +2 -13
  147. package/dist/http/middleware/response-headers.d.ts +5 -13
  148. package/dist/http/middleware/security-headers.d.ts +2 -16
  149. package/dist/http/middleware/session.d.ts +15 -34
  150. package/dist/http/middleware/validation-errors-cookie.d.ts +7 -18
  151. package/dist/http/middleware/validation.d.ts +8 -63
  152. package/dist/http/public-assets.d.ts +11 -7
  153. package/dist/http/request.d.ts +32 -118
  154. package/dist/http/resources/CursorPaginator.d.ts +5 -64
  155. package/dist/http/resources/Paginator.d.ts +7 -84
  156. package/dist/http/resources/Resource.d.ts +9 -65
  157. package/dist/http/resources/ResourceCollection.d.ts +5 -39
  158. package/dist/http/resources/types.d.ts +10 -30
  159. package/dist/http/static-documents.d.ts +10 -20
  160. package/dist/http/validation/Validator.d.ts +25 -85
  161. package/dist/http/validation/rules.d.ts +48 -147
  162. package/dist/http/validation/types.d.ts +16 -61
  163. package/dist/http/vite-assets.d.ts +5 -28
  164. package/dist/http/vite-dev-server.d.ts +6 -9
  165. package/dist/http/vite-manifest.d.ts +19 -33
  166. package/dist/i18n/I18nManager.d.ts +12 -78
  167. package/dist/i18n/Translator.d.ts +3 -54
  168. package/dist/i18n/index.js +1 -1
  169. package/dist/i18n/loaders/JsonLoader.d.ts +4 -31
  170. package/dist/i18n/loaders/MemoryLoader.d.ts +1 -21
  171. package/dist/i18n/pluralization.d.ts +4 -13
  172. package/dist/i18n/types.d.ts +17 -69
  173. package/dist/{i18n-mcWi7LCd.js → i18n-Cg1aajRP.js} +31 -225
  174. package/dist/index.d.ts +11 -4
  175. package/dist/index.js +1186 -3040
  176. package/dist/internal/agent-preflight.d.ts +9 -21
  177. package/dist/internal/agent-principal.d.ts +32 -0
  178. package/dist/internal/request.d.ts +6 -19
  179. package/dist/internal/request.js +1 -1
  180. package/dist/internal/route-path.d.ts +9 -21
  181. package/dist/internal/route-path.js +9 -21
  182. package/dist/internal/zod-compat.d.ts +55 -122
  183. package/dist/internal/zod-compat.js +39 -70
  184. package/dist/internal/zod-json-schema.d.ts +18 -54
  185. package/dist/internal/zod-json-schema.js +46 -123
  186. package/dist/jsx-runtime.d.ts +3 -8
  187. package/dist/lambda/index.d.ts +17 -79
  188. package/dist/lambda/index.js +11 -59
  189. package/dist/logging/LogManager.d.ts +1 -51
  190. package/dist/logging/Logger.d.ts +8 -47
  191. package/dist/logging/channels/ConsoleChannel.d.ts +1 -3
  192. package/dist/logging/channels/DailyFileChannel.d.ts +1 -3
  193. package/dist/logging/channels/FileChannel.d.ts +1 -3
  194. package/dist/logging/daily-file-path.d.ts +7 -16
  195. package/dist/logging/index.js +1 -1
  196. package/dist/logging/types.d.ts +13 -45
  197. package/dist/{logging-B-kngi3q.js → logging-zOY1XCtq.js} +52 -141
  198. package/dist/{loopback-guard-D0Kc7-xc.js → loopback-guard-DT9gHF0F.js} +41 -92
  199. package/dist/mail/Mail.d.ts +10 -106
  200. package/dist/mail/MailManager.d.ts +2 -60
  201. package/dist/mail/index.js +1 -1
  202. package/dist/mail/transports/LogTransport.d.ts +1 -4
  203. package/dist/mail/transports/MemoryTransport.d.ts +1 -63
  204. package/dist/mail/transports/ResendTransport.d.ts +1 -23
  205. package/dist/mail/transports/SmtpTransport.d.ts +1 -31
  206. package/dist/mail/types.d.ts +28 -150
  207. package/dist/{mail-DfEfSQEr.js → mail-76DWy9lj.js} +31 -289
  208. package/dist/mcp/McpServiceProvider.d.ts +4 -10
  209. package/dist/mcp/create-mcp-server.d.ts +42 -57
  210. package/dist/mcp/endpoint.d.ts +12 -36
  211. package/dist/mcp/index.js +1 -1
  212. package/dist/mvc/Controller.d.ts +46 -227
  213. package/dist/mvc/Router.d.ts +50 -129
  214. package/dist/mvc/inertia/InertiaEngine.d.ts +18 -48
  215. package/dist/mvc/inertia/shared.d.ts +6 -19
  216. package/dist/mvc/mount-route.d.ts +2 -6
  217. package/dist/mvc/view.d.ts +1 -2
  218. package/dist/notifications/Notification.d.ts +8 -75
  219. package/dist/notifications/NotificationManager.d.ts +15 -88
  220. package/dist/notifications/channels/DatabaseChannel.d.ts +1 -41
  221. package/dist/notifications/channels/MailChannel.d.ts +2 -31
  222. package/dist/notifications/channels/MemoryChannel.d.ts +2 -62
  223. package/dist/notifications/channels/SlackChannel.d.ts +3 -48
  224. package/dist/notifications/index.js +1 -1
  225. package/dist/notifications/notifiable-type.d.ts +3 -6
  226. package/dist/notifications/registry.d.ts +8 -27
  227. package/dist/notifications/types.d.ts +16 -53
  228. package/dist/{notifications-BGqmUNZ8.js → notifications-okWFs9ly.js} +37 -335
  229. package/dist/providers/AuthServiceProvider.d.ts +1 -3
  230. package/dist/providers/AuthorizationServiceProvider.d.ts +2 -3
  231. package/dist/providers/BroadcastServiceProvider.d.ts +1 -3
  232. package/dist/providers/CacheServiceProvider.d.ts +1 -3
  233. package/dist/providers/EncryptionServiceProvider.d.ts +1 -3
  234. package/dist/providers/ErrorServiceProvider.d.ts +1 -4
  235. package/dist/providers/EventServiceProvider.d.ts +1 -3
  236. package/dist/providers/HealthServiceProvider.d.ts +1 -3
  237. package/dist/providers/I18nServiceProvider.d.ts +6 -10
  238. package/dist/providers/InertiaServiceProvider.d.ts +1 -4
  239. package/dist/providers/LogServiceProvider.d.ts +1 -3
  240. package/dist/providers/MailServiceProvider.d.ts +1 -3
  241. package/dist/providers/NotificationServiceProvider.d.ts +1 -3
  242. package/dist/providers/OAuthServiceProvider.d.ts +1 -3
  243. package/dist/providers/QueueServiceProvider.d.ts +1 -3
  244. package/dist/providers/SchedulingServiceProvider.d.ts +1 -3
  245. package/dist/providers/StorageServiceProvider.d.ts +1 -3
  246. package/dist/queue/FailedJobReporter.d.ts +1 -24
  247. package/dist/queue/Job.d.ts +12 -99
  248. package/dist/queue/QueueManager.d.ts +6 -57
  249. package/dist/queue/Worker.d.ts +4 -65
  250. package/dist/queue/drivers/MemoryDriver.d.ts +3 -44
  251. package/dist/queue/drivers/RedisDriver.d.ts +7 -65
  252. package/dist/queue/drivers/SqsDriver.d.ts +6 -57
  253. package/dist/queue/drivers/SyncDriver.d.ts +10 -13
  254. package/dist/queue/index.js +2 -2
  255. package/dist/queue/types.d.ts +10 -92
  256. package/dist/{queue-CXrRK85G.js → queue-CcXCjuJI.js} +32 -260
  257. package/dist/redis/RedisApiTokenStore.d.ts +4 -56
  258. package/dist/redis/RedisEmailVerificationStore.d.ts +4 -37
  259. package/dist/redis/RedisOAuthStateStore.d.ts +2 -10
  260. package/dist/redis/RedisPasswordResetStore.d.ts +4 -37
  261. package/dist/redis/RedisRateLimitStore.d.ts +16 -49
  262. package/dist/redis/RedisSessionStore.d.ts +3 -44
  263. package/dist/redis/client.d.ts +2 -32
  264. package/dist/redis/index.js +47 -232
  265. package/dist/redis/redis-values.d.ts +6 -12
  266. package/dist/redis/scan-keys.d.ts +1 -4
  267. package/dist/request-CLOYytGP.js +68 -0
  268. package/dist/runtime/index.d.ts +2 -0
  269. package/dist/runtime/index.js +50 -92
  270. package/dist/scheduling/CronParser.d.ts +0 -29
  271. package/dist/scheduling/Schedule.d.ts +1 -153
  272. package/dist/scheduling/ScheduledTask.d.ts +0 -31
  273. package/dist/scheduling/Scheduler.d.ts +0 -70
  274. package/dist/scheduling/index.js +1 -1
  275. package/dist/scheduling/types.d.ts +4 -65
  276. package/dist/{scheduling-CPiEdtQd.js → scheduling-C6tcOtUl.js} +2 -287
  277. package/dist/storage/StorageManager.d.ts +0 -48
  278. package/dist/storage/drivers/LocalDriver.d.ts +1 -25
  279. package/dist/storage/drivers/MemoryDriver.d.ts +5 -35
  280. package/dist/storage/drivers/S3Driver.d.ts +6 -36
  281. package/dist/storage/drivers/s3-acl.d.ts +5 -10
  282. package/dist/storage/index.js +1 -1
  283. package/dist/storage/types.d.ts +27 -265
  284. package/dist/{storage-TLD9t0Q2.js → storage-BB59f07j.js} +17 -157
  285. package/dist/support/contained-path.d.ts +10 -20
  286. package/dist/support/error-polyfill.d.ts +4 -6
  287. package/dist/support/expiry.d.ts +17 -33
  288. package/dist/support/expiry.js +17 -33
  289. package/dist/support/import-map.d.ts +3 -7
  290. package/dist/support/inertia-defaults.d.ts +5 -10
  291. package/dist/support/redirect-target.d.ts +4 -6
  292. package/dist/support/stack-frames.d.ts +11 -50
  293. package/dist/support/trim-slashes.d.ts +4 -7
  294. package/dist/support/warn-once.d.ts +2 -6
  295. package/dist/{trim-slashes-ZJ_VsY5s.js → trim-slashes-BLY9hKAa.js} +4 -7
  296. package/dist/{vite-manifest-w_RSOvQW.js → vite-manifest-B_Iy5183.js} +34 -58
  297. package/package.json +2 -2
  298. package/dist/client-Dd7vLcqp.js +0 -27
  299. package/dist/context-DoD0c7J_.js +0 -26
  300. package/dist/endpoint-D-20PiHY.js +0 -46
  301. package/dist/hot-disposables-WsTX2ySN.js +0 -281
  302. package/dist/request-CVQwpu2J.js +0 -129
@@ -1,9 +1,8 @@
1
1
  import type { Application } from './Application.js';
2
2
  import { type RootPublicAssetsConfig } from './public-assets.js';
3
3
  /**
4
- * Derive the mount point for the vendored Inertia client from its public
5
- * path: the containing directory (always slash-terminated), the Hono route
6
- * pattern for it, and the file's path relative to that base.
4
+ * The vendored Inertia client's mount point: containing directory (always
5
+ * slash-terminated), Hono route pattern, and the file's path relative to it.
7
6
  */
8
7
  export declare function resolveInertiaClientRoute(inertiaClientPath: string): {
9
8
  base: string;
@@ -13,13 +12,13 @@ export declare function resolveInertiaClientRoute(inertiaClientPath: string): {
13
12
  export interface DevAssetsOptions {
14
13
  /** Absolute path to the resources directory (e.g. `/app/resources`). */
15
14
  resourcesDir?: string;
16
- /** Base import meta used to resolve relative paths. */
15
+ /** Base import meta that relative paths resolve against. */
17
16
  importMeta?: ImportMeta;
18
17
  /** Relative path from `importMeta` to the resources directory. Defaults to `../resources`. */
19
18
  resourcesPath?: string;
20
19
  /** Path prefix to mount transpiled JS assets. Defaults to `/resources/js`. */
21
20
  prefix?: string;
22
- /** Route pattern used to serve raw CSS assets. Defaults to `/resources/css/*`. */
21
+ /** Route pattern serving raw CSS assets. Defaults to `/resources/css/*`. */
23
22
  cssRoute?: string;
24
23
  /** Absolute path to the CSS directory. Defaults to `<resourcesDir>/../css`. */
25
24
  cssDir?: string;
@@ -42,37 +41,20 @@ export interface DevAssetsOptions {
42
41
  /** Serve selected files from the public directory without the `/public` prefix. */
43
42
  rootPublicAssets?: RootPublicAssetsConfig;
44
43
  /**
45
- * Serve document types (`.svg`, `.html`, XML) from `/public/*` and
46
- * `/resources/css/*` inline instead of forcing them to download. Defaults to
47
- * false.
48
- *
49
- * Off by default because `public/` is also where an app's uploads land, and
50
- * a stored `.html` or `.svg` served inline is script in the app's own
51
- * origin. Turn it on for a public directory holding nothing user-supplied —
52
- * a static microsite under `public/docs/index.html`, say, which Hono resolves
53
- * from a directory request and would otherwise hand back as a download.
54
- *
55
- * The root-level allowlist route has its own switch,
56
- * `rootPublicAssets: { inlineDocuments: true }`; an app serving documents
57
- * both ways sets both.
44
+ * Serve document types (`.svg`, `.html`, XML) inline rather than as
45
+ * downloads. Off by default: `public/` is also where uploads land, and a
46
+ * stored `.html` or `.svg` served inline is script in the app's own origin.
47
+ * The root-level allowlist route has its own `rootPublicAssets:
48
+ * { inlineDocuments: true }`.
58
49
  */
59
50
  inlineDocuments?: boolean;
60
51
  }
61
52
  /**
62
- * Absolute path to `@guren/inertia-client`'s build output, the directory
63
- * production serves the vendored client and its chunks from.
64
- *
65
- * Unlike {@link resolveGurenInertiaClient}, this must not follow a tsconfig
66
- * `paths` mapping to the package's TypeScript sources — production serves
67
- * files, it cannot transpile them. So it anchors on `./package.json`, a
68
- * subpath such a mapping misses (there is no `src/package.json`) and real
69
- * package resolution answers with the package root.
53
+ * `@guren/inertia-client`'s build output. Anchored on `./package.json` rather
54
+ * than a code subpath, because production serves files and cannot transpile: a
55
+ * tsconfig `paths` mapping misses that subpath (there is no `src/package.json`)
56
+ * and real package resolution answers with the package root.
70
57
  */
71
58
  export declare function resolveInertiaClientDir(): string;
72
- /**
73
- * Registers development asset serving middleware.
74
- * @param app
75
- * @param options
76
- */
77
59
  export declare function registerDevAssets(app: Application, options: DevAssetsOptions): void;
78
60
  export declare function createStaticRewrite(route: string): (path: string) => string;
@@ -6,11 +6,8 @@ export interface DevBannerOptions {
6
6
  }
7
7
  /**
8
8
  * A wildcard bind answers on every interface but is not itself dialable on
9
- * every platform.
10
- *
11
- * Lives here rather than beside its other caller because the banner and
12
- * `Application.listen()`'s returned address are two renderings of one fact,
13
- * and a platform caveat added to only one of them is the drift this replaces.
9
+ * every platform. Shared with `Application.listen()`'s returned address, which
10
+ * is the same fact rendered twice.
14
11
  */
15
12
  export declare function isWildcardHost(hostname: string): boolean;
16
13
  /** `host:port`, bracketing an IPv6 literal so the result is dialable. */
@@ -20,12 +20,9 @@ export interface AutoConfigureInertiaOptions extends InertiaAssetsOptions {
20
20
  }
21
21
  export declare function configureInertiaAssets(app: Application, options: InertiaAssetsOptions): void;
22
22
  /**
23
- * Serves the built Inertia client and the chunks it imports out of the
24
- * resolved package directory.
25
- *
26
- * Split out of {@link configureInertiaAssets} so it can be pointed at a
27
- * directory: the caller derives `inertiaClientDir` from `import.meta.resolve`,
28
- * which no test can redirect at a fixture.
23
+ * Serves the built Inertia client and its chunks. Takes a directory rather than
24
+ * deriving one, because the caller's `import.meta.resolve` cannot be redirected
25
+ * at a fixture by a test.
29
26
  */
30
27
  export declare function registerBuiltInertiaClient(app: Application, inertiaClientDir: string, inertiaClientPath: string): void;
31
28
  export declare function autoConfigureInertiaAssets(app: Application, options: AutoConfigureInertiaOptions): void;
@@ -1,16 +1,10 @@
1
1
  import type { MiddlewareHandler } from 'hono';
2
2
  /**
3
- * Internal security-capability marker (RFC 0007).
4
- *
5
- * Built-in middleware factories stamp the handlers they return so tooling
6
- * that holds the real function objects (the router registry, `guren audit`
7
- * via route loading) can recognize what a handler enforces without name
8
- * heuristics. `Symbol.for()` keeps the key identical across duplicated
9
- * `@guren/server` copies in one process.
10
- *
11
- * Deliberately not part of the public API: nothing here is exported from
12
- * the package root, and the shape may change in any release. A public
13
- * `defineMiddleware` integration is future work in RFC 0007.
3
+ * Internal security-capability marker (RFC 0007): built-in middleware
4
+ * factories stamp their handlers so tooling can read what a chain enforces
5
+ * without name heuristics. `Symbol.for()` keeps the key identical across
6
+ * duplicated `@guren/server` copies in one process. Not public API — the
7
+ * shape may change in any release.
14
8
  */
15
9
  export declare const CAPABILITIES: unique symbol;
16
10
  export interface MiddlewareCapabilities {
@@ -24,55 +18,38 @@ export interface MiddlewareCapabilities {
24
18
  /**
25
19
  * Authorization enforced by the chain (RFC 0016 §4): what makes
26
20
  * route → ability derivable without reading controller bodies.
27
- *
28
- * - `abilities` — the ability names checked, in the order the chain
29
- * checks them. Empty when every check derives its ability at request
30
- * time (see `resource`), and also for the degenerate
31
- * `authorizeMiddleware([])`, which denies every request.
32
- * - `mode` — how they combine. `'all'` every listed ability must pass,
33
- * `'any'` at least one must. A list of exactly one normalizes to
34
- * `'all'`, because any-of one ability *is* that ability — and the
35
- * middleware treats it that way at runtime too, down to the denial
36
- * message. So `'any'` means either two or more alternatives, or the
37
- * degenerate empty list that denies every request. `'mixed'` means the
38
- * chain carries more than one check and the conjunction of them is not
39
- * expressible as either: authorization is present, but the ability is
40
- * *not* cleanly derivable, and a consumer must treat it as undetermined
41
- * rather than picking a name out of `abilities`. A single derivable
42
- * ability is `abilities.length === 1` with `mode: 'all'` and no
43
- * `resource`.
44
- * - `resource` — present when a check resolves its ability from the
45
- * request method (`authorizeResourceMiddleware`). `fromMethodMap: true`
46
- * means the built-in verb map decides, so a consumer holding the
47
- * route's method resolves the ability through
48
- * `resourceAbilityForMethod()` in `../../authorization/middleware`.
49
- * `false` means an `abilityFor` callback overrides that map and the
50
- * real ability is unknowable statically — fail closed, do not fall
51
- * back to the verb map.
52
21
  */
53
22
  authorization?: {
23
+ /**
24
+ * In check order. Empty when the ability is resolved at request time
25
+ * (see `resource`), and for `authorizeMiddleware([])`, which denies all.
26
+ */
54
27
  abilities: string[];
28
+ /**
29
+ * A single ability normalizes to `'all'`, so `'any'` means two or more
30
+ * alternatives (or the empty deny-all list). `'mixed'` means several
31
+ * checks whose conjunction is neither: authorization is present but the
32
+ * ability is *not* derivable — treat it as undetermined rather than
33
+ * reading a name out of `abilities`.
34
+ */
55
35
  mode: 'all' | 'any' | 'mixed';
36
+ /**
37
+ * Present when a check resolves its ability from the request method.
38
+ * `fromMethodMap` → resolve through `resourceAbilityForMethod()` in
39
+ * `../../authorization/middleware`; otherwise an `abilityFor` callback
40
+ * overrides the verb map and the ability is statically unknowable, so
41
+ * fail closed rather than falling back to it.
42
+ */
56
43
  resource?: {
57
44
  fromMethodMap: boolean;
58
45
  };
59
46
  };
60
47
  }
61
48
  /**
62
- * Fold one middleware's stamp into an accumulating aggregate, applying the
63
- * rules the type above states: `'required'` beats `'guest-only'`; abilities
64
- * union; two checks are a conjunction, so all-of + all-of stays `'all'` and
65
- * anything else becomes `'mixed'`; `fromMethodMap` ANDs, since one
66
- * non-authoritative check makes the verb map unusable for the whole chain.
67
- *
68
- * Mutates `into` and never `stamp` — nested objects and arrays are copied
69
- * the first time they are taken, so a later merge cannot write back through
70
- * the aggregate into a handler's stamp.
71
- *
72
- * Every call counts as an independent check. Folding the *same* stamp twice
73
- * would read as two of them and degrade an `'any'` to `'mixed'`, so
74
- * de-duplicating handlers that appear more than once in a chain is the
75
- * caller's job.
49
+ * Folds one middleware's stamp into an accumulating aggregate. Mutates `into`
50
+ * and never `stamp`. Every call counts as an independent check, so folding the
51
+ * *same* stamp twice degrades an `'any'` to `'mixed'` — de-duplicating handlers
52
+ * that appear more than once in a chain is the caller's job.
76
53
  */
77
54
  export declare function mergeCapabilities(into: MiddlewareCapabilities, stamp: MiddlewareCapabilities): void;
78
55
  export declare function stampCapabilities(handler: MiddlewareHandler, capabilities: MiddlewareCapabilities): MiddlewareHandler;
@@ -1,40 +1,15 @@
1
1
  import type { MiddlewareHandler } from 'hono';
2
2
  export interface CorsOptions {
3
- /**
4
- * Allowed origins. Default: none (same-origin policy applies).
5
- * - A string: exact origin match (use '*' to allow all origins)
6
- * - An array of strings: multiple allowed origins
7
- * - A function: dynamic origin evaluation
8
- */
3
+ /** Allowed origins. Default: none, so the same-origin policy applies. */
9
4
  origin?: string | string[] | ((origin: string, ctx: unknown) => string | undefined | null);
10
5
  /** Allowed HTTP methods. Default: ['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH', 'QUERY'] */
11
6
  allowMethods?: string[];
12
- /** Allowed request headers. */
13
7
  allowHeaders?: string[];
14
- /** Headers exposed to the browser. */
15
8
  exposeHeaders?: string[];
16
- /** Preflight cache max-age in seconds. */
9
+ /** Preflight cache, in seconds. */
17
10
  maxAge?: number;
18
- /** Allow credentials (cookies, authorization headers). Default: false */
11
+ /** Cookies and Authorization headers. Default: false */
19
12
  credentials?: boolean;
20
13
  }
21
- /**
22
- * CORS middleware powered by Hono's built-in CORS support.
23
- *
24
- * @example
25
- * ```ts
26
- * import { createCorsMiddleware } from '@guren/core'
27
- *
28
- * // Allow specific origins
29
- * app.use('/api/*', createCorsMiddleware({
30
- * origin: ['https://example.com', 'https://app.example.com'],
31
- * credentials: true,
32
- * }))
33
- *
34
- * // Dynamic origin
35
- * app.use('/api/*', createCorsMiddleware({
36
- * origin: (origin) => origin.endsWith('.example.com') ? origin : null,
37
- * }))
38
- * ```
39
- */
14
+ /** CORS middleware powered by Hono's built-in CORS support. */
40
15
  export declare function createCorsMiddleware(options?: CorsOptions): MiddlewareHandler;
@@ -21,7 +21,6 @@ export interface CspDirectives {
21
21
  [directive: string]: string[] | boolean | undefined;
22
22
  }
23
23
  export interface CspOptions {
24
- /** CSP directives configuration. */
25
24
  directives?: CspDirectives;
26
25
  /** Use Content-Security-Policy-Report-Only instead. Default: false */
27
26
  reportOnly?: boolean;
@@ -31,29 +30,7 @@ export interface CspOptions {
31
30
  useNonce?: boolean;
32
31
  }
33
32
  export declare const CSP_NONCE_KEY = "csp-nonce";
34
- /**
35
- * Retrieve the CSP nonce for the current request.
36
- * Only available when `useNonce: true` is set.
37
- */
33
+ /** Throws unless the middleware was configured with `useNonce: true`. */
38
34
  export declare function getCspNonce(ctx: Context): string;
39
- /**
40
- * Middleware that sets Content-Security-Policy headers.
41
- *
42
- * @example
43
- * ```ts
44
- * import { createCspMiddleware, getCspNonce } from '@guren/core'
45
- *
46
- * app.use('*', createCspMiddleware({
47
- * directives: {
48
- * defaultSrc: ["'self'"],
49
- * scriptSrc: ["'self'", 'https://cdn.example.com'],
50
- * styleSrc: ["'self'", "'unsafe-inline'"],
51
- * imgSrc: ["'self'", 'data:', 'https:'],
52
- * objectSrc: ["'none'"],
53
- * },
54
- * useNonce: true,
55
- * reportUri: '/csp-report',
56
- * }))
57
- * ```
58
- */
35
+ /** Middleware that sets Content-Security-Policy headers. */
59
36
  export declare function createCspMiddleware(options?: CspOptions): MiddlewareHandler;
@@ -5,31 +5,17 @@ export declare const XSRF_HEADER_NAME = "X-XSRF-TOKEN";
5
5
  export declare const XSRF_COOKIE_NAME = "XSRF-TOKEN";
6
6
  export declare const CSRF_FORM_FIELD = "_token";
7
7
  export interface CsrfOptions {
8
- /**
9
- * Routes to exclude from CSRF protection.
10
- * Supports exact paths ('/api/webhook') or patterns ('/api/*').
11
- */
8
+ /** Exact paths ('/api/webhook') or patterns ('/api/*'). */
12
9
  exclude?: string[];
13
- /**
14
- * Custom error handler when CSRF validation fails.
15
- * Defaults to returning a 403 JSON response.
16
- */
10
+ /** Defaults to a 403 JSON response. */
17
11
  onError?: (ctx: Context) => Response | Promise<Response>;
18
- /**
19
- * HTTP methods that require CSRF token validation.
20
- * Defaults to ['POST', 'PUT', 'PATCH', 'DELETE'].
21
- */
12
+ /** Defaults to ['POST', 'PUT', 'PATCH', 'DELETE']. */
22
13
  methods?: string[];
23
14
  /**
24
- * Set the CSRF token as an `XSRF-TOKEN` cookie on every response.
25
- * This enables Axios/Inertia.js to automatically read the cookie
26
- * and send it back as the `X-XSRF-TOKEN` header.
27
- * Defaults to true.
15
+ * Set the token as an `XSRF-TOKEN` cookie, which Axios/Inertia read back into
16
+ * the `X-XSRF-TOKEN` header. Defaults to true.
28
17
  */
29
18
  cookie?: boolean;
30
- /**
31
- * Cookie options when `cookie` is enabled.
32
- */
33
19
  cookieOptions?: {
34
20
  path?: string;
35
21
  secure?: boolean;
@@ -37,88 +23,35 @@ export interface CsrfOptions {
37
23
  };
38
24
  }
39
25
  /**
40
- * Get the request's CSRF token.
41
- *
42
- * Signed token bound to the session when a stable one exists, otherwise a
43
- * stateless signed double-submit token for guests. Nothing is stored
44
- * server-side, so anonymous page views cost no session writes. A cookie
45
- * token that is still valid for this request's mode is reused; otherwise a
46
- * fresh token is minted and set on the response by the middleware.
47
- *
48
- * The answer tracks the session as it stands *at the moment of the call*,
49
- * because a handler can change it: log a user in and the correct token stops
50
- * being the guest one it would have got a line earlier. A token cached from
51
- * before that point would be rendered into the response body while the
52
- * response cookie carried a session-bound one, and `verifyCsrfToken` would
53
- * then reject the form on submit. So the per-request cache is keyed by the
54
- * mode it was issued for, and re-issues when the mode moves — which also
55
- * makes re-reads free, since the common case is that nothing changed.
26
+ * Read per request, not snapshotted: this middleware is created in
27
+ * `AuthServiceProvider.register()`, while an endpoint that declares itself
28
+ * mounts at `boot`. A separate argument, not a {@link CsrfOptions} field: an
29
+ * app fills those in, and there this would be a second `exclude` carrying none
30
+ * of the review a declaring endpoint's own code is what supplies.
56
31
  */
57
- export declare function getCsrfToken(ctx: Context): string;
32
+ export type CookielessAuthEndpoints = () => ReadonlySet<string>;
58
33
  /**
59
- * Generate an HTML hidden input field containing the CSRF token.
34
+ * The request's CSRF token: bound to the session when a stable one exists,
35
+ * otherwise a stateless signed double-submit token. Nothing is stored
36
+ * server-side. The per-request cache is keyed by the *mode* it was issued for,
37
+ * because a handler can log a user in mid-request — a token cached from before
38
+ * that would be rendered into the body while the cookie carried a bound one.
60
39
  */
40
+ export declare function getCsrfToken(ctx: Context): string;
61
41
  export declare function csrfField(ctx: Context): string;
62
42
  /**
63
- * Verify a request token.
64
- *
65
- * The token must first carry a valid app-key signature (proving this server
66
- * minted it). The mode is then fixed by the request — whether it carries a
67
- * bindable session — and the token has to be in that mode:
68
- * - **Session-bound** (request has a session; token must carry a matching
69
- * `sid`): immune to cookie injection — a sibling-subdomain attacker can
70
- * plant a cookie but cannot know the victim's session id. A stateless
71
- * token is rejected here, which is the point: anyone can mint one.
72
- * - **Stateless** (request has no session, so no `sid`): the token must match the `XSRF-TOKEN`
73
- * cookie (double-submit). Guests hold no authenticated state to protect.
74
- *
75
- * Legacy fallback: tokens stored in sessions by earlier releases keep
76
- * verifying against the session until those sessions expire. Remove this
77
- * branch once all pre-upgrade sessions have aged out (a major release).
43
+ * The token must carry a valid app-key signature, and be in the mode the
44
+ * *request* fixes: session-bound needs a matching `sid` (a sibling-subdomain
45
+ * attacker can plant a cookie but cannot know the session id; a stateless
46
+ * token, which anyone can mint, is rejected); stateless must match the
47
+ * `XSRF-TOKEN` cookie. TODO: drop the legacy session-stored fallback in a major release.
78
48
  */
79
49
  export declare function verifyCsrfToken(ctx: Context, token: string | undefined): boolean;
80
50
  /**
81
- * Creates a CSRF protection middleware.
82
- *
83
- * This middleware:
84
- * - Issues a signed token in the `XSRF-TOKEN` cookie on safe requests.
85
- * With a logged-in session the token is bound to the session id; for
86
- * guests it is a stateless double-submit token. Nothing is stored
87
- * server-side, so anonymous traffic costs no session writes and session
88
- * middleware is optional.
89
- * - Validates the token for state-changing HTTP methods (POST, PUT, PATCH,
90
- * DELETE): always requires a valid app-key signature, then the bound
91
- * session id or (guest) the cookie match.
92
- * - Supports token submission via form field (_token) or header (X-CSRF-TOKEN)
93
- * - Keeps verifying tokens stored in sessions by earlier releases until
94
- * those sessions expire
95
- * - Exempts the dev-only MCP endpoint while it is mounted, since agent
96
- * clients cannot fetch a token first (it guards local-only access instead)
97
- * - Skips verification for `Authorization: Bearer` requests that carry no
98
- * cookies (RFC 0016) — token clients authenticate per request and hold no
99
- * cookie ambient authority for CSRF to defend
100
- *
101
- * `cookie: false` disables the `XSRF-TOKEN` cookie for apps that deliver the
102
- * token themselves (meta tag / form field). Session-bound tokens still
103
- * verify without the cookie; guest (stateless) tokens require the cookie, so
104
- * disable it only for session-authenticated flows.
105
- *
106
- * **Mount it directly inside the session middleware.** The response cookie is
107
- * settled once the handler returns, reading the session id as it stands then.
108
- * Middleware layered *between* the two that mutates the session after its own
109
- * `await next()` — regenerating or invalidating it — moves the id after this
110
- * has already committed to a token, and the next mutation is rejected. The
111
- * automatic registration in `AuthServiceProvider` mounts them adjacently;
112
- * hand-composed chains have to keep that property.
113
- *
114
- * @example
115
- * ```ts
116
- * import { createCsrfMiddleware } from '@guren/server'
117
- *
118
- * app.use(createSessionMiddleware())
119
- * app.use(createCsrfMiddleware({
120
- * exclude: ['/api/webhooks/*']
121
- * }))
122
- * ```
51
+ * Issues a signed `XSRF-TOKEN` on safe requests and verifies it on state-changing
52
+ * ones (`_token`, `X-CSRF-TOKEN` / `X-XSRF-TOKEN`), skipping cookie-less bearer
53
+ * requests (RFC 0016) and seam-marked ones (RFC 0017). `cookie: false` suits
54
+ * session flows only. **Mount directly inside the session middleware:** anything
55
+ * between that mutates the session after `await next()` moves the id too late.
123
56
  */
124
- export declare function createCsrfMiddleware(options?: CsrfOptions): MiddlewareHandler;
57
+ export declare function createCsrfMiddleware(options?: CsrfOptions, cookielessAuthEndpoints?: CookielessAuthEndpoints): MiddlewareHandler;
@@ -7,15 +7,9 @@ export type TranslatorBinding = {
7
7
  t: Translator['t'];
8
8
  tc: Translator['tc'];
9
9
  };
10
- /**
11
- * Read the request locale resolved by {@link detectLocaleMiddleware} (or any
12
- * middleware that sets the `locale` context variable).
13
- */
10
+ /** Reads the `locale` context variable, whoever set it. */
14
11
  export declare function getRequestLocale(c: Context): string | undefined;
15
- /**
16
- * Read the request-scoped `t`/`tc` translator bound by
17
- * {@link detectLocaleMiddleware}, when present.
18
- */
12
+ /** The request-scoped translator bound by {@link detectLocaleMiddleware}. */
19
13
  export declare function getRequestTranslator(c: Context): TranslatorBinding | undefined;
20
14
  export type LocaleSource = 'query' | 'cookie' | 'header';
21
15
  /** Context variables set by {@link detectLocaleMiddleware}, for typing Hono apps. */
@@ -36,29 +30,15 @@ export interface DetectLocaleOptions {
36
30
  /** Cookie to read (defaults to `locale`). */
37
31
  cookieName?: string;
38
32
  /**
39
- * i18n manager used to bind request-scoped `t`/`tc` translator helpers.
40
- * Defaults to the global manager when one was registered via `setI18n()`;
41
- * pass a manager explicitly (e.g. `app.container.make('i18n')`), or `false`
42
- * to skip the translator binding entirely.
33
+ * Manager backing the request-scoped `t`/`tc` helpers. Defaults to the
34
+ * global one registered via `setI18n()`; `false` skips the binding.
43
35
  */
44
36
  i18n?: I18nManager | false;
45
37
  }
46
38
  /**
47
- * Middleware that resolves the request locale from the query string, a cookie,
48
- * or the `Accept-Language` header — in that order by default — restricted to
49
- * the `supported` allowlist.
50
- *
51
- * The result is stored as the `locale` context variable, which Inertia
52
- * responses pick up for the root `<html lang>` attribute. When an i18n manager
53
- * is available (see the `i18n` option), request-scoped `t`/`tc` translator
54
- * helpers are attached as well.
55
- *
56
- * @example
57
- * ```ts
58
- * import { detectLocaleMiddleware } from '@guren/core'
59
- *
60
- * app.use('*', detectLocaleMiddleware({ supported: ['en', 'ja'] }))
61
- * ```
39
+ * Resolves the request locale from the query string, a cookie, or
40
+ * `Accept-Language`, restricted to the `supported` allowlist, and stores it as
41
+ * the `locale` context variable that Inertia reads for `<html lang>`.
62
42
  */
63
43
  export declare function detectLocaleMiddleware(options: DetectLocaleOptions): import("hono").MiddlewareHandler<{
64
44
  Variables: DetectLocaleVariables;
@@ -1,34 +1,16 @@
1
1
  import type { MiddlewareHandler } from 'hono';
2
2
  export interface ForceHttpsOptions {
3
- /**
4
- * HSTS max-age in seconds. Default: 31536000 (1 year).
5
- */
3
+ /** Seconds. Default: 31536000 (1 year). */
6
4
  hstsMaxAge?: number;
7
- /**
8
- * Include subdomains in HSTS. Default: true.
9
- */
5
+ /** Default: true. */
10
6
  hstsIncludeSubDomains?: boolean;
11
- /**
12
- * Enable HSTS preload. Default: false.
13
- */
7
+ /** Default: false. */
14
8
  hstsPreload?: boolean;
15
- /**
16
- * Paths to exclude from HTTPS redirect (e.g., health checks).
17
- */
9
+ /** Paths exempt from the redirect; a trailing `*` matches a prefix. */
18
10
  exclude?: string[];
19
11
  }
20
12
  /**
21
- * Middleware that redirects HTTP requests to HTTPS and sets the
22
- * Strict-Transport-Security header. Equivalent to Rails' `force_ssl`.
23
- *
24
- * @example
25
- * ```ts
26
- * import { createForceHttpsMiddleware } from '@guren/core'
27
- *
28
- * // In production only
29
- * if (process.env.NODE_ENV === 'production') {
30
- * app.use('*', createForceHttpsMiddleware())
31
- * }
32
- * ```
13
+ * Redirects HTTP to HTTPS and sets Strict-Transport-Security. Equivalent to
14
+ * Rails' `force_ssl`.
33
15
  */
34
16
  export declare function createForceHttpsMiddleware(options?: ForceHttpsOptions): MiddlewareHandler;
@@ -8,17 +8,7 @@ export interface HostAuthorizationOptions {
8
8
  onError?: (ctx: Context) => Response | Promise<Response>;
9
9
  }
10
10
  /**
11
- * Middleware that validates the Host header against an allowed list.
12
- * Protects against DNS rebinding and host header attacks.
13
- *
14
- * @example
15
- * ```ts
16
- * import { createHostAuthorizationMiddleware } from '@guren/core'
17
- *
18
- * app.use('*', createHostAuthorizationMiddleware({
19
- * allowedHosts: ['example.com', '*.example.com', 'localhost:3000'],
20
- * exclude: ['/healthcheck'],
21
- * }))
22
- * ```
11
+ * Validates the Host header against an allowed list, guarding against DNS
12
+ * rebinding and host header attacks.
23
13
  */
24
14
  export declare function createHostAuthorizationMiddleware(options: HostAuthorizationOptions): MiddlewareHandler;
@@ -5,7 +5,7 @@ export declare function jsonResponse(data: unknown, status?: number): Response;
5
5
  export { createSessionMiddleware, MemorySessionStore, getSessionFromContext } from './session.js';
6
6
  export type { Session, SessionData, SessionStore } from './session.js';
7
7
  export { requireAuthenticated, requireGuest, attachAuthContext, type AuthContext, type RequireAuthOptions, } from './auth.js';
8
- export { createCsrfMiddleware, getCsrfToken, csrfField, verifyCsrfToken, CSRF_TOKEN_KEY, CSRF_HEADER_NAME, CSRF_FORM_FIELD, XSRF_HEADER_NAME, XSRF_COOKIE_NAME, type CsrfOptions, } from './csrf.js';
8
+ export { createCsrfMiddleware, getCsrfToken, csrfField, verifyCsrfToken, CSRF_TOKEN_KEY, CSRF_HEADER_NAME, CSRF_FORM_FIELD, XSRF_HEADER_NAME, XSRF_COOKIE_NAME, type CsrfOptions, type CookielessAuthEndpoints, } from './csrf.js';
9
9
  export { validateRequest, validateRequestWith, getValidatedData, validate, validateSafe, VALIDATED_DATA_KEY, type ValidationSchema, type ValidateRequestOptions, } from './validation.js';
10
10
  export { createRateLimitMiddleware, getRateLimitInfo, resetRateLimit, MemoryRateLimitStore, SlidingWindowRateLimitStore, type RateLimitOptions, type RateLimitStore, type RateLimitEntry, type RateLimitInfo, } from './rate-limit.js';
11
11
  export { createSecurityHeaders, type SecurityHeadersOptions, type HstsOptions, } from './security-headers.js';
@@ -1,35 +1,20 @@
1
1
  /**
2
2
  * Loopback-only access guard shared by the dev-only framework endpoints
3
- * (`/_guren/mcp`, `/_guren/docs`).
4
- *
5
- * Two classes of caller have to be stopped (see
6
- * `.claude/rules/common-pitfalls.md`): browser pages, rejected unless
7
- * their `Origin` is loopback (which also defeats DNS rebinding), and
8
- * non-browser clients, rejected unless the socket peer is loopback —
9
- * templates bind `0.0.0.0` and `Host` is trivially forged, so host
10
- * authorization does not help, and a client that sends no `Origin` is
11
- * otherwise indistinguishable from a local process.
12
- *
13
- * The guard fails closed. A request is served only once the runtime has
14
- * reported a loopback peer; if it reports no peer at all, the request is
15
- * denied rather than waved through, because "no `Origin` and no peer" is
16
- * exactly the shape of a remote `curl`. Runtimes that cannot report a peer
17
- * (Node, or any host calling `app.fetch()` directly instead of
18
- * `Application.listen()`) need `GUREN_ALLOW_UNVERIFIED_PEER=1`, which the
19
- * denial names.
3
+ * (`/_guren/mcp`, `/_guren/docs`). Two classes of caller are stopped (see
4
+ * `.claude/rules/common-pitfalls.md`): browser pages, rejected unless `Origin`
5
+ * is loopback (also defeats DNS rebinding), and non-browser clients, rejected
6
+ * unless the socket peer is loopback — templates bind `0.0.0.0`, `Host` is
7
+ * trivially forged, and a client sending no `Origin` looks like a local process.
8
+ * Fails closed: no reported peer is denied ("no `Origin`, no peer" is a remote
9
+ * `curl`); peer-less runtimes (Node, `app.fetch()`) need `GUREN_ALLOW_UNVERIFIED_PEER=1`.
20
10
  */
21
11
  import type { MiddlewareHandler } from 'hono';
22
12
  /**
23
13
  * Whether an `Origin` header value belongs to the developer's own machine.
24
- *
25
- * Non-browser clients send no `Origin` at all; a value only appears when a
26
- * web page made the request. Restricting those to loopback blocks both
27
- * ordinary cross-site requests and DNS rebinding, where an attacker's
28
- * domain resolves to 127.0.0.1 so the browser skips preflight.
29
- *
30
- * This is a *negative* filter only. A loopback `Origin` is never proof that
31
- * the caller is local: browsers set the header honestly, but any other
32
- * client sets it with one flag. Never use it to satisfy the peer check.
14
+ * Only a web page's request carries one; restricting it to loopback blocks
15
+ * cross-site requests and DNS rebinding (an attacker's domain resolving to
16
+ * 127.0.0.1 so the browser skips preflight). A *negative* filter only: any
17
+ * non-browser client sets the header with one flag, so never use it to satisfy the peer check.
33
18
  */
34
19
  export declare function isLoopbackOrigin(origin: string): boolean;
35
20
  /**
@@ -40,12 +25,9 @@ export declare function isLoopbackOrigin(origin: string): boolean;
40
25
  */
41
26
  export declare function isLoopbackAddress(address: string): boolean;
42
27
  /**
43
- * Restricts an endpoint to the developer's own machine. `resource` names
44
- * the endpoint in the 403 body (e.g. "the MCP endpoint").
45
- *
46
- * Three outcomes, and the two denials say different things on purpose:
47
- * a peer that is present and not loopback is a remote caller, while a peer
48
- * the runtime never reported is a deployment the guard cannot vouch for —
49
- * the developer needs to know which one they are looking at.
28
+ * Restricts an endpoint to the developer's own machine. `resource` names the
29
+ * endpoint in the 403 body (e.g. "the MCP endpoint"). The two denials say
30
+ * different things on purpose: a present non-loopback peer is a remote caller,
31
+ * a peer the runtime never reported is a deployment the guard cannot vouch for.
50
32
  */
51
33
  export declare function createLoopbackGuard(resource: string): MiddlewareHandler;