feat(app): admin and catalogue entries, step-up guard, MFA in Mon compte (V1-2.5 E, F)
Nav hint from own grants and roles (never a control); RequireCatalog, RequireAdmin (no admin read before aal2), Accès non autorisé page, placeholder routes; TOTP factor list, enrolment with QR and one-time secret, removal, inline step-up for aal2 actions, step-up in password reset; auth kind aal2_required. App 601, e2e:ui 227.
This commit is contained in:
1 parent
99488d71d9
commit
4744e28986
38 files changed
+1818
-55
No files matched your search
@@ -160,9 +160,43 @@ export interface FakeSupabase {
|
||||
updateUser: ReturnType<typeof vi.fn>
|
||||
resetPasswordForEmail: ReturnType<typeof vi.fn>
|
||||
signInWithOAuth: ReturnType<typeof vi.fn>
|
||||
mfa: {
|
||||
listFactors: ReturnType<typeof vi.fn>
|
||||
enroll: ReturnType<typeof vi.fn>
|
||||
challengeAndVerify: ReturnType<typeof vi.fn>
|
||||
unenroll: ReturnType<typeof vi.fn>
|
||||
getAuthenticatorAssuranceLevel: ReturnType<typeof vi.fn>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** A GoTrue factor row as `listFactors().all` returns it. */
|
||||
export function fakeFactor(patch: Record<string, unknown> = {}) {
|
||||
return {
|
||||
id: 'factor-1',
|
||||
friendly_name: 'Phone',
|
||||
factor_type: 'totp',
|
||||
status: 'verified',
|
||||
created_at: '2026-11-01T10:00:00Z',
|
||||
updated_at: '2026-11-01T10:00:00Z',
|
||||
...patch,
|
||||
}
|
||||
}
|
||||
|
||||
/** Programs the account's factors (listFactors) and the session level. */
|
||||
export function setMfa(
|
||||
fake: FakeSupabase,
|
||||
factors: Array<Record<string, unknown>>,
|
||||
currentLevel: 'aal1' | 'aal2' = 'aal1',
|
||||
) {
|
||||
fake.auth.mfa.listFactors.mockResolvedValue({ data: { all: factors, totp: [] }, error: null })
|
||||
const nextLevel = factors.some((f) => f.status === 'verified') ? 'aal2' : 'aal1'
|
||||
fake.auth.mfa.getAuthenticatorAssuranceLevel.mockResolvedValue({
|
||||
data: { currentLevel, nextLevel, currentAuthenticationMethods: [] },
|
||||
error: null,
|
||||
})
|
||||
}
|
||||
|
||||
export function createFakeSupabase(
|
||||
tables: Record<string, Row[]> = { profiles: [fakeProfile()], profile_roles: [], assets: [] },
|
||||
): FakeSupabase {
|
||||
@@ -186,6 +220,16 @@ export function createFakeSupabase(
|
||||
updateUser: vi.fn(),
|
||||
resetPasswordForEmail: vi.fn(),
|
||||
signInWithOAuth: vi.fn(),
|
||||
mfa: {
|
||||
listFactors: vi.fn(async () => ({ data: { all: [], totp: [] }, error: null })),
|
||||
enroll: vi.fn(),
|
||||
challengeAndVerify: vi.fn(async () => ({ data: {}, error: null })),
|
||||
unenroll: vi.fn(async () => ({ data: {}, error: null })),
|
||||
getAuthenticatorAssuranceLevel: vi.fn(async () => ({
|
||||
data: { currentLevel: 'aal1', nextLevel: 'aal1', currentAuthenticationMethods: [] },
|
||||
error: null,
|
||||
})),
|
||||
},
|
||||
}
|
||||
const client = {
|
||||
auth,
|
||||
|
||||
Reference in new issue
Block a user