feat(db,schemas): add migration 004, runtime throttle profile, and v1.1 Zod schemas

This commit is contained in:
tyuXX 2026-11-27 22:15:50 +00:00
parent d7c3e11d7e
commit afc2d6358a
30 changed files with 792 additions and 118 deletions

View file

@ -164,7 +164,7 @@ describe('AuthService, TOTP Replay, Step-Up, Safe Mode & Guards', () => {
db.close();
});
it('grants default 1h elevation on bootstrap/login and preserves elevation across Safe Mode toggle', async () => {
it('keeps elevateOnLogin disabled by default (15m step-up policy) and preserves elevation across Safe Mode toggle', async () => {
vi.useFakeTimers({ toFake: ['Date'] });
const t0 = 1_700_000_010_000;
vi.setSystemTime(t0);
@ -180,11 +180,18 @@ describe('AuthService, TOTP Replay, Step-Up, Safe Mode & Guards', () => {
userAgent: 'vitest',
});
expect(boot.session.elevatedUntil).toBe(t0 + 60 * 60 * 1000);
expect(boot.session.elevatedUntil).toBeNull();
vi.setSystemTime(t0 + 31_000);
const step = await auth.stepUp(boot.session.idHash, generateTotp(enroll.secretBase32, t0 + 31_000));
expect(step).toEqual({
ok: true,
elevatedUntil: t0 + 31_000 + 15 * 60 * 1000,
});
const safeSession = auth.setSafeMode(boot.session.idHash, true);
expect(safeSession?.safeMode).toBe(true);
expect(safeSession?.elevatedUntil).toBe(t0 + 60 * 60 * 1000);
expect(safeSession?.elevatedUntil).toBe(t0 + 31_000 + 15 * 60 * 1000);
db.close();
});