mulguard 1.0.1

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 (66) hide show
  1. package/README.md +368 -0
  2. package/dist/actions-CExpv_dD.js +1 -0
  3. package/dist/actions-DeCfLtHA.mjs +184 -0
  4. package/dist/client/hooks.d.ts +122 -0
  5. package/dist/client/index.d.ts +5 -0
  6. package/dist/client/index.js +1 -0
  7. package/dist/client/index.mjs +476 -0
  8. package/dist/client/provider.d.ts +25 -0
  9. package/dist/client/server-actions-helper.d.ts +22 -0
  10. package/dist/components/AccountPicker.d.ts +11 -0
  11. package/dist/components/OAuthButton.d.ts +11 -0
  12. package/dist/components/PassKeyButton.d.ts +11 -0
  13. package/dist/components/PassKeyRegister.d.ts +10 -0
  14. package/dist/components/TwoFactorSetup.d.ts +8 -0
  15. package/dist/components/TwoFactorVerify.d.ts +9 -0
  16. package/dist/core/account-picker/encryption.d.ts +22 -0
  17. package/dist/core/account-picker/index.d.ts +22 -0
  18. package/dist/core/auth/index.d.ts +40 -0
  19. package/dist/core/auth/oauth-providers.d.ts +69 -0
  20. package/dist/core/auth/oauth-state-store.d.ts +44 -0
  21. package/dist/core/auth/oauth.d.ts +20 -0
  22. package/dist/core/auth/passkey.d.ts +35 -0
  23. package/dist/core/auth/password.d.ts +22 -0
  24. package/dist/core/auth/signin-unified.d.ts +33 -0
  25. package/dist/core/auth/two-factor.d.ts +28 -0
  26. package/dist/core/client/index.d.ts +132 -0
  27. package/dist/core/client/token-refresh-manager.d.ts +48 -0
  28. package/dist/core/index.d.ts +10 -0
  29. package/dist/core/security/csrf.d.ts +46 -0
  30. package/dist/core/security/headers.d.ts +24 -0
  31. package/dist/core/security/index.d.ts +28 -0
  32. package/dist/core/security/rate-limit.d.ts +39 -0
  33. package/dist/core/security/validation.d.ts +53 -0
  34. package/dist/core/security/xss.d.ts +20 -0
  35. package/dist/core/session/index.d.ts +35 -0
  36. package/dist/core/types/auth.d.ts +131 -0
  37. package/dist/core/types/errors.d.ts +44 -0
  38. package/dist/core/types/index.d.ts +369 -0
  39. package/dist/core/utils/auth-helpers.d.ts +136 -0
  40. package/dist/core/utils/logger.d.ts +17 -0
  41. package/dist/handlers/api.d.ts +10 -0
  42. package/dist/handlers/route.d.ts +22 -0
  43. package/dist/index/index.js +1 -0
  44. package/dist/index/index.mjs +1633 -0
  45. package/dist/index.d.ts +21 -0
  46. package/dist/middleware/index.d.ts +28 -0
  47. package/dist/middleware/proxy.d.ts +53 -0
  48. package/dist/middleware/security.d.ts +9 -0
  49. package/dist/mulguard.d.ts +263 -0
  50. package/dist/oauth-state-CzIWQq3s.js +1 -0
  51. package/dist/oauth-state-LE-qeq-K.mjs +282 -0
  52. package/dist/server/actions.d.ts +86 -0
  53. package/dist/server/auth.d.ts +65 -0
  54. package/dist/server/cookies.d.ts +42 -0
  55. package/dist/server/helpers.d.ts +10 -0
  56. package/dist/server/index.d.ts +14 -0
  57. package/dist/server/index.js +1 -0
  58. package/dist/server/index.mjs +31 -0
  59. package/dist/server/middleware.d.ts +39 -0
  60. package/dist/server/oauth-state.d.ts +24 -0
  61. package/dist/server/session-helpers.d.ts +26 -0
  62. package/dist/server/session.d.ts +28 -0
  63. package/dist/server/utils.d.ts +10 -0
  64. package/dist/signin-unified-BS2gxaG1.mjs +30 -0
  65. package/dist/signin-unified-Cw41EFkc.js +1 -0
  66. package/package.json +73 -0
@@ -0,0 +1,20 @@
1
+ /**
2
+ * XSS Protection utilities
3
+ */
4
+ /**
5
+ * Escape HTML to prevent XSS
6
+ */
7
+ export declare function escapeHTML(str: string): string;
8
+ /**
9
+ * Sanitize HTML (basic)
10
+ * Note: For production, use a proper HTML sanitizer library like DOMPurify
11
+ */
12
+ export declare function sanitizeHTML(html: string): string;
13
+ /**
14
+ * Validate and sanitize user input
15
+ */
16
+ export declare function sanitizeUserInput(input: unknown): string;
17
+ /**
18
+ * Check for potential XSS patterns
19
+ */
20
+ export declare function containsXSSPattern(input: string): boolean;
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Session management utilities
3
+ */
4
+ export interface SessionStorage {
5
+ get(key: string): string | null;
6
+ set(key: string, value: string, options?: SessionCookieOptions): void;
7
+ remove(key: string): void;
8
+ }
9
+ export interface SessionCookieOptions {
10
+ expires?: Date | number;
11
+ maxAge?: number;
12
+ domain?: string;
13
+ path?: string;
14
+ secure?: boolean;
15
+ httpOnly?: boolean;
16
+ sameSite?: 'strict' | 'lax' | 'none';
17
+ }
18
+ /**
19
+ * Cookie storage implementation (client-side only)
20
+ * Note: This is for browser environments. Server-side should use Next.js cookies() API
21
+ */
22
+ export declare class CookieStorage implements SessionStorage {
23
+ get(key: string): string | null;
24
+ set(key: string, value: string, options?: SessionCookieOptions): void;
25
+ remove(key: string): void;
26
+ }
27
+ /**
28
+ * Memory storage implementation (for testing)
29
+ */
30
+ export declare class MemoryStorage implements SessionStorage {
31
+ private storage;
32
+ get(key: string): string | null;
33
+ set(key: string, value: string): void;
34
+ remove(key: string): void;
35
+ }
@@ -0,0 +1,131 @@
1
+ import { AuthErrorCode } from './errors';
2
+ export interface User {
3
+ id: string;
4
+ email: string;
5
+ name: string;
6
+ avatar?: string;
7
+ roles?: string[];
8
+ emailVerified?: boolean;
9
+ [key: string]: unknown;
10
+ }
11
+ /**
12
+ * Session object containing user information and authentication tokens
13
+ *
14
+ * @property user - User object with authentication information
15
+ * @property expiresAt - Session expiration date/time
16
+ * @property accessToken - Access token for API authentication (optional)
17
+ * @property refreshToken - Refresh token for token refresh (optional)
18
+ * @property tokenType - Type of token (default: 'Bearer')
19
+ * @property expiresIn - Token expiration time in seconds (optional)
20
+ * @property refreshTokenExpiresAt - Refresh token expiration date/time (optional)
21
+ */
22
+ export interface Session {
23
+ user: User;
24
+ expiresAt: Date | string;
25
+ /** Access token for API authentication (optional) */
26
+ accessToken?: string;
27
+ /** Refresh token for token refresh (optional) */
28
+ refreshToken?: string;
29
+ /** Type of token (default: 'Bearer') */
30
+ tokenType?: 'Bearer' | 'Basic';
31
+ /** Token expiration time in seconds (optional) */
32
+ expiresIn?: number;
33
+ /** Refresh token expiration date/time (optional) */
34
+ refreshTokenExpiresAt?: Date | string;
35
+ [key: string]: unknown;
36
+ }
37
+ /**
38
+ * Authentication result returned by sign-in, sign-up, and other auth actions
39
+ *
40
+ * @property success - Whether the authentication was successful
41
+ * @property user - User object if authentication succeeded
42
+ * @property session - Session object if authentication succeeded
43
+ * @property error - Error message if authentication failed
44
+ * @property errorCode - Specific error code for programmatic error handling
45
+ * @property requires2FA - Whether 2FA verification is required (true when 2FA is needed)
46
+ * @property email - Email address (required when requires2FA is true)
47
+ * @property userId - User ID (required when requires2FA is true)
48
+ *
49
+ * @example
50
+ * ```typescript
51
+ * const result = await auth.signIn.email({ email: 'user@example.com', password: 'password' })
52
+ * if (result.success) {
53
+ * // Authentication successful
54
+ * console.log('User:', result.user)
55
+ * } else if (result.requires2FA) {
56
+ * // 2FA required
57
+ * console.log('2FA required for:', result.email)
58
+ * } else {
59
+ * // Authentication failed
60
+ * console.error('Error:', result.error, result.errorCode)
61
+ * }
62
+ * ```
63
+ */
64
+ export interface AuthResult {
65
+ success: boolean;
66
+ user?: User;
67
+ session?: Session;
68
+ error?: string;
69
+ /** Error code for programmatic error handling */
70
+ errorCode?: AuthErrorCode;
71
+ /** Indicates if 2FA is required */
72
+ requires2FA?: boolean;
73
+ /** Email for 2FA flow */
74
+ email?: string;
75
+ /** User ID for 2FA flow */
76
+ userId?: string;
77
+ }
78
+ /**
79
+ * Two-factor authentication result
80
+ *
81
+ * This type is returned when 2FA verification is required after initial authentication.
82
+ * Use the `isTwoFactorRequired()` helper function to check if a result is of this type.
83
+ *
84
+ * @property success - Always false for 2FA required results
85
+ * @property requires2FA - Always true
86
+ * @property email - Email address of the user requiring 2FA
87
+ * @property userId - User ID requiring 2FA
88
+ * @property errorCode - Always AuthErrorCode.TWO_FA_REQUIRED
89
+ * @property twoFactorMethod - Method of 2FA (totp, sms, email) - optional
90
+ * @property challengeToken - Challenge token for 2FA verification - optional
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * const result = await auth.signIn.email({ email: 'user@example.com', password: 'password' })
95
+ * if (isTwoFactorRequired(result)) {
96
+ * // TypeScript knows result is TwoFactorAuthResult here
97
+ * console.log('2FA required for:', result.email)
98
+ * console.log('Method:', result.twoFactorMethod) // 'totp' | 'sms' | 'email'
99
+ * }
100
+ * ```
101
+ */
102
+ export interface TwoFactorAuthResult extends AuthResult {
103
+ success: false;
104
+ requires2FA: true;
105
+ email: string;
106
+ userId: string;
107
+ error: '2FA_REQUIRED';
108
+ errorCode: AuthErrorCode.TWO_FA_REQUIRED;
109
+ /** Method of 2FA (totp, sms, email) - optional */
110
+ twoFactorMethod?: 'totp' | 'sms' | 'email';
111
+ /** Challenge token for 2FA verification - optional */
112
+ challengeToken?: string;
113
+ }
114
+ /**
115
+ * Data for 2FA verification
116
+ */
117
+ export interface Verify2FAData {
118
+ email: string;
119
+ userId: string;
120
+ code: string;
121
+ }
122
+ export interface EmailCredentials {
123
+ email: string;
124
+ password: string;
125
+ }
126
+ export interface RegisterData {
127
+ email: string;
128
+ password: string;
129
+ name: string;
130
+ [key: string]: unknown;
131
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Authentication error codes
3
+ */
4
+ export declare enum AuthErrorCode {
5
+ /** Invalid email or password */
6
+ INVALID_CREDENTIALS = "INVALID_CREDENTIALS",
7
+ /** Account is temporarily locked */
8
+ ACCOUNT_LOCKED = "ACCOUNT_LOCKED",
9
+ /** Account is inactive or disabled */
10
+ ACCOUNT_INACTIVE = "ACCOUNT_INACTIVE",
11
+ /** Two-factor authentication required */
12
+ TWO_FA_REQUIRED = "TWO_FA_REQUIRED",
13
+ /** Invalid two-factor authentication code */
14
+ INVALID_TWO_FA_CODE = "INVALID_TWO_FA_CODE",
15
+ /** Session has expired */
16
+ SESSION_EXPIRED = "SESSION_EXPIRED",
17
+ /** User is not authorized */
18
+ UNAUTHORIZED = "UNAUTHORIZED",
19
+ /** Network or API error */
20
+ NETWORK_ERROR = "NETWORK_ERROR",
21
+ /** Validation error */
22
+ VALIDATION_ERROR = "VALIDATION_ERROR",
23
+ /** Rate limit exceeded */
24
+ RATE_LIMITED = "RATE_LIMITED",
25
+ /** Unknown error */
26
+ UNKNOWN_ERROR = "UNKNOWN_ERROR"
27
+ }
28
+ /**
29
+ * Authentication error interface
30
+ */
31
+ export interface AuthError {
32
+ /** Error code */
33
+ code: AuthErrorCode;
34
+ /** Human-readable error message */
35
+ message: string;
36
+ /** HTTP status code (if applicable) */
37
+ statusCode?: number;
38
+ /** Additional error details */
39
+ details?: unknown;
40
+ }
41
+ /**
42
+ * Create an authentication error
43
+ */
44
+ export declare function createAuthError(code: AuthErrorCode, message: string, statusCode?: number, details?: unknown): AuthError;
@@ -0,0 +1,369 @@
1
+ /**
2
+ * Core types for Mulguard Authentication Library
3
+ * Server Actions-based architecture with custom logic support
4
+ */
5
+ export * from './auth';
6
+ export * from './errors';
7
+ /**
8
+ * API Client interface for making HTTP requests
9
+ * Used internally by some auth methods
10
+ */
11
+ export interface ApiClient {
12
+ get: <T>(url: string, config?: unknown) => Promise<{
13
+ data: T;
14
+ }>;
15
+ post: <T>(url: string, data?: unknown, config?: unknown) => Promise<{
16
+ data: T;
17
+ }>;
18
+ put: <T>(url: string, data?: unknown, config?: unknown) => Promise<{
19
+ data: T;
20
+ }>;
21
+ delete: <T>(url: string, config?: unknown) => Promise<{
22
+ data: T;
23
+ }>;
24
+ }
25
+ /**
26
+ * Remembered user for account picker
27
+ */
28
+ export interface RememberedUser {
29
+ userId: string;
30
+ email: string;
31
+ name: string;
32
+ avatar?: string;
33
+ provider: 'email' | 'oauth' | 'passkey';
34
+ lastLoginAt: Date;
35
+ }
36
+ /**
37
+ * OAuth Provider Configuration (auth.js-like)
38
+ * Simple configuration - just clientId and clientSecret
39
+ */
40
+ export interface OAuthProviderConfig {
41
+ /** OAuth client ID */
42
+ clientId: string;
43
+ /** OAuth client secret (server-side only) */
44
+ clientSecret?: string;
45
+ /** Custom redirect URI (optional, auto-generated if not provided) */
46
+ redirectUri?: string;
47
+ /** Custom scopes (optional, defaults provided) */
48
+ scopes?: string[];
49
+ /** Additional parameters */
50
+ params?: Record<string, string>;
51
+ }
52
+ /**
53
+ * OAuth Providers Configuration
54
+ * Simple auth.js-like interface
55
+ */
56
+ export interface OAuthProvidersConfig {
57
+ google?: OAuthProviderConfig;
58
+ github?: OAuthProviderConfig;
59
+ apple?: OAuthProviderConfig;
60
+ facebook?: OAuthProviderConfig;
61
+ [key: string]: OAuthProviderConfig | undefined;
62
+ }
63
+ /**
64
+ * Main configuration for Mulguard
65
+ * User provides custom logic for each authentication method
66
+ */
67
+ export interface MulguardConfig {
68
+ /** Session configuration */
69
+ session?: SessionConfig;
70
+ /** Custom authentication logic - user writes their own implementation */
71
+ actions: AuthActions;
72
+ /** Callbacks for lifecycle events */
73
+ callbacks?: CallbacksConfig;
74
+ /** Security configuration */
75
+ security?: SecurityConfig;
76
+ /** Token refresh configuration */
77
+ tokenRefresh?: import('../client/token-refresh-manager').TokenRefreshConfig;
78
+ /** ✅ NEW: OAuth providers configuration (auth.js-like) */
79
+ providers?: {
80
+ oauth?: OAuthProvidersConfig;
81
+ };
82
+ /** ✅ NEW: OAuth state store (for production, use Redis/database-backed store) */
83
+ oauthStateStore?: import('../auth/oauth-state-store').OAuthStateStore;
84
+ /** ✅ NEW: Session cache TTL in milliseconds (default: 5000) */
85
+ sessionCacheTtl?: number;
86
+ }
87
+ /**
88
+ * Sign in options for unified signIn interface
89
+ */
90
+ export type SignInProvider = 'google' | 'github' | 'apple' | 'facebook' | string;
91
+ export interface SignInOptions {
92
+ provider: SignInProvider | 'credentials' | 'passkey' | 'otp';
93
+ credentials?: EmailCredentials;
94
+ formData?: FormData;
95
+ options?: {
96
+ userId?: string;
97
+ email?: string;
98
+ code?: string;
99
+ };
100
+ }
101
+ /**
102
+ * Custom authentication actions - user implements these
103
+ * All actions are Server Actions that run on the server
104
+ */
105
+ export interface AuthActions {
106
+ /**
107
+ * Sign in actions
108
+ */
109
+ signIn: {
110
+ /**
111
+ * Email/password sign in
112
+ * User implements custom logic here
113
+ */
114
+ email: (credentials: EmailCredentials) => Promise<AuthResult>;
115
+ /**
116
+ * OAuth sign in initiation
117
+ * Returns authorization URL and state
118
+ */
119
+ oauth?: (provider: string) => Promise<{
120
+ url: string;
121
+ state: string;
122
+ }>;
123
+ /**
124
+ * PassKey/WebAuthn sign in
125
+ */
126
+ passkey?: (options?: {
127
+ userId?: string;
128
+ }) => Promise<AuthResult>;
129
+ /**
130
+ * OTP sign in
131
+ */
132
+ otp?: (email: string, code?: string) => Promise<AuthResult>;
133
+ };
134
+ /**
135
+ * Sign up new user
136
+ * User implements custom logic here
137
+ */
138
+ signUp?: (data: RegisterData) => Promise<AuthResult>;
139
+ /**
140
+ * Sign out current session
141
+ * User implements custom logic here
142
+ */
143
+ signOut?: () => Promise<{
144
+ success: boolean;
145
+ error?: string;
146
+ }>;
147
+ /**
148
+ * Request password reset
149
+ * User implements custom logic here
150
+ */
151
+ resetPassword?: (email: string) => Promise<{
152
+ success: boolean;
153
+ error?: string;
154
+ }>;
155
+ /**
156
+ * Verify email address
157
+ * User implements custom logic here
158
+ */
159
+ verifyEmail?: (token: string) => Promise<{
160
+ success: boolean;
161
+ error?: string;
162
+ }>;
163
+ /**
164
+ * Get current session
165
+ * User implements custom logic here
166
+ */
167
+ getSession?: () => Promise<Session | null>;
168
+ /**
169
+ * Refresh session
170
+ * User implements custom logic here
171
+ */
172
+ refreshSession?: () => Promise<Session | null>;
173
+ /**
174
+ * OAuth callback handler
175
+ * User implements custom logic here
176
+ */
177
+ oauthCallback?: (provider: string, code: string, state: string) => Promise<AuthResult>;
178
+ /**
179
+ * PassKey methods
180
+ */
181
+ passkey?: {
182
+ register?: (options?: {
183
+ name?: string;
184
+ userId?: string;
185
+ }) => Promise<{
186
+ success: boolean;
187
+ passkeyId?: string;
188
+ error?: string;
189
+ }>;
190
+ authenticate?: (options?: {
191
+ userId?: string;
192
+ }) => Promise<AuthResult>;
193
+ list?: () => Promise<Array<{
194
+ id: string;
195
+ name: string;
196
+ createdAt: Date;
197
+ lastUsedAt?: Date;
198
+ }>>;
199
+ remove?: (passKeyId: string) => Promise<{
200
+ success: boolean;
201
+ error?: string;
202
+ }>;
203
+ };
204
+ /**
205
+ * Two-Factor Authentication methods
206
+ */
207
+ twoFactor?: {
208
+ enable?: () => Promise<{
209
+ success: boolean;
210
+ qrCode?: string;
211
+ secret?: string;
212
+ error?: string;
213
+ }>;
214
+ verify?: (code: string) => Promise<{
215
+ success: boolean;
216
+ backupCodes?: string[];
217
+ error?: string;
218
+ }>;
219
+ disable?: () => Promise<{
220
+ success: boolean;
221
+ error?: string;
222
+ }>;
223
+ generateBackupCodes?: () => Promise<{
224
+ success: boolean;
225
+ backupCodes?: string[];
226
+ error?: string;
227
+ }>;
228
+ isEnabled?: () => Promise<boolean>;
229
+ /**
230
+ * Verify 2FA code after initial sign in
231
+ * Used when signIn returns requires2FA: true
232
+ */
233
+ verify2FA?: (data: import('./auth').Verify2FAData) => Promise<import('./auth').AuthResult>;
234
+ };
235
+ /**
236
+ * Verify 2FA code after initial sign in (legacy - use twoFactor.verify2FA instead)
237
+ * Used when signIn returns requires2FA: true
238
+ */
239
+ verify2FA?: (data: import('./auth').Verify2FAData) => Promise<import('./auth').AuthResult>;
240
+ }
241
+ /**
242
+ * Session configuration
243
+ */
244
+ export interface SessionConfig {
245
+ /** Cookie name (default: '__mulguard_session') */
246
+ cookieName?: string;
247
+ /** Session expiration in seconds (default: 7 days) */
248
+ expiresIn?: number;
249
+ /** HttpOnly flag (default: true) */
250
+ httpOnly?: boolean;
251
+ /** Secure flag (default: true in production) */
252
+ secure?: boolean;
253
+ /** SameSite policy (default: 'lax') */
254
+ sameSite?: 'strict' | 'lax' | 'none';
255
+ /** Cookie path (default: '/') */
256
+ path?: string;
257
+ /** Cookie domain (optional) */
258
+ domain?: string;
259
+ /** Session cache TTL in milliseconds (default: 5000) */
260
+ cacheTtl?: number;
261
+ }
262
+ /**
263
+ * Security configuration
264
+ */
265
+ export interface SecurityConfig {
266
+ /** Enable CSRF protection (default: true) */
267
+ csrfProtection?: boolean;
268
+ /** Enable rate limiting (default: true) */
269
+ rateLimiting?: boolean;
270
+ /** Require HTTPS (default: true in production) */
271
+ requireHttps?: boolean;
272
+ /** Allowed origins for CORS */
273
+ allowedOrigins?: string[];
274
+ }
275
+ /**
276
+ * OAuth user info from provider
277
+ */
278
+ export interface OAuthUserInfo {
279
+ id: string;
280
+ email: string;
281
+ name: string;
282
+ avatar?: string;
283
+ emailVerified?: boolean;
284
+ }
285
+ /**
286
+ * Callbacks configuration
287
+ */
288
+ export interface CallbacksConfig {
289
+ /** Called after successful sign in */
290
+ onSignIn?: (user: User, session: Session) => Promise<void> | void;
291
+ /** Called after sign out */
292
+ onSignOut?: (user: User) => Promise<void> | void;
293
+ /** Called when session is updated */
294
+ onSessionUpdate?: (session: Session) => Promise<Session> | Session;
295
+ /** Called on error */
296
+ onError?: (error: Error, context?: string) => Promise<void> | void;
297
+ /** Called when token is refreshed */
298
+ onTokenRefresh?: (oldSession: Session, newSession: Session) => Promise<void> | void;
299
+ /** Called when session expires */
300
+ onSessionExpired?: (session: Session) => Promise<void> | void;
301
+ /** ✅ NEW: Called when OAuth user is received (for auto-generated OAuth callback) */
302
+ onOAuthUser?: (userInfo: OAuthUserInfo, provider: string) => Promise<User>;
303
+ }
304
+ /**
305
+ * User interface
306
+ */
307
+ export interface User {
308
+ id: string;
309
+ email: string;
310
+ name: string;
311
+ avatar?: string;
312
+ roles?: string[];
313
+ emailVerified?: boolean;
314
+ [key: string]: unknown;
315
+ }
316
+ /**
317
+ * Session interface
318
+ */
319
+ export interface Session {
320
+ user: User;
321
+ expiresAt: Date | string;
322
+ [key: string]: unknown;
323
+ }
324
+ /**
325
+ * Authentication result
326
+ */
327
+ export interface AuthResult {
328
+ success: boolean;
329
+ user?: User;
330
+ session?: Session;
331
+ error?: string;
332
+ /** Error code for programmatic error handling */
333
+ errorCode?: import('./errors').AuthErrorCode;
334
+ /** Indicates if 2FA is required */
335
+ requires2FA?: boolean;
336
+ /** Email for 2FA flow */
337
+ email?: string;
338
+ /** User ID for 2FA flow */
339
+ userId?: string;
340
+ }
341
+ /**
342
+ * Email credentials for sign in
343
+ */
344
+ export interface EmailCredentials {
345
+ email: string;
346
+ password: string;
347
+ }
348
+ /**
349
+ * Registration data
350
+ */
351
+ export interface RegisterData {
352
+ email: string;
353
+ password: string;
354
+ name: string;
355
+ [key: string]: unknown;
356
+ }
357
+ /**
358
+ * Request context for Server Actions
359
+ */
360
+ export interface RequestContext {
361
+ /** Request headers */
362
+ headers: Headers;
363
+ /** Request cookies */
364
+ cookies: Map<string, string>;
365
+ /** Request IP address */
366
+ ip?: string;
367
+ /** Request user agent */
368
+ userAgent?: string;
369
+ }