devv-code-backend
Version:
Devv Code Backend SDK - like Supabase for Devv Code
52 lines (38 loc) • 947 B
Markdown
Backend SDK for Devv Code - like Supabase for Devv Code.
```bash
npm install devv-code-backend
```
```javascript
import { DevvAuth } from 'devv-code-backend';
// or import { auth } from 'devv-code-backend';
const auth = new DevvAuth();
// Send OTP
await auth.sendOTP('user@example.com');
// Verify OTP
const authResponse = await auth.verifyOTP('user@example.com', '123456');
const { sid, user } = authResponse;
// Logout
await auth.logout();
```
- `sendOTP(email: string): Promise<void>` - Send verification code
- `verifyOTP(email: string, verificationCode: string): Promise<AuthResponse>` - Verify code and login
- `logout(): Promise<void>` - Logout user
```typescript
interface User {
projectId: string;
uid: string;
name: string;
email: string;
createdTime: number;
lastLoginTime: number;
}
interface AuthResponse {
sid: string;
user: User;
}
```