- Replace === with crypto.timingSafeEqual in all 7 cron routes via shared lib/auth/cron.ts - Add in-memory rate limiting (60 req/min) and expires_at support to calendar feed - Add exponential backoff on MFA verify after 3 failed attempts - Add 60s cooldown on password reset requests - Validate bank callback auth code format before API call - Redact session IDs from bank sync and callback logs - Validate OAuth redirect_uris against allowlist (claude.ai, claude.com, localhost) - Remove excessive PII/debug console logging from login page Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { NextResponse } from 'next/server'
|
|
import { extensionRegistry } from '@/lib/extensions/registry'
|
|
import { ensureInitialized } from '@/lib/init'
|
|
import { verifyCronSecret } from '@/lib/auth/cron'
|
|
|
|
ensureInitialized()
|
|
|
|
export async function POST(request: Request) {
|
|
const authError = verifyCronSecret(request)
|
|
if (authError) return authError
|
|
|
|
const aiExt = extensionRegistry.get('ai-categorization')
|
|
if (!aiExt?.services?.seedAllTemplateEmbeddings || !aiExt?.services?.getSchemaVersion) {
|
|
return NextResponse.json(
|
|
{ error: 'ai-categorization extension not loaded' },
|
|
{ status: 503 }
|
|
)
|
|
}
|
|
|
|
try {
|
|
const { seeded, errors } = await aiExt.services.seedAllTemplateEmbeddings()
|
|
const schemaVersion = await aiExt.services.getSchemaVersion()
|
|
|
|
return NextResponse.json({
|
|
success: errors.length === 0,
|
|
seeded,
|
|
errors,
|
|
schema_version: schemaVersion,
|
|
})
|
|
} catch (error) {
|
|
return NextResponse.json(
|
|
{ error: `Seeding failed: ${error instanceof Error ? error.message : 'Unknown error'}` },
|
|
{ status: 500 }
|
|
)
|
|
}
|
|
}
|