KMP PHP API Reference

PlatformTotpVerifier
in package
implements PlatformTotpVerifierInterface

Table of Contents

Interfaces

PlatformTotpVerifierInterface

Properties

$algorithm  : string
$clock  : Closure
$digits  : int
$period  : int
$secretStore  : SecretStoreInterface
$window  : int

Methods

__construct()  : mixed
Constructor.
codeForTimestamp()  : string
Generate a TOTP code for test vectors and enrollment validation.
isAvailable()  : bool
Return true when production-grade TOTP verification is available.
matchingCounter()  : int|null
Return the matched moving factor; callers must atomically consume it.
verify()  : bool
Verify only the code; authentication callers must consume the counter.
codeForCounter()  : string|null
Generate the HOTP value for a moving factor counter.
decodeBase32()  : string
Decode an RFC 4648 base32 secret without external dependencies.

Properties

Methods

__construct()

Constructor.

public __construct(SecretStoreInterface $secretStore[, int $window = 1 ][, int $period = 30 ][, int $digits = 6 ][, string $algorithm = 'sha1' ][, callable|null $clock = null ]) : mixed
Parameters
$secretStore : SecretStoreInterface
$window : int = 1
$period : int = 30
$digits : int = 6
$algorithm : string = 'sha1'
$clock : callable|null = null

codeForTimestamp()

Generate a TOTP code for test vectors and enrollment validation.

public codeForTimestamp(SensitiveString|string $base32Secret, int $timestamp) : string
Parameters
$base32Secret : SensitiveString|string
$timestamp : int
Return values
string

isAvailable()

Return true when production-grade TOTP verification is available.

public isAvailable() : bool
Tags
inheritDoc
Return values
bool

matchingCounter()

Return the matched moving factor; callers must atomically consume it.

public matchingCounter(string|null $totpSecretRef, string $totpCode) : int|null
Parameters
$totpSecretRef : string|null

Secret-store reference for the user.

$totpCode : string

User-provided TOTP code.

Return values
int|null

verify()

Verify only the code; authentication callers must consume the counter.

public verify(string $platformUserId, string|null $totpSecretRef, string $totpCode) : bool
Parameters
$platformUserId : string
$totpSecretRef : string|null
$totpCode : string
Tags
inheritDoc
Return values
bool

decodeBase32()

Decode an RFC 4648 base32 secret without external dependencies.

private decodeBase32(string $secret) : string
Parameters
$secret : string
Return values
string
On this page

Search results