# @birchui/license API reference

> Offline license key verification and watermarking for Birch UI

```bash
npm install @birchui/license
```

## @birchui/license

### checkLicense

Kind: function. Import from `@birchui/license`.

```ts
function checkLicense(product: ProductId, options: { key?: string; host?: HTMLElement; publicKey?: Uint8Array } = {}): LicenseHandle
```

| Parameter | Type | Description |
| --- | --- | --- |
| `product` | `ProductId` |  |
| `options?` | `{ key?: string; host?: HTMLElement; publicKey?: Uint8Array }` |  |

### decodeLicenseKey

Kind: function. Import from `@birchui/license`.

```ts
function decodeLicenseKey(key: string): LicensePayload | null
```

| Parameter | Type | Description |
| --- | --- | --- |
| `key` | `string` |  |

### getLicenseKey

Kind: function. Import from `@birchui/license`.

```ts
function getLicenseKey(): string | undefined
```

### licenseCovers

Kind: function. Import from `@birchui/license`.

```ts
function licenseCovers(payload: LicensePayload, product: ProductId): boolean
```

| Parameter | Type | Description |
| --- | --- | --- |
| `payload` | `LicensePayload` |  |
| `product` | `ProductId` |  |

### onLicenseKeyChange

Kind: function. Import from `@birchui/license`.

```ts
function onLicenseKeyChange(listener: (key: string | undefined) => void): () => void
```

| Parameter | Type | Description |
| --- | --- | --- |
| `listener` | `(key: string \| undefined) => void` |  |

### setLicenseKey

Kind: function. Import from `@birchui/license`.

```ts
function setLicenseKey(key: string | undefined): void
```

| Parameter | Type | Description |
| --- | --- | --- |
| `key` | `string \| undefined` |  |

### verifyLicenseKey

Kind: function. Import from `@birchui/license`.

```ts
function verifyLicenseKey(key: string | undefined, product: ProductId, options: { publicKey?: Uint8Array; now?: Date } = {}): Promise<LicenseCheck>
```

| Parameter | Type | Description |
| --- | --- | --- |
| `key` | `string \| undefined` |  |
| `product` | `ProductId` |  |
| `options?` | `{ publicKey?: Uint8Array; now?: Date }` |  |

### PRODUCT_NAMES

Kind: const. Import from `@birchui/license`.

```ts
const PRODUCT_NAMES: Record<ProductId, string>
```

### PURCHASE_URL

Kind: const. Import from `@birchui/license`.

```ts
const PURCHASE_URL: string = 'https://birchui.com/pricing'
```

### LicenseCheck

Kind: interface. Import from `@birchui/license`.

```ts
interface LicenseCheck
```

| Property | Type | Description |
| --- | --- | --- |
| `status` | `LicenseStatus` |  |
| `product` | `ProductId` |  |
| `license?` | `LicensePayload` |  |
| `message` | `string` |  |

### LicenseHandle

Kind: interface. Import from `@birchui/license`.

```ts
interface LicenseHandle
```

| Property | Type | Description |
| --- | --- | --- |
| `readonly ready` | `Promise<LicenseCheck>` |  |
| `readonly current` | `LicenseCheck \| undefined` |  |
| `dispose` | `() => void` |  |

### LicensePayload

Kind: interface. Import from `@birchui/license`.

```ts
interface LicensePayload
```

| Property | Type | Description |
| --- | --- | --- |
| `v` | `1` |  |
| `id` | `string` |  |
| `to` | `string` |  |
| `email?` | `string` |  |
| `products` | `(ProductId \| '*')[]` |  |
| `seats` | `number` |  |
| `tier` | `LicenseTier` |  |
| `iat` | `string` |  |
| `exp?` | `string` |  |

### LicenseStatus

Kind: type. Import from `@birchui/license`.

```ts
type LicenseStatus = 'valid' | 'missing' | 'malformed' | 'bad-signature' | 'expired' | 'wrong-product';
```

### LicenseTier

Kind: type. Import from `@birchui/license`.

```ts
type LicenseTier = 'developer' | 'team' | 'company' | 'oem' | 'trial';
```

### ProductId

Kind: type. Import from `@birchui/license`.

```ts
type ProductId =
  | 'grid-pro'
  | 'excel'
  | 'scheduler'
  | 'gantt'
  | 'calendar'
  | 'charts'
  | 'pivot-studio'
  | 'forms'
  | 'diagram'
  | 'spreadsheet'
  | 'pdf'
  | 'document';
```

## @birchui/license/sign

### generateSigningKeyPair

Kind: function. Import from `@birchui/license/sign`.

```ts
function generateSigningKeyPair(): { privateKeyPem: string; publicKeyRaw: Uint8Array }
```

### newLicenseId

Kind: function. Import from `@birchui/license/sign`.

```ts
function newLicenseId(): string
```

### signLicense

Kind: function. Import from `@birchui/license/sign`.

```ts
function signLicense(payload: Omit<LicensePayload, 'v'> & { v?: 1 }, privateKeyPem: string): string
```

| Parameter | Type | Description |
| --- | --- | --- |
| `payload` | `Omit<LicensePayload, 'v'> & { v?: 1 }` |  |
| `privateKeyPem` | `string` |  |
