Skip to content

otplib API Documentation / otplib / functional / verifySync

Function: verifySync() ​

verifySync(options): VerifyResult

Defined in: packages/otplib/src/functional.ts:383

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 algorithm is invalid or unsupported by the plugin

Throws ​

If HMAC computation fails or the plugin does not support sync operations

Example ​

ts
import { verifySync } from 'otplib';

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

Released under the MIT License.