# @qquik-identity/core

A lightweight TypeScript SDK for QQuik Identity services that provides seamless identity management for your applications.

## Installation

```bash
npm install @qquik-identity/core
# or
yarn add @qquik-identity/core
```

## Features

- Secure device identification
- Identity and UID retrieval
- Configurable API endpoints
- TypeScript support with full type definitions

## Usage

### Basic Setup

```typescript
import { QQuikIdentity } from '@qquik-identity/core';

// Initialize with your API key
const identity = new QQuikIdentity({
  apiKey: 'your-api-key'
});

// Get user identity
const getIdentity = async () => {
  const identity = await identity.getIdentity();
  console.log(identity);
};

// Get user UID
const getUid = async () => {
  const uid = await identity.getUid();
  console.log(uid);
};
```

### HTML Import (Browser)

You can also use the library directly in the browser via CDN:

```html
<script src="https://cdn.jsdelivr.net/npm/@qquik-identity/core/dist/qquikidentity.umd.production.min.js"></script>
<script>
  // Create an instance with your API key
  const identity = new QQuikIdentity.default({ 
    apiKey: "your-api-key" 
  });
  
  // Get user UID
  identity.getUid()
    .then(uid => console.log("User UID:", uid))
    .catch(error => console.error("Error:", error));
    
  // Get full identity object
  identity.getIdentity()
    .then(identityObj => console.log("Identity:", identityObj))
    .catch(error => console.error("Error:", error));
</script>
```

### Advanced Configuration

```typescript
import { QQuikIdentity } from '@qquik-identity/core';

// Initialize with custom configuration
const identity = new QQuikIdentity({
  baseUrl: 'https://custom-api.example.com',
  apiKey: 'your-api-key',
  timeout: 5000 // Optional timeout in ms
});

// Get identity with custom configuration
const getIdentity = async () => {
  const identity = await identity.getIdentity();
  console.log(identity);
};
```

## API Reference

### QQuikIdentity

The main class for identity operations.

#### Constructor

```typescript
new QQuikIdentity(config?: IdentityConfig)
```

- `config`: Optional configuration object
  - `apiKey`: Your API key for authentication
  - `baseUrl`: Optional API base URL
  - `timeout`: Optional request timeout in milliseconds

#### Methods

- `getIdentity()`: Returns a Promise with the full identity object
- `getUid()`: Returns a Promise with the user's unique identifier

## Types

```typescript
interface IdentityObject {
  uid: string;
  // Additional identity properties
}
```

## Development

```bash
# Install dependencies
yarn install

# Start development mode
yarn start

# Build the package
yarn build

# Run tests
yarn test
```

## License

MIT
