@guren/server 1.0.0-rc.24 → 1.0.0-rc.26
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.
- package/dist/{Application-D4_90raL.d.ts → Application-BnsyCKXY.d.ts} +3 -2
- package/dist/AuthManager-SfhCNkAU.d.ts +79 -0
- package/dist/{ConsoleKernel-BPYcP-2f.d.ts → ConsoleKernel-BDtBETjm.d.ts} +1 -1
- package/dist/{api-token-BGOsfuI9.d.ts → api-token-BSSCLlFW.d.ts} +12 -69
- package/dist/auth/index.d.ts +8 -327
- package/dist/auth/index.js +1 -1
- package/dist/{chunk-F3664MFN.js → chunk-2T6JN4VR.js} +52 -6
- package/dist/{chunk-IM6XKMP5.js → chunk-NRLZJILN.js} +12 -5
- package/dist/chunk-UY3AZSYL.js +14 -0
- package/dist/client-CKXJLsTe.d.ts +232 -0
- package/dist/email-verification-CAeArjui.d.ts +327 -0
- package/dist/index.d.ts +27 -238
- package/dist/index.js +25 -20
- package/dist/lambda/index.d.ts +4 -3
- package/dist/mcp/index.d.ts +3 -2
- package/dist/notifications/index.d.ts +4 -3
- package/dist/queue/index.d.ts +4 -3
- package/dist/redis/index.d.ts +366 -0
- package/dist/redis/index.js +597 -0
- package/dist/runtime/index.d.ts +4 -3
- package/dist/runtime/index.js +5 -3
- package/package.json +12 -5
package/dist/index.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
import {
|
|
2
|
+
logDevServerBanner,
|
|
3
|
+
parseImportMap,
|
|
4
|
+
startViteDevServer
|
|
5
|
+
} from "./chunk-NRLZJILN.js";
|
|
1
6
|
import {
|
|
2
7
|
PendingSchedule,
|
|
3
8
|
Schedule,
|
|
@@ -99,10 +104,8 @@ import {
|
|
|
99
104
|
setQueueDriver
|
|
100
105
|
} from "./chunk-R2TCP7D7.js";
|
|
101
106
|
import {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
startViteDevServer
|
|
105
|
-
} from "./chunk-IM6XKMP5.js";
|
|
107
|
+
createRedisClient
|
|
108
|
+
} from "./chunk-UY3AZSYL.js";
|
|
106
109
|
import {
|
|
107
110
|
API_TOKEN_KEY,
|
|
108
111
|
AuthManager,
|
|
@@ -155,7 +158,7 @@ import {
|
|
|
155
158
|
verifyEmailToken,
|
|
156
159
|
verifyOAuthState,
|
|
157
160
|
verifyPasswordResetToken
|
|
158
|
-
} from "./chunk-
|
|
161
|
+
} from "./chunk-2T6JN4VR.js";
|
|
159
162
|
import {
|
|
160
163
|
Gate,
|
|
161
164
|
Policy,
|
|
@@ -5238,12 +5241,6 @@ var Command = class {
|
|
|
5238
5241
|
}
|
|
5239
5242
|
return this.kernel.handle([command, ...args]);
|
|
5240
5243
|
}
|
|
5241
|
-
/**
|
|
5242
|
-
* Call another command silently.
|
|
5243
|
-
*/
|
|
5244
|
-
async callSilent(command, args = []) {
|
|
5245
|
-
return this.call(command, args);
|
|
5246
|
-
}
|
|
5247
5244
|
// ==================
|
|
5248
5245
|
// Utility Methods
|
|
5249
5246
|
// ==================
|
|
@@ -6242,15 +6239,19 @@ function renderEnvironmentSection() {
|
|
|
6242
6239
|
</section>`;
|
|
6243
6240
|
}
|
|
6244
6241
|
|
|
6245
|
-
// src/
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
|
|
6249
|
-
|
|
6250
|
-
return new Redis(url2, redisOptions);
|
|
6242
|
+
// src/auth/password/DefaultHasher.ts
|
|
6243
|
+
var DefaultHasher = class {
|
|
6244
|
+
delegate;
|
|
6245
|
+
constructor() {
|
|
6246
|
+
this.delegate = typeof Bun !== "undefined" ? new ScryptHasher() : new NodeHasher();
|
|
6251
6247
|
}
|
|
6252
|
-
|
|
6253
|
-
|
|
6248
|
+
hash(plain) {
|
|
6249
|
+
return this.delegate.hash(plain);
|
|
6250
|
+
}
|
|
6251
|
+
verify(hashed, plain) {
|
|
6252
|
+
return this.delegate.verify(hashed, plain);
|
|
6253
|
+
}
|
|
6254
|
+
};
|
|
6254
6255
|
|
|
6255
6256
|
// src/index.ts
|
|
6256
6257
|
ensureErrorStackTracePolyfill();
|
|
@@ -6292,6 +6293,7 @@ export {
|
|
|
6292
6293
|
DailyFileChannel,
|
|
6293
6294
|
DatabaseChannel,
|
|
6294
6295
|
DatabaseCheck,
|
|
6296
|
+
DefaultHasher,
|
|
6295
6297
|
Encrypter,
|
|
6296
6298
|
EncryptionServiceProvider,
|
|
6297
6299
|
ErrorServiceProvider,
|
|
@@ -6306,7 +6308,7 @@ export {
|
|
|
6306
6308
|
FileChannel,
|
|
6307
6309
|
FormRequest,
|
|
6308
6310
|
Gate,
|
|
6309
|
-
|
|
6311
|
+
DefaultHasher as Hash,
|
|
6310
6312
|
HealthCheck,
|
|
6311
6313
|
HealthManager,
|
|
6312
6314
|
HealthServiceProvider,
|
|
@@ -6341,6 +6343,7 @@ export {
|
|
|
6341
6343
|
MemoryLoader,
|
|
6342
6344
|
MemoryOAuthStateStore,
|
|
6343
6345
|
MemoryPasswordResetStore,
|
|
6346
|
+
MemoryDriver as MemoryQueueDriver,
|
|
6344
6347
|
MemoryRateLimitStore,
|
|
6345
6348
|
MemorySessionStore,
|
|
6346
6349
|
MemoryDriver3 as MemoryStorageDriver,
|
|
@@ -6368,6 +6371,7 @@ export {
|
|
|
6368
6371
|
RedisStore as RedisCacheStore,
|
|
6369
6372
|
RedisCheck,
|
|
6370
6373
|
RedisDriver,
|
|
6374
|
+
RedisDriver as RedisQueueDriver,
|
|
6371
6375
|
RequestFinished,
|
|
6372
6376
|
RequestReceived,
|
|
6373
6377
|
ResendTransport,
|
|
@@ -6392,6 +6396,7 @@ export {
|
|
|
6392
6396
|
StorageManager,
|
|
6393
6397
|
StorageServiceProvider,
|
|
6394
6398
|
SyncDriver,
|
|
6399
|
+
SyncDriver as SyncQueueDriver,
|
|
6395
6400
|
TaggedCache,
|
|
6396
6401
|
Translator,
|
|
6397
6402
|
UserAuthenticated,
|
package/dist/lambda/index.d.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as hono_aws_lambda from 'hono/aws-lambda';
|
|
2
2
|
export { APIGatewayProxyResult, LambdaEvent } from 'hono/aws-lambda';
|
|
3
|
-
import { A as Application } from '../Application-
|
|
3
|
+
import { A as Application } from '../Application-BnsyCKXY.js';
|
|
4
4
|
import { S as Scheduler } from '../Scheduler-BstvSca7.js';
|
|
5
|
-
import { C as ConsoleKernel } from '../ConsoleKernel-
|
|
5
|
+
import { C as ConsoleKernel } from '../ConsoleKernel-BDtBETjm.js';
|
|
6
6
|
import 'hono';
|
|
7
|
-
import '../api-token-
|
|
7
|
+
import '../api-token-BSSCLlFW.js';
|
|
8
|
+
import '../AuthManager-SfhCNkAU.js';
|
|
8
9
|
import '@guren/orm';
|
|
9
10
|
import 'vite';
|
|
10
11
|
import '../EventManager-CmIoLt7r.js';
|
package/dist/mcp/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
-
import { S as ServiceProvider } from '../Application-
|
|
2
|
+
import { S as ServiceProvider } from '../Application-BnsyCKXY.js';
|
|
3
3
|
import 'hono';
|
|
4
|
-
import '../api-token-
|
|
4
|
+
import '../api-token-BSSCLlFW.js';
|
|
5
|
+
import '../AuthManager-SfhCNkAU.js';
|
|
5
6
|
import '@guren/orm';
|
|
6
7
|
import 'vite';
|
|
7
8
|
import '../EventManager-CmIoLt7r.js';
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { a0 as NotificationChannel, Z as Notifiable, _ as Notification, t as DatabaseNotification, r as DatabaseChannelOptions, au as SlackMessage, ak as SentNotification } from '../Application-BnsyCKXY.js';
|
|
2
|
+
export { $ as NotificationAttachment, a1 as NotificationChannelFactory, a2 as NotificationClass, a3 as NotificationMailMessage, N as NotificationManager, a4 as NotificationManagerOptions, as as SlackAttachment, at as SlackBlock, aI as createNotificationManager, aS as getNotificationManager, b1 as setNotificationManager } from '../Application-BnsyCKXY.js';
|
|
3
3
|
import { M as MailManager } from '../MailManager-DpMvYiP9.js';
|
|
4
4
|
import 'hono';
|
|
5
|
-
import '../api-token-
|
|
5
|
+
import '../api-token-BSSCLlFW.js';
|
|
6
|
+
import '../AuthManager-SfhCNkAU.js';
|
|
6
7
|
import '@guren/orm';
|
|
7
8
|
import 'vite';
|
|
8
9
|
import '../EventManager-CmIoLt7r.js';
|
package/dist/queue/index.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { a7 as QueueDriver, a9 as QueuedJob, F as FailedJob, ay as WorkerOptions } from '../Application-BnsyCKXY.js';
|
|
2
|
+
export { U as Job, V as JobClass, W as JobFailureHandler, X as JobHandler, Y as JobOptions, a6 as QueueConfig, a8 as QueueDriverFactory, Q as QueueManager, aC as clearJobRegistry, aJ as createQueueManager, aR as getJob, aT as getQueueDriver, aU as getRegisteredJobs, aY as registerJob, b2 as setQueueDriver } from '../Application-BnsyCKXY.js';
|
|
3
3
|
import { Redis } from 'ioredis';
|
|
4
4
|
import 'hono';
|
|
5
|
-
import '../api-token-
|
|
5
|
+
import '../api-token-BSSCLlFW.js';
|
|
6
|
+
import '../AuthManager-SfhCNkAU.js';
|
|
6
7
|
import '@guren/orm';
|
|
7
8
|
import 'vite';
|
|
8
9
|
import '../EventManager-CmIoLt7r.js';
|
|
@@ -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 };
|