@guren/server 1.0.0-rc.9 → 1.0.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 (68) hide show
  1. package/dist/{Application-DtWDHXr1.d.ts → Application-BnsyCKXY.d.ts} +79 -8
  2. package/dist/AuthManager-SfhCNkAU.d.ts +79 -0
  3. package/dist/{BroadcastManager-AkIWUGJo.d.ts → BroadcastManager-CGWl9rUO.d.ts} +5 -0
  4. package/dist/{ConsoleKernel-CqCVrdZs.d.ts → ConsoleKernel-BDtBETjm.d.ts} +1 -1
  5. package/dist/{Gate-CNkBYf8m.d.ts → Gate-CynjZCtS.d.ts} +5 -0
  6. package/dist/{I18nManager-Dtgzsf5n.d.ts → I18nManager-BiSoczfV.d.ts} +6 -1
  7. package/dist/McpServiceProvider-JW6PDVMD.js +7 -0
  8. package/dist/api-token-BSSCLlFW.d.ts +541 -0
  9. package/dist/auth/index.d.ts +9 -327
  10. package/dist/auth/index.js +59 -6684
  11. package/dist/authorization/index.d.ts +2 -2
  12. package/dist/authorization/index.js +19 -604
  13. package/dist/broadcasting/index.d.ts +2 -2
  14. package/dist/broadcasting/index.js +12 -895
  15. package/dist/cache/index.js +8 -809
  16. package/dist/chunk-2T6JN4VR.js +1563 -0
  17. package/dist/chunk-44F7JQ7I.js +950 -0
  18. package/dist/chunk-74HTZG3V.js +331 -0
  19. package/dist/chunk-A3ISJVEV.js +598 -0
  20. package/dist/chunk-CSDKWLFD.js +652 -0
  21. package/dist/chunk-CSRQTEQA.js +839 -0
  22. package/dist/chunk-DAQKYKLH.js +182 -0
  23. package/dist/chunk-EDRGAM6G.js +647 -0
  24. package/dist/chunk-EGU5KB7V.js +818 -0
  25. package/dist/chunk-H32L2NE3.js +372 -0
  26. package/dist/chunk-HKQSAFSN.js +837 -0
  27. package/dist/chunk-IOTWFHZU.js +558 -0
  28. package/dist/chunk-ONSDE37A.js +125 -0
  29. package/dist/chunk-QQKTH5KX.js +114 -0
  30. package/dist/chunk-R2TCP7D7.js +409 -0
  31. package/dist/chunk-SIP34GBE.js +380 -0
  32. package/dist/chunk-THSX7OOR.js +454 -0
  33. package/dist/chunk-UY3AZSYL.js +14 -0
  34. package/dist/chunk-VT5KRDPH.js +134 -0
  35. package/dist/chunk-VXXZIXAP.js +255 -0
  36. package/dist/chunk-WJJ5CTNI.js +907 -0
  37. package/dist/chunk-WVY45EIW.js +359 -0
  38. package/dist/chunk-ZRBLZY3M.js +462 -0
  39. package/dist/client-CKXJLsTe.d.ts +232 -0
  40. package/dist/email-verification-CAeArjui.d.ts +327 -0
  41. package/dist/encryption/index.js +48 -556
  42. package/dist/errors-JOOPDDQ6.js +34 -0
  43. package/dist/events/index.js +14 -316
  44. package/dist/health/index.js +12 -367
  45. package/dist/i18n/index.d.ts +2 -2
  46. package/dist/i18n/index.js +14 -583
  47. package/dist/index.d.ts +37 -239
  48. package/dist/index.js +2873 -19166
  49. package/dist/lambda/index.d.ts +9 -7
  50. package/dist/lambda/index.js +4 -9
  51. package/dist/logging/index.js +12 -545
  52. package/dist/mail/index.d.ts +29 -1
  53. package/dist/mail/index.js +15 -684
  54. package/dist/mcp/index.d.ts +7 -5
  55. package/dist/mcp/index.js +5 -378
  56. package/dist/notifications/index.d.ts +8 -6
  57. package/dist/notifications/index.js +13 -730
  58. package/dist/queue/index.d.ts +37 -7
  59. package/dist/queue/index.js +22 -940
  60. package/dist/redis/index.d.ts +366 -0
  61. package/dist/redis/index.js +597 -0
  62. package/dist/runtime/index.d.ts +8 -6
  63. package/dist/runtime/index.js +26 -244
  64. package/dist/scheduling/index.js +14 -822
  65. package/dist/storage/index.d.ts +1 -0
  66. package/dist/storage/index.js +6 -824
  67. package/package.json +15 -7
  68. package/dist/api-token-JOif2CtG.d.ts +0 -1792
@@ -0,0 +1,366 @@
1
+ import { R as RateLimitStore, a as RateLimitEntry } from '../client-CKXJLsTe.js';
2
+ export { b as RedisClientOptions, c as createRedisClient } from '../client-CKXJLsTe.js';
3
+ import { Redis } from 'ioredis';
4
+ export { default as Redis, RedisOptions } from 'ioredis';
5
+ import { S as SessionStore, h as SessionData, i as ApiTokenStore, j as ApiToken, O as OAuthStateStore, k as OAuthStatePayload } from '../api-token-BSSCLlFW.js';
6
+ import { P as PasswordResetTokenStore, E as EmailVerificationTokenStore, a as EmailVerificationToken } from '../email-verification-CAeArjui.js';
7
+ import 'hono';
8
+
9
+ /**
10
+ * Options for RedisSessionStore.
11
+ */
12
+ interface RedisSessionStoreOptions {
13
+ /**
14
+ * Key prefix for session keys.
15
+ * @default 'session:'
16
+ */
17
+ prefix?: string;
18
+ }
19
+ /**
20
+ * Redis-backed session store.
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * import { createRedisClient } from '@guren/server/redis'
25
+ *
26
+ * const redis = createRedisClient({ url: process.env.REDIS_URL })
27
+ * const store = new RedisSessionStore(redis)
28
+ *
29
+ * app.use(createSessionMiddleware({ store }))
30
+ * ```
31
+ */
32
+ declare class RedisSessionStore implements SessionStore {
33
+ private readonly redis;
34
+ private readonly prefix;
35
+ constructor(redis: Redis, options?: RedisSessionStoreOptions);
36
+ /**
37
+ * Read session data from Redis.
38
+ */
39
+ read(id: string): Promise<SessionData | undefined>;
40
+ /**
41
+ * Write session data to Redis with TTL.
42
+ */
43
+ write(id: string, data: SessionData, ttlSeconds: number): Promise<void>;
44
+ /**
45
+ * Delete a session from Redis.
46
+ */
47
+ destroy(id: string): Promise<void>;
48
+ /**
49
+ * Get all session keys (for debugging/admin purposes).
50
+ * Note: This uses SCAN to avoid blocking Redis.
51
+ */
52
+ keys(): Promise<string[]>;
53
+ /**
54
+ * Get the count of sessions (for monitoring).
55
+ */
56
+ size(): Promise<number>;
57
+ /**
58
+ * Clear all sessions.
59
+ * Use with caution in production!
60
+ */
61
+ clear(): Promise<void>;
62
+ }
63
+
64
+ /**
65
+ * Options for RedisRateLimitStore.
66
+ */
67
+ interface RedisRateLimitStoreOptions {
68
+ /**
69
+ * Key prefix for rate limit keys.
70
+ * @default 'ratelimit:'
71
+ */
72
+ prefix?: string;
73
+ }
74
+ /**
75
+ * Redis-backed rate limit store using fixed window algorithm.
76
+ * Uses Lua script for atomic increment operations.
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * import { createRedisClient } from '@guren/server/redis'
81
+ *
82
+ * const redis = createRedisClient({ url: process.env.REDIS_URL })
83
+ * const store = new RedisRateLimitStore(redis)
84
+ *
85
+ * app.use(createRateLimitMiddleware({ store, limit: 100 }))
86
+ * ```
87
+ */
88
+ declare class RedisRateLimitStore implements RateLimitStore {
89
+ private readonly redis;
90
+ private readonly prefix;
91
+ constructor(redis: Redis, options?: RedisRateLimitStoreOptions);
92
+ /**
93
+ * Get current rate limit entry for a key.
94
+ */
95
+ get(key: string): Promise<RateLimitEntry | null>;
96
+ /**
97
+ * Increment the rate limit counter atomically.
98
+ */
99
+ increment(key: string, windowMs: number): Promise<RateLimitEntry>;
100
+ /**
101
+ * Reset the rate limit for a key.
102
+ */
103
+ reset(key: string): Promise<void>;
104
+ /**
105
+ * Get all rate limit keys (for debugging/admin purposes).
106
+ */
107
+ keys(): Promise<string[]>;
108
+ /**
109
+ * Clear all rate limits.
110
+ */
111
+ clear(): Promise<void>;
112
+ }
113
+ /**
114
+ * Redis-backed rate limit store using sliding window algorithm.
115
+ * More accurate than fixed window but slightly more expensive.
116
+ */
117
+ declare class RedisSlidingWindowRateLimitStore implements RateLimitStore {
118
+ private readonly redis;
119
+ private readonly prefix;
120
+ constructor(redis: Redis, options?: RedisRateLimitStoreOptions);
121
+ /**
122
+ * Get current rate limit entry for a key.
123
+ */
124
+ get(key: string): Promise<RateLimitEntry | null>;
125
+ /**
126
+ * Increment the rate limit counter using sorted set.
127
+ * Each request is stored with its timestamp as score.
128
+ */
129
+ increment(key: string, windowMs: number): Promise<RateLimitEntry>;
130
+ /**
131
+ * Reset the rate limit for a key.
132
+ */
133
+ reset(key: string): Promise<void>;
134
+ /**
135
+ * Clear all rate limits.
136
+ */
137
+ clear(): Promise<void>;
138
+ }
139
+
140
+ /**
141
+ * Options for RedisApiTokenStore.
142
+ */
143
+ interface RedisApiTokenStoreOptions {
144
+ /**
145
+ * Key prefix for token keys.
146
+ * @default 'apitoken:'
147
+ */
148
+ prefix?: string;
149
+ }
150
+ /**
151
+ * Redis-backed API token store.
152
+ *
153
+ * Uses the following key structure:
154
+ * - `apitoken:{id}` - Token data (hash)
155
+ * - `apitoken:hash:{hashedToken}` - Maps hash to token ID
156
+ * - `apitoken:user:{userId}` - Set of token IDs for a user
157
+ *
158
+ * @example
159
+ * ```ts
160
+ * import { createRedisClient } from '@guren/server/redis'
161
+ *
162
+ * const redis = createRedisClient({ url: process.env.REDIS_URL })
163
+ * const store = new RedisApiTokenStore(redis)
164
+ *
165
+ * const { plainTextToken } = await createApiToken(store, {
166
+ * name: 'API Token',
167
+ * userId: user.id,
168
+ * })
169
+ * ```
170
+ */
171
+ declare class RedisApiTokenStore implements ApiTokenStore {
172
+ private readonly redis;
173
+ private readonly prefix;
174
+ constructor(redis: Redis, options?: RedisApiTokenStoreOptions);
175
+ /**
176
+ * Store a new API token.
177
+ */
178
+ store(token: ApiToken): Promise<void>;
179
+ /**
180
+ * Find a token by its hashed value.
181
+ */
182
+ findByHashedToken(hashedToken: string): Promise<ApiToken | null>;
183
+ /**
184
+ * Find all tokens for a user.
185
+ */
186
+ findByUserId(userId: string | number): Promise<ApiToken[]>;
187
+ /**
188
+ * Delete a token by its ID.
189
+ */
190
+ delete(id: string): Promise<void>;
191
+ /**
192
+ * Delete all tokens for a user.
193
+ */
194
+ deleteForUser(userId: string | number): Promise<void>;
195
+ /**
196
+ * Update the last used timestamp.
197
+ */
198
+ updateLastUsed(id: string, timestamp: Date): Promise<void>;
199
+ /**
200
+ * Find a token by its ID.
201
+ */
202
+ private findById;
203
+ /**
204
+ * Serialize a token for Redis storage.
205
+ */
206
+ private serializeToken;
207
+ /**
208
+ * Deserialize a token from Redis storage.
209
+ */
210
+ private deserializeToken;
211
+ /**
212
+ * Clear all tokens (for testing).
213
+ */
214
+ clear(): Promise<void>;
215
+ }
216
+
217
+ /**
218
+ * Options for RedisPasswordResetStore.
219
+ */
220
+ interface RedisPasswordResetStoreOptions {
221
+ /**
222
+ * Key prefix for password reset keys.
223
+ * @default 'pwreset:'
224
+ */
225
+ prefix?: string;
226
+ }
227
+ /**
228
+ * Redis-backed password reset token store.
229
+ *
230
+ * Uses the following key structure:
231
+ * - `pwreset:{tokenId}` - Token data (JSON with email and expiresAt)
232
+ * - `pwreset:email:{email}` - Set of token IDs for an email
233
+ *
234
+ * @example
235
+ * ```ts
236
+ * import { createRedisClient } from '@guren/server/redis'
237
+ *
238
+ * const redis = createRedisClient({ url: process.env.REDIS_URL })
239
+ * const store = new RedisPasswordResetStore(redis)
240
+ *
241
+ * const { token } = await createPasswordResetToken(email, store, { expiresIn: 3600000 })
242
+ * ```
243
+ */
244
+ declare class RedisPasswordResetStore implements PasswordResetTokenStore {
245
+ private readonly redis;
246
+ private readonly prefix;
247
+ constructor(redis: Redis, options?: RedisPasswordResetStoreOptions);
248
+ /**
249
+ * Store a password reset token.
250
+ */
251
+ store(tokenId: string, email: string, expiresAt: Date): Promise<void>;
252
+ /**
253
+ * Find a token by its hash.
254
+ */
255
+ find(tokenId: string): Promise<{
256
+ email: string;
257
+ expiresAt: Date;
258
+ } | null>;
259
+ /**
260
+ * Delete a token by its hash.
261
+ */
262
+ delete(tokenId: string): Promise<void>;
263
+ /**
264
+ * Delete all tokens for an email.
265
+ */
266
+ deleteForEmail(email: string): Promise<void>;
267
+ /**
268
+ * Clear all tokens (for testing).
269
+ */
270
+ clear(): Promise<void>;
271
+ }
272
+
273
+ /**
274
+ * Options for RedisEmailVerificationStore.
275
+ */
276
+ interface RedisEmailVerificationStoreOptions {
277
+ /**
278
+ * Key prefix for email verification keys.
279
+ * @default 'emailverify:'
280
+ */
281
+ prefix?: string;
282
+ }
283
+ /**
284
+ * Redis-backed email verification token store.
285
+ *
286
+ * Uses the following key structure:
287
+ * - `emailverify:{tokenId}` - Token data (JSON)
288
+ * - `emailverify:email:{email}` - Set of token IDs for an email
289
+ *
290
+ * @example
291
+ * ```ts
292
+ * import { createRedisClient } from '@guren/server/redis'
293
+ *
294
+ * const redis = createRedisClient({ url: process.env.REDIS_URL })
295
+ * const store = new RedisEmailVerificationStore(redis)
296
+ *
297
+ * const { token } = await createEmailVerificationToken(email, store, { expiresIn: 86400000 })
298
+ * ```
299
+ */
300
+ declare class RedisEmailVerificationStore implements EmailVerificationTokenStore {
301
+ private readonly redis;
302
+ private readonly prefix;
303
+ constructor(redis: Redis, options?: RedisEmailVerificationStoreOptions);
304
+ /**
305
+ * Store an email verification token.
306
+ */
307
+ store(token: EmailVerificationToken): Promise<void>;
308
+ /**
309
+ * Find a token by its hash.
310
+ */
311
+ findByTokenId(tokenId: string): Promise<EmailVerificationToken | null>;
312
+ /**
313
+ * Delete a token by its hash.
314
+ */
315
+ delete(tokenId: string): Promise<void>;
316
+ /**
317
+ * Delete all tokens for an email.
318
+ */
319
+ deleteForEmail(email: string): Promise<void>;
320
+ /**
321
+ * Clear all tokens (for testing).
322
+ */
323
+ clear(): Promise<void>;
324
+ }
325
+
326
+ /**
327
+ * Options for RedisOAuthStateStore.
328
+ */
329
+ interface RedisOAuthStateStoreOptions {
330
+ /**
331
+ * Key prefix for OAuth state keys.
332
+ * @default 'oauthstate:'
333
+ */
334
+ prefix?: string;
335
+ }
336
+ /**
337
+ * Redis-backed OAuth state store.
338
+ *
339
+ * Required in production whenever more than one server process handles
340
+ * traffic (load balancers, serverless): the default MemoryOAuthStateStore
341
+ * is per-process, so the callback request may land on a process that never
342
+ * saw the state. Entries expire automatically via Redis TTL.
343
+ *
344
+ * @example
345
+ * ```ts
346
+ * import { createOAuthManager } from '@guren/core'
347
+ * import { createRedisClient, RedisOAuthStateStore } from '@guren/core/redis'
348
+ *
349
+ * const redis = createRedisClient({ url: process.env.REDIS_URL })
350
+ * const oauth = createOAuthManager({ stateStore: new RedisOAuthStateStore(redis) })
351
+ * ```
352
+ */
353
+ declare class RedisOAuthStateStore implements OAuthStateStore {
354
+ private readonly redis;
355
+ private readonly prefix;
356
+ constructor(redis: Redis, options?: RedisOAuthStateStoreOptions);
357
+ store(stateHash: string, payload: OAuthStatePayload): Promise<void>;
358
+ find(stateHash: string): Promise<OAuthStatePayload | null>;
359
+ delete(stateHash: string): Promise<void>;
360
+ /**
361
+ * Clear all states (for testing).
362
+ */
363
+ clear(): Promise<void>;
364
+ }
365
+
366
+ export { RedisApiTokenStore, type RedisApiTokenStoreOptions, RedisEmailVerificationStore, type RedisEmailVerificationStoreOptions, RedisOAuthStateStore, type RedisOAuthStateStoreOptions, RedisPasswordResetStore, type RedisPasswordResetStoreOptions, RedisRateLimitStore, type RedisRateLimitStoreOptions, RedisSessionStore, type RedisSessionStoreOptions, RedisSlidingWindowRateLimitStore };