keryx 0.35.1 → 0.35.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "keryx",
3
- "version": "0.35.1",
3
+ "version": "0.35.2",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -8,7 +8,6 @@ import {
8
8
  type AuthPageParams,
9
9
  type OAuthTemplates,
10
10
  renderAuthPage,
11
- renderSuccessPage,
12
11
  } from "../oauthTemplates";
13
12
  import { clientKey, codeKey } from "./keys";
14
13
  import type { AuthCode, OAuthClient } from "./types";
@@ -94,7 +93,7 @@ async function runAuthAction(
94
93
  * Handle the OAuth authorize form POST (signin/signup).
95
94
  *
96
95
  * @param req - The incoming form POST request.
97
- * @param templates - Loaded OAuth HTML templates for rendering the auth/success pages.
96
+ * @param templates - Loaded OAuth HTML templates for re-rendering the auth page on error.
98
97
  * @param origin - The externally-visible origin of this authorization server. Used
99
98
  * as the `iss` (issuer) value on the authorization-code redirect per RFC 9207
100
99
  * (MCP 2026-07-28 / SEP-2468); matches the `issuer` advertised in AS metadata.
@@ -177,5 +176,15 @@ export async function handleAuthorizePost(
177
176
  if (oauthParams.state)
178
177
  redirectUrl.searchParams.set("state", oauthParams.state);
179
178
 
180
- return renderSuccessPage(redirectUrl.toString(), templates);
179
+ // RFC 6749 §4.1.2: complete authorization with a 302 redirect to the client's
180
+ // (already-validated) redirect_uri. A top-level redirect is required for
181
+ // browser-based MCP connectors (e.g. claude.ai): their callback is served with
182
+ // X-Frame-Options/frame-ancestors, so any attempt to reach it from an iframe or
183
+ // sub-context is blocked by the browser and the auth code never arrives — a
184
+ // silent failure. A plain 302 also can't be blocked by CSP or popup rules and
185
+ // works equally for localhost CLI callbacks.
186
+ return new Response(null, {
187
+ status: 302,
188
+ headers: { Location: redirectUrl.toString() },
189
+ });
181
190
  }
@@ -15,7 +15,6 @@ export type FormField = {
15
15
 
16
16
  export type OAuthTemplates = {
17
17
  authTemplate: string;
18
- successTemplate: string;
19
18
  commonCss: string;
20
19
  lionSvg: string;
21
20
  };
@@ -43,7 +42,7 @@ async function resolveTemplate(
43
42
  }
44
43
 
45
44
  /**
46
- * Load all 4 OAuth template files, resolving from user project first, then framework.
45
+ * Load the OAuth template files, resolving from user project first, then framework.
47
46
  * @param rootDir - The user app's root directory.
48
47
  * @param packageDir - The framework package directory.
49
48
  * @returns An object containing all template strings.
@@ -52,15 +51,12 @@ export async function loadOAuthTemplates(
52
51
  rootDir: string,
53
52
  packageDir: string,
54
53
  ): Promise<OAuthTemplates> {
55
- const [authTemplate, successTemplate, commonCss, lionSvg] = await Promise.all(
56
- [
57
- resolveTemplate("oauth-authorize.html", rootDir, packageDir),
58
- resolveTemplate("oauth-success.html", rootDir, packageDir),
59
- resolveTemplate("oauth-common.css", rootDir, packageDir),
60
- resolveTemplate("lion.svg", rootDir, packageDir),
61
- ],
62
- );
63
- return { authTemplate, successTemplate, commonCss, lionSvg };
54
+ const [authTemplate, commonCss, lionSvg] = await Promise.all([
55
+ resolveTemplate("oauth-authorize.html", rootDir, packageDir),
56
+ resolveTemplate("oauth-common.css", rootDir, packageDir),
57
+ resolveTemplate("lion.svg", rootDir, packageDir),
58
+ ]);
59
+ return { authTemplate, commonCss, lionSvg };
64
60
  }
65
61
 
66
62
  /**
@@ -213,25 +209,3 @@ export function renderAuthPage(
213
209
  headers: { "Content-Type": "text/html; charset=utf-8" },
214
210
  });
215
211
  }
216
-
217
- /**
218
- * Render the OAuth success/redirect page.
219
- * @param redirectUrl - The URL to redirect the user to after authorization.
220
- * @param templates - Loaded OAuth template strings.
221
- * @returns An HTML Response.
222
- */
223
- export function renderSuccessPage(
224
- redirectUrl: string,
225
- templates: OAuthTemplates,
226
- ): Response {
227
- const html = Mustache.render(
228
- templates.successTemplate,
229
- { redirectUrl },
230
- { commonCss: templates.commonCss, lionSvg: templates.lionSvg },
231
- );
232
-
233
- return new Response(html, {
234
- status: 200,
235
- headers: { "Content-Type": "text/html; charset=utf-8" },
236
- });
237
- }
package/util/scaffold.ts CHANGED
@@ -62,7 +62,6 @@ export async function generateOAuthTemplateContents(): Promise<
62
62
  const result = new Map<string, string>();
63
63
  const oauthTemplates = [
64
64
  "oauth-authorize.html",
65
- "oauth-success.html",
66
65
  "oauth-common.css",
67
66
  "lion.svg",
68
67
  ];
@@ -1,38 +0,0 @@
1
- <!doctype html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8" />
5
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
- <meta name="redirect-url" content="{{redirectUrl}}" />
7
- <title>Authorization Successful</title>
8
- <style>
9
- {{> commonCss}}
10
- .container { text-align: center; }
11
- </style>
12
- </head>
13
- <body>
14
- <div class="container">
15
- <div class="checkmark">
16
- <svg viewBox="0 0 24 24">
17
- <polyline points="20 6 9 17 4 12"></polyline>
18
- </svg>
19
- </div>
20
- <h2>You're signed in!</h2>
21
- <p>Authorization was successful.</p>
22
- <p class="closing">You can close this window.</p>
23
- </div>
24
- <div class="lion">{{> lionSvg}}</div>
25
- <script>
26
- // Complete the OAuth flow by navigating to the callback URI
27
- // Use a hidden iframe so the page stays visible
28
- var iframe = document.createElement("iframe");
29
- iframe.style.display = "none";
30
- iframe.src = document.querySelector('meta[name="redirect-url"]').content;
31
- document.body.appendChild(iframe);
32
- // Try to close the window after giving the callback time to complete
33
- setTimeout(function () {
34
- window.close();
35
- }, 2000);
36
- </script>
37
- </body>
38
- </html>