create-ilorb 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE-API.md DELETED
@@ -1,108 +0,0 @@
1
- # LICENSE-API — license server contract (v1)
2
-
3
- What `create-overture` expects from the store's license API (operasourcecode.com). **The store does not exist yet**: this
4
- contract is implemented by the FAKE server `tools/fake-license-server.mjs` (tests, end-to-end and demo) and is what the
5
- real Worker must fulfil. House standard: Worker + D1 on the CONNECTING account, errors in the Core format
6
- (`{ "error": { "code": "snake_case", "message": "…" } }`).
7
-
8
- Base: `https://api.operasourcecode.com` (in the CLI: `--license-server` / `OVERTURE_LICENSE_SERVER`).
9
-
10
- ## Keys (Ed25519)
11
-
12
- - The store has one Ed25519 pair per period (`kid`, e.g. `osc-2026-11`). The **private** key lives only in the Worker (secret).
13
- The **public** key (32 bytes, base64) is embedded in the CLI at `src/license/keys.ts` → `LICENSE_KEYS`.
14
- - Rotating keys: ship a CLI with the new public key **before** issuing with it; the old ones stay in the list
15
- as long as there are valid licenses signed with them.
16
- - Today only the **test** key `test-2026-10` exists (private key in `test/fixtures/license-test-key.pem`, on purpose):
17
- the CLI only accepts a license signed by it when the license server is `localhost`. It unlocks nothing real —
18
- the server delivers the templates, and the real server does not accept the test `kid`.
19
-
20
- ## License key (what the buyer receives by e-mail)
21
-
22
- ```
23
- osc1.<payload em base64url>.<assinatura Ed25519 em base64url>
24
- assinatura = Ed25519(privada[kid], "osc1.<payload em base64url>")
25
- ```
26
- payload (JSON):
27
- ```json
28
- { "v": 1, "kid": "osc-2026-11", "lid": "lic_01J…", "products": ["chat"], "email": "comprador@empresa.com",
29
- "type": "regular", "iat": 1792700000, "exp": null }
30
- ```
31
- | field | meaning |
32
- |---|---|
33
- | `lid` | license id in the store |
34
- | `products` | ids of the unlocked products (`chat`, `consultas`…) or `["*"]` for a bundle |
35
- | `type` | `regular` or `extended` (what each allows: the owner decides; the CLI only displays it) |
36
- | `exp` | unix seconds or `null` (never expires). Support/updates have their own date at activation |
37
-
38
- The CLI checks **offline** (signature, known `kid`, `exp`, product) before calling the API. An Envato purchase code
39
- (`xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`) cannot be verified offline: only its format.
40
-
41
- ## `POST /v1/licenses/activate`
42
-
43
- Request:
44
- ```json
45
- {
46
- "credential": { "type": "license", "key": "osc1.…" },
47
- "product": "chat",
48
- "installId": "0b9c…-uuid",
49
- "machine": "sha256(hostname|usuário) truncado em 32 hex — sem dado pessoal",
50
- "cliVersion": "0.1.0",
51
- "target": "cloud"
52
- }
53
- ```
54
- or, via Envato: `"credential": { "type": "envato", "purchaseCode": "a1b2c3d4-…" }`.
55
-
56
- The server:
57
- 1. **Own license:** checks the signature with the private key of the `kid`, `exp`, revocation and the product.
58
- 2. **Envato:** calls `GET https://api.envato.com/v3/market/author/sale?code=<purchase code>` with the author's personal
59
- token (Worker secret), checks the item (Envato item id ↔ product), refund and the buyer. Stores the
60
- result (cache) so it does not hit Envato on every installation.
61
- 3. **Idempotent activation:** the same (`license` or `purchase code`) + the same `installId` returns **the same activation**
62
- (does not use another slot). A new installation counts as 1 up to the limit of the license type.
63
- 4. Generates the templates link (signed, expires in minutes) and the signed **receipt**.
64
-
65
- Response `200`:
66
- ```json
67
- {
68
- "activation": {
69
- "id": "act_…", "licenseId": "lic_…", "product": "chat", "type": "regular", "source": "opera",
70
- "buyerEmail": "comprador@empresa.com", "supportUntil": "2027-10-23T00:00:00.000Z",
71
- "activationsUsed": 1, "activationsLimit": 3, "activatedAt": "2026-10-23T12:00:00.000Z"
72
- },
73
- "receipt": "oscr1.<payload>.<assinatura>",
74
- "templates": { "version": "0.1.0", "url": "https://…/v1/templates/chat-0.1.0.tgz?…", "sha256": "<64 hex>", "size": 739790 }
75
- }
76
- ```
77
- Receipt (`oscr1`, same Ed25519 key): `{ "v": 1, "kid", "aid": "<activation.id>", "lid", "product", "installId", "iat" }`.
78
- The CLI rejects it (`license_receipt_invalid`) if the signature does not match or if `aid`/`installId`/`product` do not
79
- match the request — an arbitrary server cannot "activate" in place of the store, and a receipt cannot be used for another installation.
80
-
81
- Errors (the CLI translates each code to pt/es/en with what to do):
82
-
83
- | status | `error.code` | when |
84
- |---|---|---|
85
- | 400 | `invalid_request` | missing field |
86
- | 400 | `license_malformed` / `purchase_code_malformed` | format |
87
- | 401 | `license_bad_signature` | signature does not match |
88
- | 403 | `license_revoked` | canceled (refund, abuse) |
89
- | 403 / 404 | `license_wrong_product` | license for another product / nonexistent product |
90
- | 409 | `license_activation_limit` | installation limit |
91
- | 410 | `license_expired` | expired |
92
- | 404 | `purchase_code_invalid` | Envato does not know it |
93
- | 422 | `purchase_code_wrong_item` | belongs to another item |
94
- | 403 | `purchase_code_refunded` | purchase refunded |
95
- | 503 | `envato_unavailable` | Envato did not respond |
96
- | 429 | `rate_limited` (+ `retryAfter` in seconds) | too many attempts |
97
- | 5xx | anything else | the CLI shows `license_server_error` |
98
-
99
- ## `GET /v1/templates/<product>-<version>.tgz?…`
100
-
101
- The link that came with the activation (signed, short-lived). Returns the `.tar.gz` with the product folders **in the same
102
- structure as the repository** (`overture-core/…`, `overture-chat/…`, `vendor/opera-signal-<commit>/…`) — without `node_modules`, `dist`,
103
- `.wrangler`, `.dev.vars`, screenshots, and **without `vendor/…/apps/chat/wrangler.jsonc`** (Opera's production config). The CLI
104
- checks the `sha256` before opening it and deletes the file after copying.
105
-
106
- ## Not yet used by the CLI (suggestion for v2)
107
- - `POST /v1/licenses/deactivate { activationId, receipt }` — frees the slot (the store panel should also have the button).
108
- - `GET /v1/products/<id>/latest` — newest version of the templates, for a future `create-overture update`.