@tdacorp/hyle-sdk 0.21.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +141 -18
- package/dist/check-routes-bin.js +174 -42
- package/dist/{chunk-56Y24XBV.js → chunk-JHZJOJDC.js} +4 -3
- package/dist/{chunk-K5VDLROQ.js → chunk-SFFBZFEN.js} +34 -1
- package/dist/{chunk-HJX57NLI.js → chunk-UFMKLCXS.js} +246 -225
- package/dist/{chunk-X2TLYM7Y.js → chunk-VUML2UPD.js} +1 -1
- package/dist/chunk-VXARM37R.js +68 -0
- package/dist/{chunk-75JFLML4.js → chunk-YHXE3TGS.js} +94 -12
- package/dist/{client-41fU6OY2.d.cts → client--ighAWaj.d.ts} +13 -1
- package/dist/{client-LwzHwqpM.d.ts → client-DK-S2580.d.cts} +13 -1
- package/dist/code-copy.cjs +4 -2
- package/dist/code-copy.d.cts +5 -2
- package/dist/code-copy.d.ts +5 -2
- package/dist/code-copy.js +5 -3
- package/dist/comments.cjs +14 -6
- package/dist/comments.js +14 -6
- package/dist/docs-enhance.cjs +7 -4
- package/dist/docs-enhance.d.cts +5 -3
- package/dist/docs-enhance.d.ts +5 -3
- package/dist/docs-enhance.js +8 -5
- package/dist/{embed-BUFRQboD.d.ts → embed-XT0x_Jaa.d.cts} +4 -2
- package/dist/{embed-CYt-q13P.d.cts → embed-g7NT1CyB.d.ts} +4 -2
- package/dist/html.cjs +14 -6
- package/dist/html.d.cts +1 -1
- package/dist/html.d.ts +1 -1
- package/dist/html.js +2 -2
- package/dist/index.cjs +85 -12
- package/dist/index.d.cts +13 -11
- package/dist/index.d.ts +13 -11
- package/dist/index.js +2 -2
- package/dist/mermaid-diagram.cjs +46 -6
- package/dist/mermaid-diagram.js +15 -6
- package/dist/mermaid-image.cjs +4 -1
- package/dist/mermaid-image.js +1 -1
- package/dist/next.cjs +521 -242
- package/dist/next.d.cts +74 -17
- package/dist/next.d.ts +74 -17
- package/dist/next.js +207 -33
- package/dist/print-coordinator.js +1 -1
- package/dist/react.cjs +233 -197
- package/dist/react.d.cts +17 -6
- package/dist/react.d.ts +17 -6
- package/dist/react.js +5 -3
- package/dist/{resolve-BjAK0k_Y.d.ts → resolve-BqC9l5RH.d.ts} +1 -1
- package/dist/{resolve-eI1muCKL.d.cts → resolve-CiZCPysX.d.cts} +1 -1
- package/dist/{sanitize-ijiWjEm9.d.cts → sanitize-BpY_AdZh.d.cts} +1 -1
- package/dist/{sanitize-ijiWjEm9.d.ts → sanitize-BpY_AdZh.d.ts} +1 -1
- package/dist/styles.css +4 -4
- package/dist/toc-spy.cjs +2 -1
- package/dist/toc-spy.js +2 -1
- package/dist/{types-3F0wqD-o.d.cts → types-b9QbmEDd.d.cts} +44 -1
- package/dist/{types-3F0wqD-o.d.ts → types-b9QbmEDd.d.ts} +44 -1
- package/dist/use-cache.cjs +73 -3
- package/dist/use-cache.d.cts +3 -3
- package/dist/use-cache.d.ts +3 -3
- package/dist/use-cache.js +3 -3
- package/package.json +3 -3
- package/dist/chunk-67IOIAVW.js +0 -35
package/README.md
CHANGED
|
@@ -43,7 +43,7 @@ import { createRevalidateRoute } from "@tdacorp/hyle-sdk/next";
|
|
|
43
43
|
export const { POST } = createRevalidateRoute({ workspaceId: process.env.HYLE_WORKSPACE_ID, secrets: [process.env.HYLE_WEBHOOK_SECRET] });
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
`app/api/hyle/assets/[file]/route.ts` (images, video and audio in hyle content; see "Media"):
|
|
46
|
+
`app/api/hyle/assets/[file]/route.ts` (images, video and audio in hyle content, and the workspace theme; see "Media" and "Themes"):
|
|
47
47
|
|
|
48
48
|
```ts
|
|
49
49
|
import { createAssetRoute } from "@tdacorp/hyle-sdk/next";
|
|
@@ -113,10 +113,10 @@ const html = hastToHtml(article.content.tree, { baseUrl: "https://example.com/bl
|
|
|
113
113
|
|
|
114
114
|
| Import | Contents | Needs |
|
|
115
115
|
|---|---|---|
|
|
116
|
-
| `@tdacorp/hyle-sdk` | `createHyleClient` (typed `resolve`, `mounts` and `asset`), `listPublicationPaths`, `checkRoutes` and the other route-check functions, `Cp1ClientError`, `verifyHyleSignature`, `parseSignatureHeader`, `isValidCacheTag`, `DeliveryDedupe`, `createRevalidationCallbackRoute`, `parseCommentEvent`, the result types | nothing (no framework) |
|
|
116
|
+
| `@tdacorp/hyle-sdk` | `createHyleClient` (typed `resolve`, `mounts`, `preview` and `asset`), `listPublicationPaths`, `checkRoutes` and the other route-check functions, `Cp1ClientError`, `verifyHyleSignature`, `parseSignatureHeader`, `isValidCacheTag`, `DeliveryDedupe`, `createRevalidationCallbackRoute`, `parseCommentEvent`, the result types | nothing (no framework) |
|
|
117
117
|
| `@tdacorp/hyle-sdk/react` | `ArticlePage`, `Comments`, `HyleReactions`, `ListPage`, `HyleListView`, `HyleArticleView`, `DocsPage`, `NotFound`, `Redirecting`, `Unavailable`, `HyleBody`, `HyleToc`, `HastContent`, `TrustedServerHtml`, `sanitizeHast` | react >= 19 |
|
|
118
118
|
| `@tdacorp/hyle-sdk/html` | `hastToHtml`, `HastLimitError` (server only) | nothing (no framework) |
|
|
119
|
-
| `@tdacorp/hyle-sdk/next` | `hylePage`, `hyleMetadata`, `hyleSitemap`, `hyleFeed`, `hyleRootPage`, `hyleRootMetadata`, `hyleRootSitemap`, `createMarkdownRoute`, `markdownRewritePath`, `createLlmsTxtRoute`, `createRevalidateRoute`, `createAssetRoute`, `createOgImageRoute`, `createEngagementRoute`, `HyleList`, `HyleArticle`, `HyleComments`, `HyleCommentsFallback`, `fetchResolver`, `workspaceTags` | next >= 16 |
|
|
119
|
+
| `@tdacorp/hyle-sdk/next` | `hylePage`, `hyleMetadata`, `hyleSitemap`, `hyleFeed`, `hyleRootPage`, `hyleRootMetadata`, `hyleRootSitemap`, `createMarkdownRoute`, `markdownRewritePath`, `createLlmsTxtRoute`, `createRevalidateRoute`, `createAssetRoute`, `createOgImageRoute`, `createEngagementRoute`, `hylePreviewPage`, `hylePreviewMetadata`, `hyleProtectedPage`, `hyleProtectedMetadata`, `createProtectedUnlockRoute`, `HyleList`, `HyleArticle`, `HyleComments`, `HyleCommentsFallback`, `fetchResolver`, `workspaceTags` | next >= 16 |
|
|
120
120
|
| `@tdacorp/hyle-sdk/next/use-cache` | `cachedResolver` | next >= 16 with `cacheComponents: true` |
|
|
121
121
|
| `@tdacorp/hyle-sdk/styles.css` | the stylesheet | |
|
|
122
122
|
|
|
@@ -159,7 +159,7 @@ The revalidate route expires tags immediately (`revalidateTag(tag, { expire: 0 }
|
|
|
159
159
|
|
|
160
160
|
`list: { title, description }` sets the list page's h1, `<title>`, description and Open Graph. Each wins over hyle's section title (which is the slug, "Posts") and falls back separately: no `list.title` keeps the section title, no `list.description` shows none. Articles are unaffected.
|
|
161
161
|
|
|
162
|
-
List pages show the first page of results (`listLimit`, server default 20, maximum 100). `paginate: "searchParams"` turns on cursor pagination: `?cursor=` is read (it must be 1 to 256 characters of `A-Za-z0-9_-`, otherwise it is ignored; a well-formed cursor hyle rejects is a 404), sent to hyle, and "Older posts" links to `?cursor=<next_cursor>`. It is off by default because reading `searchParams` makes the route dynamic: it can no longer be statically generated or served from ISR (hyle's fetch cache and tags still apply per request). Leave it off when one page is enough. `generateMetadata` reads the cursor too (also under `hyleRootMetadata`), so page 2 has its own canonical and an "Older posts" title suffix.
|
|
162
|
+
List pages show the first page of results (`listLimit`, server default 20, maximum 100). `paginate: "searchParams"` turns on cursor pagination: `?cursor=` is read (it must be 1 to 256 characters of `A-Za-z0-9_-`, otherwise it is ignored; a well-formed cursor hyle rejects is a 404, because the cursor names no page), sent to hyle, and "Older posts" links to `?cursor=<next_cursor>`. It is off by default because reading `searchParams` makes the route dynamic: it can no longer be statically generated or served from ISR (hyle's fetch cache and tags still apply per request). Leave it off when one page is enough. `generateMetadata` reads the cursor too (also under `hyleRootMetadata`), so page 2 has its own canonical and an "Older posts" title suffix.
|
|
163
163
|
|
|
164
164
|
## Errors
|
|
165
165
|
|
|
@@ -167,11 +167,11 @@ How `hylePage` treats a hyle failure is chosen so a bad moment never replaces a
|
|
|
167
167
|
|
|
168
168
|
| Failure | Behaviour |
|
|
169
169
|
|---|---|
|
|
170
|
-
|
|
|
171
|
-
| Network error, timeout, 5xx,
|
|
170
|
+
| hyle's own not-found (`kind: "notfound"`, or a 404 with code `NOT_FOUND`), hyle's `VALIDATION_ERROR` for a request that carried the visitor's `cursor`, a path over 1024 characters, a non-NFC segment, `..` or a double-encoded `%XX` in a segment | `notFound()` (a real 404; the last three never reach hyle) |
|
|
171
|
+
| Network error, timeout, 5xx, **every other 4xx** (400 included, and a 404 from a proxy or firewall in front of hyle), a malformed response, a refused redirect target | **Rethrown.** Under ISR, Next keeps serving the last good page when a revalidation fails; a failure on a first render is an uncached 500 |
|
|
172
172
|
| `notFound()` and redirects | Next control flow, always propagated (`unstable_rethrow`) |
|
|
173
173
|
|
|
174
|
-
Why rethrow: a rendered "unavailable" page is a normal 200 render, so ISR would cache it and replace the last good article for everyone for the revalidate window. `onError: (error) => ReactElement` is the opt-in for a custom UI anyway; its element IS cached like any render, and the `error` it receives can contain `Cp1ClientError.message` and `requestId`, so never render it (only its name is logged, never the token or message). The `Unavailable` component (en, fr, es; `data-hyle-page="unavailable"`, `role="status"`, no error text) is exported from `./react` for `onError` or your own `error.tsx`. `hyleMetadata` follows the same split:
|
|
174
|
+
Why rethrow: a rendered "unavailable" page is a normal 200 render, so ISR would cache it and replace the last good article for everyone for the revalidate window. `onError: (error) => ReactElement` is the opt-in for a custom UI anyway; its element IS cached like any render, and the `error` it receives can contain `Cp1ClientError.message` and `requestId`, so never render it (only its name is logged, never the token or message). The `Unavailable` component (en, fr, es; `data-hyle-page="unavailable"`, `role="status"`, no error text) is exported from `./react` for `onError` or your own `error.tsx`. `hyleMetadata` follows the same split: hyle's not-found gives `{}`, anything else is rethrown, so an outage never caches a noindex page.
|
|
175
175
|
|
|
176
176
|
### More in this section
|
|
177
177
|
|
|
@@ -222,9 +222,9 @@ Why a REQUIRED catch-all: an optional catch-all at the app root (`[[...hyle]]`)
|
|
|
222
222
|
| Situation | Result |
|
|
223
223
|
|---|---|
|
|
224
224
|
| Mounts answer 401 or 403 (revoked token, deprovisioned workspace) | the last good copy is dropped and the error is rethrown (Next keeps the last good ISR page; a first render is an uncached 500) |
|
|
225
|
-
|
|
|
226
|
-
| Mounts fail
|
|
227
|
-
| Mounts fail
|
|
225
|
+
| The read surface is switched off (`kind: "disabled"`) | nothing is served: 404. The last good copy is dropped, so the kill switch is not undone by a later outage |
|
|
226
|
+
| Mounts fail any other way (network, timeout, 5xx, any other 4xx, malformed body) and a copy read within the last 15 minutes exists | that copy decides: unmatched URLs stay a plain 404, mounted pages go on to `hylePage` (which keeps its own last-good-page rule) |
|
|
227
|
+
| Mounts fail that way and there is no usable copy (a cold server, or a copy older than `MOUNTS_MAX_STALE_MS`, 15 minutes) | the error is rethrown: Next keeps the last good ISR page, a first render is an uncached 500. It is not guessed to be a 404, because the URL might be a mounted page |
|
|
228
228
|
| Root mount (`/`) and no usable copy | every unmatched URL errors until hyle is back (the root mount could own any of them) |
|
|
229
229
|
| hyle is down | the host's own pages are unaffected: they never call hyle |
|
|
230
230
|
|
|
@@ -254,7 +254,7 @@ Run it as the last step of the PRODUCTION build (a `postbuild` script, or the bu
|
|
|
254
254
|
| Variable | What |
|
|
255
255
|
|---|---|
|
|
256
256
|
| `HYLE_TARGET_BASE_URL`, `HYLE_TARGET_TOKEN` | already set for the site: finds the workspace through `mounts` (the read token only reads) |
|
|
257
|
-
| `HYLE_CONTROL_TOKEN` | NEW: a control credential (`hyle_tc_...`)
|
|
257
|
+
| `HYLE_CONTROL_TOKEN` | NEW: a control credential (`hyle_tc_...`) carrying `hyle.workspace.sync_host` on that workspace. The read token cannot write and is refused before any request. The Workspace > Agents screen issues read and write only, so an operator issues this one with `scripts/issue-control-credential.mjs --codes hyle.workspace.sync_host` in the hyle repository (a hyle that accepts only identity machine tokens, ADR 0027 there, refuses it, and this command does not send identity tokens). Without the permission the write answers 404. Store it as a secret in the Production scope of the host only |
|
|
258
258
|
| `HYLE_HOST_ID` | optional name for the audit trail; defaults to `VERCEL_PROJECT_PRODUCTION_URL`, or pass `--host` |
|
|
259
259
|
|
|
260
260
|
What is sent: `PUT /cp1/control/workspace/host-reserved-paths` with `{ paths, host, build_id }` (the build id is `.next/BUILD_ID`). The list: static routes exact; a segment with two or more routes becomes `/x/*`; a dynamic route becomes the wildcard on its static prefix (`/shop/[id]` is `/shop/*`, `/docs/[...slug]` is `/docs/*`); skipped are your hyle catch-all (`--hyle-param`), a route with no static prefix, anything on a mount's segment (the checker reports those as (b)), per-build hashed metadata routes (`/opengraph-image-1ycygp`), and `/` when hyle is mounted at the root. At most 512 entries. hyle stores it as a separate set (the workspace's own Reserved paths are never touched), enforces the union when publishing, renaming and re-prefixing, and shows it read-only in the workspace settings with the host, build and time.
|
|
@@ -265,6 +265,35 @@ What is sent: `PUT /cp1/control/workspace/host-reserved-paths` with `{ paths, ho
|
|
|
265
265
|
- **Conflicts.** If a path you now own already has a published hyle page, hyle unpublishes nothing: the result lists those URLs (CLI output and the settings page). Your own route wins in Next, so the hyle page is simply not shown; move or unpublish it in hyle.
|
|
266
266
|
- `--json` adds a `sync` object. The programmatic form is `syncHostReserved({ baseUrl, token, workspaceId, paths, host, buildId })`.
|
|
267
267
|
|
|
268
|
+
### Syncing the theme
|
|
269
|
+
|
|
270
|
+
Keep the site's theme in your repository as `hyle.theme.json` and send it with the same command:
|
|
271
|
+
|
|
272
|
+
```
|
|
273
|
+
hyle-sdk-check-routes --sync --theme --no-check
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
```json
|
|
277
|
+
{
|
|
278
|
+
"v": 1,
|
|
279
|
+
"scheme": "attr+media",
|
|
280
|
+
"values": {
|
|
281
|
+
"light.accent": "#b4400f",
|
|
282
|
+
"dark.accent": "#ff8a3d",
|
|
283
|
+
"radius": "12px",
|
|
284
|
+
"font-heading": { "family": "Fraunces", "fallback": "serif" }
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
- The file is read from the directory you run the command in, and **replaces** the workspace's code theme: a key you remove from it is removed in hyle, and `{ "v": 1, "values": {} }` clears the layer. Without `--theme` nothing happens to it. Precedence per key is hyle's defaults, then the organization theme, then this file, then overrides on hyle's Site theme screen.
|
|
290
|
+
- `scheme` is how dark is chosen: `attr` (a `data-theme` or `data-act` attribute on the root element), `media` (the system preference), `attr+media` (both, the attribute winning; the default), `light-only` or `dark-only`. The keys and their limits are hyle's (ADR 0036 there); hyle validates the file. Font files are uploaded in hyle and named by asset id.
|
|
291
|
+
- **It stays until replaced.** Deleting the file or dropping `--theme` keeps the last synced theme; clear it by syncing `{ "v": 1, "values": {} }`.
|
|
292
|
+
- **Written at build time.** hyle serves the synced theme to whatever deployment is live, so a deploy that fails or is rolled back after the sync leaves the old deployment with the new theme (sync the previous file to undo it). Only non-production Vercel builds are skipped: on any other CI, run `--sync --theme` in production builds only, or a preview build writes the production theme.
|
|
293
|
+
- Credential: the same `HYLE_CONTROL_TOKEN` as above (`hyle.workspace.sync_host`).
|
|
294
|
+
- A refused value changes nothing, and each key is printed with hyle's reason. Keys your hyle does not know are dropped and listed. Failures follow the path sync: a `theme:` warning and exit 0, or exit 3 under `--strict`; non-production Vercel builds are skipped. `--json` adds a `theme` object.
|
|
295
|
+
- Sites are revalidated only when the stylesheet they are served changes.
|
|
296
|
+
|
|
268
297
|
### Limits
|
|
269
298
|
|
|
270
299
|
- A junk URL still renders a 404 page in your site chrome; whether and how long Next keeps that render is Next's own ISR behaviour (not measured here). It never reaches hyle either way.
|
|
@@ -281,7 +310,7 @@ What is sent: `PUT /cp1/control/workspace/host-reserved-paths` with `{ paths, ho
|
|
|
281
310
|
Checklist for a site that mounts hyle at the root (details in the sections named):
|
|
282
311
|
|
|
283
312
|
- A REQUIRED catch-all `app/(site)/[...hyle]/page.tsx` (not `[[...hyle]]`), see "Root catch-all". A single mount that you name (`hylePage` at `/learn`) needs only its own route.
|
|
284
|
-
- `app/api/hyle/assets/[file]/route.ts` exporting `GET` and `HEAD` from `createAssetRoute`, if content has images, video or audio, see "Media".
|
|
313
|
+
- `app/api/hyle/assets/[file]/route.ts` exporting `GET` and `HEAD` from `createAssetRoute`, if content has images, video or audio, or the workspace has a theme, see "Media" and "Themes".
|
|
285
314
|
- `app/api/hyle/og/[...path]/route.ts` exporting `GET` from `createOgImageRoute(options)` (the same options as `hylePage`), and `ogImageRoute: true` in the page options, if you want the default card (needs `siteOrigin`, no `ogImage`): it draws the 1200x630 card, see "Not included". `/api/hyle/og` is reserved by the SDK.
|
|
286
315
|
- hyle's reserved paths must cover `/api/hyle/*` and your other routes: run `hyle-sdk-check-routes --sync` after `next build` (needs `HYLE_CONTROL_TOKEN`), see "Syncing reserved paths".
|
|
287
316
|
- No parent layout or page above the mount may export `dynamicParams = false` (below).
|
|
@@ -330,16 +359,109 @@ hyle stores an image, video or audio reference as `/assets/<uuid>.<ext>`, a path
|
|
|
330
359
|
|
|
331
360
|
How it works: `createAssetRoute` asks hyle for exactly that file (`GET /cp1/read/assets/<file>`, ADR 0015) with the target credential and streams the bytes back. hyle answers only for an asset that a currently published, non-trashed page of this workspace references, so a draft, unpublished or other workspace's asset is a 404 on your site too. Responses carry `Cache-Control: public, max-age=3600, s-maxage=86400, stale-while-revalidate=86400`, hyle's strong `ETag` (revalidation is a 304) and `Accept-Ranges`; `Range` is forwarded, so video and audio seek. After an unpublish a cached copy can still be served for up to the cache window (about a day on a CDN).
|
|
332
361
|
|
|
333
|
-
Safety: the only input is the `file` segment and it must match `<lowercase uuid>[.png|jpg|gif|webp|svg|pdf|mp4|webm|mp3|ogg]` before anything is sent, so the route is not an open proxy. Only `Range`, `If-Range` and `If-None-Match` are forwarded (never the visitor's cookies or `Authorization`); the token goes to hyle only. Response headers are built by the SDK, the content type must be on the asset allowlist (an HTML or script answer is refused), the body is capped at 16 MiB (`maxBytes`) and the upstream call times out after 30 s (`timeoutMs`). Failures are empty responses: 404 for an unknown or unpublished asset, a bad name, a missing configuration or `HYLE_CONTENT_ENABLED=0`, 502 for any upstream error, so hyle's state and your token never leak. SVG is served as `image/svg+xml` with `Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox` and `nosniff` (an `<img>` never runs SVG script; navigating to the URL runs none either).
|
|
362
|
+
Safety: the only input is the `file` segment (a draft preview adds its token, see "Draft preview") and it must match `<lowercase uuid>[.png|jpg|gif|webp|svg|pdf|mp4|webm|mp3|ogg|woff2]`, or the theme stylesheet's name `theme-<16 hex>-<64 hex>.css` (see "Themes"; fetched from `GET /cp1/read/theme.css` with nothing from the visitor's request, `text/css` only, at most 256 KiB), before anything is sent, so the route is not an open proxy. Only `Range`, `If-Range` and `If-None-Match` are forwarded (never the visitor's cookies or `Authorization`); the token goes to hyle only. Response headers are built by the SDK, the content type must be on the asset allowlist (an HTML or script answer is refused), the body is capped at 16 MiB (`maxBytes`) and the upstream call times out after 30 s (`timeoutMs`). Failures are empty responses: 404 for an unknown or unpublished asset, a bad name, a missing configuration or `HYLE_CONTENT_ENABLED=0`, 502 for any upstream error (a 404 without hyle's `NOT_FOUND` body included), so hyle's state and your token never leak. SVG is served as `image/svg+xml` with `Content-Security-Policy: default-src 'none'; style-src 'unsafe-inline'; sandbox` and `nosniff` (an `<img>` never runs SVG script; navigating to the URL runs none either).
|
|
334
363
|
|
|
335
364
|
The route sits under `/api/hyle/*`, which hyle's Reserved paths must cover (`hyle-sdk-check-routes --print-reserved` always lists `/api/hyle/*`, and so does `--sync`), and the checker prints a note when the build has no `/api/hyle/assets/...` route. If your proxy or middleware matcher intercepts `/api`, exclude `/api/hyle/assets`. Nothing renders `/assets/...` for you outside the SDK's components: a custom renderer of the `hast` tree should map `src` the same way (`/assets/<id>.<ext>` to `/api/hyle/assets/<id>.<ext>`).
|
|
336
365
|
|
|
366
|
+
## Themes
|
|
367
|
+
|
|
368
|
+
A theme is set in hyle (the organization's, your repository's `hyle.theme.json`, or the Site theme screen; hyle ADR 0036). When a workspace has one, hyle's answers carry `theme { hash, scope, css, preload }` and the SDK's pages and embeds style themselves. A workspace without a theme renders exactly as before.
|
|
369
|
+
|
|
370
|
+
- **What renders.** `ArticlePage`, `DocsPage`, `ListPage`, `HyleArticleView` and `HyleListView` (pass it the list answer's `theme`; `HyleList` does) render `<HyleTheme>`: a stylesheet link to `/api/hyle/assets/theme-<scope>-<hash>.css` and a preload for up to two theme fonts. For `HyleBody`, `HyleToc` or comments in your own page, render `<HyleTheme theme={article.theme} />` yourself.
|
|
371
|
+
- **What you need.** The asset route above, and `@tdacorp/hyle-sdk/styles.css`. Without the route the link is a 404 and pages keep the default look.
|
|
372
|
+
- **No flash, strict CSP.** React 19 puts the link in the head (`precedence`) and holds the paint until it loads. It is a same-origin file, so the theme needs only `style-src 'self'` and `font-src 'self'`; no inline style is added. Diagrams drawn in the browser still need what "Mermaid diagrams" says.
|
|
373
|
+
- **Caching.** The name holds the hash of the bytes (and `scope`, which names the workspace), so a name that matches the current stylesheet is served `public, max-age=31536000, immutable`. When the theme changes hyle sends the usual revalidation webhook and pages link the new name. A page that still links an older name of the same workspace gets the current stylesheet with `public, max-age=60`. Another workspace's name, and any name when the workspace has no theme, is an uncached 404.
|
|
374
|
+
- **Your own variables.** The theme declares on `.hyle` only the keys it sets, so your `--hyle-*` values on `:root`, `body` or a wrapper keep applying to everything else. For a key the theme sets, the theme wins: move your value into the theme or remove the key from it. A colour the theme sets for light only is `inherit` in dark, so dark shows your own value or the SDK default. Once the theme gives diagrams colours of their own it declares all seven `--hyle-diagram-*` variables, replacing yours. A rule of yours on `.hyle` with the same specificity competes by stylesheet order, which is not something to rely on.
|
|
375
|
+
- **Dark mode** follows the theme's `scheme` (below, "Syncing the theme"); only `hyle.theme.json` sets it. The scheme picks which of the theme's values apply: colours the theme leaves unset still follow your site, under `light-only` and `dark-only` too, so a single-mode theme on a site that switches modes should set every colour it depends on.
|
|
376
|
+
- **One workspace per asset route.** The route holds one credential, so on a host that mounts several workspaces (`hyleRootPage`) only that workspace's theme file is served; the others keep the default look. A theme stylesheet styles every `.hyle` element in the document.
|
|
377
|
+
- After a theme is removed, a browser that navigates client-side keeps the stylesheet it already loaded until the next full load.
|
|
378
|
+
|
|
379
|
+
## Draft preview
|
|
380
|
+
|
|
381
|
+
hyle's editor has "Open on site": it opens `https://<your site>/hyle-preview?token=hyle_pv_...` in a new tab, where `<your site>` is the workspace's site URL in Workspace settings (hyle ADR 0037). The link shows the text as it rendered when it was made, published or not, for 30 minutes. Making a link needs permission to edit documents; a newer link for the same document replaces the older one, and removing its author or making them a viewer closes it. Your site draws it, with its own templates and styles and the workspace's theme, as a published page. Needs the asset route from the quickstart.
|
|
382
|
+
|
|
383
|
+
`app/hyle-preview/page.tsx`, ready made:
|
|
384
|
+
|
|
385
|
+
```tsx
|
|
386
|
+
import { hylePreviewMetadata, hylePreviewPage } from "@tdacorp/hyle-sdk/next";
|
|
387
|
+
|
|
388
|
+
export const metadata = hylePreviewMetadata;
|
|
389
|
+
export default hylePreviewPage({ baseUrl: process.env.HYLE_TARGET_BASE_URL!, token: process.env.HYLE_TARGET_TOKEN! });
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
The ready page opens with an "Unpublished draft preview" banner that needs no stylesheet, so a visitor can tell a draft from your published pages.
|
|
393
|
+
|
|
394
|
+
It takes `components`, `slots`, `layout` (`"article"` or `"docs"`) and `localePrefix` as `hylePage` does. It also accepts `auth` with `workspaceId` in place of `token`; the asset route that serves the images still takes `token`. A link that is wrong, expired, from another workspace or whose document is gone is `notFound()`.
|
|
395
|
+
|
|
396
|
+
Inside your own template, use the fetch, and say on the page that it is an unpublished draft (the ready page's banner is yours to draw here):
|
|
397
|
+
|
|
398
|
+
```tsx
|
|
399
|
+
import { notFound } from "next/navigation";
|
|
400
|
+
import { createHyleClient } from "@tdacorp/hyle-sdk";
|
|
401
|
+
import { HyleBody, HyleTheme } from "@tdacorp/hyle-sdk/react";
|
|
402
|
+
|
|
403
|
+
const client = createHyleClient({ baseUrl: process.env.HYLE_TARGET_BASE_URL!, token: process.env.HYLE_TARGET_TOKEN! });
|
|
404
|
+
|
|
405
|
+
export const metadata = { robots: { index: false, follow: false }, referrer: "no-referrer" as const };
|
|
406
|
+
|
|
407
|
+
export default async function Preview({ searchParams }: { searchParams: Promise<{ token?: string }> }) {
|
|
408
|
+
const result = await client.preview((await searchParams).token);
|
|
409
|
+
if (result.kind !== "preview") notFound();
|
|
410
|
+
return (
|
|
411
|
+
<MyArticle title={result.article.publication.title}>
|
|
412
|
+
<p role="status">Unpublished draft preview</p>
|
|
413
|
+
<HyleTheme theme={result.article.theme} />
|
|
414
|
+
<HyleBody article={result.article} />
|
|
415
|
+
</MyArticle>
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
```
|
|
419
|
+
|
|
420
|
+
The result has `article` (the shape `resolve` returns, always `format: "hast"`; navigation, previous and next, breadcrumbs and translations are empty) and `expires_at`. It also carries the workspace's current `theme` when there is one: `ArticlePage`, `DocsPage` and so `hylePreviewPage` link it, and in your own template you render `<HyleTheme>` ("Themes"). The theme stylesheet and fonts load as on a published page, without the token. Its asset addresses, the cover's `path` too, end in `?hyle_preview=<token>`: keep that query, and `createAssetRoute` forwards it so images that are not published yet load. A `next/image` slot also needs `images.localPatterns` to allow it.
|
|
421
|
+
|
|
422
|
+
The token is a bearer secret for that draft, together with your read credential, which never leaves your server. The SDK sends it to hyle in a header only, fetches with `cache: "no-store"`, never logs it, and refuses to send anything that is not shaped like one. On your side:
|
|
423
|
+
|
|
424
|
+
- Do not wrap the page or the fetch in `use cache` or any cache, and keep `/hyle-preview` and `?hyle_preview=` out of CDN caching rules. The asset route answers them `no-store`.
|
|
425
|
+
- The token is in the page URL and the image URLs, so your access logs and the browser's history record it, and any script on the page can read it from `location.href`. Keep analytics, error reporting and other third-party scripts off this route, including ones your root layout adds to every page.
|
|
426
|
+
- Your proxy or middleware must let `/hyle-preview` through without a sign-in redirect that copies the URL elsewhere, and a catch-all must not claim it.
|
|
427
|
+
|
|
428
|
+
## Protected pages
|
|
429
|
+
|
|
430
|
+
A protected page is a copy of an article that a visitor opens with a password (hyle ADR 0039). It is never published: it is in no list, sitemap, feed or search, and its page is `noindex`. Each invited person has their own password. The site draws it at `/p/<pageId>`.
|
|
431
|
+
|
|
432
|
+
Two route files, ready made:
|
|
433
|
+
|
|
434
|
+
```ts
|
|
435
|
+
// app/p/[id]/page.tsx
|
|
436
|
+
import { hyleProtectedMetadata, hyleProtectedPage } from "@tdacorp/hyle-sdk/next";
|
|
437
|
+
|
|
438
|
+
export const metadata = hyleProtectedMetadata;
|
|
439
|
+
export default hyleProtectedPage({ baseUrl: process.env.HYLE_TARGET_BASE_URL!, token: process.env.HYLE_TARGET_TOKEN! });
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
```ts
|
|
443
|
+
// app/p/[id]/unlock/route.ts
|
|
444
|
+
import { createProtectedUnlockRoute } from "@tdacorp/hyle-sdk/next";
|
|
445
|
+
|
|
446
|
+
export const { POST } = createProtectedUnlockRoute();
|
|
447
|
+
```
|
|
448
|
+
|
|
449
|
+
Without a cookie the page shows a password form (labelled, `autocomplete="off"`, the error announced) that posts to `/p/<pageId>/unlock`. The unlock route checks that the POST is same-origin and that its form body is at most 1 KiB, stores the password in an `HttpOnly`, `Secure`, `SameSite=Lax` cookie named `hyle_p_<pageId>` for 12 hours, and redirects to `/p/<pageId>`. It never calls hyle, so one view is one open. The page then asks hyle with `client.protected(pageId, password)`: a wrong or expired password shows the form again with "Wrong or expired password", and a good one draws the article as a published page does, with its images through `createAssetRoute` (`?hyle_protected=<pageId>` reads the same cookie). The page is rendered per request and is never cached. Every answer that involves a protected page is `Cache-Control: no-store`, `X-Robots-Tag: noindex, nofollow` and `Referrer-Policy: no-referrer`.
|
|
450
|
+
|
|
451
|
+
The password is sent to hyle only in the `cp-protected` header, and a malformed page id or password is refused before anything is sent. The redirect target is built from the validated page id alone. Nothing is logged. Keep analytics off `/p/`, as for `/hyle-preview`: a page URL is shared with the person who holds the password.
|
|
452
|
+
|
|
453
|
+
The page's referrer is `same-origin`, not `no-referrer`: a no-referrer page makes browsers send `Origin: null` on its form POST. The unlock route decides by `Sec-Fetch-Site` when the browser sends it (only `same-origin` is accepted, whatever the `Origin`), and by `Origin` against the request's host otherwise. A host that sets a global `Referrer-Policy: no-referrer` therefore keeps working.
|
|
454
|
+
|
|
455
|
+
The form and its redirect use `/p/<pageId>` from the site root. A `basePath`, or a locale-prefix middleware that rewrites or redirects `/p`, breaks the unlock: keep `/p` (and `/p/<id>/unlock`) out of any basePath, locale or rewrite rule, the same way as `/hyle-preview`.
|
|
456
|
+
|
|
457
|
+
Requires a Hyle with migration 0110 and the `GET /cp1/read/_protected` route (ADR 0039).
|
|
458
|
+
|
|
337
459
|
## Comments, votes and reactions
|
|
338
460
|
|
|
339
461
|
Readers can comment under an article, vote comments up or down and react (like, love, insightful, celebrate) to the article and to comments (hyle ADR 0017 and 0021, `docs/cp1-spec.md` section 3.11). It is off unless you turn it on in three places, and nothing on a cached page changes when someone reacts or votes: the section is fetched in the browser, uncached, after the article has rendered.
|
|
340
462
|
|
|
341
463
|
1. **hyle**: switch engagement on for the workspace and register the site's public key (below).
|
|
342
|
-
2. **A key pair.** `npx hyle-sdk-engage-keygen --out .env.engage`
|
|
464
|
+
2. **A key pair.** In hyle, workspace Engagement settings, "Create signing key" (or "Rotate key") makes an Ed25519 pair in your browser, shows `HYLE_ENGAGE_SIGNING_KEY=...` once for your site's environment, and registers only the PUBLIC key after you confirm you saved the line. To make the pair on your own machine instead, `npx hyle-sdk-engage-keygen --out .env.engage` writes the private key to a new file (mode 0600, never overwritten) in the same form, and prints the PUBLIC key only after that write succeeded, with a warning if git does not ignore the file; `--stdout` is the only mode that prints the private key, and with no arguments the tool prints usage and nothing else. Register that public key in the same dialog under "Use a public key I already made" (an operator can also run `hyctl engagement key set`). hyle's server never receives the private key. When you rotate, the old key stays valid for 24 hours.
|
|
343
465
|
3. **The route file** `app/api/hyle/engage/[...path]/route.ts`:
|
|
344
466
|
|
|
345
467
|
```ts
|
|
@@ -363,7 +485,7 @@ export const { GET, POST, PATCH, PUT, DELETE } = createEngagementRoute({
|
|
|
363
485
|
|
|
364
486
|
Then pass `engagement` to the page: `hylePage({ ..., engagement: { signInHref: "/sign-in" } })`, or `<ArticlePage engagement={{ signInHref: "/sign-in" }} />`. `engagement.endpoint` defaults to `/api/hyle/engage`. `layout: "docs"` has no comments.
|
|
365
487
|
|
|
366
|
-
What the route does, per request: it matches (method, path) against a fixed allowlist (`session`, `comments`, `comments/<uuid>`, `reactions`, `votes`), rebuilds the body with only the known keys (a comment is 1 to 4000 characters, a path is a canonical site path, a reaction `kind` is one of `like`, `love`, `insightful`, `celebrate`, a vote is `{ comment_id, value: 1 | -1 }`), accepts on the listing only `path`, `cursor` and `sort=new` or `sort=top`, each once, and calls hyle with the target credential. An anonymous read carries the bearer only. A signed-in reader's read also carries a separate Ed25519 read assertion (`scope: "read"`, 30 s, not single use) so hyle can add that reader's own state; a write carries a fresh single-use assertion (30 s) of the reader `getReader` returned; a missing or invalid reader is a bare 401 before hyle is called. The browser's cookies and `Authorization` are never forwarded. Writes must be same-origin (`Sec-Fetch-Site: same-origin` when sent, and an `Origin` equal to the request's host, with the scheme compared too when the proxy sends `X-Forwarded-Proto`), carry the header `x-hyle-engage: 1` and `application/json` (at most 20 KiB), otherwise 403/415/413. The host is taken from `X-Forwarded-Host`, else `Host`: behind a proxy that rewrites `Host` or terminates TLS without forwarding these headers, pass `allowedOrigins: ["https://www.example.com"]`, which replaces the derivation with an exact list (scheme, host and port). Every response is `Cache-Control: no-store`. Failures are mapped to a fixed set of codes with no text from hyle: hyle
|
|
488
|
+
What the route does, per request: it matches (method, path) against a fixed allowlist (`session`, `comments`, `comments/<uuid>`, `reactions`, `votes`), rebuilds the body with only the known keys (a comment is 1 to 4000 characters, a path is a canonical site path, a reaction `kind` is one of `like`, `love`, `insightful`, `celebrate`, a vote is `{ comment_id, value: 1 | -1 }`), accepts on the listing only `path`, `cursor` and `sort=new` or `sort=top`, each once, and calls hyle with the target credential. An anonymous read carries the bearer only. A signed-in reader's read also carries a separate Ed25519 read assertion (`scope: "read"`, 30 s, not single use) so hyle can add that reader's own state; a write carries a fresh single-use assertion (30 s) of the reader `getReader` returned; a missing or invalid reader is a bare 401 before hyle is called. The browser's cookies and `Authorization` are never forwarded. Writes must be same-origin (`Sec-Fetch-Site: same-origin` when sent, and an `Origin` equal to the request's host, with the scheme compared too when the proxy sends `X-Forwarded-Proto`), carry the header `x-hyle-engage: 1` and `application/json` (at most 20 KiB), otherwise 403/415/413. The host is taken from `X-Forwarded-Host`, else `Host`: behind a proxy that rewrites `Host` or terminates TLS without forwarding these headers, pass `allowedOrigins: ["https://www.example.com"]`, which replaces the derivation with an exact list (scheme, host and port). Every response is `Cache-Control: no-store`. Failures are mapped to a fixed set of codes with no text from hyle: hyle's `NOT_FOUND` stays 404 (a disabled workspace, a banned reader and a hidden comment look the same), 429 keeps a clamped `Retry-After`, a 409 is an edit after the 10 minute window, and everything else, including a 401 from hyle (a wrong key or credential, which a visitor must not learn), is a 502. The kill switch is `HYLE_ENGAGE_ENABLED` (and `HYLE_CONTENT_ENABLED`): unset, empty, `1` or `true` leave the route on, and ANY other non-empty value (`0`, `false`, `off`, `no`, a typo) answers 404 everywhere; a missing or malformed configuration also answers 404 and never throws at build time. Your proxy or middleware matcher must let `/api/hyle/engage` through, and the route sits under `/api/hyle/*`, which hyle's Reserved paths already cover (see "Collision checker": `--print-reserved` and `--sync` always list it).
|
|
367
489
|
|
|
368
490
|
The component (`Comments`, a client component with no dependency) renders the states of the design kit: signed out, composer, threads to depth 4 (no Reply at depth 4), up and down votes, reactions with a pressed state and optimistic counts, a Newest/Top control, a reader's own pending comment ("Awaiting approval", visible only to them), edited marks, tombstones for removed and deleted comments, a notice for a comment hyle cannot render (`unrenderable`; its author keeps Edit and Delete), empty, loading, load error with Try again, post error that keeps the text, rate limited (the box is disabled, the button is `aria-disabled` and stays focusable), banned, and Load more (20 threads at a time, then hyle's next page). A write that answers 404 is not taken for a ban: the listing and the session are reloaded and a plain error shows; only a second 404 for a still valid session shows the banned message. Comment bodies are the sanitized hast hyle renders; the client sanitizes again with a narrower allowlist (links, emphasis, code, quotes, lists) and builds React elements, never HTML strings. Ctrl or Cmd+Enter posts, Escape closes a reply and returns focus to its button. Styling uses the existing `--hyle-*` variables plus six optional ones: `--hyle-comments-indent`, `--hyle-comments-gap`, `--hyle-comments-avatar-size`, `--hyle-comments-rule`, `--hyle-comments-held` and `--hyle-comments-like-on`. Strings are in en, fr and es (fr and es are unreviewed drafts).
|
|
369
491
|
|
|
@@ -459,7 +581,7 @@ SEO rules the embeds follow, and one you must:
|
|
|
459
581
|
- Nothing in the document head: no `<title>`, `<link>`, `<meta>` or JSON-LD. Your page keeps its own metadata.
|
|
460
582
|
- **Canonical:** a page that embeds a full article with `HyleArticle` must set its own canonical URL to the article's URL on the mount (for example `alternates.canonical` in `generateMetadata`), or the two pages compete as duplicates. A list or a comments embed needs nothing. The embeds build no absolute URLs; those belong to the mount (see its documentation).
|
|
461
583
|
- Headings: the default level is 2, and the article body's headings are h2 and below (a body `h1` is demoted), so under your page's `h1` and a section heading of your own, set `headingLevel` to 3.
|
|
462
|
-
- Failure: an embed never calls `notFound()`, never redirects and never throws on a hyle outage. A missing page, a
|
|
584
|
+
- Failure: an embed never calls `notFound()`, never redirects and never throws on a hyle outage. A missing page, a `cursor` hyle refuses and an empty section render nothing (or the `list.empty` slot). Any other failure is logged by name and renders `onError(error)` if you gave one, else nothing. A missing `workspaceId`, a bad `baseUrl` or an empty `token` is a configuration error and throws.
|
|
463
585
|
- The token is used only in the server-side request. `HyleComments` sends the target credential and nothing else (no reader assertion, no cookie, no header of the visitor), so every visitor shares one cached listing. The server-rendered thread (without `interactive`) is oldest first and has no votes or reactions. The `Comments` island receives the listing, the path, your own `/api/hyle/engage` route and the chrome strings: never the token or hyle's URL.
|
|
464
586
|
|
|
465
587
|
Styling: import `@tdacorp/hyle-sdk/styles.css`. An embed is a `.hyle.hyle-embed` block with no page padding or maximum width, so the host's layout sets its width; `data-layout="grid"` lays the items out as cards (260px minimum columns). The pure markup is also exported as `HyleListView` and `HyleArticleView` from `@tdacorp/hyle-sdk/react` for hosts that fetch for themselves.
|
|
@@ -471,7 +593,8 @@ Zero setup. A Mermaid fence arrives from hyle as a sandboxed `<iframe srcdoc>` t
|
|
|
471
593
|
- What loads when: the server renders a no-JavaScript fallback, a `<figure class="hyle-mermaid">` holding the source as a `language-mermaid` code block. On a page with a diagram, the browser then imports `mermaid` (a dynamic import, so your bundler emits it as lazy chunks served from your own origin) and swaps in the SVG. Pages without a diagram never load it: the client component is not even in their JavaScript. A page loads only the chunks its diagram type needs. `mermaid` itself is 83 MB on disk in `node_modules` (it is not shipped to browsers).
|
|
472
594
|
- Rendering: a small diagram renders when it is within 200 px of the viewport, one at a time; a large one waits for a click (below). The 10 s limit starts after the Mermaid chunk has loaded and covers drawing: past it the code block and the note appear and the next diagram starts, and a result that still arrives is shown. Per-diagram configuration (`%%{init}%%` directives and frontmatter) is stripped, see Security model. A re-render (theme change) keeps the previous SVG on screen until the new one is ready, and keeps it if the new one fails. A throw anywhere in a diagram or its viewer shows that figure's source instead of blanking the page.
|
|
473
595
|
- Themes: your CSS decides, however you switch themes. The figure's computed background picks dark or default (`rgb`, `color(srgb)`, `lab`, `lch`, `oklab`, `oklch`); when it is transparent or unreadable, its computed `color-scheme` does (if it names exactly one scheme), then `prefers-color-scheme`. The diagram redraws when that answer changes after any attribute of `<html>` or `<body>` changes (a class, a `data-*` flag, an inline style) or the OS scheme changes. A switch made only on a wrapper deeper in the page is not watched. The drawn figure carries `data-mermaid-theme`. The dark theme gets a darker edge label box so label text passes WCAG AA.
|
|
474
|
-
-
|
|
596
|
+
- Diagram colours from a Hyle theme: when a theme gives diagrams colours of their own (a `diagram-*` key, or a colour they follow: surface, surface-2, text, border, text-muted, accent), its stylesheet declares `--hyle-diagram-bg`, `-node`, `-node-text`, `-node-border`, `-line`, `-accent` and `-muted`, and the diagram is drawn with Mermaid's `base` theme in those colours, light or dark as above. All seven must be on the figure as `#rrggbb`, `#rrggbbaa` or `transparent` (you can declare them yourself without a theme); otherwise Mermaid's own themes apply. Contrast is the theme author's responsibility.
|
|
597
|
+
- Stored renders: when hyle has a pre-rendered image of the diagram in both themes (only the one it shows under a `light-only` or `dark-only` theme), drawn in the workspace theme's current diagram colours or, until the editor has stored those, in earlier ones (the editor renders it in the author's browser, hyle sanitizes and stores it, ADR 0024), the page gets a sized `<img>` (aspect ratio reserved, so no layout shift), the diagram source in a `<details>` for crawlers and no-JS readers, and no Mermaid layout runs in any browser. The image goes through your asset route (`createAssetRoute`, `img-src 'self'`). Click-to-expand fetches that same sanitized SVG for the viewer. Showing a stored render runs no layout, so it is never gated. If the image fails to load, or hyle has no stored render yet, the page renders the diagram client-side as above (a small one with a loader and a reserved height, a large one behind the Draw button).
|
|
475
598
|
- A source that is not the renderer's template is dropped. There is no length cap on the diagram beyond the 1 MiB `srcdoc` guard, and no cdnjs frame. If Mermaid cannot render the source (a syntax error), the code block stays and a short "diagram could not be rendered" note appears.
|
|
476
599
|
- Host CSP: `script-src 'self'` is enough (plus `'unsafe-inline'` or nonces for Next's own inline scripts, as for any Next app); `style-src 'unsafe-inline'` is required because Mermaid's SVG carries inline styles; `img-src` decides whether images that a diagram label references load. Checked under `default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'; img-src 'self' data:` in headless Chromium on Next 16.2.7, 16.3.4 and 16.4.2 (`node scripts/e2e-next-build.mjs --browser`).
|
|
477
600
|
- Override: `components.Mermaid` still replaces all of this. It receives `{ srcDoc, source, title }`; `source` is the diagram text, or `undefined` when it could not be extracted. `MermaidDiagram` (`{ source, title, errorText, loadingText?, labels? }`) is exported from `./react` if you want to wrap it. It takes nothing but those strings: no token or client ever crosses the boundary.
|
|
@@ -580,4 +703,4 @@ Types in `src/types.ts` mirror `packages/cp1-read/src/resolve.ts`. `src/__tests_
|
|
|
580
703
|
|
|
581
704
|
## Identity machine tokens (`auth` instead of `token`)
|
|
582
705
|
|
|
583
|
-
`createHyleClient`, `syncHostReserved` and `cachedResolver` accept `auth` (a `HyleAuth`) instead of `token`, for a service account of identity (hyle ADR 0027, needs `HYLE_MACHINE_IDENTITY_TOKENS=dual` or `identity` on hyle). The hook is called for every request with `{ method, url }` and returns the headers to send, so the DPoP proof matches that request; with the identity SDK: `auth: (req) => serviceClient.headersFor(token, req)`. `workspaceId` is required and sent as `CP-Workspace`; the token needs `hyle.document.read` on it (`hyle.workspace.
|
|
706
|
+
`createHyleClient`, `syncHostReserved` and `cachedResolver` accept `auth` (a `HyleAuth`) instead of `token`, for a service account of identity (hyle ADR 0027, needs `HYLE_MACHINE_IDENTITY_TOKENS=dual` or `identity` on hyle). The hook is called for every request with `{ method, url }` and returns the headers to send, so the DPoP proof matches that request; with the identity SDK: `auth: (req) => serviceClient.headersFor(token, req)`. `workspaceId` is required and sent as `CP-Workspace`; the token needs `hyle.document.read` on it (`hyle.workspace.sync_host` for `syncHostReserved`). Page, asset and embed helpers still take `token`.
|