inistate-mcp 1.3.2 → 1.3.4
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/build/authorize-app-routes.d.ts +3 -0
- package/build/authorize-app-routes.js +151 -0
- package/build/client-logos.d.ts +5 -0
- package/build/client-logos.js +31 -0
- package/build/http.js +3 -0
- package/build/inistate-logo.d.ts +5 -0
- package/build/inistate-logo.js +5 -0
- package/build/oauth-provider.d.ts +21 -0
- package/build/oauth-provider.js +67 -1
- package/package.json +1 -1
- package/server.json +2 -2
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import express from "express";
|
|
3
|
+
import { clientLogoForRedirect } from "./client-logos.js";
|
|
4
|
+
import { INISTATE_LOGO_SVG } from "./inistate-logo.js";
|
|
5
|
+
import { browserSecretCookieName, browserSecretCookieOptions, readCookie, } from "./oauth-provider.js";
|
|
6
|
+
/**
|
|
7
|
+
* SS06370: the Inistate App approves a flow natively (no cookie), then hands the user to the
|
|
8
|
+
* browser that started it. See ParkedApproval in oauth-provider.ts for why both the cookie and
|
|
9
|
+
* the finish token are required.
|
|
10
|
+
*
|
|
11
|
+
* POST /authorize/app-callback the App: nonce, jwt, refreshToken -> 302 to /authorize/finish
|
|
12
|
+
* GET /authorize/finish the browser: confirmation page (cookie + token)
|
|
13
|
+
* POST /authorize/finish the browser: Confirm -> 302 to the client with the code
|
|
14
|
+
*/
|
|
15
|
+
const escapeHtml = (s) => s.replace(/[&<>"']/g, (c) => ({ "&": "&", "<": "<", ">": ">", '"': """, "'": "'" })[c]);
|
|
16
|
+
/**
|
|
17
|
+
* A second tap on Confirm used to burn the flow: the first POST had already issued the code
|
|
18
|
+
* and consumed the nonce, so the retry could only say "expired". Disable the button on submit.
|
|
19
|
+
* Inline, so the CSP carries its hash instead of allowing scripts in general.
|
|
20
|
+
*/
|
|
21
|
+
const SUBMIT_SCRIPT = "document.addEventListener('submit',function(e){var b=e.target.querySelector('button');if(b){b.disabled=true;b.textContent='Connecting\\u2026'}})";
|
|
22
|
+
const SUBMIT_SCRIPT_HASH = `'sha256-${createHash("sha256").update(SUBMIT_SCRIPT).digest("base64")}'`;
|
|
23
|
+
// No form-action here: Chrome also applies it to the redirect that follows the POST, and the
|
|
24
|
+
// whole point of Confirm is to redirect to the client's own origin, so 'self' blocked it and
|
|
25
|
+
// "nothing happened". Everything interpolated into the page is escaped, so nothing here
|
|
26
|
+
// can be steered into posting elsewhere.
|
|
27
|
+
const CSP = `default-src 'none'; style-src 'unsafe-inline'; script-src ${SUBMIT_SCRIPT_HASH}; img-src data:; frame-ancestors 'none'`;
|
|
28
|
+
// Palette from the web app (webApp src/assets/scss/colors.scss): primary #2b9ec6, green #a4ce3a.
|
|
29
|
+
// The button uses a darker shade of the primary because white on #2b9ec6 is only ~3:1.
|
|
30
|
+
const STYLE = `
|
|
31
|
+
:root{color-scheme:light dark;--bg:#f4f8fa;--card:#fff;--fg:#212121;--muted:#5f6b72;--line:#e6e6e6;--brand:#2b9ec6;--green:#a4ce3a;--btn:#1d7fa3;--btn-hover:#18698a;--btn-fg:#fff;--warn-bg:#fff6e8;--warn-line:#f3d19e}
|
|
32
|
+
@media (prefers-color-scheme:dark){:root{--bg:#121a1e;--card:#1b252b;--fg:#eef3f5;--muted:#a2b0b8;--line:#2d3b43;--btn:#2b9ec6;--btn-hover:#4db3d6;--btn-fg:#06161c;--warn-bg:#2b2516;--warn-line:#5a4a1e}}
|
|
33
|
+
*{box-sizing:border-box}
|
|
34
|
+
body{margin:0;min-height:100vh;display:flex;align-items:center;justify-content:center;padding:16px;background:var(--bg);color:var(--fg);font:16px/1.5 Inter,system-ui,-apple-system,"Segoe UI",Roboto,sans-serif}
|
|
35
|
+
main{position:relative;width:100%;max-width:26rem;background:var(--card);border:1px solid var(--line);border-radius:16px;padding:32px 24px 28px;overflow:hidden;box-shadow:0 2px 12px rgba(16,40,52,.08)}
|
|
36
|
+
main::before{content:"";position:absolute;inset:0 0 auto 0;height:5px;background:linear-gradient(to right,var(--brand),var(--green))}
|
|
37
|
+
.pair{display:flex;align-items:center;gap:12px;margin:0 0 16px}
|
|
38
|
+
.logo{display:block;width:44px;height:44px;border-radius:10px}.logo svg{display:block;width:100%;height:100%}
|
|
39
|
+
.link{color:var(--muted);font-size:1.2rem;line-height:1}
|
|
40
|
+
.where{font-size:.9rem}.where strong{color:var(--fg);font-weight:600;word-break:break-all}
|
|
41
|
+
h1{margin:0 0 6px;font-size:1.3rem;line-height:1.3}
|
|
42
|
+
p{margin:0 0 14px;color:var(--muted)}
|
|
43
|
+
.account{margin:16px 0;padding:12px 14px;border:1px solid var(--line);border-left:4px solid var(--brand);border-radius:10px;word-break:break-all}
|
|
44
|
+
.account small{display:block;color:var(--muted);font-size:.8rem;margin-bottom:2px}
|
|
45
|
+
.account strong{color:var(--fg);font-weight:600}
|
|
46
|
+
.note{padding:10px 12px;border-radius:10px;background:var(--warn-bg);border:1px solid var(--warn-line);color:var(--fg);font-size:.9rem;margin:0 0 18px}
|
|
47
|
+
button{width:100%;padding:12px 16px;border:0;border-radius:10px;background:var(--btn);color:var(--btn-fg);font:inherit;font-weight:600;cursor:pointer}
|
|
48
|
+
button:hover:not(:disabled){background:var(--btn-hover)}
|
|
49
|
+
button:disabled{opacity:.6;cursor:default}
|
|
50
|
+
button:focus-visible{outline:3px solid var(--brand);outline-offset:2px}
|
|
51
|
+
`;
|
|
52
|
+
const INISTATE_MARK = `<span class="logo">${INISTATE_LOGO_SVG}</span>`;
|
|
53
|
+
function page(res, status, title, body, header = INISTATE_MARK) {
|
|
54
|
+
res
|
|
55
|
+
.status(status)
|
|
56
|
+
.set({
|
|
57
|
+
"Content-Type": "text/html; charset=utf-8",
|
|
58
|
+
"Cache-Control": "no-store",
|
|
59
|
+
"Referrer-Policy": "no-referrer",
|
|
60
|
+
// The Confirm button must not be clickjackable from another origin.
|
|
61
|
+
"X-Frame-Options": "DENY",
|
|
62
|
+
"Content-Security-Policy": CSP,
|
|
63
|
+
})
|
|
64
|
+
.send(`<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">` +
|
|
65
|
+
`<title>${escapeHtml(title)}</title><style>${STYLE}</style></head><body><main><div class="pair">${header}</div>${body}</main>` +
|
|
66
|
+
`<script>${SUBMIT_SCRIPT}</script></body></html>`);
|
|
67
|
+
}
|
|
68
|
+
function failure(res, error) {
|
|
69
|
+
const message = error instanceof Error ? error.message : "Authorization failed";
|
|
70
|
+
if (/does not belong to this browser|Invalid finish token/.test(message)) {
|
|
71
|
+
page(res, 400, "Open this link in the original browser", `<h1>Open this link in the original browser</h1>` +
|
|
72
|
+
`<p>Finish connecting in the same browser where you started from ChatGPT or Claude, then try again.</p>`);
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (/expired|Invalid or expired/i.test(message)) {
|
|
76
|
+
page(res, 400, "This link has expired", `<h1>This link has expired</h1>` +
|
|
77
|
+
`<p>It may already have been used. Go back to ChatGPT or Claude and start connecting again.</p>`);
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
res.status(400).type("text/plain").send(message);
|
|
81
|
+
}
|
|
82
|
+
export function registerAppAuthorizeRoutes(app, provider, issuerUrl) {
|
|
83
|
+
const secure = issuerUrl.startsWith("https:");
|
|
84
|
+
const base = issuerUrl.replace(/\/$/, "");
|
|
85
|
+
app.post("/authorize/app-callback", express.urlencoded({ extended: false }), async (req, res) => {
|
|
86
|
+
try {
|
|
87
|
+
const { nonce, jwt, refreshToken } = req.body ?? {};
|
|
88
|
+
if (!nonce || !jwt) {
|
|
89
|
+
res.status(400).send("Missing nonce or jwt");
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
const { finishToken } = await provider.parkAppApproval(String(nonce), String(jwt), refreshToken ? String(refreshToken) : undefined);
|
|
93
|
+
const finish = new URL(`${base}/authorize/finish`);
|
|
94
|
+
finish.searchParams.set("nonce", String(nonce));
|
|
95
|
+
finish.searchParams.set("token", finishToken);
|
|
96
|
+
res.redirect(302, finish.toString());
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
console.error("App authorize callback error:", error);
|
|
100
|
+
const message = error instanceof Error ? error.message : "Authorization failed";
|
|
101
|
+
// The App maps a 401 to "sign in again" and the exact nonce message to "expired or used".
|
|
102
|
+
res.status(/^Bearer token is invalid/.test(message) ? 401 : 400).send(message);
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
app.get("/authorize/finish", (req, res) => {
|
|
106
|
+
try {
|
|
107
|
+
const nonce = String(req.query.nonce ?? "");
|
|
108
|
+
const token = String(req.query.token ?? "");
|
|
109
|
+
const cookie = readCookie(req.headers.cookie, browserSecretCookieName(nonce));
|
|
110
|
+
const info = provider.getFinishInfo(nonce, token, cookie);
|
|
111
|
+
// A logo and a verified name only when the code is going to that service's own host;
|
|
112
|
+
// otherwise the self-chosen client name is all there is, and the host is shown plainly.
|
|
113
|
+
const brand = clientLogoForRedirect(info.redirectUri);
|
|
114
|
+
const label = brand?.name ?? (info.clientName || "this app");
|
|
115
|
+
let host = "";
|
|
116
|
+
try {
|
|
117
|
+
host = new URL(info.redirectUri).host;
|
|
118
|
+
}
|
|
119
|
+
catch {
|
|
120
|
+
/* shown without a host */
|
|
121
|
+
}
|
|
122
|
+
const header = (brand ? `<img class="logo" src="${brand.logo}" alt="${escapeHtml(brand.name)}"><span class="link" aria-hidden="true">⇄</span>` : "") +
|
|
123
|
+
INISTATE_MARK;
|
|
124
|
+
page(res, 200, "Confirm connection", `<h1>Connect ${escapeHtml(label)} to Inistate?</h1>` +
|
|
125
|
+
`<p>It will be able to work in Inistate as this account:</p>` +
|
|
126
|
+
`<div class="account"><small>Signed in as</small><strong>${escapeHtml(info.account)}</strong></div>` +
|
|
127
|
+
(host ? `<p class="where">After you confirm, you'll be sent back to <strong>${escapeHtml(host)}</strong>.</p>` : "") +
|
|
128
|
+
`<p class="note">Only continue if you just started this from ChatGPT or Claude. If someone sent you this link, close this page.</p>` +
|
|
129
|
+
`<form method="post" action="/authorize/finish">` +
|
|
130
|
+
`<input type="hidden" name="nonce" value="${escapeHtml(nonce)}">` +
|
|
131
|
+
`<input type="hidden" name="token" value="${escapeHtml(token)}">` +
|
|
132
|
+
`<button type="submit">Confirm</button></form>`, header);
|
|
133
|
+
}
|
|
134
|
+
catch (error) {
|
|
135
|
+
failure(res, error);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
app.post("/authorize/finish", express.urlencoded({ extended: false }), (req, res) => {
|
|
139
|
+
try {
|
|
140
|
+
const nonce = String(req.body?.nonce ?? "");
|
|
141
|
+
const token = String(req.body?.token ?? "");
|
|
142
|
+
const cookieName = browserSecretCookieName(nonce);
|
|
143
|
+
const { redirectUrl } = provider.completeParkedAuthorization(nonce, token, readCookie(req.headers.cookie, cookieName));
|
|
144
|
+
res.clearCookie(cookieName, { path: browserSecretCookieOptions(secure).path });
|
|
145
|
+
res.redirect(302, redirectUrl);
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
failure(res, error);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Logos for the MCP clients people connect from, shown on the finish page (SS06370).
|
|
3
|
+
*
|
|
4
|
+
* Chosen by the host the authorization code will be returned to, never by the client name:
|
|
5
|
+
* the name comes from dynamic client registration and anyone can call their client "Claude".
|
|
6
|
+
* The redirect host is where the code actually goes, so a logo here means the code is going
|
|
7
|
+
* to that service. 96px copies of the vendors' app icons, inlined (the page needs no image
|
|
8
|
+
* requests beyond data: URIs).
|
|
9
|
+
*/
|
|
10
|
+
const CHATGPT = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGAAAABgCAYAAADimHc4AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAA9jSURBVHhe7Z0HkBVFE4AFc06ogAEw6ymYI2BWgiDJLOacSkEBMSsUpjJnBLOihF9UBFOVivAbyoSYM8GICua7Y3v++vZnn/t6w9swe5z4vqqugtvZ2d3u3Znpnp55iy2WA2NMk9ra2hoR6SsiQx3HGSUiT4nIZBGZKiJTFhHhWXgmno1nHLrgmWvQgdZL4YhI2wU3MU1EHPMvRf4POkAX7bSerFNXV9deRMZxVX0zVVyD/Keurq6D1ltujDHNRWS4vmCVcBzHGYHOtB4zISKdRGSmvkiVeERkloh00fpMhYj00xVXSYeI9Nd6TYTjOEN0ZVWyQSet9RvL/PnzB+pKquRmkNZzKCLSU59ZxQ4i0lvruwwRaSUiP+sTq1hjrjGmtdZ7CcdxntJnVLGLiEzUencRkW66cJViqK+v71GmfOIZIvKGLlilGETkrbIYkojspws1JubPn2+++eYb88EHH5jp06ebTz75xHz33Xe62D8KEens/wIe1QUWNh9//LG54YYbTM+ePc1GG21kVlxxRcOtIosvvrhZZZVVzOabb24OOeQQc+edd5pZs2bpKho1IjLGU34zEflFF1hYvPDCC6ZHjx5m6aWXLik8iay00kqmb9++5q23+LobPyLyK7pfrL6+vlF0vjNnzjSHHnpoQLFpha/jzDPPNL/80mjeqUjQPUPPq/WBhmbChAmmefPmAWXmEZqnxv41oHs64An6QEMyfPjwgPL8su6665qDDz7YDB061Nx///1mzJgx5t577zWXXnqp21StscYagXM8od947rnn9CUbDeieL2C6PtBQoEitNE86duxoxo4da379laYymjlz5pgRI0aYdu3aBepAll9+eXPBBReYY4891uy7775m5513Nh06dDDdu3c3p5xyivsCLKwvBd3zBczQBxqCqVOnuu21Vhijm5EjR+riFamvrzc33nijWXPNNQN1JpHtttvOXHnlleaHH37QVRcGuscAc/SBouGtbtOmTUAJG2+8sXnvvfd08cR8//33ZpdddgnUm0boi6644grX9ygadI8BGjz4NnDgwMCDt27d2h0JZQGDXnzxxWW+Ql7ZaaedzDvvvKMvZRV0jwF+0geKBCUvu+yyZQ+71FJLmTfeyBYJeeCBB1xHTSvQL02bNjUbbLCB2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UIFSKUCaA7alzWtt/zY67SW7AUOMwV0M6ZojONFyCGlT0PMX6gYIATal/4VJrOADOA+pu1k75AQItp9TT0d1+y/z1f06F9hknyJz47SvcRnptA8JXRN4yEecEnxzFAtWjWeP19heomPEGU/8jjKL8+JLcgL2uuvVrC7Tl/MN587PwEaexyW78XOnf+UZAAOT3X5iq5Sv8htplCjr6b/n+dIvsjNYbs9hfjagdfsLbzKsDiYepWh5SMj3ZOHZ+ud/9ZcYx9aeJlnYaG9zNPvtg03VFn+w0j3lAOvXF14nW1hAVqCpleqVlqM9E571FdZavAS4oUXOs8eTXjH/COr8RbVLUY6Zz3wGu7eXauFHy0hab54AdnBV5q77Xybts9h2Wukb06Hz2mtxovpkblbYELuAK3warAOZDydFqeRrnkdHodtaUuNvRNi1PgP5G/PFUAj7PrAFntnnaP8NiM9Z3Rc2LTynwPuikPgKvzYBUaYAZqANtAYgRr7KxfXLv8XIx1nfXgdll8EauzvoYQJnxYM+SEbaqwdNAAtQJMWt/1Ys6v8l0a6FfxoclX8NFBj39Psttc1Oq0T4DxuAn927rhTdGy/OYG1YY09aq1Yu99tq/e7bXtbXRU/NdKp6Adehd7otN8ScNtX+9223T6H9YjPaT3pc1rP+hyW816H9dzNAKwFa/I6rKcaXNYjTTXWPc0u2z2tTvstoIGRLvkc/w9LNRgQOt0FjwAAAABJRU5ErkJggg==";
|
|
12
|
+
const BY_HOST = [
|
|
13
|
+
{ host: "chatgpt.com", name: "ChatGPT", logo: CHATGPT },
|
|
14
|
+
{ host: "claude.ai", name: "Claude", logo: CLAUDE },
|
|
15
|
+
{ host: "claude.com", name: "Claude", logo: CLAUDE },
|
|
16
|
+
];
|
|
17
|
+
/** The logo for a redirect URI, only when its host is exactly (or a subdomain of) a known one. */
|
|
18
|
+
export function clientLogoForRedirect(redirectUri) {
|
|
19
|
+
let host;
|
|
20
|
+
try {
|
|
21
|
+
const url = new URL(redirectUri);
|
|
22
|
+
if (url.protocol !== "https:")
|
|
23
|
+
return undefined;
|
|
24
|
+
host = url.hostname.toLowerCase();
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
const hit = BY_HOST.find((h) => host === h.host || host.endsWith("." + h.host));
|
|
30
|
+
return hit ? { name: hit.name, logo: hit.logo } : undefined;
|
|
31
|
+
}
|
package/build/http.js
CHANGED
|
@@ -11,6 +11,7 @@ import { createServer } from "./server.js";
|
|
|
11
11
|
import { requestContext } from "./context.js";
|
|
12
12
|
import { InistateOAuthProvider, decodeJwtSub, isConnectionToken, connectionModeKey, browserSecretCookieName, browserSecretCookieOptions, readCookie, SUPPORTED_SCOPES, } from "./oauth-provider.js";
|
|
13
13
|
import { getUserMode } from "./mode-store.js";
|
|
14
|
+
import { registerAppAuthorizeRoutes } from "./authorize-app-routes.js";
|
|
14
15
|
const PORT = parseInt(process.env.PORT || "3000", 10);
|
|
15
16
|
const BASE_URL = process.env.INISTATE_API_BASE ||
|
|
16
17
|
process.env.INISTATE_API_URL ||
|
|
@@ -82,6 +83,8 @@ app.post("/authorize/callback", express.urlencoded({ extended: false }), (req, r
|
|
|
82
83
|
res.status(400).send(error instanceof Error ? error.message : "Authorization failed");
|
|
83
84
|
}
|
|
84
85
|
});
|
|
86
|
+
// SS06370: the Inistate App approves natively (no cookie); the originating browser finishes.
|
|
87
|
+
registerAppAuthorizeRoutes(app, oauthProvider, ISSUER_URL);
|
|
85
88
|
/* ------------------------------------------------------------------ */
|
|
86
89
|
/* Health check */
|
|
87
90
|
/* ------------------------------------------------------------------ */
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Inistate logomark (from the brand logo SVG, with the editor metadata and path effects
|
|
3
|
+
* stripped). Inline so the finish page needs no image requests and no img-src in its CSP.
|
|
4
|
+
*/
|
|
5
|
+
export declare const INISTATE_LOGO_SVG = "<svg role=\"img\" aria-label=\"Inistate\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512.00001 512.00001\" version=\"1.1\"><defs><clipPath clipPathUnits=\"userSpaceOnUse\"><path d=\"M 0,141.732 H 141.732 V 0 H 0 Z\" /></clipPath></defs><g style=\"display:inline\"><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:14.2485;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"m 391.61737,305.25401 h 97.87941 V 136.52852 h -97.96141 v 168.64349 a 0.082,0.082 45 0 0 0.082,0.082 z\" /><path style=\"fill:#73cadf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:14.953;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"M 207.0209,304.98991 H 375.46142 V 30.5 a 8,8 45 0 0 -8,-8 H 215.0209 a 8,8 135 0 0 -8,8 z\" /><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:15.1396;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"M 190.94373,22.5 H 30.5 a 8,8 135 0 0 -8,8 v 459 h 168.44373 z\" /><path style=\"display:inline;fill:#a4ce3a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:13.8183;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"m 481.32958,22.5 h -81.79421 a 8,8 135 0 0 -8,8 v 81.92507 a 8,8 45 0 0 8,8 h 81.79421 a 8,8 135 0 0 8,-8 l 0,-81.92507 a 8,8 45 0 0 -8,-8 z\" /><path style=\"fill:#a4ce3a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:14.9525;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"M 215.0209,489.49034 H 481.5 a 8,8 135 0 0 8,-8 V 329.09336 a 8,8 45 0 0 -8,-8 H 215.0209 a 8,8 135 0 0 -8,8 v 152.39698 a 8,8 45 0 0 8,8 z\" /></g><g style=\"display:none\"><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"m 134.77045,112.79233 h 35.46627 V 55.404519 h -35.46627 z\" /><path style=\"fill:#73cadf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"M 77.385798,112.71148 H 134.77045 V 20 H 77.385798 Z\" /><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5.00812;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"M 77.385798,20 H 20 v 150 h 57.385798 z\" /><path style=\"display:inline;fill:#faa300;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"m 170.18424,20 h -35.41379 v 35.404519 h 34.95043 a 0.46336265,0.46336265 135 0 0 0.46336,-0.463363 z\" /><path style=\"fill:#a4ce3a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"M 77.385798,169.99737 H 170.2367 V 112.71148 H 77.385798 Z\" /></g><g style=\"display:none\"><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.23865\" d=\"m 134.44402,113.14365 h 35.46627 V 71.7271 A 15.97126,15.97126 45 0 0 153.93903,55.75584 h -19.49501 z\" /><path style=\"fill:#73cadf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.49455\" d=\"M 77.059371,113.14365 H 134.44402 V 29.432171 a 9,9 45 0 0 -9,-9 H 86.059371 a 9,9 135 0 0 -9,9 z\" /><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3.16784\" d=\"M 77.385798,20 H 35.438885 A 15.438885,15.438885 135 0 0 20,35.438885 V 169.5139 h 57.385798 z\" /><path style=\"display:inline;fill:#faa300;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.21099\" d=\"M 159.75589,20.36604 H 144.3421 a 10,10 135 0 0 -10,10 v 15.404519 a 10,10 45 0 0 10,10 h 15.41379 a 10,10 135 0 0 10,-10 V 30.36604 a 10,10 45 0 0 -10,-10 z\" /><path style=\"fill:#a4ce3a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.4762\" d=\"M 87.149093,170 H 160 a 10,10 135 0 0 10,-10 v -37.28589 a 10,10 45 0 0 -10,-10 H 87.149093 a 10,10 135 0 0 -10,10 V 160 a 10,10 45 0 0 10,10 z\" /><rect style=\"fill:none\" width=\"67.258392\" height=\"61.737179\" x=\"-1.756749\" y=\"17.316526\" /></g><g style=\"display:none\"><path style=\"fill:#73cadf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.11756\" d=\"M 130.50922,91.750875 H 160 V 30 h -29.49078 z\" /><path style=\"fill:#73cadf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.11756\" d=\"M 63.503626,160 H 92.994404 V 30 H 63.503626 Z\" /><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.11756\" d=\"M 126.49638,30 H 97.005583 v 61.750875 h 29.490797 z\" /><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.11756\" d=\"M 59.490775,30 H 30 v 130 h 29.490775 z\" /><path style=\"fill:#a4ce3a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.11756\" d=\"M 97.005583,160 H 159.99833 V 98.249118 H 97.005583 Z\" /><rect style=\"fill:none\" width=\"67.258392\" height=\"61.737179\" x=\"-1.756749\" y=\"17.316526\" /></g><g style=\"display:none\" /><g style=\"display:none\"><path style=\"fill:#73cadf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.26316\" d=\"m 97.0056,100.53462 h 29.49078 V 30 H 97.0056 Z\" /><path style=\"display:inline;fill:#73cadf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.11756\" d=\"M 126.49638,59.49078 V 30 H 64.7455 v 29.49078 z\" /><path style=\"fill:#73cadf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.11756\" d=\"M 63.503626,160 H 92.994404 V 30 H 63.503626 Z\" /><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.26718\" d=\"m 160,30 h -29.49079 v 70.78558 H 160 Z\" /><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.87471\" d=\"M 59.490775,58.107984 H 30 V 160 h 29.490775 z\" /><path style=\"fill:#a4ce3a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.12031\" d=\"M 30,160 H 159.99833 V 130 H 30 Z\" /><path style=\"display:inline;fill:#a4ce3a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.12031\" d=\"M 30.250964,147.06556 H 160.24929 v -30 H 30.250964 Z\" /><rect style=\"fill:none\" width=\"67.258392\" height=\"61.737179\" x=\"-1.756749\" y=\"17.316526\" /><path style=\"fill:#2b9ec6;fill-opacity:1\" d=\"m 127.23881,86.331672 18.03668,0.377977 18.03668,0.377978 -9.34568,15.431233 -9.34567,15.43123 -8.69101,-15.80921 z\" transform=\"matrix(1.2490616,0,0,0.86974614,-35.714539,24.004909)\" /><path style=\"display:inline;fill:#2b9ec6;fill-opacity:1\" transform=\"matrix(-1.2490616,0,0,-0.86974614,223.67462,134.57742)\" d=\"m 127.23881,86.331672 18.03668,0.377977 18.03668,0.377978 -9.34568,15.431233 -9.34567,15.43123 -8.69101,-15.80921 z\" /><path style=\"fill:#73cadf;fill-opacity:1\" d=\"M 15.810742,34.131124 7.7691125,20.202614 -0.27251649,6.2741045 l 16.08325849,-4e-7 16.083257,-4e-7 -8.041629,13.9285103 z\" transform=\"matrix(1.4067251,0,0,1,88.48918,91.969146)\" /></g><g style=\"display:none\" /></svg>";
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The Inistate logomark (from the brand logo SVG, with the editor metadata and path effects
|
|
3
|
+
* stripped). Inline so the finish page needs no image requests and no img-src in its CSP.
|
|
4
|
+
*/
|
|
5
|
+
export const INISTATE_LOGO_SVG = "<svg role=\"img\" aria-label=\"Inistate\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 512.00001 512.00001\" version=\"1.1\"><defs><clipPath clipPathUnits=\"userSpaceOnUse\"><path d=\"M 0,141.732 H 141.732 V 0 H 0 Z\" /></clipPath></defs><g style=\"display:inline\"><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:14.2485;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"m 391.61737,305.25401 h 97.87941 V 136.52852 h -97.96141 v 168.64349 a 0.082,0.082 45 0 0 0.082,0.082 z\" /><path style=\"fill:#73cadf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:14.953;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"M 207.0209,304.98991 H 375.46142 V 30.5 a 8,8 45 0 0 -8,-8 H 215.0209 a 8,8 135 0 0 -8,8 z\" /><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:15.1396;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"M 190.94373,22.5 H 30.5 a 8,8 135 0 0 -8,8 v 459 h 168.44373 z\" /><path style=\"display:inline;fill:#a4ce3a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:13.8183;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"m 481.32958,22.5 h -81.79421 a 8,8 135 0 0 -8,8 v 81.92507 a 8,8 45 0 0 8,8 h 81.79421 a 8,8 135 0 0 8,-8 l 0,-81.92507 a 8,8 45 0 0 -8,-8 z\" /><path style=\"fill:#a4ce3a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:14.9525;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"M 215.0209,489.49034 H 481.5 a 8,8 135 0 0 8,-8 V 329.09336 a 8,8 45 0 0 -8,-8 H 215.0209 a 8,8 135 0 0 -8,8 v 152.39698 a 8,8 45 0 0 8,8 z\" /></g><g style=\"display:none\"><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"m 134.77045,112.79233 h 35.46627 V 55.404519 h -35.46627 z\" /><path style=\"fill:#73cadf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"M 77.385798,112.71148 H 134.77045 V 20 H 77.385798 Z\" /><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5.00812;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"M 77.385798,20 H 20 v 150 h 57.385798 z\" /><path style=\"display:inline;fill:#faa300;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"m 170.18424,20 h -35.41379 v 35.404519 h 34.95043 a 0.46336265,0.46336265 135 0 0 0.46336,-0.463363 z\" /><path style=\"fill:#a4ce3a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:5;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1\" d=\"M 77.385798,169.99737 H 170.2367 V 112.71148 H 77.385798 Z\" /></g><g style=\"display:none\"><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.23865\" d=\"m 134.44402,113.14365 h 35.46627 V 71.7271 A 15.97126,15.97126 45 0 0 153.93903,55.75584 h -19.49501 z\" /><path style=\"fill:#73cadf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.49455\" d=\"M 77.059371,113.14365 H 134.44402 V 29.432171 a 9,9 45 0 0 -9,-9 H 86.059371 a 9,9 135 0 0 -9,9 z\" /><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:3.16784\" d=\"M 77.385798,20 H 35.438885 A 15.438885,15.438885 135 0 0 20,35.438885 V 169.5139 h 57.385798 z\" /><path style=\"display:inline;fill:#faa300;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.21099\" d=\"M 159.75589,20.36604 H 144.3421 a 10,10 135 0 0 -10,10 v 15.404519 a 10,10 45 0 0 10,10 h 15.41379 a 10,10 135 0 0 10,-10 V 30.36604 a 10,10 45 0 0 -10,-10 z\" /><path style=\"fill:#a4ce3a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.4762\" d=\"M 87.149093,170 H 160 a 10,10 135 0 0 10,-10 v -37.28589 a 10,10 45 0 0 -10,-10 H 87.149093 a 10,10 135 0 0 -10,10 V 160 a 10,10 45 0 0 10,10 z\" /><rect style=\"fill:none\" width=\"67.258392\" height=\"61.737179\" x=\"-1.756749\" y=\"17.316526\" /></g><g style=\"display:none\"><path style=\"fill:#73cadf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.11756\" d=\"M 130.50922,91.750875 H 160 V 30 h -29.49078 z\" /><path style=\"fill:#73cadf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.11756\" d=\"M 63.503626,160 H 92.994404 V 30 H 63.503626 Z\" /><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.11756\" d=\"M 126.49638,30 H 97.005583 v 61.750875 h 29.490797 z\" /><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.11756\" d=\"M 59.490775,30 H 30 v 130 h 29.490775 z\" /><path style=\"fill:#a4ce3a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.11756\" d=\"M 97.005583,160 H 159.99833 V 98.249118 H 97.005583 Z\" /><rect style=\"fill:none\" width=\"67.258392\" height=\"61.737179\" x=\"-1.756749\" y=\"17.316526\" /></g><g style=\"display:none\" /><g style=\"display:none\"><path style=\"fill:#73cadf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.26316\" d=\"m 97.0056,100.53462 h 29.49078 V 30 H 97.0056 Z\" /><path style=\"display:inline;fill:#73cadf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.11756\" d=\"M 126.49638,59.49078 V 30 H 64.7455 v 29.49078 z\" /><path style=\"fill:#73cadf;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.11756\" d=\"M 63.503626,160 H 92.994404 V 30 H 63.503626 Z\" /><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.26718\" d=\"m 160,30 h -29.49079 v 70.78558 H 160 Z\" /><path style=\"fill:#2b9ec6;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:1.87471\" d=\"M 59.490775,58.107984 H 30 V 160 h 29.490775 z\" /><path style=\"fill:#a4ce3a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.12031\" d=\"M 30,160 H 159.99833 V 130 H 30 Z\" /><path style=\"display:inline;fill:#a4ce3a;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:2.12031\" d=\"M 30.250964,147.06556 H 160.24929 v -30 H 30.250964 Z\" /><rect style=\"fill:none\" width=\"67.258392\" height=\"61.737179\" x=\"-1.756749\" y=\"17.316526\" /><path style=\"fill:#2b9ec6;fill-opacity:1\" d=\"m 127.23881,86.331672 18.03668,0.377977 18.03668,0.377978 -9.34568,15.431233 -9.34567,15.43123 -8.69101,-15.80921 z\" transform=\"matrix(1.2490616,0,0,0.86974614,-35.714539,24.004909)\" /><path style=\"display:inline;fill:#2b9ec6;fill-opacity:1\" transform=\"matrix(-1.2490616,0,0,-0.86974614,223.67462,134.57742)\" d=\"m 127.23881,86.331672 18.03668,0.377977 18.03668,0.377978 -9.34568,15.431233 -9.34567,15.43123 -8.69101,-15.80921 z\" /><path style=\"fill:#73cadf;fill-opacity:1\" d=\"M 15.810742,34.131124 7.7691125,20.202614 -0.27251649,6.2741045 l 16.08325849,-4e-7 16.083257,-4e-7 -8.041629,13.9285103 z\" transform=\"matrix(1.4067251,0,0,1,88.48918,91.969146)\" /></g><g style=\"display:none\" /></svg>";
|
|
@@ -82,6 +82,27 @@ export declare class InistateOAuthProvider implements OAuthServerProvider {
|
|
|
82
82
|
completeAuthorization(nonce: string, jwt: string, refreshToken?: string, browserSecret?: string): {
|
|
83
83
|
redirectUrl: string;
|
|
84
84
|
};
|
|
85
|
+
private issueCode;
|
|
86
|
+
/**
|
|
87
|
+
* SS06370: the Inistate App approves a flow it did not start. No cookie is needed (it has
|
|
88
|
+
* none); the approval is parked and the one-time token returned goes back to the App only.
|
|
89
|
+
* The JWT is checked against the backend first so the finish page can name a real account.
|
|
90
|
+
*/
|
|
91
|
+
parkAppApproval(nonce: string, jwt: string, refreshToken?: string): Promise<{
|
|
92
|
+
finishToken: string;
|
|
93
|
+
}>;
|
|
94
|
+
/** What the finish page shows before the user confirms. Needs the cookie and the token. */
|
|
95
|
+
getFinishInfo(nonce: string, finishToken: string, browserSecret?: string): {
|
|
96
|
+
clientName: string;
|
|
97
|
+
account: string;
|
|
98
|
+
redirectUri: string;
|
|
99
|
+
};
|
|
100
|
+
/** Finish an App-approved flow: the originating browser (cookie) plus the App's token. */
|
|
101
|
+
completeParkedAuthorization(nonce: string, finishToken: string, browserSecret?: string): {
|
|
102
|
+
redirectUrl: string;
|
|
103
|
+
};
|
|
104
|
+
private livePending;
|
|
105
|
+
private finishablePending;
|
|
85
106
|
challengeForAuthorizationCode(_client: OAuthClientInformationFull, authorizationCode: string): Promise<string>;
|
|
86
107
|
exchangeAuthorizationCode(client: OAuthClientInformationFull, authorizationCode: string): Promise<OAuthTokens>;
|
|
87
108
|
/**
|
package/build/oauth-provider.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createHash, randomUUID } from "node:crypto";
|
|
1
|
+
import { createHash, randomUUID, timingSafeEqual } from "node:crypto";
|
|
2
2
|
import { FileClientsStore } from "./client-store.js";
|
|
3
3
|
import { InvalidGrantError, TemporarilyUnavailableError } from "@modelcontextprotocol/sdk/server/auth/errors.js";
|
|
4
4
|
const CODE_TTL_MS = 5 * 60 * 1000; // 5 minutes
|
|
@@ -133,6 +133,12 @@ function expiresInFromExp(exp) {
|
|
|
133
133
|
export function browserSecretCookieName(nonce) {
|
|
134
134
|
return `mcp_auth_${nonce}`;
|
|
135
135
|
}
|
|
136
|
+
/** Constant-time string comparison for secrets. */
|
|
137
|
+
function safeEqual(a, b) {
|
|
138
|
+
const x = Buffer.from(a);
|
|
139
|
+
const y = Buffer.from(b);
|
|
140
|
+
return x.length === y.length && timingSafeEqual(x, y);
|
|
141
|
+
}
|
|
136
142
|
/** The value of one cookie out of a raw Cookie header, or undefined. */
|
|
137
143
|
export function readCookie(header, name) {
|
|
138
144
|
if (!header)
|
|
@@ -198,6 +204,7 @@ export class InistateOAuthProvider {
|
|
|
198
204
|
const browserSecret = randomUUID();
|
|
199
205
|
this.pendingAuth.set(nonce, {
|
|
200
206
|
clientId: client.client_id,
|
|
207
|
+
clientName: client.client_name,
|
|
201
208
|
params,
|
|
202
209
|
createdAt: Date.now(),
|
|
203
210
|
browserSecret,
|
|
@@ -249,6 +256,9 @@ export class InistateOAuthProvider {
|
|
|
249
256
|
throw new Error("Authorization session does not belong to this browser");
|
|
250
257
|
}
|
|
251
258
|
this.pendingAuth.delete(nonce);
|
|
259
|
+
return this.issueCode(pending, jwt, refreshToken);
|
|
260
|
+
}
|
|
261
|
+
issueCode(pending, jwt, refreshToken) {
|
|
252
262
|
const code = randomUUID();
|
|
253
263
|
this.codes.set(code, {
|
|
254
264
|
codeChallenge: pending.params.codeChallenge,
|
|
@@ -266,6 +276,62 @@ export class InistateOAuthProvider {
|
|
|
266
276
|
url.searchParams.set("state", pending.params.state);
|
|
267
277
|
return { redirectUrl: url.toString() };
|
|
268
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* SS06370: the Inistate App approves a flow it did not start. No cookie is needed (it has
|
|
281
|
+
* none); the approval is parked and the one-time token returned goes back to the App only.
|
|
282
|
+
* The JWT is checked against the backend first so the finish page can name a real account.
|
|
283
|
+
*/
|
|
284
|
+
async parkAppApproval(nonce, jwt, refreshToken) {
|
|
285
|
+
const pending = this.livePending(nonce);
|
|
286
|
+
if (pending.parked)
|
|
287
|
+
throw new Error("This authorization was already approved");
|
|
288
|
+
const res = await fetch(`${this.baseUrl}/v1/whoami`, {
|
|
289
|
+
headers: { Authorization: `Bearer ${jwt}`, Accept: "application/json" },
|
|
290
|
+
});
|
|
291
|
+
if (!res.ok)
|
|
292
|
+
throw new Error("Bearer token is invalid or expired");
|
|
293
|
+
const who = (await res.json().catch(() => ({})));
|
|
294
|
+
const account = String(who.userName || who.userId || "your Inistate account");
|
|
295
|
+
// The whoami round trip is a window: re-check, the first approval wins.
|
|
296
|
+
const current = this.livePending(nonce);
|
|
297
|
+
if (current.parked)
|
|
298
|
+
throw new Error("This authorization was already approved");
|
|
299
|
+
const finishToken = randomUUID();
|
|
300
|
+
current.parked = { jwt, refreshToken, finishToken, account };
|
|
301
|
+
return { finishToken };
|
|
302
|
+
}
|
|
303
|
+
/** What the finish page shows before the user confirms. Needs the cookie and the token. */
|
|
304
|
+
getFinishInfo(nonce, finishToken, browserSecret) {
|
|
305
|
+
const pending = this.finishablePending(nonce, finishToken, browserSecret);
|
|
306
|
+
return { clientName: pending.clientName, account: pending.parked.account, redirectUri: pending.params.redirectUri };
|
|
307
|
+
}
|
|
308
|
+
/** Finish an App-approved flow: the originating browser (cookie) plus the App's token. */
|
|
309
|
+
completeParkedAuthorization(nonce, finishToken, browserSecret) {
|
|
310
|
+
const pending = this.finishablePending(nonce, finishToken, browserSecret);
|
|
311
|
+
this.pendingAuth.delete(nonce);
|
|
312
|
+
return this.issueCode(pending, pending.parked.jwt, pending.parked.refreshToken);
|
|
313
|
+
}
|
|
314
|
+
livePending(nonce) {
|
|
315
|
+
const pending = this.pendingAuth.get(nonce);
|
|
316
|
+
if (!pending)
|
|
317
|
+
throw new Error("Invalid or expired authorization nonce");
|
|
318
|
+
if (Date.now() - pending.createdAt > CODE_TTL_MS) {
|
|
319
|
+
this.pendingAuth.delete(nonce);
|
|
320
|
+
throw new Error("Authorization session expired");
|
|
321
|
+
}
|
|
322
|
+
return pending;
|
|
323
|
+
}
|
|
324
|
+
finishablePending(nonce, finishToken, browserSecret) {
|
|
325
|
+
const pending = this.livePending(nonce);
|
|
326
|
+
if (!browserSecret || browserSecret !== pending.browserSecret) {
|
|
327
|
+
throw new Error("Authorization session does not belong to this browser");
|
|
328
|
+
}
|
|
329
|
+
const parked = pending.parked;
|
|
330
|
+
if (!parked || !finishToken || !safeEqual(finishToken, parked.finishToken)) {
|
|
331
|
+
throw new Error("Invalid finish token");
|
|
332
|
+
}
|
|
333
|
+
return { ...pending, parked, clientName: pending.clientName ?? "" };
|
|
334
|
+
}
|
|
269
335
|
/* ---- PKCE ---- */
|
|
270
336
|
async challengeForAuthorizationCode(_client, authorizationCode) {
|
|
271
337
|
const stored = this.codes.get(authorizationCode);
|
package/package.json
CHANGED
package/server.json
CHANGED
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"url": "https://github.com/inistate/inistate-mcp",
|
|
9
9
|
"source": "github"
|
|
10
10
|
},
|
|
11
|
-
"version": "1.3.
|
|
11
|
+
"version": "1.3.4",
|
|
12
12
|
"packages": [
|
|
13
13
|
{
|
|
14
14
|
"registryType": "npm",
|
|
15
15
|
"registryBaseUrl": "https://registry.npmjs.org",
|
|
16
16
|
"identifier": "inistate-mcp",
|
|
17
|
-
"version": "1.3.
|
|
17
|
+
"version": "1.3.4",
|
|
18
18
|
"transport": {
|
|
19
19
|
"type": "stdio"
|
|
20
20
|
},
|