# @cloudpdf/server ## 3.3.0 ### Minor Changes - [#1093](https://github.com/embedpdf/embed-pdf-viewer/pull/1093) by [@bobsingor](https://github.com/bobsingor) – A change analysis is never refused for the rules it was asked under. The rules that judge what a signature allows after it are now a part of the `analysis` engine value in `/head`, as the API evolution convention has every rule the server computes with. Before, a client put the number of those rules in the analysis URL (`policy`), and the server answered `InvalidArg` for any number but its own. A server on new rules refused every older viewer, which then showed "what changed since the signature" as indeterminate. - `GET …/signatures/analysis@`: a token that carries `policy`, as a client of 3.0 to 3.2 writes it, is answered like any other. The token's engine value decides whether the answer is cached. - `GET …/versions/analysis/:sha256` takes `engine`, the `analysis` value from `/head`. With this server's value a settled answer is `immutable`. With another value, or with none, the answer is this server's own, with `no-store` and the current value in `EmbedPDF-Engine`. A `policy` parameter is ignored. - An analysis that a worker judged under other rules, in the middle of a deploy, is answered uncached. It was an error. - `GET …/versions/signatures/:sha256` takes `engine` too, the `signatures` value from `/head`, with the same rule: `immutable` with this server's value, `no-store` with another or with none. It was `immutable` whatever the server read from the file, so a field added to that answer could not have reached a cache that held the old one. - The `analysis` engine value changes once with this release, so cached analyses are computed again. - [#1088](https://github.com/embedpdf/embed-pdf-viewer/pull/1088) by [@bobsingor](https://github.com/bobsingor) – Validation data for signatures, and a document timestamp with no field. - `GET /v1/docs/:docId/layers/:layerName/signatures/validation-info` answers the certificates, OCSP responses and CRLs the layer's file holds, each as base64. Its `@token` form is pinned at `docVersion` and cached like the signature list. It needs `doc.forms.read`. - `POST` to the same path stores more. Each entry is checked to be one DER object of at most 16 MiB, an entry the file already holds is not stored again, and the answer counts the new ones. It needs `doc.sign` for the document, and a certification that allows no changes forbids it. The document version moves, and the audit row, of the new kind `signature.addValidationInfo`, carries the counts and never the entries. A client older than 3.3 gets a full refresh in its place. - The server asks no certificate authority: it stores what it is given. - `POST …/signatures/prepare` takes a document timestamp with no `field`. The worker makes the field, the answer names it in `field`, and it needs `doc.sign` for the document. - Changing the metadata of a layer is now refused after a certification that allows no changes, before the write reaches a worker. ## 3.2.0 ### Minor Changes - [#1071](https://github.com/embedpdf/embed-pdf-viewer/pull/1071) by [@bobsingor](https://github.com/bobsingor) – `POST …/changes` takes the new op `annotations.copy`: copies of annotations in the same document, with a stamp's drawing and an attachment's file copied on the server. It needs `doc.annotate.read` and the right to create each kind, not `doc.download`. A ref the document doesn't have refuses the change with `NotFound`. On the event stream, a client that says a version before 3.2 gets `full-refresh` in place of a change with this op. A copy stays within the server's `bundleLimits`: past one, its change is refused with `PayloadTooLarge`, and `details.limit` names the limit. - [#1056](https://github.com/embedpdf/embed-pdf-viewer/pull/1056) by [@bobsingor](https://github.com/bobsingor) – The event stream answers each client as its version reads. A change with a kind that arrived after the client's `EmbedPDF-Version` goes out as `full-refresh` in the row's place, and the stream carries on with the rows after it; a `full-refresh` now says why in its data (`reason`). An op of `POST …/changes` with a field the server doesn't know refuses the request with `InvalidArg`, naming the field, where the field used to be dropped and the op applied without it. An item of a kind the server doesn't know is withheld from a connection that may not read everything. - [#1075](https://github.com/embedpdf/embed-pdf-viewer/pull/1075) by [@bobsingor](https://github.com/bobsingor) – `POST …/changes` takes the new op `forms.copy`: a new field from each field named, with its widgets, made on the server. It needs `doc.forms.modify`, and `doc.forms.script` to keep scripts, submits and links. A field the form doesn't have refuses the change with `NotFound`. On the event stream, a client that says a version before 3.2 gets `full-refresh` in place of a change with this op. A copy stays within the server's `bundleLimits`: more fields than `items` refuses its change with `PayloadTooLarge`. ## 3.1.0 ### Minor Changes - [#1030](https://github.com/embedpdf/embed-pdf-viewer/pull/1030) by [@bobsingor](https://github.com/bobsingor) – Layers and versions keep `viewports_version` (migration 053), raised by a scale change and by nothing else, so the outline, search and export caches stay warm across one. The layout's cached URL carries it; a token without it gets the layout without viewports. `PUT …/pages/:pageKey/scale` is a one-op change, so its opId undoes it. The changes endpoint applies `pages.setScale`. ## 3.0.0 ### Major Changes - [#720](https://github.com/embedpdf/embed-pdf-viewer/pull/720) by [@bobsingor](https://github.com/bobsingor) – Adds the tenant-scoped backend API and root API-token workflow to the self-hosted CloudPDF server. - Replaces the legacy flat admin routes with contract-backed `/v1/tenants/:tenantId` document, tenant, token, and deployment operations. - Adds constant-time root API-token authentication alongside delegated tenant JWT authorization. - Adds tenant lifecycle and provenance tracking, keyset pagination and state filtering, and cascade deletion for tenant-owned data. - Adds document and tenant token issuance, revocation, and durable security-event auditing. - Allows API tokens on document-plane routes and supports per-request `X-Document-Password` authorization through HMAC proofs or non-mutating checks against the canonical PDFium session, including credential-safe open singleflight behavior. - Adds matching SQLite and PostgreSQL migrations plus expanded registry, authorization, password, and end-to-end coverage. - [#711](https://github.com/embedpdf/embed-pdf-viewer/pull/711) by [@bobsingor](https://github.com/bobsingor) – Introduces the self-hostable CloudPDF document server. The Fastify service combines authentication, durable storage, native PDF processing, realtime document events, and commercial license enforcement behind the Engine v3 HTTP API. ### Minor Changes - [#788](https://github.com/embedpdf/embed-pdf-viewer/pull/788) by [@bobsingor](https://github.com/bobsingor) – Persist per-layer annotation versions and add versioned page and whole-document annotation reads with audit-head metadata. Expose a no-store backend endpoint for listing every annotation in a layer. Annotation mutations now advance the version atomically so clients can hydrate and retry against coherent snapshots. - [#803](https://github.com/embedpdf/embed-pdf-viewer/pull/803) by [@bobsingor](https://github.com/bobsingor) – Add `POST /v1/docs/{docId}/layers/{layerName}/annotations/pages/{pon}/items/flatten` (flatten a chosen set of the page's annotations; gated like page flatten and persisted the same way — one page's content and annotation versions advance) and `POST …/items/appearance` (the chosen annotations' appearances as one single-page PDF; gated by `doc.download`, no-store). Add `POST /v1/docs/{docId}/layers/{layerName}/pages/names` and `POST …/pages/names/delete` to register, rename, or remove a `/Names /Pages` entry on a layer. Both are page-structure mutations gated by `doc.pages.assemble`: the worker writes a new layer artifact and the doc and layout versions advance, exactly like a page move, with no new resource, version, or cache scope. `/layout` responses now include `namedPages`. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – The appearance endpoint returns every mode and state an annotation stores, each manifest entry labelled with its `state`, and accepts `modes` as a filter. Annotated page renders draw form fields unless the token says `formFields=false`. - [#902](https://github.com/embedpdf/embed-pdf-viewer/pull/902) by [@bobsingor](https://github.com/bobsingor) – Archive share links instead of losing what their visitors made. Archiving (migration 041) stops a link's exchange for good, like a revoke, but keeps the link and its visitors' layers, still listed with `documents.layers.list?shareId=` and downloadable. Deleting a link is refused with 409 while its visitors have layers; one whose visitors only looked can still be deleted. An archived link refuses updates, is left out of `shares.list` unless `archived=true`, and no longer keeps its shared layer from being deleted. Its visitors' layers keep to the link's idle setting. - [#766](https://github.com/embedpdf/embed-pdf-viewer/pull/766) by [@bobsingor](https://github.com/bobsingor) – Add durable asynchronous document imports backed by the `document_imports` job table and an in-process worker with one claim loop per replica. Document and job creation is atomic, lease-token-fenced transitions prevent stale workers from overwriting replacements, reconcile-on-claim avoids duplicate transfers after crashes, and exhausted retries fail the document and clean destination bytes. Retries stay pinned to one content identity, filesystem sources require `expected.sha256`, and queued or running imports are protected from the stale-pending sweeper. Migration 027 stores the re-drivable source descriptor in `source_json`. - [#891](https://github.com/embedpdf/embed-pdf-viewer/pull/891) by [@bobsingor](https://github.com/bobsingor) – Attachments are changes: `POST …/changes` takes `attachments.create` (its file as a `resource:` part) and `attachments.delete` under `doc.attachments.modify`, and undoes them by `opId`. The routes `POST …/attachments` and `DELETE …/attachments/{fileKey}` are removed, and file downloads no longer carry `X-EmbedPDF-File-Name` and `X-EmbedPDF-File-Type`: the listing has both. New current reads: `GET …/attachments`, `GET …/attachment-files/{fileKey}/data` and an annotation's `GET …/items/{annotKey}/resources/file`. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – `/v1/access` advertises the bundle limits as `bundleLimits`, and the app option is `bundleLimits`. The multipart reader for bundle imports serves any bundle family; annotation imports are unchanged. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Stops work for clients that went away: a request whose client disconnects before its reply is sent now aborts its engine job, where before no disconnect was ever detected. A render shared by several requests stops only once all of them have left. Serve the revised document, page, annotation, form, and rendering contracts, including object-number page references, page-space geometry, annotation transfer, custom metadata, and signature-aware mutation checks. - [#944](https://github.com/embedpdf/embed-pdf-viewer/pull/944) by [@bobsingor](https://github.com/bobsingor) – A tenant token hands out only the document permissions it holds itself. `tokens.issue` with kind `doc`, `grants.create`, and `grants.update` when it changes the scope answer `403 Forbidden` naming what the token doesn't hold. A key with `tokens.issue-doc`, `doc.open` and `doc.render` mints reading tokens and nothing more. The API token and `*` hold everything, as before. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Every layer write sends its worker job an `opId`: the request's `Idempotency-Key`, or one minted for the write. Results' `meta` carry `opId` and `undoable`; page-structure, metadata, attachment and signing results take them from the write. Add `POST /v1/docs/{docId}/layers/{layerName}/changes`: user actions, each a change whose ops apply in order in one layer transaction, all or none, or `{ opId, undoOf }`, the undo of an earlier change. One request runs as one worker job and one commit: each change stands on its own (a refused one rolls back alone), and the 200 answers every change in order, applied with its result or refused with its error. Bytes travel as multipart `resource:` parts the JSON names by key. At most 64 changes per request and 512 ops per change. Each answered change keeps its answer under its `opId` in the new `change_outcomes` table (migration 033), refusals included, so a retry gets the same answer and a different change under an answered `opId` is refused (`IdempotencyKeyReused`). An applied change keeps what undoes it: a record beside its answer and its captures as one object-store blob. Only the user who made a change may undo it; a redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (`layers.undo_horizon`, `UndoUnavailable`). Answers are kept 30 days (`CLOUDPDF_CHANGE_RETENTION_DAYS`); the sweeper deletes expired answers with their captures, and the records and captures of changes no undo can reach. Every change that wrote gets one audit row (kind `change`, its `opId` as idempotency key, `undo_of` naming what an undo undid). The single-op annotation, form and metadata routes now run as one-change requests: their audit rows keep their kinds and payloads, and their `Idempotency-Key` names the change, so `{ undoOf }` undoes them. The event stream's rows carry `undoOf`. - [#793](https://github.com/embedpdf/embed-pdf-viewer/pull/793) by [@bobsingor](https://github.com/bobsingor) – Action reads served by `/v1/docs/:docId/actions@:token` (and the layer-scoped variant) now include interpreter payloads on every executable node and the destination-form `/OpenAction` as `openDestination`, via the shared engine-services reader. The wire representation of action nodes changed shape (payload-carrying discriminated union); deploy server and clients from the same prerelease train. - [#748](https://github.com/embedpdf/embed-pdf-viewer/pull/748) by [@bobsingor](https://github.com/bobsingor) – Derives the connected usage-reporting credential from the license key, so a connected deployment is configured with `CLOUDPDF_LICENSE_KEY` alone. - Computes the reporting credential as `cpr_v1_` + base64url(HMAC-SHA256) over a domain-separated message that binds the signed `cloudpdfLicenseId` license metadata, so the wire credential is one-way (it can never reveal the license key) and never authenticates another license record. - Retires `CLOUDPDF_LICENSE_REPORTING_TOKEN`. A deployment that still sets it boots normally; the variable is ignored and the server logs a warning asking for its removal. - Existing connected deployments upgrade by removing the retired variable. During the coordinated verifier cutover on the CloudPDF side a usage report may answer 401; reports retry every five minutes with cumulative counters, so no usage is lost and license validation is unaffected. - Air-gapped deployments are unchanged and continue to send no telemetry. - Pins fixed cross-runtime derivation test vectors shared with the CloudPDF control plane. - [#746](https://github.com/embedpdf/embed-pdf-viewer/pull/746) by [@bobsingor](https://github.com/bobsingor) – Fixes presigned-upload materialization and makes commit-time sha verification single-read and constant-memory. - Fixes the range materializer crashing with `EBADF` whenever an object carried no SHA metadata — the shape of every presigned browser upload. The failure was silent: commits still reached `ready` while the security probe recorded `unknown` and thumbnail warming recorded `failed`. The hash fallback now closes the write-only handle and streams the finished partial from disk, guards against short positional writes, and rejects a metadata/expected-sha disagreement before paying for the download. - Replaces the S3 and FS `getSha256` fallbacks that buffered whole objects in RAM with streaming hashes — constant memory regardless of document size. - Commit now verifies uploaded bytes with a single object-store read when a base-file cache is wired (`DocumentLifecycleOptions.fileCache`): the upload is materialized into the cache, hashed on the way down, and reused by the security probe instead of being downloaded a second time. `LocalFileHandle.sourceKey` reports which object key materialized a content-addressed entry, so a cross-key cache hit still triggers a direct verification of the committing document's own object. - Adds a typed `ShaMismatchError` (exported) thrown by all `materializeLocal` implementations, letting callers distinguish declared-hash mismatches from retryable transport failures. - Surfaces previously swallowed failures: `DocumentSecurityProbeOptions.onError`, `DerivedRenderServiceOptions.onWarmError`, and base-file-cache `materialize-error` events are now wired to the server log. - [#730](https://github.com/embedpdf/embed-pdf-viewer/pull/730) by [@bobsingor](https://github.com/bobsingor) – Implements share grants, origin locking, per-tenant usage, and tenant suspension. - Stores share grants whose row id is the public share token, carrying document capabilities, an optional origin allowlist, an optional scrypt-hashed passphrase, a session TTL, and an optional expiry. Editing or deleting a grant retargets every embedded copy of its token at the next exchange. - Serves the public `POST /v1/share-sessions` exchange, which validates origin, passphrase, expiry, disablement, and tenant suspension before minting a document session JWT. Unknown, revoked, disabled, and suspended grants answer alike so the existence of a grant is never disclosed, and the route carries its own per-IP and per-grant limiters rather than the authentication-failure budget. - Enforces an optional `origins` claim on document tokens for every request that arrives with a browser `Origin` header, covering both share sessions and backend-minted tokens. Requests without the header are governed by the token itself. - Adds CORS through `CLOUDPDF_CORS_ORIGINS` (`*` to reflect, or a comma-separated allowlist), which browser-direct deployments need. Bearer tokens remain the security boundary; per-credential origin locks carry the origin policy a server-wide list cannot express. - Records per-tenant usage facts for views, uploads, and stored bytes, readable at `GET /v1/tenants/:tenantId/usage`. A view is a share exchange or an authorized `/v1/access` grant, counted once across the two. These counters hold no limits and are separate from license metering. - Adds `tenants.suspend` and `tenants.resume`, which fail every tenant JWT, document JWT, and share exchange closed while leaving the root API token free to inspect, resume, or delete the tenant. - Mounts token revocation from the CLI through `CLOUDPDF_ENABLE_REVOCATION`. - Records share and suspension lifecycle events in the security-event trail, and adds matching SQLite and PostgreSQL migrations plus origin, passphrase, and end-to-end share coverage. - [#766](https://github.com/embedpdf/embed-pdf-viewer/pull/766) by [@bobsingor](https://github.com/bobsingor) – Add operator-registered import connections through `CLOUDPDF_IMPORT_CONNECTIONS` for S3 and S3-compatible stores, GCS, Azure Blob, and filesystem roots. Connections enforce credential classes, tenant allowlists, scoped prefixes or tenant-bound key templates, provider-specific revision pinning, and fail-closed authorization. Canonical backend fingerprints reject self-imports, and each import records sanitized source provenance and outcome in the new `document_imports` table from migration 026. A shared conformance suite keeps URL and connection adapters aligned on source-opening behavior. - [#991](https://github.com/embedpdf/embed-pdf-viewer/pull/991) by [@bobsingor](https://github.com/bobsingor) – Layers and base versions store `contents_version` (migration 052), raised in the same transaction as a flatten, a redaction or a change to the page set, and published in the manifest. Versioned searches pin it with `layoutVersion` instead of a content epoch, so an annotation write keeps every cached search and a content write refreshes them; the unversioned search form takes the same two pins as optional parameters. - [#734](https://github.com/embedpdf/embed-pdf-viewer/pull/734) by [@bobsingor](https://github.com/bobsingor) – Adds integrity-pinned uploads with presigned storage transfer preferred and a policy-controlled multipart proxy fallback. Hardens filesystem-backed storage against path traversal, storage-root deletion, and recursive deletion through symbolic links. - [#917](https://github.com/embedpdf/embed-pdf-viewer/pull/917) by [@bobsingor](https://github.com/bobsingor) – Organize documents in folders. Folders nest up to 100 levels with names unique among siblings, ignoring case. A move takes documents and folders together or not at all and never makes a loop, even when two moves race; only empty folders delete. Documents are filed at upload and listed per folder, and a document being deleted leaves its folder. Migration 046 adds the `folders` table and `documents.folder_id`. Errors thrown with structured context now return it as `details`. - [#941](https://github.com/embedpdf/embed-pdf-viewer/pull/941) by [@bobsingor](https://github.com/bobsingor) – Every worker registers Noto Sans Hebrew and Noto Naskh Arabic as fallback fonts, tried after the deployment's own (`CLOUDPDF_FONTS`), so Hebrew and Arabic draw with no setup. A key the deployment uses keeps its font. The server's fonts (`CLOUDPDF_FONTS`, renamed from `CLOUDPDF_FALLBACK_FONTS`; `buildApp({ fonts })`, `ServerFontDescriptor` and `loadServerFontsFromEnv()`) take `serve`: a served font's file goes to a client that may write text, at one URL for every document (`/v1/font-program-files/{hash}`, `private, immutable`), so the viewer types in it; a font not served is listed with `'not-served'`. Noto Sans Hebrew and Noto Naskh Arabic are served. A document's fonts on the cloud: `GET …/fonts@{fontsVersion,serverFonts}` (the base's shared URL while a layer draws what the base does), `POST …/fonts/resolve`, a program's facts at `…/font-programs/{hash}` and its bytes at `…/font-program-files/{hash}` (for a token with `doc.annotate.modify`, `doc.forms.fill`, `doc.forms.modify` or `doc.redact` that the document's signatures leave it, `private`, never on the CDN). The manifest's `fontsVersion` (migration 049, on layers and base versions) moves with every write the engine says changed the fonts the list shows, and its `CacheDelta` carries it. The manifest's `serverFonts`, a fingerprint of the server's fonts, is in the font list's URL and every picture's, rendered and stored: a change of the server's fonts draws every page again once, and a replica answers only URLs with its own. - [#917](https://github.com/embedpdf/embed-pdf-viewer/pull/917) by [@bobsingor](https://github.com/bobsingor) – Store a name for every document, searchable and sortable without regard to case, and rename documents with `PATCH /v1/tenants/:tenantId/documents/:id` under the new `docs.update` scope. The documents list searches by name, sorts by creation time, name or size in either order with stable cursors, and hides documents that are being deleted unless asked for by state. Migration 045 names existing documents from `metadata.name` when it is a non-empty string, otherwise from their id. - [#885](https://github.com/embedpdf/embed-pdf-viewer/pull/885) by [@bobsingor](https://github.com/bobsingor) – The document's outline: `GET /v1/docs/:docId/outline@{token}` (shared and cacheable while a layer inherits the outline and the layout) and `GET /v1/docs/:docId/layers/:layerName/outline`, with outline edits through `POST …/changes`. Layers and published versions carry an outline version (migration `035_outline_version`), outline ops move it, and its plane decides when a layer reads the shared outline. A token that may change the outline (`doc.outline.modify`) is handed object numbers for new items, as one that may create annotations is. - [#766](https://github.com/embedpdf/embed-pdf-viewer/pull/766) by [@bobsingor](https://github.com/bobsingor) – Implement server-side PDF imports from caller-supplied URLs through the existing document lifecycle. Deployment policy controls size, timeout, concurrency, HTTPS, and public-network requirements; URL handling blocks private and metadata addresses with DNS pinning, rejects redirects, and requires `Content-Length`. Imports enforce optional size and SHA-256 pins, sanitize failures so URL secrets do not leak, leave documents pending after retryable transport failures, and add the `pull` upload kind in migration 025. - [#902](https://github.com/embedpdf/embed-pdf-viewer/pull/902) by [@bobsingor](https://github.com/bobsingor) – Incremental downloads no longer go through the engine. A layer's PDF saved incrementally, the default, is now its base file followed by the delta its stored artifact holds, streamed from storage with the same permission and password checks as before; a layer nobody wrote downloads as its base file, and a signed file's bytes stay exactly as stored. A rewrite (`mode=rewrite`) is still saved by the engine. Download links: `POST …/layers/{layerName}/download-link` returns a URL that downloads the layer's current PDF without an Authorization header, for services that only take a plain URL. The URL is the layer's versioned download with a `link` token that opens nothing else: it isn't accepted as a bearer token, it works only for the version it was made for (404 once the layer changes), it expires after `expiresIn`, and a password-protected document is checked when the link is made. Deployments that verify tokens with their own keys can mint the same link on their backend, as a doc token with `layer_name` and a `download` claim. - [#989](https://github.com/embedpdf/embed-pdf-viewer/pull/989) by [@bobsingor](https://github.com/bobsingor) – `/head` carries this server's engine value for each kind of cached read: a digest of the rules and fonts it computes that kind with, never of its release, so a deploy that changes nothing keeps every cached answer. Every versioned read checks the token's engine value and shape: a shape newer than the server answers is refused, and another engine value is answered with this server's own answer, uncached, and its value in `EmbedPDF-Engine` (exposed to browsers), so nothing is cached under a value that doesn't describe it and no request fails during a rolling deploy. Renders are stored by engine value. The manifest no longer carries `serverFonts`. - [#994](https://github.com/embedpdf/embed-pdf-viewer/pull/994) by [@bobsingor](https://github.com/bobsingor) – Every error response is `{ error: { code, message, details? } }` with a code from `EngineErrorCode`. An engine error no longer carries `name`. A license refusal is `LicenseInvalid` with the license status's code in `details.licenseCode`; a usage limit says its `metric` and `limit` in `details`; a thumbnail that isn't ready says its state in `details.state`; `BadInput` is `InvalidArg`; and an error from Fastify itself carries the code for its status instead of Fastify's own. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Form writes stamp field attribution from the token's identity: creating a field, filling one in, and the values a script run writes. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Field groups on the server: - **Fill and sign routes** (a value, a reset, a signature look, a values import, signing) accept a token that may fill in or sign some field: `doc.forms.fill` / `doc.sign`, or a `fields:` scope. The write checks each field against the token's grants. - **Design routes** send the grants too, for the group checks. - **Identity:** the verified identity claim drops `groups`, and `/v1/access` no longer echoes it. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – `POST …/form/calculations/reorder` (`doc.forms.reorderCalculations`, audit kind `form.reorderCalculations`). Creating or updating a field with scripts takes `doc.forms.script` too. - [#917](https://github.com/embedpdf/embed-pdf-viewer/pull/917) by [@bobsingor](https://github.com/bobsingor) – Delete a folder with everything in it via `recursive=true`: the folder and every folder under it go in one transaction, and every document in them stops opening, leaves every list and stops answering its share links at once, while their stored files are removed in the background. The sweeper now also finishes deletes left behind, such as one interrupted by a crash, after `deletingGraceMs` (default one minute). The filesystem object store no longer fails a write when a delete elsewhere in the same tenant prunes the directories the write has just made. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Form bundle routes replace `form/data`: `GET …/form/export@:token` (doc and layer, cacheable at the form and layout pins), `POST …/form/export` for a selection a URL can't carry, and multipart `POST …/form/import` and `POST …/form/import-values`, each one change under its `Idempotency-Key`, audited as `form.import` and `form.importValues`. The FDF/XFDF content-type parsers are gone. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – The form is its own read family: - **New routes:** `form@{formsVersion}` and `form/pages/{p}/appearances@{widgetVersion}`, each with its layer twin (and an unversioned layer appearance route), needing `doc.forms.read`; `PATCH …/form/widgets/{pageKey}/{annotKey}` (`doc.forms.updateWidget`). - **Pins:** migration 034 adds `layers.forms_version`, `base_versions.forms_version` and `widget_version` on page rows. Form writes move the form's pins, never the annotation pins; annotation writes the reverse. Page insert/delete, flatten and redaction move both. Plane scopes compare the document pins too, and gain `forms`. - Annotation reads and appearance batches hold no widgets. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – `DELETE /v1/docs/:docId/layers/:layerName/form/widgets/:pageKey/:annotKey` deletes a widget (`doc.forms.modify`), audited as `form.deleteWidget`. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – - `POST /v1/docs/:docId/layers/:layerName/form/effects` is removed: a script run's effects are one change, `POST …/changes`. - A reset of fields already at their defaults, or a display that changes no widget, writes nothing: it can't be undone. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – - Pages report their tab order and list boxes their top row. - A widget update that changes only its colour or size keeps its font; a free text's border colour change keeps its font. - A value write that changes nothing records no undo step. - [#918](https://github.com/embedpdf/embed-pdf-viewer/pull/918) by [@bobsingor](https://github.com/bobsingor) – Share links are grants: routes under `/v1/tenants/{tenantId}/grants`, the `grants.manage` scope, and the public exchange at `POST /v1/grant-sessions`, which takes `{ grant, passphrase }`. Migration 047 renames `share_grants` to `grants` and `share_visitors` to `grant_visitors` with their indexes and constraints, renames `password_hash` to `passphrase_hash`, and adds a grant's `name`. New grants are `grt_…`, and `shr_…` grants keep working. Session tokens name `grant:`, and `security_events` records `grant.created`, `grant.updated`, `grant.archived` and `grant.revoked`. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – An annotation import is a change: kept in the change outcomes under its `Idempotency-Key` with the record that undoes it, so `POST …/changes` with `{ undoOf }` undoes and redoes it, and a retry is answered from the outcome. Still audited as `annot.import`. - [#996](https://github.com/embedpdf/embed-pdf-viewer/pull/996) by [@bobsingor](https://github.com/bobsingor) – Every point in time the server sends is an ISO 8601 string in UTC, and a grant's and a token revoke's `expiresAt` are taken as one, with its offset. Rows keep their milliseconds. The admin routes' records are typed by the contract's, so a field the contract doesn't say no longer compiles. - [#902](https://github.com/embedpdf/embed-pdf-viewer/pull/902) by [@bobsingor](https://github.com/bobsingor) – Delete a layer with `DELETE /v1/tenants/{tenantId}/documents/{id}/layers/{layerName}`. Its artifacts, renders, change captures, changes, audit rows, signings, password sessions and object numbers go, and its worker session closes. A layer that was written keeps its row as a tombstone (migration 037), and every route then answers its name with `LayerDeleted` (HTTP 410), because its read URLs were cached as immutable and a new layer under the name would restart at the same versions. A layer nobody wrote leaves no tombstone and stays usable. A write in flight on another replica loses its commit to the delete. Deleting a layer a share link uses is refused with 409, and a share link can't be created for a deleted layer. - [#902](https://github.com/embedpdf/embed-pdf-viewer/pull/902) by [@bobsingor](https://github.com/bobsingor) – List a document's layers with `GET /v1/tenants/{tenantId}/documents/{id}/layers`: newest first, cursor-paged like documents, tenants and shares, optionally only one share link's visitors' layers (`shareId`). This is how a link's owner finds what visitors filled in and downloads it through the layer's routes. Migration 040 replaces the per-document layer index with one in list order. - [#827](https://github.com/embedpdf/embed-pdf-viewer/pull/827) by [@bobsingor](https://github.com/bobsingor) – Persist page measurement calibration in layer artifacts with authorization and audit events. Calibration advances the document version while retaining existing page cache versions and annotation scales. - [#967](https://github.com/embedpdf/embed-pdf-viewer/pull/967) by [@bobsingor](https://github.com/bobsingor) – Modules describe themselves, and count their usage. A module has a `name` (required) and a `description`, and declares `meters` (each with a `label` and a `unit`) that its routes count with `req.meters.count(meter, { oncePerDay })` for the document's tenant. A permission can say how it relates to the core's: `replaces` (`protected-display.view` replaces `doc.render`) and `bypassedBy` (`doc.download`…), facts for a grant dialog that the server doesn't enforce; a token may hold a permission and the one it replaces, and the core one has its usual effect. `GET /v1/deployment/modules` lists the installed modules as they declare themselves, with the API token. Tenant usage is counted per UTC day: `tenants.usage` takes `from` and `to` in place of `period`, and reports each installed module's meters next to the core's. Migration 051 moves the counters to days (a month counted before keeps its total on its first day) and keeps the once-a-day keys as hashes, swept when the day is over. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Every multipart request and answer has one shape: a JSON `body` part, and each file as a part `resource:` that the body names by role, `resources: { : }`. Annotation create and update, page insert, attachments, a signature's drawn appearance, signature prepare and change ops name their files this way; bundle imports and exports and appearance batches call their JSON part `body`, and an appearance batch's images are `resource:` parts. A named key with no part, and a part nothing names, are refused. - [#997](https://github.com/embedpdf/embed-pdf-viewer/pull/997) by [@bobsingor](https://github.com/bobsingor) – Takes and sends the renamed fields: `sizeBytes` (documents, layers, versions), `baseSha256`, the manifest's `baseSizeBytes`, `uploadTtlSeconds`, `expiresInSeconds` (also the editing session's on `/access`, the event stream and object-number reservations), `docIds` and the camelCase usage metrics (module meters in `moduleMeters`), and names its path parameters `docId`, `annotationKey`, `sha256` and `displaySha256`. - [#940](https://github.com/embedpdf/embed-pdf-viewer/pull/940) by [@bobsingor](https://github.com/bobsingor) – Accept the `pages.copy` change op and object numbers on `pages.insert`. Copies are counted as new pages for the layer's page set and object number estimates, and page list answers carry the page label sections (`labels`). - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Serve the four page picture families at both tiers: `render/pages`, `render/annotations`, `render/fields` and `render/all` (renamed from `render/annotated`, which now draws form fields too). Each takes `doc.render` plus the read of what it draws, pins the page counters of the planes it draws, and is stored under its own family. - [#830](https://github.com/embedpdf/embed-pdf-viewer/pull/830) by [@bobsingor](https://github.com/bobsingor) – Serve page routes under `:pageKey` (`obj:N`; malformed keys answer 400), accept `pages`/`page` refs in page mutation, extraction, redaction and weak-session bodies, and emit `PageRef` page identity in every response and event while keeping storage keyed by page object number. - [#890](https://github.com/embedpdf/embed-pdf-viewer/pull/890) by [@bobsingor](https://github.com/bobsingor) – Page edits are changes: `POST …/changes` takes `pages.rotate`, `pages.reorder`, `pages.delete`, `pages.insertBlank` and `pages.insert` (its PDF as a `resource:` part) under `doc.pages.assemble`, and undoes them by `opId`. An undo of a delete brings the same pages back with fresh page pins, so no picture cached before they went is served for them. The routes `POST …/pages/reorder`, `/pages/rotate`, `/pages/delete`, `/pages/insert` and `/pages/insert-blank` are removed. - [#772](https://github.com/embedpdf/embed-pdf-viewer/pull/772) by [@bobsingor](https://github.com/bobsingor) – Add document routes for inserting PDF pages, creating blank pages, and extracting selected pages. Insert mutations persist the new page set and versions atomically and publish audit events for realtime collaborators. - [#931](https://github.com/embedpdf/embed-pdf-viewer/pull/931) by [@bobsingor](https://github.com/bobsingor) – Each kind of page picture needs its own permission and no other. Thumbnails have routes of their own, at the document's and a layer's path (`render/thumbnail/…`), and need `doc.render.thumbnail`, which `doc.render` includes: the whole page at 512 pixels on its long side, cached like print pictures and never classified against the render lattice. Print pictures no longer need `doc.render`: `doc.print` is enough, and `doc.print.high` for 300 DPI. `/access` lists `doc.render.thumbnail` in `effectiveScope` for a session with `doc.render`. A server module's raw render can ask for a thumbnail, which needs `doc.render.thumbnail` in its `requires.document`. - [#926](https://github.com/embedpdf/embed-pdf-viewer/pull/926) by [@bobsingor](https://github.com/bobsingor) – The server knows the plugin permissions its installed modules declare (`bundle.permissions`); a plugin whose permission is checked elsewhere, by a viewer plugin for example, is installed as a module that only declares permissions, which needs no document plane. Issuing a token or saving a grant that names a plugin permission no installed plugin declares is refused with `InvalidArg`. `/access` puts the installed plugin permissions a token holds (every one under `*`) into `effectiveScope`; a plugin permission whose plugin isn't installed is carried by the token but takes no effect. The app bundle also lists the routes it mounted (`routes`). Add server modules: packages that run inside the server with their own routes and permissions, written with the new `@cloudpdf/server-modules`. Name them in `CLOUDPDF_MODULES` (or pass `buildApp({ modules })`); each reads its settings from `CLOUDPDF__*`, and a module that won't load, misses a required setting, or asks for something other than core document permissions in `requires.document` stops the server at boot. A module's routes mount at `/v1/docs/:docId/layers/:layerName//…` behind `doc.open` and the module's own permission. Each request reaches the server's API through its own routes, in process (that connection reaches only this server, never a CDN or another host): as the caller, with their own token, and as the module, with a short-lived token for that document carrying `doc.open` and `requires.document`. Raw page pixels come from the host in the engine's own terms (`PageRenderOptions` in, a `PageRenderRaster` with its transform out), drawn as the module: everything the picture draws needs its permission in `requires.document`, with the local engine's defaults, and print pictures are refused. The host side is typed in the new `@cloudpdf/server/modules` entry. - [#964](https://github.com/embedpdf/embed-pdf-viewer/pull/964) by [@bobsingor](https://github.com/bobsingor) – A Postgres connection that fails while idle in the pool no longer crashes the server. A database restart or failover, `pg_terminate_backend`, or a proxy closing the connection used to reach Node as an uncaught `error` event from `pg.Pool`. The pool now drops that connection and opens a new one for the next query. `createPostgresDb` takes `onIdleConnectionError` to report these, and `cloudpdf-server` logs each one's message as a warning. - [#883](https://github.com/embedpdf/embed-pdf-viewer/pull/883) by [@bobsingor](https://github.com/bobsingor) – `POST /v1/docs/:docId/layers/:layerName/pages/extract` takes `flatten` (`{ usage?: 'display' | 'print' }`), `includeAnnotations` and `includeFormFields`, and returns the pages as they draw for that usage. A flattened copy passes on `doc.download` or `doc.download.flattened` (a signed document refuses the latter), and paints only what the token may read; the include options are refused without `flatten`. - [#883](https://github.com/embedpdf/embed-pdf-viewer/pull/883) by [@bobsingor](https://github.com/bobsingor) – Serve the print pictures at both tiers: each picture family printed at 150 DPI under `render/print/` (needs `doc.print`) and at 300 DPI under `render/print-high/` (needs `doc.print.high`), on top of the family's own rights. A print picture's token is its pins and its format; the server sizes it from the DPI and the paper. Print pictures are cached at their versioned URLs but never stored or refused by the render lattice. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – `POST …/pages/reorder`, `POST …/annotations/pages/{pageKey}/items/reorder` and `POST …/form/widgets/{pageKey}/reorder` replace the move routes; page inserts take a `position`. Audit kinds `annot.reorder`, `pages.reorder` and `form.reorderWidgets`. A reorder bumps only its family's pins: annotation reorders the annotation pins, widget reorders the form's. - [#800](https://github.com/embedpdf/embed-pdf-viewer/pull/800) by [@LazyCompiler](https://github.com/LazyCompiler) – The layer search routes (`/v1/docs/:docId/layers/:layerName/search/{rects,full}/data`) accept `ignoreWhitespace=true` alongside the other query flags and forward it to the engine, so a cloud search for `invoice` finds a letter-spaced `i n v o i c e`. Combining it with `regex=true` is rejected with `InvalidArg`, and the flag is carried by the search tokens that page through results. - [#783](https://github.com/embedpdf/embed-pdf-viewer/pull/783) by [@bobsingor](https://github.com/bobsingor) – Add a production Helm chart with validated SQLite and Postgres profiles, safety gates, smoke and crash drills, and OCI publishing tied to the server package version. Add Prometheus metrics, drain-aware bounded shutdown and readiness, serialized Postgres migrations, and fail-fast worker supervision. Add opt-in supervised engine-host process isolation with generation-fenced recovery, crash journaling, document quarantine enforcement, engine health reporting, and audited quarantine CLI commands. Repeated engine crashers can be observed or rejected with `DocumentQuarantined`, while native host crashes restart the engine without terminating the API server. Encode page renders, annotation appearances, and warm thumbnails inside engine workers by default so compressed images cross the engine boundary, with a temporary API-side encoding fallback. Add bounded interactive and background scheduling, per-host memory telemetry, controlled engine recycling, and deterministic engine sharding with per-shard readiness and metrics. Add `POST /v1/docs/:docId/layers/:layerName/access` as the canonical layer-tier access endpoint (identity rides the path on both axes; path/body mismatches are rejected), retaining two transitional aliases removed together before GA: the body-addressed `POST /v1/access` and the short-lived doc-tier `POST /v1/docs/:docId/access`. Head responses advertise the default-layer endpoint. Allow the `X-CloudPDF-Doc` affinity header (sent by default by current SDKs) through CORS and expose retry and image metadata response headers to browser clients. - [#955](https://github.com/embedpdf/embed-pdf-viewer/pull/955) by [@bobsingor](https://github.com/bobsingor) – `buildApp` takes the deployment's license as `license`: the runtime `createLicenseRuntime` made, and nothing else. It replaces `licenseGate`. Any other object, including a copy of a runtime, stops the build with an error naming `createLicenseRuntime`. The runtime is sealed: its methods can't be replaced, and `buildApp` enforces the license from the runtime behind it. `createLicenseRuntime` takes only `db`, `env`, `secretResolver` and `startTimer`, and passes nothing else on, so license verification always uses the identity compiled into the package. - [#812](https://github.com/embedpdf/embed-pdf-viewer/pull/812) by [@bobsingor](https://github.com/bobsingor) – Add durable two-phase digital signing with prepare, complete, abort, and expiry handling. Persist candidate data so completion can run on another replica, verify the supplied CMS, and reject completion when the document or layer has changed. Publish each completed signature as an immutable document version while retaining the document ID and version history. Consume the signing layer's edits into the new base and refresh document state across replicas. Add signature inspection and analysis routes, immutable version and revision downloads, and visual signature-field appearances. Use files and streaming storage transfers for signing candidates, with configurable temporary storage and signing expiry. - [#917](https://github.com/embedpdf/embed-pdf-viewer/pull/917) by [@bobsingor](https://github.com/bobsingor) – Tenant scopes act on records and document capabilities act on what is inside documents, on any token. A tenant JWT is checked inside documents the way a document JWT is, against the document capabilities its scope names, which hold for every document of the tenant; `docs.read` lists documents but no longer opens, reads or changes them. Downloading the original file needs `doc.download` and the thumbnail needs `doc.render`. A tenant token whose scope names no document capability is refused on the document routes, and `tokens.issue` validates a tenant token's scope entries. - [#956](https://github.com/embedpdf/embed-pdf-viewer/pull/956) by [@bobsingor](https://github.com/bobsingor) – Tenants have `features`: the server modules each tenant may use, by module id. A module's routes answer only tenants whose features hold it; others get `403 FeatureNotEnabled`, and a feature held as `{ id, stopped: 'cap' }` answers `402 FeatureStopped`. A new tenant has none: the operator turns modules on per tenant with `PATCH /v1/tenants/:tenantId` (API token only, every id an installed module), and other replicas follow within 30 seconds. Migration 050 adds the column on SQLite and Postgres. - [#925](https://github.com/embedpdf/embed-pdf-viewer/pull/925) by [@bobsingor](https://github.com/bobsingor) – Upload tokens let a browser upload straight to CloudPDF. `tokens.issue` with kind `upload` makes one for a folder, with your metadata, a file count (one by default), an optional size limit and an origin lock. The token reaches only init, commit and the proxy upload. There it uploads into its folder with its metadata, whatever the request says, and commits only the documents it started. Every other route refuses it. Migration 048 adds `documents.upload_token_jti` and the `upload_token_uses` table, which counts each token's documents atomically. - [#992](https://github.com/embedpdf/embed-pdf-viewer/pull/992) by [@bobsingor](https://github.com/bobsingor) – Every response says which version the server is, in `EmbedPDF-Server-Version`. A request's `EmbedPDF-Version` is answered within the server's major; another major, or a value that isn't `.`, gets a 400 naming both versions. CORS allows `EmbedPDF-Version` and exposes `EmbedPDF-Server-Version`. - [#902](https://github.com/embedpdf/embed-pdf-viewer/pull/902) by [@bobsingor](https://github.com/bobsingor) – Share links can ask their visitors who they are. A link's `visitorIdentity` names the fields it asks (`displayName`, `email`, `title`, `organization`, `organizationalUnit`, each required or optional), when it asks (`'on-open'` or `'before-first-change'`), and the owner's `purpose` and `privacyUrl`. The exchange takes the answers as `visitorIdentity`; until the required ones are given, a link that asks on open answers 422 `VisitorIdentityRequired`, and one that asks before the first change issues the session with `visitor.identityRequest` and refuses its writes with 403 `VisitorIdentityRequired`. Answers are stored once per visitor (migration 042, `share_visitors`), with the time they were given, and go into every token issued for them as its `identity`; an answer once given is never replaced, and a visitor who starts over is a new visitor who is asked again. `GET /v1/tenants/{tenantId}/shares/{shareId}/visitors` lists a link's visitors (who answered or made a change) newest first with their layer, and `DELETE …/visitors/{visitorId}` erases a visitor's answers and layer, on archived links too. A link with visitors is archived rather than deleted (409). The idle clock is now the visitor's: `visitorIdleSeconds` (renamed from `visitorLayerIdleSeconds`) deletes the visitor and their layer once unseen that long, only on links that set it. - [#902](https://github.com/embedpdf/embed-pdf-viewer/pull/902) by [@bobsingor](https://github.com/bobsingor) – Share links can give each visitor a layer of their own. Every exchange names a visitor: the session token carries them as the author (`identity.userId` `visitor_`), and a handle, an HMAC the link issued, brings them back on renewal. On a per-visitor link the session pins the visitor's layer, `visitor-`, which is made at their first write and stamped with the link, the visitor and when they were last seen (migration 038); each exchange with the handle restarts that idle clock. `restart: true` deletes the visitor's layer and starts a new visitor, and a visitor whose layer was deleted comes back as a new one. Names starting with `visitor-` are refused for a link's shared layer and for issued tokens. - [#902](https://github.com/embedpdf/embed-pdf-viewer/pull/902) by [@bobsingor](https://github.com/bobsingor) – Deleting share-link visitors' layers is now the link owner's choice. A link's `visitorIdleSeconds` is null by default, and a visitor's layer then stays until it is deleted on purpose, since what a visitor filled in is often the only copy; migration 039 moves links on the earlier 7-day default to it. A link that sets an idle time, for throwaway layers like examples, has the sweeper delete its visitors' layers nobody has seen for that long; a visitor with the document open renews and stays seen. A visit through a share link now counts as one view however often its session renews: the visitor handle carries the signed time it was issued, and an exchange whose handle is newer than the session lifetime plus five minutes continues the visit. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Widget placements and widget updates take `actions`. Creating a field, adding a widget or updating one with a script, submit or URI action takes `doc.forms.script` too. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Check the caller's authority over an annotation inside the engine's write for updates and deletes, instead of reading the page first: the check and the write see the same document, and each request makes one engine call. The engine checks an update's patch against its annotation's kind. Page flatten and redaction apply fail as a whole when a page fails, leaving the document unchanged; their responses no longer list `'failed'` or `'skipped'` pages. Address annotations as `:annotKey` = `obj:N` or `base:N` on every annotation route; remove the weak annotation session routes, the `index` update and delete route, page revision tokens and the weak annotation columns (migration `031`). Manifest pages are `{ page, cache }`, and annotation reads and write results carry `PageRef`s. `ObjectNumberUnavailable` and `LayerFull` answer HTTP 409. Hand object numbers to editing sessions (migration `032`). An editing session is the client's `X-Engine-Session-Id` together with the token's subject, and lives 15 minutes past its last sign of life. `/access` opens one for a caller that may create and hands it numbers (the body's `objectNumbers`, the response's `edit`); a write tops it up when asked with `EmbedPDF-Reserve-Object-Numbers` and answers `EmbedPDF-Object-Numbers`; `POST /v1/docs/:docId/layers/:layerName/object-numbers` reserves up to 1,000 at once; the event stream sends a `session` event and keeps the session alive. Creates name their numbers in the query string (`objectNumber`, `objectNumbers`, `widgetObjectNumbers`, `splitObjectNumber`), and a number the session doesn't hold is refused `not-held`. What a write makes for itself is numbered past every number handed out, and a publish drops the numbers handed out on its layer. Every layer write route takes `Idempotency-Key`: a retry gets what the first request committed, and no numbers. ### Patch Changes - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Annotation records are typed `Annotation` (was `AnnotationDTO`). - [#771](https://github.com/embedpdf/embed-pdf-viewer/pull/771) by [@bobsingor](https://github.com/bobsingor) – Accepts bodyless requests that carry `Content-Type: application/json` instead of failing them with an unhandled 500. - An empty JSON body now parses as no body rather than `FST_ERR_CTP_EMPTY_JSON_BODY` — the shape the generated PHP, Go, and Ruby SDKs (and clients with default JSON headers) send for bodyless calls such as document delete. Non-empty bodies still go through Fastify's default parser, keeping its prototype-poisoning protection, and routes that require a body still reject its absence with a 400. - The error handler now honors Fastify's `statusCode` on framework errors, so parser and payload rejections (empty or malformed JSON, body limits) surface as the 4xx client errors they are instead of being logged and returned as "unhandled error" 500s. - [#750](https://github.com/embedpdf/embed-pdf-viewer/pull/750) by [@bobsingor](https://github.com/bobsingor) – Preserves configured CORS response headers on the hijacked server-sent events stream, allowing browser clients on permitted origins to subscribe to document layer events. - [#787](https://github.com/embedpdf/embed-pdf-viewer/pull/787) by [@bobsingor](https://github.com/bobsingor) – Reusing an explicit `docId` on `documents.init` or `documents.import` now answers a clean `409 Conflict` explaining how to proceed (retry with the same `idempotencyKey` to resume, delete the document to replace it, or use a different/omitted `docId`) instead of surfacing the raw database unique-constraint error as a 500 — including the case where a retry mints a fresh idempotency key per attempt. A `docId` already owned by another tenant answers `403`, mirroring the existing delete semantics. - [#1019](https://github.com/embedpdf/embed-pdf-viewer/pull/1019) by [@bobsingor](https://github.com/bobsingor) – The font list marks the fallback fonts the server comes with (Noto Sans Hebrew and Noto Naskh Arabic) `builtIn: true`, and the fonts in `CLOUDPDF_FONTS` `builtIn: false`. Font lists get new cached URLs, so none is read without the field. - [#869](https://github.com/embedpdf/embed-pdf-viewer/pull/869) by [@bobsingor](https://github.com/bobsingor) – The widget attach and detach routes accept the widget's `AnnotationRef` as `body.widget`; widget records on the wire carry `ref`. - [#766](https://github.com/embedpdf/embed-pdf-viewer/pull/766) by [@bobsingor](https://github.com/bobsingor) – Mount the document import handler under the renamed `documents.importFrom` contract operation and align the server's import policy and lifecycle terminology. The HTTP route and runtime behavior remain unchanged. - [#760](https://github.com/embedpdf/embed-pdf-viewer/pull/760) by [@bobsingor](https://github.com/bobsingor) – Keep connected licenses usable during Keygen's three-day `EXPIRING` window by relying on the signed validation decision instead of the informational status label. Licenses whose expiry has elapsed remain denied. - [#902](https://github.com/embedpdf/embed-pdf-viewer/pull/902) by [@bobsingor](https://github.com/bobsingor) – Opening a document to edit no longer creates its layer. A layer nobody has changed reads the base document, so `/access` hands its editing session object numbers counted past the base document's last object, without storing the layer or opening a worker session for it. The layer is stored at its first write. Object numbers are now kept by document and layer name (migration 036), and numbers a layer was handed on one base version start over on another. The sweeper forgets the numbers of layers nobody changed once their editing sessions have been expired for a session lifetime, so someone who only looked leaves nothing behind. Layer worker sessions no longer stay open for the life of the document. The sweeper closes a layer's session after it goes unused for `layerSessionIdleMs` (default 10 minutes), and a document keeps at most `maxLayerSessionsPerDoc` layer sessions open (default 32), closing the least recently used beyond that. The next request reopens a closed session from the stored layer. Searching a layer whose text and page order are still the base document's now runs on the base, without opening a session for the layer. A write retried on two replicas under the same change id now answers what the first one committed, also when that commit spent the write's object numbers while the second was still preparing. - [#910](https://github.com/embedpdf/embed-pdf-viewer/pull/910) by [@bobsingor](https://github.com/bobsingor) – A layer's versions are read through the layer. The version routes moved from `/v1/docs/:docId/versions…` to `/v1/docs/:docId/layers/:layerName/versions…`, checked like every other layer route. - **The list** gives the layer's versions (the upload, then the ones its signatures made) and its `baseSha`. - **A version's signatures, analysis, download and revisions** answer only for the upload or the layer's own versions: another layer's version is 404, and a token for one layer can't use another layer's path. - **Tenant tokens** read any layer's versions, through that layer. - [#995](https://github.com/embedpdf/embed-pdf-viewer/pull/995) by [@bobsingor](https://github.com/bobsingor) – A grant create takes `origins: null` and `expiresAt: null`, as a grant read says them: any origin and no expiry. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Security fixes: - **Pictures with annotations need `doc.annotate.read`,** at the origin and in CDN grants. They draw no form fields. - **The event stream sends each connection only what its token may read.** Annotations need `doc.annotate.read`; widgets and form fields need `doc.forms.read`. A row with nothing left goes out marked `withheld`, with only its pins. - **Moving annotations checks each one inside the write,** so moving a widget takes `doc.forms.modify`. - [#1005](https://github.com/embedpdf/embed-pdf-viewer/pull/1005) by [@bobsingor](https://github.com/bobsingor) – The head and `/access` carry named permission flags, not the raw word; `/access` no longer sends the `advisory`. - [#988](https://github.com/embedpdf/embed-pdf-viewer/pull/988) by [@bobsingor](https://github.com/bobsingor) – Every versioned read (`…@token`) now answers exactly the state its pins name. The pins are checked before the read and again after it, and a read that a layer write began during is refused as no longer current, so a write can no longer end up cached for a year under an older version. Before, page renders, page text and geometry, appearance batches, outline, metadata, fonts, attachments, layout, actions, search, signatures and downloads checked their pins only before reading, and the annotation and form reads could still send an applied but uncommitted write. - [#785](https://github.com/embedpdf/embed-pdf-viewer/pull/785) by [@bobsingor](https://github.com/bobsingor) – Fix AWS S3-backed streaming uploads by buffering small source chunks before the SDK applies checksum framing, preventing `InvalidChunkSizeError` during document imports and other streamed writes. Handled 5xx responses now also emit structured error logs with the request ID and HTTP status. - [#909](https://github.com/embedpdf/embed-pdf-viewer/pull/909) by [@bobsingor](https://github.com/bobsingor) – A share link can say who its visitors are, for a link made for one person: `identity` on `shares.create` and `shares.update`, the same shape as `tokens.issue`'s (migration 043). Every session the link gives carries it, whoever opens the link: a field it sets is never asked, and a visitor's answer for it is ignored. Its `userId` replaces the visitor's own `visitor_`; each visit still gets its own layer on a per-visitor link. A link that asks a field its identity sets is refused (400), on create and on an update checked against the link as it will be. - [#907](https://github.com/embedpdf/embed-pdf-viewer/pull/907) by [@bobsingor](https://github.com/bobsingor) – A share link's visitor is remembered on every link except a per-visitor link that doesn't keep visitors' layers: the exchange answers `visitor.keep: true` for shared links too. A visitor who comes back in the same browser keeps their answers to the link's questions and stays the author of what they added, instead of being asked again on every page load and listed as a new visitor each time. - [#910](https://github.com/embedpdf/embed-pdf-viewer/pull/910) by [@bobsingor](https://github.com/bobsingor) – A signature moves only the layer it was made in. Completing a signature writes the new version as that layer's own: only its `base_sha` moves, and the document (`documents.base_sha`, the upload) and every other layer stay as they were. Before, a signature moved the whole document, so on a per-visitor link the next visitor opened the signer's filled-in, signed copy, and layers still on the old version could no longer sign (`StaleBase`). - **Every layer can sign**, over its own base. A layer that signs again signs over its previous version. - **Versions belong to their layer:** a layer's versions are numbered along its own chain and stored under the layer, and they're deleted with it. - **`/layers/:layerName/head`** reports the layer's own base. - **Migration 044** gives each existing signed version its layer, puts a document a signature moved back on its upload, and starts layers that stored nothing on the upload too. - **No document-wide signal any more:** the base-changed bus channel is gone. Other replicas reload the signing layer because its version moved. - [#766](https://github.com/embedpdf/embed-pdf-viewer/pull/766) by [@bobsingor](https://github.com/bobsingor) – Cloud ObjectStore adapters (S3, GCS, Azure Blob) now truly stream `put` bodies: a `Readable` is hashed and length-enforced as it flows (constant memory) instead of being buffered whole. Under- or over-delivery aborts before a visible object can appear, any prior object at the key survives a failed attempt, and the SHA-256 metadata is attached post-stream (S3 via a same-key server-side copy). FsObjectStore now cleans up its `.partial` file when the source stream errors mid-put. - [#990](https://github.com/embedpdf/embed-pdf-viewer/pull/990) by [@bobsingor](https://github.com/bobsingor) – `redactions.apply` parses its body with `RedactionApplyScopeInputSchema`, which still refuses a field it doesn't know, now that the scope a response carries is read tolerantly. - [#1003](https://github.com/embedpdf/embed-pdf-viewer/pull/1003) by [@bobsingor](https://github.com/bobsingor) – Follows engine-core's names: `FormField`, `Signature`. - [#1002](https://github.com/embedpdf/embed-pdf-viewer/pull/1002) by [@bobsingor](https://github.com/bobsingor) – The document init and import answers say `status`, not `tag`. Form fields are tagged `kind`. - [#902](https://github.com/embedpdf/embed-pdf-viewer/pull/902) by [@bobsingor](https://github.com/bobsingor) – Versioned reads without a CDN now answer `Cache-Control: private, max-age=31536000, immutable` instead of `public, …`. Only the caller's browser may keep a response that needed a token; a proxy in front of the engine no longer may. Deployments with a CDN keep `public`, because the edge checks the signature before serving its copy. - [#1000](https://github.com/embedpdf/embed-pdf-viewer/pull/1000) by [@bobsingor](https://github.com/bobsingor) – The image encoder and the appearance batch say `mimeType`, as engine-core's render results do. ## 3.0.0-next.23 ### Minor Changes - [#991](https://github.com/embedpdf/embed-pdf-viewer/pull/991) by [@bobsingor](https://github.com/bobsingor) – Layers and base versions store `contents_version` (migration 052), raised in the same transaction as a flatten, a redaction or a change to the page set, and published in the manifest. Versioned searches pin it with `layoutVersion` instead of a content epoch, so an annotation write keeps every cached search and a content write refreshes them; the unversioned search form takes the same two pins as optional parameters. - [#989](https://github.com/embedpdf/embed-pdf-viewer/pull/989) by [@bobsingor](https://github.com/bobsingor) – `/head` carries this server's engine value for each kind of cached read: a digest of the rules and fonts it computes that kind with, never of its release, so a deploy that changes nothing keeps every cached answer. Every versioned read checks the token's engine value and shape: a shape newer than the server answers is refused, and another engine value is answered with this server's own answer, uncached, and its value in `EmbedPDF-Engine` (exposed to browsers), so nothing is cached under a value that doesn't describe it and no request fails during a rolling deploy. Renders are stored by engine value. The manifest no longer carries `serverFonts`. - [#994](https://github.com/embedpdf/embed-pdf-viewer/pull/994) by [@bobsingor](https://github.com/bobsingor) – Every error response is `{ error: { code, message, details? } }` with a code from `EngineErrorCode`. An engine error no longer carries `name`. A license refusal is `LicenseInvalid` with the license status's code in `details.licenseCode`; a usage limit says its `metric` and `limit` in `details`; a thumbnail that isn't ready says its state in `details.state`; `BadInput` is `InvalidArg`; and an error from Fastify itself carries the code for its status instead of Fastify's own. - [#996](https://github.com/embedpdf/embed-pdf-viewer/pull/996) by [@bobsingor](https://github.com/bobsingor) – Every point in time the server sends is an ISO 8601 string in UTC, and a grant's and a token revoke's `expiresAt` are taken as one, with its offset. Rows keep their milliseconds. The admin routes' records are typed by the contract's, so a field the contract doesn't say no longer compiles. - [#997](https://github.com/embedpdf/embed-pdf-viewer/pull/997) by [@bobsingor](https://github.com/bobsingor) – Takes and sends the renamed fields: `sizeBytes` (documents, layers, versions), `baseSha256`, the manifest's `baseSizeBytes`, `uploadTtlSeconds`, `expiresInSeconds` (also the editing session's on `/access`, the event stream and object-number reservations), `docIds` and the camelCase usage metrics (module meters in `moduleMeters`), and names its path parameters `docId`, `annotationKey`, `sha256` and `displaySha256`. - [#992](https://github.com/embedpdf/embed-pdf-viewer/pull/992) by [@bobsingor](https://github.com/bobsingor) – Every response says which version the server is, in `EmbedPDF-Server-Version`. A request's `EmbedPDF-Version` is answered within the server's major; another major, or a value that isn't `.`, gets a 400 naming both versions. CORS allows `EmbedPDF-Version` and exposes `EmbedPDF-Server-Version`. ### Patch Changes - [#995](https://github.com/embedpdf/embed-pdf-viewer/pull/995) by [@bobsingor](https://github.com/bobsingor) – A grant create takes `origins: null` and `expiresAt: null`, as a grant read says them: any origin and no expiry. - [#1005](https://github.com/embedpdf/embed-pdf-viewer/pull/1005) by [@bobsingor](https://github.com/bobsingor) – The head and `/access` carry named permission flags, not the raw word; `/access` no longer sends the `advisory`. - [#988](https://github.com/embedpdf/embed-pdf-viewer/pull/988) by [@bobsingor](https://github.com/bobsingor) – Every versioned read (`…@token`) now answers exactly the state its pins name. The pins are checked before the read and again after it, and a read that a layer write began during is refused as no longer current, so a write can no longer end up cached for a year under an older version. Before, page renders, page text and geometry, appearance batches, outline, metadata, fonts, attachments, layout, actions, search, signatures and downloads checked their pins only before reading, and the annotation and form reads could still send an applied but uncommitted write. - [#990](https://github.com/embedpdf/embed-pdf-viewer/pull/990) by [@bobsingor](https://github.com/bobsingor) – `redactions.apply` parses its body with `RedactionApplyScopeInputSchema`, which still refuses a field it doesn't know, now that the scope a response carries is read tolerantly. - [#1003](https://github.com/embedpdf/embed-pdf-viewer/pull/1003) by [@bobsingor](https://github.com/bobsingor) – Follows engine-core's names: `FormField`, `Signature`. - [#1002](https://github.com/embedpdf/embed-pdf-viewer/pull/1002) by [@bobsingor](https://github.com/bobsingor) – The document init and import answers say `status`, not `tag`. Form fields are tagged `kind`. - [#1000](https://github.com/embedpdf/embed-pdf-viewer/pull/1000) by [@bobsingor](https://github.com/bobsingor) – The image encoder and the appearance batch say `mimeType`, as engine-core's render results do. ## 3.0.0-next.22 ### Minor Changes - [#967](https://github.com/embedpdf/embed-pdf-viewer/pull/967) by [@bobsingor](https://github.com/bobsingor) – Modules describe themselves, and count their usage. A module has a `name` (required) and a `description`, and declares `meters` (each with a `label` and a `unit`) that its routes count with `req.meters.count(meter, { oncePerDay })` for the document's tenant. A permission can say how it relates to the core's: `replaces` (`protected-display.view` replaces `doc.render`) and `bypassedBy` (`doc.download`…), facts for a grant dialog that the server doesn't enforce; a token may hold a permission and the one it replaces, and the core one has its usual effect. `GET /v1/deployment/modules` lists the installed modules as they declare themselves, with the API token. Tenant usage is counted per UTC day: `tenants.usage` takes `from` and `to` in place of `period`, and reports each installed module's meters next to the core's. Migration 051 moves the counters to days (a month counted before keeps its total on its first day) and keeps the once-a-day keys as hashes, swept when the day is over. ## 3.0.0-next.21 ### Minor Changes - [#964](https://github.com/embedpdf/embed-pdf-viewer/pull/964) by [@bobsingor](https://github.com/bobsingor) – A Postgres connection that fails while idle in the pool no longer crashes the server. A database restart or failover, `pg_terminate_backend`, or a proxy closing the connection used to reach Node as an uncaught `error` event from `pg.Pool`. The pool now drops that connection and opens a new one for the next query. `createPostgresDb` takes `onIdleConnectionError` to report these, and `cloudpdf-server` logs each one's message as a warning. - [#955](https://github.com/embedpdf/embed-pdf-viewer/pull/955) by [@bobsingor](https://github.com/bobsingor) – `buildApp` takes the deployment's license as `license`: the runtime `createLicenseRuntime` made, and nothing else. It replaces `licenseGate`. Any other object, including a copy of a runtime, stops the build with an error naming `createLicenseRuntime`. The runtime is sealed: its methods can't be replaced, and `buildApp` enforces the license from the runtime behind it. `createLicenseRuntime` takes only `db`, `env`, `secretResolver` and `startTimer`, and passes nothing else on, so license verification always uses the identity compiled into the package. - [#956](https://github.com/embedpdf/embed-pdf-viewer/pull/956) by [@bobsingor](https://github.com/bobsingor) – Tenants have `features`: the server modules each tenant may use, by module id. A module's routes answer only tenants whose features hold it; others get `403 FeatureNotEnabled`, and a feature held as `{ id, stopped: 'cap' }` answers `402 FeatureStopped`. A new tenant has none: the operator turns modules on per tenant with `PATCH /v1/tenants/:tenantId` (API token only, every id an installed module), and other replicas follow within 30 seconds. Migration 050 adds the column on SQLite and Postgres. ## 3.0.0-next.20 ### Minor Changes - [#944](https://github.com/embedpdf/embed-pdf-viewer/pull/944) by [@bobsingor](https://github.com/bobsingor) – A tenant token hands out only the document permissions it holds itself. `tokens.issue` with kind `doc`, `grants.create`, and `grants.update` when it changes the scope answer `403 Forbidden` naming what the token doesn't hold. A key with `tokens.issue-doc`, `doc.open` and `doc.render` mints reading tokens and nothing more. The API token and `*` hold everything, as before. - [#941](https://github.com/embedpdf/embed-pdf-viewer/pull/941) by [@bobsingor](https://github.com/bobsingor) – Every worker registers Noto Sans Hebrew and Noto Naskh Arabic as fallback fonts, tried after the deployment's own (`CLOUDPDF_FONTS`), so Hebrew and Arabic draw with no setup. A key the deployment uses keeps its font. The server's fonts (`CLOUDPDF_FONTS`, renamed from `CLOUDPDF_FALLBACK_FONTS`; `buildApp({ fonts })`, `ServerFontDescriptor` and `loadServerFontsFromEnv()`) take `serve`: a served font's file goes to a client that may write text, at one URL for every document (`/v1/font-program-files/{hash}`, `private, immutable`), so the viewer types in it; a font not served is listed with `'not-served'`. Noto Sans Hebrew and Noto Naskh Arabic are served. A document's fonts on the cloud: `GET …/fonts@{fontsVersion,serverFonts}` (the base's shared URL while a layer draws what the base does), `POST …/fonts/resolve`, a program's facts at `…/font-programs/{hash}` and its bytes at `…/font-program-files/{hash}` (for a token with `doc.annotate.modify`, `doc.forms.fill`, `doc.forms.modify` or `doc.redact` that the document's signatures leave it, `private`, never on the CDN). The manifest's `fontsVersion` (migration 049, on layers and base versions) moves with every write the engine says changed the fonts the list shows, and its `CacheDelta` carries it. The manifest's `serverFonts`, a fingerprint of the server's fonts, is in the font list's URL and every picture's, rendered and stored: a change of the server's fonts draws every page again once, and a replica answers only URLs with its own. - [#940](https://github.com/embedpdf/embed-pdf-viewer/pull/940) by [@bobsingor](https://github.com/bobsingor) – Accept the `pages.copy` change op and object numbers on `pages.insert`. Copies are counted as new pages for the layer's page set and object number estimates, and page list answers carry the page label sections (`labels`). - [#931](https://github.com/embedpdf/embed-pdf-viewer/pull/931) by [@bobsingor](https://github.com/bobsingor) – Each kind of page picture needs its own permission and no other. Thumbnails have routes of their own, at the document's and a layer's path (`render/thumbnail/…`), and need `doc.render.thumbnail`, which `doc.render` includes: the whole page at 512 pixels on its long side, cached like print pictures and never classified against the render lattice. Print pictures no longer need `doc.render`: `doc.print` is enough, and `doc.print.high` for 300 DPI. `/access` lists `doc.render.thumbnail` in `effectiveScope` for a session with `doc.render`. A server module's raw render can ask for a thumbnail, which needs `doc.render.thumbnail` in its `requires.document`. - [#926](https://github.com/embedpdf/embed-pdf-viewer/pull/926) by [@bobsingor](https://github.com/bobsingor) – The server knows the plugin permissions its installed modules declare (`bundle.permissions`); a plugin whose permission is checked elsewhere, by a viewer plugin for example, is installed as a module that only declares permissions, which needs no document plane. Issuing a token or saving a grant that names a plugin permission no installed plugin declares is refused with `InvalidArg`. `/access` puts the installed plugin permissions a token holds (every one under `*`) into `effectiveScope`; a plugin permission whose plugin isn't installed is carried by the token but takes no effect. The app bundle also lists the routes it mounted (`routes`). Add server modules: packages that run inside the server with their own routes and permissions, written with the new `@cloudpdf/server-modules`. Name them in `CLOUDPDF_MODULES` (or pass `buildApp({ modules })`); each reads its settings from `CLOUDPDF__*`, and a module that won't load, misses a required setting, or asks for something other than core document permissions in `requires.document` stops the server at boot. A module's routes mount at `/v1/docs/:docId/layers/:layerName//…` behind `doc.open` and the module's own permission. Each request reaches the server's API through its own routes, in process (that connection reaches only this server, never a CDN or another host): as the caller, with their own token, and as the module, with a short-lived token for that document carrying `doc.open` and `requires.document`. Raw page pixels come from the host in the engine's own terms (`PageRenderOptions` in, a `PageRenderRaster` with its transform out), drawn as the module: everything the picture draws needs its permission in `requires.document`, with the local engine's defaults, and print pictures are refused. The host side is typed in the new `@cloudpdf/server/modules` entry. - [#925](https://github.com/embedpdf/embed-pdf-viewer/pull/925) by [@bobsingor](https://github.com/bobsingor) – Upload tokens let a browser upload straight to CloudPDF. `tokens.issue` with kind `upload` makes one for a folder, with your metadata, a file count (one by default), an optional size limit and an origin lock. The token reaches only init, commit and the proxy upload. There it uploads into its folder with its metadata, whatever the request says, and commits only the documents it started. Every other route refuses it. Migration 048 adds `documents.upload_token_jti` and the `upload_token_uses` table, which counts each token's documents atomically. ## 3.0.0-next.19 ### Minor Changes - [#918](https://github.com/embedpdf/embed-pdf-viewer/pull/918) by [@bobsingor](https://github.com/bobsingor) – Share links are grants: routes under `/v1/tenants/{tenantId}/grants`, the `grants.manage` scope, and the public exchange at `POST /v1/grant-sessions`, which takes `{ grant, passphrase }`. Migration 047 renames `share_grants` to `grants` and `share_visitors` to `grant_visitors` with their indexes and constraints, renames `password_hash` to `passphrase_hash`, and adds a grant's `name`. New grants are `grt_…`, and `shr_…` grants keep working. Session tokens name `grant:`, and `security_events` records `grant.created`, `grant.updated`, `grant.archived` and `grant.revoked`. ## 3.0.0-next.18 ### Minor Changes - [#917](https://github.com/embedpdf/embed-pdf-viewer/pull/917) by [@bobsingor](https://github.com/bobsingor) – Organize documents in folders. Folders nest up to 100 levels with names unique among siblings, ignoring case. A move takes documents and folders together or not at all and never makes a loop, even when two moves race; only empty folders delete. Documents are filed at upload and listed per folder, and a document being deleted leaves its folder. Migration 046 adds the `folders` table and `documents.folder_id`. Errors thrown with structured context now return it as `details`. - [#917](https://github.com/embedpdf/embed-pdf-viewer/pull/917) by [@bobsingor](https://github.com/bobsingor) – Store a name for every document, searchable and sortable without regard to case, and rename documents with `PATCH /v1/tenants/:tenantId/documents/:id` under the new `docs.update` scope. The documents list searches by name, sorts by creation time, name or size in either order with stable cursors, and hides documents that are being deleted unless asked for by state. Migration 045 names existing documents from `metadata.name` when it is a non-empty string, otherwise from their id. - [#917](https://github.com/embedpdf/embed-pdf-viewer/pull/917) by [@bobsingor](https://github.com/bobsingor) – Delete a folder with everything in it via `recursive=true`: the folder and every folder under it go in one transaction, and every document in them stops opening, leaves every list and stops answering its share links at once, while their stored files are removed in the background. The sweeper now also finishes deletes left behind, such as one interrupted by a crash, after `deletingGraceMs` (default one minute). The filesystem object store no longer fails a write when a delete elsewhere in the same tenant prunes the directories the write has just made. - [#917](https://github.com/embedpdf/embed-pdf-viewer/pull/917) by [@bobsingor](https://github.com/bobsingor) – Tenant scopes act on records and document capabilities act on what is inside documents, on any token. A tenant JWT is checked inside documents the way a document JWT is, against the document capabilities its scope names, which hold for every document of the tenant; `docs.read` lists documents but no longer opens, reads or changes them. Downloading the original file needs `doc.download` and the thumbnail needs `doc.render`. A tenant token whose scope names no document capability is refused on the document routes, and `tokens.issue` validates a tenant token's scope entries. ### Patch Changes - [#910](https://github.com/embedpdf/embed-pdf-viewer/pull/910) by [@bobsingor](https://github.com/bobsingor) – A layer's versions are read through the layer. The version routes moved from `/v1/docs/:docId/versions…` to `/v1/docs/:docId/layers/:layerName/versions…`, checked like every other layer route. - **The list** gives the layer's versions (the upload, then the ones its signatures made) and its `baseSha`. - **A version's signatures, analysis, download and revisions** answer only for the upload or the layer's own versions: another layer's version is 404, and a token for one layer can't use another layer's path. - **Tenant tokens** read any layer's versions, through that layer. - [#909](https://github.com/embedpdf/embed-pdf-viewer/pull/909) by [@bobsingor](https://github.com/bobsingor) – A share link can say who its visitors are, for a link made for one person: `identity` on `shares.create` and `shares.update`, the same shape as `tokens.issue`'s (migration 043). Every session the link gives carries it, whoever opens the link: a field it sets is never asked, and a visitor's answer for it is ignored. Its `userId` replaces the visitor's own `visitor_`; each visit still gets its own layer on a per-visitor link. A link that asks a field its identity sets is refused (400), on create and on an update checked against the link as it will be. - [#907](https://github.com/embedpdf/embed-pdf-viewer/pull/907) by [@bobsingor](https://github.com/bobsingor) – A share link's visitor is remembered on every link except a per-visitor link that doesn't keep visitors' layers: the exchange answers `visitor.keep: true` for shared links too. A visitor who comes back in the same browser keeps their answers to the link's questions and stays the author of what they added, instead of being asked again on every page load and listed as a new visitor each time. - [#910](https://github.com/embedpdf/embed-pdf-viewer/pull/910) by [@bobsingor](https://github.com/bobsingor) – A signature moves only the layer it was made in. Completing a signature writes the new version as that layer's own: only its `base_sha` moves, and the document (`documents.base_sha`, the upload) and every other layer stay as they were. Before, a signature moved the whole document, so on a per-visitor link the next visitor opened the signer's filled-in, signed copy, and layers still on the old version could no longer sign (`StaleBase`). - **Every layer can sign**, over its own base. A layer that signs again signs over its previous version. - **Versions belong to their layer:** a layer's versions are numbered along its own chain and stored under the layer, and they're deleted with it. - **`/layers/:layerName/head`** reports the layer's own base. - **Migration 044** gives each existing signed version its layer, puts a document a signature moved back on its upload, and starts layers that stored nothing on the upload too. - **No document-wide signal any more:** the base-changed bus channel is gone. Other replicas reload the signing layer because its version moved. ## 3.0.0-next.17 ### Minor Changes - [#902](https://github.com/embedpdf/embed-pdf-viewer/pull/902) by [@bobsingor](https://github.com/bobsingor) – Archive share links instead of losing what their visitors made. Archiving (migration 041) stops a link's exchange for good, like a revoke, but keeps the link and its visitors' layers, still listed with `documents.layers.list?shareId=` and downloadable. Deleting a link is refused with 409 while its visitors have layers; one whose visitors only looked can still be deleted. An archived link refuses updates, is left out of `shares.list` unless `archived=true`, and no longer keeps its shared layer from being deleted. Its visitors' layers keep to the link's idle setting. - [#902](https://github.com/embedpdf/embed-pdf-viewer/pull/902) by [@bobsingor](https://github.com/bobsingor) – Incremental downloads no longer go through the engine. A layer's PDF saved incrementally, the default, is now its base file followed by the delta its stored artifact holds, streamed from storage with the same permission and password checks as before; a layer nobody wrote downloads as its base file, and a signed file's bytes stay exactly as stored. A rewrite (`mode=rewrite`) is still saved by the engine. Download links: `POST …/layers/{layerName}/download-link` returns a URL that downloads the layer's current PDF without an Authorization header, for services that only take a plain URL. The URL is the layer's versioned download with a `link` token that opens nothing else: it isn't accepted as a bearer token, it works only for the version it was made for (404 once the layer changes), it expires after `expiresIn`, and a password-protected document is checked when the link is made. Deployments that verify tokens with their own keys can mint the same link on their backend, as a doc token with `layer_name` and a `download` claim. - [#902](https://github.com/embedpdf/embed-pdf-viewer/pull/902) by [@bobsingor](https://github.com/bobsingor) – Delete a layer with `DELETE /v1/tenants/{tenantId}/documents/{id}/layers/{layerName}`. Its artifacts, renders, change captures, changes, audit rows, signings, password sessions and object numbers go, and its worker session closes. A layer that was written keeps its row as a tombstone (migration 037), and every route then answers its name with `LayerDeleted` (HTTP 410), because its read URLs were cached as immutable and a new layer under the name would restart at the same versions. A layer nobody wrote leaves no tombstone and stays usable. A write in flight on another replica loses its commit to the delete. Deleting a layer a share link uses is refused with 409, and a share link can't be created for a deleted layer. - [#902](https://github.com/embedpdf/embed-pdf-viewer/pull/902) by [@bobsingor](https://github.com/bobsingor) – List a document's layers with `GET /v1/tenants/{tenantId}/documents/{id}/layers`: newest first, cursor-paged like documents, tenants and shares, optionally only one share link's visitors' layers (`shareId`). This is how a link's owner finds what visitors filled in and downloads it through the layer's routes. Migration 040 replaces the per-document layer index with one in list order. - [#902](https://github.com/embedpdf/embed-pdf-viewer/pull/902) by [@bobsingor](https://github.com/bobsingor) – Share links can ask their visitors who they are. A link's `visitorIdentity` names the fields it asks (`displayName`, `email`, `title`, `organization`, `organizationalUnit`, each required or optional), when it asks (`'on-open'` or `'before-first-change'`), and the owner's `purpose` and `privacyUrl`. The exchange takes the answers as `visitorIdentity`; until the required ones are given, a link that asks on open answers 422 `VisitorIdentityRequired`, and one that asks before the first change issues the session with `visitor.identityRequest` and refuses its writes with 403 `VisitorIdentityRequired`. Answers are stored once per visitor (migration 042, `share_visitors`), with the time they were given, and go into every token issued for them as its `identity`; an answer once given is never replaced, and a visitor who starts over is a new visitor who is asked again. `GET /v1/tenants/{tenantId}/shares/{shareId}/visitors` lists a link's visitors (who answered or made a change) newest first with their layer, and `DELETE …/visitors/{visitorId}` erases a visitor's answers and layer, on archived links too. A link with visitors is archived rather than deleted (409). The idle clock is now the visitor's: `visitorIdleSeconds` (renamed from `visitorLayerIdleSeconds`) deletes the visitor and their layer once unseen that long, only on links that set it. - [#902](https://github.com/embedpdf/embed-pdf-viewer/pull/902) by [@bobsingor](https://github.com/bobsingor) – Share links can give each visitor a layer of their own. Every exchange names a visitor: the session token carries them as the author (`identity.userId` `visitor_`), and a handle, an HMAC the link issued, brings them back on renewal. On a per-visitor link the session pins the visitor's layer, `visitor-`, which is made at their first write and stamped with the link, the visitor and when they were last seen (migration 038); each exchange with the handle restarts that idle clock. `restart: true` deletes the visitor's layer and starts a new visitor, and a visitor whose layer was deleted comes back as a new one. Names starting with `visitor-` are refused for a link's shared layer and for issued tokens. - [#902](https://github.com/embedpdf/embed-pdf-viewer/pull/902) by [@bobsingor](https://github.com/bobsingor) – Deleting share-link visitors' layers is now the link owner's choice. A link's `visitorIdleSeconds` is null by default, and a visitor's layer then stays until it is deleted on purpose, since what a visitor filled in is often the only copy; migration 039 moves links on the earlier 7-day default to it. A link that sets an idle time, for throwaway layers like examples, has the sweeper delete its visitors' layers nobody has seen for that long; a visitor with the document open renews and stays seen. A visit through a share link now counts as one view however often its session renews: the visitor handle carries the signed time it was issued, and an exchange whose handle is newer than the session lifetime plus five minutes continues the visit. ### Patch Changes - [#902](https://github.com/embedpdf/embed-pdf-viewer/pull/902) by [@bobsingor](https://github.com/bobsingor) – Opening a document to edit no longer creates its layer. A layer nobody has changed reads the base document, so `/access` hands its editing session object numbers counted past the base document's last object, without storing the layer or opening a worker session for it. The layer is stored at its first write. Object numbers are now kept by document and layer name (migration 036), and numbers a layer was handed on one base version start over on another. The sweeper forgets the numbers of layers nobody changed once their editing sessions have been expired for a session lifetime, so someone who only looked leaves nothing behind. Layer worker sessions no longer stay open for the life of the document. The sweeper closes a layer's session after it goes unused for `layerSessionIdleMs` (default 10 minutes), and a document keeps at most `maxLayerSessionsPerDoc` layer sessions open (default 32), closing the least recently used beyond that. The next request reopens a closed session from the stored layer. Searching a layer whose text and page order are still the base document's now runs on the base, without opening a session for the layer. A write retried on two replicas under the same change id now answers what the first one committed, also when that commit spent the write's object numbers while the second was still preparing. - [#902](https://github.com/embedpdf/embed-pdf-viewer/pull/902) by [@bobsingor](https://github.com/bobsingor) – Versioned reads without a CDN now answer `Cache-Control: private, max-age=31536000, immutable` instead of `public, …`. Only the caller's browser may keep a response that needed a token; a proxy in front of the engine no longer may. Deployments with a CDN keep `public`, because the edge checks the signature before serving its copy. ## 3.0.0-next.16 ### Minor Changes - [#891](https://github.com/embedpdf/embed-pdf-viewer/pull/891) by [@bobsingor](https://github.com/bobsingor) – Attachments are changes: `POST …/changes` takes `attachments.create` (its file as a `resource:` part) and `attachments.delete` under `doc.attachments.modify`, and undoes them by `opId`. The routes `POST …/attachments` and `DELETE …/attachments/{fileKey}` are removed, and file downloads no longer carry `X-EmbedPDF-File-Name` and `X-EmbedPDF-File-Type`: the listing has both. New current reads: `GET …/attachments`, `GET …/attachment-files/{fileKey}/data` and an annotation's `GET …/items/{annotKey}/resources/file`. - [#885](https://github.com/embedpdf/embed-pdf-viewer/pull/885) by [@bobsingor](https://github.com/bobsingor) – The document's outline: `GET /v1/docs/:docId/outline@{token}` (shared and cacheable while a layer inherits the outline and the layout) and `GET /v1/docs/:docId/layers/:layerName/outline`, with outline edits through `POST …/changes`. Layers and published versions carry an outline version (migration `035_outline_version`), outline ops move it, and its plane decides when a layer reads the shared outline. A token that may change the outline (`doc.outline.modify`) is handed object numbers for new items, as one that may create annotations is. - [#890](https://github.com/embedpdf/embed-pdf-viewer/pull/890) by [@bobsingor](https://github.com/bobsingor) – Page edits are changes: `POST …/changes` takes `pages.rotate`, `pages.reorder`, `pages.delete`, `pages.insertBlank` and `pages.insert` (its PDF as a `resource:` part) under `doc.pages.assemble`, and undoes them by `opId`. An undo of a delete brings the same pages back with fresh page pins, so no picture cached before they went is served for them. The routes `POST …/pages/reorder`, `/pages/rotate`, `/pages/delete`, `/pages/insert` and `/pages/insert-blank` are removed. - [#883](https://github.com/embedpdf/embed-pdf-viewer/pull/883) by [@bobsingor](https://github.com/bobsingor) – `POST /v1/docs/:docId/layers/:layerName/pages/extract` takes `flatten` (`{ usage?: 'display' | 'print' }`), `includeAnnotations` and `includeFormFields`, and returns the pages as they draw for that usage. A flattened copy passes on `doc.download` or `doc.download.flattened` (a signed document refuses the latter), and paints only what the token may read; the include options are refused without `flatten`. - [#883](https://github.com/embedpdf/embed-pdf-viewer/pull/883) by [@bobsingor](https://github.com/bobsingor) – Serve the print pictures at both tiers: each picture family printed at 150 DPI under `render/print/` (needs `doc.print`) and at 300 DPI under `render/print-high/` (needs `doc.print.high`), on top of the family's own rights. A print picture's token is its pins and its format; the server sizes it from the DPI and the paper. Print pictures are cached at their versioned URLs but never stored or refused by the render lattice. ## 3.0.0-next.15 ### Minor Changes - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – The appearance endpoint returns every mode and state an annotation stores, each manifest entry labelled with its `state`, and accepts `modes` as a filter. Annotated page renders draw form fields unless the token says `formFields=false`. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – `/v1/access` advertises the bundle limits as `bundleLimits`, and the app option is `bundleLimits`. The multipart reader for bundle imports serves any bundle family; annotation imports are unchanged. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Stops work for clients that went away: a request whose client disconnects before its reply is sent now aborts its engine job, where before no disconnect was ever detected. A render shared by several requests stops only once all of them have left. Serve the revised document, page, annotation, form, and rendering contracts, including object-number page references, page-space geometry, annotation transfer, custom metadata, and signature-aware mutation checks. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Every layer write sends its worker job an `opId`: the request's `Idempotency-Key`, or one minted for the write. Results' `meta` carry `opId` and `undoable`; page-structure, metadata, attachment and signing results take them from the write. Add `POST /v1/docs/{docId}/layers/{layerName}/changes`: user actions, each a change whose ops apply in order in one layer transaction, all or none, or `{ opId, undoOf }`, the undo of an earlier change. One request runs as one worker job and one commit: each change stands on its own (a refused one rolls back alone), and the 200 answers every change in order, applied with its result or refused with its error. Bytes travel as multipart `resource:` parts the JSON names by key. At most 64 changes per request and 512 ops per change. Each answered change keeps its answer under its `opId` in the new `change_outcomes` table (migration 033), refusals included, so a retry gets the same answer and a different change under an answered `opId` is refused (`IdempotencyKeyReused`). An applied change keeps what undoes it: a record beside its answer and its captures as one object-store blob. Only the user who made a change may undo it; a redaction, a flatten, a form repair or a completed signature ends undo for the changes before it (`layers.undo_horizon`, `UndoUnavailable`). Answers are kept 30 days (`CLOUDPDF_CHANGE_RETENTION_DAYS`); the sweeper deletes expired answers with their captures, and the records and captures of changes no undo can reach. Every change that wrote gets one audit row (kind `change`, its `opId` as idempotency key, `undo_of` naming what an undo undid). The single-op annotation, form and metadata routes now run as one-change requests: their audit rows keep their kinds and payloads, and their `Idempotency-Key` names the change, so `{ undoOf }` undoes them. The event stream's rows carry `undoOf`. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Form writes stamp field attribution from the token's identity: creating a field, filling one in, and the values a script run writes. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Field groups on the server: - **Fill and sign routes** (a value, a reset, a signature look, a values import, signing) accept a token that may fill in or sign some field: `doc.forms.fill` / `doc.sign`, or a `fields:` scope. The write checks each field against the token's grants. - **Design routes** send the grants too, for the group checks. - **Identity:** the verified identity claim drops `groups`, and `/v1/access` no longer echoes it. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – `POST …/form/calculations/reorder` (`doc.forms.reorderCalculations`, audit kind `form.reorderCalculations`). Creating or updating a field with scripts takes `doc.forms.script` too. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Form bundle routes replace `form/data`: `GET …/form/export@:token` (doc and layer, cacheable at the form and layout pins), `POST …/form/export` for a selection a URL can't carry, and multipart `POST …/form/import` and `POST …/form/import-values`, each one change under its `Idempotency-Key`, audited as `form.import` and `form.importValues`. The FDF/XFDF content-type parsers are gone. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – The form is its own read family: - **New routes:** `form@{formsVersion}` and `form/pages/{p}/appearances@{widgetVersion}`, each with its layer twin (and an unversioned layer appearance route), needing `doc.forms.read`; `PATCH …/form/widgets/{pageKey}/{annotKey}` (`doc.forms.updateWidget`). - **Pins:** migration 034 adds `layers.forms_version`, `base_versions.forms_version` and `widget_version` on page rows. Form writes move the form's pins, never the annotation pins; annotation writes the reverse. Page insert/delete, flatten and redaction move both. Plane scopes compare the document pins too, and gain `forms`. - Annotation reads and appearance batches hold no widgets. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – `DELETE /v1/docs/:docId/layers/:layerName/form/widgets/:pageKey/:annotKey` deletes a widget (`doc.forms.modify`), audited as `form.deleteWidget`. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – - `POST /v1/docs/:docId/layers/:layerName/form/effects` is removed: a script run's effects are one change, `POST …/changes`. - A reset of fields already at their defaults, or a display that changes no widget, writes nothing: it can't be undone. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – - Pages report their tab order and list boxes their top row. - A widget update that changes only its colour or size keeps its font; a free text's border colour change keeps its font. - A value write that changes nothing records no undo step. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – An annotation import is a change: kept in the change outcomes under its `Idempotency-Key` with the record that undoes it, so `POST …/changes` with `{ undoOf }` undoes and redoes it, and a retry is answered from the outcome. Still audited as `annot.import`. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Every multipart request and answer has one shape: a JSON `body` part, and each file as a part `resource:` that the body names by role, `resources: { : }`. Annotation create and update, page insert, attachments, a signature's drawn appearance, signature prepare and change ops name their files this way; bundle imports and exports and appearance batches call their JSON part `body`, and an appearance batch's images are `resource:` parts. A named key with no part, and a part nothing names, are refused. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Serve the four page picture families at both tiers: `render/pages`, `render/annotations`, `render/fields` and `render/all` (renamed from `render/annotated`, which now draws form fields too). Each takes `doc.render` plus the read of what it draws, pins the page counters of the planes it draws, and is stored under its own family. - [#830](https://github.com/embedpdf/embed-pdf-viewer/pull/830) by [@bobsingor](https://github.com/bobsingor) – Serve page routes under `:pageKey` (`obj:N`; malformed keys answer 400), accept `pages`/`page` refs in page mutation, extraction, redaction and weak-session bodies, and emit `PageRef` page identity in every response and event while keeping storage keyed by page object number. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – `POST …/pages/reorder`, `POST …/annotations/pages/{pageKey}/items/reorder` and `POST …/form/widgets/{pageKey}/reorder` replace the move routes; page inserts take a `position`. Audit kinds `annot.reorder`, `pages.reorder` and `form.reorderWidgets`. A reorder bumps only its family's pins: annotation reorders the annotation pins, widget reorders the form's. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Widget placements and widget updates take `actions`. Creating a field, adding a widget or updating one with a script, submit or URI action takes `doc.forms.script` too. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Check the caller's authority over an annotation inside the engine's write for updates and deletes, instead of reading the page first: the check and the write see the same document, and each request makes one engine call. The engine checks an update's patch against its annotation's kind. Page flatten and redaction apply fail as a whole when a page fails, leaving the document unchanged; their responses no longer list `'failed'` or `'skipped'` pages. Address annotations as `:annotKey` = `obj:N` or `base:N` on every annotation route; remove the weak annotation session routes, the `index` update and delete route, page revision tokens and the weak annotation columns (migration `031`). Manifest pages are `{ page, cache }`, and annotation reads and write results carry `PageRef`s. `ObjectNumberUnavailable` and `LayerFull` answer HTTP 409. Hand object numbers to editing sessions (migration `032`). An editing session is the client's `X-Engine-Session-Id` together with the token's subject, and lives 15 minutes past its last sign of life. `/access` opens one for a caller that may create and hands it numbers (the body's `objectNumbers`, the response's `edit`); a write tops it up when asked with `EmbedPDF-Reserve-Object-Numbers` and answers `EmbedPDF-Object-Numbers`; `POST /v1/docs/:docId/layers/:layerName/object-numbers` reserves up to 1,000 at once; the event stream sends a `session` event and keeps the session alive. Creates name their numbers in the query string (`objectNumber`, `objectNumbers`, `widgetObjectNumbers`, `splitObjectNumber`), and a number the session doesn't hold is refused `not-held`. What a write makes for itself is numbered past every number handed out, and a publish drops the numbers handed out on its layer. Every layer write route takes `Idempotency-Key`: a retry gets what the first request committed, and no numbers. ### Patch Changes - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Annotation records are typed `Annotation` (was `AnnotationDTO`). - [#869](https://github.com/embedpdf/embed-pdf-viewer/pull/869) by [@bobsingor](https://github.com/bobsingor) – The widget attach and detach routes accept the widget's `AnnotationRef` as `body.widget`; widget records on the wire carry `ref`. - [#841](https://github.com/embedpdf/embed-pdf-viewer/pull/841) by [@bobsingor](https://github.com/bobsingor) – Security fixes: - **Pictures with annotations need `doc.annotate.read`,** at the origin and in CDN grants. They draw no form fields. - **The event stream sends each connection only what its token may read.** Annotations need `doc.annotate.read`; widgets and form fields need `doc.forms.read`. A row with nothing left goes out marked `withheld`, with only its pins. - **Moving annotations checks each one inside the write,** so moving a widget takes `doc.forms.modify`. ## 3.0.0-next.14 ### Minor Changes - [#827](https://github.com/embedpdf/embed-pdf-viewer/pull/827) by [@bobsingor](https://github.com/bobsingor) – Persist page measurement calibration in layer artifacts with authorization and audit events. Calibration advances the document version while retaining existing page cache versions and annotation scales. - [#800](https://github.com/embedpdf/embed-pdf-viewer/pull/800) by [@LazyCompiler](https://github.com/LazyCompiler) – The layer search routes (`/v1/docs/:docId/layers/:layerName/search/{rects,full}/data`) accept `ignoreWhitespace=true` alongside the other query flags and forward it to the engine, so a cloud search for `invoice` finds a letter-spaced `i n v o i c e`. Combining it with `regex=true` is rejected with `InvalidArg`, and the flag is carried by the search tokens that page through results. ## 3.0.0-next.13 ### Minor Changes - [#812](https://github.com/embedpdf/embed-pdf-viewer/pull/812) by [@bobsingor](https://github.com/bobsingor) – Add durable two-phase digital signing with prepare, complete, abort, and expiry handling. Persist candidate data so completion can run on another replica, verify the supplied CMS, and reject completion when the document or layer has changed. Publish each completed signature as an immutable document version while retaining the document ID and version history. Consume the signing layer's edits into the new base and refresh document state across replicas. Add signature inspection and analysis routes, immutable version and revision downloads, and visual signature-field appearances. Use files and streaming storage transfers for signing candidates, with configurable temporary storage and signing expiry. ## 3.0.0-next.12 ### Minor Changes - [#803](https://github.com/embedpdf/embed-pdf-viewer/pull/803) by [@bobsingor](https://github.com/bobsingor) – Add `POST /v1/docs/{docId}/layers/{layerName}/annotations/pages/{pon}/items/flatten` (flatten a chosen set of the page's annotations; gated like page flatten and persisted the same way — one page's content and annotation versions advance) and `POST …/items/appearance` (the chosen annotations' appearances as one single-page PDF; gated by `doc.download`, no-store). Add `POST /v1/docs/{docId}/layers/{layerName}/pages/names` and `POST …/pages/names/delete` to register, rename, or remove a `/Names /Pages` entry on a layer. Both are page-structure mutations gated by `doc.pages.assemble`: the worker writes a new layer artifact and the doc and layout versions advance, exactly like a page move, with no new resource, version, or cache scope. `/layout` responses now include `namedPages`. ## 3.0.0-next.11 ### Minor Changes - [#793](https://github.com/embedpdf/embed-pdf-viewer/pull/793) by [@bobsingor](https://github.com/bobsingor) – Action reads served by `/v1/docs/:docId/actions@:token` (and the layer-scoped variant) now include interpreter payloads on every executable node and the destination-form `/OpenAction` as `openDestination`, via the shared engine-services reader. The wire representation of action nodes changed shape (payload-carrying discriminated union); deploy server and clients from the same prerelease train. ## 3.0.0-next.10 ### Minor Changes - [#788](https://github.com/embedpdf/embed-pdf-viewer/pull/788) by [@bobsingor](https://github.com/bobsingor) – Persist per-layer annotation versions and add versioned page and whole-document annotation reads with audit-head metadata. Expose a no-store backend endpoint for listing every annotation in a layer. Annotation mutations now advance the version atomically so clients can hydrate and retry against coherent snapshots. ## 3.0.0-next.9 ### Minor Changes - [#772](https://github.com/embedpdf/embed-pdf-viewer/pull/772) by [@bobsingor](https://github.com/bobsingor) – Add document routes for inserting PDF pages, creating blank pages, and extracting selected pages. Insert mutations persist the new page set and versions atomically and publish audit events for realtime collaborators. ### Patch Changes - [#787](https://github.com/embedpdf/embed-pdf-viewer/pull/787) by [@bobsingor](https://github.com/bobsingor) – Reusing an explicit `docId` on `documents.init` or `documents.import` now answers a clean `409 Conflict` explaining how to proceed (retry with the same `idempotencyKey` to resume, delete the document to replace it, or use a different/omitted `docId`) instead of surfacing the raw database unique-constraint error as a 500 — including the case where a retry mints a fresh idempotency key per attempt. A `docId` already owned by another tenant answers `403`, mirroring the existing delete semantics. - [#785](https://github.com/embedpdf/embed-pdf-viewer/pull/785) by [@bobsingor](https://github.com/bobsingor) – Fix AWS S3-backed streaming uploads by buffering small source chunks before the SDK applies checksum framing, preventing `InvalidChunkSizeError` during document imports and other streamed writes. Handled 5xx responses now also emit structured error logs with the request ID and HTTP status. ## 3.0.0-next.8 ### Minor Changes - [#783](https://github.com/embedpdf/embed-pdf-viewer/pull/783) by [@bobsingor](https://github.com/bobsingor) – Add a production Helm chart with validated SQLite and Postgres profiles, safety gates, smoke and crash drills, and OCI publishing tied to the server package version. Add Prometheus metrics, drain-aware bounded shutdown and readiness, serialized Postgres migrations, and fail-fast worker supervision. Add opt-in supervised engine-host process isolation with generation-fenced recovery, crash journaling, document quarantine enforcement, engine health reporting, and audited quarantine CLI commands. Repeated engine crashers can be observed or rejected with `DocumentQuarantined`, while native host crashes restart the engine without terminating the API server. Encode page renders, annotation appearances, and warm thumbnails inside engine workers by default so compressed images cross the engine boundary, with a temporary API-side encoding fallback. Add bounded interactive and background scheduling, per-host memory telemetry, controlled engine recycling, and deterministic engine sharding with per-shard readiness and metrics. Add `POST /v1/docs/:docId/access` as the document-scoped access endpoint while retaining `POST /v1/access` as a transitional alias. Head responses advertise the scoped endpoint, and path/body document ID mismatches are rejected. Allow the optional `X-CloudPDF-Doc` affinity header through CORS and expose retry and image metadata response headers to browser clients. ## 3.0.0-next.7 ### Patch Changes - [#771](https://github.com/embedpdf/embed-pdf-viewer/pull/771) by [@bobsingor](https://github.com/bobsingor) – Accepts bodyless requests that carry `Content-Type: application/json` instead of failing them with an unhandled 500. - An empty JSON body now parses as no body rather than `FST_ERR_CTP_EMPTY_JSON_BODY` — the shape the generated PHP, Go, and Ruby SDKs (and clients with default JSON headers) send for bodyless calls such as document delete. Non-empty bodies still go through Fastify's default parser, keeping its prototype-poisoning protection, and routes that require a body still reject its absence with a 400. - The error handler now honors Fastify's `statusCode` on framework errors, so parser and payload rejections (empty or malformed JSON, body limits) surface as the 4xx client errors they are instead of being logged and returned as "unhandled error" 500s. ## 3.0.0-next.6 ### Minor Changes - [#766](https://github.com/embedpdf/embed-pdf-viewer/pull/766) by [@bobsingor](https://github.com/bobsingor) – Add durable asynchronous document imports backed by the `document_imports` job table and an in-process worker with one claim loop per replica. Document and job creation is atomic, lease-token-fenced transitions prevent stale workers from overwriting replacements, reconcile-on-claim avoids duplicate transfers after crashes, and exhausted retries fail the document and clean destination bytes. Retries stay pinned to one content identity, filesystem sources require `expected.sha256`, and queued or running imports are protected from the stale-pending sweeper. Migration 027 stores the re-drivable source descriptor in `source_json`. - [#766](https://github.com/embedpdf/embed-pdf-viewer/pull/766) by [@bobsingor](https://github.com/bobsingor) – Add operator-registered import connections through `CLOUDPDF_IMPORT_CONNECTIONS` for S3 and S3-compatible stores, GCS, Azure Blob, and filesystem roots. Connections enforce credential classes, tenant allowlists, scoped prefixes or tenant-bound key templates, provider-specific revision pinning, and fail-closed authorization. Canonical backend fingerprints reject self-imports, and each import records sanitized source provenance and outcome in the new `document_imports` table from migration 026. A shared conformance suite keeps URL and connection adapters aligned on source-opening behavior. - [#766](https://github.com/embedpdf/embed-pdf-viewer/pull/766) by [@bobsingor](https://github.com/bobsingor) – Implement server-side PDF imports from caller-supplied URLs through the existing document lifecycle. Deployment policy controls size, timeout, concurrency, HTTPS, and public-network requirements; URL handling blocks private and metadata addresses with DNS pinning, rejects redirects, and requires `Content-Length`. Imports enforce optional size and SHA-256 pins, sanitize failures so URL secrets do not leak, leave documents pending after retryable transport failures, and add the `pull` upload kind in migration 025. ### Patch Changes - [#766](https://github.com/embedpdf/embed-pdf-viewer/pull/766) by [@bobsingor](https://github.com/bobsingor) – Mount the document import handler under the renamed `documents.importFrom` contract operation and align the server's import policy and lifecycle terminology. The HTTP route and runtime behavior remain unchanged. - [#766](https://github.com/embedpdf/embed-pdf-viewer/pull/766) by [@bobsingor](https://github.com/bobsingor) – Cloud ObjectStore adapters (S3, GCS, Azure Blob) now truly stream `put` bodies: a `Readable` is hashed and length-enforced as it flows (constant memory) instead of being buffered whole. Under- or over-delivery aborts before a visible object can appear, any prior object at the key survives a failed attempt, and the SHA-256 metadata is attached post-stream (S3 via a same-key server-side copy). FsObjectStore now cleans up its `.partial` file when the source stream errors mid-put. ## 3.0.0-next.5 ### Patch Changes - [#760](https://github.com/embedpdf/embed-pdf-viewer/pull/760) by [@bobsingor](https://github.com/bobsingor) – Keep connected licenses usable during Keygen's three-day `EXPIRING` window by relying on the signed validation decision instead of the informational status label. Licenses whose expiry has elapsed remain denied. ## 3.0.0-next.4 ### Patch Changes - [#750](https://github.com/embedpdf/embed-pdf-viewer/pull/750) by [@bobsingor](https://github.com/bobsingor) – Preserves configured CORS response headers on the hijacked server-sent events stream, allowing browser clients on permitted origins to subscribe to document layer events. ## 3.0.0-next.3 ### Minor Changes - [#748](https://github.com/embedpdf/embed-pdf-viewer/pull/748) by [@bobsingor](https://github.com/bobsingor) – Derives the connected usage-reporting credential from the license key, so a connected deployment is configured with `CLOUDPDF_LICENSE_KEY` alone. - Computes the reporting credential as `cpr_v1_` + base64url(HMAC-SHA256) over a domain-separated message that binds the signed `cloudpdfLicenseId` license metadata, so the wire credential is one-way (it can never reveal the license key) and never authenticates another license record. - Retires `CLOUDPDF_LICENSE_REPORTING_TOKEN`. A deployment that still sets it boots normally; the variable is ignored and the server logs a warning asking for its removal. - Existing connected deployments upgrade by removing the retired variable. During the coordinated verifier cutover on the CloudPDF side a usage report may answer 401; reports retry every five minutes with cumulative counters, so no usage is lost and license validation is unaffected. - Air-gapped deployments are unchanged and continue to send no telemetry. - Pins fixed cross-runtime derivation test vectors shared with the CloudPDF control plane. - [#746](https://github.com/embedpdf/embed-pdf-viewer/pull/746) by [@bobsingor](https://github.com/bobsingor) – Fixes presigned-upload materialization and makes commit-time sha verification single-read and constant-memory. - Fixes the range materializer crashing with `EBADF` whenever an object carried no SHA metadata — the shape of every presigned browser upload. The failure was silent: commits still reached `ready` while the security probe recorded `unknown` and thumbnail warming recorded `failed`. The hash fallback now closes the write-only handle and streams the finished partial from disk, guards against short positional writes, and rejects a metadata/expected-sha disagreement before paying for the download. - Replaces the S3 and FS `getSha256` fallbacks that buffered whole objects in RAM with streaming hashes — constant memory regardless of document size. - Commit now verifies uploaded bytes with a single object-store read when a base-file cache is wired (`DocumentLifecycleOptions.fileCache`): the upload is materialized into the cache, hashed on the way down, and reused by the security probe instead of being downloaded a second time. `LocalFileHandle.sourceKey` reports which object key materialized a content-addressed entry, so a cross-key cache hit still triggers a direct verification of the committing document's own object. - Adds a typed `ShaMismatchError` (exported) thrown by all `materializeLocal` implementations, letting callers distinguish declared-hash mismatches from retryable transport failures. - Surfaces previously swallowed failures: `DocumentSecurityProbeOptions.onError`, `DerivedRenderServiceOptions.onWarmError`, and base-file-cache `materialize-error` events are now wired to the server log. ## 3.0.0-next.2 ### Minor Changes - [#730](https://github.com/embedpdf/embed-pdf-viewer/pull/730) by [@bobsingor](https://github.com/bobsingor) – Implements share grants, origin locking, per-tenant usage, and tenant suspension. - Stores share grants whose row id is the public share token, carrying document capabilities, an optional origin allowlist, an optional scrypt-hashed passphrase, a session TTL, and an optional expiry. Editing or deleting a grant retargets every embedded copy of its token at the next exchange. - Serves the public `POST /v1/share-sessions` exchange, which validates origin, passphrase, expiry, disablement, and tenant suspension before minting a document session JWT. Unknown, revoked, disabled, and suspended grants answer alike so the existence of a grant is never disclosed, and the route carries its own per-IP and per-grant limiters rather than the authentication-failure budget. - Enforces an optional `origins` claim on document tokens for every request that arrives with a browser `Origin` header, covering both share sessions and backend-minted tokens. Requests without the header are governed by the token itself. - Adds CORS through `CLOUDPDF_CORS_ORIGINS` (`*` to reflect, or a comma-separated allowlist), which browser-direct deployments need. Bearer tokens remain the security boundary; per-credential origin locks carry the origin policy a server-wide list cannot express. - Records per-tenant usage facts for views, uploads, and stored bytes, readable at `GET /v1/tenants/:tenantId/usage`. A view is a share exchange or an authorized `/v1/access` grant, counted once across the two. These counters hold no limits and are separate from license metering. - Adds `tenants.suspend` and `tenants.resume`, which fail every tenant JWT, document JWT, and share exchange closed while leaving the root API token free to inspect, resume, or delete the tenant. - Mounts token revocation from the CLI through `CLOUDPDF_ENABLE_REVOCATION`. - Records share and suspension lifecycle events in the security-event trail, and adds matching SQLite and PostgreSQL migrations plus origin, passphrase, and end-to-end share coverage. - [#734](https://github.com/embedpdf/embed-pdf-viewer/pull/734) by [@bobsingor](https://github.com/bobsingor) – Adds integrity-pinned uploads with presigned storage transfer preferred and a policy-controlled multipart proxy fallback. Hardens filesystem-backed storage against path traversal, storage-root deletion, and recursive deletion through symbolic links. ## 3.0.0-next.1 ### Major Changes - [#720](https://github.com/embedpdf/embed-pdf-viewer/pull/720) by [@bobsingor](https://github.com/bobsingor) – Adds the tenant-scoped backend API and root API-token workflow to the self-hosted CloudPDF server. - Replaces the legacy flat admin routes with contract-backed `/v1/tenants/:tenantId` document, tenant, token, and deployment operations. - Adds constant-time root API-token authentication alongside delegated tenant JWT authorization. - Adds tenant lifecycle and provenance tracking, keyset pagination and state filtering, and cascade deletion for tenant-owned data. - Adds document and tenant token issuance, revocation, and durable security-event auditing. - Allows API tokens on document-plane routes and supports per-request `X-Document-Password` authorization through HMAC proofs or non-mutating checks against the canonical PDFium session, including credential-safe open singleflight behavior. - Adds matching SQLite and PostgreSQL migrations plus expanded registry, authorization, password, and end-to-end coverage. ## 3.0.0-next.0 ### Major Changes - [#711](https://github.com/embedpdf/embed-pdf-viewer/pull/711) by [@bobsingor](https://github.com/bobsingor) – Introduces the self-hostable CloudPDF document server. The Fastify service combines authentication, durable storage, native PDF processing, realtime document events, and commercial license enforcement behind the Engine v3 HTTP API.