mulguard 1.1.2 → 1.1.3

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.
@@ -1,71 +1,197 @@
1
+ import { OAuthProviderConfig } from '../types';
1
2
  /**
2
- * Built-in OAuth Provider Configurations
3
- * Simple auth.js-like configuration for OAuth providers
3
+ * OAuth provider identifier.
4
4
  */
5
+ export type OAuthProviderId = 'google' | 'github' | 'apple' | 'facebook' | string;
5
6
  /**
6
- * OAuth Provider Configuration (auth.js-like)
7
+ * Provider metadata for OAuth endpoints and configuration.
7
8
  */
8
- export interface OAuthProviderConfig {
9
- /** OAuth client ID */
10
- clientId: string;
11
- /** OAuth client secret (server-side only) */
12
- clientSecret?: string;
13
- /** Custom redirect URI (optional, auto-generated if not provided) */
14
- redirectUri?: string;
15
- /** Custom scopes (optional, defaults provided) */
16
- scopes?: string[];
17
- /** Additional parameters */
18
- params?: Record<string, string>;
9
+ export interface ProviderMetadata {
10
+ readonly authorizationUrl: string;
11
+ readonly tokenUrl: string;
12
+ readonly userInfoUrl: string;
13
+ readonly defaultScopes: readonly string[];
14
+ readonly defaultParams?: Readonly<Record<string, string>>;
19
15
  }
20
16
  /**
21
- * OAuth Providers Configuration
22
- * Simple auth.js-like interface
17
+ * Normalized OAuth user profile.
23
18
  */
24
- export interface OAuthProvidersConfig {
25
- google?: OAuthProviderConfig;
26
- github?: OAuthProviderConfig;
27
- apple?: OAuthProviderConfig;
28
- facebook?: OAuthProviderConfig;
29
- [key: string]: OAuthProviderConfig | undefined;
19
+ export interface OAuthUserProfile {
20
+ readonly id: string;
21
+ readonly email: string;
22
+ readonly name: string;
23
+ readonly avatar?: string;
24
+ readonly emailVerified?: boolean;
25
+ readonly rawProfile: Readonly<Record<string, unknown>>;
30
26
  }
31
27
  /**
32
- * Provider metadata for built-in providers
28
+ * OAuth token exchange result.
33
29
  */
34
- interface ProviderMetadata {
35
- authorizationUrl: string;
36
- tokenUrl: string;
37
- userInfoUrl: string;
38
- defaultScopes: string[];
39
- defaultParams?: Record<string, string>;
30
+ export interface TokenExchangeResult {
31
+ readonly access_token: string;
32
+ readonly refresh_token?: string;
33
+ readonly expires_in?: number;
34
+ readonly token_type?: string;
35
+ readonly id_token?: string;
36
+ readonly scope?: string;
40
37
  }
41
38
  /**
42
- * Get provider metadata
39
+ * OAuth error response.
40
+ */
41
+ export interface OAuthErrorResponse {
42
+ readonly error: string;
43
+ readonly error_description?: string;
44
+ readonly error_uri?: string;
45
+ }
46
+ /**
47
+ * Built-in OAuth provider metadata.
48
+ *
49
+ * Contains endpoint URLs, default scopes, and provider-specific parameters.
50
+ */
51
+ declare const PROVIDER_METADATA: Readonly<Record<string, ProviderMetadata>>;
52
+ /**
53
+ * Gets provider metadata for a given provider ID.
54
+ *
55
+ * @param providerId - OAuth provider identifier
56
+ * @returns Provider metadata or null if not found
57
+ *
58
+ * @example
59
+ * ```typescript
60
+ * const metadata = getProviderMetadata('google')
61
+ * if (metadata) {
62
+ * console.log(metadata.authorizationUrl)
63
+ * }
64
+ * ```
43
65
  */
44
66
  export declare function getProviderMetadata(providerId: string): ProviderMetadata | null;
45
67
  /**
46
- * Build OAuth authorization URL
68
+ * Type predicate to check if provider metadata exists.
69
+ *
70
+ * @param providerId - Provider ID to check
71
+ * @returns True if provider is supported
72
+ *
73
+ * @example
74
+ * ```typescript
75
+ * if (isSupportedProvider('google')) {
76
+ * // Provider is supported
77
+ * }
78
+ * ```
79
+ */
80
+ export declare function isSupportedProvider(providerId: string): providerId is keyof typeof PROVIDER_METADATA;
81
+ /**
82
+ * Builds OAuth authorization URL with proper parameters.
83
+ *
84
+ * @param providerId - OAuth provider identifier
85
+ * @param config - Provider configuration
86
+ * @param baseUrl - Base URL for redirect URI
87
+ * @param state - CSRF state token
88
+ * @returns Authorization URL
89
+ * @throws {Error} If provider is not supported
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * const url = buildOAuthAuthorizationUrl(
94
+ * 'google',
95
+ * { clientId: '...' },
96
+ * 'https://example.com',
97
+ * 'state123'
98
+ * )
99
+ * ```
47
100
  */
48
101
  export declare function buildOAuthAuthorizationUrl(providerId: string, config: OAuthProviderConfig, baseUrl: string, state: string): string;
49
102
  /**
50
- * Exchange authorization code for tokens
103
+ * Exchanges authorization code for access tokens.
104
+ *
105
+ * @param providerId - OAuth provider identifier
106
+ * @param config - Provider configuration
107
+ * @param code - Authorization code from OAuth callback
108
+ * @param redirectUri - Redirect URI used in authorization request
109
+ * @returns Token exchange result
110
+ * @throws {Error} If exchange fails or provider is not supported
111
+ *
112
+ * @example
113
+ * ```typescript
114
+ * const tokens = await exchangeOAuthCode(
115
+ * 'google',
116
+ * { clientId: '...', clientSecret: '...' },
117
+ * 'code123',
118
+ * 'https://example.com/callback'
119
+ * )
120
+ * console.log(tokens.access_token)
121
+ * ```
122
+ */
123
+ export declare function exchangeOAuthCode(providerId: string, config: OAuthProviderConfig, code: string, redirectUri: string): Promise<TokenExchangeResult>;
124
+ /**
125
+ * Retrieves user information from OAuth provider.
126
+ *
127
+ * @param providerId - OAuth provider identifier
128
+ * @param accessToken - OAuth access token
129
+ * @returns Normalized user profile with raw provider data
130
+ * @throws {Error} If retrieval fails or provider is not supported
131
+ *
132
+ * @example
133
+ * ```typescript
134
+ * const profile = await getOAuthUserInfo('google', 'access_token_123')
135
+ * console.log(profile.email, profile.name)
136
+ * ```
51
137
  */
52
- export declare function exchangeOAuthCode(providerId: string, config: OAuthProviderConfig, code: string, redirectUri: string): Promise<{
53
- access_token: string;
54
- refresh_token?: string;
55
- expires_in?: number;
56
- token_type?: string;
57
- id_token?: string;
58
- }>;
138
+ export declare function getOAuthUserInfo(providerId: string, accessToken: string): Promise<OAuthUserProfile>;
59
139
  /**
60
- * Get user info from OAuth provider
61
- * Returns normalized user info with raw profile data
140
+ * Type predicate to check if a value is a valid OAuth provider config.
141
+ *
142
+ * @param value - Value to check
143
+ * @returns True if value is a valid OAuth provider config
62
144
  */
63
- export declare function getOAuthUserInfo(providerId: string, accessToken: string): Promise<{
64
- id: string;
65
- email: string;
66
- name: string;
67
- avatar?: string;
68
- emailVerified?: boolean;
69
- rawProfile: Record<string, unknown>;
70
- }>;
145
+ export declare function isOAuthProviderConfig(value: unknown): value is OAuthProviderConfig;
71
146
  export {};
147
+ /**
148
+ * TODO: Performance
149
+ * - [ ] Add token exchange result caching (with TTL)
150
+ * - [ ] Implement request retry logic with exponential backoff
151
+ * - [ ] Add connection pooling for OAuth API calls
152
+ * - [ ] Cache provider metadata lookups
153
+ *
154
+ * TODO: Features
155
+ * - [ ] Add support for PKCE (Proof Key for Code Exchange)
156
+ * - [ ] Implement token refresh flow
157
+ * - [ ] Add support for custom OAuth providers
158
+ * - [ ] Create provider plugin system
159
+ * - [ ] Add OAuth 2.1 compliance
160
+ * - [ ] Support for OpenID Connect
161
+ *
162
+ * TODO: Type Safety
163
+ * - [ ] Add branded types for provider IDs
164
+ * - [ ] Create type-safe provider configuration
165
+ * - [ ] Add compile-time provider validation
166
+ * - [ ] Implement type-level endpoint validation
167
+ *
168
+ * TODO: Security
169
+ * - [ ] Add token validation before use
170
+ * - [ ] Implement token encryption at rest
171
+ * - [ ] Add request signing for OAuth calls
172
+ * - [ ] Create security audit logging
173
+ * - [ ] Add rate limiting for OAuth operations
174
+ *
175
+ * TODO: Error Handling
176
+ * - [ ] Add structured error types for OAuth errors
177
+ * - [ ] Implement error recovery strategies
178
+ * - [ ] Add error retry logic
179
+ * - [ ] Create error reporting
180
+ *
181
+ * TODO: Testing
182
+ * - [ ] Add comprehensive unit tests
183
+ * - [ ] Test all provider normalizations
184
+ * - [ ] Test error handling scenarios
185
+ * - [ ] Add integration tests with mock OAuth servers
186
+ *
187
+ * TODO: Documentation
188
+ * - [ ] Add provider-specific configuration guides
189
+ * - [ ] Document error handling best practices
190
+ * - [ ] Create troubleshooting guide
191
+ *
192
+ * TODO: Limitations
193
+ * - [ ] GitHub email retrieval may fail silently
194
+ * - [ ] Apple profile name only available on first sign-in
195
+ * - [ ] Facebook API version is hardcoded (v18.0)
196
+ * - [ ] No support for OAuth 1.0 providers
197
+ */
@@ -0,0 +1,100 @@
1
+ import { AuthResult, EmailCredentials, RegisterData, User, Session, AuthActions, CallbacksConfig } from '../types';
2
+ /**
3
+ * Authentication handlers configuration.
4
+ */
5
+ export interface AuthHandlersConfig<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>> {
6
+ readonly actions: AuthActions<TUser, TSession>;
7
+ readonly callbacks: CallbacksConfig;
8
+ readonly saveSessionAfterAuth: (result: AuthResult<TUser, TSession>) => Promise<{
9
+ success: boolean;
10
+ error?: string;
11
+ warning?: string;
12
+ }>;
13
+ readonly onError?: (error: Error, context: string) => Promise<void> | void;
14
+ }
15
+ /**
16
+ * Sign-in handlers result.
17
+ */
18
+ export interface SignInHandlers<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>> {
19
+ readonly email: (credentials: EmailCredentials) => Promise<AuthResult<TUser, TSession>>;
20
+ readonly oauth?: (provider: string) => Promise<{
21
+ url: string;
22
+ state: string;
23
+ }>;
24
+ readonly passkey?: (options?: {
25
+ userId?: string;
26
+ }) => Promise<AuthResult<TUser, TSession>>;
27
+ readonly otp?: (email: string, code?: string) => Promise<AuthResult<TUser, TSession>>;
28
+ }
29
+ /**
30
+ * Creates unified sign-in handler that supports both provider-based and direct method calls.
31
+ *
32
+ * @template TUser - User type
33
+ * @template TSession - Session type
34
+ * @param config - Handler configuration
35
+ * @param storeOAuthState - Function to store OAuth state
36
+ * @returns Unified sign-in handler
37
+ */
38
+ export declare function createUnifiedSignInHandler<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>>(config: AuthHandlersConfig<TUser, TSession>, storeOAuthState: (state: string, provider: string) => Promise<void>): SignInHandlers<TUser, TSession> & {
39
+ (provider: string): Promise<{
40
+ url: string;
41
+ state: string;
42
+ }>;
43
+ (provider: 'credentials', credentials: EmailCredentials): Promise<AuthResult<TUser, TSession>>;
44
+ (provider: 'otp', options: {
45
+ email: string;
46
+ code?: string;
47
+ }): Promise<AuthResult<TUser, TSession>>;
48
+ (provider: 'passkey', options?: {
49
+ userId?: string;
50
+ }): Promise<AuthResult<TUser, TSession>>;
51
+ };
52
+ /**
53
+ * Creates sign-up handler.
54
+ *
55
+ * @template TUser - User type
56
+ * @template TSession - Session type
57
+ * @param config - Handler configuration
58
+ * @returns Sign-up handler
59
+ */
60
+ export declare function createSignUpHandler<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>>(config: AuthHandlersConfig<TUser, TSession>): (data: RegisterData) => Promise<AuthResult<TUser, TSession>>;
61
+ /**
62
+ * TODO: Performance
63
+ * - [ ] Add request deduplication for concurrent sign-in attempts
64
+ * - [ ] Implement rate limiting per email/IP
65
+ * - [ ] Add sign-in attempt caching
66
+ * - [ ] Optimize validation logic
67
+ *
68
+ * TODO: Features
69
+ * - [ ] Add social login account linking
70
+ * - [ ] Implement sign-in with magic link
71
+ * - [ ] Add biometric authentication support
72
+ * - [ ] Create sign-in attempt tracking
73
+ *
74
+ * TODO: Type Safety
75
+ * - [ ] Add runtime validation for all inputs
76
+ * - [ ] Create type-safe credential builders
77
+ * - [ ] Implement compile-time provider validation
78
+ *
79
+ * TODO: Security
80
+ * - [ ] Add CAPTCHA support for repeated failures
81
+ * - [ ] Implement account lockout after failed attempts
82
+ * - [ ] Add device fingerprinting
83
+ * - [ ] Create security event logging
84
+ *
85
+ * TODO: Testing
86
+ * - [ ] Add comprehensive handler tests
87
+ * - [ ] Test all validation scenarios
88
+ * - [ ] Test error handling
89
+ * - [ ] Add integration tests
90
+ *
91
+ * TODO: Documentation
92
+ * - [ ] Document all sign-in methods
93
+ * - [ ] Add usage examples
94
+ * - [ ] Create troubleshooting guide
95
+ *
96
+ * TODO: Limitations
97
+ * - [ ] Input validation is basic (consider schema validation)
98
+ * - [ ] No support for custom validation rules
99
+ * - [ ] Error messages may be too generic
100
+ */
@@ -0,0 +1,58 @@
1
+ import { SessionConfig } from '../types';
2
+ import { TokenRefreshConfig } from '../client/token-refresh-manager';
3
+ /**
4
+ * Default session configuration.
5
+ *
6
+ * Auto-detects environment and applies secure defaults.
7
+ *
8
+ * @returns Default session configuration
9
+ */
10
+ export declare function getDefaultSessionConfig(): SessionConfig;
11
+ /**
12
+ * Default token refresh configuration.
13
+ *
14
+ * Optimized to prevent infinite loops and improve performance.
15
+ *
16
+ * @returns Default token refresh configuration
17
+ */
18
+ export declare function getDefaultTokenRefreshConfig(): TokenRefreshConfig;
19
+ /**
20
+ * Gets the base URL for OAuth redirects.
21
+ *
22
+ * Detects the base URL from environment variables or defaults to localhost.
23
+ *
24
+ * @returns Base URL string
25
+ */
26
+ export declare function getBaseUrl(): string;
27
+ /**
28
+ * TODO: Performance
29
+ * - [ ] Cache base URL detection result
30
+ * - [ ] Add configuration validation at startup
31
+ * - [ ] Implement configuration hot-reload support
32
+ *
33
+ * TODO: Features
34
+ * - [ ] Add environment-specific configuration presets
35
+ * - [ ] Create configuration builder pattern
36
+ * - [ ] Add configuration schema validation
37
+ * - [ ] Implement configuration inheritance
38
+ *
39
+ * TODO: Type Safety
40
+ * - [ ] Add type-level validation for configuration values
41
+ * - [ ] Create branded types for configuration
42
+ * - [ ] Implement compile-time configuration checking
43
+ *
44
+ * TODO: Testing
45
+ * - [ ] Add tests for default configurations
46
+ * - [ ] Test environment detection
47
+ * - [ ] Test configuration merging
48
+ *
49
+ * TODO: Documentation
50
+ * - [ ] Document all default values
51
+ * - [ ] Add configuration examples
52
+ * - [ ] Create configuration reference guide
53
+ *
54
+ * TODO: Limitations
55
+ * - [ ] Base URL detection is basic (consider more sophisticated detection)
56
+ * - [ ] No configuration validation at runtime
57
+ * - [ ] Defaults are fixed (consider configurable defaults)
58
+ */
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Mulguard core modules.
3
+ *
4
+ * @module @mulguard/core/mulguard
5
+ */
6
+ export * from './defaults';
7
+ export * from './session-manager';
8
+ export * from './auth-handlers';
9
+ export * from './oauth-handler';
@@ -0,0 +1,93 @@
1
+ import { AuthResult, OAuthUserInfo, User, Session, OAuthProviderConfig, OAuthProvidersConfig, CallbacksConfig } from '../types';
2
+ import { exchangeOAuthCode } from '../auth/oauth-providers';
3
+ /**
4
+ * OAuth handler configuration.
5
+ */
6
+ export interface OAuthHandlerConfig<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>> {
7
+ readonly oauthProviders: OAuthProvidersConfig;
8
+ readonly baseUrl: string;
9
+ readonly callbacks: CallbacksConfig;
10
+ readonly createSession: (user: TUser, userInfo: OAuthUserInfo, tokens: Awaited<ReturnType<typeof exchangeOAuthCode>>) => TSession;
11
+ readonly saveSession: (session: TSession) => Promise<void>;
12
+ readonly onError?: (error: Error, context: string) => Promise<void> | void;
13
+ }
14
+ /**
15
+ * OAuth state validation function.
16
+ */
17
+ export type ValidateOAuthState = (state: string, provider: string) => Promise<boolean>;
18
+ /**
19
+ * Creates OAuth callback handler.
20
+ *
21
+ * Automatically handles:
22
+ * 1. Code exchange for tokens
23
+ * 2. User profile retrieval
24
+ * 3. User creation/lookup via callback
25
+ * 4. Session creation and storage
26
+ *
27
+ * @template TUser - User type
28
+ * @template TSession - Session type
29
+ * @param config - OAuth handler configuration
30
+ * @param validateState - Function to validate OAuth state
31
+ * @returns OAuth callback handler
32
+ *
33
+ * @example
34
+ * ```typescript
35
+ * const handler = createOAuthCallbackHandler(config, validateState)
36
+ * const result = await handler('google', 'code123', 'state456')
37
+ * ```
38
+ */
39
+ export declare function createOAuthCallbackHandler<TUser extends User = User, TSession extends Session<TUser> = Session<TUser>>(config: OAuthHandlerConfig<TUser, TSession>, _validateState: ValidateOAuthState): (provider: string, code: string, _state: string) => Promise<AuthResult<TUser, TSession>>;
40
+ /**
41
+ * Creates OAuth initiation action if providers are configured.
42
+ *
43
+ * @param oauthProviders - OAuth providers configuration
44
+ * @param baseUrl - Base URL for redirects
45
+ * @param generateState - Function to generate CSRF state
46
+ * @param buildAuthUrl - Function to build authorization URL
47
+ * @returns OAuth initiation action or undefined
48
+ */
49
+ export declare function createOAuthInitiationAction(oauthProviders: OAuthProvidersConfig, baseUrl: string, generateState: () => string, buildAuthUrl: (provider: string, config: OAuthProviderConfig, baseUrl: string, state: string) => string): ((provider: string) => Promise<{
50
+ url: string;
51
+ state: string;
52
+ }>) | undefined;
53
+ /**
54
+ * TODO: Performance
55
+ * - [ ] Add token exchange result caching
56
+ * - [ ] Implement request retry logic
57
+ * - [ ] Add connection pooling for OAuth API calls
58
+ * - [ ] Cache user profile data
59
+ *
60
+ * TODO: Features
61
+ * - [ ] Add PKCE support
62
+ * - [ ] Implement token refresh flow
63
+ * - [ ] Add OAuth 2.1 compliance
64
+ * - [ ] Support for OpenID Connect
65
+ * - [ ] Add account linking
66
+ *
67
+ * TODO: Type Safety
68
+ * - [ ] Add type-safe provider configuration
69
+ * - [ ] Create type-level endpoint validation
70
+ * - [ ] Implement compile-time provider validation
71
+ *
72
+ * TODO: Security
73
+ * - [ ] Add token validation before use
74
+ * - [ ] Implement token encryption
75
+ * - [ ] Add request signing
76
+ * - [ ] Create security audit logging
77
+ *
78
+ * TODO: Testing
79
+ * - [ ] Add comprehensive OAuth handler tests
80
+ * - [ ] Test all provider flows
81
+ * - [ ] Test error handling
82
+ * - [ ] Add integration tests
83
+ *
84
+ * TODO: Documentation
85
+ * - [ ] Document OAuth flow
86
+ * - [ ] Add provider setup guides
87
+ * - [ ] Create troubleshooting guide
88
+ *
89
+ * TODO: Limitations
90
+ * - [ ] No support for OAuth 1.0
91
+ * - [ ] Token refresh not implemented
92
+ * - [ ] No PKCE support yet
93
+ */
@@ -0,0 +1,94 @@
1
+ import { Session, SessionConfig } from '../types';
2
+ /**
3
+ * Session cache entry.
4
+ */
5
+ interface SessionCacheEntry {
6
+ readonly session: Session | null;
7
+ readonly timestamp: number;
8
+ }
9
+ /**
10
+ * Session manager configuration.
11
+ */
12
+ export interface SessionManagerConfig {
13
+ readonly sessionConfig: SessionConfig;
14
+ readonly cacheTtl: number;
15
+ readonly getSessionAction?: () => Promise<Session | null>;
16
+ readonly onSessionExpired?: (session: Session) => Promise<void> | void;
17
+ readonly onError?: (error: Error, context: string) => Promise<void> | void;
18
+ }
19
+ /**
20
+ * Session operation result.
21
+ */
22
+ export interface SessionResult {
23
+ readonly success: boolean;
24
+ readonly error?: string;
25
+ readonly warning?: string;
26
+ }
27
+ /**
28
+ * Creates a session manager instance.
29
+ *
30
+ * @param config - Session manager configuration
31
+ * @returns Session manager functions
32
+ */
33
+ export declare function createSessionManager(config: SessionManagerConfig): {
34
+ getSession: () => Promise<Session | null>;
35
+ setSession: (session: Session) => Promise<SessionResult>;
36
+ clearSessionCookie: () => Promise<void>;
37
+ getAccessToken: () => Promise<string | null>;
38
+ getRefreshToken: () => Promise<string | null>;
39
+ hasValidTokens: () => Promise<boolean>;
40
+ clearCache: () => void;
41
+ getSessionConfig: () => {
42
+ cookieName: string;
43
+ config: SessionConfig;
44
+ };
45
+ };
46
+ /**
47
+ * Type predicate to check if a value is a valid session cache entry.
48
+ *
49
+ * @param value - Value to check
50
+ * @returns True if value is a valid cache entry
51
+ */
52
+ export declare function isSessionCacheEntry(value: unknown): value is SessionCacheEntry;
53
+ export {};
54
+ /**
55
+ * TODO: Performance
56
+ * - [ ] Add session compression for large sessions
57
+ * - [ ] Implement session chunking for very large sessions
58
+ * - [ ] Add session cache invalidation strategies
59
+ * - [ ] Consider using WeakMap for session references
60
+ *
61
+ * TODO: Features
62
+ * - [ ] Add session encryption at rest
63
+ * - [ ] Implement session rotation
64
+ * - [ ] Add session fingerprinting
65
+ * - [ ] Create session analytics
66
+ * - [ ] Add session migration support
67
+ *
68
+ * TODO: Type Safety
69
+ * - [ ] Add type-level session validation
70
+ * - [ ] Create type-safe session builders
71
+ * - [ ] Implement session schema validation
72
+ *
73
+ * TODO: Security
74
+ * - [ ] Add session hijacking detection
75
+ * - [ ] Implement session timeout warnings
76
+ * - [ ] Add session audit logging
77
+ * - [ ] Create session security monitoring
78
+ *
79
+ * TODO: Testing
80
+ * - [ ] Add comprehensive session manager tests
81
+ * - [ ] Test cache invalidation
82
+ * - [ ] Test session expiration
83
+ * - [ ] Test error handling
84
+ *
85
+ * TODO: Documentation
86
+ * - [ ] Document session lifecycle
87
+ * - [ ] Add session best practices guide
88
+ * - [ ] Create troubleshooting guide
89
+ *
90
+ * TODO: Limitations
91
+ * - [ ] Session cache is in-memory (not shared across instances)
92
+ * - [ ] No session persistence (consider database-backed sessions)
93
+ * - [ ] Session validation is basic (consider schema validation)
94
+ */