AtAuth
7

Configure Feed

Select the types of activity you want to include in your feed.

fix: use single quotes for SQLite datetime('now') keyword

SQLite interprets double quotes as identifiers (column names), not
string literals. This caused cleanupExpiredSessions() to fail with:
"no such column: now"

Changed datetime("now") to datetime('now') to properly reference
the SQLite datetime function's special 'now' keyword.

Bryan Brooks (Jan 7, 2026, 9:33 AM -0600) 74654f1a db7fd8f3

+35 -1
+35 -1
gateway/src/services/database.ts
··· 190 190 } 191 191 192 192 cleanupExpiredSessions(): number { 193 - const stmt = this.db.prepare('DELETE FROM sessions WHERE expires_at < datetime("now")'); 193 + const stmt = this.db.prepare("DELETE FROM sessions WHERE expires_at < datetime('now')"); 194 194 const result = stmt.run(); 195 195 return result.changes; 196 196 } ··· 252 252 `); 253 253 const result = stmt.run(did, appId, keepSessionId); 254 254 return result.changes; 255 + } 256 + 257 + // Admin methods for listing and managing apps 258 + getAllApps(): Omit<AppConfig, 'hmac_secret'>[] { 259 + const stmt = this.db.prepare( 260 + 'SELECT id, name, token_ttl_seconds, callback_url, created_at FROM apps ORDER BY created_at DESC' 261 + ); 262 + return stmt.all() as Omit<AppConfig, 'hmac_secret'>[]; 263 + } 264 + 265 + deleteApp(appId: string): void { 266 + // Delete in order respecting foreign keys 267 + this.db.prepare('DELETE FROM oauth_states WHERE app_id = ?').run(appId); 268 + this.db.prepare('DELETE FROM sessions WHERE app_id = ?').run(appId); 269 + this.db.prepare('DELETE FROM user_mappings WHERE app_id = ?').run(appId); 270 + this.db.prepare('DELETE FROM apps WHERE id = ?').run(appId); 271 + } 272 + 273 + getStats(): { appCount: number; activeSessions: number; pendingOAuthStates: number } { 274 + const appCount = ( 275 + this.db.prepare('SELECT COUNT(*) as count FROM apps').get() as { count: number } 276 + ).count; 277 + 278 + const activeSessions = ( 279 + this.db 280 + .prepare("SELECT COUNT(*) as count FROM sessions WHERE expires_at > datetime('now')") 281 + .get() as { count: number } 282 + ).count; 283 + 284 + const pendingOAuthStates = ( 285 + this.db.prepare('SELECT COUNT(*) as count FROM oauth_states').get() as { count: number } 286 + ).count; 287 + 288 + return { appCount, activeSessions, pendingOAuthStates }; 255 289 } 256 290 257 291 close(): void {