@parsrun/auth 0.1.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.
- package/README.md +133 -0
- package/dist/adapters/hono.d.ts +9 -0
- package/dist/adapters/hono.js +6 -0
- package/dist/adapters/hono.js.map +1 -0
- package/dist/adapters/index.d.ts +9 -0
- package/dist/adapters/index.js +7 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/authorization-By1Xp8Za.d.ts +213 -0
- package/dist/base-BKyR8rcE.d.ts +646 -0
- package/dist/chunk-42MGHABB.js +263 -0
- package/dist/chunk-42MGHABB.js.map +1 -0
- package/dist/chunk-7GOBAL4G.js +3 -0
- package/dist/chunk-7GOBAL4G.js.map +1 -0
- package/dist/chunk-G5I3T73A.js +152 -0
- package/dist/chunk-G5I3T73A.js.map +1 -0
- package/dist/chunk-IB4WUQDZ.js +410 -0
- package/dist/chunk-IB4WUQDZ.js.map +1 -0
- package/dist/chunk-MOG4Y6I7.js +415 -0
- package/dist/chunk-MOG4Y6I7.js.map +1 -0
- package/dist/chunk-NK4TJV2W.js +295 -0
- package/dist/chunk-NK4TJV2W.js.map +1 -0
- package/dist/chunk-RHNVRCF3.js +838 -0
- package/dist/chunk-RHNVRCF3.js.map +1 -0
- package/dist/chunk-YTCPXJR5.js +570 -0
- package/dist/chunk-YTCPXJR5.js.map +1 -0
- package/dist/cloudflare-kv-L64CZKDK.js +105 -0
- package/dist/cloudflare-kv-L64CZKDK.js.map +1 -0
- package/dist/deno-kv-F55HKKP6.js +111 -0
- package/dist/deno-kv-F55HKKP6.js.map +1 -0
- package/dist/index-C3kz9XqE.d.ts +226 -0
- package/dist/index-DOGcetyD.d.ts +1041 -0
- package/dist/index.d.ts +1579 -0
- package/dist/index.js +4294 -0
- package/dist/index.js.map +1 -0
- package/dist/jwt-manager-CH8H0kmm.d.ts +182 -0
- package/dist/providers/index.d.ts +90 -0
- package/dist/providers/index.js +3 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/otp/index.d.ts +3 -0
- package/dist/providers/otp/index.js +4 -0
- package/dist/providers/otp/index.js.map +1 -0
- package/dist/redis-5TIS6XCA.js +121 -0
- package/dist/redis-5TIS6XCA.js.map +1 -0
- package/dist/security/index.d.ts +301 -0
- package/dist/security/index.js +5 -0
- package/dist/security/index.js.map +1 -0
- package/dist/session/index.d.ts +117 -0
- package/dist/session/index.js +4 -0
- package/dist/session/index.js.map +1 -0
- package/dist/storage/index.d.ts +97 -0
- package/dist/storage/index.js +3 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/types-DSjafxJ4.d.ts +193 -0
- package/package.json +102 -0
|
@@ -0,0 +1,301 @@
|
|
|
1
|
+
import { K as KVStorage } from '../types-DSjafxJ4.js';
|
|
2
|
+
export { b as AuthorizationContext, A as AuthorizationGuard, e as AuthorizationRequirements, d as AuthorizationResult, f as PermissionPattern, P as Permissions, R as Roles, T as TenantMembershipInfo, a as authorize, c as createAuthorizationGuard } from '../authorization-By1Xp8Za.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Rate Limiting
|
|
6
|
+
* Uses KVStorage interface for multi-runtime support
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Rate limit configuration
|
|
11
|
+
*/
|
|
12
|
+
interface RateLimitConfig {
|
|
13
|
+
/** Time window in seconds */
|
|
14
|
+
windowSeconds: number;
|
|
15
|
+
/** Max requests per window */
|
|
16
|
+
maxRequests: number;
|
|
17
|
+
/** Key prefix for rate limit entries */
|
|
18
|
+
keyPrefix?: string;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Rate limit result
|
|
22
|
+
*/
|
|
23
|
+
interface RateLimitResult {
|
|
24
|
+
/** Whether the request is allowed */
|
|
25
|
+
allowed: boolean;
|
|
26
|
+
/** Remaining requests in current window */
|
|
27
|
+
remaining: number;
|
|
28
|
+
/** When the window resets */
|
|
29
|
+
resetAt: Date;
|
|
30
|
+
/** Milliseconds until retry is allowed (if not allowed) */
|
|
31
|
+
retryAfterMs?: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Rate Limiter using KVStorage
|
|
35
|
+
*/
|
|
36
|
+
declare class RateLimiter {
|
|
37
|
+
private storage;
|
|
38
|
+
private config;
|
|
39
|
+
constructor(storage: KVStorage, config: RateLimitConfig);
|
|
40
|
+
/**
|
|
41
|
+
* Get storage key for rate limit entry
|
|
42
|
+
*/
|
|
43
|
+
private getKey;
|
|
44
|
+
/**
|
|
45
|
+
* Check and consume rate limit
|
|
46
|
+
*/
|
|
47
|
+
check(identifier: string): Promise<RateLimitResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Get current rate limit status without consuming
|
|
50
|
+
*/
|
|
51
|
+
status(identifier: string): Promise<RateLimitResult | null>;
|
|
52
|
+
/**
|
|
53
|
+
* Reset rate limit for an identifier
|
|
54
|
+
*/
|
|
55
|
+
reset(identifier: string): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Check rate limit without consuming (peek)
|
|
58
|
+
*/
|
|
59
|
+
peek(identifier: string): Promise<RateLimitResult>;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Create a rate limiter
|
|
63
|
+
*/
|
|
64
|
+
declare function createRateLimiter(storage: KVStorage, config: RateLimitConfig): RateLimiter;
|
|
65
|
+
/**
|
|
66
|
+
* Common rate limit configurations
|
|
67
|
+
*/
|
|
68
|
+
declare const RateLimitPresets: {
|
|
69
|
+
/** Login attempts: 5 per 15 minutes */
|
|
70
|
+
readonly login: {
|
|
71
|
+
readonly windowSeconds: number;
|
|
72
|
+
readonly maxRequests: 5;
|
|
73
|
+
readonly keyPrefix: "login:";
|
|
74
|
+
};
|
|
75
|
+
/** OTP requests: 5 per 15 minutes */
|
|
76
|
+
readonly otp: {
|
|
77
|
+
readonly windowSeconds: number;
|
|
78
|
+
readonly maxRequests: 5;
|
|
79
|
+
readonly keyPrefix: "otp:";
|
|
80
|
+
};
|
|
81
|
+
/** Magic link requests: 3 per 10 minutes */
|
|
82
|
+
readonly magicLink: {
|
|
83
|
+
readonly windowSeconds: number;
|
|
84
|
+
readonly maxRequests: 3;
|
|
85
|
+
readonly keyPrefix: "magic:";
|
|
86
|
+
};
|
|
87
|
+
/** Password reset: 3 per hour */
|
|
88
|
+
readonly passwordReset: {
|
|
89
|
+
readonly windowSeconds: number;
|
|
90
|
+
readonly maxRequests: 3;
|
|
91
|
+
readonly keyPrefix: "pwreset:";
|
|
92
|
+
};
|
|
93
|
+
/** API general: 100 per minute */
|
|
94
|
+
readonly api: {
|
|
95
|
+
readonly windowSeconds: 60;
|
|
96
|
+
readonly maxRequests: 100;
|
|
97
|
+
readonly keyPrefix: "api:";
|
|
98
|
+
};
|
|
99
|
+
/** Registration: 5 per hour per IP */
|
|
100
|
+
readonly registration: {
|
|
101
|
+
readonly windowSeconds: number;
|
|
102
|
+
readonly maxRequests: 5;
|
|
103
|
+
readonly keyPrefix: "register:";
|
|
104
|
+
};
|
|
105
|
+
/** 2FA attempts: 5 per 5 minutes */
|
|
106
|
+
readonly twoFactor: {
|
|
107
|
+
readonly windowSeconds: number;
|
|
108
|
+
readonly maxRequests: 5;
|
|
109
|
+
readonly keyPrefix: "2fa:";
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* CSRF Protection
|
|
115
|
+
* Double-Submit Cookie Pattern with KVStorage support
|
|
116
|
+
*/
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* CSRF configuration
|
|
120
|
+
*/
|
|
121
|
+
interface CsrfConfig {
|
|
122
|
+
/** Token expiry in seconds (default: 3600 = 1 hour) */
|
|
123
|
+
expiresIn?: number;
|
|
124
|
+
/** Header name for CSRF token (default: 'x-csrf-token') */
|
|
125
|
+
headerName?: string;
|
|
126
|
+
/** Cookie name for CSRF token (default: 'csrf') */
|
|
127
|
+
cookieName?: string;
|
|
128
|
+
/** Token byte length (default: 32) */
|
|
129
|
+
tokenLength?: number;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* CSRF token pair
|
|
133
|
+
*/
|
|
134
|
+
interface CsrfTokenPair {
|
|
135
|
+
/** Plain token (for client) */
|
|
136
|
+
token: string;
|
|
137
|
+
/** Hashed token (for server storage/cookie) */
|
|
138
|
+
hash: string;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* CSRF Manager
|
|
142
|
+
*/
|
|
143
|
+
declare class CsrfManager {
|
|
144
|
+
private storage;
|
|
145
|
+
private config;
|
|
146
|
+
constructor(storage: KVStorage, config?: CsrfConfig);
|
|
147
|
+
/**
|
|
148
|
+
* Generate a cryptographically secure CSRF token
|
|
149
|
+
*/
|
|
150
|
+
generateToken(): string;
|
|
151
|
+
/**
|
|
152
|
+
* Hash a CSRF token for storage
|
|
153
|
+
*/
|
|
154
|
+
hashToken(token: string): Promise<string>;
|
|
155
|
+
/**
|
|
156
|
+
* Generate token pair for double-submit pattern
|
|
157
|
+
*/
|
|
158
|
+
generateTokenPair(): Promise<CsrfTokenPair>;
|
|
159
|
+
/**
|
|
160
|
+
* Store CSRF token for a session
|
|
161
|
+
*/
|
|
162
|
+
storeToken(sessionId: string, token: string): Promise<void>;
|
|
163
|
+
/**
|
|
164
|
+
* Verify CSRF token against stored hash
|
|
165
|
+
*/
|
|
166
|
+
verifyToken(token: string, hash: string): Promise<boolean>;
|
|
167
|
+
/**
|
|
168
|
+
* Verify CSRF token for a session
|
|
169
|
+
*/
|
|
170
|
+
verifyTokenForSession(sessionId: string, token: string): Promise<boolean>;
|
|
171
|
+
/**
|
|
172
|
+
* Validate double-submit cookie pattern
|
|
173
|
+
* Compares CSRF token from header/body against cookie value
|
|
174
|
+
*/
|
|
175
|
+
validateDoubleSubmit(headerToken: string, cookieToken: string): boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Extract CSRF token from request headers or body
|
|
178
|
+
*/
|
|
179
|
+
extractTokenFromRequest(headers: Record<string, string | undefined>, body?: Record<string, unknown>): string | null;
|
|
180
|
+
/**
|
|
181
|
+
* Delete CSRF token for a session
|
|
182
|
+
*/
|
|
183
|
+
deleteToken(sessionId: string): Promise<void>;
|
|
184
|
+
/**
|
|
185
|
+
* Refresh CSRF token for a session
|
|
186
|
+
*/
|
|
187
|
+
refreshToken(sessionId: string): Promise<CsrfTokenPair>;
|
|
188
|
+
/**
|
|
189
|
+
* Get configuration
|
|
190
|
+
*/
|
|
191
|
+
getConfig(): Required<CsrfConfig>;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Create CSRF manager
|
|
195
|
+
*/
|
|
196
|
+
declare function createCsrfManager(storage: KVStorage, config?: CsrfConfig): CsrfManager;
|
|
197
|
+
/**
|
|
198
|
+
* Static CSRF utilities (for stateless double-submit pattern)
|
|
199
|
+
*/
|
|
200
|
+
declare const CsrfUtils: {
|
|
201
|
+
/**
|
|
202
|
+
* Generate a CSRF token
|
|
203
|
+
*/
|
|
204
|
+
generateToken(length?: number): string;
|
|
205
|
+
/**
|
|
206
|
+
* Hash a token
|
|
207
|
+
*/
|
|
208
|
+
hashToken(token: string): Promise<string>;
|
|
209
|
+
/**
|
|
210
|
+
* Generate token pair
|
|
211
|
+
*/
|
|
212
|
+
generateTokenPair(length?: number): Promise<CsrfTokenPair>;
|
|
213
|
+
/**
|
|
214
|
+
* Verify token against hash
|
|
215
|
+
*/
|
|
216
|
+
verifyToken(token: string, hash: string): Promise<boolean>;
|
|
217
|
+
/**
|
|
218
|
+
* Validate double-submit pattern
|
|
219
|
+
*/
|
|
220
|
+
validateDoubleSubmit(headerToken: string, cookieToken: string): boolean;
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Account Lockout
|
|
225
|
+
* Prevents brute force attacks by locking accounts after failed attempts
|
|
226
|
+
*/
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Lockout configuration
|
|
230
|
+
*/
|
|
231
|
+
interface LockoutConfig {
|
|
232
|
+
/** Maximum failed attempts before lockout */
|
|
233
|
+
maxAttempts: number;
|
|
234
|
+
/** Lockout duration in seconds */
|
|
235
|
+
lockoutDuration: number;
|
|
236
|
+
/** Time window for counting attempts in seconds */
|
|
237
|
+
attemptWindow: number;
|
|
238
|
+
/** Key prefix for lockout entries */
|
|
239
|
+
keyPrefix?: string;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Lockout status
|
|
243
|
+
*/
|
|
244
|
+
interface LockoutStatus {
|
|
245
|
+
/** Whether the account is locked */
|
|
246
|
+
locked: boolean;
|
|
247
|
+
/** Number of failed attempts */
|
|
248
|
+
attempts: number;
|
|
249
|
+
/** Remaining attempts before lockout */
|
|
250
|
+
remainingAttempts: number;
|
|
251
|
+
/** When the lockout expires (if locked) */
|
|
252
|
+
unlocksAt?: Date;
|
|
253
|
+
/** Seconds until unlock (if locked) */
|
|
254
|
+
unlocksInSeconds?: number;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Account Lockout Manager
|
|
258
|
+
*/
|
|
259
|
+
declare class LockoutManager {
|
|
260
|
+
private storage;
|
|
261
|
+
private config;
|
|
262
|
+
constructor(storage: KVStorage, config: LockoutConfig);
|
|
263
|
+
/**
|
|
264
|
+
* Get storage key for lockout entry
|
|
265
|
+
*/
|
|
266
|
+
private getKey;
|
|
267
|
+
/**
|
|
268
|
+
* Record a failed attempt
|
|
269
|
+
*/
|
|
270
|
+
recordFailedAttempt(identifier: string): Promise<LockoutStatus>;
|
|
271
|
+
/**
|
|
272
|
+
* Record a successful attempt (clear lockout state)
|
|
273
|
+
*/
|
|
274
|
+
recordSuccessfulAttempt(identifier: string): Promise<void>;
|
|
275
|
+
/**
|
|
276
|
+
* Get current lockout status
|
|
277
|
+
*/
|
|
278
|
+
getStatus(identifier: string): Promise<LockoutStatus>;
|
|
279
|
+
/**
|
|
280
|
+
* Check if account is locked
|
|
281
|
+
*/
|
|
282
|
+
isLocked(identifier: string): Promise<boolean>;
|
|
283
|
+
/**
|
|
284
|
+
* Manually lock an account
|
|
285
|
+
*/
|
|
286
|
+
lock(identifier: string, durationSeconds?: number): Promise<void>;
|
|
287
|
+
/**
|
|
288
|
+
* Manually unlock an account
|
|
289
|
+
*/
|
|
290
|
+
unlock(identifier: string): Promise<void>;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Create lockout manager
|
|
294
|
+
*/
|
|
295
|
+
declare function createLockoutManager(storage: KVStorage, config: LockoutConfig): LockoutManager;
|
|
296
|
+
/**
|
|
297
|
+
* Default lockout configuration
|
|
298
|
+
*/
|
|
299
|
+
declare const DefaultLockoutConfig: LockoutConfig;
|
|
300
|
+
|
|
301
|
+
export { type CsrfConfig, CsrfManager, type CsrfTokenPair, CsrfUtils, DefaultLockoutConfig, type LockoutConfig, LockoutManager, type LockoutStatus, type RateLimitConfig, RateLimitPresets, type RateLimitResult, RateLimiter, createCsrfManager, createLockoutManager, createRateLimiter };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { CsrfManager, CsrfUtils, DefaultLockoutConfig, LockoutManager, RateLimitPresets, RateLimiter, createCsrfManager, createLockoutManager, createRateLimiter } from '../chunk-YTCPXJR5.js';
|
|
2
|
+
export { AuthorizationGuard, Permissions, Roles, authorize, createAuthorizationGuard } from '../chunk-NK4TJV2W.js';
|
|
3
|
+
import '../chunk-42MGHABB.js';
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export { b as JwtConfig, a as JwtError, J as JwtManager, d as JwtPayload, K as KeyRotationResult, T as TokenPair, c as createJwtManager, e as extractBearerToken, p as parseDuration } from '../jwt-manager-CH8H0kmm.js';
|
|
2
|
+
import { K as KVStorage } from '../types-DSjafxJ4.js';
|
|
3
|
+
import 'jose';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Session Blocklist
|
|
7
|
+
* Uses KVStorage interface for multi-runtime support
|
|
8
|
+
* Supports token/session revocation for logout
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Blocklist configuration
|
|
13
|
+
*/
|
|
14
|
+
interface BlocklistConfig {
|
|
15
|
+
/** Key prefix for blocked sessions */
|
|
16
|
+
prefix?: string;
|
|
17
|
+
/** Default TTL in seconds (should match max token lifetime) */
|
|
18
|
+
defaultTTL?: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Blocklist entry
|
|
22
|
+
*/
|
|
23
|
+
interface BlocklistEntry {
|
|
24
|
+
/** Session or token ID */
|
|
25
|
+
id: string;
|
|
26
|
+
/** When the entry expires */
|
|
27
|
+
expiresAt: string;
|
|
28
|
+
/** Why was it blocked */
|
|
29
|
+
reason?: string;
|
|
30
|
+
/** When it was blocked */
|
|
31
|
+
blockedAt: string;
|
|
32
|
+
/** User ID (for audit) */
|
|
33
|
+
userId?: string;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Session Blocklist
|
|
37
|
+
* Manages blocked/revoked sessions and tokens
|
|
38
|
+
*/
|
|
39
|
+
declare class SessionBlocklist {
|
|
40
|
+
private storage;
|
|
41
|
+
constructor(storage: KVStorage, _config?: BlocklistConfig);
|
|
42
|
+
/**
|
|
43
|
+
* Get storage key for blocklist entry
|
|
44
|
+
*/
|
|
45
|
+
private getKey;
|
|
46
|
+
/**
|
|
47
|
+
* Block a session (revoke it)
|
|
48
|
+
*/
|
|
49
|
+
blockSession(sessionId: string, expiresAt: Date, options?: {
|
|
50
|
+
reason?: string;
|
|
51
|
+
userId?: string;
|
|
52
|
+
}): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* Check if a session is blocked
|
|
55
|
+
*/
|
|
56
|
+
isBlocked(sessionId: string): Promise<boolean>;
|
|
57
|
+
/**
|
|
58
|
+
* Get blocklist entry details
|
|
59
|
+
*/
|
|
60
|
+
getEntry(sessionId: string): Promise<BlocklistEntry | null>;
|
|
61
|
+
/**
|
|
62
|
+
* Unblock a session (if needed)
|
|
63
|
+
*/
|
|
64
|
+
unblockSession(sessionId: string): Promise<void>;
|
|
65
|
+
/**
|
|
66
|
+
* Block multiple sessions (logout all devices)
|
|
67
|
+
*/
|
|
68
|
+
blockMultipleSessions(sessions: Array<{
|
|
69
|
+
id: string;
|
|
70
|
+
expiresAt: Date;
|
|
71
|
+
reason?: string;
|
|
72
|
+
userId?: string;
|
|
73
|
+
}>): Promise<void>;
|
|
74
|
+
/**
|
|
75
|
+
* Block all sessions for a user
|
|
76
|
+
* Requires session IDs to be provided (from session store)
|
|
77
|
+
*/
|
|
78
|
+
blockAllUserSessions(userId: string, sessionIds: string[], tokenExpiresAt: Date, reason?: string): Promise<void>;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Token Blocklist
|
|
82
|
+
* For revoking individual tokens (separate from sessions)
|
|
83
|
+
*/
|
|
84
|
+
declare class TokenBlocklist {
|
|
85
|
+
private storage;
|
|
86
|
+
constructor(storage: KVStorage);
|
|
87
|
+
/**
|
|
88
|
+
* Get storage key for token blocklist entry
|
|
89
|
+
*/
|
|
90
|
+
private getKey;
|
|
91
|
+
/**
|
|
92
|
+
* Hash a token for storage (don't store raw tokens)
|
|
93
|
+
*/
|
|
94
|
+
private hashToken;
|
|
95
|
+
/**
|
|
96
|
+
* Block a token
|
|
97
|
+
*/
|
|
98
|
+
blockToken(token: string, expiresAt: Date, reason?: string): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Check if a token is blocked
|
|
101
|
+
*/
|
|
102
|
+
isBlocked(token: string): Promise<boolean>;
|
|
103
|
+
/**
|
|
104
|
+
* Unblock a token
|
|
105
|
+
*/
|
|
106
|
+
unblockToken(token: string): Promise<void>;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Create session blocklist
|
|
110
|
+
*/
|
|
111
|
+
declare function createSessionBlocklist(storage: KVStorage, config?: BlocklistConfig): SessionBlocklist;
|
|
112
|
+
/**
|
|
113
|
+
* Create token blocklist
|
|
114
|
+
*/
|
|
115
|
+
declare function createTokenBlocklist(storage: KVStorage): TokenBlocklist;
|
|
116
|
+
|
|
117
|
+
export { type BlocklistConfig, SessionBlocklist, TokenBlocklist, createSessionBlocklist, createTokenBlocklist };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { JwtError, JwtManager, SessionBlocklist, TokenBlocklist, createJwtManager, createSessionBlocklist, createTokenBlocklist, extractBearerToken, parseDuration } from '../chunk-MOG4Y6I7.js';
|
|
2
|
+
import '../chunk-42MGHABB.js';
|
|
3
|
+
//# sourceMappingURL=index.js.map
|
|
4
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { K as KVStorage, M as MemoryConfig, S as StorageConfig } from '../types-DSjafxJ4.js';
|
|
2
|
+
export { C as CloudflareKVConfig, D as DenoKVConfig, c as DenoKv, b as KVNamespace, R as RedisConfig, a as StorageType } from '../types-DSjafxJ4.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* In-memory KV Storage adapter
|
|
6
|
+
* Suitable for development, testing, and single-instance deployments
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* In-memory storage with TTL support and LRU eviction
|
|
11
|
+
*/
|
|
12
|
+
declare class MemoryStorage implements KVStorage {
|
|
13
|
+
private cache;
|
|
14
|
+
private readonly maxSize;
|
|
15
|
+
private readonly prefix;
|
|
16
|
+
constructor(config?: MemoryConfig);
|
|
17
|
+
private getKey;
|
|
18
|
+
private isExpired;
|
|
19
|
+
private cleanup;
|
|
20
|
+
private evictOldest;
|
|
21
|
+
get<T = unknown>(key: string): Promise<T | null>;
|
|
22
|
+
set<T = unknown>(key: string, value: T, ttl?: number): Promise<void>;
|
|
23
|
+
delete(key: string): Promise<void>;
|
|
24
|
+
has(key: string): Promise<boolean>;
|
|
25
|
+
getMany<T = unknown>(keys: string[]): Promise<(T | null)[]>;
|
|
26
|
+
setMany<T = unknown>(entries: Array<[key: string, value: T, ttl?: number]>): Promise<void>;
|
|
27
|
+
deleteMany(keys: string[]): Promise<void>;
|
|
28
|
+
keys(pattern?: string): Promise<string[]>;
|
|
29
|
+
private matchPattern;
|
|
30
|
+
clear(): Promise<void>;
|
|
31
|
+
close(): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Get the current size of the cache
|
|
34
|
+
*/
|
|
35
|
+
get size(): number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create a new memory storage instance
|
|
39
|
+
*/
|
|
40
|
+
declare function createMemoryStorage(config?: MemoryConfig): KVStorage;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Multi-runtime Storage Factory
|
|
44
|
+
* Auto-detects runtime and creates appropriate storage adapter
|
|
45
|
+
*/
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Create a storage adapter based on configuration
|
|
49
|
+
* Auto-detects runtime if type is not specified
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```ts
|
|
53
|
+
* // Auto-detect (uses Deno KV on Deno, CF KV on Workers, Memory otherwise)
|
|
54
|
+
* const storage = await createStorage();
|
|
55
|
+
*
|
|
56
|
+
* // Explicit Redis
|
|
57
|
+
* const storage = await createStorage({
|
|
58
|
+
* type: 'redis',
|
|
59
|
+
* redis: { url: 'redis://localhost:6379' }
|
|
60
|
+
* });
|
|
61
|
+
*
|
|
62
|
+
* // Cloudflare KV
|
|
63
|
+
* const storage = await createStorage({
|
|
64
|
+
* type: 'cloudflare-kv',
|
|
65
|
+
* cloudflareKv: { binding: env.MY_KV }
|
|
66
|
+
* });
|
|
67
|
+
*
|
|
68
|
+
* // Custom adapter
|
|
69
|
+
* const storage = await createStorage({
|
|
70
|
+
* type: 'custom',
|
|
71
|
+
* custom: myCustomAdapter
|
|
72
|
+
* });
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
declare function createStorage(config?: StorageConfig): Promise<KVStorage>;
|
|
76
|
+
/**
|
|
77
|
+
* Create storage synchronously (only for memory storage)
|
|
78
|
+
* Use createStorage() for other adapters
|
|
79
|
+
*/
|
|
80
|
+
declare function createStorageSync(config?: StorageConfig): KVStorage;
|
|
81
|
+
/**
|
|
82
|
+
* Storage key prefixes for different purposes
|
|
83
|
+
*/
|
|
84
|
+
declare const StorageKeys: {
|
|
85
|
+
/** OTP storage prefix */
|
|
86
|
+
readonly otp: (identifier: string, type: string) => string;
|
|
87
|
+
/** Rate limit storage prefix */
|
|
88
|
+
readonly rateLimit: (key: string) => string;
|
|
89
|
+
/** Session blocklist prefix */
|
|
90
|
+
readonly blocklist: (tokenId: string) => string;
|
|
91
|
+
/** Magic link token prefix */
|
|
92
|
+
readonly magicLink: (token: string) => string;
|
|
93
|
+
/** CSRF token prefix */
|
|
94
|
+
readonly csrf: (sessionId: string) => string;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export { KVStorage, MemoryConfig, MemoryStorage, StorageConfig, StorageKeys, createMemoryStorage, createStorage, createStorageSync };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|