phoneAuth plugin registers and authenticates users with a phone number and a one-time code. You supply the SMS delivery function. KavachOS handles code generation, expiry, and rate limiting.
Setup
lib/kavach.ts
Send code
POST /auth/phone/send-code
Sends a one-time code to the given phone number. Creates the user account on first send.
Send code (client)
+ prefix, country code, number).
Error codes
Verify code
POST /auth/phone/verify-code
Submits the code the user received. Returns a session on success.
Verify code (client)
Configuration reference
required
Callback invoked to deliver the code. Receives the phone number (E.164) and the numeric code as a string.
number
default:6
Number of digits in the generated code.
number
default:"300 (5 min)"
Code validity window in seconds.
number
default:5
Failed attempts allowed before the code is invalidated.