@avocadostudio-ai/orchestrator-core 0.25.0 → 0.26.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.
@@ -64,6 +64,7 @@ import { createCmsBootstrapCache } from "../cms/bootstrap.js";
64
64
  import { resolveCapabilities } from "../cms/adapter.js";
65
65
  import { mediaSourceFromUnknown } from "../cms/media-sources.js";
66
66
  import { extractAccessToken, isAccessGateEnabled, isValidAccessToken, mintAccessToken, verifyAccessPassword } from "../http/access-tokens.js";
67
+ import { editorCredentials } from "../http/editor-credentials.js";
67
68
  import { declareLibraryMount, observeLibraryMount } from "./library-mount.js";
68
69
  import { checkAuth, resolveAuth, CLOSED_HINT } from "./auth.js";
69
70
  import { setSiteAssetLister, invalidateSiteAssets } from "../state/site-assets.js";
@@ -262,6 +263,7 @@ const SUPPORTED_ROUTES = [
262
263
  "GET /health",
263
264
  "GET /auth/status",
264
265
  "POST /auth/verify",
266
+ "GET /editor/credentials",
265
267
  "POST /chat",
266
268
  "POST /chat/stream",
267
269
  "POST /chat/start",
@@ -643,6 +645,16 @@ export function createOrchestrator(config = {}) {
643
645
  }
644
646
  return jsonResponse({ ok: true, accessToken: mintAccessToken() }, { cors });
645
647
  }
648
+ /*
649
+ * The site's draft secret and publish token, for a caller the gate above has
650
+ * already let in. See `http/editor-credentials.ts` for why these no longer
651
+ * travel in the editor's HTML. Not in `PUBLIC_PATHS`, and that is the point:
652
+ * on a mount with a credential, a request without a valid token never gets
653
+ * here.
654
+ */
655
+ if (request.method === "GET" && path === "/editor/credentials") {
656
+ return jsonResponse(editorCredentials(), { cors: { ...cors, "cache-control": "no-store" } });
657
+ }
646
658
  if (request.method === "POST" && path === "/chat") {
647
659
  const runtime = await getRuntime();
648
660
  await runtime.ready;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * The two site credentials a signed-in editor needs, served by
3
+ * `GET /editor/credentials` instead of being written into the editor's HTML.
4
+ *
5
+ * - `siteDraftSecret` rides on every preview URL the editor builds, because the
6
+ * draft cookie is routinely blocked in a cross-origin iframe. Without it a
7
+ * production site renders its published pages and nothing is selectable.
8
+ * - `publishToken` is the `x-publish-token` the standalone server checks on
9
+ * publish (library mode authenticates publish with the access token instead).
10
+ *
11
+ * Both used to reach the browser only through `window.__AVOCADO_CONFIG__`,
12
+ * which the self-host CLI writes into `index.html`. That page is served before
13
+ * the password gate runs, so an editor hosted on a public URL handed the site's
14
+ * draft secret to anyone who loaded it. With that secret, anyone could read the
15
+ * CMS's unpublished drafts through the site's preview route, password or not.
16
+ * Served from here, they reach only a caller the access gate has already let in.
17
+ *
18
+ * Absent values are omitted rather than sent as empty strings, so the editor
19
+ * keeps whatever it was configured with when this process holds nothing.
20
+ */
21
+ export interface EditorCredentials {
22
+ siteDraftSecret?: string;
23
+ publishToken?: string;
24
+ }
25
+ export declare function editorCredentials(env?: Record<string, string | undefined>): EditorCredentials;
@@ -0,0 +1,9 @@
1
+ import { getConfiguredDraftSecret } from "@avocadostudio-ai/shared";
2
+ export function editorCredentials(env = process.env) {
3
+ const siteDraftSecret = getConfiguredDraftSecret(env) ?? undefined;
4
+ const publishToken = env.PUBLISH_TOKEN?.trim() || undefined;
5
+ return {
6
+ ...(siteDraftSecret ? { siteDraftSecret } : {}),
7
+ ...(publishToken ? { publishToken } : {})
8
+ };
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@avocadostudio-ai/orchestrator-core",
3
- "version": "0.25.0",
3
+ "version": "0.26.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  "./package.json": "./package.json",
@@ -22,8 +22,8 @@
22
22
  "openai": "^4.87.1",
23
23
  "sharp": "^0.35.4",
24
24
  "zod": "^4.3.6",
25
- "@avocadostudio-ai/migration-sdk": "^0.25.0",
26
- "@avocadostudio-ai/shared": "^0.25.0"
25
+ "@avocadostudio-ai/migration-sdk": "^0.26.0",
26
+ "@avocadostudio-ai/shared": "^0.26.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@anthropic-ai/claude-agent-sdk": "^0.3.220",