@guren/server 2.1.1 → 2.2.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 (270) hide show
  1. package/dist/{McpServiceProvider-7BB5FPF3.js → McpServiceProvider-GRDYNEQG.js} +1 -1
  2. package/dist/auth/AuthManager.d.ts +30 -0
  3. package/dist/auth/AuthenticatableModel.d.ts +25 -0
  4. package/dist/auth/RequestAuthContext.d.ts +24 -0
  5. package/dist/auth/SessionGuard.d.ts +31 -0
  6. package/dist/auth/api-token.d.ts +299 -0
  7. package/dist/auth/email-verification.d.ts +203 -0
  8. package/dist/auth/index.d.ts +18 -110
  9. package/dist/auth/index.js +3 -1
  10. package/dist/auth/oauth/index.d.ts +239 -0
  11. package/dist/auth/password/DefaultHasher.d.ts +13 -0
  12. package/dist/auth/password/NodeHasher.d.ts +22 -0
  13. package/dist/auth/password/PasswordHasher.d.ts +5 -0
  14. package/dist/auth/password/ScryptHasher.d.ts +26 -0
  15. package/dist/auth/password-reset.d.ts +91 -0
  16. package/dist/auth/providers/ModelUserProvider.d.ts +36 -0
  17. package/dist/auth/providers/UserProvider.d.ts +9 -0
  18. package/dist/auth/types.d.ts +102 -0
  19. package/dist/auth/utils.d.ts +39 -0
  20. package/dist/{Gate-CynjZCtS.d.ts → authorization/Gate.d.ts} +30 -111
  21. package/dist/authorization/Policy.d.ts +77 -0
  22. package/dist/authorization/index.d.ts +5 -129
  23. package/dist/authorization/index.js +3 -1
  24. package/dist/authorization/middleware.d.ts +49 -0
  25. package/dist/authorization/types.d.ts +108 -0
  26. package/dist/broadcasting/BroadcastManager.d.ts +205 -0
  27. package/dist/broadcasting/channels/Channel.d.ts +28 -0
  28. package/dist/broadcasting/channels/PresenceChannel.d.ts +72 -0
  29. package/dist/broadcasting/channels/PrivateChannel.d.ts +32 -0
  30. package/dist/broadcasting/channels/index.d.ts +3 -0
  31. package/dist/broadcasting/drivers/MemoryDriver.d.ts +93 -0
  32. package/dist/broadcasting/drivers/RedisDriver.d.ts +112 -0
  33. package/dist/broadcasting/drivers/index.d.ts +2 -0
  34. package/dist/broadcasting/index.d.ts +6 -233
  35. package/dist/broadcasting/index.js +1 -1
  36. package/dist/broadcasting/typed.d.ts +23 -0
  37. package/dist/broadcasting/types.d.ts +155 -0
  38. package/dist/cache/CacheManager.d.ts +87 -0
  39. package/dist/cache/TaggedCache.d.ts +62 -0
  40. package/dist/cache/index.d.ts +6 -233
  41. package/dist/cache/index.js +1 -1
  42. package/dist/cache/stores/FileStore.d.ts +64 -0
  43. package/dist/cache/stores/MemoryStore.d.ts +52 -0
  44. package/dist/cache/stores/RedisStore.d.ts +53 -0
  45. package/dist/{CacheManager-BmDzUKrF.d.ts → cache/types.d.ts} +26 -99
  46. package/dist/{chunk-TVY72CLV.js → chunk-4VE3LYOM.js} +3 -2
  47. package/dist/{chunk-FZD2AKJI.js → chunk-7OB2YXRE.js} +56 -28
  48. package/dist/{chunk-J6ETA476.js → chunk-BUQXOZCT.js} +93 -5
  49. package/dist/{chunk-DSDX3ASM.js → chunk-CDZUNKI6.js} +65 -83
  50. package/dist/{chunk-CWI4AJ47.js → chunk-HPET6XY5.js} +13 -9
  51. package/dist/{chunk-A3ISJVEV.js → chunk-HR2KZ3WL.js} +23 -5
  52. package/dist/{chunk-5SZTEZ22.js → chunk-PZKUDFMW.js} +11 -8
  53. package/dist/console/Command.d.ts +179 -0
  54. package/dist/{ConsoleKernel-CJg975mp.d.ts → console/ConsoleKernel.d.ts} +4 -6
  55. package/dist/console/Input.d.ts +140 -0
  56. package/dist/console/Output.d.ts +161 -0
  57. package/dist/console/index.d.ts +5 -0
  58. package/dist/console/types.d.ts +106 -0
  59. package/dist/container/Container.d.ts +148 -0
  60. package/dist/container/ServiceProvider.d.ts +103 -0
  61. package/dist/container/bindings.d.ts +55 -0
  62. package/dist/container/defineModule.d.ts +88 -0
  63. package/dist/container/definePlugin.d.ts +62 -0
  64. package/dist/container/index.d.ts +8 -0
  65. package/dist/container/types.d.ts +73 -0
  66. package/dist/database/Factory.d.ts +82 -0
  67. package/dist/database/Seeder.d.ts +35 -0
  68. package/dist/database/SeederRunner.d.ts +41 -0
  69. package/dist/database/index.d.ts +4 -0
  70. package/dist/database/types.d.ts +49 -0
  71. package/dist/discovery/AutoDiscovery.d.ts +113 -0
  72. package/dist/discovery/index.d.ts +2 -0
  73. package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +12 -0
  74. package/dist/docs-viewer/endpoint.d.ts +19 -0
  75. package/dist/encryption/Encrypter.d.ts +96 -0
  76. package/dist/encryption/Hash.d.ts +69 -0
  77. package/dist/encryption/MessageSigner.d.ts +21 -0
  78. package/dist/encryption/Random.d.ts +119 -0
  79. package/dist/encryption/app-key.d.ts +12 -0
  80. package/dist/encryption/index.d.ts +10 -222
  81. package/dist/encryption/signed-url.d.ts +9 -0
  82. package/dist/encryption/types.d.ts +103 -0
  83. package/dist/errors/ExceptionHandler.d.ts +118 -0
  84. package/dist/errors/HttpException.d.ts +106 -0
  85. package/dist/errors/debug-page.d.ts +22 -0
  86. package/dist/errors/error-page.d.ts +1 -0
  87. package/dist/errors/exceptions/AuthenticationException.d.ts +32 -0
  88. package/dist/errors/exceptions/AuthorizationException.d.ts +32 -0
  89. package/dist/errors/exceptions/MethodNotAllowedException.d.ts +31 -0
  90. package/dist/errors/exceptions/NotFoundHttpException.d.ts +36 -0
  91. package/dist/errors/exceptions/ValidationException.d.ts +60 -0
  92. package/dist/errors/exceptions/index.d.ts +5 -0
  93. package/dist/errors/index.d.ts +5 -0
  94. package/dist/errors/types.d.ts +43 -0
  95. package/dist/events/Event.d.ts +33 -0
  96. package/dist/{EventManager-CmIoLt7r.d.ts → events/EventManager.d.ts} +4 -86
  97. package/dist/events/Listener.d.ts +79 -0
  98. package/dist/events/builtin.d.ts +73 -0
  99. package/dist/events/index.d.ts +6 -155
  100. package/dist/events/types.d.ts +48 -0
  101. package/dist/facades/index.d.ts +31 -0
  102. package/dist/health/HealthCheck.d.ts +34 -0
  103. package/dist/health/HealthManager.d.ts +53 -0
  104. package/dist/health/checks/CacheCheck.d.ts +35 -0
  105. package/dist/health/checks/CustomCheck.d.ts +23 -0
  106. package/dist/health/checks/DatabaseCheck.d.ts +33 -0
  107. package/dist/health/checks/MemoryCheck.d.ts +32 -0
  108. package/dist/health/checks/RedisCheck.d.ts +27 -0
  109. package/dist/health/checks/StorageCheck.d.ts +35 -0
  110. package/dist/health/checks/index.d.ts +12 -0
  111. package/dist/health/index.d.ts +5 -185
  112. package/dist/health/types.d.ts +52 -0
  113. package/dist/hot-reload/hot-disposables.d.ts +96 -0
  114. package/dist/hot-reload/testing.d.ts +14 -0
  115. package/dist/http/Application.d.ts +187 -0
  116. package/dist/http/FormRequest.d.ts +73 -0
  117. package/dist/http/dev-assets.d.ts +51 -0
  118. package/dist/http/dev-banner.d.ts +7 -0
  119. package/dist/http/inertia-assets.d.ts +22 -0
  120. package/dist/http/middleware/auth.d.ts +13 -0
  121. package/dist/http/middleware/capabilities.d.ts +22 -0
  122. package/dist/http/middleware/cors.d.ts +40 -0
  123. package/dist/http/middleware/csp.d.ts +59 -0
  124. package/dist/http/middleware/csrf.d.ts +121 -0
  125. package/dist/http/middleware/detect-locale.d.ts +65 -0
  126. package/dist/http/middleware/force-https.d.ts +34 -0
  127. package/dist/http/middleware/host-authorization.d.ts +24 -0
  128. package/dist/http/middleware/index.d.ts +19 -0
  129. package/dist/http/middleware/loopback-guard.d.ts +38 -0
  130. package/dist/{rate-limit-D9J2b4S1.d.ts → http/middleware/rate-limit.d.ts} +22 -50
  131. package/dist/http/middleware/redirect-safety.d.ts +29 -0
  132. package/dist/http/middleware/request-id.d.ts +19 -0
  133. package/dist/http/middleware/request-logging.d.ts +16 -0
  134. package/dist/http/middleware/security-headers.d.ts +49 -0
  135. package/dist/http/middleware/session.d.ts +93 -0
  136. package/dist/http/middleware/validation.d.ts +94 -0
  137. package/dist/http/public-assets.d.ts +15 -0
  138. package/dist/http/request.d.ts +24 -0
  139. package/dist/http/resources/CursorPaginator.d.ts +106 -0
  140. package/dist/http/resources/Paginator.d.ts +130 -0
  141. package/dist/http/resources/Resource.d.ts +67 -0
  142. package/dist/http/resources/ResourceCollection.d.ts +60 -0
  143. package/dist/http/resources/index.d.ts +6 -0
  144. package/dist/http/resources/types.d.ts +91 -0
  145. package/dist/http/validation/Validator.d.ts +128 -0
  146. package/dist/http/validation/index.d.ts +3 -0
  147. package/dist/http/validation/rules.d.ts +196 -0
  148. package/dist/http/validation/types.d.ts +96 -0
  149. package/dist/http/vite-dev-server.d.ts +27 -0
  150. package/dist/i18n/I18nManager.d.ts +114 -0
  151. package/dist/i18n/Translator.d.ts +80 -0
  152. package/dist/i18n/index.d.ts +6 -101
  153. package/dist/i18n/index.js +5 -3
  154. package/dist/i18n/loaders/JsonLoader.d.ts +47 -0
  155. package/dist/i18n/loaders/MemoryLoader.d.ts +37 -0
  156. package/dist/i18n/pluralization.d.ts +19 -0
  157. package/dist/i18n/types.d.ts +106 -0
  158. package/dist/index.d.ts +69 -2605
  159. package/dist/index.js +332 -152
  160. package/dist/lambda/index.d.ts +17 -37
  161. package/dist/logging/LogManager.d.ts +83 -0
  162. package/dist/logging/Logger.d.ts +76 -0
  163. package/dist/logging/channels/ConsoleChannel.d.ts +11 -0
  164. package/dist/logging/channels/DailyFileChannel.d.ts +20 -0
  165. package/dist/logging/channels/FileChannel.d.ts +15 -0
  166. package/dist/logging/index.d.ts +8 -50
  167. package/dist/logging/types.d.ts +96 -0
  168. package/dist/mail/Mail.d.ts +138 -0
  169. package/dist/mail/MailManager.d.ts +79 -0
  170. package/dist/mail/address.d.ts +8 -0
  171. package/dist/mail/index.d.ts +7 -316
  172. package/dist/mail/transports/LogTransport.d.ts +19 -0
  173. package/dist/mail/transports/MemoryTransport.d.ts +84 -0
  174. package/dist/mail/transports/ResendTransport.d.ts +32 -0
  175. package/dist/mail/transports/SmtpTransport.d.ts +40 -0
  176. package/dist/{MailManager-DpMvYiP9.d.ts → mail/types.d.ts} +11 -92
  177. package/dist/mcp/McpServiceProvider.d.ts +17 -0
  178. package/dist/mcp/create-mcp-server.d.ts +144 -0
  179. package/dist/mcp/endpoint.d.ts +29 -0
  180. package/dist/mcp/index.d.ts +3 -185
  181. package/dist/mcp/index.js +1 -1
  182. package/dist/mvc/Controller.d.ts +326 -0
  183. package/dist/mvc/Router.d.ts +239 -0
  184. package/dist/mvc/ViewEngine.d.ts +11 -0
  185. package/dist/mvc/inertia/InertiaEngine.d.ts +114 -0
  186. package/dist/mvc/inertia/shared.d.ts +90 -0
  187. package/dist/mvc/mount-route.d.ts +10 -0
  188. package/dist/notifications/Notification.d.ts +99 -0
  189. package/dist/notifications/NotificationManager.d.ts +150 -0
  190. package/dist/notifications/channels/DatabaseChannel.d.ts +55 -0
  191. package/dist/notifications/channels/MailChannel.d.ts +45 -0
  192. package/dist/notifications/channels/MemoryChannel.d.ts +85 -0
  193. package/dist/notifications/channels/SlackChannel.d.ts +73 -0
  194. package/dist/notifications/channels/index.d.ts +4 -0
  195. package/dist/notifications/index.d.ts +6 -322
  196. package/dist/notifications/notifiable-type.d.ts +10 -0
  197. package/dist/notifications/registry.d.ts +39 -0
  198. package/dist/notifications/types.d.ts +162 -0
  199. package/dist/providers/AuthServiceProvider.d.ts +7 -0
  200. package/dist/providers/AuthorizationServiceProvider.d.ts +9 -0
  201. package/dist/providers/BroadcastServiceProvider.d.ts +7 -0
  202. package/dist/providers/CacheServiceProvider.d.ts +7 -0
  203. package/dist/providers/EncryptionServiceProvider.d.ts +7 -0
  204. package/dist/providers/ErrorServiceProvider.d.ts +9 -0
  205. package/dist/providers/EventServiceProvider.d.ts +7 -0
  206. package/dist/providers/HealthServiceProvider.d.ts +7 -0
  207. package/dist/providers/I18nServiceProvider.d.ts +27 -0
  208. package/dist/providers/InertiaServiceProvider.d.ts +20 -0
  209. package/dist/providers/LogServiceProvider.d.ts +7 -0
  210. package/dist/providers/MailServiceProvider.d.ts +7 -0
  211. package/dist/providers/NotificationServiceProvider.d.ts +8 -0
  212. package/dist/providers/OAuthServiceProvider.d.ts +7 -0
  213. package/dist/providers/QueueServiceProvider.d.ts +7 -0
  214. package/dist/providers/SchedulingServiceProvider.d.ts +7 -0
  215. package/dist/providers/StorageServiceProvider.d.ts +7 -0
  216. package/dist/providers/index.d.ts +17 -0
  217. package/dist/queue/FailedJobReporter.d.ts +40 -0
  218. package/dist/queue/Job.d.ts +140 -0
  219. package/dist/queue/QueueManager.d.ts +79 -0
  220. package/dist/queue/Worker.d.ts +99 -0
  221. package/dist/queue/drivers/MemoryDriver.d.ts +60 -0
  222. package/dist/queue/drivers/RedisDriver.d.ts +96 -0
  223. package/dist/queue/drivers/SqsDriver.d.ts +108 -0
  224. package/dist/queue/drivers/SyncDriver.d.ts +28 -0
  225. package/dist/queue/index.d.ts +9 -453
  226. package/dist/queue/types.d.ts +171 -0
  227. package/dist/redis/RedisApiTokenStore.d.ts +78 -0
  228. package/dist/redis/RedisEmailVerificationStore.d.ts +54 -0
  229. package/dist/redis/RedisOAuthStateStore.d.ts +26 -0
  230. package/dist/redis/RedisPasswordResetStore.d.ts +57 -0
  231. package/dist/redis/RedisRateLimitStore.d.ts +77 -0
  232. package/dist/redis/RedisSessionStore.d.ts +61 -0
  233. package/dist/redis/client.d.ts +41 -0
  234. package/dist/redis/index.d.ts +14 -356
  235. package/dist/redis/index.js +5 -2
  236. package/dist/redis/scan-keys.d.ts +6 -0
  237. package/dist/runtime/index.d.ts +8 -95
  238. package/dist/runtime/index.js +1 -1
  239. package/dist/scheduling/CronParser.d.ts +37 -0
  240. package/dist/scheduling/Schedule.d.ts +229 -0
  241. package/dist/scheduling/ScheduledTask.d.ts +47 -0
  242. package/dist/scheduling/Scheduler.d.ts +99 -0
  243. package/dist/scheduling/index.d.ts +5 -41
  244. package/dist/scheduling/types.d.ts +97 -0
  245. package/dist/storage/StorageManager.d.ts +65 -0
  246. package/dist/storage/drivers/LocalDriver.d.ts +55 -0
  247. package/dist/storage/drivers/MemoryDriver.d.ts +66 -0
  248. package/dist/storage/drivers/S3Driver.d.ts +72 -0
  249. package/dist/storage/index.d.ts +5 -197
  250. package/dist/{StorageManager-oZTHqaza.d.ts → storage/types.d.ts} +10 -77
  251. package/dist/support/error-polyfill.d.ts +9 -0
  252. package/dist/support/import-map.d.ts +13 -0
  253. package/dist/support/redirect-target.d.ts +11 -0
  254. package/dist/support/stack-frames.d.ts +56 -0
  255. package/dist/support/trim-slashes.d.ts +11 -0
  256. package/dist/vite/index.d.ts +2 -35
  257. package/dist/vite/index.js +0 -3
  258. package/dist/vite/plugin.d.ts +34 -0
  259. package/package.json +3 -3
  260. package/dist/AuthManager-DBP4KYsx.d.ts +0 -79
  261. package/dist/BroadcastManager-D8KoJxiV.d.ts +0 -492
  262. package/dist/HealthManager-DUyMIzsZ.d.ts +0 -141
  263. package/dist/I18nManager-BiSoczfV.d.ts +0 -275
  264. package/dist/LogManager-7mxnkaPM.d.ts +0 -256
  265. package/dist/Scheduler-pZiT8i57.d.ts +0 -471
  266. package/dist/api-token-D24VPr_E.d.ts +0 -663
  267. package/dist/app-key-CsBfRC_Q.d.ts +0 -214
  268. package/dist/email-verification-Dx426KLn.d.ts +0 -336
  269. package/dist/index-9_Jzj5jo.d.ts +0 -7
  270. package/dist/validation-yAL53e1S.d.ts +0 -2610
package/dist/index.js CHANGED
@@ -2,7 +2,7 @@ import {
2
2
  logDevServerBanner,
3
3
  parseImportMap,
4
4
  startViteDevServer
5
- } from "./chunk-5SZTEZ22.js";
5
+ } from "./chunk-PZKUDFMW.js";
6
6
  import {
7
7
  PendingSchedule,
8
8
  Schedule,
@@ -42,8 +42,9 @@ import {
42
42
  selectPluralForm,
43
43
  setI18n,
44
44
  t,
45
- tc
46
- } from "./chunk-A3ISJVEV.js";
45
+ tc,
46
+ tryGetI18n
47
+ } from "./chunk-HR2KZ3WL.js";
47
48
  import {
48
49
  ConsoleChannel,
49
50
  DailyFileChannel,
@@ -134,6 +135,7 @@ import {
134
135
  MemorySessionStore,
135
136
  ModelUserProvider,
136
137
  NodeHasher,
138
+ OAUTH_SESSION_BINDING_KEY,
137
139
  OAuthManager,
138
140
  ScryptHasher,
139
141
  SessionGuard,
@@ -178,7 +180,7 @@ import {
178
180
  verifyEmailToken,
179
181
  verifyOAuthState,
180
182
  verifyPasswordResetToken
181
- } from "./chunk-J6ETA476.js";
183
+ } from "./chunk-BUQXOZCT.js";
182
184
  import {
183
185
  Gate,
184
186
  Policy,
@@ -195,7 +197,7 @@ import {
195
197
  getGate,
196
198
  setGate,
197
199
  withAuthorization
198
- } from "./chunk-FZD2AKJI.js";
200
+ } from "./chunk-7OB2YXRE.js";
199
201
  import {
200
202
  AuthorizationException,
201
203
  ExceptionHandler,
@@ -228,7 +230,7 @@ import {
228
230
  getBroadcastManager,
229
231
  parseRequestPayload,
230
232
  setBroadcastManager
231
- } from "./chunk-TVY72CLV.js";
233
+ } from "./chunk-4VE3LYOM.js";
232
234
  import {
233
235
  CacheManager,
234
236
  FileStore,
@@ -236,7 +238,7 @@ import {
236
238
  RedisStore,
237
239
  TaggedCache,
238
240
  createCacheManager
239
- } from "./chunk-CWI4AJ47.js";
241
+ } from "./chunk-HPET6XY5.js";
240
242
  import {
241
243
  claimHotDisposable,
242
244
  isHotReloadRuntime,
@@ -904,11 +906,11 @@ async function resolveModelBindings(c, modelBindings, path) {
904
906
  const params = c.req.param();
905
907
  const pathParams = path?.match(/:([a-zA-Z0-9_-]+)/g)?.map((p) => p.slice(1)) ?? [];
906
908
  for (const param of pathParams) {
907
- const resolver2 = modelBindings.get(param);
908
- if (!resolver2) continue;
909
+ const resolver = modelBindings.get(param);
910
+ if (!resolver) continue;
909
911
  const value = params[param];
910
912
  if (value !== void 0) {
911
- const model = await resolver2(value);
913
+ const model = await resolver(value);
912
914
  resolved.push(model);
913
915
  }
914
916
  }
@@ -1032,7 +1034,10 @@ function randomNonce() {
1032
1034
  return Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
1033
1035
  }
1034
1036
  function bindableSessionId(session) {
1035
- return session && !session.isNew ? session.id : void 0;
1037
+ if (!session) {
1038
+ return void 0;
1039
+ }
1040
+ return session.willPersist?.() ?? !session.isNew ? session.id : void 0;
1036
1041
  }
1037
1042
  function mintCsrfToken(sessionId) {
1038
1043
  const signer = createCsrfSigner();
@@ -1042,7 +1047,10 @@ function verifiedClaims(token) {
1042
1047
  return createCsrfSigner().verify(token, { purpose: CSRF_PURPOSE });
1043
1048
  }
1044
1049
  function claimsUsableFor(claims, boundId) {
1045
- return claims.sid !== void 0 ? claims.sid === boundId : boundId === void 0;
1050
+ if (claims.sid === void 0) {
1051
+ return boundId === void 0;
1052
+ }
1053
+ return boundId !== void 0 && secureCompare(claims.sid, boundId);
1046
1054
  }
1047
1055
  function matchesPattern(path, pattern) {
1048
1056
  if (pattern.endsWith("/*")) {
@@ -1058,21 +1066,23 @@ function isMcpEndpointRequest(path) {
1058
1066
  return path === MCP_ENDPOINT_PATH && isMcpEndpointEnabled();
1059
1067
  }
1060
1068
  function getCsrfToken(ctx) {
1061
- const pending = ctx.get(CSRF_CONTEXT_KEY);
1062
- if (pending) {
1063
- return pending;
1064
- }
1065
1069
  const boundId = bindableSessionId(getSessionFromContext(ctx));
1070
+ const issued = ctx.get(CSRF_CONTEXT_KEY);
1071
+ if (issued && issued.boundId === boundId) {
1072
+ return issued.token;
1073
+ }
1074
+ return remember(ctx, reusableCookieToken(ctx, boundId) ?? mintCsrfToken(boundId), boundId);
1075
+ }
1076
+ function reusableCookieToken(ctx, boundId) {
1066
1077
  const cookieToken = getCookie(ctx, XSRF_COOKIE_NAME);
1067
- if (cookieToken) {
1068
- const claims = verifiedClaims(cookieToken);
1069
- if (claims && claimsUsableFor(claims, boundId)) {
1070
- ctx.set(CSRF_CONTEXT_KEY, cookieToken);
1071
- return cookieToken;
1072
- }
1078
+ if (!cookieToken) {
1079
+ return void 0;
1073
1080
  }
1074
- const token = mintCsrfToken(boundId);
1075
- ctx.set(CSRF_CONTEXT_KEY, token);
1081
+ const claims = verifiedClaims(cookieToken);
1082
+ return claims && claimsUsableFor(claims, boundId) ? cookieToken : void 0;
1083
+ }
1084
+ function remember(ctx, token, boundId) {
1085
+ ctx.set(CSRF_CONTEXT_KEY, { token, boundId });
1076
1086
  return token;
1077
1087
  }
1078
1088
  function csrfField(ctx) {
@@ -1084,17 +1094,13 @@ function verifyCsrfToken(ctx, token) {
1084
1094
  return false;
1085
1095
  }
1086
1096
  const claims = verifiedClaims(token);
1087
- if (claims) {
1097
+ if (claims && claimsUsableFor(claims, bindableSessionId(getSessionFromContext(ctx)))) {
1088
1098
  if (claims.sid !== void 0) {
1089
- const boundId = bindableSessionId(getSessionFromContext(ctx));
1090
- if (boundId !== void 0 && secureCompare(claims.sid, boundId)) {
1091
- return true;
1092
- }
1093
- } else {
1094
- const cookieToken = getCookie(ctx, XSRF_COOKIE_NAME);
1095
- if (cookieToken && secureCompare(token, cookieToken)) {
1096
- return true;
1097
- }
1099
+ return true;
1100
+ }
1101
+ const cookieToken = getCookie(ctx, XSRF_COOKIE_NAME);
1102
+ if (cookieToken && secureCompare(token, cookieToken)) {
1103
+ return true;
1098
1104
  }
1099
1105
  }
1100
1106
  const sessionToken = getSessionFromContext(ctx)?.get(CSRF_TOKEN_KEY);
@@ -1143,19 +1149,22 @@ function createCsrfMiddleware(options = {}) {
1143
1149
  cookieOptions = {}
1144
1150
  } = options;
1145
1151
  const protectedMethods = new Set(methods.map((m) => m.toUpperCase()));
1152
+ const settleCookie = (ctx) => {
1153
+ if (enableCookie) {
1154
+ setXsrfCookie(ctx, getCsrfToken(ctx), cookieOptions);
1155
+ }
1156
+ };
1146
1157
  return async (ctx, next) => {
1147
1158
  const method = ctx.req.method.toUpperCase();
1148
1159
  const path = new URL(ctx.req.url).pathname;
1149
1160
  if (!protectedMethods.has(method)) {
1150
- const token = getCsrfToken(ctx);
1151
1161
  await next();
1152
- if (enableCookie) {
1153
- setXsrfCookie(ctx, token, cookieOptions);
1154
- }
1162
+ settleCookie(ctx);
1155
1163
  return;
1156
1164
  }
1157
1165
  if (isExcluded(path, exclude) || isMcpEndpointRequest(path)) {
1158
1166
  await next();
1167
+ settleCookie(ctx);
1159
1168
  return;
1160
1169
  }
1161
1170
  const requestToken = await getTokenFromRequest(ctx);
@@ -1167,9 +1176,7 @@ function createCsrfMiddleware(options = {}) {
1167
1176
  return jsonResponse({ message: "CSRF token mismatch" }, 403);
1168
1177
  }
1169
1178
  await next();
1170
- if (enableCookie) {
1171
- setXsrfCookie(ctx, getCsrfToken(ctx), cookieOptions);
1172
- }
1179
+ settleCookie(ctx);
1173
1180
  };
1174
1181
  }
1175
1182
  function setXsrfCookie(ctx, token, options = {}) {
@@ -1232,15 +1239,8 @@ function validateSafe(schema, data) {
1232
1239
 
1233
1240
  // src/http/middleware/rate-limit.ts
1234
1241
  var BaseMemoryStore = class {
1235
- cleanupInterval;
1236
- /**
1237
- * This store's claim on its hot-reload slot, if it holds one.
1238
- *
1239
- * Unlike the cache sweep, this interval is not `unref()`ed, so a leaked one
1240
- * both duplicates work and keeps the process alive on its own.
1241
- */
1242
- hotReloadClaim;
1243
- constructor(cleanupIntervalMs = 6e4) {
1242
+ constructor(cleanupIntervalMs = 6e4, now = () => Date.now()) {
1243
+ this.now = now;
1244
1244
  if (cleanupIntervalMs <= 0) {
1245
1245
  return;
1246
1246
  }
@@ -1252,6 +1252,15 @@ var BaseMemoryStore = class {
1252
1252
  () => this.destroy()
1253
1253
  );
1254
1254
  }
1255
+ now;
1256
+ cleanupInterval;
1257
+ /**
1258
+ * This store's claim on its hot-reload slot, if it holds one.
1259
+ *
1260
+ * Unlike the cache sweep, this interval is not `unref()`ed, so a leaked one
1261
+ * both duplicates work and keeps the process alive on its own.
1262
+ */
1263
+ hotReloadClaim;
1255
1264
  destroy() {
1256
1265
  if (this.cleanupInterval) {
1257
1266
  clearInterval(this.cleanupInterval);
@@ -1265,14 +1274,14 @@ var MemoryRateLimitStore = class extends BaseMemoryStore {
1265
1274
  async get(key) {
1266
1275
  const entry = this.entries.get(key);
1267
1276
  if (!entry) return null;
1268
- if (Date.now() >= entry.resetAt) {
1277
+ if (this.now() >= entry.resetAt) {
1269
1278
  this.entries.delete(key);
1270
1279
  return null;
1271
1280
  }
1272
1281
  return entry;
1273
1282
  }
1274
1283
  async increment(key, windowMs) {
1275
- const now = Date.now();
1284
+ const now = this.now();
1276
1285
  const existing = this.entries.get(key);
1277
1286
  if (existing && now < existing.resetAt) {
1278
1287
  existing.count++;
@@ -1286,7 +1295,7 @@ var MemoryRateLimitStore = class extends BaseMemoryStore {
1286
1295
  this.entries.delete(key);
1287
1296
  }
1288
1297
  cleanup() {
1289
- const now = Date.now();
1298
+ const now = this.now();
1290
1299
  for (const [key, entry] of this.entries.entries()) {
1291
1300
  if (now >= entry.resetAt) {
1292
1301
  this.entries.delete(key);
@@ -1353,13 +1362,19 @@ function createRateLimitMiddleware(options = {}) {
1353
1362
  windowMs = 6e4,
1354
1363
  trustProxy = false,
1355
1364
  keyGenerator = trustProxy ? proxyAwareKeyGenerator : defaultKeyGenerator,
1356
- store = getDefaultStore(),
1365
+ // An injected clock must drive the default store too, or expiry would run
1366
+ // on real time while Retry-After runs on the fake clock. The shared default
1367
+ // store stays on real time, so build a dedicated store instead — without
1368
+ // auto-cleanup, since a real-time sweep is meaningless on a fake clock and
1369
+ // its interval would outlive tests.
1370
+ store = options.now ? new MemoryRateLimitStore(0, options.now) : getDefaultStore(),
1357
1371
  skip,
1358
1372
  onRateLimited,
1359
1373
  headers = true,
1360
1374
  message = "Too many requests, please try again later.",
1361
1375
  statusCode = 429,
1362
- keyPrefix = "rl:"
1376
+ keyPrefix = "rl:",
1377
+ now = () => Date.now()
1363
1378
  } = options;
1364
1379
  return async (ctx, next) => {
1365
1380
  if (skip && await skip(ctx)) {
@@ -1369,7 +1384,7 @@ function createRateLimitMiddleware(options = {}) {
1369
1384
  const key = `${keyPrefix}${baseKey}`;
1370
1385
  const entry = await store.increment(key, windowMs);
1371
1386
  const remaining = Math.max(0, limit - entry.count);
1372
- const resetSeconds = Math.ceil((entry.resetAt - Date.now()) / 1e3);
1387
+ const resetSeconds = Math.max(0, Math.ceil((entry.resetAt - now()) / 1e3));
1373
1388
  if (headers) {
1374
1389
  ctx.header("X-RateLimit-Limit", limit.toString());
1375
1390
  ctx.header("X-RateLimit-Remaining", remaining.toString());
@@ -1416,7 +1431,7 @@ var SlidingWindowRateLimitStore = class extends BaseMemoryStore {
1416
1431
  async get(key) {
1417
1432
  const entry = this.requests.get(key);
1418
1433
  if (!entry || entry.timestamps.length === 0) return null;
1419
- const now = Date.now();
1434
+ const now = this.now();
1420
1435
  const windowStart = now - entry.windowMs;
1421
1436
  const timestamps = entry.timestamps.filter((t2) => t2 > windowStart);
1422
1437
  if (timestamps.length === 0) {
@@ -1429,7 +1444,7 @@ var SlidingWindowRateLimitStore = class extends BaseMemoryStore {
1429
1444
  return { count: timestamps.length, resetAt: timestamps[0] + entry.windowMs };
1430
1445
  }
1431
1446
  async increment(key, windowMs) {
1432
- const now = Date.now();
1447
+ const now = this.now();
1433
1448
  const windowStart = now - windowMs;
1434
1449
  const entry = this.requests.get(key);
1435
1450
  let timestamps = entry ? entry.timestamps.filter((t2) => t2 > windowStart) : [];
@@ -1441,7 +1456,7 @@ var SlidingWindowRateLimitStore = class extends BaseMemoryStore {
1441
1456
  this.requests.delete(key);
1442
1457
  }
1443
1458
  cleanup() {
1444
- const now = Date.now();
1459
+ const now = this.now();
1445
1460
  for (const [key, entry] of this.requests.entries()) {
1446
1461
  const windowStart = now - entry.windowMs;
1447
1462
  const valid = entry.timestamps.filter((t2) => t2 > windowStart);
@@ -1754,6 +1769,16 @@ import { createMiddleware as createMiddleware3 } from "hono/factory";
1754
1769
  import { getCookie as getCookie2 } from "hono/cookie";
1755
1770
  import { parseAccept } from "hono/utils/accept";
1756
1771
  var LOCALE_CONTEXT_KEY = "locale";
1772
+ function getRequestLocale(c) {
1773
+ const locale = c.var?.[LOCALE_CONTEXT_KEY];
1774
+ return typeof locale === "string" && locale.length > 0 ? locale : void 0;
1775
+ }
1776
+ function getRequestTranslator(c) {
1777
+ const vars = c.var;
1778
+ const t2 = vars?.["t"];
1779
+ const tc2 = vars?.["tc"];
1780
+ return typeof t2 === "function" && typeof tc2 === "function" ? { t: t2, tc: tc2 } : void 0;
1781
+ }
1757
1782
  var DEFAULT_SOURCES = ["query", "cookie", "header"];
1758
1783
  function detectLocaleMiddleware(options) {
1759
1784
  const supported = options.supported.map((locale) => locale.trim()).filter(Boolean);
@@ -1788,26 +1813,20 @@ function detectLocaleMiddleware(options) {
1788
1813
  return void 0;
1789
1814
  };
1790
1815
  const translators = /* @__PURE__ */ new Map();
1791
- const resolveTranslator = async (locale) => {
1792
- if (options.i18n === false) {
1793
- return void 0;
1794
- }
1816
+ const supportedSet = new Set(supported);
1817
+ const bindingFor = (locale, i18n) => {
1795
1818
  const cached = translators.get(locale);
1796
1819
  if (cached) {
1797
1820
  return cached;
1798
1821
  }
1799
- const i18n = options.i18n ?? tryGlobalI18n();
1800
- if (!i18n) {
1801
- return void 0;
1802
- }
1803
- await i18n.loadLocale(locale).catch(() => {
1804
- });
1805
1822
  const translator = i18n.forLocale(locale);
1806
1823
  const binding = {
1807
1824
  t: translator.t.bind(translator),
1808
1825
  tc: translator.tc.bind(translator)
1809
1826
  };
1810
- translators.set(locale, binding);
1827
+ if (supportedSet.has(locale) && i18n.isLocaleLoaded(locale)) {
1828
+ translators.set(locale, binding);
1829
+ }
1811
1830
  return binding;
1812
1831
  };
1813
1832
  return createMiddleware3(async (c, next) => {
@@ -1825,21 +1844,17 @@ function detectLocaleMiddleware(options) {
1825
1844
  }
1826
1845
  }
1827
1846
  c.set(LOCALE_CONTEXT_KEY, resolved);
1828
- const binding = await resolveTranslator(resolved);
1829
- if (binding) {
1830
- c.set("t", binding.t);
1831
- c.set("tc", binding.tc);
1847
+ const i18n = options.i18n === false ? void 0 : options.i18n ?? tryGetI18n();
1848
+ if (i18n) {
1849
+ await i18n.loadLocale(resolved).catch(() => {
1850
+ });
1851
+ const current = () => bindingFor(getRequestLocale(c) ?? resolved, i18n);
1852
+ c.set("t", (key, replacements) => current().t(key, replacements));
1853
+ c.set("tc", (key, count, replacements) => current().tc(key, count, replacements));
1832
1854
  }
1833
1855
  await next();
1834
1856
  });
1835
1857
  }
1836
- function tryGlobalI18n() {
1837
- try {
1838
- return getI18n();
1839
- } catch {
1840
- return void 0;
1841
- }
1842
- }
1843
1858
 
1844
1859
  // src/http/middleware/index.ts
1845
1860
  function defineMiddleware(handler) {
@@ -2009,6 +2024,163 @@ var ErrorServiceProvider = class extends ServiceProvider {
2009
2024
  }
2010
2025
  };
2011
2026
 
2027
+ // src/mvc/inertia/shared.ts
2028
+ var INERTIA_SHARED_PROPS_BINDING = "inertia.sharedProps";
2029
+ var registrationSequence = 0;
2030
+ var SharedInertiaPropsRegistry = class {
2031
+ resolvers = [];
2032
+ /** Replace every resolver registered in this scope. */
2033
+ set(resolverFn) {
2034
+ this.resolvers = resolverFn ? [orderedResolver(resolverFn)] : [];
2035
+ }
2036
+ /**
2037
+ * Register additional shared props without replacing resolvers registered
2038
+ * earlier — the new resolver's props are merged over the previous ones.
2039
+ */
2040
+ share(resolverFn) {
2041
+ this.resolvers.push(orderedResolver(resolverFn));
2042
+ }
2043
+ /** The resolvers registered in this scope, ordered by registration. */
2044
+ entries() {
2045
+ return this.resolvers;
2046
+ }
2047
+ /**
2048
+ * The scope's registrations composed into one resolver, or null when empty.
2049
+ * The composition is a snapshot: resolvers registered later are not picked up.
2050
+ */
2051
+ get() {
2052
+ if (this.resolvers.length === 0) return null;
2053
+ if (this.resolvers.length === 1) return this.resolvers[0].resolve;
2054
+ const snapshot = [...this.resolvers];
2055
+ return (ctx) => applyResolvers(snapshot, ctx);
2056
+ }
2057
+ async resolve(ctx) {
2058
+ return applyResolvers(this.resolvers, ctx);
2059
+ }
2060
+ };
2061
+ function orderedResolver(resolverFn) {
2062
+ return {
2063
+ seq: registrationSequence++,
2064
+ resolve: resolverFn
2065
+ };
2066
+ }
2067
+ async function applyResolvers(entries, ctx) {
2068
+ const merged = {};
2069
+ for (const entry of entries) {
2070
+ const props = await entry.resolve(ctx);
2071
+ if (props && typeof props === "object") {
2072
+ Object.assign(merged, props);
2073
+ }
2074
+ }
2075
+ return merged;
2076
+ }
2077
+ var globalRegistry = new SharedInertiaPropsRegistry();
2078
+ function scopedRegistry(container) {
2079
+ if (!container?.has?.(INERTIA_SHARED_PROPS_BINDING)) return null;
2080
+ return container.make(INERTIA_SHARED_PROPS_BINDING);
2081
+ }
2082
+ function ensureSharedInertiaPropsRegistry(container) {
2083
+ const existing = scopedRegistry(container);
2084
+ if (existing) return existing;
2085
+ const registry = new SharedInertiaPropsRegistry();
2086
+ container.instance(INERTIA_SHARED_PROPS_BINDING, registry);
2087
+ return registry;
2088
+ }
2089
+ function setInertiaSharedProps(resolverFn) {
2090
+ globalRegistry.set(resolverFn);
2091
+ }
2092
+ function getInertiaSharedPropsResolver() {
2093
+ return globalRegistry.get();
2094
+ }
2095
+ function shareInertiaProps(resolverFn, container) {
2096
+ const registry = container ? ensureSharedInertiaPropsRegistry(container) : globalRegistry;
2097
+ registry.share(resolverFn);
2098
+ }
2099
+ async function resolveSharedInertiaProps(ctx, container) {
2100
+ const scoped = scopedRegistry(container);
2101
+ if (!scoped) return globalRegistry.resolve(ctx);
2102
+ const globalEntries = globalRegistry.entries();
2103
+ if (globalEntries.length === 0) return scoped.resolve(ctx);
2104
+ const ordered = [...globalEntries, ...scoped.entries()].sort((a, b) => a.seq - b.seq);
2105
+ return applyResolvers(ordered, ctx);
2106
+ }
2107
+
2108
+ // src/providers/I18nServiceProvider.ts
2109
+ var I18nServiceProvider = class extends ServiceProvider {
2110
+ register() {
2111
+ const app = this.application();
2112
+ const options = app?.i18nOptions;
2113
+ if (options) {
2114
+ if (options.supported.length === 0) {
2115
+ throw new Error("createApp({ i18n }) requires at least one supported locale.");
2116
+ }
2117
+ if (options.fallback && !options.supported.includes(options.fallback)) {
2118
+ throw new Error(
2119
+ `createApp({ i18n }): fallback locale '${options.fallback}' must be one of the supported locales (${options.supported.join(", ")}).`
2120
+ );
2121
+ }
2122
+ }
2123
+ this.container.singleton("i18n", () => {
2124
+ if (!options) {
2125
+ return createI18n({ locale: "en" });
2126
+ }
2127
+ const fallback = options.fallback ?? options.supported[0];
2128
+ return createI18n({
2129
+ locale: fallback,
2130
+ fallbackLocale: fallback,
2131
+ path: options.loader ? void 0 : options.path ?? "lang",
2132
+ loader: options.loader
2133
+ });
2134
+ });
2135
+ if (app && options && options.detect !== false) {
2136
+ const manager = this.container.make("i18n");
2137
+ app.use("*", detectLocaleMiddleware({
2138
+ ...options.detect,
2139
+ supported: options.supported,
2140
+ fallback: manager.getLocale(),
2141
+ i18n: manager
2142
+ }));
2143
+ }
2144
+ }
2145
+ async boot() {
2146
+ const options = this.application()?.i18nOptions;
2147
+ if (!options) return;
2148
+ const manager = this.container.make("i18n");
2149
+ await manager.loadLocales([...options.supported]);
2150
+ for (const locale of options.supported) {
2151
+ if (Object.keys(manager.getMessages(locale)).length === 0) {
2152
+ console.warn(
2153
+ `[guren] i18n: no translations loaded for locale '${locale}'` + (options.loader ? "." : ` \u2014 expected ${options.path ?? "lang"}/${locale}/*.json.`)
2154
+ );
2155
+ }
2156
+ }
2157
+ if (options.share !== false) {
2158
+ const fallback = manager.getFallbackLocale() ?? manager.getLocale();
2159
+ const supported = new Set(options.supported);
2160
+ const propsByLocale = /* @__PURE__ */ new Map();
2161
+ shareInertiaProps((ctx) => {
2162
+ const locale = getRequestLocale(ctx) ?? fallback;
2163
+ let i18nProps = propsByLocale.get(locale);
2164
+ if (!i18nProps) {
2165
+ i18nProps = {
2166
+ locale,
2167
+ fallbackLocale: fallback,
2168
+ messages: manager.messagesForLocale(locale)
2169
+ };
2170
+ if (supported.has(locale)) {
2171
+ propsByLocale.set(locale, i18nProps);
2172
+ }
2173
+ }
2174
+ return { _i18n: i18nProps };
2175
+ }, this.container);
2176
+ }
2177
+ }
2178
+ /** The provider works standalone on a bare container (no `app` binding). */
2179
+ application() {
2180
+ return this.container.has("app") ? this.container.make("app") : void 0;
2181
+ }
2182
+ };
2183
+
2012
2184
  // src/mvc/inertia/InertiaEngine.ts
2013
2185
  import { isAbsolute, resolve as resolvePath } from "path";
2014
2186
  import { pathToFileURL } from "url";
@@ -2317,31 +2489,6 @@ var ViewEngine = class {
2317
2489
  }
2318
2490
  };
2319
2491
 
2320
- // src/mvc/inertia/shared.ts
2321
- var resolver = null;
2322
- function setInertiaSharedProps(resolverFn) {
2323
- resolver = resolverFn;
2324
- }
2325
- function getInertiaSharedPropsResolver() {
2326
- return resolver;
2327
- }
2328
- function shareInertiaProps(resolverFn) {
2329
- const previous = resolver;
2330
- resolver = async (ctx) => {
2331
- const prev = previous ? await previous(ctx) : {};
2332
- const next = await resolverFn(ctx);
2333
- return { ...prev, ...next };
2334
- };
2335
- }
2336
- async function resolveSharedInertiaProps(ctx) {
2337
- if (!resolver) return {};
2338
- const shared = await resolver(ctx);
2339
- if (shared && typeof shared === "object") {
2340
- return shared;
2341
- }
2342
- return {};
2343
- }
2344
-
2345
2492
  // src/providers/InertiaServiceProvider.ts
2346
2493
  var InertiaServiceProvider = class extends ServiceProvider {
2347
2494
  register() {
@@ -2391,19 +2538,16 @@ var InertiaServiceProvider = class extends ServiceProvider {
2391
2538
  });
2392
2539
  }
2393
2540
  /**
2394
- * Wrap existing shared props resolver to auto-inject flashed `errors`.
2541
+ * Auto-inject flashed `errors` into shared props. Scoped to this app's
2542
+ * container so a second Application booted in the same process keeps its
2543
+ * own registrations.
2395
2544
  */
2396
2545
  registerSharedErrors() {
2397
- const previous = getInertiaSharedPropsResolver();
2398
- setInertiaSharedProps(async (ctx) => {
2399
- const prev = previous ? await previous(ctx) : {};
2546
+ shareInertiaProps(async (ctx) => {
2400
2547
  const session = getSessionFromContext(ctx);
2401
2548
  const errors = session?.getFlash("errors");
2402
- return {
2403
- ...prev,
2404
- ...errors && Object.keys(errors).length > 0 ? { errors } : {}
2405
- };
2406
- });
2549
+ return errors && Object.keys(errors).length > 0 ? { errors } : {};
2550
+ }, this.container);
2407
2551
  }
2408
2552
  };
2409
2553
 
@@ -2508,19 +2652,17 @@ var Application = class {
2508
2652
  ...Array.isArray(this.options.providers) ? this.options.providers : [],
2509
2653
  ...moduleProviders
2510
2654
  ];
2511
- const hasUserErrorProvider = userProviders.some(
2512
- (provider) => provider === ErrorServiceProvider || provider.prototype instanceof ErrorServiceProvider
2513
- );
2514
- if (!hasUserErrorProvider) {
2655
+ const hasUserProviderOf = (base) => userProviders.some((provider) => provider === base || provider.prototype instanceof base);
2656
+ if (this.options.i18n && !hasUserProviderOf(I18nServiceProvider)) {
2657
+ this.providerManager.register(I18nServiceProvider);
2658
+ }
2659
+ if (!hasUserProviderOf(ErrorServiceProvider)) {
2515
2660
  this.providerManager.register(ErrorServiceProvider);
2516
2661
  }
2517
2662
  if (userProviders.length > 0) {
2518
2663
  this.providerManager.registerMany(userProviders);
2519
2664
  }
2520
- const hasUserInertiaProvider = userProviders.some(
2521
- (provider) => provider === InertiaServiceProvider || provider.prototype instanceof InertiaServiceProvider
2522
- );
2523
- if (!hasUserInertiaProvider) {
2665
+ if (!hasUserProviderOf(InertiaServiceProvider)) {
2524
2666
  this.providerManager.register(InertiaServiceProvider);
2525
2667
  }
2526
2668
  }
@@ -2542,6 +2684,9 @@ var Application = class {
2542
2684
  get authOptions() {
2543
2685
  return this.options.auth;
2544
2686
  }
2687
+ get i18nOptions() {
2688
+ return this.options.i18n;
2689
+ }
2545
2690
  markAutoSessionAttached() {
2546
2691
  this.autoSessionAttached = true;
2547
2692
  }
@@ -2579,7 +2724,7 @@ var Application = class {
2579
2724
  await this.mountRoutes();
2580
2725
  await this.mountDevEndpoint(
2581
2726
  isMcpEndpointEnabled(),
2582
- async () => (await import("./McpServiceProvider-7BB5FPF3.js")).McpServiceProvider,
2727
+ async () => (await import("./McpServiceProvider-GRDYNEQG.js")).McpServiceProvider,
2583
2728
  "GUREN_MCP=1 but the MCP endpoint could not load \u2014 is @modelcontextprotocol/sdk installed?"
2584
2729
  );
2585
2730
  await this.mountDevEndpoint(
@@ -2653,7 +2798,7 @@ var Application = class {
2653
2798
  const { server: server2, localUrl } = await startViteDevServer({
2654
2799
  root: viteOptions?.root ?? process.cwd(),
2655
2800
  config: viteOptions?.config,
2656
- host: viteOptions?.host ?? true,
2801
+ host: viteOptions?.host,
2657
2802
  port: viteOptions?.port
2658
2803
  });
2659
2804
  this.viteDevServer = server2;
@@ -2930,11 +3075,13 @@ var Controller = class {
2930
3075
  const { url: overrideUrl, ...rest } = options;
2931
3076
  const url2 = overrideUrl ?? ctx.req.path ?? ctx.req.url ?? "";
2932
3077
  const component = typeof componentOrPage === "string" ? componentOrPage : componentOrPage.component ?? componentOrPage.id;
2933
- const sharedProps = await resolveSharedInertiaProps(ctx);
3078
+ const sharedProps = await resolveSharedInertiaProps(ctx, this._container);
2934
3079
  const propsWithShared = { ...sharedProps, ...props };
2935
3080
  const response = await inertia(component, propsWithShared, {
2936
3081
  ...rest,
2937
- lang: rest.lang ?? this.#defaultInertiaLang(),
3082
+ // No 'en' fallback here (unlike the locale getter): unconfigured apps
3083
+ // keep the Inertia engine's own default lang.
3084
+ lang: rest.lang ?? this.#resolveLocale(),
2938
3085
  url: url2,
2939
3086
  request: ctx.req.raw
2940
3087
  });
@@ -2945,29 +3092,65 @@ var Controller = class {
2945
3092
  return response;
2946
3093
  }
2947
3094
  /**
2948
- * Default `<html lang>` for Inertia responses when `options.lang` is not
2949
- * provided: the request-scoped `locale` context variable (set by locale
2950
- * middleware) wins over the app-wide i18n locale (the router-injected
2951
- * container binding, then the `setI18n()` global).
3095
+ * Locale resolved for the current request: the request-scoped `locale`
3096
+ * context variable (set by locale middleware) wins over the app-wide i18n
3097
+ * locale (the router-injected container binding, then the `setI18n()`
3098
+ * global). Falls back to `'en'` when no i18n is configured.
2952
3099
  */
2953
- #defaultInertiaLang() {
2954
- const vars = this.ctx.var;
2955
- const requestLocale = vars?.[LOCALE_CONTEXT_KEY];
2956
- if (typeof requestLocale === "string" && requestLocale.length > 0) {
3100
+ get locale() {
3101
+ return this.#resolveLocale() ?? "en";
3102
+ }
3103
+ /**
3104
+ * Translate a key for the current request locale.
3105
+ *
3106
+ * Uses the request-scoped translator bound by the locale detection
3107
+ * middleware when present, falling back to a translator scoped to
3108
+ * `this.locale` from the container's `i18n` binding (then the `setI18n()`
3109
+ * global).
3110
+ *
3111
+ * @example
3112
+ * ```typescript
3113
+ * this.t('posts.created')
3114
+ * this.t('posts.greeting', { name: user.name })
3115
+ * ```
3116
+ */
3117
+ t(key, replacements) {
3118
+ return this.#requestTranslator().t(key, replacements);
3119
+ }
3120
+ /**
3121
+ * Translate a key with a count for pluralization, using the same locale
3122
+ * resolution as {@link Controller.t}.
3123
+ */
3124
+ tc(key, count, replacements) {
3125
+ return this.#requestTranslator().tc(key, count, replacements);
3126
+ }
3127
+ #requestTranslator() {
3128
+ const bound = getRequestTranslator(this.ctx);
3129
+ if (bound) {
3130
+ return bound;
3131
+ }
3132
+ const i18n = this.#resolveI18n();
3133
+ if (!i18n) {
3134
+ throw new Error(
3135
+ "Controller i18n helpers require i18n to be configured. Pass createApp({ i18n }) or register an I18nManager."
3136
+ );
3137
+ }
3138
+ const locale = getRequestLocale(this.ctx);
3139
+ return locale && locale !== i18n.getLocale() ? i18n.forLocale(locale) : i18n;
3140
+ }
3141
+ #resolveLocale() {
3142
+ const requestLocale = getRequestLocale(this.ctx);
3143
+ if (requestLocale) {
2957
3144
  return requestLocale;
2958
3145
  }
2959
- let i18n;
3146
+ const locale = this.#resolveI18n()?.getLocale();
3147
+ return typeof locale === "string" && locale.length > 0 ? locale : void 0;
3148
+ }
3149
+ #resolveI18n() {
2960
3150
  if (this._container?.has?.("i18n")) {
2961
- i18n = this._container.make("i18n");
2962
- } else {
2963
- try {
2964
- i18n = getI18n();
2965
- } catch {
2966
- i18n = void 0;
2967
- }
3151
+ return this._container.make("i18n");
2968
3152
  }
2969
- const locale = i18n?.getLocale?.();
2970
- return typeof locale === "string" && locale.length > 0 ? locale : void 0;
3153
+ return tryGetI18n();
2971
3154
  }
2972
3155
  json(data, init = {}) {
2973
3156
  return new Response(JSON.stringify(data), {
@@ -3239,13 +3422,6 @@ var LogServiceProvider = class extends ServiceProvider {
3239
3422
  }
3240
3423
  };
3241
3424
 
3242
- // src/providers/I18nServiceProvider.ts
3243
- var I18nServiceProvider = class extends ServiceProvider {
3244
- register() {
3245
- this.container.singleton("i18n", () => createI18n({ locale: "en" }));
3246
- }
3247
- };
3248
-
3249
3425
  // src/providers/NotificationServiceProvider.ts
3250
3426
  var NotificationServiceProvider = class extends ServiceProvider {
3251
3427
  register() {
@@ -6833,6 +7009,7 @@ export {
6833
7009
  Notification,
6834
7010
  NotificationManager,
6835
7011
  NotificationServiceProvider,
7012
+ OAUTH_SESSION_BINDING_KEY,
6836
7013
  OAuthManager,
6837
7014
  OAuthServiceProvider,
6838
7015
  Output,
@@ -7013,6 +7190,8 @@ export {
7013
7190
  getQueueDriver,
7014
7191
  getRateLimitInfo,
7015
7192
  getRegisteredJobs,
7193
+ getRequestLocale,
7194
+ getRequestTranslator,
7016
7195
  getSessionFromContext,
7017
7196
  getUserApiTokens,
7018
7197
  getValidatedData,
@@ -7122,6 +7301,7 @@ export {
7122
7301
  tokenCan,
7123
7302
  tokenCanAll,
7124
7303
  tokenCanAny,
7304
+ tryGetI18n,
7125
7305
  unique,
7126
7306
  url as urlRule,
7127
7307
  urlSafeToken,