webcake-landing-mcp 1.18.2 → 1.18.3

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.
@@ -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,11 @@
1
1
  [
2
+ {
3
+ "v": "1.18.3",
4
+ "d": "01/12/2026",
5
+ "type": "Fixed",
6
+ "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…",
7
+ "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…"
8
+ },
2
9
  {
3
10
  "v": "1.18.2",
4
11
  "d": "01/12/2026",
@@ -33,12 +40,5 @@
33
40
  "type": "Fixed",
34
41
  "en": "clone_page and ingest_html/ingest_url with intent:'clone' now dismiss cookie/consent/newsletter banners, promo modals and chat widgets (clicking…",
35
42
  "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")) {
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.3",
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",