@dipayan_/loti-client
v1.0.4
Published
The official Node.js SDK for the LOTI (Local OTP Testing Infrastructure) ecosystem.
Downloads
63
Maintainers
Readme
📱 @dipayan_/loti-client
The official Node.js client SDK for LOTI (Local OTP Testing Infrastructure).
This package allows your Node.js application to interact with your local LOTI Docker container, enabling you to test physical SMS and OTP flows completely free during development.
📦 Installation
npm install @dipayan_/loti-clientNote: This SDK requires the LOTI local infrastructure to be running. If you haven't set it up yet, use the LOTI CLI .
🚀 Quickstart
Import the client and point it to your locally running LOTI server port (generated by loti init ).
import { LotiClient } from '@dipayan_/loti-client';
const loti = new LotiClient({
endpoint: 'http://localhost:59338', // Replace w PORT
defaultTTL: 300, // 5 minutes
defaultRetries: 3 // Queue retries
});📖 API Reference
sendOTP(options)
Dispatches an SMS message to the specified phone number via your connected Android worker.
const response = await loti.sendOTP({
phone: '+919876543210',
message: 'Your verification code is {{OTP}}. Do not share this.',
ttl: 120 // Optional override
});
console.log(`Queued Job ID: ${response.jobId}`);verifyOTP(options)
Validates the user's input against the local Redis datastore.
const validation = await loti.verifyOTP({
phone: '+919876543210',
otp: '123456'
});
if (validation.verified) {
console.log("Success!");
}getSystemHealth()
Checks the connection status of the backend, Redis queue, and the physical Android device.
const health = await loti.getSystemHealth();
console.log(`Connected Android Devices: ${health.connectedDevices}`);🧠 TypeScript Support
This package includes built-in TypeScript definitions (index.d.ts) for full IDE IntelliSense and autocomplete out of the box.
