veriflo
v1.0.0
Published
Official Node.js SDK for Veriflo WhatsApp OTP API
Maintainers
Readme
veriflo
Official Node.js SDK for Veriflo WhatsApp OTP API.
Install
npm install verifloQuick Start
const Veriflo = require('veriflo');
(async () => {
const client = Veriflo.init(process.env.VERIFLO_API_KEY);
const sent = await client.sendOTP('+919999999999');
console.log(sent.request_id);
const verify = await client.verifyOTP(sent.request_id, '123456');
console.log(verify.verified);
})();Supported Flows
Flow A: Request ID + Verify API (recommended)
sendOTPreturnsrequest_id.- User enters OTP on your app.
- Call
verifyOTP(request_id, otp)from backend.
Flow B: Return OTP to caller (debug/testing/custom flow)
If your Veriflo dashboard has return_otp_in_response enabled, API returns debug_otp.
const sent = await client.sendOTP('+919999999999', {
requireOtpInResponse: true,
});
// sent.otp / sent.debug_otp available
const locallyValid = client.verifyOtpLocally(sent.otp, userEnteredOtp);API
init(apiKey, options?)
apiKey: Veriflo API key- API base URL is preconfigured in SDK (
https://api.veriflo.app/v1) options.timeoutMs(default:10000)
sendOTP(phone, options?)
Options:
otp: custom OTP value (4-16 digits)length: generate OTP client-side (4-16) and send as custom OTPintegrationTest: sendsintegration_test: truetestMode: sendstest_mode: truerequireOtpInResponse: throws if API does not returndebug_otp
resendOTP(requestId, options?)
Same options as sendOTP.
verifyOTP(requestId, otp, options?)
Verifies OTP against Veriflo verify endpoint.
verifyOtpLocally(expectedOtp, receivedOtp)
Local comparison helper for returned OTP flow.
Notes
- Requires Node.js 18+.
- Keep API keys in server env variables.
- Do not expose API keys in browser/mobile client code.
