Skip to content

v3.2: Better Parameter Support

Latest
Compare
Choose a tag to compare
@jdpanderson jdpanderson released this 31 Jan 21:39
· 1 commit to master since this release
  • Added a URI builder method to support currently known otpauth URI parameters
  • Internal re-factoring required to prevent code duplication in the new URI builder
  • Changes are backwards compatible

New URI builder usage:

$uriBuilder = (new \Vectorface\GoogleAuthenticator())
    ->getUriBuilder()
    ->secret("AABBCCDDEEFF")
    ->account("John Doe")
    ->issuer("Acme Corp.");

// __toString() allows using the URI builder in strings
$uri = "$uriBuilder";
// or
$uri = $uriBuilder->getUri();

// $uri in both cases is:
// "otpauth://totp/Acme%20Corp.:%20John%20Doe?secret=AABBCCDDEEFF&issuer=Acme%20Corp."

Supports secret, account, issuer, type ("totp" or "hotp"), algorithm ("SHA1" (default), "SHA256", or "SHA512"), digits (6 or 8), counter (HOTP only), and period (TOTP only) parameters.