The recovery code provider is Trilbdev\TwoFactorLibrary\Modules\Recovery\RecoveryCodeProvider.
This module generates and validates backup codes that can be used as a secondary form of recovery when primary authentication factors are unavailable.
<?php
use Trilbdev\TwoFactorLibrary\TwoFactorAuthentication;
$auth = new TwoFactorAuthentication('Example', 'user@example.com');
$codes = $auth->recoveryCodes()->createBatch(5, 16, 'alphanumeric');
print_r($codes);<?php
$code = $auth->recoveryCodes()->generateCode(12, 'letters');<?php
$matches = $auth->recoveryCodes()->validate('ABC123XYZ789', $codes);numeric→ digits onlyletters→ uppercase letters onlyalphanumeric→ uppercase letters and digitsalpha_numeric→ same asalphanumeric
<?php
$numericCodes = $auth->recoveryCodes()->createBatch(3, 10, 'numeric');
$alphaCodes = $auth->recoveryCodes()->createBatch(2, 12, 'letters');
$validNumeric = $auth->recoveryCodes()->validate($numericCodes[0], $numericCodes);
$validAlpha = $auth->recoveryCodes()->validate($alphaCodes[0], $alphaCodes);createBatch(int $count = 5, int $length = 16, string $type = 'alphanumeric'): arraygenerateCode(int $length = 16, string $type = 'alphanumeric'): stringvalidate(string $candidate, array $codes): bool