This is documentation for the next version of Grafana k6 documentation. For the latest stable release, go to the latest version.
TOTP.verify(code, [timeStep])
Verifies a TOTP code against the current time.
Returns
Example
import { TOTP } from 'https://jslib.k6.io/totp/1.0.0/index.js';
export default async function () {
const totp = new TOTP('GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ', 6);
// Generate and verify a code
const code = await totp.gen();
const isValid = await totp.verify(code);
if (isValid) {
console.log('Code is valid!');
} else {
console.log('Code is invalid!');
}
}
