@guren/server 2.1.1 → 2.3.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 (281) hide show
  1. package/dist/{DocsViewerServiceProvider-D7RGJPGM.js → DocsViewerServiceProvider-RUYDFBMW.js} +2 -2
  2. package/dist/McpServiceProvider-FRJ5O7LT.js +8 -0
  3. package/dist/auth/AuthManager.d.ts +30 -0
  4. package/dist/auth/AuthenticatableModel.d.ts +25 -0
  5. package/dist/auth/RequestAuthContext.d.ts +24 -0
  6. package/dist/auth/SessionGuard.d.ts +31 -0
  7. package/dist/auth/api-token.d.ts +299 -0
  8. package/dist/auth/email-verification.d.ts +203 -0
  9. package/dist/auth/index.d.ts +18 -110
  10. package/dist/auth/index.js +4 -1
  11. package/dist/auth/oauth/index.d.ts +239 -0
  12. package/dist/auth/password/DefaultHasher.d.ts +13 -0
  13. package/dist/auth/password/NodeHasher.d.ts +22 -0
  14. package/dist/auth/password/PasswordHasher.d.ts +5 -0
  15. package/dist/auth/password/ScryptHasher.d.ts +26 -0
  16. package/dist/auth/password-reset.d.ts +91 -0
  17. package/dist/auth/providers/ModelUserProvider.d.ts +36 -0
  18. package/dist/auth/providers/UserProvider.d.ts +9 -0
  19. package/dist/auth/types.d.ts +102 -0
  20. package/dist/auth/utils.d.ts +39 -0
  21. package/dist/{Gate-CynjZCtS.d.ts → authorization/Gate.d.ts} +30 -111
  22. package/dist/authorization/Policy.d.ts +77 -0
  23. package/dist/authorization/index.d.ts +5 -129
  24. package/dist/authorization/index.js +3 -1
  25. package/dist/authorization/middleware.d.ts +49 -0
  26. package/dist/authorization/types.d.ts +108 -0
  27. package/dist/broadcasting/BroadcastManager.d.ts +205 -0
  28. package/dist/broadcasting/channels/Channel.d.ts +28 -0
  29. package/dist/broadcasting/channels/PresenceChannel.d.ts +72 -0
  30. package/dist/broadcasting/channels/PrivateChannel.d.ts +32 -0
  31. package/dist/broadcasting/channels/index.d.ts +3 -0
  32. package/dist/broadcasting/drivers/MemoryDriver.d.ts +93 -0
  33. package/dist/broadcasting/drivers/RedisDriver.d.ts +112 -0
  34. package/dist/broadcasting/drivers/index.d.ts +2 -0
  35. package/dist/broadcasting/index.d.ts +6 -233
  36. package/dist/broadcasting/index.js +1 -1
  37. package/dist/broadcasting/typed.d.ts +23 -0
  38. package/dist/broadcasting/types.d.ts +155 -0
  39. package/dist/cache/CacheManager.d.ts +87 -0
  40. package/dist/cache/TaggedCache.d.ts +62 -0
  41. package/dist/cache/index.d.ts +6 -233
  42. package/dist/cache/index.js +1 -1
  43. package/dist/cache/stores/FileStore.d.ts +64 -0
  44. package/dist/cache/stores/MemoryStore.d.ts +52 -0
  45. package/dist/cache/stores/RedisStore.d.ts +53 -0
  46. package/dist/{CacheManager-BmDzUKrF.d.ts → cache/types.d.ts} +26 -99
  47. package/dist/chunk-3KV5X2FL.js +31 -0
  48. package/dist/{chunk-TVY72CLV.js → chunk-4VE3LYOM.js} +3 -2
  49. package/dist/{chunk-DSDX3ASM.js → chunk-5WL2FTC4.js} +67 -85
  50. package/dist/{chunk-5SZTEZ22.js → chunk-6IGN233M.js} +15 -8
  51. package/dist/{chunk-FZD2AKJI.js → chunk-7OB2YXRE.js} +56 -28
  52. package/dist/{chunk-WIXGT4TN.js → chunk-A5JJ7XTH.js} +8 -2
  53. package/dist/{chunk-CWI4AJ47.js → chunk-HPET6XY5.js} +13 -9
  54. package/dist/{chunk-A3ISJVEV.js → chunk-HR2KZ3WL.js} +23 -5
  55. package/dist/{chunk-BZMZEFRG.js → chunk-LHR6OHI7.js} +11 -0
  56. package/dist/{chunk-JBG4AR24.js → chunk-Q2P6YLRR.js} +8 -2
  57. package/dist/{chunk-J6ETA476.js → chunk-TVV5YNEC.js} +101 -9
  58. package/dist/console/Command.d.ts +179 -0
  59. package/dist/{ConsoleKernel-CJg975mp.d.ts → console/ConsoleKernel.d.ts} +4 -6
  60. package/dist/console/Input.d.ts +140 -0
  61. package/dist/console/Output.d.ts +161 -0
  62. package/dist/console/index.d.ts +5 -0
  63. package/dist/console/types.d.ts +106 -0
  64. package/dist/container/Container.d.ts +148 -0
  65. package/dist/container/ServiceProvider.d.ts +103 -0
  66. package/dist/container/bindings.d.ts +55 -0
  67. package/dist/container/defineModule.d.ts +88 -0
  68. package/dist/container/definePlugin.d.ts +62 -0
  69. package/dist/container/index.d.ts +8 -0
  70. package/dist/container/types.d.ts +73 -0
  71. package/dist/database/Factory.d.ts +82 -0
  72. package/dist/database/Seeder.d.ts +35 -0
  73. package/dist/database/SeederRunner.d.ts +41 -0
  74. package/dist/database/index.d.ts +4 -0
  75. package/dist/database/types.d.ts +49 -0
  76. package/dist/discovery/AutoDiscovery.d.ts +113 -0
  77. package/dist/discovery/index.d.ts +2 -0
  78. package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +12 -0
  79. package/dist/docs-viewer/endpoint.d.ts +29 -0
  80. package/dist/encryption/Encrypter.d.ts +96 -0
  81. package/dist/encryption/Hash.d.ts +69 -0
  82. package/dist/encryption/MessageSigner.d.ts +21 -0
  83. package/dist/encryption/Random.d.ts +119 -0
  84. package/dist/encryption/app-key.d.ts +12 -0
  85. package/dist/encryption/index.d.ts +10 -222
  86. package/dist/encryption/signed-url.d.ts +9 -0
  87. package/dist/encryption/types.d.ts +103 -0
  88. package/dist/errors/ExceptionHandler.d.ts +118 -0
  89. package/dist/errors/HttpException.d.ts +106 -0
  90. package/dist/errors/debug-page.d.ts +22 -0
  91. package/dist/errors/error-page.d.ts +1 -0
  92. package/dist/errors/exceptions/AuthenticationException.d.ts +32 -0
  93. package/dist/errors/exceptions/AuthorizationException.d.ts +32 -0
  94. package/dist/errors/exceptions/MethodNotAllowedException.d.ts +31 -0
  95. package/dist/errors/exceptions/NotFoundHttpException.d.ts +36 -0
  96. package/dist/errors/exceptions/ValidationException.d.ts +60 -0
  97. package/dist/errors/exceptions/index.d.ts +5 -0
  98. package/dist/errors/index.d.ts +5 -0
  99. package/dist/errors/types.d.ts +43 -0
  100. package/dist/events/Event.d.ts +33 -0
  101. package/dist/{EventManager-CmIoLt7r.d.ts → events/EventManager.d.ts} +4 -86
  102. package/dist/events/Listener.d.ts +79 -0
  103. package/dist/events/builtin.d.ts +73 -0
  104. package/dist/events/index.d.ts +6 -155
  105. package/dist/events/types.d.ts +48 -0
  106. package/dist/facades/index.d.ts +31 -0
  107. package/dist/health/HealthCheck.d.ts +34 -0
  108. package/dist/health/HealthManager.d.ts +53 -0
  109. package/dist/health/checks/CacheCheck.d.ts +35 -0
  110. package/dist/health/checks/CustomCheck.d.ts +23 -0
  111. package/dist/health/checks/DatabaseCheck.d.ts +33 -0
  112. package/dist/health/checks/MemoryCheck.d.ts +32 -0
  113. package/dist/health/checks/RedisCheck.d.ts +27 -0
  114. package/dist/health/checks/StorageCheck.d.ts +35 -0
  115. package/dist/health/checks/index.d.ts +12 -0
  116. package/dist/health/index.d.ts +5 -185
  117. package/dist/health/types.d.ts +52 -0
  118. package/dist/hot-reload/hot-disposables.d.ts +96 -0
  119. package/dist/hot-reload/testing.d.ts +14 -0
  120. package/dist/http/Application.d.ts +199 -0
  121. package/dist/http/FormRequest.d.ts +73 -0
  122. package/dist/http/dev-assets.d.ts +62 -0
  123. package/dist/http/dev-banner.d.ts +7 -0
  124. package/dist/http/inertia-assets.d.ts +31 -0
  125. package/dist/http/middleware/auth.d.ts +13 -0
  126. package/dist/http/middleware/capabilities.d.ts +22 -0
  127. package/dist/http/middleware/cors.d.ts +40 -0
  128. package/dist/http/middleware/csp.d.ts +59 -0
  129. package/dist/http/middleware/csrf.d.ts +121 -0
  130. package/dist/http/middleware/detect-locale.d.ts +65 -0
  131. package/dist/http/middleware/force-https.d.ts +34 -0
  132. package/dist/http/middleware/host-authorization.d.ts +24 -0
  133. package/dist/http/middleware/index.d.ts +19 -0
  134. package/dist/http/middleware/loopback-guard.d.ts +51 -0
  135. package/dist/{rate-limit-D9J2b4S1.d.ts → http/middleware/rate-limit.d.ts} +22 -50
  136. package/dist/http/middleware/redirect-safety.d.ts +29 -0
  137. package/dist/http/middleware/request-id.d.ts +19 -0
  138. package/dist/http/middleware/request-logging.d.ts +16 -0
  139. package/dist/http/middleware/response-headers.d.ts +18 -0
  140. package/dist/http/middleware/security-headers.d.ts +49 -0
  141. package/dist/http/middleware/session.d.ts +93 -0
  142. package/dist/http/middleware/validation.d.ts +94 -0
  143. package/dist/http/public-assets.d.ts +15 -0
  144. package/dist/http/request.d.ts +24 -0
  145. package/dist/http/resources/CursorPaginator.d.ts +106 -0
  146. package/dist/http/resources/Paginator.d.ts +130 -0
  147. package/dist/http/resources/Resource.d.ts +67 -0
  148. package/dist/http/resources/ResourceCollection.d.ts +60 -0
  149. package/dist/http/resources/index.d.ts +6 -0
  150. package/dist/http/resources/types.d.ts +91 -0
  151. package/dist/http/validation/Validator.d.ts +128 -0
  152. package/dist/http/validation/index.d.ts +3 -0
  153. package/dist/http/validation/rules.d.ts +196 -0
  154. package/dist/http/validation/types.d.ts +96 -0
  155. package/dist/http/vite-dev-server.d.ts +27 -0
  156. package/dist/i18n/I18nManager.d.ts +114 -0
  157. package/dist/i18n/Translator.d.ts +80 -0
  158. package/dist/i18n/index.d.ts +6 -101
  159. package/dist/i18n/index.js +5 -3
  160. package/dist/i18n/loaders/JsonLoader.d.ts +47 -0
  161. package/dist/i18n/loaders/MemoryLoader.d.ts +37 -0
  162. package/dist/i18n/pluralization.d.ts +19 -0
  163. package/dist/i18n/types.d.ts +106 -0
  164. package/dist/index.d.ts +69 -2605
  165. package/dist/index.js +405 -180
  166. package/dist/lambda/index.d.ts +17 -37
  167. package/dist/logging/LogManager.d.ts +83 -0
  168. package/dist/logging/Logger.d.ts +76 -0
  169. package/dist/logging/channels/ConsoleChannel.d.ts +11 -0
  170. package/dist/logging/channels/DailyFileChannel.d.ts +20 -0
  171. package/dist/logging/channels/FileChannel.d.ts +15 -0
  172. package/dist/logging/index.d.ts +8 -50
  173. package/dist/logging/types.d.ts +96 -0
  174. package/dist/mail/Mail.d.ts +138 -0
  175. package/dist/mail/MailManager.d.ts +79 -0
  176. package/dist/mail/address.d.ts +8 -0
  177. package/dist/mail/index.d.ts +7 -316
  178. package/dist/mail/transports/LogTransport.d.ts +19 -0
  179. package/dist/mail/transports/MemoryTransport.d.ts +84 -0
  180. package/dist/mail/transports/ResendTransport.d.ts +32 -0
  181. package/dist/mail/transports/SmtpTransport.d.ts +40 -0
  182. package/dist/{MailManager-DpMvYiP9.d.ts → mail/types.d.ts} +11 -92
  183. package/dist/mcp/McpServiceProvider.d.ts +17 -0
  184. package/dist/mcp/create-mcp-server.d.ts +152 -0
  185. package/dist/mcp/endpoint.d.ts +47 -0
  186. package/dist/mcp/index.d.ts +3 -185
  187. package/dist/mcp/index.js +3 -3
  188. package/dist/mvc/Controller.d.ts +326 -0
  189. package/dist/mvc/Router.d.ts +239 -0
  190. package/dist/mvc/ViewEngine.d.ts +11 -0
  191. package/dist/mvc/inertia/InertiaEngine.d.ts +114 -0
  192. package/dist/mvc/inertia/shared.d.ts +90 -0
  193. package/dist/mvc/mount-route.d.ts +10 -0
  194. package/dist/notifications/Notification.d.ts +99 -0
  195. package/dist/notifications/NotificationManager.d.ts +150 -0
  196. package/dist/notifications/channels/DatabaseChannel.d.ts +55 -0
  197. package/dist/notifications/channels/MailChannel.d.ts +45 -0
  198. package/dist/notifications/channels/MemoryChannel.d.ts +85 -0
  199. package/dist/notifications/channels/SlackChannel.d.ts +73 -0
  200. package/dist/notifications/channels/index.d.ts +4 -0
  201. package/dist/notifications/index.d.ts +6 -322
  202. package/dist/notifications/notifiable-type.d.ts +10 -0
  203. package/dist/notifications/registry.d.ts +39 -0
  204. package/dist/notifications/types.d.ts +162 -0
  205. package/dist/providers/AuthServiceProvider.d.ts +7 -0
  206. package/dist/providers/AuthorizationServiceProvider.d.ts +9 -0
  207. package/dist/providers/BroadcastServiceProvider.d.ts +7 -0
  208. package/dist/providers/CacheServiceProvider.d.ts +7 -0
  209. package/dist/providers/EncryptionServiceProvider.d.ts +7 -0
  210. package/dist/providers/ErrorServiceProvider.d.ts +9 -0
  211. package/dist/providers/EventServiceProvider.d.ts +7 -0
  212. package/dist/providers/HealthServiceProvider.d.ts +7 -0
  213. package/dist/providers/I18nServiceProvider.d.ts +27 -0
  214. package/dist/providers/InertiaServiceProvider.d.ts +20 -0
  215. package/dist/providers/LogServiceProvider.d.ts +7 -0
  216. package/dist/providers/MailServiceProvider.d.ts +7 -0
  217. package/dist/providers/NotificationServiceProvider.d.ts +8 -0
  218. package/dist/providers/OAuthServiceProvider.d.ts +7 -0
  219. package/dist/providers/QueueServiceProvider.d.ts +7 -0
  220. package/dist/providers/SchedulingServiceProvider.d.ts +7 -0
  221. package/dist/providers/StorageServiceProvider.d.ts +7 -0
  222. package/dist/providers/index.d.ts +17 -0
  223. package/dist/queue/FailedJobReporter.d.ts +40 -0
  224. package/dist/queue/Job.d.ts +140 -0
  225. package/dist/queue/QueueManager.d.ts +79 -0
  226. package/dist/queue/Worker.d.ts +99 -0
  227. package/dist/queue/drivers/MemoryDriver.d.ts +60 -0
  228. package/dist/queue/drivers/RedisDriver.d.ts +96 -0
  229. package/dist/queue/drivers/SqsDriver.d.ts +108 -0
  230. package/dist/queue/drivers/SyncDriver.d.ts +28 -0
  231. package/dist/queue/index.d.ts +9 -453
  232. package/dist/queue/types.d.ts +171 -0
  233. package/dist/redis/RedisApiTokenStore.d.ts +78 -0
  234. package/dist/redis/RedisEmailVerificationStore.d.ts +54 -0
  235. package/dist/redis/RedisOAuthStateStore.d.ts +26 -0
  236. package/dist/redis/RedisPasswordResetStore.d.ts +57 -0
  237. package/dist/redis/RedisRateLimitStore.d.ts +77 -0
  238. package/dist/redis/RedisSessionStore.d.ts +61 -0
  239. package/dist/redis/client.d.ts +41 -0
  240. package/dist/redis/index.d.ts +14 -356
  241. package/dist/redis/index.js +45 -9
  242. package/dist/redis/redis-values.d.ts +17 -0
  243. package/dist/redis/scan-keys.d.ts +6 -0
  244. package/dist/runtime/index.d.ts +8 -95
  245. package/dist/runtime/index.js +101 -68
  246. package/dist/scheduling/CronParser.d.ts +37 -0
  247. package/dist/scheduling/Schedule.d.ts +229 -0
  248. package/dist/scheduling/ScheduledTask.d.ts +47 -0
  249. package/dist/scheduling/Scheduler.d.ts +99 -0
  250. package/dist/scheduling/index.d.ts +5 -41
  251. package/dist/scheduling/types.d.ts +97 -0
  252. package/dist/storage/StorageManager.d.ts +65 -0
  253. package/dist/storage/drivers/LocalDriver.d.ts +55 -0
  254. package/dist/storage/drivers/MemoryDriver.d.ts +66 -0
  255. package/dist/storage/drivers/S3Driver.d.ts +72 -0
  256. package/dist/storage/index.d.ts +5 -197
  257. package/dist/{StorageManager-oZTHqaza.d.ts → storage/types.d.ts} +10 -77
  258. package/dist/support/contained-path.d.ts +26 -0
  259. package/dist/support/error-polyfill.d.ts +9 -0
  260. package/dist/support/expiry.d.ts +47 -0
  261. package/dist/support/expiry.js +12 -0
  262. package/dist/support/import-map.d.ts +13 -0
  263. package/dist/support/redirect-target.d.ts +11 -0
  264. package/dist/support/stack-frames.d.ts +56 -0
  265. package/dist/support/trim-slashes.d.ts +11 -0
  266. package/dist/vite/index.d.ts +2 -35
  267. package/dist/vite/index.js +0 -3
  268. package/dist/vite/plugin.d.ts +34 -0
  269. package/package.json +7 -3
  270. package/dist/AuthManager-DBP4KYsx.d.ts +0 -79
  271. package/dist/BroadcastManager-D8KoJxiV.d.ts +0 -492
  272. package/dist/HealthManager-DUyMIzsZ.d.ts +0 -141
  273. package/dist/I18nManager-BiSoczfV.d.ts +0 -275
  274. package/dist/LogManager-7mxnkaPM.d.ts +0 -256
  275. package/dist/McpServiceProvider-7BB5FPF3.js +0 -8
  276. package/dist/Scheduler-pZiT8i57.d.ts +0 -471
  277. package/dist/api-token-D24VPr_E.d.ts +0 -663
  278. package/dist/app-key-CsBfRC_Q.d.ts +0 -214
  279. package/dist/email-verification-Dx426KLn.d.ts +0 -336
  280. package/dist/index-9_Jzj5jo.d.ts +0 -7
  281. package/dist/validation-yAL53e1S.d.ts +0 -2610
@@ -1,222 +1,10 @@
1
- import { A as AppKeyring, H as HashAlgorithm, P as PasswordHashOptions, d as HmacOptions, R as RandomStringOptions } from '../app-key-CsBfRC_Q.js';
2
- export { D as DecryptOptions, a as EncryptOptions, b as EncryptedPayload, E as Encrypter, c as EncrypterConfig, e as createEncrypter, f as decrypt, g as deriveAppKey, h as deriveAppKeyring, q as encodeDerivedKey, i as encrypt, j as generateAppKey, k as generateKey, l as getAppKeyringFromEnv, m as getEncrypter, n as normalizeAppKey, p as parseAppKey, o as parsePreviousAppKeys, s as setEncrypter } from '../app-key-CsBfRC_Q.js';
3
-
4
- interface SignedMessageClaims {
5
- purpose?: string;
6
- iat: number;
7
- exp?: number;
8
- [key: string]: unknown;
9
- }
10
- interface SignMessageOptions {
11
- purpose?: string;
12
- expiresIn?: number;
13
- }
14
- interface VerifySignedMessageOptions {
15
- purpose?: string;
16
- allowExpired?: boolean;
17
- }
18
- declare class MessageSigner {
19
- private readonly keyring;
20
- constructor(keyring: AppKeyring);
21
- sign<T extends Record<string, unknown>>(payload: T, options?: SignMessageOptions): string;
22
- verify<T extends Record<string, unknown> = Record<string, unknown>>(token: string, options?: VerifySignedMessageOptions): (T & SignedMessageClaims) | null;
23
- }
24
-
25
- interface SignedUrlOptions {
26
- expiresIn?: number;
27
- }
28
- interface VerifySignedUrlOptions {
29
- requireExpiration?: boolean;
30
- }
31
- declare function signUrl(value: string, keyring: AppKeyring, options?: SignedUrlOptions): string;
32
- declare function verifySignedUrl(value: string, keyring: AppKeyring, options?: VerifySignedUrlOptions): boolean;
33
-
34
- /**
35
- * Hash a value using the specified algorithm.
36
- *
37
- * @example
38
- * ```typescript
39
- * hash('hello') // SHA-256 by default
40
- * hash('hello', 'sha512')
41
- * hash('hello', 'md5')
42
- * ```
43
- */
44
- declare function hash(value: string | Buffer, algorithm?: HashAlgorithm, encoding?: 'hex' | 'base64'): string;
45
- /**
46
- * Create an HMAC signature.
47
- *
48
- * @example
49
- * ```typescript
50
- * hmac('message', 'secret-key')
51
- * hmac('message', 'secret-key', { algorithm: 'sha512' })
52
- * ```
53
- */
54
- declare function hmac(value: string | Buffer, key: string | Buffer, options?: HmacOptions): string;
55
- /**
56
- * Verify an HMAC signature.
57
- */
58
- declare function verifyHmac(value: string | Buffer, signature: string, key: string | Buffer, options?: HmacOptions): boolean;
59
- /**
60
- * Create a SHA-256 hash.
61
- */
62
- declare function sha256(value: string | Buffer): string;
63
- /**
64
- * Create a SHA-512 hash.
65
- */
66
- declare function sha512(value: string | Buffer): string;
67
- /**
68
- * Create an MD5 hash (not secure, use only for checksums).
69
- */
70
- declare function md5(value: string | Buffer): string;
71
- /**
72
- * Hash a password using scrypt.
73
- *
74
- * @example
75
- * ```typescript
76
- * const hashed = await hashPassword('mypassword')
77
- * // Returns: $scrypt$N=16384,r=8,p=1$salt$hash
78
- * ```
79
- */
80
- declare function hashPassword(password: string, options?: PasswordHashOptions): Promise<string>;
81
- /**
82
- * Verify a password against a hash.
83
- *
84
- * @example
85
- * ```typescript
86
- * const isValid = await verifyPassword('mypassword', hashedPassword)
87
- * ```
88
- */
89
- declare function verifyPassword(password: string, hash: string): Promise<boolean>;
90
- /**
91
- * Check if a password needs to be rehashed (parameters changed).
92
- */
93
- declare function needsRehash(hash: string, options?: PasswordHashOptions): boolean;
94
- /**
95
- * Constant-time string comparison.
96
- */
97
- declare function secureCompare(a: string, b: string): boolean;
98
- /**
99
- * Check if a value matches a hash.
100
- */
101
- declare function check(value: string | Buffer, hash: string, algorithm?: HashAlgorithm): boolean;
102
-
103
- /**
104
- * Generate a cryptographically secure random string.
105
- *
106
- * @example
107
- * ```typescript
108
- * randomString(32) // 32-character alphanumeric string
109
- * randomString(16, { charset: 'hex' }) // 16-character hex string
110
- * randomString(24, { charset: 'url-safe' }) // URL-safe string
111
- * ```
112
- */
113
- declare function randomString(length: number, options?: RandomStringOptions): string;
114
- /**
115
- * Generate random bytes.
116
- *
117
- * @example
118
- * ```typescript
119
- * const bytes = random(32) // 32 random bytes
120
- * ```
121
- */
122
- declare function random(length: number): Buffer;
123
- /**
124
- * Generate random bytes as hex string.
125
- */
126
- declare function randomHex(length: number): string;
127
- /**
128
- * Generate random bytes as base64 string.
129
- */
130
- declare function randomBase64(length: number): string;
131
- /**
132
- * Generate random bytes as URL-safe base64 string.
133
- */
134
- declare function randomBase64Url(length: number): string;
135
- /**
136
- * Generate a UUID v4.
137
- *
138
- * @example
139
- * ```typescript
140
- * const id = uuid() // e.g., '550e8400-e29b-41d4-a716-446655440000'
141
- * ```
142
- */
143
- declare function uuid(): string;
144
- /**
145
- * Generate a secure random integer.
146
- *
147
- * @example
148
- * ```typescript
149
- * randomInt(1, 100) // Random number between 1 and 100 (inclusive)
150
- * ```
151
- */
152
- declare function randomInt(min: number, max: number): number;
153
- /**
154
- * Generate a random token suitable for URLs.
155
- *
156
- * @example
157
- * ```typescript
158
- * const token = urlSafeToken(32) // URL-safe 32-character token
159
- * ```
160
- */
161
- declare function urlSafeToken(length?: number): string;
162
- /**
163
- * Generate a secure random password.
164
- *
165
- * @example
166
- * ```typescript
167
- * const password = generatePassword(16) // Random 16-character password
168
- * ```
169
- */
170
- declare function generatePassword(length?: number, options?: {
171
- uppercase?: boolean;
172
- lowercase?: boolean;
173
- numbers?: boolean;
174
- symbols?: boolean;
175
- }): string;
176
- /**
177
- * Generate a random OTP (One-Time Password).
178
- *
179
- * @example
180
- * ```typescript
181
- * const otp = generateOtp(6) // e.g., '482901'
182
- * ```
183
- */
184
- declare function generateOtp(length?: number): string;
185
- /**
186
- * Generate a random slug-friendly string.
187
- *
188
- * @example
189
- * ```typescript
190
- * const slug = generateSlug() // e.g., 'a8b2c4d6e8'
191
- * ```
192
- */
193
- declare function generateSlug(length?: number): string;
194
- /**
195
- * Shuffle an array using Fisher-Yates algorithm with secure random.
196
- *
197
- * @example
198
- * ```typescript
199
- * const shuffled = shuffle([1, 2, 3, 4, 5])
200
- * ```
201
- */
202
- declare function shuffle<T>(array: T[]): T[];
203
- /**
204
- * Pick a random element from an array.
205
- *
206
- * @example
207
- * ```typescript
208
- * const item = pick(['a', 'b', 'c']) // Random element
209
- * ```
210
- */
211
- declare function pick<T>(array: T[]): T;
212
- /**
213
- * Pick multiple random elements from an array.
214
- *
215
- * @example
216
- * ```typescript
217
- * const items = sample(['a', 'b', 'c', 'd'], 2) // Two random elements
218
- * ```
219
- */
220
- declare function sample<T>(array: T[], count: number): T[];
221
-
222
- export { AppKeyring, HashAlgorithm, HmacOptions, MessageSigner, PasswordHashOptions, RandomStringOptions, type SignMessageOptions, type SignedMessageClaims, type SignedUrlOptions, type VerifySignedMessageOptions, type VerifySignedUrlOptions, check, generateOtp, generatePassword, generateSlug, hash, hashPassword, hmac, md5, needsRehash, pick, random, randomBase64, randomBase64Url, randomHex, randomInt, randomString, sample, secureCompare, sha256, sha512, shuffle, signUrl, urlSafeToken, uuid, verifyHmac, verifyPassword, verifySignedUrl };
1
+ export type { EncryptOptions, DecryptOptions, EncrypterConfig, EncryptedPayload, HashAlgorithm, HmacOptions, PasswordHashOptions, RandomStringOptions, } from './types.js';
2
+ export { Encrypter, generateKey, createEncrypter, setEncrypter, getEncrypter, encrypt, decrypt, } from './Encrypter.js';
3
+ export { generateAppKey, normalizeAppKey, parseAppKey, parsePreviousAppKeys, getAppKeyringFromEnv, deriveAppKey, deriveAppKeyring, encodeDerivedKey, } from './app-key.js';
4
+ export type { AppKeyring } from './app-key.js';
5
+ export { MessageSigner } from './MessageSigner.js';
6
+ export type { SignedMessageClaims, SignMessageOptions, VerifySignedMessageOptions, } from './MessageSigner.js';
7
+ export { signUrl, verifySignedUrl } from './signed-url.js';
8
+ export type { SignedUrlOptions, VerifySignedUrlOptions } from './signed-url.js';
9
+ export { hash, hmac, verifyHmac, sha256, sha512, md5, hashPassword, verifyPassword, needsRehash, secureCompare, check, } from './Hash.js';
10
+ export { randomString, random, randomHex, randomBase64, randomBase64Url, uuid, randomInt, urlSafeToken, generatePassword, generateOtp, generateSlug, shuffle, pick, sample, } from './Random.js';
@@ -0,0 +1,9 @@
1
+ import type { AppKeyring } from './app-key.js';
2
+ export interface SignedUrlOptions {
3
+ expiresIn?: number;
4
+ }
5
+ export interface VerifySignedUrlOptions {
6
+ requireExpiration?: boolean;
7
+ }
8
+ export declare function signUrl(value: string, keyring: AppKeyring, options?: SignedUrlOptions): string;
9
+ export declare function verifySignedUrl(value: string, keyring: AppKeyring, options?: VerifySignedUrlOptions): boolean;
@@ -0,0 +1,103 @@
1
+ /**
2
+ * Encryption options.
3
+ */
4
+ export interface EncryptOptions {
5
+ /**
6
+ * Whether to serialize the value before encryption.
7
+ */
8
+ serialize?: boolean;
9
+ }
10
+ /**
11
+ * Decryption options.
12
+ */
13
+ export interface DecryptOptions {
14
+ /**
15
+ * Whether to deserialize the value after decryption.
16
+ */
17
+ deserialize?: boolean;
18
+ }
19
+ /**
20
+ * Encrypter configuration.
21
+ */
22
+ export interface EncrypterConfig {
23
+ /**
24
+ * Encryption key (base64 encoded, 32 bytes for AES-256).
25
+ */
26
+ key: string;
27
+ /**
28
+ * Previous encryption keys used for decryption fallback during key rotation.
29
+ */
30
+ previousKeys?: string[];
31
+ /**
32
+ * Encryption cipher to use.
33
+ */
34
+ cipher?: 'aes-256-gcm' | 'aes-256-cbc';
35
+ }
36
+ /**
37
+ * Encrypted payload structure.
38
+ */
39
+ export interface EncryptedPayload {
40
+ /**
41
+ * Initialization vector (base64).
42
+ */
43
+ iv: string;
44
+ /**
45
+ * Encrypted value (base64).
46
+ */
47
+ value: string;
48
+ /**
49
+ * Authentication tag for GCM mode (base64).
50
+ */
51
+ tag?: string;
52
+ /**
53
+ * MAC for CBC mode (hex).
54
+ */
55
+ mac?: string;
56
+ }
57
+ /**
58
+ * Hash algorithm options.
59
+ */
60
+ export type HashAlgorithm = 'sha256' | 'sha384' | 'sha512' | 'md5' | 'sha1';
61
+ /**
62
+ * HMAC options.
63
+ */
64
+ export interface HmacOptions {
65
+ /**
66
+ * Hash algorithm to use.
67
+ */
68
+ algorithm?: HashAlgorithm;
69
+ /**
70
+ * Output encoding.
71
+ */
72
+ encoding?: 'hex' | 'base64';
73
+ }
74
+ /**
75
+ * Password hash options.
76
+ */
77
+ export interface PasswordHashOptions {
78
+ /**
79
+ * Memory cost (for scrypt/argon2).
80
+ */
81
+ memory?: number;
82
+ /**
83
+ * CPU cost (for scrypt/argon2).
84
+ */
85
+ cost?: number;
86
+ /**
87
+ * Salt length in bytes.
88
+ */
89
+ saltLength?: number;
90
+ /**
91
+ * Key length in bytes.
92
+ */
93
+ keyLength?: number;
94
+ }
95
+ /**
96
+ * Random string options.
97
+ */
98
+ export interface RandomStringOptions {
99
+ /**
100
+ * Character set to use.
101
+ */
102
+ charset?: 'alphanumeric' | 'alphabetic' | 'numeric' | 'hex' | 'base64' | 'url-safe';
103
+ }
@@ -0,0 +1,118 @@
1
+ import type { Context } from '../http/Application.js';
2
+ import type { Middleware } from '../http/middleware/index.js';
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
+ */
28
+ export declare class ExceptionHandler {
29
+ /**
30
+ * Exception reporters.
31
+ */
32
+ protected reporters: ExceptionReporter[];
33
+ /**
34
+ * Exception renderers.
35
+ */
36
+ protected renderers: RendererRegistration[];
37
+ /**
38
+ * Exception classes to not report.
39
+ */
40
+ protected dontReportClasses: ExceptionClass[];
41
+ /**
42
+ * Handler options.
43
+ */
44
+ protected options: ExceptionHandlerOptions;
45
+ constructor(options?: ExceptionHandlerOptions);
46
+ /**
47
+ * Register an exception reporter.
48
+ * Reporters are called for every exception (unless in dontReport list).
49
+ */
50
+ report(callback: ExceptionReporter): this;
51
+ /**
52
+ * Register a custom renderer for an exception type.
53
+ */
54
+ 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
+ dontReport(errorClass: ExceptionClass): this;
59
+ /**
60
+ * Check if debug mode is enabled.
61
+ */
62
+ shouldShowDetails(): boolean;
63
+ /**
64
+ * Handle an exception.
65
+ */
66
+ handle(error: Error, ctx: Context): Promise<Response>;
67
+ /**
68
+ * Report an exception to all reporters.
69
+ */
70
+ protected reportException(error: Error): Promise<void>;
71
+ /**
72
+ * Check if an exception should not be reported.
73
+ */
74
+ protected shouldNotReport(error: Error): boolean;
75
+ protected matchesErrorClass(error: Error, errorClass: ExceptionClass): boolean;
76
+ /**
77
+ * Render an exception to a response.
78
+ */
79
+ protected renderException(error: Error, ctx: Context): Promise<Response>;
80
+ /**
81
+ * Default exception rendering.
82
+ */
83
+ 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
+ */
89
+ protected wantsHtmlResponse(ctx: Context): boolean;
90
+ /**
91
+ * Create middleware for exception handling.
92
+ */
93
+ middleware(): Middleware;
94
+ }
95
+ /**
96
+ * Create an exception handler.
97
+ */
98
+ export declare function createExceptionHandler(options?: ExceptionHandlerOptions): ExceptionHandler;
99
+ /**
100
+ * Set the global exception handler.
101
+ */
102
+ export declare function setExceptionHandler(handler: ExceptionHandler): void;
103
+ /**
104
+ * Get the global exception handler.
105
+ */
106
+ export declare function getExceptionHandler(): ExceptionHandler;
107
+ /**
108
+ * Abort the request with an HTTP exception.
109
+ */
110
+ export declare function abort(statusCode: number, message?: string, errors?: Record<string, string[]>): never;
111
+ /**
112
+ * Abort if condition is true.
113
+ */
114
+ export declare function abortIf(condition: boolean, statusCode: number, message?: string): void;
115
+ /**
116
+ * Abort unless condition is true.
117
+ */
118
+ export declare function abortUnless(condition: boolean, statusCode: number, message?: string): void;
@@ -0,0 +1,106 @@
1
+ import type { ErrorResponse } from './types.js';
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
+ */
21
+ export declare class HttpException extends Error {
22
+ /**
23
+ * HTTP status code.
24
+ */
25
+ readonly statusCode: number;
26
+ /**
27
+ * Validation or field-specific errors.
28
+ */
29
+ readonly errors?: Record<string, string[]>;
30
+ /**
31
+ * Additional error data.
32
+ */
33
+ readonly data?: Record<string, unknown>;
34
+ constructor(statusCode: number, message: string, errors?: Record<string, string[]>, data?: Record<string, unknown>);
35
+ /**
36
+ * Convert to response format.
37
+ */
38
+ toResponse(debug?: boolean): {
39
+ status: number;
40
+ body: ErrorResponse;
41
+ };
42
+ /**
43
+ * Convert to JSON.
44
+ */
45
+ toJSON(): Record<string, unknown>;
46
+ /**
47
+ * Create a 400 Bad Request exception.
48
+ */
49
+ static badRequest(message?: string): HttpException;
50
+ /**
51
+ * Create a 401 Unauthorized exception.
52
+ */
53
+ static unauthorized(message?: string): HttpException;
54
+ /**
55
+ * Create a 403 Forbidden exception.
56
+ */
57
+ static forbidden(message?: string): HttpException;
58
+ /**
59
+ * Create a 404 Not Found exception.
60
+ */
61
+ static notFound(message?: string): HttpException;
62
+ /**
63
+ * Create a 405 Method Not Allowed exception.
64
+ */
65
+ static methodNotAllowed(message?: string): HttpException;
66
+ /**
67
+ * Create a 409 Conflict exception.
68
+ */
69
+ static conflict(message?: string): HttpException;
70
+ /**
71
+ * Create a 410 Gone exception.
72
+ */
73
+ static gone(message?: string): HttpException;
74
+ /**
75
+ * Create a 422 Unprocessable Entity exception.
76
+ */
77
+ static unprocessable(message?: string, errors?: Record<string, string[]>): HttpException;
78
+ /**
79
+ * Create a 429 Too Many Requests exception.
80
+ */
81
+ static tooManyRequests(message?: string): HttpException;
82
+ /**
83
+ * Create a 500 Internal Server Error exception.
84
+ */
85
+ static internal(message?: string): HttpException;
86
+ /**
87
+ * Create a 501 Not Implemented exception.
88
+ */
89
+ static notImplemented(message?: string): HttpException;
90
+ /**
91
+ * Create a 502 Bad Gateway exception.
92
+ */
93
+ static badGateway(message?: string): HttpException;
94
+ /**
95
+ * Create a 503 Service Unavailable exception.
96
+ */
97
+ static serviceUnavailable(message?: string): HttpException;
98
+ /**
99
+ * Create a 504 Gateway Timeout exception.
100
+ */
101
+ static gatewayTimeout(message?: string): HttpException;
102
+ /**
103
+ * Check if an error is an HTTP exception.
104
+ */
105
+ static isHttpException(error: unknown): error is HttpException;
106
+ }
@@ -0,0 +1,22 @@
1
+ import type { MiddlewareHandler } from 'hono';
2
+ /**
3
+ * Render a rich HTML debug error page for development mode.
4
+ *
5
+ * When an error occurs and NODE_ENV is not 'production', this function
6
+ * generates a helpful page displaying the error class, message, stack trace
7
+ * with source context, and request details.
8
+ */
9
+ export declare function renderDebugPage(error: Error, request?: Request): string;
10
+ /**
11
+ * Middleware that catches errors and renders a debug page in development.
12
+ * In production (NODE_ENV === 'production'), errors are re-thrown so
13
+ * downstream handlers or the ExceptionHandler can process them normally.
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * import { debugErrorMiddleware } from '@guren/server/errors/debug-page'
18
+ *
19
+ * app.use('*', debugErrorMiddleware())
20
+ * ```
21
+ */
22
+ export declare function debugErrorMiddleware(): MiddlewareHandler;
@@ -0,0 +1 @@
1
+ export declare function renderErrorPage(statusCode: number, message?: string): string;
@@ -0,0 +1,32 @@
1
+ import { HttpException } from '../HttpException.js';
2
+ /**
3
+ * Authentication exception.
4
+ *
5
+ * Thrown when a user is not authenticated or credentials are invalid.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * throw new AuthenticationException()
10
+ * throw new AuthenticationException('Invalid token')
11
+ * throw new AuthenticationException('Session expired', 'login')
12
+ * ```
13
+ */
14
+ export declare class AuthenticationException extends HttpException {
15
+ /**
16
+ * The guard that threw the exception.
17
+ */
18
+ readonly guard?: string;
19
+ /**
20
+ * URL to redirect to for authentication.
21
+ */
22
+ readonly redirectTo?: string;
23
+ constructor(message?: string, guard?: string, redirectTo?: string);
24
+ /**
25
+ * Create exception with redirect URL.
26
+ */
27
+ static withRedirect(redirectTo: string, message?: string): AuthenticationException;
28
+ /**
29
+ * Create exception for a specific guard.
30
+ */
31
+ static forGuard(guard: string, message?: string): AuthenticationException;
32
+ }
@@ -0,0 +1,32 @@
1
+ import { HttpException } from '../HttpException.js';
2
+ /**
3
+ * Authorization exception.
4
+ *
5
+ * Thrown when a user is authenticated but not authorized to perform an action.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * throw new AuthorizationException()
10
+ * throw new AuthorizationException('You cannot edit this post')
11
+ * throw new AuthorizationException('Access denied', 'edit', 'Post')
12
+ * ```
13
+ */
14
+ export declare class AuthorizationException extends HttpException {
15
+ /**
16
+ * The action that was attempted.
17
+ */
18
+ readonly action?: string;
19
+ /**
20
+ * The resource that was being accessed.
21
+ */
22
+ readonly resource?: string;
23
+ constructor(message?: string, action?: string, resource?: string);
24
+ /**
25
+ * Create exception for a specific action and resource.
26
+ */
27
+ static forAction(action: string, resource?: string): AuthorizationException;
28
+ /**
29
+ * Deny access to a resource.
30
+ */
31
+ static deny(resource?: string): AuthorizationException;
32
+ }
@@ -0,0 +1,31 @@
1
+ import { HttpException } from '../HttpException.js';
2
+ /**
3
+ * Method Not Allowed exception.
4
+ *
5
+ * Thrown when an HTTP method is not allowed for a route.
6
+ *
7
+ * @example
8
+ * ```typescript
9
+ * throw new MethodNotAllowedException()
10
+ * throw new MethodNotAllowedException('POST', ['GET', 'HEAD'])
11
+ * ```
12
+ */
13
+ export declare class MethodNotAllowedException extends HttpException {
14
+ /**
15
+ * The HTTP method that was attempted.
16
+ */
17
+ readonly method?: string;
18
+ /**
19
+ * The allowed HTTP methods.
20
+ */
21
+ readonly allowedMethods?: string[];
22
+ constructor(method?: string, allowedMethods?: string[], message?: string);
23
+ /**
24
+ * Get the Allow header value.
25
+ */
26
+ getAllowHeader(): string;
27
+ /**
28
+ * Create exception with method details.
29
+ */
30
+ static forMethod(method: string, allowedMethods: string[]): MethodNotAllowedException;
31
+ }