@focura/auth-core 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.
@@ -0,0 +1,593 @@
1
+ import { z } from 'zod';
2
+
3
+ interface RedisAdapter {
4
+ get(key: string): Promise<string | null>;
5
+ set(key: string, value: string, ...args: unknown[]): Promise<"OK" | null>;
6
+ setex(key: string, ttl: number, value: string): Promise<"OK" | null>;
7
+ setnx(key: string, value: string): Promise<number>;
8
+ del(...keys: string[]): Promise<number>;
9
+ exists(key: string): Promise<0 | 1>;
10
+ expire(key: string, seconds: number): Promise<0 | 1>;
11
+ ttl(key: string): Promise<number>;
12
+ sadd(key: string, ...members: string[]): Promise<number>;
13
+ srem(key: string, ...members: string[]): Promise<number>;
14
+ smembers(key: string): Promise<string[]>;
15
+ incr(key: string): Promise<number>;
16
+ scan(cursor: string, ...args: string[]): Promise<[string, string[]]>;
17
+ eval<T = unknown>(script: string, numKeys: number, ...args: string[]): Promise<T>;
18
+ pipeline(): RedisPipeline;
19
+ }
20
+ interface RedisPipeline {
21
+ setex(key: string, ttl: number, value: string): this;
22
+ incr(key: string): this;
23
+ expire(key: string, seconds: number): this;
24
+ exec(): Promise<[Error | null, unknown][]>;
25
+ }
26
+ interface UserStore {
27
+ findById(id: string): Promise<User | null>;
28
+ findByEmail(email: string): Promise<User | null>;
29
+ update(id: string, data: Partial<User>): Promise<void>;
30
+ updateEmailVerified(id: string, verified: Date): Promise<void>;
31
+ }
32
+ interface User {
33
+ id: string;
34
+ email: string;
35
+ name?: string | null;
36
+ role: string;
37
+ password?: string | null;
38
+ emailVerified?: Date | null;
39
+ twoFactorEnabled?: boolean;
40
+ twoFactorSecret?: string | null;
41
+ bannedAt?: Date | null;
42
+ banReason?: string | null;
43
+ lastLoginAt?: Date | null;
44
+ image?: string | null;
45
+ }
46
+ interface CacheAdapter {
47
+ get<T>(key: string): Promise<T | null>;
48
+ set(key: string, value: unknown, ttlSeconds?: number): Promise<void>;
49
+ delete(key: string): Promise<void>;
50
+ }
51
+ interface AuditLogger {
52
+ log(event: string, data: Record<string, unknown>): Promise<void>;
53
+ }
54
+ interface ObservabilitySink {
55
+ setUserContext?(user: {
56
+ id: string;
57
+ email?: string;
58
+ }): void;
59
+ addBreadcrumb?(breadcrumb: {
60
+ message: string;
61
+ data?: Record<string, unknown>;
62
+ }): void;
63
+ captureException?(error: Error, context?: Record<string, unknown>): void;
64
+ }
65
+ interface ErrorFactory {
66
+ UnauthorizedError(message?: string, code?: string): Error;
67
+ TokenExpiredError(): Error;
68
+ InvalidTokenError(code?: string): Error;
69
+ TokenRevokedError(): Error;
70
+ EmailNotVerifiedError(): Error;
71
+ AccountBannedError(reason?: string | null, bannedAt?: Date | null): Error;
72
+ ForbiddenError(message?: string): Error;
73
+ SessionHijackError(reason?: string): Error;
74
+ BadRequestError(message?: string, code?: string): Error;
75
+ ValidationError(message?: string, details?: unknown[], code?: string): Error;
76
+ }
77
+ interface SessionLifecycle {
78
+ recordCreation(sessionId: string): Promise<void>;
79
+ invalidate(sessionId: string): Promise<void>;
80
+ isTracked(sessionId: string): Promise<boolean>;
81
+ isInactive(sessionId: string): Promise<boolean>;
82
+ }
83
+ type RateLimiterFactory = (max: number, windowSeconds: number, keyFn?: (req: {
84
+ headers: Record<string, unknown>;
85
+ ip?: string;
86
+ }) => string | undefined, options?: {
87
+ failOpen?: boolean;
88
+ }) => (req: unknown, res: unknown, next: () => void) => void;
89
+ interface ZodSchema {
90
+ safeParse(data: unknown): {
91
+ success: true;
92
+ data: unknown;
93
+ } | {
94
+ success: false;
95
+ error: {
96
+ issues: Array<{
97
+ path: (string | number)[];
98
+ message: string;
99
+ }>;
100
+ };
101
+ };
102
+ }
103
+ interface TokenConfig {
104
+ privateKey: string;
105
+ publicKey: string;
106
+ issuer?: string;
107
+ audience?: string;
108
+ accessTokenExpiry?: string;
109
+ refreshTokenExpiry?: string;
110
+ sseTokenExpiry?: string;
111
+ currentVersion?: number;
112
+ }
113
+ interface LockoutConfig {
114
+ maxFailures?: number;
115
+ lockoutSeconds?: number;
116
+ windowSeconds?: number;
117
+ }
118
+ interface SessionConfig {
119
+ inactivityTimeout?: number;
120
+ absoluteTimeout?: number;
121
+ maxConcurrent?: number;
122
+ metadataTtl?: number;
123
+ }
124
+ interface AuthCoreConfig {
125
+ redis: RedisAdapter;
126
+ userStore: UserStore;
127
+ hmacSecret: string;
128
+ jwt: TokenConfig;
129
+ cache?: CacheAdapter;
130
+ auditLogger?: AuditLogger;
131
+ observability?: ObservabilitySink;
132
+ errors?: ErrorFactory;
133
+ keyPrefix?: string;
134
+ lockout?: LockoutConfig;
135
+ session?: SessionConfig;
136
+ }
137
+ interface TokenPayload {
138
+ id: string;
139
+ email: string;
140
+ role: string;
141
+ type: "access" | "refresh" | "sse";
142
+ version: number;
143
+ jti: string;
144
+ sessionId?: string;
145
+ }
146
+ interface TokenPair {
147
+ accessToken: string;
148
+ refreshToken: string;
149
+ accessTokenExpiry: number;
150
+ refreshTokenExpiry: number;
151
+ }
152
+ interface DeviceFingerprint {
153
+ userAgent: string;
154
+ acceptLanguage: string;
155
+ acceptEncoding: string;
156
+ ipAddress: string;
157
+ }
158
+ interface SessionMetadata {
159
+ deviceId: string | null;
160
+ ipAddress: string;
161
+ userAgent: string;
162
+ location?: string;
163
+ lastActivity: number;
164
+ }
165
+ type AuditEventType = "LOGIN_SUCCESS" | "LOGIN_FAILED" | "LOGIN_BLOCKED" | "LOGOUT" | "LOGOUT_ALL_DEVICES" | "TOKEN_REFRESHED" | "TOKEN_REVOKED" | "TOKEN_EXPIRED" | "TOKEN_VERSION_MISMATCH" | "TOKEN_REPLAY_DETECTED" | "EXCHANGE_SUCCESS" | "EXCHANGE_FAILED" | "SSE_CONNECTED" | "SSE_DISCONNECTED" | "ACCOUNT_LOCKED" | "TOTP_VERIFIED" | "TOTP_FAILED" | "PERMISSION_DENIED" | "EMAIL_NOT_VERIFIED" | "SESSION_BOUND" | "SESSION_REBOUND" | "SESSION_HIJACK_DETECTED" | "SESSION_TIMEOUT" | "SESSION_REVOKED" | "SESSIONS_REVOKED" | "MAX_SESSIONS_REACHED" | "DEVICE_MISMATCH" | "SUSPICIOUS_IP_CHANGE" | "CSRF_VALIDATION_FAILED" | "UNAUTHORIZED_ACCESS" | "RATE_LIMIT_EXCEEDED" | "MALWARE_DETECTED" | "SUSPICIOUS_ACTIVITY" | "DATA_EXPORT" | "DATA_DELETION" | "SENSITIVE_DATA_ACCESS" | "WORKSPACE_CREATED" | "WORKSPACE_DELETED" | "MEMBER_ADDED" | "MEMBER_REMOVED" | "ROLE_CHANGED" | "SUBSCRIPTION_CREATED" | "SUBSCRIPTION_CANCELLED" | "PAYMENT_FAILED";
166
+ type AuditSeverity = "info" | "warn" | "critical";
167
+
168
+ declare class TokenManager {
169
+ private readonly privateKey;
170
+ private readonly publicKey;
171
+ private readonly issuer;
172
+ private readonly audience;
173
+ private readonly accessTokenExpiry;
174
+ private readonly refreshTokenExpiry;
175
+ private readonly sseTokenExpiry;
176
+ private readonly currentVersion;
177
+ constructor(config: TokenConfig);
178
+ createAccessToken(p: {
179
+ id: string;
180
+ email: string;
181
+ role: string;
182
+ sessionId: string;
183
+ }): string;
184
+ createRefreshToken(p: {
185
+ id: string;
186
+ email: string;
187
+ role: string;
188
+ sessionId: string;
189
+ }): string;
190
+ createTokenPair(p: {
191
+ id: string;
192
+ email: string;
193
+ role: string;
194
+ sessionId?: string;
195
+ }): TokenPair;
196
+ createSseToken(userId: string): string;
197
+ verifyToken(token: string, expectedType?: TokenPayload["type"]): TokenPayload;
198
+ getPublicKey(): string;
199
+ getAccessTokenExpiry(): string;
200
+ getRefreshTokenExpiry(): string;
201
+ getSseTokenExpiry(): string;
202
+ getCurrentVersion(): number;
203
+ getIssuer(): string;
204
+ getAudience(): string;
205
+ static parseExpiry(expiry: string): number;
206
+ static extractJti(token: string): string;
207
+ }
208
+
209
+ declare class TokenRevocation {
210
+ private readonly redis;
211
+ private readonly prefix;
212
+ constructor(redis: RedisAdapter, prefix?: string);
213
+ private refreshIndexKey;
214
+ private refreshTokenKey;
215
+ private revokedAccessKey;
216
+ private sseKey;
217
+ private sessionRevokedKey;
218
+ revokeAccessToken(jti: string, expiresInSeconds: number): Promise<void>;
219
+ isAccessTokenRevoked(jti: string): Promise<boolean>;
220
+ storeRefreshToken(userId: string, jti: string, expiresInSeconds: number): Promise<void>;
221
+ isRefreshTokenValid(userId: string, jti: string): Promise<boolean>;
222
+ revokeRefreshToken(userId: string, jti: string): Promise<void>;
223
+ revokeAllRefreshTokens(userId: string): Promise<void>;
224
+ rotateRefreshToken(userId: string, oldJti: string, newJti: string, expiresInSeconds: number): Promise<boolean>;
225
+ storeSseToken(jti: string, userId: string, ttlSeconds: number): Promise<void>;
226
+ consumeSseToken(jti: string): Promise<string | null>;
227
+ markSessionRevoked(sessionId: string): Promise<void>;
228
+ isSessionRevoked(sessionId: string): Promise<boolean>;
229
+ }
230
+
231
+ declare class RefreshLock {
232
+ private readonly redis;
233
+ private readonly prefix;
234
+ constructor(redis: RedisAdapter, prefix?: string);
235
+ private lockKey;
236
+ acquire(sessionId: string): Promise<boolean>;
237
+ release(sessionId: string): Promise<void>;
238
+ isLocked(sessionId: string): Promise<boolean>;
239
+ }
240
+
241
+ declare class SessionManager {
242
+ private readonly redis;
243
+ private readonly tokenRevocation;
244
+ private readonly auditLogger?;
245
+ private readonly maxConcurrent;
246
+ constructor(redis: RedisAdapter, tokenRevocation: {
247
+ markSessionRevoked(id: string): Promise<void>;
248
+ }, auditLogger?: AuditLogger | undefined, prefix?: string, maxConcurrent?: number);
249
+ private readonly prefix;
250
+ private sessionKey;
251
+ private metadataKey;
252
+ trackUserSession(userId: string, sessionId: string): Promise<void>;
253
+ private pickLeastActiveSession;
254
+ revokeUserSession(userId: string, sessionId: string): Promise<void>;
255
+ getUserActiveSessions(userId: string): Promise<Array<{
256
+ sessionId: string;
257
+ deviceInfo: string;
258
+ ipAddress?: string;
259
+ lastActivity: string;
260
+ createdAt: string;
261
+ }>>;
262
+ }
263
+
264
+ declare function looksLikeServerToServerUA(userAgent: string): boolean;
265
+ declare function looksLikeServerToServerRequest(req: {
266
+ headers: Record<string, string | string[] | undefined>;
267
+ }): boolean;
268
+ declare function normalizeUserAgent(userAgent: string): string;
269
+ declare function generateDeviceFingerprint(req: {
270
+ headers: Record<string, string | string[] | undefined>;
271
+ }): string;
272
+ declare function getClientIp(req: {
273
+ ip?: string;
274
+ headers: Record<string, string | string[] | undefined>;
275
+ socket?: {
276
+ remoteAddress?: string;
277
+ };
278
+ }): string;
279
+ declare function createSessionMetadata(req: {
280
+ ip?: string;
281
+ headers: Record<string, string | string[] | undefined>;
282
+ socket?: {
283
+ remoteAddress?: string;
284
+ };
285
+ }): SessionMetadata;
286
+ declare function isPrivateIp(ip: string): boolean;
287
+ declare function validateSessionBinding(req: {
288
+ headers: Record<string, string | string[] | undefined>;
289
+ ip?: string;
290
+ socket?: {
291
+ remoteAddress?: string;
292
+ };
293
+ }, storedMetadata: SessionMetadata): {
294
+ valid: boolean;
295
+ reason?: string;
296
+ };
297
+
298
+ declare class AccountLockout {
299
+ private readonly redis;
300
+ private readonly maxFailures;
301
+ private readonly lockoutSeconds;
302
+ private readonly windowSeconds;
303
+ private readonly prefix;
304
+ constructor(redis: RedisAdapter, config?: {
305
+ maxFailures?: number;
306
+ lockoutSeconds?: number;
307
+ windowSeconds?: number;
308
+ prefix?: string;
309
+ });
310
+ recordFailedAttempt(identifier: string): Promise<{
311
+ locked: boolean;
312
+ unlocksAt?: Date;
313
+ attempts: number;
314
+ }>;
315
+ clearFailedAttempts(identifier: string): Promise<void>;
316
+ isAccountLocked(identifier: string): Promise<{
317
+ locked: boolean;
318
+ unlocksAt?: Date;
319
+ }>;
320
+ }
321
+
322
+ declare class AuditLog {
323
+ private readonly logger?;
324
+ constructor(logger?: AuditLogger | undefined);
325
+ log(event: AuditEventType, data: Omit<Record<string, unknown>, "event" | "timestamp" | "severity">): void;
326
+ }
327
+
328
+ declare class TotpManager {
329
+ private readonly issuer;
330
+ constructor(issuer?: string);
331
+ generateSecret(): string;
332
+ createUri(secret: string, email: string): string;
333
+ verify(token: string, secret: string): Promise<boolean>;
334
+ }
335
+
336
+ declare class SessionTimeoutManager implements SessionLifecycle {
337
+ private readonly redis;
338
+ private readonly inactivityTimeout;
339
+ private readonly absoluteTimeout;
340
+ private readonly prefix;
341
+ constructor(redis: RedisAdapter, config?: {
342
+ inactivityTimeout?: number;
343
+ absoluteTimeout?: number;
344
+ prefix?: string;
345
+ });
346
+ private createdKey;
347
+ private activityKey;
348
+ recordCreation(sessionId: string): Promise<void>;
349
+ invalidate(sessionId: string): Promise<void>;
350
+ isTracked(sessionId: string): Promise<boolean>;
351
+ isInactive(sessionId: string): Promise<boolean>;
352
+ updateActivity(sessionId: string): Promise<boolean>;
353
+ }
354
+
355
+ declare const DEFAULTS: {
356
+ readonly keyPrefix: "focura:";
357
+ readonly issuer: "focura-app";
358
+ readonly audience: "focura-backend";
359
+ readonly accessTokenExpiry: "15m";
360
+ readonly refreshTokenExpiry: "7d";
361
+ readonly sseTokenExpiry: "30s";
362
+ readonly currentVersion: 1;
363
+ readonly maxConcurrentSessions: 5;
364
+ readonly sessionMetadataTtl: number;
365
+ readonly lockoutMaxFailures: 10;
366
+ readonly lockoutSeconds: number;
367
+ readonly lockoutWindowSeconds: number;
368
+ readonly refreshLockTtlSeconds: 45;
369
+ readonly refreshDedupeTtlSeconds: 30;
370
+ readonly revokedSessionTtl: number;
371
+ readonly inactivityTimeout: number;
372
+ readonly absoluteTimeout: number;
373
+ };
374
+ declare function resolveConfig(raw: AuthCoreConfig): {
375
+ keyPrefix: string;
376
+ issuer: string;
377
+ audience: string;
378
+ accessTokenExpiry: string;
379
+ refreshTokenExpiry: string;
380
+ sseTokenExpiry: string;
381
+ currentVersion: number;
382
+ maxConcurrentSessions: number;
383
+ sessionMetadataTtl: number;
384
+ lockoutMaxFailures: number;
385
+ lockoutSeconds: number;
386
+ lockoutWindowSeconds: number;
387
+ inactivityTimeout: number;
388
+ absoluteTimeout: number;
389
+ redis: RedisAdapter;
390
+ userStore: UserStore;
391
+ hmacSecret: string;
392
+ jwt: TokenConfig;
393
+ cache?: CacheAdapter;
394
+ auditLogger?: AuditLogger;
395
+ observability?: ObservabilitySink;
396
+ errors?: ErrorFactory;
397
+ lockout?: LockoutConfig;
398
+ session?: SessionConfig;
399
+ };
400
+ type ResolvedConfig = ReturnType<typeof resolveConfig>;
401
+ declare const AUDIT_SEVERITY: Record<AuditEventType, AuditSeverity>;
402
+
403
+ interface AuthRequest {
404
+ user?: {
405
+ id: string;
406
+ email: string;
407
+ role: string;
408
+ name?: string | null;
409
+ tokenJti?: string;
410
+ sessionId?: string;
411
+ };
412
+ headers: Record<string, string | string[] | undefined>;
413
+ ip?: string;
414
+ socket?: {
415
+ remoteAddress?: string;
416
+ };
417
+ body?: Record<string, unknown>;
418
+ params?: Record<string, unknown>;
419
+ query?: Record<string, unknown>;
420
+ path?: string;
421
+ method?: string;
422
+ originalUrl?: string;
423
+ [key: string]: unknown;
424
+ }
425
+ interface JwtPayload {
426
+ sub: string;
427
+ email: string;
428
+ role: string;
429
+ jti: string;
430
+ version: number;
431
+ type: string;
432
+ sessionId?: string;
433
+ }
434
+ declare class MiddlewareFactory {
435
+ private readonly config;
436
+ private readonly tokenManager;
437
+ private readonly tokenRevocation;
438
+ private readonly errors;
439
+ private readonly audit;
440
+ private readonly observability?;
441
+ private readonly cache?;
442
+ private sessionTimeoutManager;
443
+ constructor(rawConfig: AuthCoreConfig);
444
+ getTokenManager(): TokenManager;
445
+ getTokenRevocation(): TokenRevocation;
446
+ getAuditLog(): AuditLog;
447
+ getRedis(): RedisAdapter;
448
+ getConfig(): ResolvedConfig;
449
+ enforceSessionBinding(req: AuthRequest, decoded: JwtPayload): Promise<Error | null>;
450
+ createAuthenticateMiddleware(): (req: AuthRequest, res: {
451
+ status(code: number): {
452
+ json(data: unknown): unknown;
453
+ };
454
+ }, next: (err?: Error) => void) => Promise<void>;
455
+ createAuthorizeMiddleware(...roles: string[]): (req: AuthRequest, res: {
456
+ status(code: number): {
457
+ json(data: unknown): unknown;
458
+ };
459
+ }, next: (err?: Error) => void) => void;
460
+ createCsrfMiddleware(): {
461
+ generateToken: (userId: string, sessionId: string) => Promise<string>;
462
+ validateToken: (userId: string, sessionId: string, token: string) => Promise<boolean>;
463
+ middleware(): (req: AuthRequest, res: {
464
+ status(code: number): {
465
+ json(data: unknown): unknown;
466
+ };
467
+ end(): unknown;
468
+ }, next: (err?: Error) => void) => Promise<unknown>;
469
+ };
470
+ createRateLimitMiddleware(): (max: number, windowSeconds: number, keyFn?: (req: AuthRequest) => string | undefined, options?: {
471
+ failOpen?: boolean;
472
+ }) => (req: AuthRequest, res: {
473
+ status(code: number): {
474
+ json(data: unknown): unknown;
475
+ };
476
+ }, next: (err?: Error) => void) => Promise<unknown>;
477
+ createSessionTimeoutMiddleware(): (req: AuthRequest, res: {
478
+ status(code: number): {
479
+ json(data: unknown): unknown;
480
+ };
481
+ }, next: (err?: Error) => void) => Promise<unknown>;
482
+ createExchangeHandler(): (req: AuthRequest, res: {
483
+ status(code: number): {
484
+ json(data: unknown): unknown;
485
+ };
486
+ }) => Promise<unknown>;
487
+ createRefreshHandler(): (req: AuthRequest, res: {
488
+ status(code: number): {
489
+ json(data: unknown): unknown;
490
+ };
491
+ }) => Promise<unknown>;
492
+ createLogoutHandler(): (req: AuthRequest, res: {
493
+ status(code: number): {
494
+ json(data: unknown): unknown;
495
+ };
496
+ }) => Promise<unknown>;
497
+ private loadUser;
498
+ private assignUser;
499
+ }
500
+
501
+ declare const exchangeSchema: z.ZodObject<{
502
+ userId: z.ZodString;
503
+ email: z.ZodString;
504
+ role: z.ZodString;
505
+ sessionId: z.ZodString;
506
+ timestamp: z.ZodUnion<[z.ZodString, z.ZodNumber]>;
507
+ signature: z.ZodString;
508
+ }, "strip", z.ZodTypeAny, {
509
+ email: string;
510
+ role: string;
511
+ sessionId: string;
512
+ userId: string;
513
+ timestamp: string | number;
514
+ signature: string;
515
+ }, {
516
+ email: string;
517
+ role: string;
518
+ sessionId: string;
519
+ userId: string;
520
+ timestamp: string | number;
521
+ signature: string;
522
+ }>;
523
+ declare const refreshSchema: z.ZodObject<{
524
+ refreshToken: z.ZodString;
525
+ }, "strip", z.ZodTypeAny, {
526
+ refreshToken: string;
527
+ }, {
528
+ refreshToken: string;
529
+ }>;
530
+ declare const logoutSchema: z.ZodObject<{
531
+ logoutAll: z.ZodOptional<z.ZodBoolean>;
532
+ }, "strip", z.ZodTypeAny, {
533
+ logoutAll?: boolean | undefined;
534
+ }, {
535
+ logoutAll?: boolean | undefined;
536
+ }>;
537
+
538
+ declare class UnauthorizedError extends Error {
539
+ readonly code: string;
540
+ readonly statusCode = 401;
541
+ constructor(message?: string, code?: string);
542
+ }
543
+ declare class TokenExpiredError extends Error {
544
+ readonly code = "TOKEN_EXPIRED";
545
+ readonly statusCode = 401;
546
+ constructor(message?: string);
547
+ }
548
+ declare class InvalidTokenError extends Error {
549
+ readonly code: string;
550
+ readonly statusCode = 401;
551
+ constructor(code?: string);
552
+ }
553
+ declare class TokenRevokedError extends Error {
554
+ readonly code = "TOKEN_REVOKED";
555
+ readonly statusCode = 401;
556
+ constructor(message?: string);
557
+ }
558
+ declare class EmailNotVerifiedError extends Error {
559
+ readonly code = "EMAIL_NOT_VERIFIED";
560
+ readonly statusCode = 403;
561
+ constructor(message?: string);
562
+ }
563
+ declare class AccountBannedError extends Error {
564
+ readonly code = "ACCOUNT_BANNED";
565
+ readonly statusCode = 403;
566
+ readonly bannedAt?: Date;
567
+ constructor(reason?: string | null, bannedAt?: Date | null);
568
+ }
569
+ declare class ForbiddenError extends Error {
570
+ readonly code = "FORBIDDEN";
571
+ readonly statusCode = 403;
572
+ constructor(message?: string);
573
+ }
574
+ declare class SessionHijackError extends Error {
575
+ readonly code = "SESSION_HIJACK_DETECTED";
576
+ readonly statusCode = 401;
577
+ constructor(reason?: string);
578
+ }
579
+ declare class BadRequestError extends Error {
580
+ readonly code: string;
581
+ readonly statusCode = 400;
582
+ constructor(message?: string, code?: string);
583
+ }
584
+ declare class ValidationError extends Error {
585
+ readonly code: string;
586
+ readonly statusCode = 400;
587
+ readonly details?: unknown[];
588
+ constructor(message?: string, details?: unknown[], code?: string);
589
+ }
590
+
591
+ declare const defaultErrors: ErrorFactory;
592
+
593
+ export { AUDIT_SEVERITY, AccountBannedError, AccountLockout, type AuditEventType, AuditLog, type AuditLogger, type AuditSeverity, type AuthCoreConfig, type AuthRequest, BadRequestError, type CacheAdapter, DEFAULTS, type DeviceFingerprint, EmailNotVerifiedError, type ErrorFactory, ForbiddenError, InvalidTokenError, type LockoutConfig, MiddlewareFactory, type ObservabilitySink, type RateLimiterFactory, type RedisAdapter, type RedisPipeline, RefreshLock, type ResolvedConfig, type SessionConfig, SessionHijackError, type SessionLifecycle, SessionManager, type SessionMetadata, SessionTimeoutManager, type TokenConfig, TokenExpiredError, TokenManager, type TokenPair, type TokenPayload, TokenRevocation, TokenRevokedError, TotpManager, UnauthorizedError, type User, type UserStore, ValidationError, type ZodSchema, createSessionMetadata, defaultErrors, exchangeSchema, generateDeviceFingerprint, getClientIp, isPrivateIp, logoutSchema, looksLikeServerToServerRequest, looksLikeServerToServerUA, normalizeUserAgent, refreshSchema, resolveConfig, validateSessionBinding };