# CUBE License API (as implemented by license/api.php)

Single endpoint, built into the plugin: `POST https://cube.myfix.vip/license/api.php`, JSON body:

```json
{
  "action": "activate | validate | deactivate",
  "license_key": "ABCD-EFGH-JKLM-NPQR-STUV",
  "block": "shopee-woocommerce",
  "instance_id": "uuid of the WordPress installation",
  "site_url": "https://customer-shop.com",
  "plugin_version": "2.4.0",
  "nonce": "32 random hex characters"
}
```

Every response (success or failure) is JSON, echoes `block`, `instance_id`, `nonce` and the normalised
`domain`, and is signed: header `X-Cube-Signature: base64(ed25519_sign(raw_body, server_secret_key))`.
The plugin rejects unsigned, altered or replayed (wrong nonce) responses.

Success:

```json
{ "success": true, "status": "active", "license_id": "CUBE-000042", "type": "lifetime",
  "activated_at": "2026-11-24T10:00:00+00:00", "expires_at": null, "validity_days": 0,
  "max_sites": 1, "domain": "customer-shop.com", "message": "License activated." }
```

Failure statuses: `invalid`, `block_mismatch`, `revoked`, `expired`, `domain_mismatch`,
`already_activated` (site limit reached), `inactive` (validate on a site that is not/no longer activated),
`rate_limited`.

## Rules

* Keys are stored only as HMAC-SHA256 fingerprints (secret in config.php); shown once at generation.
* Activation binds the key to the site's domain (`www.` ignored). Re-activating on the same domain is allowed.
* `max_sites` (default 1; 0 = unlimited) limits active domains. Admin can release a domain or raise the limit.
* Optional `allowed_domain` locks a key to one domain before first use.
* Revoked keys fail `validate`; the plugin disables itself at its next check (daily, and every 12 h on CUBE screens).
* If the server is unreachable the plugin keeps working for a 3-day grace period.
* Rate limits: 120 requests / 10 min per IP; 20 unknown-key attempts / hour per IP.
