@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,119 +1,26 @@
1
1
  import type { RandomStringOptions } from './types.js';
2
- /**
3
- * Generate a cryptographically secure random string.
4
- *
5
- * @example
6
- * ```typescript
7
- * randomString(32) // 32-character alphanumeric string
8
- * randomString(16, { charset: 'hex' }) // 16-character hex string
9
- * randomString(24, { charset: 'url-safe' }) // URL-safe string
10
- * ```
11
- */
2
+ /** Cryptographically secure random string. */
12
3
  export declare function randomString(length: number, options?: RandomStringOptions): string;
13
- /**
14
- * Generate random bytes.
15
- *
16
- * @example
17
- * ```typescript
18
- * const bytes = random(32) // 32 random bytes
19
- * ```
20
- */
4
+ /** Cryptographically secure random bytes. */
21
5
  export declare function random(length: number): Buffer;
22
- /**
23
- * Generate random bytes as hex string.
24
- */
25
6
  export declare function randomHex(length: number): string;
26
- /**
27
- * Generate random bytes as base64 string.
28
- */
29
7
  export declare function randomBase64(length: number): string;
30
- /**
31
- * Generate random bytes as URL-safe base64 string.
32
- */
33
8
  export declare function randomBase64Url(length: number): string;
34
- /**
35
- * Generate a UUID v4.
36
- *
37
- * @example
38
- * ```typescript
39
- * const id = uuid() // e.g., '550e8400-e29b-41d4-a716-446655440000'
40
- * ```
41
- */
42
9
  export declare function uuid(): string;
43
- /**
44
- * Generate a secure random integer.
45
- *
46
- * @example
47
- * ```typescript
48
- * randomInt(1, 100) // Random number between 1 and 100 (inclusive)
49
- * ```
50
- */
10
+ /** Secure random integer in `[min, max]` — `max` is inclusive. */
51
11
  export declare function randomInt(min: number, max: number): number;
52
- /**
53
- * Generate a random token suitable for URLs.
54
- *
55
- * @example
56
- * ```typescript
57
- * const token = urlSafeToken(32) // URL-safe 32-character token
58
- * ```
59
- */
12
+ /** URL-safe token of exactly `length` characters. */
60
13
  export declare function urlSafeToken(length?: number): string;
61
- /**
62
- * Generate a secure random password.
63
- *
64
- * @example
65
- * ```typescript
66
- * const password = generatePassword(16) // Random 16-character password
67
- * ```
68
- */
69
14
  export declare function generatePassword(length?: number, options?: {
70
15
  uppercase?: boolean;
71
16
  lowercase?: boolean;
72
17
  numbers?: boolean;
73
18
  symbols?: boolean;
74
19
  }): string;
75
- /**
76
- * Generate a random OTP (One-Time Password).
77
- *
78
- * @example
79
- * ```typescript
80
- * const otp = generateOtp(6) // e.g., '482901'
81
- * ```
82
- */
20
+ /** One-time password. */
83
21
  export declare function generateOtp(length?: number): string;
84
- /**
85
- * Generate a random slug-friendly string.
86
- *
87
- * @example
88
- * ```typescript
89
- * const slug = generateSlug() // e.g., 'a8b2c4d6e8'
90
- * ```
91
- */
92
22
  export declare function generateSlug(length?: number): string;
93
- /**
94
- * Shuffle an array using Fisher-Yates algorithm with secure random.
95
- *
96
- * @example
97
- * ```typescript
98
- * const shuffled = shuffle([1, 2, 3, 4, 5])
99
- * ```
100
- */
23
+ /** Fisher-Yates, drawing from the secure source. */
101
24
  export declare function shuffle<T>(array: T[]): T[];
102
- /**
103
- * Pick a random element from an array.
104
- *
105
- * @example
106
- * ```typescript
107
- * const item = pick(['a', 'b', 'c']) // Random element
108
- * ```
109
- */
110
25
  export declare function pick<T>(array: T[]): T;
111
- /**
112
- * Pick multiple random elements from an array.
113
- *
114
- * @example
115
- * ```typescript
116
- * const items = sample(['a', 'b', 'c', 'd'], 2) // Two random elements
117
- * ```
118
- */
119
26
  export declare function sample<T>(array: T[], count: number): T[];
@@ -1,5 +1,5 @@
1
1
  import { a as generateAppKey, c as parseAppKey, i as encodeDerivedKey, l as parsePreviousAppKeys, n as deriveAppKey, o as getAppKeyringFromEnv, r as deriveAppKeyring, s as normalizeAppKey, t as MessageSigner } from "../MessageSigner-Bd25ZJAV.js";
2
- import { a as md5, c as sha256, d as verifyPassword, i as hmac, l as sha512, n as hash, o as needsRehash, r as hashPassword, s as secureCompare, t as check, u as verifyHmac } from "../Hash-C8aejmi8.js";
3
- import { a as random, c as randomHex, d as sample, f as shuffle, i as pick, l as randomInt, m as uuid, n as generatePassword, o as randomBase64, p as urlSafeToken, r as generateSlug, s as randomBase64Url, t as generateOtp, u as randomString } from "../Random-DbIJ22KQ.js";
4
- import { a as decrypt, c as getEncrypter, i as createEncrypter, l as setEncrypter, n as verifySignedUrl, o as encrypt, r as Encrypter, s as generateKey, t as signUrl } from "../encryption-D99Vmls3.js";
2
+ import { a as md5, c as sha256, d as verifyPassword, i as hmac, l as sha512, n as hash, o as needsRehash, r as hashPassword, s as secureCompare, t as check, u as verifyHmac } from "../Hash-D2DFd8xX.js";
3
+ import { a as random, c as randomHex, d as sample, f as shuffle, i as pick, l as randomInt, m as uuid, n as generatePassword, o as randomBase64, p as urlSafeToken, r as generateSlug, s as randomBase64Url, t as generateOtp, u as randomString } from "../Random-S0OvCuR8.js";
4
+ import { a as decrypt, c as getEncrypter, i as createEncrypter, l as setEncrypter, n as verifySignedUrl, o as encrypt, r as Encrypter, s as generateKey, t as signUrl } from "../encryption-uwP3Di4D.js";
5
5
  export { Encrypter, MessageSigner, check, createEncrypter, decrypt, deriveAppKey, deriveAppKeyring, encodeDerivedKey, encrypt, generateAppKey, generateKey, generateOtp, generatePassword, generateSlug, getAppKeyringFromEnv, getEncrypter, hash, hashPassword, hmac, md5, needsRehash, normalizeAppKey, parseAppKey, parsePreviousAppKeys, pick, random, randomBase64, randomBase64Url, randomHex, randomInt, randomString, sample, secureCompare, setEncrypter, sha256, sha512, shuffle, signUrl, urlSafeToken, uuid, verifyHmac, verifyPassword, verifySignedUrl };
@@ -1,103 +1,41 @@
1
- /**
2
- * Encryption options.
3
- */
4
1
  export interface EncryptOptions {
5
- /**
6
- * Whether to serialize the value before encryption.
7
- */
8
2
  serialize?: boolean;
9
3
  }
10
- /**
11
- * Decryption options.
12
- */
13
4
  export interface DecryptOptions {
14
- /**
15
- * Whether to deserialize the value after decryption.
16
- */
17
5
  deserialize?: boolean;
18
6
  }
19
- /**
20
- * Encrypter configuration.
21
- */
22
7
  export interface EncrypterConfig {
23
- /**
24
- * Encryption key (base64 encoded, 32 bytes for AES-256).
25
- */
8
+ /** Base64; 32 bytes for AES-256. */
26
9
  key: string;
27
- /**
28
- * Previous encryption keys used for decryption fallback during key rotation.
29
- */
10
+ /** Decryption-only fallbacks, for key rotation. */
30
11
  previousKeys?: string[];
31
- /**
32
- * Encryption cipher to use.
33
- */
34
12
  cipher?: 'aes-256-gcm' | 'aes-256-cbc';
35
13
  }
36
- /**
37
- * Encrypted payload structure.
38
- */
39
14
  export interface EncryptedPayload {
40
- /**
41
- * Initialization vector (base64).
42
- */
15
+ /** Base64. */
43
16
  iv: string;
44
- /**
45
- * Encrypted value (base64).
46
- */
17
+ /** Base64. */
47
18
  value: string;
48
- /**
49
- * Authentication tag for GCM mode (base64).
50
- */
19
+ /** GCM authentication tag, base64. */
51
20
  tag?: string;
52
- /**
53
- * MAC for CBC mode (hex).
54
- */
21
+ /** CBC MAC, hex. */
55
22
  mac?: string;
56
23
  }
57
- /**
58
- * Hash algorithm options.
59
- */
60
24
  export type HashAlgorithm = 'sha256' | 'sha384' | 'sha512' | 'md5' | 'sha1';
61
- /**
62
- * HMAC options.
63
- */
64
25
  export interface HmacOptions {
65
- /**
66
- * Hash algorithm to use.
67
- */
68
26
  algorithm?: HashAlgorithm;
69
- /**
70
- * Output encoding.
71
- */
72
27
  encoding?: 'hex' | 'base64';
73
28
  }
74
- /**
75
- * Password hash options.
76
- */
77
29
  export interface PasswordHashOptions {
78
- /**
79
- * Memory cost (for scrypt/argon2).
80
- */
30
+ /** For scrypt/argon2. */
81
31
  memory?: number;
82
- /**
83
- * CPU cost (for scrypt/argon2).
84
- */
32
+ /** For scrypt/argon2. */
85
33
  cost?: number;
86
- /**
87
- * Salt length in bytes.
88
- */
34
+ /** Bytes. */
89
35
  saltLength?: number;
90
- /**
91
- * Key length in bytes.
92
- */
36
+ /** Bytes. */
93
37
  keyLength?: number;
94
38
  }
95
- /**
96
- * Random string options.
97
- */
98
39
  export interface RandomStringOptions {
99
- /**
100
- * Character set to use.
101
- */
102
40
  charset?: 'alphanumeric' | 'alphabetic' | 'numeric' | 'hex' | 'base64' | 'url-safe';
103
41
  }
@@ -2,55 +2,27 @@ import { a as generateAppKey, s as normalizeAppKey, t as MessageSigner } from ".
2
2
  import { createCipheriv, createDecipheriv, createHmac, randomBytes } from "crypto";
3
3
  //#region src/encryption/Encrypter.ts
4
4
  /**
5
- * GCM authentication tag length, in bytes.
6
- *
7
- * Pinned on both sides. Node and Bun accept 4-, 8-, 12-, 13-, 14-, 15- and
8
- * 16-byte GCM tags, and `setAuthTag()` adopts whatever length it is handed — so
9
- * a payload rewritten with a 4-byte tag would be accepted, dropping forgery
10
- * resistance from 2^128 to 2^32. Everything this class writes uses the full
11
- * tag, so nothing legitimate is rejected by requiring it.
5
+ * GCM authentication tag length, in bytes, pinned on both sides: Node and Bun
6
+ * accept 4-, 8-, 12-, 13-, 14-, 15- and 16-byte tags, and `setAuthTag()` adopts
7
+ * whatever length it is handed, so a payload rewritten with a 4-byte tag would
8
+ * drop forgery resistance from 2^128 to 2^32.
12
9
  */
13
10
  const GCM_TAG_BYTES = 16;
14
- /**
15
- * Encrypter for secure data encryption using AES.
16
- *
17
- * @example
18
- * ```typescript
19
- * const encrypter = new Encrypter({ key: 'base64-encoded-32-byte-key' })
20
- *
21
- * // Encrypt
22
- * const encrypted = encrypter.encrypt({ userId: 123, role: 'admin' })
23
- *
24
- * // Decrypt
25
- * const data = encrypter.decrypt(encrypted)
26
- * ```
27
- */
11
+ /** AES encryption over a base64-encoded 32-byte key. */
28
12
  var Encrypter = class {
29
- /**
30
- * Encryption key.
31
- */
32
13
  key;
33
14
  previousKeys;
34
- /**
35
- * Cipher algorithm.
36
- */
37
15
  cipher;
38
16
  constructor(config) {
39
17
  this.key = Buffer.from(normalizeAppKey(config.key).slice(7), "base64");
40
18
  this.previousKeys = (config.previousKeys ?? []).map((key) => Buffer.from(normalizeAppKey(key).slice(7), "base64"));
41
19
  this.cipher = config.cipher ?? "aes-256-gcm";
42
20
  }
43
- /**
44
- * Encrypt a value.
45
- */
46
21
  encrypt(value, options = {}) {
47
22
  const data = options.serialize !== false ? JSON.stringify(value) : String(value);
48
23
  if (this.cipher === "aes-256-gcm") return this.encryptGcm(data);
49
24
  return this.encryptCbc(data);
50
25
  }
51
- /**
52
- * Decrypt a value.
53
- */
54
26
  decrypt(payload, options = {}) {
55
27
  const deserialize = options.deserialize !== false;
56
28
  let parsed;
@@ -70,21 +42,12 @@ var Encrypter = class {
70
42
  }
71
43
  return decrypted;
72
44
  }
73
- /**
74
- * Encrypt a string (no serialization).
75
- */
76
45
  encryptString(value) {
77
46
  return this.encrypt(value, { serialize: false });
78
47
  }
79
- /**
80
- * Decrypt a string (no deserialization).
81
- */
82
48
  decryptString(payload) {
83
49
  return this.decrypt(payload, { deserialize: false });
84
50
  }
85
- /**
86
- * Encrypt using AES-256-GCM.
87
- */
88
51
  encryptGcm(data) {
89
52
  const iv = randomBytes(12);
90
53
  const cipher = createCipheriv("aes-256-gcm", this.key, iv, { authTagLength: GCM_TAG_BYTES });
@@ -97,9 +60,6 @@ var Encrypter = class {
97
60
  };
98
61
  return Buffer.from(JSON.stringify(payload)).toString("base64");
99
62
  }
100
- /**
101
- * Decrypt using AES-256-GCM.
102
- */
103
63
  decryptGcm(payload) {
104
64
  const iv = Buffer.from(payload.iv, "base64");
105
65
  const encrypted = Buffer.from(payload.value, "base64");
@@ -111,9 +71,6 @@ var Encrypter = class {
111
71
  return Buffer.concat([decipher.update(encrypted), decipher.final()]).toString("utf8");
112
72
  });
113
73
  }
114
- /**
115
- * Encrypt using AES-256-CBC with HMAC.
116
- */
117
74
  encryptCbc(data) {
118
75
  const iv = randomBytes(16);
119
76
  const cipher = createCipheriv("aes-256-cbc", this.key, iv);
@@ -126,9 +83,6 @@ var Encrypter = class {
126
83
  };
127
84
  return Buffer.from(JSON.stringify(payload)).toString("base64");
128
85
  }
129
- /**
130
- * Decrypt using AES-256-CBC with HMAC verification.
131
- */
132
86
  decryptCbc(payload) {
133
87
  return this.tryDecryptWithKeys((key) => {
134
88
  const iv = Buffer.from(payload.iv, "base64");
@@ -139,27 +93,20 @@ var Encrypter = class {
139
93
  return Buffer.concat([decipher.update(encrypted), decipher.final()]).toString("utf8");
140
94
  });
141
95
  }
142
- /**
143
- * Create HMAC for CBC mode.
144
- */
145
96
  createMac(iv, encrypted, key = this.key) {
146
97
  const hmac = createHmac("sha256", key);
147
98
  hmac.update(iv);
148
99
  hmac.update(encrypted);
149
100
  return hmac.digest("hex");
150
101
  }
151
- /**
152
- * Constant-time string comparison.
153
- */
102
+ /** Constant-time comparison. */
154
103
  secureCompare(a, b) {
155
104
  if (a.length !== b.length) return false;
156
105
  let result = 0;
157
106
  for (let i = 0; i < a.length; i++) result |= a.charCodeAt(i) ^ b.charCodeAt(i);
158
107
  return result === 0;
159
108
  }
160
- /**
161
- * Get the encryption key (base64).
162
- */
109
+ /** The encryption key, base64-encoded. */
163
110
  getKey() {
164
111
  return this.key.toString("base64");
165
112
  }
@@ -174,41 +121,25 @@ var Encrypter = class {
174
121
  throw lastError ?? /* @__PURE__ */ new Error("Failed to decrypt payload.");
175
122
  }
176
123
  };
177
- /**
178
- * Generate a random encryption key.
179
- */
180
124
  function generateKey() {
181
125
  return generateAppKey();
182
126
  }
183
127
  let globalEncrypter = null;
184
- /**
185
- * Create an encrypter instance.
186
- */
187
128
  function createEncrypter(config) {
188
129
  return new Encrypter(config);
189
130
  }
190
- /**
191
- * Set the global encrypter.
192
- */
193
131
  function setEncrypter(encrypter) {
194
132
  globalEncrypter = encrypter;
195
133
  }
196
- /**
197
- * Get the global encrypter.
198
- */
199
134
  function getEncrypter() {
200
135
  if (!globalEncrypter) throw new Error("Encrypter not initialized. Call setEncrypter() first.");
201
136
  return globalEncrypter;
202
137
  }
203
- /**
204
- * Encrypt a value using the global encrypter.
205
- */
138
+ /** Encrypt with the global encrypter. */
206
139
  function encrypt(value, options) {
207
140
  return getEncrypter().encrypt(value, options);
208
141
  }
209
- /**
210
- * Decrypt a value using the global encrypter.
211
- */
142
+ /** Decrypt with the global encrypter. */
212
143
  function decrypt(payload, options) {
213
144
  return getEncrypter().decrypt(payload, options);
214
145
  }
@@ -1,18 +1,12 @@
1
- import { t as createLoopbackGuard } from "./loopback-guard-D0Kc7-xc.js";
1
+ import { t as createLoopbackGuard } from "./loopback-guard-DT9gHF0F.js";
2
2
  //#region src/docs-viewer/endpoint.ts
3
3
  const DOCS_VIEWER_PATH = "/_guren/docs";
4
4
  /**
5
- * Whether the docs viewer is mounted for this process.
6
- *
7
- * Opt-in via `GUREN_DOCS=1` and never active in production: the viewer
8
- * renders the project's private knowledge bundle, so it must not be
9
- * reachable unless the developer asked for it.
10
- *
11
- * The environment reads use plain member access so that the deploy plugins'
12
- * `--define 'process.env.NODE_ENV="production"'` settles the production
13
- * branch at bundle time; an optional chain is a different expression and no
14
- * define matches it. See `mcp/endpoint.ts` for the full reasoning — and do
15
- * not add optional chaining back, a test reads this file for it.
5
+ * Whether the docs viewer is mounted: opt-in via `GUREN_DOCS=1`, never in
6
+ * production — it renders the project's private knowledge bundle. Plain
7
+ * `process.env.X` access on purpose: the deploy plugins' `--define
8
+ * 'process.env.NODE_ENV="production"'` settles that branch at bundle time, and
9
+ * an optional chain is a different expression no define matches (`mcp/endpoint.ts`; a test greps this file).
16
10
  */
17
11
  function isDocsViewerEnabled() {
18
12
  if (typeof process === "undefined") return false;
@@ -0,0 +1,26 @@
1
+ import { t as createLoopbackGuard } from "./loopback-guard-DT9gHF0F.js";
2
+ //#region src/mcp/endpoint.ts
3
+ const MCP_ENDPOINT_PATH = "/_guren/mcp";
4
+ /**
5
+ * Whether the MCP endpoint is mounted: opt-in via `GUREN_MCP=1`, never in
6
+ * production (it exposes project introspection and code generation). The env
7
+ * reads are plain member access on purpose: the deploy plugins settle NODE_ENV
8
+ * with `--define`, which matches one exact expression, so an optional chain
9
+ * leaves a runtime read that reopens the gate on workerd; `tests/mcp/endpoint.test.ts` pins the form.
10
+ */
11
+ function isMcpEndpointEnabled() {
12
+ if (typeof process === "undefined") return false;
13
+ if (process.env.NODE_ENV === "production") return false;
14
+ return process.env.GUREN_MCP === "1";
15
+ }
16
+ /**
17
+ * Restricts the MCP endpoint to the developer's own machine. The endpoint is
18
+ * CSRF-exempt (agent clients carry no token), so this guard takes over: a web
19
+ * page is rejected unless its `Origin` is loopback, and every caller unless its
20
+ * socket peer is. It fails closed when the runtime reports no peer at all.
21
+ */
22
+ function createMcpAccessGuard() {
23
+ return createLoopbackGuard("the MCP endpoint");
24
+ }
25
+ //#endregion
26
+ export { createMcpAccessGuard as n, isMcpEndpointEnabled as r, MCP_ENDPOINT_PATH as t };
@@ -1,118 +1,31 @@
1
1
  import type { Context } from '../http/Application.js';
2
2
  import type { Middleware } from '../http/middleware/index.js';
3
3
  import type { ExceptionHandlerOptions, ExceptionReporter, ExceptionRenderer, ExceptionClass, RendererRegistration } from './types.js';
4
- /**
5
- * Exception handler for centralized error handling.
6
- *
7
- * @example
8
- * ```typescript
9
- * const handler = new ExceptionHandler({ debug: false })
10
- *
11
- * // Report exceptions (e.g., to Sentry)
12
- * handler.report(async (error) => {
13
- * await sentry.captureException(error)
14
- * })
15
- *
16
- * // Custom renderer for validation errors
17
- * handler.render(ValidationException, (error, ctx) => {
18
- * return ctx.json({ errors: error.errors }, 422)
19
- * })
20
- *
21
- * // Don't report 404 errors
22
- * handler.dontReport(NotFoundHttpException)
23
- *
24
- * // Use as middleware
25
- * app.use('*', handler.middleware())
26
- * ```
27
- */
4
+ /** Centralized error handling: reporting, per-class renderers, middleware. */
28
5
  export declare class ExceptionHandler {
29
- /**
30
- * Exception reporters.
31
- */
32
6
  protected reporters: ExceptionReporter[];
33
- /**
34
- * Exception renderers.
35
- */
36
7
  protected renderers: RendererRegistration[];
37
- /**
38
- * Exception classes to not report.
39
- */
40
8
  protected dontReportClasses: ExceptionClass[];
41
- /**
42
- * Handler options.
43
- */
44
9
  protected options: ExceptionHandlerOptions;
45
10
  constructor(options?: ExceptionHandlerOptions);
46
- /**
47
- * Register an exception reporter.
48
- * Reporters are called for every exception (unless in dontReport list).
49
- */
11
+ /** Reporters run for every exception outside the `dontReport` list. */
50
12
  report(callback: ExceptionReporter): this;
51
- /**
52
- * Register a custom renderer for an exception type.
53
- */
54
13
  render<T extends Error>(errorClass: ExceptionClass<T>, renderer: ExceptionRenderer<T>): this;
55
- /**
56
- * Add an exception class to the don't report list.
57
- */
58
14
  dontReport(errorClass: ExceptionClass): this;
59
- /**
60
- * Check if debug mode is enabled.
61
- */
62
15
  shouldShowDetails(): boolean;
63
- /**
64
- * Handle an exception.
65
- */
66
16
  handle(error: Error, ctx: Context): Promise<Response>;
67
- /**
68
- * Report an exception to all reporters.
69
- */
70
17
  protected reportException(error: Error): Promise<void>;
71
- /**
72
- * Check if an exception should not be reported.
73
- */
74
18
  protected shouldNotReport(error: Error): boolean;
75
19
  protected matchesErrorClass(error: Error, errorClass: ExceptionClass): boolean;
76
- /**
77
- * Render an exception to a response.
78
- */
79
20
  protected renderException(error: Error, ctx: Context): Promise<Response>;
80
- /**
81
- * Default exception rendering.
82
- */
83
21
  protected renderDefaultException(error: Error, ctx: Context): Response;
84
- /**
85
- * Determine whether the request expects an HTML response.
86
- * Returns false for Inertia, XHR, and JSON API requests so they
87
- * continue to receive JSON error payloads.
88
- */
22
+ /** False for Inertia, XHR and JSON callers, which need a JSON payload. */
89
23
  protected wantsHtmlResponse(ctx: Context): boolean;
90
- /**
91
- * Create middleware for exception handling.
92
- */
93
24
  middleware(): Middleware;
94
25
  }
95
- /**
96
- * Create an exception handler.
97
- */
98
26
  export declare function createExceptionHandler(options?: ExceptionHandlerOptions): ExceptionHandler;
99
- /**
100
- * Set the global exception handler.
101
- */
102
27
  export declare function setExceptionHandler(handler: ExceptionHandler): void;
103
- /**
104
- * Get the global exception handler.
105
- */
106
28
  export declare function getExceptionHandler(): ExceptionHandler;
107
- /**
108
- * Abort the request with an HTTP exception.
109
- */
110
29
  export declare function abort(statusCode: number, message?: string, errors?: Record<string, string[]>): never;
111
- /**
112
- * Abort if condition is true.
113
- */
114
30
  export declare function abortIf(condition: boolean, statusCode: number, message?: string): void;
115
- /**
116
- * Abort unless condition is true.
117
- */
118
31
  export declare function abortUnless(condition: boolean, statusCode: number, message?: string): void;