test(supabase): V1-2.1 re-runnable sandbox suite, two-session cases, caps timing

F18 and workspaces no longer leave the seed owner changed. Ten two-session
scenarios with a blocking session, seed-owner AR-1 acceptance, shim columns
against the image, save/submit/approve/publish timed at the caps.
This commit is contained in:
bchanot committed 2026-10-28 18:14:10 +01:00
1 parent d05f75da84
commit ef1f4b593f
10 files changed
+930 -65

No files matched your search

+20 -13
View File
@@ -4,8 +4,8 @@
* user's own access token, as the browser does. TOTP secrets and tokens stay
* in memory and are never printed.
*/
import { stack } from './stack'
import { msToNextStep, totpCode } from './totp'
import { stack, type Account } from './stack'
import { totpCode } from './totp'
export interface Factor {
id: string
@@ -77,20 +77,27 @@ export async function verifyTotp(
})
}
/**
* Verify with a code of a step not used before for this factor: GoTrue refuses
* a code it already accepted, so a second verification waits for the next step.
*/
export async function verifyTotpFreshStep(
/** Enrols and verifies a TOTP factor from `token`, returning the new aal2 access token. */
export async function stepUp(
token: string,
factor: Factor,
): Promise<MfaResult> {
await new Promise((resolve) => setTimeout(resolve, msToNextStep() + 200))
return verifyTotp(token, factor)
name = 'device',
): Promise<string> {
const enrol = await enrolTotp(token, name)
if (!enrol.factor)
throw new Error(`enrol failed: ${JSON.stringify(enrol.body)}`)
const verified = await verifyTotp(token, enrol.factor)
const aal2 = verified.body.access_token as string
if (!aal2) throw new Error(`verify failed: ${JSON.stringify(verified.body)}`)
return aal2
}
export function unenrol(token: string, factorId: string): Promise<MfaResult> {
return authRequest('DELETE', `/factors/${factorId}`, token)
/** A confirmed account signed in, with one verified factor and its aal2 token. */
export interface SteppedAccount extends Account {
aal2: string
}
export async function steppedUp(account: Account): Promise<SteppedAccount> {
return { ...account, aal2: await stepUp(account.token) }
}
/** The claims of an access token (payload only; the signature is not checked here). */