webcake-landing-mcp 1.18.2 → 1.18.4

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.
@@ -89,7 +89,7 @@ function activateApp(name) {
89
89
  return;
90
90
  // Re-focus by process name via System Events (works for terminals whose app
91
91
  // name differs from the process, e.g. iTerm/Terminal/Warp/VS Code).
92
- execFile("osascript", ["-e", `tell application "System Events" to set frontmost of (first application process whose name is "${name.replace(/"/g, '\\"')}") to true`], () => { });
92
+ execFile("osascript", ["-e", `tell application "System Events" to set frontmost of (first application process whose name is "${name.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}") to true`], () => { });
93
93
  }
94
94
  const SUCCESS_HTML = `<!doctype html><html lang="en"><head><meta charset="utf-8">
95
95
  <meta name="viewport" content="width=device-width,initial-scale=1"><title>Connected to Webcake</title>
@@ -150,6 +150,10 @@ class MemoryStore {
150
150
  this.pending.delete(state);
151
151
  return p && p.expiresAt >= now() ? p : undefined;
152
152
  }
153
+ async peekPending(state) {
154
+ const p = this.pending.get(state);
155
+ return p && p.expiresAt >= now() ? p : undefined;
156
+ }
153
157
  async putCode(code, c) {
154
158
  this.codes.set(code, c);
155
159
  }
@@ -235,6 +239,13 @@ class PgStore {
235
239
  expiresAt: Number(r.expires_at),
236
240
  };
237
241
  }
242
+ async peekPending(state) {
243
+ const { rows } = await this.pool.query(`SELECT client_id, redirect_uri, expires_at FROM oauth_pending WHERE state=$1`, [state]);
244
+ const r = rows[0];
245
+ if (!r || Number(r.expires_at) < now())
246
+ return undefined;
247
+ return { client_id: r.client_id, redirect_uri: r.redirect_uri, expiresAt: Number(r.expires_at) };
248
+ }
238
249
  async putCode(code, c) {
239
250
  await this.pool.query(`INSERT INTO oauth_codes (code, client_id, redirect_uri, code_challenge, scope, ljwt, wsid, expires_at)
240
251
  VALUES ($1,$2,$3,$4,$5,$6,$7,$8)`, [code, c.client_id, c.redirect_uri, c.code_challenge, c.scope ?? null, sealCred(c.ljwt), sealCred(c.wsid), c.expiresAt]);
@@ -357,6 +368,21 @@ export async function registerClient(body) {
357
368
  (await getStore()).putClient(client).catch((e) => console.error("[oauth] putClient:", e?.message ?? e));
358
369
  return { ok: true, client };
359
370
  }
371
+ /**
372
+ * Who a pending /authorize belongs to, for the consent page to display. Looked up server-side by
373
+ * `state` so the page never shows a client the link itself claims (query params are forgeable).
374
+ */
375
+ export async function pendingClientInfo(state) {
376
+ if (!state)
377
+ return undefined;
378
+ const store = await getStore();
379
+ const p = await store.peekPending(state);
380
+ if (!p)
381
+ return undefined;
382
+ const client = await store.getClient(p.client_id);
383
+ const name = client?.client_name ? Array.from(client.client_name).slice(0, 60).join("") : undefined;
384
+ return { client_host: new URL(p.redirect_uri).hostname, client_name: name };
385
+ }
360
386
  export async function getClient(clientId) {
361
387
  if (!clientId)
362
388
  return undefined;
@@ -1,4 +1,18 @@
1
1
  [
2
+ {
3
+ "v": "1.18.4",
4
+ "d": "02/12/2026",
5
+ "type": "Fixed",
6
+ "en": "render_preview no longer accepts a per-request x-render-screenshot-base header to choose which screenshot proxy host this server calls, since a…",
7
+ "vi": "render_preview nay không còn nhận header x-render-screenshot-base theo từng request để chọn host proxy chụp ảnh mà server này gọi, vì một caller từ…"
8
+ },
9
+ {
10
+ "v": "1.18.3",
11
+ "d": "01/12/2026",
12
+ "type": "Fixed",
13
+ "en": "The OAuth /authorize consent page no longer trusts the client_host/client_name query parameters on its own login link to decide which app it…",
14
+ "vi": "Trang consent /authorize của OAuth nay không còn tin vào tham số query client_host/client_name trên chính link đăng nhập của nó để quyết định hiển…"
15
+ },
2
16
  {
3
17
  "v": "1.18.2",
4
18
  "d": "01/12/2026",
@@ -26,19 +40,5 @@
26
40
  "type": "Fixed",
27
41
  "en": "The hosted remote-connector OAuth flow now rejects Dynamic Client Registration and /authorize requests whose redirect_uri is not a known MCP client…",
28
42
  "vi": "Luồng OAuth của remote connector đã hosted nay từ chối các yêu cầu Dynamic Client Registration và /authorize có redirect_uri không phải callback của…"
29
- },
30
- {
31
- "v": "1.17.0",
32
- "d": "28/11/2026",
33
- "type": "Fixed",
34
- "en": "clone_page and ingest_html/ingest_url with intent:'clone' now dismiss cookie/consent/newsletter banners, promo modals and chat widgets (clicking…",
35
- "vi": "clone_page và ingest_html/ingest_url với intent:'clone' nay bỏ các lớp cookie/consent/newsletter, modal quảng cáo và widget chat (bấm nút chấp…"
36
- },
37
- {
38
- "v": "1.16.2",
39
- "d": "28/11/2026",
40
- "type": "Fixed",
41
- "en": "login and the OAuth connect flow now also capture the landing session id (wsid, the SPA's lwsid cookie) alongside the JWT and persistence calls send…",
42
- "vi": "login và luồng OAuth connect nay cũng lấy thêm session id landing (wsid, tức cookie lwsid của SPA) cùng với JWT, và các lượt gọi persistence gửi nó…"
43
43
  }
44
44
  ]
package/dist/http.js CHANGED
@@ -25,7 +25,7 @@ import { captureWithPlaywright, captureTilesWithPlaywright, assertPublicUrl, set
25
25
  import { resolveEnv, ENVIRONMENTS, stripTrailingSlash, readConfig, configFromHeaders } from "./persistence/config.js";
26
26
  import { listOrganizations } from "./persistence/webcake-client.js";
27
27
  import { buildConnectUrl } from "./auth/login.js";
28
- import { registerClient, startAuthorize, completeAuthorize, exchangeToken, resolveAccessToken, isDeadJwt, markJwtDead, revokeToken, initOAuthStore, pendingCookieName, authServerMetadata, protectedResourceMetadata, } from "./auth/oauth-server.js";
28
+ import { registerClient, startAuthorize, completeAuthorize, exchangeToken, resolveAccessToken, isDeadJwt, markJwtDead, revokeToken, pendingClientInfo, initOAuthStore, pendingCookieName, authServerMetadata, protectedResourceMetadata, } from "./auth/oauth-server.js";
29
29
  const MCP_PATH = "/mcp";
30
30
  const IMAGES_PATH = "/api/images/search";
31
31
  const RENDER_SCREENSHOT_PATH = "/api/render/screenshot";
@@ -35,6 +35,7 @@ const WELL_KNOWN_AS = "/.well-known/oauth-authorization-server";
35
35
  const OAUTH_REGISTER = "/register";
36
36
  const OAUTH_AUTHORIZE = "/authorize";
37
37
  const OAUTH_CALLBACK = "/oauth/callback"; // where /mcp-connect bounces the user's ljwt back
38
+ const OAUTH_CLIENT_INFO = "/oauth/client-info"; // consent page: who is asking, by state
38
39
  const OAUTH_TOKEN = "/token";
39
40
  const OAUTH_REVOKE = "/revoke";
40
41
  // OAuth enforcement is ON by default so an OAuth-capable client (Claude/ChatGPT/
@@ -314,11 +315,8 @@ async function handleOAuth(req, res, path) {
314
315
  }
315
316
  // Send the user to the SPA login; it returns here with ?token=<ljwt>[&wsid=<lwsid>]&state=<internalState>.
316
317
  const callback = `${issuer}${OAUTH_CALLBACK}`;
317
- // client_host + client_name let the consent page show who is asking and where the code goes.
318
- const loginUrl = buildConnectUrl(connectPageUrl(), callback, result.internalState, {
319
- client_host: new URL(sp.get("redirect_uri")).hostname,
320
- client_name: result.clientName ? Array.from(result.clientName).slice(0, 60).join("") : undefined,
321
- });
318
+ // The consent page asks OAUTH_CLIENT_INFO who is connecting (by state), never trusting its own URL.
319
+ const loginUrl = buildConnectUrl(connectPageUrl(), callback, result.internalState);
322
320
  const c = pendingCookie(issuer, result.internalState);
323
321
  res.writeHead(302, { location: loginUrl, "set-cookie": `${c.name}=1; Max-Age=600${c.attrs}` });
324
322
  return res.end(), true;
@@ -326,6 +324,17 @@ async function handleOAuth(req, res, path) {
326
324
  // ---- Login callback: the SPA handed back the user's ljwt → mint a code ----
327
325
  // Legacy: GET ?token=&wsid=&state=. Preferred: the SPA puts them in the #fragment (never sent to a
328
326
  // server or logged); GET then serves CALLBACK_PAGE, which re-POSTs them here from the same origin.
327
+ // ---- Consent page: which client is this pending request for (looked up by state) ----
328
+ if (path === OAUTH_CLIENT_INFO) {
329
+ const cors = { "access-control-allow-origin": "*", "cache-control": "no-store" };
330
+ if (req.method === "OPTIONS")
331
+ return res.writeHead(204, { ...cors, "access-control-allow-methods": "GET" }), res.end(), true;
332
+ if (req.method !== "GET")
333
+ return oauthError(res, 405, "invalid_request", "Use GET."), true;
334
+ const info = await pendingClientInfo(new URL(req.url ?? "/", "http://x").searchParams.get("state"));
335
+ res.writeHead(info ? 200 : 404, { "content-type": "application/json", ...cors });
336
+ return res.end(JSON.stringify(info ?? { error: "unknown_state" })), true;
337
+ }
329
338
  if (path === OAUTH_CALLBACK && (req.method === "GET" || req.method === "POST")) {
330
339
  const sp = req.method === "POST" ? new URLSearchParams(await readRawBody(req)) : new URL(req.url ?? "/", "http://x").searchParams;
331
340
  if (req.method === "GET" && !sp.get("token")) {
@@ -33,12 +33,6 @@ export function resolveScreenshotProxyBase(override) {
33
33
  const base = override ?? process.env.RENDER_SCREENSHOT_BASE;
34
34
  return base && base.trim() !== "" ? base.replace(/\/+$/, "") : undefined;
35
35
  }
36
- /** Pull the per-request proxy base header (remote mode), if present. */
37
- export function screenshotProxyBaseFromHeaders(headers) {
38
- const v = headers?.["x-render-screenshot-base"];
39
- const raw = Array.isArray(v) ? v[0] : v;
40
- return raw && raw.trim() !== "" ? raw.trim() : undefined;
41
- }
42
36
  /** Which engine to try FIRST: "microlink" (free, default) or "proxy" (the keyed/self-hosted route). */
43
37
  export function resolveScreenshotPrimary(override) {
44
38
  const v = (override ?? process.env.RENDER_SCREENSHOT_PRIMARY ?? "").toLowerCase();
@@ -192,6 +192,10 @@ export function registerApiGatewayTools(server) {
192
192
  const missingPath = pathParams(o.path).filter((p) => params[p] == null || params[p] === "");
193
193
  if (missingPath.length)
194
194
  return { ok: false, error: `Missing path_params: ${missingPath.join(", ")}. Call sheet: api_find({ id: "${o.id}" }).` };
195
+ // encodeURIComponent keeps "." / "..", and the URL parser would resolve them onto another (refused) route.
196
+ const dotted = pathParams(o.path).filter((p) => /^\.{1,2}$/.test(String(params[p])));
197
+ if (dotted.length)
198
+ return { ok: false, error: `Invalid path_params: ${dotted.join(", ")} cannot be "." or "..".` };
195
199
  const path = o.path.replace(/:(\w+)/g, (_, p) => encodeURIComponent(String(params[p])));
196
200
  const input = o.method === "GET" ? args.query || {} : args.body || {};
197
201
  const missing = (o.required || []).filter((k) => input[k] === undefined);
@@ -28,7 +28,7 @@ import { homedir } from "node:os";
28
28
  import { fileURLToPath } from "node:url";
29
29
  import { text, image, images } from "../mcp/response.js";
30
30
  import { searchPexels, searchImagesViaProxy, resolvePexelsKey, resolvePexelsProxyBase, pexelsKeyFromHeaders, annotateVariantSizes, IMAGE_SIZE_GUIDE, } from "../persistence/pexels-client.js";
31
- import { captureScreenshot, captureScreenshotTiles, resolveScreenshotProxyBase, screenshotProxyBaseFromHeaders, resolveMicrolinkKey, microlinkKeyFromHeaders, } from "../persistence/screenshot-client.js";
31
+ import { captureScreenshot, captureScreenshotTiles, resolveScreenshotProxyBase, resolveMicrolinkKey, microlinkKeyFromHeaders, } from "../persistence/screenshot-client.js";
32
32
  import { uploadImageMultipart, uploadImagePreferCollection, resolveCollectionOrgId, listOrganizations, } from "../persistence/webcake-client.js";
33
33
  import { resolveIconSvg } from "../persistence/icon-client.js";
34
34
  import { sniffMime } from "../persistence/rehost.js";
@@ -252,7 +252,7 @@ export function registerMediaTools(server, allowLocalFiles = true) {
252
252
  });
253
253
  });
254
254
  // 13c) Render a page/URL to a screenshot the model can SEE --------------------
255
- server.tool("render_preview", "Renders a public URL to a PNG screenshot and returns it as an image. `page_id` targets a created page's preview URL (/preview/<id>); `url` targets any public page and takes precedence. full_page (default true) captures the whole scrollable page and `width` sets the viewport; `tiles:true` returns a tall page as several top-to-bottom band images (requires a self-hosted Playwright host via RENDER_SCREENSHOT_BASE, otherwise a single image is returned). Engine: Microlink's free tier by default (API: https://microlink.io/docs/api/getting-started/overview; about 50 requests/day per IP — when rate-limited the result is ok:false with HTTP 429), or a self-hosted screenshot proxy set by RENDER_SCREENSHOT_BASE / x-render-screenshot-base; MICROLINK_API_KEY / x-microlink-key raises the quota. A page published without a custom domain serves its preview for about 10 minutes after the last publish; after that the preview shows 'Preview page is expired'. Docs: https://github.com/vuluu2k/webcake-landing-mcp/blob/main/docs/tools.md", {
255
+ server.tool("render_preview", "Renders a public URL to a PNG screenshot and returns it as an image. `page_id` targets a created page's preview URL (/preview/<id>); `url` targets any public page and takes precedence. full_page (default true) captures the whole scrollable page and `width` sets the viewport; `tiles:true` returns a tall page as several top-to-bottom band images (requires a self-hosted Playwright host via RENDER_SCREENSHOT_BASE, otherwise a single image is returned). Engine: Microlink's free tier by default (API: https://microlink.io/docs/api/getting-started/overview; about 50 requests/day per IP — when rate-limited the result is ok:false with HTTP 429), or a self-hosted screenshot proxy set by RENDER_SCREENSHOT_BASE; MICROLINK_API_KEY / x-microlink-key raises the quota. A page published without a custom domain serves its preview for about 10 minutes after the last publish; after that the preview shows 'Preview page is expired'. Docs: https://github.com/vuluu2k/webcake-landing-mcp/blob/main/docs/tools.md", {
256
256
  page_id: z.string().optional().describe("A created page's id — screenshots its /preview/<id> URL (built from the preview base). Provide page_id OR url."),
257
257
  url: z.string().optional().describe("Any public http(s) URL to screenshot (e.g. the reference page being cloned). Wins over page_id."),
258
258
  full_page: z.boolean().optional().describe("Capture the whole scrollable page (default true) vs just the viewport."),
@@ -268,7 +268,8 @@ export function registerMediaTools(server, allowLocalFiles = true) {
268
268
  return text({ ok: false, error: "Pass `page_id` (to shoot its /preview/<id>) or `url`." });
269
269
  }
270
270
  const resolved = {
271
- proxyBase: resolveScreenshotProxyBase(screenshotProxyBaseFromHeaders(headers)),
271
+ // The proxy host is the operator's (env), never a caller header: a remote caller would pick where this server sends requests.
272
+ proxyBase: resolveScreenshotProxyBase(),
272
273
  microlinkKey: resolveMicrolinkKey(microlinkKeyFromHeaders(headers)),
273
274
  };
274
275
  // Tiles mode (tall pages): a stack of readable top→bottom bands. Needs a
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webcake-landing-mcp",
3
- "version": "1.18.2",
3
+ "version": "1.18.4",
4
4
  "description": "MCP server exposing Webcake landing-page element schemas + AI usage hints, and persisting LLM-generated page sources to a Webcake backend.",
5
5
  "mcpName": "io.github.vuluu2k/webcake-landing-mcp",
6
6
  "type": "module",