mulguard 1.1.6 → 1.1.7

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 (61) hide show
  1. package/README.md +210 -706
  2. package/dist/actions-CMtg7FGv.js +1 -0
  3. package/dist/{actions-DeCfLtHA.mjs → actions-CjQUKaXF.mjs} +54 -38
  4. package/dist/client/index.js +1 -1
  5. package/dist/client/index.mjs +84 -78
  6. package/dist/core/auth/email-password.d.ts +145 -0
  7. package/dist/core/auth/oauth/index.d.ts +14 -0
  8. package/dist/core/auth/oauth/oauth-handler.d.ts +172 -0
  9. package/dist/core/auth/oauth/pkce.d.ts +168 -0
  10. package/dist/core/auth/{oauth-providers.d.ts → oauth/providers.d.ts} +8 -7
  11. package/dist/core/auth/{oauth-state-store-cookie.d.ts → oauth/state-store-cookie.d.ts} +4 -4
  12. package/dist/core/auth/{oauth-state-store-redis.d.ts → oauth/state-store-redis.d.ts} +1 -1
  13. package/dist/core/auth/{oauth-state-store.d.ts → oauth/state-store.d.ts} +4 -1
  14. package/dist/core/auth/otp.d.ts +184 -0
  15. package/dist/core/errors/index.d.ts +269 -0
  16. package/dist/core/index.d.ts +1 -3
  17. package/dist/core/logger/index.d.ts +147 -0
  18. package/dist/core/mulguard/integration.d.ts +104 -0
  19. package/dist/core/mulguard/oauth-handler.d.ts +1 -1
  20. package/dist/core/security/security-manager.d.ts +236 -0
  21. package/dist/core/session/session-manager.d.ts +235 -0
  22. package/dist/core/types/index.d.ts +27 -5
  23. package/dist/index/index.js +1 -1
  24. package/dist/index/index.mjs +1388 -881
  25. package/dist/index.d.ts +3 -6
  26. package/dist/{client → nextjs/client}/hooks.d.ts +2 -2
  27. package/dist/nextjs/client/index.d.ts +13 -0
  28. package/dist/{client → nextjs/client}/provider.d.ts +1 -1
  29. package/dist/{client → nextjs/client}/server-actions-helper.d.ts +2 -2
  30. package/dist/{handlers → nextjs/handlers}/api.d.ts +1 -1
  31. package/dist/nextjs/handlers/index.d.ts +9 -0
  32. package/dist/{handlers → nextjs/handlers}/route.d.ts +1 -1
  33. package/dist/nextjs/index.d.ts +15 -0
  34. package/dist/nextjs/proxy/index.d.ts +149 -0
  35. package/dist/nextjs/server/actions.d.ts +30 -0
  36. package/dist/{server → nextjs/server}/auth.d.ts +6 -6
  37. package/dist/{server → nextjs/server}/cookies.d.ts +5 -6
  38. package/dist/nextjs/server/index.d.ts +18 -0
  39. package/dist/{server → nextjs/server}/oauth-state.d.ts +5 -3
  40. package/dist/{server → nextjs/server}/session-helpers.d.ts +1 -3
  41. package/dist/nextjs/server/session.d.ts +144 -0
  42. package/dist/oauth-state-Drwz6fES.js +1 -0
  43. package/dist/oauth-state-pdypStuS.mjs +210 -0
  44. package/dist/server/index.js +1 -1
  45. package/dist/server/index.mjs +27 -29
  46. package/package.json +64 -11
  47. package/dist/actions-CExpv_dD.js +0 -1
  48. package/dist/client/index.d.ts +0 -5
  49. package/dist/core/auth/index.d.ts +0 -40
  50. package/dist/core/auth/oauth.d.ts +0 -20
  51. package/dist/middleware/index.d.ts +0 -28
  52. package/dist/middleware/proxy.d.ts +0 -53
  53. package/dist/oauth-state-DKle8eCr.mjs +0 -289
  54. package/dist/oauth-state-DlvrCV11.js +0 -1
  55. package/dist/server/actions.d.ts +0 -86
  56. package/dist/server/helpers.d.ts +0 -10
  57. package/dist/server/index.d.ts +0 -14
  58. package/dist/server/middleware.d.ts +0 -39
  59. package/dist/server/session.d.ts +0 -28
  60. package/dist/server/utils.d.ts +0 -10
  61. /package/dist/{middleware → nextjs/proxy}/security.d.ts +0 -0
@@ -0,0 +1,184 @@
1
+ import { AuthResult, User, Session } from '../types';
2
+ import { SecurityManager } from '../security/security-manager';
3
+ import { Logger } from '../logger';
4
+ /**
5
+ * OTP provider type.
6
+ */
7
+ export type OTPProvider = 'email' | 'sms';
8
+ /**
9
+ * OTP configuration.
10
+ */
11
+ export interface OTPConfig {
12
+ readonly length?: number;
13
+ readonly expiresIn?: number;
14
+ readonly provider?: OTPProvider;
15
+ readonly security?: SecurityManager;
16
+ readonly logger?: Logger;
17
+ }
18
+ /**
19
+ * OTP storage adapter interface.
20
+ */
21
+ export interface OTPStorageAdapter {
22
+ /**
23
+ * Stores an OTP code.
24
+ *
25
+ * @param email - User email
26
+ * @param code - OTP code
27
+ * @param expiresIn - Expiration time in seconds
28
+ */
29
+ set(email: string, code: string, expiresIn: number): Promise<void>;
30
+ /**
31
+ * Gets an OTP code.
32
+ *
33
+ * @param email - User email
34
+ * @returns OTP code or null if not found/expired
35
+ */
36
+ get(email: string): Promise<string | null>;
37
+ /**
38
+ * Deletes an OTP code.
39
+ *
40
+ * @param email - User email
41
+ */
42
+ delete(email: string): Promise<void>;
43
+ }
44
+ /**
45
+ * In-memory OTP storage adapter.
46
+ */
47
+ export declare class MemoryOTPStorage implements OTPStorageAdapter {
48
+ private readonly storage;
49
+ set(email: string, code: string, expiresIn: number): Promise<void>;
50
+ get(email: string): Promise<string | null>;
51
+ delete(email: string): Promise<void>;
52
+ }
53
+ /**
54
+ * OTP authentication handler.
55
+ *
56
+ * Provides secure OTP generation, validation, and authentication.
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * const handler = new OTPAuth({
61
+ * length: 6,
62
+ * expiresIn: 600, // 10 minutes
63
+ * provider: 'email',
64
+ * })
65
+ *
66
+ * // Generate OTP
67
+ * const code = await handler.generateOTP('user@example.com')
68
+ *
69
+ * // Verify OTP
70
+ * const result = await handler.verifyOTP('user@example.com', code, userLookup, createSession)
71
+ * ```
72
+ */
73
+ export declare class OTPAuth {
74
+ private readonly config;
75
+ private readonly storage;
76
+ private readonly security;
77
+ constructor(config?: OTPConfig, storage?: OTPStorageAdapter);
78
+ /**
79
+ * Generates an OTP code for a user.
80
+ *
81
+ * @param email - User email
82
+ * @returns Generated OTP code
83
+ *
84
+ * @example
85
+ * ```typescript
86
+ * const code = await handler.generateOTP('user@example.com')
87
+ * // Send code via email/SMS
88
+ * ```
89
+ */
90
+ generateOTP(email: string): Promise<string>;
91
+ /**
92
+ * Verifies an OTP code and authenticates the user.
93
+ *
94
+ * @template TUser - User type
95
+ * @template TSession - Session type
96
+ * @param email - User email
97
+ * @param code - OTP code to verify
98
+ * @param userLookup - Function to lookup user by email
99
+ * @param createSession - Function to create session (optional)
100
+ * @returns Authentication result
101
+ *
102
+ * @example
103
+ * ```typescript
104
+ * const result = await handler.verifyOTP(
105
+ * 'user@example.com',
106
+ * '123456',
107
+ * async (email) => await db.user.findUnique({ where: { email } })
108
+ * )
109
+ * ```
110
+ */
111
+ verifyOTP<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>>(email: string, code: string, userLookup: (email: string) => Promise<TUser | null>, createSession?: (user: TUser) => Promise<TSession>): Promise<AuthResult<TUser, TSession>>;
112
+ /**
113
+ * Generates a numeric OTP code.
114
+ *
115
+ * @param length - Code length
116
+ * @returns Numeric code string
117
+ */
118
+ private generateNumericCode;
119
+ /**
120
+ * Constant-time string comparison to prevent timing attacks.
121
+ *
122
+ * @param a - First string
123
+ * @param b - Second string
124
+ * @returns True if strings match
125
+ */
126
+ private constantTimeCompare;
127
+ }
128
+ /**
129
+ * Creates an OTP authentication handler.
130
+ *
131
+ * @param config - OTP configuration
132
+ * @param storage - OTP storage adapter (optional)
133
+ * @returns OTP authentication handler
134
+ *
135
+ * @example
136
+ * ```typescript
137
+ * const handler = createOTPAuth({
138
+ * length: 6,
139
+ * expiresIn: 600,
140
+ * provider: 'email',
141
+ * })
142
+ * ```
143
+ */
144
+ export declare function createOTPAuth(config?: OTPConfig, storage?: OTPStorageAdapter): OTPAuth;
145
+ /**
146
+ * TODO: Performance
147
+ * - [ ] Add OTP generation caching
148
+ * - [ ] Optimize storage lookups
149
+ * - [ ] Implement async code generation
150
+ *
151
+ * TODO: Features
152
+ * - [ ] Add SMS provider support
153
+ * - [ ] Implement OTP resend functionality
154
+ * - [ ] Add OTP rate limiting
155
+ * - [ ] Create OTP delivery tracking
156
+ * - [ ] Add OTP code hints (for testing)
157
+ *
158
+ * TODO: Security
159
+ * - [ ] Add OTP brute force protection
160
+ * - [ ] Implement OTP code rotation
161
+ * - [ ] Add OTP delivery verification
162
+ * - [ ] Create security event logging
163
+ *
164
+ * TODO: Type Safety
165
+ * - [ ] Add branded types for OTP codes
166
+ * - [ ] Create type-safe OTP storage
167
+ * - [ ] Implement compile-time validation
168
+ *
169
+ * TODO: Testing
170
+ * - [ ] Add comprehensive unit tests
171
+ * - [ ] Test OTP expiration
172
+ * - [ ] Test constant-time comparison
173
+ * - [ ] Add storage adapter tests
174
+ *
175
+ * TODO: Documentation
176
+ * - [ ] Document OTP flow
177
+ * - [ ] Add provider setup guide
178
+ * - [ ] Create security best practices guide
179
+ *
180
+ * TODO: Limitations
181
+ * - [ ] OTP storage is in-memory (consider Redis for production)
182
+ * - [ ] Code generation uses Math.random (consider crypto.randomInt)
183
+ * - [ ] No SMS provider implementation yet
184
+ */
@@ -0,0 +1,269 @@
1
+ import { AuthErrorCode, AuthError as AuthErrorInterface, ErrorResult } from '../types/errors';
2
+ /**
3
+ * Base authentication error class.
4
+ *
5
+ * Extends native Error with authentication-specific properties.
6
+ * All authentication errors should extend this class.
7
+ *
8
+ * @property code - Specific error code
9
+ * @property statusCode - HTTP status code (if applicable)
10
+ * @property details - Additional error details (optional)
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * throw new AuthError(
15
+ * AuthErrorCode.INVALID_CREDENTIALS,
16
+ * 'Invalid email or password'
17
+ * )
18
+ * ```
19
+ */
20
+ export declare class AuthError extends Error {
21
+ readonly code: AuthErrorCode;
22
+ readonly statusCode: number;
23
+ readonly details?: unknown;
24
+ constructor(code: AuthErrorCode, message: string, statusCode?: number, details?: unknown);
25
+ /**
26
+ * Converts error to plain object for serialization.
27
+ *
28
+ * @returns Plain error object
29
+ */
30
+ toJSON(): AuthErrorInterface;
31
+ /**
32
+ * Creates error result for failed operations.
33
+ *
34
+ * @returns ErrorResult object
35
+ */
36
+ toErrorResult(): ErrorResult;
37
+ }
38
+ /**
39
+ * Invalid credentials error.
40
+ *
41
+ * Thrown when email/password authentication fails.
42
+ */
43
+ export declare class InvalidCredentialsError extends AuthError {
44
+ constructor(message?: string, details?: unknown);
45
+ }
46
+ /**
47
+ * Account locked error.
48
+ *
49
+ * Thrown when account is temporarily locked due to failed attempts.
50
+ */
51
+ export declare class AccountLockedError extends AuthError {
52
+ constructor(message?: string, unlockAt?: Date, details?: unknown);
53
+ }
54
+ /**
55
+ * Account inactive error.
56
+ *
57
+ * Thrown when account is inactive or disabled.
58
+ */
59
+ export declare class AccountInactiveError extends AuthError {
60
+ constructor(message?: string, details?: unknown);
61
+ }
62
+ /**
63
+ * Two-factor authentication required error.
64
+ *
65
+ * Thrown when 2FA verification is required after initial authentication.
66
+ */
67
+ export declare class TwoFactorRequiredError extends AuthError {
68
+ readonly email: string;
69
+ readonly userId: string;
70
+ readonly twoFactorMethod?: 'totp' | 'sms' | 'email';
71
+ readonly challengeToken?: string;
72
+ constructor(email: string, userId: string, message?: string, twoFactorMethod?: 'totp' | 'sms' | 'email', challengeToken?: string, details?: unknown);
73
+ }
74
+ /**
75
+ * Invalid two-factor authentication code error.
76
+ *
77
+ * Thrown when 2FA code verification fails.
78
+ */
79
+ export declare class InvalidTwoFactorCodeError extends AuthError {
80
+ constructor(message?: string, details?: unknown);
81
+ }
82
+ /**
83
+ * Session expired error.
84
+ *
85
+ * Thrown when session has expired.
86
+ */
87
+ export declare class SessionExpiredError extends AuthError {
88
+ constructor(message?: string, details?: unknown);
89
+ }
90
+ /**
91
+ * Unauthorized error.
92
+ *
93
+ * Thrown when user is not authorized for an operation.
94
+ */
95
+ export declare class UnauthorizedError extends AuthError {
96
+ constructor(message?: string, details?: unknown);
97
+ }
98
+ /**
99
+ * Network error.
100
+ *
101
+ * Thrown when network or API communication fails.
102
+ */
103
+ export declare class NetworkError extends AuthError {
104
+ constructor(message?: string, details?: unknown);
105
+ }
106
+ /**
107
+ * Validation error.
108
+ *
109
+ * Thrown when input validation fails.
110
+ */
111
+ export declare class ValidationError extends AuthError {
112
+ readonly fields?: ReadonlyArray<{
113
+ field: string;
114
+ message: string;
115
+ }>;
116
+ constructor(message?: string, fields?: ReadonlyArray<{
117
+ field: string;
118
+ message: string;
119
+ }>, details?: unknown);
120
+ }
121
+ /**
122
+ * Rate limit error.
123
+ *
124
+ * Thrown when rate limit is exceeded.
125
+ */
126
+ export declare class RateLimitError extends AuthError {
127
+ readonly retryAfter?: number;
128
+ constructor(message?: string, retryAfter?: number, details?: unknown);
129
+ }
130
+ /**
131
+ * Creates an authentication error from error code and message.
132
+ *
133
+ * @param code - Error code
134
+ * @param message - Error message
135
+ * @param details - Additional error details (optional)
136
+ * @returns AuthError instance
137
+ *
138
+ * @example
139
+ * ```typescript
140
+ * const error = createError(
141
+ * AuthErrorCode.INVALID_CREDENTIALS,
142
+ * 'Invalid email or password'
143
+ * )
144
+ * ```
145
+ */
146
+ export declare function createError(code: AuthErrorCode, message: string, details?: unknown): AuthError;
147
+ /**
148
+ * Creates an error result for failed operations.
149
+ *
150
+ * @template TCode - Error code type
151
+ * @param code - Error code
152
+ * @param message - Error message
153
+ * @param details - Additional error details (optional)
154
+ * @returns ErrorResult object
155
+ *
156
+ * @example
157
+ * ```typescript
158
+ * const result = createErrorResult(
159
+ * AuthErrorCode.INVALID_CREDENTIALS,
160
+ * 'Invalid email or password'
161
+ * )
162
+ * ```
163
+ */
164
+ export declare function createErrorResult<TCode extends AuthErrorCode = AuthErrorCode>(code: TCode, message: string, details?: unknown): ErrorResult<TCode>;
165
+ /**
166
+ * Converts unknown error to AuthError.
167
+ *
168
+ * Handles various error types and converts them to AuthError.
169
+ *
170
+ * @param error - Unknown error value
171
+ * @param defaultCode - Default error code (optional)
172
+ * @param defaultMessage - Default error message (optional)
173
+ * @returns AuthError instance
174
+ *
175
+ * @example
176
+ * ```typescript
177
+ * try {
178
+ * // Some operation
179
+ * } catch (error) {
180
+ * const authError = toAuthError(error, AuthErrorCode.UNKNOWN_ERROR)
181
+ * logger.error('Operation failed', authError)
182
+ * }
183
+ * ```
184
+ */
185
+ export declare function toAuthError(error: unknown, defaultCode?: AuthErrorCode, defaultMessage?: string): AuthError;
186
+ /**
187
+ * Checks if error is an authentication error.
188
+ *
189
+ * @param error - Error to check
190
+ * @returns True if error is AuthError
191
+ *
192
+ * @example
193
+ * ```typescript
194
+ * if (isAuthError(error)) {
195
+ * // Handle authentication error
196
+ * console.error(error.code, error.message)
197
+ * }
198
+ * ```
199
+ */
200
+ export declare function isAuthError(error: unknown): error is AuthError;
201
+ /**
202
+ * Gets error message from unknown error.
203
+ *
204
+ * @param error - Error to extract message from
205
+ * @param defaultMessage - Default message if extraction fails
206
+ * @returns Error message string
207
+ *
208
+ * @example
209
+ * ```typescript
210
+ * const message = getErrorMessage(error, 'Unknown error')
211
+ * ```
212
+ */
213
+ export declare function getErrorMessage(error: unknown, defaultMessage?: string): string;
214
+ /**
215
+ * Gets error code from unknown error.
216
+ *
217
+ * @param error - Error to extract code from
218
+ * @param defaultCode - Default code if extraction fails
219
+ * @returns Error code
220
+ *
221
+ * @example
222
+ * ```typescript
223
+ * const code = getErrorCode(error, AuthErrorCode.UNKNOWN_ERROR)
224
+ * ```
225
+ */
226
+ export declare function getErrorCode(error: unknown, defaultCode?: AuthErrorCode): AuthErrorCode;
227
+ export { AuthErrorCode, type AuthError as AuthErrorInterface, type ErrorResult, getErrorStatusCode, ERROR_STATUS_MAP, } from '../types/errors';
228
+ /**
229
+ * TODO: Performance
230
+ * - [ ] Add error pooling for high-frequency error creation
231
+ * - [ ] Implement error serialization caching
232
+ * - [ ] Add error aggregation for batch operations
233
+ * - [ ] Consider using Error.cause for error chaining (Node.js 16.9+)
234
+ *
235
+ * TODO: Features
236
+ * - [ ] Add error recovery strategies
237
+ * - [ ] Implement error code hierarchies/categories
238
+ * - [ ] Add localized error messages support
239
+ * - [ ] Create error code to user-friendly message mapping
240
+ * - [ ] Add error code metadata (retryable, transient, etc.)
241
+ * - [ ] Implement error reporting integration (Sentry, etc.)
242
+ * - [ ] Add error context propagation
243
+ *
244
+ * TODO: Type Safety
245
+ * - [ ] Add branded types for error codes
246
+ * - [ ] Implement type-safe error code unions
247
+ * - [ ] Add exhaustiveness checking for error handling
248
+ * - [ ] Create type-safe error code validation
249
+ * - [ ] Add type-level error code to status code mapping
250
+ *
251
+ * TODO: Testing
252
+ * - [ ] Add unit tests for all error classes
253
+ * - [ ] Test error factory functions
254
+ * - [ ] Test error conversion utilities
255
+ * - [ ] Test error serialization
256
+ * - [ ] Add integration tests for error handling flow
257
+ *
258
+ * TODO: Documentation
259
+ * - [ ] Add examples for each error class
260
+ * - [ ] Document error handling best practices
261
+ * - [ ] Create error code reference guide
262
+ * - [ ] Add error handling patterns guide
263
+ *
264
+ * TODO: Limitations
265
+ * - [ ] Error code enum may need extension for custom errors
266
+ * - [ ] Status code mapping is fixed (consider configurable)
267
+ * - [ ] Error details type is unknown (consider generic)
268
+ * - [ ] Stack trace capture may have performance impact
269
+ */
@@ -6,6 +6,4 @@ export type { MulguardConfig, SessionConfig, SecurityConfig, CallbacksConfig, Au
6
6
  export * from './security';
7
7
  export * from './utils/auth-helpers';
8
8
  export * from './auth/signin-unified';
9
- export * from './auth/oauth-providers';
10
- export * from './auth/oauth-state-store';
11
- export * from './auth/oauth-state-store-redis';
9
+ export * from './auth/oauth';
@@ -0,0 +1,147 @@
1
+ import { Logger, LoggerConfig, LogLevel } from '../utils/logger';
2
+ /**
3
+ * Enhanced logging system for Mulguard Authentication Library.
4
+ *
5
+ * Provides structured logging with multiple adapters (Console, Pino) and
6
+ * comprehensive log sanitization for security.
7
+ *
8
+ * @module @mulguard/core/logger
9
+ */
10
+ /**
11
+ * Logger adapter interface for different logging backends.
12
+ */
13
+ export interface LoggerAdapter {
14
+ readonly debug: (message: string, data?: Readonly<Record<string, unknown>>) => void;
15
+ readonly info: (message: string, data?: Readonly<Record<string, unknown>>) => void;
16
+ readonly warn: (message: string, data?: Readonly<Record<string, unknown>>) => void;
17
+ readonly error: (message: string, error?: Error | Readonly<Record<string, unknown>>) => void;
18
+ }
19
+ /**
20
+ * Logger adapter type.
21
+ */
22
+ export type LoggerAdapterType = 'console' | 'pino' | 'custom';
23
+ /**
24
+ * Creates a console-based logger adapter.
25
+ *
26
+ * @param config - Logger configuration
27
+ * @returns Console logger adapter
28
+ */
29
+ export declare function createConsoleAdapter(config?: LoggerConfig): LoggerAdapter;
30
+ /**
31
+ * Creates a Pino-based logger adapter.
32
+ *
33
+ * Requires 'pino' package to be installed.
34
+ * Falls back to console adapter if Pino is not available.
35
+ *
36
+ * @param config - Logger configuration
37
+ * @returns Pino logger adapter or console fallback
38
+ *
39
+ * @example
40
+ * ```typescript
41
+ * const logger = createPinoAdapter({
42
+ * level: 'info',
43
+ * context: 'Auth'
44
+ * })
45
+ * ```
46
+ */
47
+ export declare function createPinoAdapter(config?: LoggerConfig): LoggerAdapter;
48
+ /**
49
+ * Enhanced logger configuration with adapter support.
50
+ */
51
+ export interface EnhancedLoggerConfig {
52
+ readonly adapter?: LoggerAdapterType | LoggerAdapter;
53
+ readonly pinoOptions?: Record<string, unknown>;
54
+ readonly level?: LogLevel;
55
+ readonly context?: string;
56
+ }
57
+ /**
58
+ * Creates an enhanced logger instance with adapter support.
59
+ *
60
+ * @param config - Enhanced logger configuration
61
+ * @returns Logger instance
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * // Console adapter (default)
66
+ * const logger1 = createEnhancedLogger({ level: LogLevel.INFO })
67
+ *
68
+ * // Pino adapter
69
+ * const logger2 = createEnhancedLogger({ adapter: 'pino' })
70
+ *
71
+ * // Custom adapter
72
+ * const logger3 = createEnhancedLogger({ adapter: customAdapter })
73
+ * ```
74
+ */
75
+ export declare function createEnhancedLogger(config?: EnhancedLoggerConfig): Logger;
76
+ /**
77
+ * Default enhanced logger instance.
78
+ *
79
+ * Uses console adapter by default, can be configured via environment variables.
80
+ */
81
+ export declare const logger: Logger;
82
+ /**
83
+ * Creates a logger with context.
84
+ *
85
+ * @param context - Log context
86
+ * @param baseLogger - Base logger instance (optional)
87
+ * @returns Logger with context
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * const authLogger = createContextLogger('Auth', logger)
92
+ * authLogger.info('User signed in', { userId: '123' })
93
+ * // Output: [Auth] User signed in { userId: '123' }
94
+ * ```
95
+ */
96
+ export declare function createContextLogger(context: string, baseLogger?: Logger): Logger;
97
+ export type { Logger, LoggerConfig, LogEntry } from '../utils/logger';
98
+ export { LogLevel, createLogger, isLogger } from '../utils/logger';
99
+ /**
100
+ * TODO: Performance
101
+ * - [ ] Add log batching for high-frequency operations
102
+ * - [ ] Implement async logging for non-blocking operations
103
+ * - [ ] Add log rotation and cleanup
104
+ * - [ ] Consider log sampling for high-volume scenarios
105
+ * - [ ] Add log compression for file-based logging
106
+ *
107
+ * TODO: Features
108
+ * - [ ] Add Winston adapter support
109
+ * - [ ] Implement log transport abstraction (file, remote, etc.)
110
+ * - [ ] Add log correlation IDs (request IDs)
111
+ * - [ ] Create log aggregation support
112
+ * - [ ] Add performance metrics logging
113
+ * - [ ] Implement structured logging with schemas
114
+ * - [ ] Add log filtering by context/level
115
+ *
116
+ * TODO: Type Safety
117
+ * - [ ] Add type-safe log data validation
118
+ * - [ ] Create log schema definitions
119
+ * - [ ] Add compile-time log level checking
120
+ * - [ ] Implement type-safe log context
121
+ *
122
+ * TODO: Security
123
+ * - [ ] Enhance sensitive data detection
124
+ * - [ ] Add PII (Personally Identifiable Information) masking
125
+ * - [ ] Implement log encryption for sensitive logs
126
+ * - [ ] Add audit log support
127
+ * - [ ] Add log access control
128
+ *
129
+ * TODO: Testing
130
+ * - [ ] Add logger adapter unit tests
131
+ * - [ ] Test Pino adapter fallback
132
+ * - [ ] Test log sanitization
133
+ * - [ ] Test context logger
134
+ * - [ ] Add performance tests
135
+ *
136
+ * TODO: Documentation
137
+ * - [ ] Document adapter configuration
138
+ * - [ ] Add logging best practices guide
139
+ * - [ ] Document log levels and when to use them
140
+ * - [ ] Create adapter migration guide
141
+ *
142
+ * TODO: Limitations
143
+ * - [ ] Pino adapter requires 'pino' package (optional dependency)
144
+ * - [ ] Dynamic import may have performance impact
145
+ * - [ ] Log sanitization is basic (may need enhancement)
146
+ * - [ ] No log persistence (consider file/remote logging)
147
+ */