webcake-landing-mcp 1.7.0 → 1.9.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.
@@ -29,6 +29,74 @@
29
29
  */
30
30
  import { randomBytes, createHash } from "node:crypto";
31
31
  import { getPg, ensureOAuthSchema } from "../persistence/postgres.js";
32
+ import { jwtExpired } from "../persistence/config.js";
33
+ import { getRedis } from "../persistence/redis.js";
34
+ // ---- Dead Webcake sessions -------------------------------------------------
35
+ // The OAuth tokens outlive the Webcake JWT they wrap. Once that JWT is expired (or the
36
+ // backend rejected it), refreshing would just re-issue the dead JWT; refusing it makes the
37
+ // client restart the full flow, i.e. open the Connect page again.
38
+ // Shared across instances: markJwtDead revokes every OAuth token wrapping the JWT in the
39
+ // store (Postgres = source of truth) and flags it in Redis for raw ?jwt= callers.
40
+ // Only a sha256 of the JWT is kept, never the token itself.
41
+ const DEAD_PREFIX = "wc:lp:deadjwt:";
42
+ const DEAD_MAX_TTL = 30 * 24 * 60 * 60 * 1000;
43
+ const deadLocal = new Map(); // hash → expiresAt (ms)
44
+ const jwtHash = (jwt) => createHash("sha256").update(jwt).digest("hex");
45
+ function deadTtl(jwt) {
46
+ try {
47
+ const exp = JSON.parse(Buffer.from(jwt.split(".")[1], "base64url").toString()).exp;
48
+ if (typeof exp === "number")
49
+ return Math.min(Math.max(exp * 1000 - Date.now(), 60_000), DEAD_MAX_TTL);
50
+ }
51
+ catch { /* opaque token */ }
52
+ return DEAD_MAX_TTL;
53
+ }
54
+ function rememberDeadLocally(hash, ttl) {
55
+ if (deadLocal.size > 10_000)
56
+ for (const [k, exp] of deadLocal)
57
+ if (exp < Date.now())
58
+ deadLocal.delete(k);
59
+ if (deadLocal.size > 10_000)
60
+ deadLocal.delete(deadLocal.keys().next().value); // still full: drop oldest
61
+ deadLocal.set(hash, Date.now() + ttl);
62
+ }
63
+ /** Expired, or already marked dead here — no I/O. */
64
+ function isDeadLocally(jwt) {
65
+ if (jwtExpired(jwt))
66
+ return true;
67
+ const exp = deadLocal.get(jwtHash(jwt));
68
+ return exp !== undefined && exp >= Date.now();
69
+ }
70
+ /** The backend rejected this JWT: make every instance treat it as dead. Never throws. */
71
+ export async function markJwtDead(jwt) {
72
+ if (!jwt)
73
+ return;
74
+ const hash = jwtHash(jwt);
75
+ const ttl = deadTtl(jwt);
76
+ rememberDeadLocally(hash, ttl);
77
+ try {
78
+ await getRedis()?.set(DEAD_PREFIX + hash, "1", "PX", ttl);
79
+ await (await getStore()).revokeJwt(jwt);
80
+ }
81
+ catch (e) {
82
+ console.error("[oauth] markJwtDead:", e?.message ?? e);
83
+ }
84
+ }
85
+ /** True when the JWT is expired or any instance marked it dead. */
86
+ export async function isDeadJwt(jwt) {
87
+ if (!jwt)
88
+ return false;
89
+ if (isDeadLocally(jwt))
90
+ return true;
91
+ const redis = getRedis();
92
+ if (!redis)
93
+ return false;
94
+ const hash = jwtHash(jwt);
95
+ const hit = await redis.get(DEAD_PREFIX + hash).catch(() => null);
96
+ if (hit)
97
+ rememberDeadLocally(hash, deadTtl(jwt));
98
+ return !!hit;
99
+ }
32
100
  // ---- TTLs (override via env where useful) ---------------------------------
33
101
  const TEN_MIN = 10 * 60 * 1000;
34
102
  const ACCESS_TTL = Number(process.env.WEBCAKE_OAUTH_ACCESS_TTL_MS) || 60 * 60 * 1000; // 1h
@@ -113,6 +181,14 @@ class MemoryStore {
113
181
  this.access.delete(t);
114
182
  this.refresh.delete(t);
115
183
  }
184
+ async revokeJwt(ljwt) {
185
+ for (const [k, v] of this.access)
186
+ if (v.ljwt === ljwt)
187
+ this.access.delete(k);
188
+ for (const [k, v] of this.refresh)
189
+ if (v.ljwt === ljwt)
190
+ this.refresh.delete(k);
191
+ }
116
192
  }
117
193
  // ---- Postgres store (when DATABASE_URL is set) ----------------------------
118
194
  class PgStore {
@@ -206,6 +282,11 @@ class PgStore {
206
282
  await this.pool.query(`DELETE FROM oauth_access_tokens WHERE token=$1`, [t]);
207
283
  await this.pool.query(`DELETE FROM oauth_refresh_tokens WHERE token=$1`, [t]);
208
284
  }
285
+ // ponytail: no index on ljwt — a seq scan, but this only runs when a JWT dies.
286
+ async revokeJwt(ljwt) {
287
+ await this.pool.query(`DELETE FROM oauth_access_tokens WHERE ljwt=$1`, [ljwt]);
288
+ await this.pool.query(`DELETE FROM oauth_refresh_tokens WHERE ljwt=$1`, [ljwt]);
289
+ }
209
290
  }
210
291
  // ---- Backend selection (memoized) -----------------------------------------
211
292
  const memoryStore = new MemoryStore();
@@ -373,6 +454,9 @@ export async function exchangeToken(p) {
373
454
  if (!r) {
374
455
  return { ok: false, status: 400, error: "invalid_grant", error_description: "Unknown or expired refresh token." };
375
456
  }
457
+ if (await isDeadJwt(r.ljwt)) {
458
+ return { ok: false, status: 400, error: "invalid_grant", error_description: "Webcake session expired — sign in again (Connect)." };
459
+ }
376
460
  return { ok: true, body: await issueTokens(store, r.ljwt, r.client_id, r.scope) };
377
461
  }
378
462
  return { ok: false, status: 400, error: "unsupported_grant_type", error_description: "grant_type must be authorization_code or refresh_token." };
@@ -383,7 +467,7 @@ export async function resolveAccessToken(accessToken) {
383
467
  if (!accessToken)
384
468
  return undefined;
385
469
  const a = await (await getStore()).getAccess(accessToken);
386
- return a?.ljwt;
470
+ return a && !isDeadLocally(a.ljwt) ? a.ljwt : undefined;
387
471
  }
388
472
  /** Revoke an access or refresh token (best-effort; for /revoke). */
389
473
  export async function revokeToken(t) {
@@ -0,0 +1,111 @@
1
+ import { closeSync, mkdirSync, openSync, statSync, unlinkSync } from "node:fs";
2
+ import { join } from "node:path";
3
+ import { configDir, configFromHeaders, jwtExpired, readConfig, readSavedConfig } from "../persistence/config.js";
4
+ import { markJwtDead } from "./oauth-server.js";
5
+ import { runLogin } from "./login.js";
6
+ // One browser Connect at a time — across every stdio process on this machine (several IDE
7
+ // windows share ~/.webcake-landing-mcp): the first takes a lock file and opens the browser,
8
+ // the others wait for the token it saves. After a failed/abandoned Connect, wait before
9
+ // reopening so a looping agent doesn't spam tabs.
10
+ const LOGIN_WAIT_MS = 185_000; // runLogin times out at 180s
11
+ const lockPath = () => join(configDir(), "renew.lock");
12
+ let renewing = null;
13
+ let lastFail = 0;
14
+ /** auth.json holds a token newer than `stale` and not expired (another process renewed it). */
15
+ const savedFresh = (stale) => {
16
+ const jwt = readSavedConfig().jwt;
17
+ return !!jwt && jwt !== stale && !jwtExpired(jwt);
18
+ };
19
+ function takeLock() {
20
+ try {
21
+ mkdirSync(configDir(), { recursive: true });
22
+ closeSync(openSync(lockPath(), "wx"));
23
+ return true;
24
+ }
25
+ catch {
26
+ try {
27
+ if (Date.now() - statSync(lockPath()).mtimeMs > LOGIN_WAIT_MS) {
28
+ unlinkSync(lockPath()); // left behind by a crashed process
29
+ return takeLock();
30
+ }
31
+ }
32
+ catch { /* raced with its owner releasing it */ }
33
+ return false;
34
+ }
35
+ }
36
+ async function renew(stale) {
37
+ if (savedFresh(stale))
38
+ return true;
39
+ if (!takeLock()) {
40
+ // Someone else has the browser open — wait for the token they save.
41
+ for (const until = Date.now() + LOGIN_WAIT_MS; Date.now() < until;) {
42
+ await new Promise((r) => setTimeout(r, 1000));
43
+ if (savedFresh(stale))
44
+ return true;
45
+ try {
46
+ statSync(lockPath());
47
+ }
48
+ catch {
49
+ return savedFresh(stale);
50
+ } // released without a token
51
+ }
52
+ return false;
53
+ }
54
+ try {
55
+ console.error("[webcake-landing] Token hết hạn — mở trình duyệt để Kết nối lại…");
56
+ await runLogin([]);
57
+ return true;
58
+ }
59
+ finally {
60
+ try {
61
+ unlinkSync(lockPath());
62
+ }
63
+ catch { /* already gone */ }
64
+ }
65
+ }
66
+ export function renewInBrowser(staleJwt) {
67
+ if (!renewing && Date.now() - lastFail > 120_000) {
68
+ renewing = renew(staleJwt)
69
+ .then((ok) => {
70
+ if (!ok)
71
+ lastFail = Date.now();
72
+ return ok;
73
+ })
74
+ .catch((e) => {
75
+ lastFail = Date.now();
76
+ console.error("[webcake-landing] gia hạn token thất bại:", e?.message || e);
77
+ return false;
78
+ })
79
+ .finally(() => {
80
+ renewing = null;
81
+ });
82
+ }
83
+ return renewing ?? Promise.resolve(false);
84
+ }
85
+ /** Every backend call reports auth failures as "Backend returned 401…" in the tool result. */
86
+ export function isUnauthorized(result) {
87
+ return !!result?.content?.some((c) => typeof c?.text === "string" && /Backend returned 401\b/.test(c.text));
88
+ }
89
+ const jwtOf = (extra) => readConfig(configFromHeaders(extra?.requestInfo?.headers)).config?.jwt;
90
+ export function renewAuthOnExpiry(server, stdio) {
91
+ const tool = server.tool.bind(server);
92
+ server.tool = (...args) => {
93
+ const handler = args[args.length - 1];
94
+ args[args.length - 1] = async (...call) => {
95
+ const extra = call[call.length - 1];
96
+ const before = jwtOf(extra);
97
+ if (stdio && jwtExpired(before))
98
+ await renewInBrowser(before);
99
+ const used = jwtOf(extra);
100
+ const result = await handler(...call);
101
+ if (!isUnauthorized(result))
102
+ return result;
103
+ if (!stdio) {
104
+ await markJwtDead(used);
105
+ return result;
106
+ }
107
+ return (await renewInBrowser(used)) ? handler(...call) : result;
108
+ };
109
+ return tool(...args);
110
+ };
111
+ }
@@ -1,4 +1,18 @@
1
1
  [
2
+ {
3
+ "v": "1.9.0",
4
+ "d": "19/11/2026",
5
+ "type": "Changed",
6
+ "en": "A Webcake JWT the backend rejects is now marked dead in a shared store (Redis + Postgres) instead of a single process's memory, so every remote…",
7
+ "vi": "Một JWT Webcake bị backend từ chối nay được đánh dấu \"chết\" trong một store chung (Redis + Postgres) thay vì chỉ nằm trong bộ nhớ của một process,…"
8
+ },
9
+ {
10
+ "v": "1.8.0",
11
+ "d": "19/11/2026",
12
+ "type": "Added",
13
+ "en": "The stdio server now detects an expired or backend-rejected WEBCAKE_JWT and automatically reopens the browser Connect page, then retries the failing…",
14
+ "vi": "Server stdio nay tự phát hiện WEBCAKE_JWT đã hết hạn hoặc bị backend từ chối, tự mở lại trang Connect trên trình duyệt, rồi thử lại tool bị lỗi một…"
15
+ },
2
16
  {
3
17
  "v": "1.7.0",
4
18
  "d": "05/11/2026",
@@ -26,19 +40,5 @@
26
40
  "type": "Added",
27
41
  "en": "The self-hosted screenshot route behind render_preview now caps concurrent Playwright captures at RENDER_SCREENSHOT_CONCURRENCY (default 2), queuing…",
28
42
  "vi": "Route screenshot self-hosted phía sau render_preview nay giới hạn số lượt chụp Playwright chạy đồng thời theo RENDER_SCREENSHOT_CONCURRENCY (mặc…"
29
- },
30
- {
31
- "v": "1.5.11",
32
- "d": "13/10/2026",
33
- "type": "Fixed",
34
- "en": "The HTTP server now answers HEAD requests the same way it answers GET on every public read-only route (/privacy, /privacy-policy, /terms, /tos,…",
35
- "vi": "HTTP server nay trả lời request HEAD giống như GET trên mọi route công khai chỉ-đọc (/privacy, /privacy-policy, /terms, /tos, /favicon.ico,…"
36
- },
37
- {
38
- "v": "1.5.10",
39
- "d": "13/10/2026",
40
- "type": "Changed",
41
- "en": "Rewrote every tool and parameter description (new_element, new_page_skeleton, validate_page, layout, ingest_html, ingest_url, search_images,…",
42
- "vi": "Viết lại toàn bộ mô tả tool và tham số (new_element, new_page_skeleton, validate_page, layout, ingest_html, ingest_url, search_images, get_icon_svg,…"
43
43
  }
44
44
  ]
package/dist/http.js CHANGED
@@ -24,7 +24,7 @@ import { searchPexels, resolvePexelsKey } from "./persistence/pexels-client.js";
24
24
  import { captureWithPlaywright, captureTilesWithPlaywright, isAllowedScreenshotUrl } from "./persistence/screenshot-playwright.js";
25
25
  import { resolveEnv, ENVIRONMENTS, stripTrailingSlash } from "./persistence/config.js";
26
26
  import { buildConnectUrl } from "./auth/login.js";
27
- import { registerClient, startAuthorize, completeAuthorize, exchangeToken, resolveAccessToken, revokeToken, authServerMetadata, protectedResourceMetadata, } from "./auth/oauth-server.js";
27
+ import { registerClient, startAuthorize, completeAuthorize, exchangeToken, resolveAccessToken, isDeadJwt, revokeToken, authServerMetadata, protectedResourceMetadata, } from "./auth/oauth-server.js";
28
28
  const MCP_PATH = "/mcp";
29
29
  const IMAGES_PATH = "/api/images/search";
30
30
  const RENDER_SCREENSHOT_PATH = "/api/render/screenshot";
@@ -474,24 +474,28 @@ export async function startHttpServer(port) {
474
474
  // Accept credentials via ?jwt=/?api_base=/... (for clients that can't set headers).
475
475
  applyQueryAuth(req);
476
476
  // OAuth access token → resolve to the user's landing JWT and inject it as the
477
- // normal x-webcake-jwt header, so persistence/config.ts is unchanged. A legacy
478
- // raw JWT sent via x-webcake-jwt / ?jwt= still wins and passes straight through.
477
+ // normal x-webcake-jwt header, so persistence/config.ts is unchanged. It WINS over a
478
+ // ?jwt= / x-webcake-jwt: a Bearer from our OAuth flow is what the last Connect issued,
479
+ // so it's the renewed credential when the URL still carries an old, expired JWT.
479
480
  const bearer = bearerFrom(req);
480
481
  const oauthLjwt = await resolveAccessToken(bearer);
481
- if (oauthLjwt && req.headers["x-webcake-jwt"] == null) {
482
+ if (oauthLjwt) {
482
483
  req.headers["x-webcake-jwt"] = oauthLjwt;
483
484
  req.rawHeaders.push("x-webcake-jwt", oauthLjwt);
484
485
  }
485
- // Enforcement (WEBCAKE_OAUTH=1): a request with NO recognized credential gets a
486
- // 401 + WWW-Authenticate so Claude/ChatGPT kick off the OAuth flow. Legacy creds
487
- // (x-webcake-jwt header or ?jwt= → mapped above) still pass; in enforced mode a
488
- // raw JWT must use those, since Bearer is reserved for OAuth access tokens.
489
- if (OAUTH_ENFORCED && !oauthLjwt && req.headers["x-webcake-jwt"] == null) {
486
+ // Enforcement: no credential, or an expired/rejected Webcake JWT, gets a 401 +
487
+ // WWW-Authenticate so Claude/ChatGPT (re)open the Connect page by themselves. In
488
+ // enforced mode a raw JWT must use x-webcake-jwt / ?jwt=, since Bearer is reserved
489
+ // for OAuth access tokens.
490
+ const given = req.headers["x-webcake-jwt"];
491
+ const dead = await isDeadJwt(Array.isArray(given) ? given[0] : given);
492
+ if (OAUTH_ENFORCED && (given == null || dead)) {
490
493
  res.writeHead(401, {
491
- "www-authenticate": `Bearer resource_metadata="${publicBase(req)}${WELL_KNOWN_PR}"`,
494
+ "www-authenticate": `Bearer error="invalid_token", resource_metadata="${publicBase(req)}${WELL_KNOWN_PR}"`,
492
495
  "content-type": "application/json",
493
496
  });
494
- return res.end(JSON.stringify({ error: "invalid_token", error_description: "Authentication required — connect via OAuth." }));
497
+ const why = dead ? "Webcake session expired — reconnect (Connect) to renew it." : "Authentication required — connect via OAuth.";
498
+ return res.end(JSON.stringify({ error: "invalid_token", error_description: why }));
495
499
  }
496
500
  const sidHeader = req.headers["mcp-session-id"];
497
501
  const sessionId = Array.isArray(sidHeader) ? sidHeader[0] : sidHeader;
@@ -43,6 +43,16 @@ export const ENVIRONMENTS = {
43
43
  staging: { apiBase: "https://api.staging.webcake.io", appBase: "https://staging.webcake.io", builderBase: "https://builder.staging.webcake.io", previewBase: "https://staging.webcake.me", buildBase: undefined },
44
44
  prod: { apiBase: "https://api.webcake.io", appBase: "https://webcake.io", builderBase: "https://builder.webcake.io", previewBase: "https://www.webcake.me", buildBase: "https://build.webcake.io" },
45
45
  };
46
+ /** True when `token` is a JWT whose `exp` is past (with `skewSec` margin). Non-JWTs never count as expired. */
47
+ export function jwtExpired(token, skewSec = 30) {
48
+ try {
49
+ const exp = JSON.parse(Buffer.from(String(token).split(".")[1], "base64url").toString()).exp;
50
+ return typeof exp === "number" && exp * 1000 < Date.now() + skewSec * 1000;
51
+ }
52
+ catch {
53
+ return false;
54
+ }
55
+ }
46
56
  export function stripTrailingSlash(s) {
47
57
  return s?.replace(/\/+$/, "");
48
58
  }
@@ -77,7 +87,10 @@ export function readConfig(overrides = {}) {
77
87
  // A named environment supplies default base URLs; explicit values still win.
78
88
  const preset = resolveEnv(overrides.env ?? process.env.WEBCAKE_ENV);
79
89
  const base = overrides.base ?? process.env.WEBCAKE_API_BASE ?? preset?.apiBase ?? saved.base;
80
- const jwt = overrides.jwt ?? process.env.WEBCAKE_JWT ?? saved.jwt;
90
+ // An expired env JWT (pinned in the IDE config) loses to a fresher one saved by a re-login.
91
+ const envJwt = process.env.WEBCAKE_JWT;
92
+ const renewed = !!envJwt && jwtExpired(envJwt) && !!saved.jwt && !jwtExpired(saved.jwt);
93
+ const jwt = overrides.jwt ?? (renewed ? saved.jwt : envJwt) ?? saved.jwt;
81
94
  const missing = [];
82
95
  if (!base)
83
96
  missing.push("WEBCAKE_API_BASE");
package/dist/server.js CHANGED
@@ -10,6 +10,7 @@ import { readFileSync } from "node:fs";
10
10
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
11
11
  import { landingDomain } from "./domains/landing/index.js";
12
12
  import { registerTools } from "./tools/index.js";
13
+ import { renewAuthOnExpiry } from "./auth/renew.js";
13
14
  import { ICON_DATA_URI, ICON_MIME, BRAND } from "./branding.js";
14
15
  /**
15
16
  * The published package version, read at runtime from package.json so the MCP
@@ -45,6 +46,7 @@ export function createServer({ allowLocalFiles = true } = {}) {
45
46
  websiteUrl: BRAND.websiteUrl,
46
47
  icons: [{ src: ICON_DATA_URI, mimeType: ICON_MIME, sizes: ["any"] }],
47
48
  }, { instructions: landingDomain.instructions });
49
+ renewAuthOnExpiry(server, allowLocalFiles); // allowLocalFiles ⇔ stdio (the user's own machine)
48
50
  registerTools(server, landingDomain, { allowLocalFiles });
49
51
  return server;
50
52
  }
package/dist/smoke.js CHANGED
@@ -19,7 +19,9 @@ import { matchAccountDomain, normalizeDomain } from "./persistence/domain-match.
19
19
  import { normalizePhoto, resolvePexelsKey, pexelsKeyFromHeaders, resolvePexelsProxyBase, buildSearchQuery, PEXELS_PROXY_DEFAULT, variantPixels, annotateVariantSizes } from "./persistence/pexels-client.js";
20
20
  import { putDraft, getDraft, updateDraft, deleteDraft } from "./persistence/draft-cache.js";
21
21
  import { buildConnectUrl, parseCallback } from "./auth/login.js";
22
- import { redirectMatches } from "./auth/oauth-server.js";
22
+ import { redirectMatches, isDeadJwt, markJwtDead } from "./auth/oauth-server.js";
23
+ import { isUnauthorized, renewAuthOnExpiry } from "./auth/renew.js";
24
+ import { jwtExpired } from "./persistence/config.js";
23
25
  import { isLocalPath, resolveLocalPath, sniffMime, localContentType } from "./tools/media.js";
24
26
  import { buildMicrolinkUrl } from "./persistence/screenshot-client.js";
25
27
  import { isPrivateHost, isAllowedScreenshotUrl, acquireSlot, releaseSlot, slotStats } from "./persistence/screenshot-playwright.js";
@@ -2549,6 +2551,29 @@ console.log("== publish_page: custom_domain matches the account's stored domain
2549
2551
  check("domain: empty account list → no match", !matchAccountDomain("shop.vn", []).ok);
2550
2552
  check("domain: normalizeDomain drops port + trailing dot", normalizeDomain(" Shop.VN.:8080/a ") === "shop.vn", normalizeDomain(" Shop.VN.:8080/a "));
2551
2553
  }
2554
+ console.log("== auth: expired token → Connect again ==");
2555
+ {
2556
+ const jwt = (dSec) => `h.${Buffer.from(JSON.stringify({ exp: Math.floor(Date.now() / 1000) + dSec })).toString("base64url")}.s`;
2557
+ const OLD = jwt(-3600), NEW = jwt(3600);
2558
+ check("auth: jwtExpired reads exp; opaque tokens never expire", jwtExpired(OLD) && !jwtExpired(NEW) && !jwtExpired("opaque"));
2559
+ check("auth: expired JWT is dead (OAuth refresh + resolve refuse it)", (await isDeadJwt(OLD)) && !(await isDeadJwt(NEW)));
2560
+ await markJwtDead("rejected-by-backend");
2561
+ check("auth: backend-rejected JWT is dead", await isDeadJwt("rejected-by-backend"));
2562
+ check("auth: isUnauthorized spots a backend 401 in a tool result", isUnauthorized({ content: [{ type: "text", text: '{"ok":false,"error":"Backend returned 401: Unauthorized"}' }] }) && !isUnauthorized({ content: [{ type: "text", text: '{"error":"Backend returned 403"}' }] }));
2563
+ const saveEnv = process.env.WEBCAKE_JWT;
2564
+ process.env.WEBCAKE_JWT = OLD;
2565
+ check("auth: expired env JWT loses to a fresh override", readConfig({ env: "prod", jwt: NEW }).config?.jwt === NEW);
2566
+ if (saveEnv === undefined)
2567
+ delete process.env.WEBCAKE_JWT;
2568
+ else
2569
+ process.env.WEBCAKE_JWT = saveEnv;
2570
+ // Remote wrapper: a 401 result marks the request's JWT dead so the next /mcp call 401s into Connect.
2571
+ const fake = { tool: (...a) => (fake.h = a[a.length - 1]) };
2572
+ renewAuthOnExpiry(fake, false);
2573
+ fake.tool("t", async () => ({ content: [{ type: "text", text: "Backend returned 401: Unauthorized" }] }));
2574
+ await fake.h({}, { requestInfo: { headers: { "x-webcake-jwt": "remote-rejected", "x-webcake-env": "prod" } } });
2575
+ check("auth: remote 401 marks the session JWT dead", await isDeadJwt("remote-rejected"));
2576
+ }
2552
2577
  console.log("== server: MCP serverInfo.version follows package.json (no hardcoded constant) ==");
2553
2578
  {
2554
2579
  const pkg = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
@@ -121,7 +121,7 @@ export function sceneHtml(lang) {
121
121
  .map((s, i) => `<li${i === 0 ? ' class="cur"' : ""}><button type="button" class="sc-step"><span class="sc-n">${i + 1}</span><span>${s.t}</span></button><div class="sc-dw"><p>${s.d}</p></div></li>`)
122
122
  .join("\n ")}
123
123
  </ol>
124
- <button type="button" class="sc-ctl" hidden></button>
124
+ <button type="button" class="sc-ctl" hidden>${c.pause}</button>
125
125
  </div>
126
126
  </section>`;
127
127
  }
@@ -171,10 +171,13 @@ export const GLASS_CSS = `
171
171
  .sc{position:relative;width:min(1180px,calc(100vw - 32px));margin-left:calc(50% - min(590px,calc(50vw - 16px)))}
172
172
  .sc-stage{display:none;position:relative;overflow:hidden;height:clamp(440px,46vw,600px)}
173
173
  .js .sc.on .sc-stage{display:block}
174
- .sc-stage canvas{position:absolute;inset:0;width:100%;height:100%;display:block}
174
+ .sc-stage canvas{position:absolute;inset:0;width:100%;height:100%;display:block;opacity:0;transition:opacity .45s ease}
175
+ /* Canvas + labels wait for the first drawn frame, so the labels never flash stacked at 0,0. */
176
+ .sc-tag{opacity:0}
177
+ .sc.ready .sc-stage canvas,.sc.ready .sc-tag{opacity:1}
175
178
  .sc-tag{position:absolute;left:0;top:0;padding:5px 13px 6px;border-radius:14px;text-align:center;white-space:nowrap;line-height:1.25;
176
179
  color:var(--ink);background:var(--glass-strong);box-shadow:inset 0 1px 0 var(--rim),0 8px 18px -12px rgba(0,0,0,.5);
177
- -webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);pointer-events:none;will-change:transform;transition:color .25s ease}
180
+ -webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);pointer-events:none;will-change:transform;transition:color .25s ease,opacity .45s ease}
178
181
  .sc-tag b{display:block;font-size:.84rem}
179
182
  .sc-tag small{display:block;font-size:.72rem;font-weight:500;color:var(--mut)}
180
183
  .sc-tag.on b{color:var(--g7)}
@@ -199,8 +202,10 @@ export const GLASS_CSS = `
199
202
  color:var(--g7);font:inherit;font-size:.84rem;font-weight:700}
200
203
  .sc-ctl:hover{background:rgba(127,160,140,.14)}
201
204
  .sc-ctl[hidden]{display:none}
205
+ /* Reserve the play/pause row before three.js arrives so the panel doesn't grow. */
206
+ @media(prefers-reduced-motion:no-preference){.js .sc.on .sc-ctl[hidden]{display:block;visibility:hidden}}
202
207
  @media(max-width:639px){.sc-stage{height:520px}.sc-tag small{font-size:.68rem}.nav{margin-left:0;margin-right:0}}
203
- @media(prefers-reduced-motion:reduce){.sc-dw,.sc-step,.sc-n,.sc-tag{transition:none}}
208
+ @media(prefers-reduced-motion:reduce){.sc-dw,.sc-step,.sc-n,.sc-tag,.sc-stage canvas{transition:none}}
204
209
  @media(prefers-reduced-transparency:reduce){
205
210
  .glass,.iconbtn,.langsw,.btn.ghost,.btn.ghost:hover,.nav,.tip,.sc-tag{background-color:var(--card);background-image:none;
206
211
  -webkit-backdrop-filter:none;backdrop-filter:none}
@@ -545,6 +550,7 @@ export const SCENE_JS = String.raw `
545
550
  }
546
551
  syncCtl();
547
552
  renderer.render(scene,camera);
553
+ root.classList.add('ready');
548
554
  }
549
555
  function syncCtl(){
550
556
  if(reduced)return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "webcake-landing-mcp",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
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",