Skip to content

otplib API Documentation / otplib / verifySync

Function: verifySync()

verifySync(options): VerifyResult

Defined in: otplib/src/functional.ts:369

Verify an OTP code synchronously

This is the synchronous version of verify. It requires a crypto plugin that supports synchronous HMAC operations.

Parameters

options

OTPVerifyFunctionalOptions

OTP verification options

Returns

VerifyResult

Verification result with validity and optional delta

Throws

If the crypto plugin doesn't support sync operations

Example

ts
import { verifySync } from 'otplib';

const result = verifySync({
  secret: 'JBSWY3DPEHPK3PXP',
  token: '123456',
});

Released under the MIT License.