webcake-landing-mcp 1.16.1 → 1.16.2
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/dist/auth/login.js +3 -2
- package/dist/auth/oauth-server.js +21 -18
- package/dist/changelog.json +7 -7
- package/dist/http.js +13 -7
- package/dist/persistence/config.js +6 -0
- package/dist/persistence/postgres.js +3 -0
- package/dist/persistence/webcake-client.js +7 -4
- package/dist/smoke.js +4 -0
- package/package.json +1 -1
package/dist/auth/login.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* 1. open a loopback server on 127.0.0.1:<port>,
|
|
7
7
|
* 2. open the browser to the Webcake "connect" URL with redirect_uri=<loopback>,
|
|
8
8
|
* 3. the user is already logged in to Webcake, so Webcake reads their `jwt`
|
|
9
|
-
* cookie server-side and 302s back to the loopback with ?token=<jwt
|
|
9
|
+
* cookie server-side and 302s back to the loopback with ?token=<jwt>[&wsid=<lwsid>],
|
|
10
10
|
* 4. we save it to the credentials file (persistence/config.ts#saveSavedConfig),
|
|
11
11
|
* which the stdio/http server then reads automatically.
|
|
12
12
|
*
|
|
@@ -159,7 +159,7 @@ export function parseCallback(reqUrl, expectedState) {
|
|
|
159
159
|
return { ok: false, status: 400, reason: "no token in the callback — re-run the command" };
|
|
160
160
|
if (url.searchParams.get("state") !== expectedState)
|
|
161
161
|
return { ok: false, status: 400, reason: "state mismatch (login link truncated or expired) — re-run the command" };
|
|
162
|
-
return { ok: true, token };
|
|
162
|
+
return { ok: true, token, sessionId: url.searchParams.get("wsid") || url.searchParams.get("session_id") || undefined };
|
|
163
163
|
}
|
|
164
164
|
export async function runLogin(argv) {
|
|
165
165
|
const opts = parseArgs(argv);
|
|
@@ -193,6 +193,7 @@ export async function runLogin(argv) {
|
|
|
193
193
|
try {
|
|
194
194
|
path = saveSavedConfig({
|
|
195
195
|
jwt: cb.token,
|
|
196
|
+
sessionId: cb.sessionId, // undefined drops a stale one from a previous login
|
|
196
197
|
base: stripTrailingSlash(apiBase),
|
|
197
198
|
appBase: stripTrailingSlash(appBase),
|
|
198
199
|
...(opts.orgId ? { orgId: opts.orgId } : {}),
|
|
@@ -232,11 +232,11 @@ class PgStore {
|
|
|
232
232
|
};
|
|
233
233
|
}
|
|
234
234
|
async putCode(code, c) {
|
|
235
|
-
await this.pool.query(`INSERT INTO oauth_codes (code, client_id, redirect_uri, code_challenge, scope, ljwt, expires_at)
|
|
236
|
-
VALUES ($1,$2,$3,$4,$5,$6,$7)`, [code, c.client_id, c.redirect_uri, c.code_challenge, c.scope ?? null, c.ljwt, c.expiresAt]);
|
|
235
|
+
await this.pool.query(`INSERT INTO oauth_codes (code, client_id, redirect_uri, code_challenge, scope, ljwt, wsid, expires_at)
|
|
236
|
+
VALUES ($1,$2,$3,$4,$5,$6,$7,$8)`, [code, c.client_id, c.redirect_uri, c.code_challenge, c.scope ?? null, c.ljwt, c.wsid, c.expiresAt]);
|
|
237
237
|
}
|
|
238
238
|
async takeCode(code) {
|
|
239
|
-
const { rows } = await this.pool.query(`DELETE FROM oauth_codes WHERE code=$1 RETURNING client_id, redirect_uri, code_challenge, scope, ljwt, expires_at`, [code]);
|
|
239
|
+
const { rows } = await this.pool.query(`DELETE FROM oauth_codes WHERE code=$1 RETURNING client_id, redirect_uri, code_challenge, scope, ljwt, wsid, expires_at`, [code]);
|
|
240
240
|
const r = rows[0];
|
|
241
241
|
if (!r || Number(r.expires_at) < now())
|
|
242
242
|
return undefined;
|
|
@@ -246,14 +246,15 @@ class PgStore {
|
|
|
246
246
|
code_challenge: r.code_challenge,
|
|
247
247
|
scope: r.scope ?? undefined,
|
|
248
248
|
ljwt: r.ljwt,
|
|
249
|
+
wsid: r.wsid ?? "",
|
|
249
250
|
expiresAt: Number(r.expires_at),
|
|
250
251
|
};
|
|
251
252
|
}
|
|
252
253
|
async putAccess(t, a) {
|
|
253
|
-
await this.pool.query(`INSERT INTO oauth_access_tokens (token, ljwt, scope, expires_at) VALUES ($1,$2,$3,$4)`, [t, a.ljwt, a.scope ?? null, a.expiresAt]);
|
|
254
|
+
await this.pool.query(`INSERT INTO oauth_access_tokens (token, ljwt, wsid, scope, expires_at) VALUES ($1,$2,$3,$4,$5)`, [t, a.ljwt, a.wsid, a.scope ?? null, a.expiresAt]);
|
|
254
255
|
}
|
|
255
256
|
async getAccess(t) {
|
|
256
|
-
const { rows } = await this.pool.query(`SELECT ljwt, scope, expires_at FROM oauth_access_tokens WHERE token=$1`, [t]);
|
|
257
|
+
const { rows } = await this.pool.query(`SELECT ljwt, wsid, scope, expires_at FROM oauth_access_tokens WHERE token=$1`, [t]);
|
|
257
258
|
const r = rows[0];
|
|
258
259
|
if (!r)
|
|
259
260
|
return undefined;
|
|
@@ -261,18 +262,19 @@ class PgStore {
|
|
|
261
262
|
await this.pool.query(`DELETE FROM oauth_access_tokens WHERE token=$1`, [t]);
|
|
262
263
|
return undefined;
|
|
263
264
|
}
|
|
264
|
-
return { ljwt: r.ljwt, scope: r.scope ?? undefined, expiresAt: Number(r.expires_at) };
|
|
265
|
+
return { ljwt: r.ljwt, wsid: r.wsid ?? "", scope: r.scope ?? undefined, expiresAt: Number(r.expires_at) };
|
|
265
266
|
}
|
|
266
267
|
async putRefresh(t, r) {
|
|
267
|
-
await this.pool.query(`INSERT INTO oauth_refresh_tokens (token, ljwt, client_id, scope, expires_at) VALUES ($1,$2,$3,$4,$5)`, [t, r.ljwt, r.client_id, r.scope ?? null, r.expiresAt]);
|
|
268
|
+
await this.pool.query(`INSERT INTO oauth_refresh_tokens (token, ljwt, wsid, client_id, scope, expires_at) VALUES ($1,$2,$3,$4,$5,$6)`, [t, r.ljwt, r.wsid, r.client_id, r.scope ?? null, r.expiresAt]);
|
|
268
269
|
}
|
|
269
270
|
async takeRefresh(t) {
|
|
270
|
-
const { rows } = await this.pool.query(`DELETE FROM oauth_refresh_tokens WHERE token=$1 RETURNING ljwt, client_id, scope, expires_at`, [t]);
|
|
271
|
+
const { rows } = await this.pool.query(`DELETE FROM oauth_refresh_tokens WHERE token=$1 RETURNING ljwt, wsid, client_id, scope, expires_at`, [t]);
|
|
271
272
|
const r = rows[0];
|
|
272
273
|
if (!r || Number(r.expires_at) < now())
|
|
273
274
|
return undefined;
|
|
274
275
|
return {
|
|
275
276
|
ljwt: r.ljwt,
|
|
277
|
+
wsid: r.wsid ?? "",
|
|
276
278
|
client_id: r.client_id,
|
|
277
279
|
scope: r.scope ?? undefined,
|
|
278
280
|
expiresAt: Number(r.expires_at),
|
|
@@ -399,12 +401,12 @@ export async function startAuthorize(p) {
|
|
|
399
401
|
return { ok: true, internalState };
|
|
400
402
|
}
|
|
401
403
|
/**
|
|
402
|
-
* The login page (/mcp-connect) bounced back with the user's `ljwt`
|
|
403
|
-
* `internalState`. Mint a one-time authorization code bound to that ljwt + the
|
|
404
|
+
* The login page (/mcp-connect) bounced back with the user's `ljwt` (+ optional
|
|
405
|
+
* `wsid`) and our `internalState`. Mint a one-time authorization code bound to that ljwt + the
|
|
404
406
|
* parked PKCE challenge, and return where to redirect the user (the client's
|
|
405
407
|
* redirect_uri with ?code=&state=).
|
|
406
408
|
*/
|
|
407
|
-
export async function completeAuthorize(internalState, ljwt) {
|
|
409
|
+
export async function completeAuthorize(internalState, ljwt, wsid) {
|
|
408
410
|
const store = await getStore();
|
|
409
411
|
const p = internalState ? await store.takePending(internalState) : undefined;
|
|
410
412
|
if (!p) {
|
|
@@ -420,15 +422,16 @@ export async function completeAuthorize(internalState, ljwt) {
|
|
|
420
422
|
code_challenge: p.code_challenge,
|
|
421
423
|
scope: p.scope,
|
|
422
424
|
ljwt,
|
|
425
|
+
wsid: wsid ?? "",
|
|
423
426
|
expiresAt: now() + CODE_TTL,
|
|
424
427
|
});
|
|
425
428
|
return { ok: true, redirectUri: p.redirect_uri, code, state: p.state };
|
|
426
429
|
}
|
|
427
|
-
async function issueTokens(store, ljwt, client_id, scope) {
|
|
430
|
+
async function issueTokens(store, ljwt, wsid, client_id, scope) {
|
|
428
431
|
const access = token(32);
|
|
429
432
|
const refresh = token(32);
|
|
430
|
-
await store.putAccess(access, { ljwt, scope, expiresAt: now() + ACCESS_TTL });
|
|
431
|
-
await store.putRefresh(refresh, { ljwt, client_id, scope, expiresAt: now() + REFRESH_TTL });
|
|
433
|
+
await store.putAccess(access, { ljwt, wsid, scope, expiresAt: now() + ACCESS_TTL });
|
|
434
|
+
await store.putRefresh(refresh, { ljwt, wsid, client_id, scope, expiresAt: now() + REFRESH_TTL });
|
|
432
435
|
return { access_token: access, token_type: "Bearer", expires_in: Math.floor(ACCESS_TTL / 1000), refresh_token: refresh, scope };
|
|
433
436
|
}
|
|
434
437
|
export async function exchangeToken(p) {
|
|
@@ -447,7 +450,7 @@ export async function exchangeToken(p) {
|
|
|
447
450
|
if (!p.code_verifier || !verifyPkce(p.code_verifier, c.code_challenge)) {
|
|
448
451
|
return { ok: false, status: 400, error: "invalid_grant", error_description: "PKCE verification failed." };
|
|
449
452
|
}
|
|
450
|
-
return { ok: true, body: await issueTokens(store, c.ljwt, c.client_id, c.scope) };
|
|
453
|
+
return { ok: true, body: await issueTokens(store, c.ljwt, c.wsid, c.client_id, c.scope) };
|
|
451
454
|
}
|
|
452
455
|
if (p.grant_type === "refresh_token") {
|
|
453
456
|
const r = p.refresh_token ? await store.takeRefresh(p.refresh_token) : undefined; // rotate
|
|
@@ -457,17 +460,17 @@ export async function exchangeToken(p) {
|
|
|
457
460
|
if (await isDeadJwt(r.ljwt)) {
|
|
458
461
|
return { ok: false, status: 400, error: "invalid_grant", error_description: "Webcake session expired — sign in again (Connect)." };
|
|
459
462
|
}
|
|
460
|
-
return { ok: true, body: await issueTokens(store, r.ljwt, r.client_id, r.scope) };
|
|
463
|
+
return { ok: true, body: await issueTokens(store, r.ljwt, r.wsid, r.client_id, r.scope) };
|
|
461
464
|
}
|
|
462
465
|
return { ok: false, status: 400, error: "unsupported_grant_type", error_description: "grant_type must be authorization_code or refresh_token." };
|
|
463
466
|
}
|
|
464
467
|
// ---- Resource-server side: resolve a Bearer access token to its ljwt -------
|
|
465
|
-
/** Returns the user's ljwt for a valid, unexpired access token, else undefined. */
|
|
468
|
+
/** Returns the user's { ljwt, wsid } for a valid, unexpired access token, else undefined. */
|
|
466
469
|
export async function resolveAccessToken(accessToken) {
|
|
467
470
|
if (!accessToken)
|
|
468
471
|
return undefined;
|
|
469
472
|
const a = await (await getStore()).getAccess(accessToken);
|
|
470
|
-
return a && !isDeadLocally(a.ljwt) ? a.ljwt : undefined;
|
|
473
|
+
return a && !isDeadLocally(a.ljwt) ? { ljwt: a.ljwt, wsid: a.wsid } : undefined;
|
|
471
474
|
}
|
|
472
475
|
/** Revoke an access or refresh token (best-effort; for /revoke). */
|
|
473
476
|
export async function revokeToken(t) {
|
package/dist/changelog.json
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
[
|
|
2
|
+
{
|
|
3
|
+
"v": "1.16.2",
|
|
4
|
+
"d": "28/11/2026",
|
|
5
|
+
"type": "Fixed",
|
|
6
|
+
"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…",
|
|
7
|
+
"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ó…"
|
|
8
|
+
},
|
|
2
9
|
{
|
|
3
10
|
"v": "1.16.1",
|
|
4
11
|
"d": "25/11/2026",
|
|
@@ -33,12 +40,5 @@
|
|
|
33
40
|
"type": "Fixed",
|
|
34
41
|
"en": "install now writes the Claude Desktop config to every location Claude may read on Windows (Store/MSIX package containers, Claude-Data,…",
|
|
35
42
|
"vi": "install nay ghi config Claude Desktop vào mọi vị trí Claude có thể đọc trên Windows (container gói Store/MSIX, Claude-Data, %APPDATA%\\Claude) thay…"
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
"v": "1.13.6",
|
|
39
|
-
"d": "20/11/2026",
|
|
40
|
-
"type": "Fixed",
|
|
41
|
-
"en": "update_page/patch_page no longer compute a sections-only diff against a page that has two elements sharing the same id (something the Webcake editor…",
|
|
42
|
-
"vi": "update_page/patch_page nay không còn tính diff theo từng section với một trang có hai element dùng chung id (điều mà chính editor Webcake vẫn cho…"
|
|
43
43
|
}
|
|
44
44
|
]
|
package/dist/http.js
CHANGED
|
@@ -109,13 +109,15 @@ async function readBody(req) {
|
|
|
109
109
|
// require HTTPS, and disable query-string logging on your reverse proxy.
|
|
110
110
|
const QUERY_AUTH = {
|
|
111
111
|
jwt: "x-webcake-jwt",
|
|
112
|
+
wsid: "x-webcake-session-id",
|
|
113
|
+
session_id: "x-webcake-session-id",
|
|
112
114
|
env: "x-webcake-env",
|
|
113
115
|
api_base: "x-webcake-api-base",
|
|
114
116
|
org_id: "x-webcake-org-id",
|
|
115
117
|
app_base: "x-webcake-app-base",
|
|
116
118
|
builder_base: "x-webcake-builder-base",
|
|
117
119
|
};
|
|
118
|
-
function applyQueryAuth(req) {
|
|
120
|
+
export function applyQueryAuth(req) {
|
|
119
121
|
const q = (req.url ?? "").indexOf("?");
|
|
120
122
|
if (q === -1)
|
|
121
123
|
return;
|
|
@@ -252,7 +254,7 @@ async function handleOAuth(req, res, path) {
|
|
|
252
254
|
}
|
|
253
255
|
return htmlError(res, 400, result.error_description), true;
|
|
254
256
|
}
|
|
255
|
-
// Send the user to the SPA login; it returns here with ?token=<ljwt
|
|
257
|
+
// Send the user to the SPA login; it returns here with ?token=<ljwt>[&wsid=<lwsid>]&state=<internalState>.
|
|
256
258
|
const callback = `${issuer}${OAUTH_CALLBACK}`;
|
|
257
259
|
const loginUrl = buildConnectUrl(connectPageUrl(), callback, result.internalState);
|
|
258
260
|
res.writeHead(302, { location: loginUrl });
|
|
@@ -261,7 +263,7 @@ async function handleOAuth(req, res, path) {
|
|
|
261
263
|
// ---- Login callback: the SPA handed back the user's ljwt → mint a code ----
|
|
262
264
|
if (req.method === "GET" && path === OAUTH_CALLBACK) {
|
|
263
265
|
const sp = new URL(req.url ?? "/", "http://x").searchParams;
|
|
264
|
-
const done = await completeAuthorize(sp.get("state"), sp.get("token"));
|
|
266
|
+
const done = await completeAuthorize(sp.get("state"), sp.get("token"), sp.get("wsid") || sp.get("session_id"));
|
|
265
267
|
if (!done.ok)
|
|
266
268
|
return htmlError(res, 400, done.error_description), true;
|
|
267
269
|
const r = new URL(done.redirectUri);
|
|
@@ -478,10 +480,14 @@ export async function startHttpServer(port) {
|
|
|
478
480
|
// ?jwt= / x-webcake-jwt: a Bearer from our OAuth flow is what the last Connect issued,
|
|
479
481
|
// so it's the renewed credential when the URL still carries an old, expired JWT.
|
|
480
482
|
const bearer = bearerFrom(req);
|
|
481
|
-
const
|
|
482
|
-
if (
|
|
483
|
-
req.headers["x-webcake-jwt"] =
|
|
484
|
-
req.rawHeaders.push("x-webcake-jwt",
|
|
483
|
+
const oauthCred = await resolveAccessToken(bearer);
|
|
484
|
+
if (oauthCred) {
|
|
485
|
+
req.headers["x-webcake-jwt"] = oauthCred.ljwt;
|
|
486
|
+
req.rawHeaders.push("x-webcake-jwt", oauthCred.ljwt);
|
|
487
|
+
if (oauthCred.wsid) {
|
|
488
|
+
req.headers["x-webcake-session-id"] = oauthCred.wsid;
|
|
489
|
+
req.rawHeaders.push("x-webcake-session-id", oauthCred.wsid);
|
|
490
|
+
}
|
|
485
491
|
}
|
|
486
492
|
// Enforcement: no credential, or an expired/rejected Webcake JWT, gets a 401 +
|
|
487
493
|
// WWW-Authenticate so Claude/ChatGPT (re)open the Connect page by themselves. In
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* explicit WEBCAKE_API_BASE / WEBCAKE_APP_BASE still wins over it.
|
|
18
18
|
* WEBCAKE_API_BASE e.g. http://localhost:5800 (required to call the backend)
|
|
19
19
|
* WEBCAKE_JWT the account JWT (required to call the backend)
|
|
20
|
+
* WEBCAKE_SESSION_ID optional landing session id (`lwsid`), sent as `x-session-id`
|
|
20
21
|
* WEBCAKE_ORG_ID optional default organization id for create_page
|
|
21
22
|
* WEBCAKE_APP_BASE optional SPA base (used for the login connect page)
|
|
22
23
|
* WEBCAKE_BUILDER_BASE optional builder host for the editor URLs in the result
|
|
@@ -91,6 +92,8 @@ export function readConfig(overrides = {}) {
|
|
|
91
92
|
const envJwt = process.env.WEBCAKE_JWT;
|
|
92
93
|
const renewed = !!envJwt && jwtExpired(envJwt) && !!saved.jwt && !jwtExpired(saved.jwt);
|
|
93
94
|
const jwt = overrides.jwt ?? (renewed ? saved.jwt : envJwt) ?? saved.jwt;
|
|
95
|
+
// The session id belongs to the JWT it was issued with — take it from the same source.
|
|
96
|
+
const sessionId = overrides.jwt ? overrides.sessionId : envJwt && !renewed ? process.env.WEBCAKE_SESSION_ID : saved.sessionId;
|
|
94
97
|
const missing = [];
|
|
95
98
|
if (!base)
|
|
96
99
|
missing.push("WEBCAKE_API_BASE");
|
|
@@ -128,6 +131,7 @@ export function readConfig(overrides = {}) {
|
|
|
128
131
|
config: {
|
|
129
132
|
base: cleanBase,
|
|
130
133
|
jwt: jwt,
|
|
134
|
+
sessionId: sessionId || undefined,
|
|
131
135
|
orgId: overrides.orgId ?? process.env.WEBCAKE_ORG_ID ?? saved.orgId,
|
|
132
136
|
appBase: stripTrailingSlash(overrides.appBase ?? process.env.WEBCAKE_APP_BASE ?? preset?.appBase ?? saved.appBase),
|
|
133
137
|
builderBase,
|
|
@@ -145,6 +149,7 @@ function header(headers, name) {
|
|
|
145
149
|
* Build request-scoped config overrides from HTTP headers. Lets a remote client
|
|
146
150
|
* send its own credentials per request instead of a server-wide env token:
|
|
147
151
|
* x-webcake-jwt the account JWT (or `Authorization: Bearer <jwt>`)
|
|
152
|
+
* x-webcake-session-id landing session id (`lwsid`), forwarded as `x-session-id`
|
|
148
153
|
* x-webcake-org-id organization id
|
|
149
154
|
* x-webcake-env named environment (local|staging|prod) for the base URLs
|
|
150
155
|
* x-webcake-api-base backend base URL (overrides the env preset)
|
|
@@ -159,6 +164,7 @@ export function configFromHeaders(headers) {
|
|
|
159
164
|
return {
|
|
160
165
|
base: header(headers, "x-webcake-api-base"),
|
|
161
166
|
jwt: header(headers, "x-webcake-jwt") ?? bearer,
|
|
167
|
+
sessionId: header(headers, "x-webcake-session-id"),
|
|
162
168
|
orgId: header(headers, "x-webcake-org-id"),
|
|
163
169
|
appBase: header(headers, "x-webcake-app-base"),
|
|
164
170
|
builderBase: header(headers, "x-webcake-builder-base"),
|
|
@@ -108,6 +108,9 @@ export function ensureOAuthSchema(pool) {
|
|
|
108
108
|
scope text,
|
|
109
109
|
expires_at bigint NOT NULL
|
|
110
110
|
);
|
|
111
|
+
ALTER TABLE oauth_codes ADD COLUMN IF NOT EXISTS wsid text;
|
|
112
|
+
ALTER TABLE oauth_access_tokens ADD COLUMN IF NOT EXISTS wsid text;
|
|
113
|
+
ALTER TABLE oauth_refresh_tokens ADD COLUMN IF NOT EXISTS wsid text;
|
|
111
114
|
`);
|
|
112
115
|
return true;
|
|
113
116
|
}
|
|
@@ -235,6 +235,8 @@ function authHeaders(config, orgId) {
|
|
|
235
235
|
Authorization: `Bearer ${config.jwt}`,
|
|
236
236
|
Cookie: `jwt=${config.jwt}`,
|
|
237
237
|
};
|
|
238
|
+
if (config.sessionId)
|
|
239
|
+
headers["x-session-id"] = config.sessionId;
|
|
238
240
|
const org = orgId ?? config.orgId;
|
|
239
241
|
if (org != null && `${org}` !== "")
|
|
240
242
|
headers["x-org-id"] = `${org}`;
|
|
@@ -335,7 +337,7 @@ export function buildRequestRedacted(config, name, source, orgId) {
|
|
|
335
337
|
return {
|
|
336
338
|
method: req.method,
|
|
337
339
|
url: req.url,
|
|
338
|
-
headers: { ...req.headers, Authorization: "Bearer ***JWT***", Cookie: "jwt=***JWT***" },
|
|
340
|
+
headers: { ...req.headers, Authorization: "Bearer ***JWT***", Cookie: "jwt=***JWT***", ...(config.sessionId ? { "x-session-id": "***" } : {}) },
|
|
339
341
|
body: mask(req.body).slice(0, 400) + (req.body.length > 400 ? `… (${req.body.length} bytes)` : ""),
|
|
340
342
|
};
|
|
341
343
|
}
|
|
@@ -552,7 +554,7 @@ export function buildUpdateRequestRedacted(config, pageId, source) {
|
|
|
552
554
|
return {
|
|
553
555
|
method: "POST",
|
|
554
556
|
url: `${config.base}${UPDATE_ENDPOINT}`,
|
|
555
|
-
headers: { ...authHeaders(config), Authorization: "Bearer ***JWT***", Cookie: "jwt=***JWT***" },
|
|
557
|
+
headers: { ...authHeaders(config), Authorization: "Bearer ***JWT***", Cookie: "jwt=***JWT***", ...(config.sessionId ? { "x-session-id": "***" } : {}) },
|
|
556
558
|
body: body.replace(config.jwt, "***JWT***").slice(0, 400) + (body.length > 400 ? `… (${body.length} bytes)` : ""),
|
|
557
559
|
};
|
|
558
560
|
}
|
|
@@ -562,7 +564,7 @@ export function buildAppendRequestRedacted(config, pageId, sections) {
|
|
|
562
564
|
return {
|
|
563
565
|
method: "POST",
|
|
564
566
|
url: `${config.base}${APPEND_ENDPOINT}`,
|
|
565
|
-
headers: { ...authHeaders(config), Authorization: "Bearer ***JWT***", Cookie: "jwt=***JWT***" },
|
|
567
|
+
headers: { ...authHeaders(config), Authorization: "Bearer ***JWT***", Cookie: "jwt=***JWT***", ...(config.sessionId ? { "x-session-id": "***" } : {}) },
|
|
566
568
|
body: body.replace(config.jwt, "***JWT***").slice(0, 400) + (body.length > 400 ? `… (${body.length} bytes)` : ""),
|
|
567
569
|
};
|
|
568
570
|
}
|
|
@@ -872,7 +874,7 @@ export function buildPublishRequestRedacted(config, pageId, source, opts = {}, w
|
|
|
872
874
|
return {
|
|
873
875
|
method: "POST",
|
|
874
876
|
url: publishUrl(config, pageId, willRender),
|
|
875
|
-
headers: { ...authHeaders(config), Authorization: "Bearer ***JWT***", Cookie: "jwt=***JWT***" },
|
|
877
|
+
headers: { ...authHeaders(config), Authorization: "Bearer ***JWT***", Cookie: "jwt=***JWT***", ...(config.sessionId ? { "x-session-id": "***" } : {}) },
|
|
876
878
|
body: body.replace(config.jwt, "***JWT***").slice(0, 600) + (body.length > 600 ? `… (${body.length} bytes)` : ""),
|
|
877
879
|
rendered: willRender,
|
|
878
880
|
};
|
|
@@ -1030,6 +1032,7 @@ export async function uploadImageToCollection(config, bytes, filename, contentTy
|
|
|
1030
1032
|
Accept: "application/json, text/plain, */*", // builder host: application/json alone → 406
|
|
1031
1033
|
Authorization: `Bearer ${config.jwt}`,
|
|
1032
1034
|
Cookie: `jwt=${config.jwt}`,
|
|
1035
|
+
...(config.sessionId ? { "x-session-id": config.sessionId } : {}),
|
|
1033
1036
|
"x-org-id": `${org}`,
|
|
1034
1037
|
},
|
|
1035
1038
|
body: form,
|
package/dist/smoke.js
CHANGED
|
@@ -1501,6 +1501,8 @@ console.log("== config: named environment presets (local/staging/prod) ==");
|
|
|
1501
1501
|
check("previewBase defaults to www.webcake.me without a preset", readConfig({ base: "https://api.example.com", jwt: "t" }).config?.previewBase === "https://www.webcake.me");
|
|
1502
1502
|
check("explicit previewBase overrides the preset", readConfig({ env: "prod", previewBase: "https://p.test/", jwt: "t" }).config?.previewBase === "https://p.test");
|
|
1503
1503
|
check("x-webcake-preview-base header parsed", configFromHeaders({ "x-webcake-preview-base": "https://p.example" }).previewBase === "https://p.example");
|
|
1504
|
+
check("x-webcake-session-id header → config.sessionId", readConfig({ ...configFromHeaders({ "x-webcake-jwt": "t", "x-webcake-session-id": "w" }), env: "prod" }).config?.sessionId === "w");
|
|
1505
|
+
check("no session id → config.sessionId undefined", readConfig({ env: "prod", jwt: "t" }).config?.sessionId === undefined);
|
|
1504
1506
|
check("preview url from a path → preview host (not builder)", toPreviewUrl(localCfg, "/preview/abc") === "http://preview.localhost:5800/preview/abc");
|
|
1505
1507
|
check("preview url from an absolute api url → preview host", toPreviewUrl(localCfg, "http://localhost:5800/preview/abc?x=1") === "http://preview.localhost:5800/preview/abc?x=1");
|
|
1506
1508
|
check("preview url passthrough when empty", toPreviewUrl(localCfg, undefined) === undefined);
|
|
@@ -1534,6 +1536,8 @@ console.log("== login: connect URL + loopback callback parsing (offline) ==");
|
|
|
1534
1536
|
check("connect url joins with & when a query already exists", buildConnectUrl("https://x.test/c?a=1", "http://127.0.0.1:1/callback", "s").includes("?a=1&redirect_uri="));
|
|
1535
1537
|
const okCb = parseCallback("/callback?token=tok&state=abc", "abc");
|
|
1536
1538
|
check("callback with token+state accepted", okCb.ok && okCb.token === "tok", okCb);
|
|
1539
|
+
const wsidCb = parseCallback("/callback?token=tok&wsid=w&state=abc", "abc");
|
|
1540
|
+
check("callback carries the optional wsid", wsidCb.ok && wsidCb.sessionId === "w" && okCb.ok && okCb.sessionId === undefined, wsidCb);
|
|
1537
1541
|
const wrongState = parseCallback("/callback?token=tok&state=other", "abc");
|
|
1538
1542
|
check("callback with wrong state rejected (400)", !wrongState.ok && wrongState.status === 400, wrongState);
|
|
1539
1543
|
const noState = parseCallback("/callback?token=tok", "abc");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "webcake-landing-mcp",
|
|
3
|
-
"version": "1.16.
|
|
3
|
+
"version": "1.16.2",
|
|
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",
|