TheDocumentation Index
Fetch the complete documentation index at: https://docs.kavachos.com/llms.txt
Use this file to discover all available pages before exploring further.
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
| Code | Status | Meaning |
|---|---|---|
PHONE_INVALID | 422 | Not a valid E.164 phone number |
RATE_LIMITED | 429 | Too many codes sent to this number |
Verify code
POST /auth/phone/verify-code
Submits the code the user received. Returns a session on success.
Verify code (client)
| Code | Status | Meaning |
|---|---|---|
INVALID_CODE | 401 | Code is wrong or expired |
CODE_EXPIRED | 401 | Code was valid but has passed its expiry window |
Configuration reference
Callback invoked to deliver the code. Receives the phone number (E.164) and the numeric code as a string.
Number of digits in the generated code.
Code validity window in seconds.
Failed attempts allowed before the code is invalidated.