Skip to content
docsv0.9.0

FileChallengeStore

A challenge ledger on disk: each issued challenge kept until it is consumed once or expires. The shape mirrors the framework's other file stores — an exclusive lock around every mutation, JSON on disk. Consuming a challenge DELETES it, so a second attempt with the same one finds nothing: single-use is enforced by removal, not by a flag someone could forget to check.

FileChallengeStore::__construct()

public function __construct(string $path, int $ttlSeconds = 300, ?callable $clock = null):

Parameters

Parameters of __construct()
NameTypeDescription
$pathstringwhere the ledger lives on disk
$ttlSecondsinthow long an issued challenge stays acceptable
$clock(callable(): int | null)the current unix time, injectable for tests

FileChallengeStore::issue()

public function issue(): string

Mint a fresh random challenge, keep it until it expires, and return its raw bytes.

FileChallengeStore::consume()

public function consume(string $challenge): bool

Accept a challenge once — true if issued and unexpired, then deleted so it can never be true again.

Parameters

Parameters of consume()
NameTypeDescription
$challengestring