# Phase 12 — Licensing & Deployment Protection Checklist

## Scope

Phase 12 adds commercial software licensing without changing hotel transactional data or core ordering flows.

### Included

- Ed25519 signed offline license verification using PHP sodium
- unique installation UUID and server fingerprint
- approved-domain binding
- licensed hotel-code binding
- expiration and configurable grace period
- feature/module entitlements
- deployment limits for hotels, physical restaurants, rooms and KDS devices
- global license middleware
- safe license-required lock state; customer data is never deleted
- `/admin/license` management screen
- activation request JSON endpoint and CLI command
- signed-license web and CLI installation
- validation history and feature-usage counters
- license audit events
- production readiness checks for sodium/public key
- separate vendor-only license issuer toolkit

## Production setup

1. Generate a vendor Ed25519 key pair with the separate vendor tool.
2. Store the private key offline. Never upload it to a customer server.
3. Put only the public key in the customer `.env`:

```env
LICENSE_PUBLIC_KEY_BASE64=<32-byte-Ed25519-public-key-as-base64>
```

4. Import/migrate the Phase 12 database.
5. Run the normal secure seed.
6. Generate an activation request:

```bash
php bin/license-request.php activation-request.json
```

or sign in and open `/admin/license` → **Activation request JSON**.
7. Issue the signed license using the vendor tool.
8. Install the returned JSON:

```bash
php bin/license-install.php /path/to/license.json
```

or upload it at `/admin/license`.
9. Confirm:

```bash
php bin/license-status.php
php bin/check.php
php bin/security-audit.php
php bin/test.php
```

## Expected behavior

- ACTIVE: all licensed modules operate normally.
- GRACE: application operates but admins see an expiry warning.
- EXPIRED/INVALID/MISSING/BINDING MISMATCH/LIMIT EXCEEDED: operational routes lock; `/admin/login`, `/admin/license`, `/healthz` and diagnostics remain available.
- missing module entitlement: only that module is blocked.
- license removal never deletes orders, bills, reservations, guests, reports or configuration.

## Copy protection boundary

The license binds to installation ID + server fingerprint + domain + hotel code(s). Copying the application/database to a different server/domain normally invalidates the license.

Readable PHP source can still be modified by a technically capable customer. For stronger commercial enforcement, encode the licensing/core commercial modules with a compatible PHP encoder after acceptance testing. Never distribute the vendor private signing key.
