@@ -26,7 +26,7 @@ export interface AuthManagerOptions extends Partial<AuthConfig> {
2626 * If not provided, one will be created from config
2727 */
2828 authInstance ?: Auth < any > ;
29-
29+
3030 /**
3131 * ObjectQL Data Engine instance
3232 * Required for database operations using ObjectQL instead of third-party ORMs
@@ -36,7 +36,7 @@ export interface AuthManagerOptions extends Partial<AuthConfig> {
3636
3737/**
3838 * Authentication Manager
39- *
39+ *
4040 * Wraps better-auth and provides authentication services for ObjectStack.
4141 * Supports multiple authentication methods:
4242 * - Email/password
@@ -52,7 +52,7 @@ export class AuthManager {
5252
5353 constructor ( config : AuthManagerOptions ) {
5454 this . config = config ;
55-
55+
5656 // Use provided auth instance
5757 if ( config . authInstance ) {
5858 this . auth = config . authInstance ;
@@ -80,10 +80,10 @@ export class AuthManager {
8080 secret : this . config . secret || this . generateSecret ( ) ,
8181 baseURL : this . config . baseUrl || 'http://localhost:3000' ,
8282 basePath : '/' , // ← 关键修复!告诉 better-auth 路径已被剥离
83-
83+
8484 // Database adapter configuration
8585 database : this . createDatabaseConfig ( ) ,
86-
86+
8787 // Model/field mapping: camelCase (better-auth) → snake_case (ObjectStack)
8888 // These declarations tell better-auth the actual table/column names used
8989 // by ObjectStack's protocol layer, enabling automatic transformation via
@@ -97,19 +97,19 @@ export class AuthManager {
9797 verification : {
9898 ...AUTH_VERIFICATION_CONFIG ,
9999 } ,
100-
100+
101101 // Email configuration
102102 emailAndPassword : {
103103 enabled : true ,
104104 } ,
105-
105+
106106 // Session configuration
107107 session : {
108108 ...AUTH_SESSION_CONFIG ,
109109 expiresIn : this . config . session ?. expiresIn || 60 * 60 * 24 * 7 , // 7 days default
110110 updateAge : this . config . session ?. updateAge || 60 * 60 * 24 , // 1 day default
111111 } ,
112-
112+
113113 // better-auth plugins — registered based on AuthPluginConfig flags
114114 plugins : this . buildPluginList ( ) ,
115115 } ;
@@ -127,13 +127,13 @@ export class AuthManager {
127127 private buildPluginList ( ) : any [ ] {
128128 const pluginConfig = this . config . plugins ;
129129 const plugins : any [ ] = [ ] ;
130-
130+
131131 if ( pluginConfig ?. organization ) {
132132 plugins . push ( organization ( {
133133 schema : buildOrganizationPluginSchema ( ) ,
134134 } ) ) ;
135135 }
136-
136+
137137 if ( pluginConfig ?. twoFactor ) {
138138 plugins . push ( twoFactor ( {
139139 schema : buildTwoFactorPluginSchema ( ) ,
@@ -153,7 +153,7 @@ export class AuthManager {
153153 } ,
154154 } ) ) ;
155155 }
156-
156+
157157 return plugins ;
158158 }
159159
@@ -179,14 +179,14 @@ export class AuthManager {
179179 // the betterAuth config above.
180180 return createObjectQLAdapterFactory ( this . config . dataEngine ) ;
181181 }
182-
182+
183183 // Fallback warning if no dataEngine is provided
184184 console . warn (
185185 '⚠️ WARNING: No dataEngine provided to AuthManager! ' +
186186 'Using in-memory storage. This is NOT suitable for production. ' +
187187 'Please provide a dataEngine instance (e.g., ObjectQL) in AuthManagerOptions.'
188188 ) ;
189-
189+
190190 // Return a minimal in-memory configuration as fallback
191191 // This allows the system to work in development/testing without a real database
192192 return undefined ; // better-auth will use its default in-memory adapter
@@ -197,22 +197,22 @@ export class AuthManager {
197197 */
198198 private generateSecret ( ) : string {
199199 const envSecret = process . env . AUTH_SECRET ;
200-
200+
201201 if ( ! envSecret ) {
202202 // In production, a secret MUST be provided
203203 // For development/testing, we'll use a fallback but warn about it
204204 const fallbackSecret = 'dev-secret-' + Date . now ( ) ;
205-
205+
206206 console . warn (
207207 '⚠️ WARNING: No AUTH_SECRET environment variable set! ' +
208208 'Using a temporary development secret. ' +
209209 'This is NOT secure for production use. ' +
210210 'Please set AUTH_SECRET in your environment variables.'
211211 ) ;
212-
212+
213213 return fallbackSecret ;
214214 }
215-
215+
216216 return envSecret ;
217217 }
218218
@@ -231,7 +231,7 @@ export class AuthManager {
231231 * better-auth catches internal errors (database / adapter / ORM) and
232232 * returns a 500 Response instead of throwing. We therefore inspect the
233233 * response status and log server errors so they are not silently swallowed.
234- *
234+ *
235235 * @param request - Web standard Request object
236236 * @returns Web standard Response object
237237 */
0 commit comments