pi-mcp-extension 1.15.2 → 1.15.3
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 +1 -1
- package/src/authorize-browser.ts +15 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-mcp-extension",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.3",
|
|
4
4
|
"description": "Full-featured, lightweight MCP extension for the Pi coding agent: stdio, SSE & Streamable HTTP transports, OAuth 2.1 (PKCE + DCR), lazy/eager lifecycles — minimal dependencies, zero bloat.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
package/src/authorize-browser.ts
CHANGED
|
@@ -40,6 +40,7 @@ export type BrowserSpawn = (
|
|
|
40
40
|
export interface OpenBrowserDeps {
|
|
41
41
|
platform?: NodeJS.Platform | undefined;
|
|
42
42
|
spawnProcess?: BrowserSpawn | undefined;
|
|
43
|
+
serverName?: string | undefined;
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
export interface BrowserLauncherContext {
|
|
@@ -73,8 +74,21 @@ export function browserOpenCommand(
|
|
|
73
74
|
* Works on macOS, Linux, and Windows.
|
|
74
75
|
*/
|
|
75
76
|
export function openBrowser(url: string, deps?: OpenBrowserDeps): Promise<void> {
|
|
77
|
+
// WHY: This public entry point must enforce the URL policy independently of its callers,
|
|
78
|
+
// and require a string primitive so a non-string object with a stateful `toString()`
|
|
79
|
+
// cannot pass validation and mutate before `new URL(url)`.
|
|
80
|
+
if (typeof url !== "string" || !isSafeAuthorizationUrl(url)) {
|
|
81
|
+
return Promise.reject(
|
|
82
|
+
new McpError(
|
|
83
|
+
"Refusing to open unsafe authorization URL: only HTTPS (or loopback HTTP) URLs are allowed",
|
|
84
|
+
deps?.serverName ?? "<oauth>",
|
|
85
|
+
"protocol",
|
|
86
|
+
),
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
const safeHref = new URL(url).toString();
|
|
76
90
|
const spawnProcess: BrowserSpawn = deps?.spawnProcess ?? spawn;
|
|
77
|
-
const { command, args } = browserOpenCommand(
|
|
91
|
+
const { command, args } = browserOpenCommand(safeHref, deps?.platform);
|
|
78
92
|
return new Promise<void>((resolve, reject) => {
|
|
79
93
|
const child = spawnProcess(command, args, {
|
|
80
94
|
detached: true,
|