npm package: @securedevkit/sdk
Description: Official JavaScript/TypeScript SDK for SecureDevKit Authentication Platform
Author: SecureDevKit
Latest version: 1.0.0

# SecureDevKit JavaScript SDK

Official JavaScript/TypeScript SDK for SecureDevKit Authentication Platform.

## Installation

```bash
npm install @securedevkit/sdk
```

## Quick Start

```typescript
import SecureDevKit from '@securedevkit/sdk';

// Initialize the SDK
const sdk = new SecureDevKit({
  apiKey: 'your-api-key-here',
  baseURL: 'https://api.securedevkit.com/api/v1', // Optional, defaults to localhost
});

// Register a new user
const { user, accessToken, refreshToken } = await sdk.auth.register({
  email: 'user@example.com',
  password: 'SecurePassword123!',
  name: 'John Doe',
});

// Login
const authResponse = await sdk.auth.login({
  email: 'user@example.com',
  password: 'SecurePassword123!',
});

// Get current user
const currentUser = await sdk.user.getCurrent(authResponse.accessToken);
```

## Authentication Methods

### Email/Password

```typescript
// Register
await sdk.auth.register({
  email: 'user@example.com',
  password: 'password123',
  name: 'John Doe',
});

// Login
await sdk.auth.login({
  email: 'user@example.com',
  password: 'password123',
});
```

### Magic Link

```typescript
// Request magic link
await sdk.auth.requestMagicLink({
  email: 'user@example.com',
  redirectUrl: 'https://yourapp.com/callback',
});

// Verify magic link token
await sdk.auth.verifyMagicLink(token);
```

### OTP (One-Time Password)

```typescript
// Request OTP
await sdk.auth.requestOTP({
  email: 'user@example.com',
});

// Verify OTP
await sdk.auth.verifyOTP({
  email: 'user@example.com',
  code: '123456',
});
```

### Password Reset

```typescript
// Request password reset
await sdk.auth.requestPasswordReset({
  email: 'user@example.com',
});

// Verify reset token and set new password
await sdk.auth.verifyPasswordReset({
  token: 'reset-token',
  newPassword: 'newSecurePassword123!',
});
```

## User Management

```typescript
// Get user by ID
const user = await sdk.user.getById(userId, accessToken);

// List users with filters
const users = await sdk.user.list({
  page: 1,
  limit: 10,
  search: 'john',
  emailVerified: true,
}, accessToken);

// Update user
await sdk.user.update(userId, {
  name: 'Jane Doe',
  email: 'jane@example.com',
}, accessToken);

// Suspend/Unsuspend user
await sdk.user.suspend(userId, accessToken);
await sdk.user.unsuspend(userId, accessToken);

// Ban/Unban user
await sdk.user.ban(userId, accessToken);
await sdk.user.unban(userId, accessToken);

// Delete user
await sdk.user.delete(userId, accessToken);
```

## Error Handling

```typescript
import { SecureDevKitError } from '@securedevkit/sdk';

try {
  await sdk.auth.login({ email: 'user@example.com', password: 'wrong' });
} catch (error) {
  if (error instanceof SecureDevKitError) {
    console.error('Error:', error.message);
    console.error('Status:', error.status);
    console.error('Code:', error.code);
  }
}
```

## API Reference

See the [full API documentation](https://docs.securedevkit.com) for complete details.

## License

MIT