# Aphrodite Domain - External API Integrations Inventory

> Documentation of all external API integrations in the Eve codebase for
> migration to the Aphrodite domain within the Oshun monorepo.

## Table of Contents

1. [Payment Processors](#1-payment-processors)
2. [Interactive Device Integrations](#2-interactive-device-integrations)
3. [Streaming Infrastructure](#3-streaming-infrastructure)
4. [CDN & Cloud Services](#4-cdn--cloud-services)
5. [Email & Notification Services](#5-email--notification-services)
6. [Authentication & Social Login](#6-authentication--social-login)
7. [Content Moderation & Compliance](#7-content-moderation--compliance)
8. [Analytics & Monitoring](#8-analytics--monitoring)
9. [Message Queues & Event Streaming](#9-message-queues--event-streaming)
10. [Video Processing](#10-video-processing)
11. [Device Pattern Systems](#11-device-pattern-systems)
12. [Environment Variable Reference](#12-environment-variable-reference)
13. [Webhook Endpoints](#13-webhook-endpoints)
14. [Migration Considerations](#14-migration-considerations)

---

## 1. Payment Processors

### 1.1 CCBill

Adult-industry specialized payment processor with high-risk merchant support.

| Attribute          | Details                                       |
| ------------------ | --------------------------------------------- |
| **Implementation** | `/eve/apps/payment-service/src/ccbill.ts`     |
| **API Base URL**   | Configurable (production/sandbox)             |
| **Authentication** | Account-based: `clientAccnum`, `clientSubacc` |

**API Operations:**

- Build purchase URLs with price, currency, userId
- Redirect users to CCBill checkout
- Process webhook callbacks

**Configuration:**

```typescript
interface CCBillConfig {
  apiUrl: string;
  clientAccnum: string;
  clientSubacc: string;
  webhookSecret: string;
}
```

**Webhook Handler:** `/api/payments/webhook/ccbill`

**Error Handling:**

- Throws errors on invalid responses
- Retry logic for transient failures
- Webhook signature validation

---

### 1.2 Epoch

Alternative adult-industry payment processor.

| Attribute          | Details                                  |
| ------------------ | ---------------------------------------- |
| **Implementation** | `/eve/apps/payment-service/src/epoch.ts` |
| **API Base URL**   | Configurable                             |
| **Authentication** | Client ID-based                          |

**API Operations:**

- Build checkout URLs with price, currency, userId
- Redirect-based payment flow
- Webhook processing

**Webhook Handler:** `/api/payments/webhook/epoch`

---

### 1.3 SegPay

Adult-industry payment processor with global coverage.

| Attribute          | Details                                   |
| ------------------ | ----------------------------------------- |
| **Implementation** | `/eve/apps/payment-service/src/segpay.ts` |
| **API Base URL**   | Configurable                              |
| **Authentication** | Vendor ID-based                           |

**API Operations:**

- Build checkout URLs with vendor ID, price, currency, userId
- Webhook callbacks for payment events

**Webhook Handler:** `/api/payments/webhook/segpay`

---

### 1.4 Stripe

General-purpose payment processor for non-adult transactions and subscriptions.

| Attribute          | Details                                                     |
| ------------------ | ----------------------------------------------------------- |
| **Implementation** | `/eve/apps/payment-service/src/`                            |
| **SDK**            | `@stripe/stripe-js`                                         |
| **Authentication** | API Key (Secret Key for server, Publishable Key for client) |

**Environment Variables:**

```bash
STRIPE_SECRET_KEY=sk_test_xxx
STRIPE_PUBLISHABLE_KEY=pk_test_xxx
STRIPE_WEBHOOK_SECRET=whsec_xxx
```

**Features:**

- Token purchases
- Subscription management
- Platform fee handling (Connect)
- Webhook integration for payment confirmations
- Retry logic for failed payments

---

### 1.5 In-App Purchases (Mobile)

Native platform payment integration for iOS and Android.

| Attribute          | Details                                          |
| ------------------ | ------------------------------------------------ |
| **Implementation** | `/eve/apps/mobile/src/services/inAppPurchase.ts` |
| **SDK**            | `react-native-iap`                               |
| **Platforms**      | iOS (App Store), Android (Google Play)           |

**Token Package SKUs:**

| SKU                   | Name    | Tokens |
| --------------------- | ------- | ------ |
| `com.eve.tokens.100`  | Starter | 100    |
| `com.eve.tokens.250`  | Basic   | 250    |
| `com.eve.tokens.550`  | Popular | 550    |
| `com.eve.tokens.1200` | Premium | 1200   |
| `com.eve.tokens.2750` | VIP     | 2750   |

**Subscription SKUs:**

- `com.eve.subscription.monthly`
- `com.eve.subscription.annual`

**Features:**

- Product fetching from stores
- Purchase initiation
- Subscription management
- Transaction completion
- Receipt validation
- Listener-based update handling

---

## 2. Interactive Device Integrations

### 2.1 Lovense

Industry-leading interactive toy manufacturer with comprehensive API.

| Attribute          | Details                                 |
| ------------------ | --------------------------------------- |
| **Implementation** | `/eve/apps/stream-service/src/lovense/` |
| **API Base URL**   | `https://api.lovense.com/api/lan/v2`    |
| **Authentication** | API Key + Token (24-hour expiration)    |

**Files:**

- `service.ts` - Main service implementation
- `types.ts` - Type definitions
- `patterns.ts` - Built-in vibration patterns
- `index.ts` - Public exports

**API Endpoints:**

- `/auth` - Authentication
- `/pair` - Device pairing
- Control endpoints for device commands

**Features:**

- Device authentication and pairing
- Vibration pattern control
- Battery monitoring
- Firmware version tracking
- Tip-to-vibration mapping

**Events Emitted:**

```typescript
'lovense.authenticated';
'lovense.device.paired';
'lovense.device.vibration.sent';
```

**Error Handling:**

- Comprehensive logging
- Automatic reconnection
- Token refresh mechanism

---

### 2.2 Buttplug.io

Open-source protocol supporting 200+ device types.

| Attribute          | Details                                    |
| ------------------ | ------------------------------------------ |
| **Implementation** | `/eve/apps/stream-service/src/buttplug/`   |
| **Connection**     | WebSocket (`ws://localhost:12345` default) |
| **Protocol**       | Buttplug Protocol v3                       |

**Files:**

- `service.ts` - Service implementation
- `types.ts` - Type definitions
- `utils.ts` - Device detection utilities
- `index.ts` - Public exports

**Features:**

- WebSocket server connection
- Device discovery and scanning
- Device lifecycle management
- Command execution
- Device capability detection
- User pairing

**Events Emitted:**

```typescript
'buttplug.connected';
'buttplug.disconnected';
'buttplug.scanning.started';
'buttplug.scanning.stopped';
'buttplug.device.discovered';
'buttplug.device.disconnected';
```

**Supported Device Categories:**

- Vibrators
- Strokers
- Oscillators
- Rotators
- Linear devices

---

### 2.3 The Handy

Male stroker device with advanced synchronization capabilities.

| Attribute          | Details                                     |
| ------------------ | ------------------------------------------- |
| **Implementation** | `/eve/apps/stream-service/src/handy/`       |
| **API Base URL**   | `https://www.handyfeeling.com/api/handy/v2` |
| **Authentication** | Connection Key (per-user, header-based)     |

**Files:**

- `service.ts` - Service implementation
- `types.ts` - Type definitions
- `patterns.ts` - Stroke patterns (CSV format)
- `index.ts` - Public exports

**API Endpoints:**

- `/connected` - Connection verification
- `/info` - Device information
- `/status` - Status (position, speed, temperature)
- `/stroke` - Stroke control
- `/speed` - Speed adjustment

**Authentication Header:** `X-Connection-Key`

**Features:**

- Device connection verification
- Device info retrieval
- Status monitoring (position, speed, temperature)
- Stroke pattern control
- Speed adjustment
- Mode management (HAMP, CVSR)
- Firmware version tracking
- Battery monitoring

**Events Emitted:**

```typescript
'handy.authenticated';
'handy.device.paired';
'handy.stroking.started';
'handy.stroking.stopped';
```

**Caching:**

- Connection keys
- Time offsets (for sync)
- Stroke zones

---

### 2.4 Kiiroo

Interactive toy manufacturer with FeelConnect platform.

| Attribute          | Details                                |
| ------------------ | -------------------------------------- |
| **Implementation** | `/eve/apps/stream-service/src/kiiroo/` |
| **Protocol**       | FeelConnect API                        |

**Files:**

- `service.ts` - Service implementation
- `types.ts` - Type definitions
- `patterns.ts` - Kiiroo-specific patterns
- `index.ts` - Public exports

**Features:**

- Device pairing
- Pattern execution
- Real-time feedback
- Touch feedback (bi-directional devices)

---

### 2.5 OhMiBod

Bluetooth-enabled interactive toys with music mode support.

| Attribute           | Details                                 |
| ------------------- | --------------------------------------- |
| **Implementation**  | `/eve/apps/stream-service/src/ohmibod/` |
| **Connection**      | Bluetooth Low Energy (BLE)              |
| **Device Tracking** | MAC address                             |

**Files:**

- `service.ts` - Service implementation
- `types.ts` - Type definitions
- `patterns.ts` - Vibration patterns and modes
- `index.ts` - Public exports

**Features:**

- Bluetooth device discovery
- Device pairing
- Music mode support (with sensitivity adjustment)
- Vibration pattern control
- Battery monitoring
- Device lifecycle management

**Events Emitted:**

```typescript
'ohmibod.device.connected';
'ohmibod.device.disconnected';
'ohmibod.vibration.sent';
'ohmibod.battery.updated';
```

---

## 3. Streaming Infrastructure

### 3.1 WebRTC / TURN / STUN

Real-time communication infrastructure for low-latency streaming.

| Attribute          | Details                         |
| ------------------ | ------------------------------- |
| **Implementation** | `/eve/apps/stream-service/src/` |
| **Files**          | `mediasoup.ts`, `signaling.ts`  |
| **Mobile**         | `coStreamWebRTCService.ts`      |

**Environment Variables:**

```bash
TURN_SERVER_URL=turn:turn.eve.example.com:3478
TURN_SERVER_USERNAME=turnuser
TURN_SERVER_CREDENTIAL=turnsecret
STUN_SERVER_URL=stun:stun.l.google.com:19302
```

**Features:**

- Peer connection establishment
- NAT traversal
- ICE candidate gathering
- SFU (Selective Forwarding Unit) via MediaSoup
- Co-streaming support

**MediaSoup Configuration:**

- Workers based on CPU cores
- Router with video/audio codecs
- WebRTC transport creation
- Producer/Consumer management

---

### 3.2 HLS / DASH Streaming

Adaptive bitrate streaming for broad device compatibility.

| Attribute          | Details                                            |
| ------------------ | -------------------------------------------------- |
| **Implementation** | `/eve/apps/stream-service/src/hls.ts`, `ll-hls.ts` |
| **Protocols**      | HLS, Low-Latency HLS (LL-HLS), DASH                |

**Features:**

- HTTP Live Streaming (HLS)
- Low-Latency HLS (LL-HLS) for sub-2s latency
- DASH manifest generation
- Segment management
- Multi-quality encoding

---

### 3.3 Media Server

Transcoding and processing server for video content.

| Attribute         | Details                 |
| ----------------- | ----------------------- |
| **Configuration** | `MEDIA_SERVER_URL`      |
| **Default**       | `http://localhost:8080` |

**Features:**

- Real-time transcoding
- Format conversion
- Thumbnail generation

---

## 4. CDN & Cloud Services

### 4.1 AWS CloudFront

Primary CDN for content delivery with signed URL support.

| Attribute          | Details                                                     |
| ------------------ | ----------------------------------------------------------- |
| **Implementation** | `/eve/infra/terraform/networking/cloudfront.tf`             |
| **Module**         | `/eve/infra/terraform/modules/cloudfront-api-cache/main.tf` |

**Features:**

- Origin Access Identities (OAI) for S3 access
- Signed URL generation for protected content
- Cache invalidation API
- Lambda@Edge integration
- Custom cache behaviors per content type

**Configuration:**

- Distribution policies
- Origin access control
- SSL/TLS certificates
- Geographic restrictions

---

### 4.2 AWS S3 / MinIO

Object storage for media files with presigned URL support.

| Attribute          | Details                                                 |
| ------------------ | ------------------------------------------------------- |
| **Implementation** | `/eve/apps/content-service/src/media-upload-service.ts` |
| **SDK**            | `@aws-sdk/client-s3`, `@aws-sdk/s3-request-presigner`   |

**Environment Variables:**

```bash
S3_BUCKET=eve-stream-recordings
S3_REGION=us-east-1
S3_ENDPOINT=http://localhost:9000  # MinIO for local dev
S3_ACCESS_KEY=accesskey
S3_SECRET_KEY=secretkey
```

**Features:**

- Presigned URLs for uploads/downloads
- Multipart uploads for large files
- Object metadata management
- Content-type validation

**Supported Content Types:**

- Images: JPEG, PNG, GIF, WebP
- Videos: MP4, WebM, QuickTime
- Audio: MPEG, WAV, OGG
- Documents: PDF, TXT

**Operations:**

- `PutObject` - Direct uploads
- `CreateMultipartUpload` - Large file initialization
- `UploadPart` - Chunk upload
- `CompleteMultipartUpload` - Finalize multipart

---

### 4.3 Cloudflare

DDoS protection and edge security.

| Attribute          | Details                                         |
| ------------------ | ----------------------------------------------- |
| **Implementation** | `/eve/infra/terraform/networking/cloudflare.tf` |
| **DDoS Config**    | `/eve/infra/terraform/networking/ddos.tf`       |

**Features:**

- DDoS protection (Layer 3-7)
- Web Application Firewall (WAF)
- DNS management
- SSL/TLS optimization
- Rate limiting
- Bot management

---

### 4.4 CDN Configuration (Generic)

General CDN configuration for signed URL delivery.

**Environment Variables:**

```bash
CDN_BASE_URL=https://cdn.eve.example.com
CDN_SIGNING_KEY=signingkeysecret
```

**Features:**

- Signed URL generation
- Cache control headers
- Edge caching strategy

---

## 5. Email & Notification Services

### 5.1 SendGrid

Primary email delivery service with analytics.

| Attribute          | Details                                                            |
| ------------------ | ------------------------------------------------------------------ |
| **Implementation** | `/eve/apps/notification-service/src/email-notification-service.ts` |
| **SDK**            | `@sendgrid/mail`                                                   |

**Environment Variables:**

```bash
SENDGRID_API_KEY=SG.xxx
```

**Features:**

- Email sending with templates
- Email analytics tracking (delivery, open, click, bounce, spam)
- Unsubscribe token generation and verification
- Notification template mapping
- Rate limiting per user

**Supported Email Notifications:**

- Follow notifications
- Tip notifications
- Show start/cancel notifications
- Ticket purchase notifications
- Stream reminders
- Promotion notifications

---

### 5.2 Firebase Cloud Messaging (FCM)

Push notifications for web and mobile platforms.

| Attribute          | Details                                                           |
| ------------------ | ----------------------------------------------------------------- |
| **Implementation** | `/eve/apps/notification-service/src/push-notification-service.ts` |
| **SDK**            | `firebase-admin`                                                  |

**Environment Variables:**

```bash
FCM_PROJECT_ID=eve-project
FCM_SERVICE_ACCOUNT_PATH=/path/to/service-account.json
FCM_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n..."
FCM_CLIENT_EMAIL=firebase-adminsdk@eve-project.iam.gserviceaccount.com
```

**Features:**

- Push notification subscriptions (Web, iOS, Android)
- Token management
- Multicast messaging
- Notification formatting
- Payload customization
- Platform-specific handling

**Subscription Tracking:**

- User tokens stored with platform info
- Automatic token refresh
- Invalid token cleanup

---

### 5.3 Apple Push Notification Service (APNs)

Native iOS push notifications.

| Attribute | Details                |
| --------- | ---------------------- |
| **SDK**   | `apn` or direct HTTP/2 |

**Environment Variables:**

```bash
APNS_KEY_ID=keyid
APNS_TEAM_ID=teamid
APNS_AUTH_KEY_PATH=/path/to/AuthKey.p8
APNS_ENVIRONMENT=development  # or production
```

---

### 5.4 Twilio (SMS)

SMS notifications for critical alerts.

**Environment Variables:**

```bash
TWILIO_ACCOUNT_SID=ACxxx
TWILIO_AUTH_TOKEN=authtoken
TWILIO_FROM_NUMBER=+1234567890
```

**Features:**

- SMS delivery for critical notifications
- Two-factor authentication codes
- Account verification

---

## 6. Authentication & Social Login

### 6.1 OAuth 2.0 Integration

Social login providers for simplified registration.

| Attribute          | Details                               |
| ------------------ | ------------------------------------- |
| **Implementation** | `/eve/apps/user-service/src/oauth.ts` |

**Supported Providers:**

| Provider | Protocol   | Callback URL              |
| -------- | ---------- | ------------------------- |
| Google   | OAuth 2.0  | `/oauth/google/callback`  |
| Twitter  | OAuth 1.0a | `/oauth/twitter/callback` |

**Features:**

- Provider-specific callbacks
- User linking to existing accounts
- Token generation (access + refresh)
- Session creation
- Refresh token hashing and storage

**Token Configuration:**

```typescript
{
  accessToken: {
    expiration: '15m',
    algorithm: 'RS256'
  },
  refreshToken: {
    expiration: '7d',
    algorithm: 'RS256'
  }
}
```

---

## 7. Content Moderation & Compliance

### 7.1 Hive AI

AI-powered content classification and moderation.

| Attribute          | Details                             |
| ------------------ | ----------------------------------- |
| **Implementation** | `/eve/apps/moderation-service/src/` |
| **API Base URL**   | `https://api.thehive.ai/api/v2`     |
| **Authentication** | API Key                             |

**Environment Variables:**

```bash
HIVE_API_KEY=hiveapikey
HIVE_BASE_URL=https://api.thehive.ai/api/v2
```

**Features:**

- Content classification
- Text moderation
- Image/video analysis
- Confidence scoring

**Threshold Configuration:**

```bash
AUTO_REJECT_THRESHOLD=0.95
AUTO_APPROVE_THRESHOLD=0.1
```

---

### 7.2 Thorn Safer (CSAM Detection)

**CRITICAL: Legally required for CSAM detection.**

| Attribute          | Details                |
| ------------------ | ---------------------- |
| **API Base URL**   | `https://api.safer.io` |
| **Authentication** | API Key                |

**Environment Variables:**

```bash
THORN_API_KEY=thornkey
THORN_BASE_URL=https://api.safer.io
```

**Purpose:** Child Sexual Abuse Material (CSAM) detection - legally mandated.

---

### 7.3 PhotoDNA (Microsoft)

Alternative CSAM detection system for redundancy.

**Environment Variables:**

```bash
PHOTODNA_SUBSCRIPTION_KEY=subscriptionkey
PHOTODNA_ENDPOINT=https://api.microsoftmoderator.com
```

---

### 7.4 AWS Rekognition

AWS-based content moderation and image/video analysis.

**Environment Variables:**

```bash
AWS_REKOGNITION_REGION=us-east-1
AWS_ACCESS_KEY_ID=accesskey
AWS_SECRET_ACCESS_KEY=secretkey
```

**Features:**

- Content moderation labels
- Unsafe content detection
- Face detection/comparison

---

### 7.5 NCMEC Reporting

**CRITICAL: Legally required reporting in the United States.**

| Attribute        | Details                                          |
| ---------------- | ------------------------------------------------ |
| **Organization** | National Center for Missing & Exploited Children |
| **Purpose**      | Mandatory incident reporting                     |

**Environment Variables:**

```bash
NCMEC_REPORTING_ENABLED=true
NCMEC_ESP_ID=espidentifier
NCMEC_API_KEY=ncmeckey
```

---

### 7.6 Human Moderation Configuration

**Environment Variables:**

```bash
MODERATOR_HOURLY_LIMIT=50
REQUIRE_DOUBLE_CHECK=true
```

---

## 8. Analytics & Monitoring

### 8.1 Analytics Services

Internal analytics pipeline for creator and viewer metrics.

| Attribute          | Details                            |
| ------------------ | ---------------------------------- |
| **Implementation** | `/eve/apps/analytics-service/src/` |

**Features:**

- Real-time analytics ingestion
- Creator dashboard metrics
- Viewer analytics
- Earnings tracking
- Performance metrics
- Retention analysis

---

### 8.2 Sentry (Error Tracking)

Crash reporting and error monitoring.

**Environment Variables:**

```bash
SENTRY_DSN=https://xxx@sentry.io/xxx
```

---

### 8.3 Prometheus / Grafana

Metrics collection and visualization.

| Attribute          | Details                      |
| ------------------ | ---------------------------- |
| **Implementation** | Infrastructure configuration |

**Features:**

- Metrics collection
- Service monitoring
- Dashboard visualization
- Alerting

---

## 9. Message Queues & Event Streaming

### 9.1 Apache Kafka

Event streaming for high-throughput messaging.

**Environment Variables:**

```bash
KAFKA_CLIENT_ID=eve-service
KAFKA_BROKERS=localhost:9092
```

**Use Cases:**

- Stream events (start, end, tip)
- Viewer join/leave events
- Payment events
- Analytics events

---

### 9.2 Redis (Pub/Sub & Caching)

Real-time messaging and caching layer.

**Environment Variables:**

```bash
REDIS_URL=redis://localhost:6379
```

**Use Cases:**

- Real-time viewer counts
- Session management
- Payment state caching
- Moderation queue
- Rate limiting
- Pub/sub for real-time updates

---

## 10. Video Processing

### 10.1 FFmpeg

Video transcoding and processing pipeline.

| Attribute          | Details                                                     |
| ------------------ | ----------------------------------------------------------- |
| **Implementation** | `/eve/apps/content-service/src/video-processing-service.ts` |
| **Tool**           | FFmpeg CLI                                                  |

**Features:**

- Multi-quality transcoding
- HLS/DASH manifest generation
- Thumbnail extraction
- Video preview generation
- DRM encryption support
- Metadata extraction

**Quality Presets:**

| Quality | Resolution | Video Bitrate | Audio Bitrate |
| ------- | ---------- | ------------- | ------------- |
| 360p    | 640x360    | 800k          | 96k           |
| 480p    | 854x480    | 1.4M          | 128k          |
| 720p    | 1280x720   | 2.8M          | 128k          |
| 1080p   | 1920x1080  | 5M            | 192k          |
| 1440p   | 2560x1440  | 9M            | 192k          |
| 2160p   | 3840x2160  | 16M           | 256k          |

---

## 11. Device Pattern Systems

### 11.1 Funscript Format Support

Standard format for interactive device scripts.

| Attribute          | Details                                             |
| ------------------ | --------------------------------------------------- |
| **Implementation** | `/eve/apps/stream-service/src/funscript-service.ts` |

**Supported Devices:**

- Lovense
- Handy
- Buttplug.io compatible devices

**Features:**

- Script parsing
- Timeline synchronization
- Position interpolation

---

### 11.2 Vibration Pattern System

**Pattern Types:**

- Built-in patterns (seeded on service initialization)
- Custom user patterns
- Tip-mapped patterns (tip amount to intensity)

**Storage:**

- Device-specific repositories in database
- User custom patterns
- Creator-defined mappings

---

## 12. Environment Variable Reference

### Payment Processors

```bash
# Stripe
STRIPE_SECRET_KEY=sk_xxx
STRIPE_PUBLISHABLE_KEY=pk_xxx
STRIPE_WEBHOOK_SECRET=whsec_xxx

# CCBill
CCBILL_CLIENT_ACCNUM=xxx
CCBILL_CLIENT_SUBACC=xxx
CCBILL_WEBHOOK_SECRET=xxx

# Epoch
EPOCH_CLIENT_ID=xxx
EPOCH_WEBHOOK_SECRET=xxx

# SegPay
SEGPAY_VENDOR_ID=xxx
SEGPAY_WEBHOOK_SECRET=xxx
```

### Email & Notifications

```bash
SENDGRID_API_KEY=SG.xxx

FCM_PROJECT_ID=xxx
FCM_PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n..."
FCM_CLIENT_EMAIL=xxx@xxx.iam.gserviceaccount.com

APNS_KEY_ID=xxx
APNS_TEAM_ID=xxx
APNS_AUTH_KEY_PATH=/path/to/AuthKey.p8
APNS_ENVIRONMENT=development

TWILIO_ACCOUNT_SID=ACxxx
TWILIO_AUTH_TOKEN=xxx
TWILIO_FROM_NUMBER=+1234567890
```

### Storage

```bash
S3_BUCKET=eve-content
S3_REGION=us-east-1
S3_ENDPOINT=http://localhost:9000
S3_ACCESS_KEY=xxx
S3_SECRET_KEY=xxx
```

### CDN

```bash
CDN_BASE_URL=https://cdn.eve.example.com
CDN_SIGNING_KEY=xxx
```

### WebRTC

```bash
TURN_SERVER_URL=turn:turn.eve.example.com:3478
TURN_SERVER_USERNAME=xxx
TURN_SERVER_CREDENTIAL=xxx
STUN_SERVER_URL=stun:stun.l.google.com:19302
```

### Moderation

```bash
HIVE_API_KEY=xxx
HIVE_BASE_URL=https://api.thehive.ai/api/v2
THORN_API_KEY=xxx
THORN_BASE_URL=https://api.safer.io
PHOTODNA_SUBSCRIPTION_KEY=xxx
PHOTODNA_ENDPOINT=https://api.microsoftmoderator.com
AWS_REKOGNITION_REGION=us-east-1
NCMEC_REPORTING_ENABLED=true
NCMEC_ESP_ID=xxx
NCMEC_API_KEY=xxx
```

### Message Queues

```bash
KAFKA_CLIENT_ID=eve-service
KAFKA_BROKERS=localhost:9092
REDIS_URL=redis://localhost:6379
```

### Databases

```bash
DATABASE_URL=postgresql://user:pass@localhost:5432/eve
MONGODB_URI=mongodb://localhost:27017/eve
```

### Infrastructure

```bash
VAULT_ADDR=http://localhost:8200
VAULT_TOKEN=xxx
MEDIA_SERVER_URL=http://localhost:8080
```

---

## 13. Webhook Endpoints

### Payment Webhooks

**Base Path:** `/api/payments/webhook/:provider`

| Provider | Endpoint                       | Purpose                            |
| -------- | ------------------------------ | ---------------------------------- |
| CCBill   | `/api/payments/webhook/ccbill` | Payment confirmations, chargebacks |
| Epoch    | `/api/payments/webhook/epoch`  | Payment confirmations, refunds     |
| SegPay   | `/api/payments/webhook/segpay` | Payment confirmations              |
| Stripe   | `/api/payments/webhook/stripe` | Payment intents, subscriptions     |

### Webhook Security

- Signature validation for all providers
- IP allowlisting where supported
- Replay attack prevention via timestamps
- Idempotency key handling

---

## 14. Migration Considerations

### 14.1 Provider Abstraction Strategy

Create unified interfaces for each integration category:

```typescript
// Payment provider interface
interface PaymentProvider {
  name: string;
  createCheckoutUrl(params: CheckoutParams): Promise<string>;
  handleWebhook(payload: unknown, signature: string): Promise<WebhookResult>;
  validatePayment(transactionId: string): Promise<PaymentStatus>;
}

// Device provider interface
interface DeviceProvider {
  name: string;
  connect(userId: string, deviceId: string): Promise<DeviceConnection>;
  sendCommand(command: DeviceCommand): Promise<void>;
  getStatus(deviceId: string): Promise<DeviceStatus>;
}
```

### 14.2 Configuration Migration

Move all provider configurations to Oshun's centralized config system:

1. Use `@oshun/config` for environment-based configuration
2. Store secrets in HashiCorp Vault
3. Implement provider feature flags for gradual rollout

### 14.3 SDK Version Updates

Audit and update SDK versions during migration:

| SDK                 | Current      | Recommended   |
| ------------------- | ------------ | ------------- |
| `@stripe/stripe-js` | Audit needed | Latest stable |
| `@sendgrid/mail`    | Audit needed | Latest stable |
| `firebase-admin`    | Audit needed | Latest stable |
| `@aws-sdk/*`        | v3           | Latest v3.x   |

### 14.4 Compliance Requirements

**Critical integrations that must be maintained:**

1. **CSAM Detection** (Thorn Safer, PhotoDNA) - Legally required
2. **NCMEC Reporting** - Legally required in US
3. **Payment Processor Compliance** - PCI-DSS requirements

### 14.5 Testing Strategy

1. Create mock implementations for all external APIs
2. Use sandbox/test environments during development
3. Implement contract testing for API compatibility
4. Load test payment and device integrations

### 14.6 Monitoring Requirements

Ensure monitoring for:

- API latency and error rates
- Payment success/failure rates
- Device connection success rates
- Content moderation pipeline throughput
- Webhook delivery success rates

---

## Summary Statistics

| Category            | Count | Providers                                       |
| ------------------- | ----- | ----------------------------------------------- |
| Payment Processors  | 5     | CCBill, Epoch, SegPay, Stripe, IAP              |
| Interactive Devices | 5     | Lovense, Buttplug.io, Handy, Kiiroo, OhMiBod    |
| Streaming           | 3     | WebRTC/TURN/STUN, HLS/DASH, Media Server        |
| CDN/Cloud           | 3     | CloudFront, S3, Cloudflare                      |
| Email/Notifications | 4     | SendGrid, FCM, APNs, Twilio                     |
| Auth Providers      | 2     | Google OAuth, Twitter OAuth                     |
| Content Moderation  | 4     | Hive AI, Thorn Safer, PhotoDNA, AWS Rekognition |
| Compliance          | 1     | NCMEC                                           |
| Message Queues      | 2     | Kafka, Redis                                    |

**Total External Integrations: 29+**
