onetime-sdk
v1.0.1
Published
A secure SDK for sending and verifying OTPs via email and SMS.
Maintainers
Readme
OneTime SDK
Easily send and verify OTPs via email or SMS using OneTime's secure API.
🔧 Installation
npm install onetime-sdk⚙️ Usage
import { initOTPClient, sendOTP, verifyOTP } from 'onetime-sdk';
initOTPClient({ apiKey: 'your-api-key' });
await sendOTP({
channel: 'email',
recipient: '[email protected]',
});
await verifyOTP({
channel: 'email',
recipient: '[email protected]',
code: '123456',
});📘 Documentation
✅ Write Unit Tests with Jest
1. Install test tooling
npm install --save-dev jest ts-jest @types/jest
npx ts-jest config:init2. Example test
Create a file at test/client.test.ts:
import { initOTPClient } from '../src';
import { getClient } from '../src/client';
describe('SDK Client Init', () => {
it('should initialize Axios client with API key', () => {
initOTPClient({ apiKey: 'test-key' });
const client = getClient();
expect(client.defaults.headers.common['x-api-key']).toBe('test-key');
});
});3. Add test script to package.json
"scripts": {
"build": "tsup",
"test": "jest"
}