@ultimatelemon-eu/mcp-http 2.3.0 → 2.3.1

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/oauth.js CHANGED
@@ -274,7 +274,8 @@ export function createOAuthHandler(options, basePath) {
274
274
  u: tokens,
275
275
  ...(flow.s !== undefined ? { s: flow.s } : {})
276
276
  }, STATE_TTL_MS);
277
- return htmlResponse(settingsPage(form, `${origin}${paths.settings}`, pending), 200);
277
+ // Browsers apply form-action to the redirect after the POST, so the client's origin must be allowed.
278
+ return htmlResponse(settingsPage(form, `${origin}${paths.settings}`, pending), 200, [new URL(flow.r).origin]);
278
279
  }
279
280
  async function callback(request, url) {
280
281
  const failure = url.searchParams.get('error');
package/dist/pages.d.ts CHANGED
@@ -19,6 +19,6 @@ export interface SettingsForm {
19
19
  fields: SettingsField[];
20
20
  }
21
21
  export declare function escapeHtml(value: string): string;
22
- export declare function htmlResponse(body: string, status: number): Response;
22
+ export declare function htmlResponse(body: string, status: number, formTargets?: readonly string[]): Response;
23
23
  export declare function errorPage(title: string, detail: string): string;
24
24
  export declare function settingsPage(form: SettingsForm, action: string, pending: string): string;
package/dist/pages.js CHANGED
@@ -48,13 +48,14 @@ function page(title, body) {
48
48
  <body><main>${body}</main></body>
49
49
  </html>`;
50
50
  }
51
- export function htmlResponse(body, status) {
51
+ export function htmlResponse(body, status, formTargets = []) {
52
+ const formAction = ["'self'", ...formTargets].join(' ');
52
53
  return new Response(body, {
53
54
  status,
54
55
  headers: {
55
56
  'content-type': 'text/html; charset=utf-8',
56
57
  'cache-control': 'no-store',
57
- 'content-security-policy': "default-src 'none'; style-src 'unsafe-inline'; form-action 'self'; frame-ancestors 'none'",
58
+ 'content-security-policy': `default-src 'none'; style-src 'unsafe-inline'; form-action ${formAction}; frame-ancestors 'none'`,
58
59
  'x-frame-options': 'DENY'
59
60
  }
60
61
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ultimatelemon-eu/mcp-http",
3
- "version": "2.3.0",
3
+ "version": "2.3.1",
4
4
  "description": "Run an MCP server over stateless Streamable HTTP: /mcp, /healthz, a base path for proxies, the caller's own API key or a stateless OAuth sign-in, and errors that never leak a stack trace.",
5
5
  "license": "MIT",
6
6
  "repository": {