npm package: @fisapool/cookie-manager
Description: A comprehensive cookie management library with encryption, validation, and browser integration
Author: fisapool
Latest version: 1.0.0

# @fisapool/cookie-manager

A comprehensive cookie management library for browser extensions with encryption, validation, and security features.

## Features

- 🔒 **Secure Cookie Management**: Export and import cookies with encryption support
- ✅ **Validation**: Comprehensive cookie validation including domain, format, and security checks
- 🛡️ **Security**: Built-in protection against malicious content and security flag validation
- 🔍 **Browser Integration**: Seamless integration with Chrome extension API
- 🚀 **TypeScript Support**: Full TypeScript support with type definitions

## Installation

```bash
npm install @fisapool/cookie-manager
```

## Usage

### Basic Usage

```typescript
import { CookieManager } from '@fisapool/cookie-manager';

const manager = new CookieManager();

// Export cookies
const settings = {
  encryptionEnabled: true,
  encryptionMethod: 'aes256',
  validateSecurity: true
};

try {
  const result = await manager.exportCookies('example.com', settings);
  console.log('Exported cookies:', result);
} catch (error) {
  console.error('Export failed:', error);
}

// Import cookies
try {
  const result = await manager.importCookies(cookieData, settings);
  console.log('Import result:', result);
} catch (error) {
  console.error('Import failed:', error);
}
```

### Validation

```typescript
import { CookieValidator } from '@fisapool/cookie-manager';

const validator = new CookieValidator();

const cookie = {
  name: 'sessionId',
  value: '12345',
  domain: 'example.com',
  path: '/',
  secure: true,
  httpOnly: true
};

const result = await validator.validateCookie(cookie, settings);
console.log('Validation result:', result);
```

### Encryption

```typescript
import { CookieEncryption } from '@fisapool/cookie-manager';

const encryption = new CookieEncryption();

// Encrypt cookies
const encrypted = await encryption.encryptCookies(cookies, settings);

// Decrypt cookies
const decrypted = await encryption.decryptCookies(encrypted, settings);
```

## API Reference

### CookieManager

- `exportCookies(domain: string, settings: Settings, customName?: string): Promise<ExportResult>`
- `importCookies(importData: any, settings: Settings): Promise<ImportResult>`

### CookieValidator

- `validateCookie(cookie: Cookie, settings: Settings): Promise<ValidationResult>`

### CookieEncryption

- `encryptCookies(cookies: Cookie[], settings: Settings): Promise<EncryptedData>`
- `decryptCookies(encryptedData: EncryptedData, settings: Settings): Promise<Cookie[]>`

## Types

```typescript
interface Cookie {
  name: string;
  value: string;
  domain: string;
  path: string;
  secure: boolean;
  httpOnly: boolean;
  sameSite?: 'strict' | 'lax' | 'none';
  expirationDate?: number;
}

interface Settings {
  encryptionEnabled: boolean;
  encryptionMethod: string;
  validateSecurity: boolean;
}
```

## Security Features

- AES-GCM encryption for cookie data
- Validation of security-related cookie flags
- Detection of potentially malicious content
- Support for Secure and Host-only cookie prefixes
- SameSite attribute validation

## License

MIT