@poli-page/cli 0.10.0 → 0.11.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.
Files changed (132) hide show
  1. package/README.md +103 -37
  2. package/dist/api-client.d.ts +20 -0
  3. package/dist/api-client.d.ts.map +1 -1
  4. package/dist/api-client.js +55 -9
  5. package/dist/api-client.js.map +1 -1
  6. package/dist/api-origin.d.ts +28 -0
  7. package/dist/api-origin.d.ts.map +1 -0
  8. package/dist/api-origin.js +84 -0
  9. package/dist/api-origin.js.map +1 -0
  10. package/dist/auth.d.ts +4 -0
  11. package/dist/auth.d.ts.map +1 -1
  12. package/dist/auth.js +19 -13
  13. package/dist/auth.js.map +1 -1
  14. package/dist/cloud-context.d.ts +8 -0
  15. package/dist/cloud-context.d.ts.map +1 -1
  16. package/dist/cloud-context.js +14 -9
  17. package/dist/cloud-context.js.map +1 -1
  18. package/dist/cloud-link.d.ts +41 -0
  19. package/dist/cloud-link.d.ts.map +1 -0
  20. package/dist/cloud-link.js +112 -0
  21. package/dist/cloud-link.js.map +1 -0
  22. package/dist/commands/auth.d.ts +31 -8
  23. package/dist/commands/auth.d.ts.map +1 -1
  24. package/dist/commands/auth.js +72 -23
  25. package/dist/commands/auth.js.map +1 -1
  26. package/dist/commands/dev.d.ts +3 -0
  27. package/dist/commands/dev.d.ts.map +1 -1
  28. package/dist/commands/dev.js +33 -22
  29. package/dist/commands/dev.js.map +1 -1
  30. package/dist/commands/documents/delete.d.ts.map +1 -1
  31. package/dist/commands/documents/delete.js +2 -9
  32. package/dist/commands/documents/delete.js.map +1 -1
  33. package/dist/commands/documents/document-id.d.ts +2 -0
  34. package/dist/commands/documents/document-id.d.ts.map +1 -0
  35. package/dist/commands/documents/document-id.js +10 -0
  36. package/dist/commands/documents/document-id.js.map +1 -0
  37. package/dist/commands/documents/get.d.ts.map +1 -1
  38. package/dist/commands/documents/get.js +2 -9
  39. package/dist/commands/documents/get.js.map +1 -1
  40. package/dist/commands/documents/preview.d.ts +1 -0
  41. package/dist/commands/documents/preview.d.ts.map +1 -1
  42. package/dist/commands/documents/preview.js +89 -14
  43. package/dist/commands/documents/preview.js.map +1 -1
  44. package/dist/commands/documents/thumbnails.d.ts.map +1 -1
  45. package/dist/commands/documents/thumbnails.js +35 -20
  46. package/dist/commands/documents/thumbnails.js.map +1 -1
  47. package/dist/commands/env.d.ts.map +1 -1
  48. package/dist/commands/env.js +4 -19
  49. package/dist/commands/env.js.map +1 -1
  50. package/dist/commands/init.d.ts.map +1 -1
  51. package/dist/commands/init.js +33 -26
  52. package/dist/commands/init.js.map +1 -1
  53. package/dist/commands/link.d.ts +6 -0
  54. package/dist/commands/link.d.ts.map +1 -1
  55. package/dist/commands/link.js +66 -14
  56. package/dist/commands/link.js.map +1 -1
  57. package/dist/commands/new.d.ts.map +1 -1
  58. package/dist/commands/new.js +13 -6
  59. package/dist/commands/new.js.map +1 -1
  60. package/dist/commands/publish.d.ts +6 -1
  61. package/dist/commands/publish.d.ts.map +1 -1
  62. package/dist/commands/publish.js +31 -15
  63. package/dist/commands/publish.js.map +1 -1
  64. package/dist/commands/render.d.ts.map +1 -1
  65. package/dist/commands/render.js +23 -12
  66. package/dist/commands/render.js.map +1 -1
  67. package/dist/commands/watch.d.ts +3 -0
  68. package/dist/commands/watch.d.ts.map +1 -1
  69. package/dist/commands/watch.js +7 -1
  70. package/dist/commands/watch.js.map +1 -1
  71. package/dist/constants.d.ts +1 -0
  72. package/dist/constants.d.ts.map +1 -1
  73. package/dist/constants.js +1 -0
  74. package/dist/constants.js.map +1 -1
  75. package/dist/credentials.d.ts +10 -0
  76. package/dist/credentials.d.ts.map +1 -1
  77. package/dist/credentials.js +27 -15
  78. package/dist/credentials.js.map +1 -1
  79. package/dist/dev-page.d.ts +7 -0
  80. package/dist/dev-page.d.ts.map +1 -1
  81. package/dist/dev-page.js +18 -0
  82. package/dist/dev-page.js.map +1 -1
  83. package/dist/dev-server.d.ts +19 -0
  84. package/dist/dev-server.d.ts.map +1 -1
  85. package/dist/dev-server.js +70 -8
  86. package/dist/dev-server.js.map +1 -1
  87. package/dist/exit-codes.d.ts.map +1 -1
  88. package/dist/exit-codes.js +13 -6
  89. package/dist/exit-codes.js.map +1 -1
  90. package/dist/file-watcher.d.ts +4 -1
  91. package/dist/file-watcher.d.ts.map +1 -1
  92. package/dist/file-watcher.js +26 -11
  93. package/dist/file-watcher.js.map +1 -1
  94. package/dist/format-resolver.d.ts +6 -0
  95. package/dist/format-resolver.d.ts.map +1 -1
  96. package/dist/format-resolver.js +14 -6
  97. package/dist/format-resolver.js.map +1 -1
  98. package/dist/manifest.d.ts +8 -0
  99. package/dist/manifest.d.ts.map +1 -1
  100. package/dist/manifest.js +37 -7
  101. package/dist/manifest.js.map +1 -1
  102. package/dist/manifest.schema.d.ts +4 -2
  103. package/dist/manifest.schema.d.ts.map +1 -1
  104. package/dist/manifest.schema.js +40 -7
  105. package/dist/manifest.schema.js.map +1 -1
  106. package/dist/output.d.ts +5 -0
  107. package/dist/output.d.ts.map +1 -1
  108. package/dist/output.js +7 -0
  109. package/dist/output.js.map +1 -1
  110. package/dist/program.d.ts.map +1 -1
  111. package/dist/program.js +49 -19
  112. package/dist/program.js.map +1 -1
  113. package/dist/project-files.d.ts +19 -0
  114. package/dist/project-files.d.ts.map +1 -1
  115. package/dist/project-files.js +24 -6
  116. package/dist/project-files.js.map +1 -1
  117. package/dist/project-loader.d.ts +6 -3
  118. package/dist/project-loader.d.ts.map +1 -1
  119. package/dist/project-loader.js +36 -61
  120. package/dist/project-loader.js.map +1 -1
  121. package/dist/project-sync.d.ts +35 -2
  122. package/dist/project-sync.d.ts.map +1 -1
  123. package/dist/project-sync.js +171 -39
  124. package/dist/project-sync.js.map +1 -1
  125. package/dist/security/paths.d.ts +29 -0
  126. package/dist/security/paths.d.ts.map +1 -0
  127. package/dist/security/paths.js +109 -0
  128. package/dist/security/paths.js.map +1 -0
  129. package/dist/template-importer.d.ts.map +1 -1
  130. package/dist/template-importer.js +170 -59
  131. package/dist/template-importer.js.map +1 -1
  132. package/package.json +1 -1
package/README.md CHANGED
@@ -98,10 +98,10 @@ The CLI supports two authentication modes. Both flow through the same internal r
98
98
  ```bash
99
99
  poli login # device authorization flow — opens your browser
100
100
  poli whoami # show the current session and active org
101
- poli logout # clear ~/.polipage/credentials.json
101
+ poli logout # delete ~/.polipage/credentials, then revoke the session
102
102
  ```
103
103
 
104
- After `poli login`, the session token is stored at `~/.polipage/credentials.json` and used automatically by every subsequent command.
104
+ After `poli login`, the session token is stored at `~/.polipage/credentials` and used by every command that needs it (while `POLI_PAGE_API_KEY` is set, the commands that accept a key use the key instead: see [Precedence](#precedence)).
105
105
 
106
106
  ### Programmatic (CI / CD / scripts)
107
107
 
@@ -113,7 +113,7 @@ Set the `POLI_PAGE_API_KEY` environment variable. Every key is bound to one envi
113
113
  | `pp_live_…` | `name@live` — counted in the monthly quota |
114
114
  | `pp_<environment>_…` | `name@<environment>` — counted in the monthly quota |
115
115
 
116
- A key renders only its own environment, and never the draft: the draft (`poli render name`) needs `poli login`.
116
+ A key renders only its own environment, and never the draft: the draft (`poli render name`) needs `poli login`, with `POLI_PAGE_API_KEY` unset (see [Precedence](#precedence)).
117
117
 
118
118
  ```bash
119
119
  export POLI_PAGE_API_KEY=pp_live_xxx
@@ -130,9 +130,7 @@ The other workspace commands (`link`, `watch`, `dev`) need `poli login`.
130
130
 
131
131
  ### Precedence
132
132
 
133
- When **both** `~/.polipage/credentials.json` (a session) and `POLI_PAGE_API_KEY` are set, **the session wins**. `poli login` does not refuse if the env var is set — it shows an info-message and proceeds, after which the new session takes precedence.
134
-
135
- This means a developer can keep `POLI_PAGE_API_KEY` set in `.zshrc` for occasional CI-style commands without it interfering with their interactive workflow.
133
+ When **both** `~/.polipage/credentials` (a session) and `POLI_PAGE_API_KEY` are set, **the key wins** for every command that accepts either credential (`whoami`, `publish`, `render`, `documents`): a set key is an explicit choice, so exporting a `pp_sandbox_…` key makes those commands act as that key, not as your full session. The session-only commands (`link`, `watch`, `dev`, `env`) keep using your session. While the key wins, what it cannot do is refused even though a session is stored: `poli render <name>` (the draft), `poli render <name>@<environment>` for another environment than the key's, `poli publish` with a standard key, with an `--env` other than the key's or with a key of another organization than the linked one, and any of those commands with a malformed key fail, and their error says to unset `POLI_PAGE_API_KEY` to use the session. In a terminal, `poli whoami` says when the key is used instead of a stored session (its JSON is the `GET /v1/me` response, unchanged), and `poli publish` prints which credential it used (`Auth:` in its summary, `credential` in its JSON). `poli login` does not refuse if the env var is set — it shows an info-message and proceeds, but the key keeps winning until you unset it.
136
134
 
137
135
  ---
138
136
 
@@ -159,7 +157,8 @@ Flags:
159
157
 
160
158
  - `--with-template <ref>` — pre-install a starter template, format `<collection>/<template>`. Skips the interactive prompt.
161
159
  - `--template-name <name>` — override the imported template's destination name
162
- - `--source <repo>` — source repo, format `github:<owner>/<repo>` (default: `github:poli-page/templates`)
160
+ - `--source <repo>` — source repo, format `github:<owner>/<repo>` (default: `github:poli-page/templates`); `<owner>` and `<repo>` are each one name of letters, digits, `.`, `_` and `-`, not `.` or `..`
161
+ A source's collection and template names, and the `template`, `mock`, `fonts[].src` and `images[]` paths of its template manifests, must be relative paths of letters, digits, `.`, `_` and `-` segments (no `..`, no leading `.` or `/`); the first one that is not refuses the whole import before anything is written. No imported file is written outside the project or the cache, including through a symlink that is there when the import starts, and no file of the project (the template files, fonts, images, `tailwind.css`, the files of `--starter` and its `poli-page.json`) is written through a symlink, even one that stays inside the project: each is written to a temp file and renamed into place; the paths are checked before the writes, so another process changing the project's folders during the import is not covered.
163
162
  - `--no-cache` — bypass the 24-hour template cache
164
163
 
165
164
  ##### `--starter getting-started` — start from your org's getting-started project
@@ -183,7 +182,7 @@ poli publish --env sandbox # publish the project to the sandbox environment
183
182
 
184
183
  and re-run the dashboard snippet to see your change.
185
184
 
186
- Piped, or with `--json`, it prints `{ starter, projectDir, link }` as JSON instead (`link` is `{ status: "linked", orgSlug }` or `{ status: "unlinked", reason }`) and never prompts. `<name>` is one top-level folder of the source (no `/`).
185
+ Piped, or with `--json`, it prints `{ starter, projectDir, link }` as JSON instead (`link` is `{ status: "linked", orgSlug }` or `{ status: "unlinked", reason }`) and never prompts. `<name>` is one top-level folder of the source (no `/`). Every file path in that folder must be made of letters, digits, `.`, `_` and `-` segments (dotfiles allowed, no `.` or `..` segment); the first one that is not refuses the starter before any file is fetched.
187
186
 
188
187
  Flags: `--starter <name>`, `--org <slug>`, `--force`, `--json`, plus `--source` and `--no-cache` as above.
189
188
 
@@ -204,16 +203,19 @@ Flags:
204
203
  - `--from-template <ref>` — collection/template. Skips the interactive prompt.
205
204
  - `--source <repo>` — override the source
206
205
  - `--no-cache` — bypass cache
206
+ - `--format <format>`, `--orientation <orientation>` — set the template's page format and orientation (see [Manifest format](#manifest-format)); an unknown value exits `2` before anything is imported
207
207
 
208
208
  ### Authentication commands
209
209
 
210
210
  #### `poli login`
211
211
 
212
- Opens your browser for the device authorization flow and stores the session token at `~/.polipage/credentials.json`.
212
+ Opens your browser for the device authorization flow and stores the session token at `~/.polipage/credentials`.
213
+
214
+ It first prints the API host it logs into. The browser opens only an `https` page on the API's own site (`poli.page` or a subdomain; a local page when the API is local): any other verification URL the API sends is printed, not opened, and login exits `3`. The API URL is stored in the credentials file only when you chose it: `--api-url`, your own `POLI_API_URL`, or the `apiUrl` an earlier login stored. A `poli-page.json` `cloud.apiUrl` is never stored.
213
215
 
214
216
  #### `poli logout`
215
217
 
216
- Clears the local credentials file.
218
+ Deletes the local credentials file, then revokes the session it held on the API origin that issued it (`POST /api/auth/sign-out`), so the file is gone even if the revoke hangs or is interrupted. If the revoke fails (network error, API error, an origin the CLI does not trust), a warning says the session stays valid until it expires; the exit code is `0` either way. If the file cannot be deleted (for example a read-only `~/.polipage`), the CLI still tries to revoke the session (a failed revoke gets the same warning), an error asks you to delete the file by hand, and the exit code is `6`.
217
219
 
218
220
  #### `poli whoami`
219
221
 
@@ -244,11 +246,27 @@ Flag: `--json` to dump the raw `/v1/me` payload (or, in `session-no-org` mode, `
244
246
 
245
247
  #### `poli link`
246
248
 
247
- Interactively select an organization, create the cloud project, and write the `cloud:` section into `poli-page.json` with the four fields the API needs (`orgSlug`, `orgId`, `projectSlug`, `projectId`). No API key is stored in the manifest — the file is safe to commit.
249
+ Pick an organization, create the cloud project, and write the `cloud:` section into `poli-page.json` with the four fields the API needs (`orgSlug`, `orgId`, `projectSlug`, `projectId`). No API key is stored in the manifest — the file is safe to commit. It also records the folder as a [confirmed link](#confirmed-links) on this machine, so `poli watch` and `poli dev` sync it without asking.
250
+
251
+ The organization is the one `--org <slug>` names; an unknown or empty slug fails with exit `2`, listing your organizations. Without `--org`, an account with a single organization uses it, and one with several asks in a terminal; when it cannot ask (stdin or stdout not a TTY, e.g. in CI or a script), it exits `2`, listing the slugs, and tells you to pass `--org <slug>`.
252
+
253
+ ```bash
254
+ poli link --org acme
255
+ ```
256
+
257
+ When the organization already has a project whose slug is the kebab-cased `project.name` (say, a teammate's), `poli link` links to it instead of creating one, and every later sync overwrites that project's draft. So it first names the project and organization and asks; a no leaves the folder unlinked (exit `1`). When it cannot ask (stdin or stdout not a TTY, e.g. its output piped), it refuses with exit `2` and writes nothing, unless you pass `--existing`, which links to that project without asking. In a script, pass both: `poli link --org <slug> --existing`. `poli init --starter` is not affected: it links only to the organization's existing starter project.
258
+
259
+ The new cloud project is created from the files [`poli publish`](#poli-publish) would send (regular files only, never a symlink), restricted to the templates and mocks the manifest names, `tailwind.css`, the image files under `assets/images/` and `assets/icons/` and the font files under `assets/fonts/`; partials and other files reach the project on the first sync or publish. A template or mock file the manifest names that is not in that set (missing, symlinked, outside `templates/<name>/`, or under a `node_modules`, `.git`, `output`, `dist` or `.poli` folder, e.g. a template named `output`) fails the link before the project is created.
260
+
261
+ #### Confirmed links
262
+
263
+ A `cloud:` block can come with a cloned repository, and every sync overwrites the cloud draft of the project it names. So `poli watch` and `poli dev` sync only a folder whose link you confirmed on this machine. The confirmed links are kept per user in `~/.polipage/links.json` (mode `0600`), keyed by the folder's real path and the project id; `poli link` and `poli init --starter` (when it links) write them, `poli unlink` removes the folder's. The first time you run `poli watch` or `poli dev` in a folder that is not there, or whose `projectId` changed, the command names the organization and project and asks once; a yes is recorded, a no stops the command before any sync. Without a terminal to ask in (stdin or stdout not a TTY), it refuses with exit `2`.
264
+
265
+ Before syncing, `poli watch` and `poli dev` also check with the API that the manifest's `orgSlug`, `orgId`, `projectId` and `projectSlug` all name the same project (sync writes to `projectId` in the `orgSlug` organization; render and publish address `projectSlug` with `orgId`). A manifest whose ids disagree, or whose `orgSlug` names none of your organizations, is refused before any write (exit `6`); `poli publish` with a session refuses it too.
248
266
 
249
267
  #### `poli unlink`
250
268
 
251
- Removes the `cloud:` section from `poli-page.json`. Local files are preserved.
269
+ Removes the `cloud:` section from `poli-page.json`, even one whose ids are invalid, and forgets the folder's [confirmed link](#confirmed-links), so a `cloud:` block that comes back later (a pull, a checkout) is asked about again. Local files are preserved.
252
270
 
253
271
  #### `poli watch`
254
272
 
@@ -264,7 +282,7 @@ Resilience built in:
264
282
  - `503 ORGANIZATION_MIGRATING` → 5-second retry
265
283
  - Other API errors → logged, watch continues, next save retries
266
284
 
267
- Requires a TTY. Refused with exit `2` when run in a non-interactive context. If
285
+ Requires a TTY. Refused with exit `2` when run in a non-interactive context. Syncs only a [confirmed link](#confirmed-links): the first run in a cloned folder asks first. If
268
286
  you need the same sync inside a script or alongside a browser preview, use
269
287
  [`poli dev`](#poli-dev-template), which has no TTY requirement.
270
288
 
@@ -291,7 +309,7 @@ poli dev -d ./big.json # render every template against your own data
291
309
  | Flag | Default | Meaning |
292
310
  | -------------------- | ------------------ | ---------------------------------------------------------- |
293
311
  | `-p, --port <n>` | `7654` | Port to bind on `127.0.0.1`. Walks upwards when it is busy. |
294
- | `-d, --data <path>` | the template mock | JSON data file, same shape as `poli render -d`. |
312
+ | `-d, --data <path>` | the template mock | JSON data file, same shape as `poli render -d`; saving it re-renders when it is inside the project. |
295
313
  | `--no-open` | opens the browser | Skip launching a browser on start. |
296
314
  | `[template]` | first in manifest | Which template to show first. |
297
315
 
@@ -323,8 +341,14 @@ Notes:
323
341
  { "scripts": { "dev": "concurrently \"poli dev --no-open\" \"vite\"" } }
324
342
  ```
325
343
 
344
+ - It syncs only a [confirmed link](#confirmed-links). In a terminal the first
345
+ run in a cloned folder asks first; piped, an unconfirmed folder is refused
346
+ with exit `2`: run `poli dev` once in a terminal, or `poli unlink`, then `poli link`.
326
347
  - It binds to `127.0.0.1` only — the rendered draft is never exposed to the
327
348
  local network.
349
+ - Only its own page can change the view: a `POST` from another site (or from
350
+ any client that sends neither `Sec-Fetch-Site: same-origin` nor the server's
351
+ own `Origin`) gets a `403`, and no other site can frame the page.
328
352
  - On start it pushes the whole working tree to the draft, so the first render
329
353
  reflects your local files rather than whatever the draft last contained.
330
354
  - Failures are surfaced, not fatal: a render that errors, a rejected sync, a
@@ -337,7 +361,7 @@ Notes:
337
361
 
338
362
  #### `poli publish`
339
363
 
340
- Publishes the local project, the files on disk, to an environment of your organization: `POST /v1/projects/<projectSlug>/publish`, with your `poli login` session and the manifest's `cloud.orgId`, or, without a session, with a service key in `POLI_PAGE_API_KEY` (see below). The environment's copy of the project is replaced in place. There is no rollback: to go back, check out the earlier state from your own version control and publish again.
364
+ Publishes the local project, the files on disk, to an environment of your organization: `POST /v1/projects/<projectSlug>/publish`, with a service key in `POLI_PAGE_API_KEY` when one is set (see below), or else with your `poli login` session and the manifest's `cloud.orgId`; with a session, a manifest whose `cloud` ids do not all name the same project is refused before the upload (exit `6`, see [confirmed links](#confirmed-links)). The environment's copy of the project is replaced in place. There is no rollback: to go back, check out the earlier state from your own version control and publish again.
341
365
 
342
366
  ```bash
343
367
  poli publish --env sandbox
@@ -353,12 +377,13 @@ poli publish --env live --yes # protected environment, no prompt (scripts)
353
377
  | `--json` | Print the API response as JSON (also the default when stdout is not a TTY). |
354
378
 
355
379
  - **Environment names** are 1-20 characters: lowercase letters, digits and single inner hyphens, starting with a letter. A name that breaks this rule is refused before any call (exit `2`). An environment that does not exist in the organization is refused with the list of the ones that do (exit `2`).
356
- - **The bundle** is the project file set: `poli-page.json`, `tailwind.css`, the `.html`, `.json` and `.css` files under `templates/<slug>/`, the `.html` files under `partials/`, everything under `assets/images/` and `assets/icons/`, and the `.woff2`, `.woff`, `.ttf` and `.otf` files under `assets/fonts/`. Anything else (`.gitignore`, `README.md`, `output/`, `node_modules/`) is left out. Assets are sent base64-encoded, every other file as UTF-8. A bundle over 5 MiB, or a message over 500 characters, is refused before any call (exit `2`).
357
- - **Protected environments** (`live` by default) accept a publish from an owner or an admin only. In a terminal, `poli publish` asks for confirmation first; without a TTY it needs `--yes`, and `CI=true` counts as `--yes`. Without the role, the API refuses with `ENVIRONMENT_PROTECTED` (exit `5`).
358
- - **With a service key** (`POLI_PAGE_API_KEY` and no `poli login` session; a session wins when both are there): the CLI calls `GET /v1/me`, then publishes to the manifest's `cloud.projectSlug` with no organization header, since the key carries its organization. `--env` must name the key's own environment, or the publish is refused before any upload, naming it (exit `2`). A standard key is refused with "Standard API keys can only render. Use a service key or `poli login`." (exit `5`). There is no prompt and no environment check on the CLI side: the API applies the protected-environment rule, and a service key without the `admin` role gets `ENVIRONMENT_PROTECTED` (exit `5`).
380
+ - **The bundle** is the project file set: `poli-page.json`, `tailwind.css`, the `.html`, `.json` and `.css` files under `templates/<slug>/`, the `.html` files under `partials/`, the `.png`, `.jpg`, `.jpeg`, `.gif`, `.webp` and `.svg` files under `assets/images/` and `assets/icons/` (the image types the engine renders), and the `.woff2`, `.woff`, `.ttf` and `.otf` files under `assets/fonts/`, extensions in any letter case. Anything else (`.gitignore`, `README.md`, `*.log`, `.DS_Store`) is left out, a file of another type under `assets/images/` or `assets/icons/` with a warning that names it (but not `.gitkeep`, `.keep`, `.DS_Store`, `Thumbs.db` or `desktop.ini`), and so is every `node_modules/`, `.git/`, `output/`, `dist/` and `.poli/` directory at any depth. Assets are sent base64-encoded, every other file as UTF-8. A bundle over 5 MiB, or a message over 500 characters, is refused before any call (exit `2`).
381
+ - **Limits.** Only `poli-page.json`, `tailwind.css`, `templates/`, `partials/` and `assets/` are walked, and every file's size is checked before any is read. A file over 4 MiB, more than 1000 files, or files adding up to more than 5 MiB fail the command before any call, naming the file or the limit (exit `2`); nothing is sent. These are the API's limits, and `poli link`, `poli watch` and `poli dev` apply them too.
382
+ - **Protected environments** (`live` by default) accept a publish from an owner or an admin only. In a terminal, `poli publish` asks for confirmation first; without a TTY it needs `--yes`. `CI=true` does not stand in for `--yes`. Without the role, the API refuses with `ENVIRONMENT_PROTECTED` (exit `5`).
383
+ - **With a service key** (`POLI_PAGE_API_KEY`; the key wins over a `poli login` session when both are there): the CLI calls `GET /v1/me`, then publishes to the manifest's `cloud.projectSlug` with no organization header, since the key carries its organization. `--env` must name the key's own environment, or the publish is refused before any upload, naming it (exit `2`). When the manifest has a `cloud.orgId`, the key must belong to that organization (the one `GET /v1/me` names), or the publish is refused before any upload, naming both organizations (exit `2`): the key would otherwise publish to a project of the same slug in its own organization. A standard key is refused with "Standard API keys can only render. Use a service key or `poli login`." (exit `5`); with a session stored, the standard-key, `--env` and organization refusals all say to unset `POLI_PAGE_API_KEY` to use the session instead. There is no prompt and no environment check on the CLI side: the API applies the protected-environment rule, and a service key without the `admin` role gets `ENVIRONMENT_PROTECTED` (exit `5`).
359
384
  - **One publish at a time** per project and environment: while one runs, a second gets `PUBLISH_IN_PROGRESS` (exit `3`). It is not retried; run it again once the first one is done.
360
385
 
361
- On success it prints the environment, the project, the short bundle hash, the file count and the publish log id.
386
+ On success it prints the environment, the project, the short bundle hash, the file count, the publish log id and the credential used (`POLI_PAGE_API_KEY` or `session (poli login)`).
362
387
 
363
388
  #### `poli env list`
364
389
 
@@ -429,7 +454,7 @@ Spec rules:
429
454
  Flags:
430
455
 
431
456
  - `--data <file>` — JSON data overrides the mock
432
- - `-o <file>` — output PDF path. Incompatible with `--no-download`
457
+ - `-o <file>` — output PDF path. Incompatible with `--no-download`. Without it the PDF goes to `output/<name>/<format-orientation>/<name>.pdf` in the project, which is refused if it is a symlink or resolves outside the project through one; the PDF is written to a temp file and renamed into place. `-o` is written as given
433
458
  - `--no-download` — skip the presigned URL fetch (CI/CD pipelines). Environment renders only
434
459
  - `--json` — force JSON output even in a TTY
435
460
 
@@ -492,9 +517,11 @@ poli documents thumbnails doc_abc123 -o ./out
492
517
 
493
518
  Flags: `-w/--width`, `-f/--format png|jpeg`, `-q/--quality`, `--pages 1,3`, `-o/--output`, `--json`.
494
519
 
520
+ The default folder is `./output/thumbnails/<id>/`, with `page-<n>.<ext>` files. The `<id>` must be letters, digits, `.`, `_` and `-`, starting with a letter or digit, without `..`; another one is refused before any request (exit `2`). A page number from the API that is not a positive integer refuses the whole set before anything is written. A default file that is a symlink, or resolves outside the current directory through one, refuses the whole set before any page is written; `-o` is written as given.
521
+
495
522
  #### `poli documents preview <id>`
496
523
 
497
- Fetch the stored canonical HTML re-wrapped as preview-mode (free, no quota cost). Default writes the file at `./output/documents/<id>.preview.html` and opens the browser.
524
+ Fetch the stored canonical HTML re-wrapped as preview-mode (free, no quota cost). Default writes the file at `./output/documents/<id>.preview.html` and opens the browser: the `<id>` is checked as for `thumbnails` before any request, and that file is refused if it is a symlink or resolves outside the current directory through one (`-o` is written as given). The written file carries a Content-Security-Policy meta that blocks scripts, network loads, form submissions and `<base>` (inline styles and `data:` images and fonts still render; a `<meta http-equiv="refresh">` in the HTML can still navigate away, which CSP cannot block; a second meta turns off DNS prefetching of hyperlinks, which CSP does not cover, but a `<link rel="dns-prefetch">` can still resolve its hostname); `--json` prints the HTML as received.
498
525
 
499
526
  ```bash
500
527
  poli documents preview doc_abc123
@@ -523,8 +550,8 @@ poli documents preview doc_abc123 -o ./preview.html
523
550
  "templates": [
524
551
  {
525
552
  "name": "invoice",
526
- "template": "templates/invoice/invoice.html",
527
- "mock": "templates/invoice/invoice.json",
553
+ "template": "invoice.html",
554
+ "mock": "invoice.json",
528
555
  "format": "A4",
529
556
  "orientation": "portrait"
530
557
  }
@@ -538,8 +565,17 @@ poli documents preview doc_abc123 -o ./preview.html
538
565
  }
539
566
  ```
540
567
 
568
+ Each `templates[]` entry is checked when the manifest is read, and a bad value fails with the field it is in (`templates[0].mock: …`):
569
+
570
+ - `name` — the template's folder under `templates/`: lowercase letters, digits and inner `-`.
571
+ - `template`, `mock` — paths relative to `templates/<name>/`, made of segments of letters, digits, `.`, `_` and `-`, each starting with a letter or digit (no `..`, absolute path, `\`, `?`, `#` or `%`). The files are read only when they resolve inside the project, symlinks included.
572
+ - `format` (default `A4`) — one of `A3`, `A4`, `A5`, `A6`, `B4`, `B5`, `Letter`, `Legal`, `Tabloid`, `Statement`, `Executive`, `Folio`, in any letter case.
573
+ - `orientation` (default `portrait`) — `portrait` or `landscape`, in any letter case.
574
+
541
575
  The `cloud:` block is written by `poli link`, removed by `poli unlink`. **No API keys here** — the credentials file (or `POLI_PAGE_API_KEY`) carries the secret.
542
576
 
577
+ `cloud.orgId` and `cloud.projectId` must be UUIDs (8-4-4-4-12 hex digits): any other value makes the manifest invalid (`Invalid poli-page.json — cloud.projectId: must be a UUID`, from every command that reads it), so a hand-edited id cannot change the API path the CLI calls with your session. `poli unlink` still removes such a block, and `poli init --starter` ignores the starter's own `cloud:` block. A `cloud.projectSlug` of `.` or `..` is refused by `poli publish` (`Invalid project ID.`).
578
+
543
579
  A manifest from before environments may still carry `project.version` or `cloud.track`. Both are ignored, and dropped the next time the CLI writes the file (`poli link`, `poli unlink`, `poli new`).
544
580
 
545
581
  ---
@@ -550,14 +586,16 @@ A manifest from before environments may still carry `project.version` or `cloud.
550
586
 
551
587
  | Variable | Effect |
552
588
  | -------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
553
- | `POLI_PAGE_API_KEY` | Single env var for any API key in CI/CD: `pp_<environment>_` followed by 32 lowercase hex characters, checked in full before any call. The key renders only its own environment; a service key also publishes to it. **Precedence**: when a credentials file is also present, the session wins. |
554
- | `POLI_API_URL` | Override the API base URL (precedence: `--api-url` flag → `POLI_API_URL` → `poli-page.json` `cloud.apiUrl` → `~/.polipage/credentials.json` `apiUrl` → default `https://api.poli.page`). |
589
+ | `POLI_PAGE_API_KEY` | Single env var for any API key in CI/CD: `pp_<environment>_` followed by 32 lowercase hex characters, checked in full before any call. The key renders only its own environment; a service key also publishes to it. **Precedence**: when a credentials file is also present, the key wins for `whoami`, `publish`, `render` and `documents`. |
590
+ | `POLI_API_URL` | Override the API base URL (precedence: `--api-url` flag → `POLI_API_URL` → `poli-page.json` `cloud.apiUrl`, when allowed (see below) → `~/.polipage/credentials` `apiUrl` → default `https://api.poli.page`). The URL must be an origin only (no user, path, query or hash) on `https://poli.page` or `https://*.poli.page`; anything else exits `2` before any request. `poli-page.json` `cloud.apiUrl` is ignored, with a warning, unless it equals the stored `apiUrl` or the default: a cloned folder cannot choose where your credentials go. A session is only sent to the API origin that issued it; log in again to use another one. |
591
+ | `POLI_ALLOW_INSECURE_API` | Set to `1` to allow a local API URL (`http://localhost`, `http://127.0.0.1`), like `--allow-insecure-api`. |
555
592
  | `NO_COLOR` | Disable ANSI colors (Unix standard). |
556
- | `CI` | Auto-detected; equivalent to a global `--yes`, except for `poli env remove-project`. |
593
+ | `CI` | Not read. `CI=true` is not consent: without a TTY, a prompt needs `--yes`. |
557
594
 
558
595
  ### Common flags
559
596
 
560
- - `--api-url <url>` — override the API base URL for one invocation
597
+ - `--api-url <url>` — override the API base URL for one invocation (a Poli Page origin; see `POLI_API_URL`)
598
+ - `--allow-insecure-api` — allow a local API URL (`localhost`, `127.0.0.1`) for one invocation
561
599
  - `-y` / `--yes` — skip confirmation prompts
562
600
  - `-h` / `--help` — show help for any command or sub-command
563
601
  - `-v` / `--version` — print the CLI version and exit
@@ -588,9 +626,9 @@ Imperative commands (`init` without `--starter`, `new`, `link`, `unlink`, `logou
588
626
  | `1` | Recoverable inconsistency (already logged in, already linked) |
589
627
  | `2` | Invalid usage (bad args, template not found, project not published in that environment, non-TTY context where TTY is required) |
590
628
  | `3` | Network / API error (timeout, 5xx, unspecified 4xx) |
591
- | `4` | Not authenticated — run `poli login` or set `POLI_PAGE_API_KEY` |
592
- | `5` | Not authorized (insufficient role, protected environment, `THUMBNAILS_NOT_AVAILABLE`) |
593
- | `6` | Invalid local state (no project, project not linked, empty folder where required) |
629
+ | `4` | Not authenticated: run `poli login` or set `POLI_PAGE_API_KEY`; or the API answered `MISSING_API_KEY`, `INVALID_API_KEY` or `API_KEY_EXPIRED` |
630
+ | `5` | Not authorized (insufficient role, protected environment, `PROJECT_OUT_OF_SCOPE`, `THUMBNAILS_NOT_AVAILABLE`) |
631
+ | `6` | Invalid local state (no project, invalid `poli-page.json`, project not linked, empty folder where required) |
594
632
 
595
633
  These map to the centralised `ExitCode` constants in `src/exit-codes.ts`. Every handler routes errors through `errorToExitCode(err)`.
596
634
 
@@ -687,27 +725,55 @@ Either run `poli login` interactively, or export `POLI_PAGE_API_KEY` for CI use.
687
725
 
688
726
  ### `POLI_PAGE_API_KEY must be a Poli Page API key: \`pp_<environment>_…\`...`
689
727
 
690
- You set the variable but its value is not a whole key: `pp_`, the environment name, `_`, then 32 lowercase hex characters. Copy the key again, or create one from the dashboard's API keys page. Exit code `4`.
728
+ You set the variable but its value is not a whole key: `pp_`, the environment name, `_`, then 32 lowercase hex characters. Copy the key again, or create one from the dashboard's API keys page. If you are logged in, the key wins over your session while it is set, so a malformed key is refused even then (the message then says so): fix it, or unset `POLI_PAGE_API_KEY` to use the session. Exit code `4`.
691
729
 
692
730
  ### `Standard API keys can only render. Use a service key or \`poli login\`.`
693
731
 
694
- `poli publish` with `POLI_PAGE_API_KEY` set to a standard key. Only a service key, or a `poli login` session, can publish. Exit code `5`.
732
+ `poli publish` with `POLI_PAGE_API_KEY` set to a standard key. Only a service key, or a `poli login` session, can publish. If you are already logged in, the key wins over your session while it is set (the message then says so): unset `POLI_PAGE_API_KEY` to publish with the session. Exit code `5`.
695
733
 
696
734
  ### `This service key publishes to "<a>" only, not "<b>"...`
697
735
 
698
- A service key publishes into its own environment only. Pass `--env <a>`, or use a service key for `<b>`. Exit code `2`.
736
+ A service key publishes into its own environment only. Pass `--env <a>`, or use a service key for `<b>`. If you are logged in, the key wins over your session while it is set (the message then says so): unset `POLI_PAGE_API_KEY` to publish with the session. Exit code `2`.
737
+
738
+ ### `This API key belongs to organization "<name>" (<slug>, <id>), but this folder is linked to organization "<slug>" (<id>)...`
739
+
740
+ `poli publish` with `POLI_PAGE_API_KEY` set to a key of another organization than the manifest's `cloud.orgId`. Since a key publishes to `cloud.projectSlug` in its own organization, the CLI refuses before any upload rather than publish to a same-slug project there. Use a service key of the linked organization, or, if the folder belongs to the key's organization, run `poli unlink`, then `poli link`. If you are logged in to the linked organization, the key wins over your session while it is set (the message then says so): unset `POLI_PAGE_API_KEY` to publish with the session. Exit code `2`.
741
+
742
+ ### `Not authenticated: your session has expired or no API key was sent. Run \`poli login\`, or set POLI_PAGE_API_KEY...`
743
+
744
+ The API answered `MISSING_API_KEY`: it received no valid credential. Either your `poli login` session has expired (run `poli login` again), or no API key was sent (create a key on the dashboard's API keys page and export it as `POLI_PAGE_API_KEY`). Exit code `4`.
745
+
746
+ ### `This API key is not valid: it is unknown or was revoked, its environment was deleted, or its service account was disabled or deleted...`
747
+
748
+ The API does not accept the key (`INVALID_API_KEY`): it never existed, it was revoked, its environment was deleted, or its service account was disabled or deleted. Create a new key on the dashboard's API keys page and update `POLI_PAGE_API_KEY`. Exit code `4`.
749
+
750
+ ### `Your API key has expired. Create a new one in the dashboard (API keys) and update POLI_PAGE_API_KEY.`
751
+
752
+ The key passed its expiry date (`API_KEY_EXPIRED`). Create a new key on the dashboard's API keys page and update `POLI_PAGE_API_KEY`. Exit code `4`.
753
+
754
+ ### `This API key is restricted to other projects. Use a key that includes this project, or create one in the dashboard (API keys).`
755
+
756
+ The key is limited to some projects and this folder's project is not one of them (`PROJECT_OUT_OF_SCOPE`). Use a key that includes the project, or create one on the dashboard's API keys page. Exit code `5`.
699
757
 
700
758
  ### `This folder isn't linked to a cloud project. Run \`poli link\` first.`
701
759
 
702
760
  You're in session mode and the local manifest has no `cloud:` block. Either run `poli link`, or switch to api-key mode with `POLI_PAGE_API_KEY=pp_<environment>_…` (which carries the org context implicitly). Exit code `6`.
703
761
 
762
+ ### `This folder is linked to project "<name>" (<slug>) of organization "<name>" (<slug>), a link you have not confirmed on this machine...`
763
+
764
+ `poli watch` or `poli dev` found a `cloud:` block (from a clone, say) that is not in your `~/.polipage/links.json`, and had no terminal to ask in. Run the command once in a terminal and answer yes, or run `poli unlink`, then `poli link`. Exit code `2`. See [confirmed links](#confirmed-links).
765
+
766
+ ### `The cloud block of poli-page.json names more than one project: ...`
767
+
768
+ The manifest's `orgSlug`, `orgId`, `projectId` and `projectSlug` do not all name the same project, so sync and publish would write to different ones. The message names the id that disagrees. Run `poli unlink`, then `poli link`. Exit code `6`.
769
+
704
770
  ### `API keys render a published environment: use \`name@<environment>\``
705
771
 
706
- `poli render name` renders the draft, which only a `poli login` session can do. With an API key, render the key's environment: `poli render name@<environment>`. Exit code `2`.
772
+ `poli render name` renders the draft, which only a `poli login` session can do. With an API key, render the key's environment: `poli render name@<environment>`. If you are logged in, the key wins over your session while it is set (the message then says so): unset `POLI_PAGE_API_KEY` to render the draft. Exit code `2`.
707
773
 
708
774
  ### `This API key renders the \`<a>\` environment, not \`<b>\``
709
775
 
710
- A key renders only the environment in its prefix. Render `name@<a>`, or use a key for `<b>`. Exit code `2`.
776
+ A key renders only the environment in its prefix. Render `name@<a>`, or use a key for `<b>`. If you are logged in, the key wins over your session while it is set (the message then says so): unset `POLI_PAGE_API_KEY` to render `<b>` with the session. Exit code `2`.
711
777
 
712
778
  ### `\`invoice@1.2.3\`: templates no longer have versions...`
713
779
 
@@ -721,7 +787,7 @@ The API renders the draft for a `poli login` session only. The CLI refuses a dra
721
787
 
722
788
  `poli publish --env <env>` to a protected environment (`live` by default) by someone who is not an owner or admin of the organization, or with a service key without the `admin` role. Ask an owner or admin to publish, or use an `admin` service key. Exit code `5`.
723
789
 
724
- Without a terminal, `Environment "<env>" is protected. Pass --yes to publish to it without a prompt.` means the confirmation could not be asked: pass `--yes` (`CI=true` counts as `--yes`). Exit code `2`.
790
+ Without a terminal, `Environment "<env>" is protected. Pass --yes to publish to it without a prompt.` means the confirmation could not be asked: pass `--yes` (`CI=true` does not count as `--yes`). Exit code `2`.
725
791
 
726
792
  ### `PUBLISH_IN_PROGRESS`
727
793
 
@@ -741,7 +807,7 @@ Your org is being migrated to a new tier. `poli watch` retries automatically aft
741
807
 
742
808
  ### `poli watch` doesn't fire on save
743
809
 
744
- Make sure you're not editing inside an ignored directory. Default ignores: `node_modules/`, `.git/`, `output/`, `dist/`, `*.log`, `.DS_Store`. The watcher uses `chokidar` v5; if your editor saves via "atomic write + rename" (some Vim setups), the rename event fires within the debounce window and triggers a sync.
810
+ Make sure the file is in the project file set, as [`poli publish`](#poli-publish) defines the bundle (only some file types count under each folder, e.g. `templates/<slug>/logo.svg` does not): no other file triggers a sync, except the `poli dev --data` file. The watcher does not follow symlinks: a file reached through a symlinked directory is not watched. The watcher uses `chokidar` v5; if your editor saves via "atomic write + rename" (some Vim setups), the rename event fires within the debounce window and triggers a sync.
745
811
 
746
812
  ---
747
813
 
@@ -50,6 +50,24 @@ export declare class UnsupportedFileTypeError extends ApiError {
50
50
  export declare class InsufficientRoleError extends ApiError {
51
51
  constructor(message: string, retryAfter?: number);
52
52
  }
53
+ export declare const API_KEY_MESSAGES: {
54
+ readonly MISSING_API_KEY: "Not authenticated: your session has expired or no API key was sent. Run `poli login`, or set POLI_PAGE_API_KEY to a key created in the dashboard (API keys).";
55
+ readonly INVALID_API_KEY: "This API key is not valid: it is unknown or was revoked, its environment was deleted, or its service account was disabled or deleted. Create a new one in the dashboard (API keys) and update POLI_PAGE_API_KEY.";
56
+ readonly API_KEY_EXPIRED: "Your API key has expired. Create a new one in the dashboard (API keys) and update POLI_PAGE_API_KEY.";
57
+ readonly PROJECT_OUT_OF_SCOPE: "This API key is restricted to other projects. Use a key that includes this project, or create one in the dashboard (API keys).";
58
+ };
59
+ export declare class MissingApiKeyError extends ApiError {
60
+ constructor(_message?: string, retryAfter?: number);
61
+ }
62
+ export declare class InvalidApiKeyError extends ApiError {
63
+ constructor(_message?: string, retryAfter?: number);
64
+ }
65
+ export declare class ApiKeyExpiredError extends ApiError {
66
+ constructor(_message?: string, retryAfter?: number);
67
+ }
68
+ export declare class ProjectOutOfScopeError extends ApiError {
69
+ constructor(_message?: string, retryAfter?: number);
70
+ }
53
71
  export interface DeviceRequestResult {
54
72
  deviceCode: string;
55
73
  userCode: string;
@@ -226,6 +244,8 @@ export interface ApiClient {
226
244
  }>;
227
245
  deviceRequest(): Promise<DeviceRequestResult>;
228
246
  devicePoll(deviceCode: string): Promise<DevicePollResult>;
247
+ /** `POST /api/auth/sign-out`: revokes the session server-side. */
248
+ signOut(session: string): Promise<void>;
229
249
  getOrganizations(session: string): Promise<Array<{
230
250
  id: string;
231
251
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"api-client.d.ts","sourceRoot":"","sources":["../src/api-client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAIjD,qBAAa,QAAS,SAAQ,KAAK;aAEjB,IAAI,EAAE,MAAM;aACZ,UAAU,EAAE,MAAM;aAElB,UAAU,CAAC,EAAE,MAAM;gBAHnB,IAAI,EAAE,MAAM,EACZ,UAAU,EAAE,MAAM,EAClC,OAAO,EAAE,MAAM,EACC,UAAU,CAAC,EAAE,MAAM,YAAA;CAKpC;AAED,qBAAa,kBAAmB,SAAQ,QAAQ;gBACnC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAGhD;AACD,qBAAa,eAAgB,SAAQ,QAAQ;gBAChC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAGhD;AACD,qBAAa,oBAAqB,SAAQ,QAAQ;gBACrC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,GAC9B,OAAO,CAAC,YAAY,CAAC,CAAC;IACzB;;;;OAIG;IACH,WAAW,CACV,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,MAAM,CAAC,CAAC;IACnB,KAAK,CAAC,aAAa,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAGxE,WAAW,CACV,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,EAAE,EAAE,MAAM,GACR,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC/B,cAAc,CACb,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,EAAE,EAAE,MAAM,GACR,OAAO,CAAC,IAAI,CAAC,CAAC;IACjB,kBAAkB,CACjB,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,EAAE,EAAE,MAAM,EACV,OAAO,EAAE,wBAAwB,GAC/B,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;IAC9B,eAAe,CACd,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,MAAM,GAAG,SAAS,EAC/B,EAAE,EAAE,MAAM,GACR,OAAO,CAAC,qBAAqB,CAAC,CAAC;CAClC;AAED,wBAAgB,eAAe,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CA+T3D"}
@@ -1,4 +1,5 @@
1
- const DEFAULT_API_URL = 'https://api.poli.page';
1
+ import { apiOrigin, assertTrustedApiOrigin } from './api-origin.js';
2
+ import { oneLine } from './output.js';
2
3
  export class ApiError extends Error {
3
4
  code;
4
5
  httpStatus;
@@ -86,6 +87,36 @@ export class InsufficientRoleError extends ApiError {
86
87
  super('INSUFFICIENT_ROLE', 403, message, retryAfter);
87
88
  }
88
89
  }
90
+ // API key errors (cli-spec §1.2). The message is always the spec's actionable
91
+ // text: the constructors ignore the message argument (the registry passes the
92
+ // server's detail, which is dropped), so build them with no argument and do
93
+ // not rely on rewording one; command error handlers print the text as is.
94
+ export const API_KEY_MESSAGES = {
95
+ MISSING_API_KEY: 'Not authenticated: your session has expired or no API key was sent. Run `poli login`, or set POLI_PAGE_API_KEY to a key created in the dashboard (API keys).',
96
+ INVALID_API_KEY: 'This API key is not valid: it is unknown or was revoked, its environment was deleted, or its service account was disabled or deleted. Create a new one in the dashboard (API keys) and update POLI_PAGE_API_KEY.',
97
+ API_KEY_EXPIRED: 'Your API key has expired. Create a new one in the dashboard (API keys) and update POLI_PAGE_API_KEY.',
98
+ PROJECT_OUT_OF_SCOPE: 'This API key is restricted to other projects. Use a key that includes this project, or create one in the dashboard (API keys).',
99
+ };
100
+ export class MissingApiKeyError extends ApiError {
101
+ constructor(_message, retryAfter) {
102
+ super('MISSING_API_KEY', 401, API_KEY_MESSAGES.MISSING_API_KEY, retryAfter);
103
+ }
104
+ }
105
+ export class InvalidApiKeyError extends ApiError {
106
+ constructor(_message, retryAfter) {
107
+ super('INVALID_API_KEY', 401, API_KEY_MESSAGES.INVALID_API_KEY, retryAfter);
108
+ }
109
+ }
110
+ export class ApiKeyExpiredError extends ApiError {
111
+ constructor(_message, retryAfter) {
112
+ super('API_KEY_EXPIRED', 401, API_KEY_MESSAGES.API_KEY_EXPIRED, retryAfter);
113
+ }
114
+ }
115
+ export class ProjectOutOfScopeError extends ApiError {
116
+ constructor(_message, retryAfter) {
117
+ super('PROJECT_OUT_OF_SCOPE', 403, API_KEY_MESSAGES.PROJECT_OUT_OF_SCOPE, retryAfter);
118
+ }
119
+ }
89
120
  const TYPED_ERROR_REGISTRY = {
90
121
  QUOTA_EXCEEDED: QuotaExceededError,
91
122
  OVERAGE_CAP_EXCEEDED: OverageCapError,
@@ -102,20 +133,27 @@ const TYPED_ERROR_REGISTRY = {
102
133
  ENVIRONMENT_NOT_FOUND: EnvironmentNotFoundError,
103
134
  UNSUPPORTED_FILE_TYPE: UnsupportedFileTypeError,
104
135
  INSUFFICIENT_ROLE: InsufficientRoleError,
136
+ MISSING_API_KEY: MissingApiKeyError,
137
+ INVALID_API_KEY: InvalidApiKeyError,
138
+ API_KEY_EXPIRED: ApiKeyExpiredError,
139
+ PROJECT_OUT_OF_SCOPE: ProjectOutOfScopeError,
105
140
  };
106
141
  export function createApiClient(baseUrl) {
107
- const url = baseUrl ?? process.env.POLI_API_URL ?? DEFAULT_API_URL;
142
+ const origin = baseUrl === undefined ? apiOrigin() : assertTrustedApiOrigin(baseUrl);
108
143
  async function request(path, options = {}) {
109
- const fullUrl = `${url}${path}`;
144
+ const fullUrl = new URL(path, origin).href;
110
145
  let response;
111
146
  try {
112
147
  response = await fetch(fullUrl, {
113
148
  ...options,
114
149
  headers: {
115
150
  'Content-Type': 'application/json',
116
- Origin: url,
151
+ Origin: origin,
117
152
  ...options.headers,
118
153
  },
154
+ // A 307/308 would re-send the body (project files, the password)
155
+ // to wherever the API points it.
156
+ redirect: 'error',
119
157
  });
120
158
  }
121
159
  catch (err) {
@@ -170,6 +208,12 @@ export function createApiClient(baseUrl) {
170
208
  });
171
209
  return response.json();
172
210
  },
211
+ async signOut(session) {
212
+ await request('/api/auth/sign-out', {
213
+ method: 'POST',
214
+ headers: { Authorization: `Bearer ${session}` },
215
+ });
216
+ },
173
217
  async getOrganizations(session) {
174
218
  const response = await request('/api/organizations', {
175
219
  headers: {
@@ -180,7 +224,7 @@ export function createApiClient(baseUrl) {
180
224
  return response.json();
181
225
  },
182
226
  async listProjects(session, orgId) {
183
- const response = await request(`/api/organizations/${orgId}/projects`, {
227
+ const response = await request(`/api/organizations/${idSegment(orgId, 'organization')}/projects`, {
184
228
  headers: {
185
229
  'Content-Type': 'application/json',
186
230
  Authorization: `Bearer ${session}`,
@@ -189,7 +233,7 @@ export function createApiClient(baseUrl) {
189
233
  return response.json();
190
234
  },
191
235
  async createProject(session, orgId, payload) {
192
- const response = await request(`/api/organizations/${orgId}/projects`, {
236
+ const response = await request(`/api/organizations/${idSegment(orgId, 'organization')}/projects`, {
193
237
  method: 'POST',
194
238
  headers: {
195
239
  'Content-Type': 'application/json',
@@ -312,7 +356,7 @@ export function createApiClient(baseUrl) {
312
356
  return Buffer.from(await response.arrayBuffer());
313
357
  },
314
358
  async patchFiles(session, orgId, projectId, body) {
315
- const response = await request(`/api/organizations/${orgId}/projects/${projectId}/files`, {
359
+ const response = await request(`/api/organizations/${idSegment(orgId, 'organization')}/projects/${idSegment(projectId, 'project')}/files`, {
316
360
  method: 'PATCH',
317
361
  headers: {
318
362
  'Content-Type': 'application/json',
@@ -357,7 +401,7 @@ export function createApiClient(baseUrl) {
357
401
  if (orgIdHeader) {
358
402
  headers['X-Poli-Org-Id'] = orgIdHeader;
359
403
  }
360
- const response = await request(`/v1/projects/${encodeURIComponent(project)}/publish`, {
404
+ const response = await request(`/v1/projects/${idSegment(project, 'project')}/publish`, {
361
405
  method: 'POST',
362
406
  headers,
363
407
  body: JSON.stringify(body),
@@ -369,7 +413,9 @@ export function createApiClient(baseUrl) {
369
413
  async function buildApiError(response) {
370
414
  const text = await response.text();
371
415
  const retryAfter = parseRetryAfter(response.headers.get('Retry-After'));
372
- const { code, message } = parseErrorBody(text, response.status);
416
+ const { code, message: serverText } = parseErrorBody(text, response.status);
417
+ // Command error handlers print the message to stderr as is.
418
+ const message = oneLine(serverText);
373
419
  const typed = code ? TYPED_ERROR_REGISTRY[code] : undefined;
374
420
  if (typed) {
375
421
  return new typed(message, retryAfter);