@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,24 +1,19 @@
1
- import { r as ServiceProvider } from "./loopback-guard-D0Kc7-xc.js";
2
- import { n as createDocsViewerAccessGuard, r as isDocsViewerEnabled, t as DOCS_VIEWER_PATH } from "./endpoint-D6GIqOpe.js";
1
+ import { r as ServiceProvider } from "./loopback-guard-DT9gHF0F.js";
2
+ import { n as createDocsViewerAccessGuard, r as isDocsViewerEnabled, t as DOCS_VIEWER_PATH } from "./endpoint-BXipU2Jj.js";
3
3
  import { createRequire } from "node:module";
4
4
  import { createHash } from "node:crypto";
5
5
  import { readFile } from "node:fs/promises";
6
6
  import { join } from "node:path";
7
7
  //#region src/docs-viewer/DocsViewerServiceProvider.ts
8
8
  /**
9
- * How long a built `data.json` payload answers subsequent requests.
10
- * Comfortably longer than the UI's poll interval, so a visible tab does
11
- * not rebuild the whole bundle every few seconds only to find the ETag
12
- * unchanged — the build reads and renders every doc, which is real work
13
- * inside the process serving the app under development.
9
+ * How long a built `data.json` payload answers requests. Longer than the UI's
10
+ * poll interval, so a visible tab does not re-read and re-render every doc
11
+ * inside the dev server every few seconds only to find the ETag unchanged.
14
12
  */
15
13
  const DATA_CACHE_TTL_MS = 15e3;
16
14
  /**
17
- * Registers the docs viewer (RFC 0005) at /_guren/docs: a read-only,
18
- * loopback-guarded UI that renders the OKF docs bundle as an
19
- * interactive relation graph. Only active while `isDocsViewerEnabled()`
20
- * holds. All routes are GET; the whole bundle ships as one payload, so
21
- * no route takes a path parameter.
15
+ * The docs viewer (RFC 0005) at /_guren/docs: a read-only, loopback-guarded UI
16
+ * over the OKF docs bundle, mounted only while `isDocsViewerEnabled()` holds.
22
17
  */
23
18
  var DocsViewerServiceProvider = class extends ServiceProvider {
24
19
  register() {}
@@ -2,65 +2,29 @@ import { createHash, createHmac, randomBytes, scrypt, timingSafeEqual } from "cr
2
2
  import { promisify } from "util";
3
3
  //#region src/encryption/Hash.ts
4
4
  const scryptAsync = promisify(scrypt);
5
- /**
6
- * Hash a value using the specified algorithm.
7
- *
8
- * @example
9
- * ```typescript
10
- * hash('hello') // SHA-256 by default
11
- * hash('hello', 'sha512')
12
- * hash('hello', 'md5')
13
- * ```
14
- */
5
+ /** Hash a value; SHA-256 by default. */
15
6
  function hash(value, algorithm = "sha256", encoding = "hex") {
16
7
  return createHash(algorithm).update(value).digest(encoding);
17
8
  }
18
- /**
19
- * Create an HMAC signature.
20
- *
21
- * @example
22
- * ```typescript
23
- * hmac('message', 'secret-key')
24
- * hmac('message', 'secret-key', { algorithm: 'sha512' })
25
- * ```
26
- */
9
+ /** Create an HMAC signature; SHA-256 by default. */
27
10
  function hmac(value, key, options = {}) {
28
11
  const { algorithm = "sha256", encoding = "hex" } = options;
29
12
  return createHmac(algorithm, key).update(value).digest(encoding);
30
13
  }
31
- /**
32
- * Verify an HMAC signature.
33
- */
34
14
  function verifyHmac(value, signature, key, options = {}) {
35
15
  return secureCompare(signature, hmac(value, key, options));
36
16
  }
37
- /**
38
- * Create a SHA-256 hash.
39
- */
40
17
  function sha256(value) {
41
18
  return hash(value, "sha256");
42
19
  }
43
- /**
44
- * Create a SHA-512 hash.
45
- */
46
20
  function sha512(value) {
47
21
  return hash(value, "sha512");
48
22
  }
49
- /**
50
- * Create an MD5 hash (not secure, use only for checksums).
51
- */
23
+ /** Not secure — checksums only. */
52
24
  function md5(value) {
53
25
  return hash(value, "md5");
54
26
  }
55
- /**
56
- * Hash a password using scrypt.
57
- *
58
- * @example
59
- * ```typescript
60
- * const hashed = await hashPassword('mypassword')
61
- * // Returns: $scrypt$N=16384,r=8,p=1$salt$hash
62
- * ```
63
- */
27
+ /** scrypt, returning `$scrypt$N=16384,r=8,p=1$salt$hash`. */
64
28
  async function hashPassword(password, options = {}) {
65
29
  const { cost = 16384, memory = 8, saltLength = 16, keyLength = 64 } = options;
66
30
  const salt = randomBytes(saltLength);
@@ -71,14 +35,7 @@ async function hashPassword(password, options = {}) {
71
35
  });
72
36
  return `$scrypt$${`N=${cost},r=${memory},p=1`}$${salt.toString("base64")}$${derived.toString("base64")}`;
73
37
  }
74
- /**
75
- * Verify a password against a hash.
76
- *
77
- * @example
78
- * ```typescript
79
- * const isValid = await verifyPassword('mypassword', hashedPassword)
80
- * ```
81
- */
38
+ /** Verify a password against a hash. */
82
39
  async function verifyPassword(password, hash) {
83
40
  if (!hash.startsWith("$scrypt$")) throw new Error("Invalid password hash format.");
84
41
  const parts = hash.split("$");
@@ -103,9 +60,7 @@ async function verifyPassword(password, hash) {
103
60
  function isPositiveInteger(value) {
104
61
  return Number.isInteger(value) && value > 0;
105
62
  }
106
- /**
107
- * Check if a password needs to be rehashed (parameters changed).
108
- */
63
+ /** Whether the hash was made with different parameters than `options`. */
109
64
  function needsRehash(hash, options = {}) {
110
65
  const { cost = 16384, memory = 8 } = options;
111
66
  if (!hash.startsWith("$scrypt$")) return true;
@@ -119,18 +74,13 @@ function needsRehash(hash, options = {}) {
119
74
  }
120
75
  return params.N !== cost || params.r !== memory;
121
76
  }
122
- /**
123
- * Constant-time string comparison.
124
- */
77
+ /** Constant-time comparison. */
125
78
  function secureCompare(a, b) {
126
79
  if (a.length !== b.length) return false;
127
80
  const bufA = Buffer.from(a);
128
81
  const bufB = Buffer.from(b);
129
82
  return timingSafeEqual(bufA, bufB);
130
83
  }
131
- /**
132
- * Check if a value matches a hash.
133
- */
134
84
  function check(value, hash, algorithm = "sha256") {
135
85
  return secureCompare(createHash(algorithm).update(value).digest("hex"), hash);
136
86
  }
@@ -1,35 +1,8 @@
1
1
  //#region src/errors/HttpException.ts
2
- /**
3
- * Base HTTP exception class.
4
- *
5
- * @example
6
- * ```typescript
7
- * // Using factory methods
8
- * throw HttpException.notFound('User not found')
9
- * throw HttpException.unauthorized('Invalid credentials')
10
- *
11
- * // Custom status code
12
- * throw new HttpException(418, "I'm a teapot")
13
- *
14
- * // With validation errors
15
- * throw HttpException.unprocessable('Validation failed', {
16
- * email: ['Email is required', 'Email must be valid'],
17
- * password: ['Password is too short'],
18
- * })
19
- * ```
20
- */
2
+ /** Base HTTP exception class. */
21
3
  var HttpException = class HttpException extends Error {
22
- /**
23
- * HTTP status code.
24
- */
25
4
  statusCode;
26
- /**
27
- * Validation or field-specific errors.
28
- */
29
5
  errors;
30
- /**
31
- * Additional error data.
32
- */
33
6
  data;
34
7
  constructor(statusCode, message, errors, data) {
35
8
  super(message);
@@ -39,9 +12,6 @@ var HttpException = class HttpException extends Error {
39
12
  this.data = data;
40
13
  if (Error.captureStackTrace) Error.captureStackTrace(this, this.constructor);
41
14
  }
42
- /**
43
- * Convert to response format.
44
- */
45
15
  toResponse(debug = false) {
46
16
  const body = { message: this.message };
47
17
  if (this.errors) body.errors = this.errors;
@@ -54,9 +24,6 @@ var HttpException = class HttpException extends Error {
54
24
  body
55
25
  };
56
26
  }
57
- /**
58
- * Convert to JSON.
59
- */
60
27
  toJSON() {
61
28
  return {
62
29
  name: this.name,
@@ -66,93 +33,49 @@ var HttpException = class HttpException extends Error {
66
33
  data: this.data
67
34
  };
68
35
  }
69
- /**
70
- * Create a 400 Bad Request exception.
71
- */
72
36
  static badRequest(message = "Bad Request") {
73
37
  return new HttpException(400, message);
74
38
  }
75
- /**
76
- * Create a 401 Unauthorized exception.
77
- */
78
39
  static unauthorized(message = "Unauthorized") {
79
40
  return new HttpException(401, message);
80
41
  }
81
- /**
82
- * Create a 403 Forbidden exception.
83
- */
84
42
  static forbidden(message = "Forbidden") {
85
43
  return new HttpException(403, message);
86
44
  }
87
- /**
88
- * Create a 404 Not Found exception.
89
- */
90
45
  static notFound(message = "Not Found") {
91
46
  return new HttpException(404, message);
92
47
  }
93
- /**
94
- * Create a 405 Method Not Allowed exception.
95
- */
96
48
  static methodNotAllowed(message = "Method Not Allowed") {
97
49
  return new HttpException(405, message);
98
50
  }
99
- /**
100
- * Create a 409 Conflict exception.
101
- */
102
51
  static conflict(message = "Conflict") {
103
52
  return new HttpException(409, message);
104
53
  }
105
- /**
106
- * Create a 410 Gone exception.
107
- */
108
54
  static gone(message = "Gone") {
109
55
  return new HttpException(410, message);
110
56
  }
111
- /**
112
- * Create a 422 Unprocessable Entity exception.
113
- */
114
57
  static unprocessable(message = "Unprocessable Entity", errors) {
115
58
  return new HttpException(422, message, errors);
116
59
  }
117
- /**
118
- * Create a 429 Too Many Requests exception.
119
- */
120
60
  static tooManyRequests(message = "Too Many Requests") {
121
61
  return new HttpException(429, message);
122
62
  }
123
- /**
124
- * Create a 500 Internal Server Error exception.
125
- */
126
63
  static internal(message = "Internal Server Error") {
127
64
  return new HttpException(500, message);
128
65
  }
129
- /**
130
- * Create a 501 Not Implemented exception.
131
- */
132
66
  static notImplemented(message = "Not Implemented") {
133
67
  return new HttpException(501, message);
134
68
  }
135
- /**
136
- * Create a 502 Bad Gateway exception.
137
- */
138
69
  static badGateway(message = "Bad Gateway") {
139
70
  return new HttpException(502, message);
140
71
  }
141
- /**
142
- * Create a 503 Service Unavailable exception.
143
- */
144
72
  static serviceUnavailable(message = "Service Unavailable") {
145
73
  return new HttpException(503, message);
146
74
  }
147
- /**
148
- * Create a 504 Gateway Timeout exception.
149
- */
150
75
  static gatewayTimeout(message = "Gateway Timeout") {
151
76
  return new HttpException(504, message);
152
77
  }
153
- /**
154
- * Check if an error is an HTTP exception.
155
- */
78
+ /** Duck-typed: an exception from another copy of the package still passes. */
156
79
  static isHttpException(error) {
157
80
  return error instanceof HttpException || typeof error === "object" && error !== null && "statusCode" in error && typeof error.statusCode === "number" && "toResponse" in error && typeof error.toResponse === "function";
158
81
  }
@@ -1,22 +1,8 @@
1
1
  import { randomBytes } from "node:crypto";
2
2
  //#region src/container/Container.ts
3
3
  /**
4
- * Dependency injection container with type-safe service resolution.
5
- *
6
- * @example
7
- * ```typescript
8
- * const container = new Container()
9
- *
10
- * // Register services
11
- * container.singleton('events', (c) => new EventManager())
12
- * container.instance('config', loadConfig())
13
- *
14
- * // Type-safe resolution (known bindings)
15
- * const events = container.make('events') // EventManager
16
- *
17
- * // Generic resolution (custom bindings)
18
- * const db = container.make<Database>('db')
19
- * ```
4
+ * Dependency injection container. Keys from `ServiceBindings` type `make()`
5
+ * automatically; other keys take an explicit type parameter (`make<T>(key)`).
20
6
  */
21
7
  var Container = class Container {
22
8
  bindings = /* @__PURE__ */ new Map();
@@ -26,12 +12,14 @@ var Container = class Container {
26
12
  resolvingStack = [];
27
13
  scopedInstances = [];
28
14
  fakes = /* @__PURE__ */ new Map();
29
- /** @internal Used by ProviderManager to resolve deferred providers on demand */
30
- deferredProviderLoader = null;
31
15
  /**
32
- * Bind a service to the container.
33
- * Each resolution creates a new instance.
16
+ * @internal Installed by ProviderManager once every eager provider has booted.
17
+ * Called from make() for an unbound key; must run the deferred provider's
18
+ * register() synchronously before returning (boot() may settle on the returned
19
+ * promise). `undefined` means no deferred provider claims the service.
34
20
  */
21
+ deferredProviderLoader = null;
22
+ /** Bind a factory; each resolution creates a new instance. */
35
23
  bind(key, factory) {
36
24
  this.bindings.set(key, {
37
25
  factory,
@@ -39,10 +27,7 @@ var Container = class Container {
39
27
  });
40
28
  return this;
41
29
  }
42
- /**
43
- * Bind a singleton service to the container.
44
- * Only one instance is created and reused.
45
- */
30
+ /** Bind a factory whose single instance is reused. */
46
31
  singleton(key, factory) {
47
32
  this.bindings.set(key, {
48
33
  factory,
@@ -50,9 +35,6 @@ var Container = class Container {
50
35
  });
51
36
  return this;
52
37
  }
53
- /**
54
- * Bind an existing instance to the container.
55
- */
56
38
  instance(key, value) {
57
39
  this.bindings.set(key, {
58
40
  factory: () => value,
@@ -67,11 +49,9 @@ var Container = class Container {
67
49
  if (resolvedKey !== key && this.fakes.has(resolvedKey)) return this.fakes.get(resolvedKey);
68
50
  let binding = this.bindings.get(resolvedKey);
69
51
  if (!binding && this.deferredProviderLoader) {
70
- let resolved = false;
71
- this.deferredProviderLoader(resolvedKey).then(() => {
72
- resolved = true;
73
- });
74
- if (resolved) binding = this.bindings.get(resolvedKey);
52
+ const loading = this.deferredProviderLoader(resolvedKey);
53
+ binding = this.bindings.get(resolvedKey);
54
+ if (loading && !binding) throw new Error(`Deferred provider for "${key}" did not bind "${resolvedKey}" synchronously in register(). Container.make() cannot await an async register(); bind the service synchronously, or await ProviderManager.loadDeferredProvider() before resolving it.`);
75
55
  }
76
56
  if (!binding) throw new Error(`Service "${key}" not found in container`);
77
57
  if (binding.singleton && binding.instance !== void 0) return binding.instance;
@@ -90,9 +70,6 @@ var Container = class Container {
90
70
  this.resolvingStack.pop();
91
71
  }
92
72
  }
93
- /**
94
- * Resolve a service with additional parameters.
95
- */
96
73
  makeWith(key, params) {
97
74
  const resolvedKey = this.resolveAlias(key);
98
75
  const binding = this.bindings.get(resolvedKey);
@@ -102,24 +79,15 @@ var Container = class Container {
102
79
  for (const [paramKey, paramValue] of Object.entries(params)) tempContainer.instance(paramKey, paramValue);
103
80
  return binding.factory(tempContainer);
104
81
  }
105
- /**
106
- * Check if a service is bound in the container.
107
- */
108
82
  has(key) {
109
83
  const resolvedKey = this.resolveAlias(key);
110
84
  return this.bindings.has(resolvedKey);
111
85
  }
112
- /**
113
- * Create an alias for a service.
114
- */
115
86
  alias(alias, key) {
116
87
  if (alias === key) throw new Error("Alias cannot be the same as the key");
117
88
  this.aliases.set(alias, key);
118
89
  return this;
119
90
  }
120
- /**
121
- * Tag multiple services with a tag name.
122
- */
123
91
  tag(keys, tagName) {
124
92
  let taggedKeys = this.tags.get(tagName);
125
93
  if (!taggedKeys) {
@@ -129,17 +97,11 @@ var Container = class Container {
129
97
  for (const key of keys) taggedKeys.add(key);
130
98
  return this;
131
99
  }
132
- /**
133
- * Resolve all services with a given tag.
134
- */
135
100
  tagged(tagName) {
136
101
  const taggedKeys = this.tags.get(tagName);
137
102
  if (!taggedKeys) return [];
138
103
  return Array.from(taggedKeys).map((key) => this.make(key));
139
104
  }
140
- /**
141
- * Define a contextual binding.
142
- */
143
105
  when(concrete) {
144
106
  return { needs: (abstract) => {
145
107
  return { give: (factoryOrValue) => {
@@ -152,10 +114,7 @@ var Container = class Container {
152
114
  } };
153
115
  } };
154
116
  }
155
- /**
156
- * Run a callback within a scoped context.
157
- * Services resolved within the scope are cached and released when the scope ends.
158
- */
117
+ /** Services resolved inside the callback are cached for the scope and released when it ends. */
159
118
  scoped(callback) {
160
119
  this.scopedInstances.push(/* @__PURE__ */ new Map());
161
120
  try {
@@ -164,9 +123,6 @@ var Container = class Container {
164
123
  this.scopedInstances.pop();
165
124
  }
166
125
  }
167
- /**
168
- * Run an async callback within a scoped context.
169
- */
170
126
  async scopedAsync(callback) {
171
127
  this.scopedInstances.push(/* @__PURE__ */ new Map());
172
128
  try {
@@ -181,49 +137,28 @@ var Container = class Container {
181
137
  this.fakes.delete(key);
182
138
  } };
183
139
  }
184
- /**
185
- * Check if a service is currently faked.
186
- */
187
140
  isFaked(key) {
188
141
  return this.fakes.has(key);
189
142
  }
190
- /**
191
- * Remove all fakes.
192
- */
193
143
  clearFakes() {
194
144
  this.fakes.clear();
195
145
  }
196
- /**
197
- * Flush all resolved singleton instances.
198
- */
199
146
  flush() {
200
147
  for (const binding of this.bindings.values()) binding.instance = void 0;
201
148
  }
202
- /**
203
- * Remove a binding from the container.
204
- */
205
149
  forget(key) {
206
150
  const resolvedKey = this.resolveAlias(key);
207
151
  this.bindings.delete(resolvedKey);
208
152
  return this;
209
153
  }
210
- /**
211
- * Get all bound service keys.
212
- */
213
154
  getBindings() {
214
155
  return Array.from(this.bindings.keys());
215
156
  }
216
- /**
217
- * Get all aliases.
218
- */
219
157
  getAliases() {
220
158
  const result = {};
221
159
  for (const [alias, key] of this.aliases) result[alias] = key;
222
160
  return result;
223
161
  }
224
- /**
225
- * Get all tags.
226
- */
227
162
  getTags() {
228
163
  const result = {};
229
164
  for (const [tag, keys] of this.tags) result[tag] = Array.from(keys);
@@ -246,9 +181,6 @@ var Container = class Container {
246
181
  return null;
247
182
  }
248
183
  };
249
- /**
250
- * Create a new container instance.
251
- */
252
184
  function createContainer() {
253
185
  return new Container();
254
186
  }
@@ -265,94 +197,37 @@ function resolve(key) {
265
197
  }
266
198
  //#endregion
267
199
  //#region src/queue/Job.ts
268
- /**
269
- * Global queue driver instance.
270
- * Set via setQueueDriver() or QueueManager.
271
- */
272
200
  let globalDriver = null;
273
- /**
274
- * Set the global queue driver.
275
- */
276
201
  function setQueueDriver(driver) {
277
202
  globalDriver = driver;
278
203
  }
279
- /**
280
- * Get the global queue driver.
281
- */
282
204
  function getQueueDriver() {
283
205
  return globalDriver;
284
206
  }
285
- /**
286
- * Generate a unique job ID.
287
- */
288
207
  function generateJobId() {
289
208
  return randomBytes(16).toString("hex");
290
209
  }
291
- /**
292
- * Base class for defining jobs.
293
- *
294
- * @example
295
- * ```ts
296
- * class SendWelcomeEmailJob extends Job<{ userId: string }> {
297
- * static queue = 'emails'
298
- * static maxAttempts = 5
299
- *
300
- * async handle({ userId }: { userId: string }): Promise<void> {
301
- * const user = await User.find(userId)
302
- * await mail.to(user.email).template(WelcomeEmail, user).send()
303
- * }
304
- *
305
- * async failed({ userId }: { userId: string }, error: Error): Promise<void> {
306
- * console.error(`Failed to send welcome email to user ${userId}:`, error)
307
- * }
308
- * }
309
- *
310
- * // Dispatch the job
311
- * await SendWelcomeEmailJob.dispatch({ userId: '123' })
312
- *
313
- * // Dispatch with delay
314
- * await SendWelcomeEmailJob.dispatchAfter(60000, { userId: '123' })
315
- * ```
316
- */
317
210
  var Job = class {
318
211
  /**
319
- * Stable wire name for this job.
320
- *
321
- * Queued messages record this name, and the worker resolves the class back
322
- * from it. When omitted the class name is used, which breaks if a bundler
323
- * mangles identifiers or if the class is later renamed while messages are
324
- * still in flight. Set it to pin the name across both.
325
- *
212
+ * Stable wire name: queued messages record it and the worker resolves the
213
+ * class back from it. Defaults to the class name, which breaks under
214
+ * identifier mangling or a rename with messages still in flight.
326
215
  * @default the class name
327
216
  */
328
217
  static jobName;
329
- /**
330
- * The queue this job should be dispatched to.
331
- * @default 'default'
332
- */
218
+ /** @default 'default' */
333
219
  static queue = "default";
334
- /**
335
- * Maximum number of times the job should be attempted.
336
- * @default 3
337
- */
220
+ /** @default 3 */
338
221
  static maxAttempts = 3;
339
222
  /**
340
- * Backoff strategy for retries.
341
- * - 'exponential': 2^attempt * 1000ms (1s, 2s, 4s, 8s, ...)
342
- * - 'linear': attempt * 1000ms (1s, 2s, 3s, 4s, ...)
343
- * - number: fixed delay in milliseconds
223
+ * 'exponential' = 2^attempt * 1000ms, 'linear' = attempt * 1000ms, a number
224
+ * is a fixed delay in milliseconds.
344
225
  * @default 'exponential'
345
226
  */
346
227
  static backoff = "exponential";
347
228
  make(key) {
348
229
  return getContainer().make(key);
349
230
  }
350
- /**
351
- * Dispatch the job to the queue.
352
- *
353
- * @param payload - Job payload data
354
- * @param options - Optional dispatch options
355
- */
356
231
  static async dispatch(payload, options = {}) {
357
232
  const driver = globalDriver;
358
233
  if (!driver) throw new Error("Queue driver not configured. Call setQueueDriver() first.");
@@ -373,22 +248,12 @@ var Job = class {
373
248
  await driver.push(job);
374
249
  return jobId;
375
250
  }
376
- /**
377
- * Dispatch the job after a delay.
378
- *
379
- * @param delayMs - Delay in milliseconds
380
- * @param payload - Job payload data
381
- * @param options - Optional dispatch options (delay is overridden)
382
- */
383
251
  static async dispatchAfter(delayMs, payload, options = {}) {
384
252
  return this.dispatch(payload, {
385
253
  ...options,
386
254
  delay: delayMs
387
255
  });
388
256
  }
389
- /**
390
- * Calculate the retry delay based on backoff strategy.
391
- */
392
257
  static calculateRetryDelay(attempts) {
393
258
  if (typeof this.backoff === "number") return this.backoff;
394
259
  if (this.backoff === "linear") return attempts * 1e3;
@@ -396,44 +261,24 @@ var Job = class {
396
261
  }
397
262
  };
398
263
  /**
399
- * Resolve the wire name a job is queued and looked up under.
400
- *
401
- * Prefers an explicit `jobName` over the class name so that renaming the class
402
- * or bundling with identifier mangling does not orphan queued messages.
403
- *
404
- * Only an *own* `jobName` counts. Static members are inherited, so reading it
405
- * off the prototype chain would make every subclass of a pinned job claim its
406
- * parent's identity and overwrite it in the registry. A subclass that wants a
407
- * pinned name declares its own.
264
+ * Only an *own* `jobName` counts: statics are inherited, so reading the
265
+ * prototype chain would make every subclass of a pinned job claim its
266
+ * parent's identity and overwrite it in the registry.
408
267
  */
409
268
  function resolveJobName(jobClass) {
410
269
  return (Object.prototype.hasOwnProperty.call(jobClass, "jobName") ? jobClass.jobName : void 0) ?? jobClass.name;
411
270
  }
412
- /**
413
- * Job registry for looking up job classes by name.
414
- */
415
271
  const jobRegistry = /* @__PURE__ */ new Map();
416
- /**
417
- * Register a job class for the worker to use.
418
- */
419
272
  function registerJob(jobClass) {
420
273
  jobRegistry.set(resolveJobName(jobClass), jobClass);
421
274
  }
422
- /**
423
- * Get a registered job class by name.
424
- */
425
275
  function getJob(name) {
426
276
  return jobRegistry.get(name);
427
277
  }
428
- /**
429
- * Get all registered job classes.
430
- */
431
278
  function getRegisteredJobs() {
432
279
  return new Map(jobRegistry);
433
280
  }
434
- /**
435
- * Clear all registered jobs (for testing).
436
- */
281
+ /** Testing only. */
437
282
  function clearJobRegistry() {
438
283
  jobRegistry.clear();
439
284
  }