strands-darwin 0.0.44 → 0.0.45
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/README.md +4 -1
- package/README.zh-CN.md +4 -1
- package/dist/patches/ink+7.1.1.patch +15 -0
- package/dist/src/agent/context-breakdown.d.ts +26 -3
- package/dist/src/agent/context-breakdown.js +27 -1
- package/dist/src/agent/context-breakdown.js.map +1 -1
- package/dist/src/agent/goal-check.d.ts +35 -0
- package/dist/src/agent/goal-check.js +132 -0
- package/dist/src/agent/goal-check.js.map +1 -0
- package/dist/src/agent/model-retry.d.ts +6 -1
- package/dist/src/agent/model-retry.js +45 -9
- package/dist/src/agent/model-retry.js.map +1 -1
- package/dist/src/agent/permission-rules.d.ts +31 -13
- package/dist/src/agent/permission-rules.js +180 -20
- package/dist/src/agent/permission-rules.js.map +1 -1
- package/dist/src/agent/permission.d.ts +0 -6
- package/dist/src/agent/permission.js +4 -3
- package/dist/src/agent/permission.js.map +1 -1
- package/dist/src/agent/runtime.d.ts +9 -0
- package/dist/src/agent/runtime.js +39 -3
- package/dist/src/agent/runtime.js.map +1 -1
- package/dist/src/agent/safety-classifier.d.ts +3 -1
- package/dist/src/agent/safety-classifier.js +0 -0
- package/dist/src/agent/safety-classifier.js.map +1 -1
- package/dist/src/agent/working-context.d.ts +16 -0
- package/dist/src/agent/working-context.js +20 -0
- package/dist/src/agent/working-context.js.map +1 -1
- package/dist/src/cli-main.js +3 -1
- package/dist/src/cli-main.js.map +1 -1
- package/dist/src/cli-mcp.d.ts +12 -0
- package/dist/src/cli-mcp.js +111 -0
- package/dist/src/cli-mcp.js.map +1 -0
- package/dist/src/cli-usage.d.ts +1 -1
- package/dist/src/cli-usage.js +2 -0
- package/dist/src/cli-usage.js.map +1 -1
- package/dist/src/cli.js +4 -0
- package/dist/src/cli.js.map +1 -1
- package/dist/src/collaboration/command.js +1 -1
- package/dist/src/collaboration/command.js.map +1 -1
- package/dist/src/collaboration/local.d.ts +137 -6
- package/dist/src/collaboration/local.js +76 -19
- package/dist/src/collaboration/local.js.map +1 -1
- package/dist/src/collaboration/tools.js +1 -1
- package/dist/src/collaboration/tools.js.map +1 -1
- package/dist/src/commands/custom-commands.d.ts +1 -1
- package/dist/src/commands/custom-commands.js +3 -1
- package/dist/src/commands/custom-commands.js.map +1 -1
- package/dist/src/commands/goal-command.d.ts +26 -0
- package/dist/src/commands/goal-command.js +32 -0
- package/dist/src/commands/goal-command.js.map +1 -0
- package/dist/src/config.d.ts +3 -5
- package/dist/src/config.js.map +1 -1
- package/dist/src/mcp/oauth-login.d.ts +37 -0
- package/dist/src/mcp/oauth-login.js +263 -0
- package/dist/src/mcp/oauth-login.js.map +1 -0
- package/dist/src/mcp/oauth-net.d.ts +50 -0
- package/dist/src/mcp/oauth-net.js +321 -0
- package/dist/src/mcp/oauth-net.js.map +1 -0
- package/dist/src/mcp/oauth-provider.d.ts +89 -0
- package/dist/src/mcp/oauth-provider.js +398 -0
- package/dist/src/mcp/oauth-provider.js.map +1 -0
- package/dist/src/mcp/oauth-store.d.ts +49 -0
- package/dist/src/mcp/oauth-store.js +176 -0
- package/dist/src/mcp/oauth-store.js.map +1 -0
- package/dist/src/mcp/registry.d.ts +6 -0
- package/dist/src/mcp/registry.js +83 -4
- package/dist/src/mcp/registry.js.map +1 -1
- package/dist/src/tools/shell-env.d.ts +27 -1
- package/dist/src/tools/shell-env.js +34 -5
- package/dist/src/tools/shell-env.js.map +1 -1
- package/dist/src/tui/App.d.ts +4 -1
- package/dist/src/tui/App.js +209 -10
- package/dist/src/tui/App.js.map +1 -1
- package/dist/src/tui/InputBox.d.ts +1 -1
- package/dist/src/tui/InputBox.js +1 -1
- package/dist/src/tui/context-format.d.ts +7 -3
- package/dist/src/tui/context-format.js +28 -3
- package/dist/src/tui/context-format.js.map +1 -1
- package/dist/src/tui/goal.d.ts +123 -0
- package/dist/src/tui/goal.js +187 -0
- package/dist/src/tui/goal.js.map +1 -0
- package/dist/src/tui/help-format.d.ts +1 -1
- package/dist/src/tui/help-format.js +1 -1
- package/dist/src/tui/mcp-format.js +5 -1
- package/dist/src/tui/mcp-format.js.map +1 -1
- package/dist/src/tui/prompt-editor.d.ts +4 -3
- package/dist/src/tui/prompt-editor.js +8 -3
- package/dist/src/tui/prompt-editor.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type OAuthServerSettings } from './oauth-provider.js';
|
|
2
|
+
export declare const LOGIN_TIMEOUT_MS: number;
|
|
3
|
+
export declare class OAuthLoginError extends Error {
|
|
4
|
+
constructor(message: string);
|
|
5
|
+
}
|
|
6
|
+
export interface LoopbackCallback {
|
|
7
|
+
/** `http://127.0.0.1:<port>/callback` — the redirect URI to register. */
|
|
8
|
+
readonly redirectUrl: string;
|
|
9
|
+
/** Resolves with the first callback whose `state` matches; rejects on deadline, abort or flooding. */
|
|
10
|
+
wait(expectedState: () => string | undefined): Promise<URLSearchParams>;
|
|
11
|
+
close(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/** Binds the loopback listener (port 0 = ephemeral) and starts counting its deadline in `wait`. */
|
|
14
|
+
export declare function startLoopbackCallback(options: {
|
|
15
|
+
port?: number;
|
|
16
|
+
timeoutMs?: number;
|
|
17
|
+
signal?: AbortSignal;
|
|
18
|
+
}): Promise<LoopbackCallback>;
|
|
19
|
+
/** Best-effort default-browser launch: argv only (no shell), detached, output ignored. */
|
|
20
|
+
export declare function openInBrowser(url: string): Promise<boolean>;
|
|
21
|
+
/** A short single-line description of a failure, safe to print: no control characters, bounded. */
|
|
22
|
+
export declare function describeLoginFailure(error: unknown): string;
|
|
23
|
+
export interface RunLoginOptions {
|
|
24
|
+
readonly settings: OAuthServerSettings;
|
|
25
|
+
readonly timeoutMs?: number;
|
|
26
|
+
readonly signal?: AbortSignal;
|
|
27
|
+
/** Progress lines (never a secret). */
|
|
28
|
+
readonly log: (line: string) => void;
|
|
29
|
+
/** Launch the browser; `false` skips it (the URL is always printed). Default: {@link openInBrowser}. */
|
|
30
|
+
readonly open?: ((url: string) => Promise<boolean>) | false;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Logs in to one server: probe → discovery → registration → browser → callback → code exchange →
|
|
34
|
+
* store. Resolves when the token record is written; rejects with {@link OAuthLoginError} or an
|
|
35
|
+
* SDK/policy error whose message {@link describeLoginFailure} makes printable.
|
|
36
|
+
*/
|
|
37
|
+
export declare function runOAuthLogin(options: RunLoginOptions): Promise<void>;
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `darwin mcp login` engine (SER-107): a bounded authorization-code + PKCE login for one remote
|
|
3
|
+
* MCP server, run entirely by the MCP SDK's `auth()` over darwin's guarded fetch and provider.
|
|
4
|
+
*
|
|
5
|
+
* The only listener is a loopback callback: bound to `127.0.0.1`, one path, one accepted
|
|
6
|
+
* callback, a Host-header check against DNS rebinding, a `state` check (a request with the wrong
|
|
7
|
+
* state is answered `400` and ignored, so a stray local page can neither complete nor abort the
|
|
8
|
+
* login), a request cap, and a hard deadline. It answers with a fixed static page and reflects
|
|
9
|
+
* nothing it received. The deadline, `AbortSignal` and the listener's teardown are the whole
|
|
10
|
+
* lifecycle: nothing outlives this call.
|
|
11
|
+
*/
|
|
12
|
+
import { spawn } from 'node:child_process';
|
|
13
|
+
import { timingSafeEqual } from 'node:crypto';
|
|
14
|
+
import http from 'node:http';
|
|
15
|
+
import { auth, extractWWWAuthenticateParams } from '@modelcontextprotocol/sdk/client/auth.js';
|
|
16
|
+
import { createGuardedFetch, validateOAuthUrl } from './oauth-net.js';
|
|
17
|
+
import { DarwinOAuthProvider } from './oauth-provider.js';
|
|
18
|
+
import { writeOAuthRecord } from './oauth-store.js';
|
|
19
|
+
export const LOGIN_TIMEOUT_MS = 5 * 60_000;
|
|
20
|
+
const MAX_CALLBACK_REQUESTS = 25;
|
|
21
|
+
const MAX_CALLBACK_PARAM = 4096;
|
|
22
|
+
export class OAuthLoginError extends Error {
|
|
23
|
+
constructor(message) {
|
|
24
|
+
super(message);
|
|
25
|
+
this.name = 'OAuthLoginError';
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
const CALLBACK_PAGE = (title, body) => `<!doctype html><meta charset="utf-8"><title>${title}</title><body style="font-family:sans-serif;margin:3em"><h1>${title}</h1><p>${body}</p></body>`;
|
|
29
|
+
/** Binds the loopback listener (port 0 = ephemeral) and starts counting its deadline in `wait`. */
|
|
30
|
+
export async function startLoopbackCallback(options) {
|
|
31
|
+
const timeoutMs = options.timeoutMs ?? LOGIN_TIMEOUT_MS;
|
|
32
|
+
let requests = 0;
|
|
33
|
+
let settle;
|
|
34
|
+
let expected = () => undefined;
|
|
35
|
+
let done = false;
|
|
36
|
+
const server = http.createServer((request, response) => {
|
|
37
|
+
const reply = (status, title, body) => {
|
|
38
|
+
response.writeHead(status, {
|
|
39
|
+
'Content-Type': 'text/html; charset=utf-8',
|
|
40
|
+
'Cache-Control': 'no-store',
|
|
41
|
+
'Referrer-Policy': 'no-referrer',
|
|
42
|
+
'Content-Security-Policy': "default-src 'none'; style-src 'unsafe-inline'",
|
|
43
|
+
Connection: 'close',
|
|
44
|
+
});
|
|
45
|
+
response.end(CALLBACK_PAGE(title, body));
|
|
46
|
+
};
|
|
47
|
+
requests += 1;
|
|
48
|
+
if (requests > MAX_CALLBACK_REQUESTS) {
|
|
49
|
+
reply(429, 'Too many requests', 'The login was cancelled.');
|
|
50
|
+
settle?.reject(new OAuthLoginError('too many requests reached the loopback callback; login cancelled'));
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const port = server.address()?.port;
|
|
54
|
+
const host = request.headers.host;
|
|
55
|
+
if (done || host === undefined || (host !== `127.0.0.1:${port}` && host !== `localhost:${port}`)) {
|
|
56
|
+
reply(403, 'Forbidden', 'Unexpected host.');
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
let url;
|
|
60
|
+
try {
|
|
61
|
+
url = new URL(request.url ?? '/', `http://127.0.0.1:${port}`);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
reply(400, 'Bad request', 'Malformed request.');
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (request.method !== 'GET' || url.pathname !== '/callback') {
|
|
68
|
+
reply(404, 'Not found', 'Nothing here.');
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const want = expected();
|
|
72
|
+
const got = url.searchParams.get('state') ?? '';
|
|
73
|
+
const stateOk = want !== undefined && got.length === want.length && timingSafeEqual(Buffer.from(got), Buffer.from(want));
|
|
74
|
+
if (!stateOk) {
|
|
75
|
+
reply(400, 'Bad request', 'This request does not belong to the login in progress.');
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
for (const value of url.searchParams.values()) {
|
|
79
|
+
if (value.length > MAX_CALLBACK_PARAM) {
|
|
80
|
+
reply(400, 'Bad request', 'A parameter is too long.');
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
done = true;
|
|
85
|
+
reply(200, 'darwin login', 'You can close this tab and return to the terminal.');
|
|
86
|
+
settle?.resolve(url.searchParams);
|
|
87
|
+
});
|
|
88
|
+
await new Promise((resolve, reject) => {
|
|
89
|
+
server.once('error', reject);
|
|
90
|
+
server.listen({ host: '127.0.0.1', port: options.port ?? 0 }, () => {
|
|
91
|
+
server.off('error', reject);
|
|
92
|
+
resolve();
|
|
93
|
+
});
|
|
94
|
+
}).catch((error) => {
|
|
95
|
+
throw new OAuthLoginError(error.code === 'EADDRINUSE'
|
|
96
|
+
? `loopback callback port ${options.port} is already in use`
|
|
97
|
+
: `could not open the loopback callback listener (${error.code ?? 'error'})`);
|
|
98
|
+
});
|
|
99
|
+
const port = server.address().port;
|
|
100
|
+
const close = async () => {
|
|
101
|
+
done = true;
|
|
102
|
+
settle?.reject(new OAuthLoginError('login closed'));
|
|
103
|
+
await new Promise((resolve) => {
|
|
104
|
+
server.close(() => resolve());
|
|
105
|
+
server.closeAllConnections();
|
|
106
|
+
});
|
|
107
|
+
};
|
|
108
|
+
return {
|
|
109
|
+
redirectUrl: `http://127.0.0.1:${port}/callback`,
|
|
110
|
+
close,
|
|
111
|
+
wait(expectedState) {
|
|
112
|
+
expected = expectedState;
|
|
113
|
+
return new Promise((resolve, reject) => {
|
|
114
|
+
const timer = setTimeout(() => reject(new OAuthLoginError(`no callback within ${Math.round(timeoutMs / 1000)} s; login timed out`)), timeoutMs);
|
|
115
|
+
const onAbort = () => reject(new OAuthLoginError('login cancelled'));
|
|
116
|
+
const clear = () => {
|
|
117
|
+
clearTimeout(timer);
|
|
118
|
+
options.signal?.removeEventListener('abort', onAbort);
|
|
119
|
+
};
|
|
120
|
+
settle = {
|
|
121
|
+
resolve: (params) => {
|
|
122
|
+
clear();
|
|
123
|
+
resolve(params);
|
|
124
|
+
},
|
|
125
|
+
reject: (error) => {
|
|
126
|
+
clear();
|
|
127
|
+
reject(error);
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
if (options.signal?.aborted === true)
|
|
131
|
+
onAbort();
|
|
132
|
+
else
|
|
133
|
+
options.signal?.addEventListener('abort', onAbort, { once: true });
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
/** Best-effort default-browser launch: argv only (no shell), detached, output ignored. */
|
|
139
|
+
export async function openInBrowser(url) {
|
|
140
|
+
const parsed = new URL(url);
|
|
141
|
+
if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:')
|
|
142
|
+
return false;
|
|
143
|
+
const [command, args] = process.platform === 'darwin'
|
|
144
|
+
? ['open', [parsed.href]]
|
|
145
|
+
: process.platform === 'win32'
|
|
146
|
+
? ['rundll32', ['url.dll,FileProtocolHandler', parsed.href]]
|
|
147
|
+
: ['xdg-open', [parsed.href]];
|
|
148
|
+
return await new Promise((resolve) => {
|
|
149
|
+
try {
|
|
150
|
+
const child = spawn(command, args, { stdio: 'ignore', detached: true });
|
|
151
|
+
child.once('error', () => resolve(false));
|
|
152
|
+
child.once('spawn', () => {
|
|
153
|
+
child.unref();
|
|
154
|
+
resolve(true);
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
catch {
|
|
158
|
+
resolve(false);
|
|
159
|
+
}
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
/** A short single-line description of a failure, safe to print: no control characters, bounded. */
|
|
163
|
+
export function describeLoginFailure(error) {
|
|
164
|
+
const text = error instanceof Error ? `${error.name === 'Error' ? '' : `${error.name}: `}${error.message}` : String(error);
|
|
165
|
+
// An SDK error can quote a raw server response; never let one carry a credential into the terminal.
|
|
166
|
+
return text
|
|
167
|
+
.replace(/("?(?:access_token|refresh_token|id_token|client_secret|code_verifier|code)"?\s*[:=]\s*)("[^"]*"|[^\s,&}]+)/gi, '$1[redacted]')
|
|
168
|
+
.replace(/\bBearer\s+[A-Za-z0-9._~+/=-]+/gi, 'Bearer [redacted]')
|
|
169
|
+
.replace(/[\u0000-\u001f\u007f]+/g, ' ')
|
|
170
|
+
.trim()
|
|
171
|
+
.slice(0, 300);
|
|
172
|
+
}
|
|
173
|
+
/**
|
|
174
|
+
* Logs in to one server: probe → discovery → registration → browser → callback → code exchange →
|
|
175
|
+
* store. Resolves when the token record is written; rejects with {@link OAuthLoginError} or an
|
|
176
|
+
* SDK/policy error whose message {@link describeLoginFailure} makes printable.
|
|
177
|
+
*/
|
|
178
|
+
export async function runOAuthLogin(options) {
|
|
179
|
+
const { settings, log } = options;
|
|
180
|
+
const fetchFn = createGuardedFetch({
|
|
181
|
+
allowPrivate: settings.allowPrivate,
|
|
182
|
+
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
183
|
+
});
|
|
184
|
+
const callback = await startLoopbackCallback({
|
|
185
|
+
...(settings.callbackPort === undefined ? {} : { port: settings.callbackPort }),
|
|
186
|
+
...(options.timeoutMs === undefined ? {} : { timeoutMs: options.timeoutMs }),
|
|
187
|
+
...(options.signal === undefined ? {} : { signal: options.signal }),
|
|
188
|
+
});
|
|
189
|
+
try {
|
|
190
|
+
// One unauthenticated probe: the 401's WWW-Authenticate names the resource metadata document.
|
|
191
|
+
const probe = await fetchFn(settings.serverUrl, {
|
|
192
|
+
method: 'POST',
|
|
193
|
+
headers: { 'content-type': 'application/json', accept: 'application/json, text/event-stream' },
|
|
194
|
+
body: JSON.stringify({
|
|
195
|
+
jsonrpc: '2.0',
|
|
196
|
+
id: 1,
|
|
197
|
+
method: 'initialize',
|
|
198
|
+
params: { protocolVersion: '2025-03-26', capabilities: {}, clientInfo: { name: 'darwin', version: '0' } },
|
|
199
|
+
}),
|
|
200
|
+
});
|
|
201
|
+
if (probe.status >= 200 && probe.status < 300) {
|
|
202
|
+
throw new OAuthLoginError('the server accepted a request without authentication; there is nothing to log in to');
|
|
203
|
+
}
|
|
204
|
+
const challenge = extractWWWAuthenticateParams(probe);
|
|
205
|
+
let resourceMetadataUrl;
|
|
206
|
+
if (challenge.resourceMetadataUrl !== undefined) {
|
|
207
|
+
const candidate = validateOAuthUrl(challenge.resourceMetadataUrl, 'resource metadata URL', { allowPrivate: settings.allowPrivate });
|
|
208
|
+
if (candidate.origin !== settings.serverUrl.origin) {
|
|
209
|
+
throw new OAuthLoginError('the server pointed its resource metadata at a different origin; refusing to follow it');
|
|
210
|
+
}
|
|
211
|
+
resourceMetadataUrl = candidate;
|
|
212
|
+
}
|
|
213
|
+
const scope = settings.scope ?? challenge.scope;
|
|
214
|
+
const provider = new DarwinOAuthProvider({
|
|
215
|
+
settings,
|
|
216
|
+
mode: 'login',
|
|
217
|
+
redirectUrl: callback.redirectUrl,
|
|
218
|
+
onAuthorizationUrl: async (url) => {
|
|
219
|
+
log(`Open this URL to authorize darwin:\n ${url.href}`);
|
|
220
|
+
if (options.open === false)
|
|
221
|
+
return;
|
|
222
|
+
const opened = await (options.open ?? openInBrowser)(url.href);
|
|
223
|
+
log(opened ? 'Opened your browser; waiting for the callback…' : 'Could not open a browser; open the URL above yourself. Waiting for the callback…');
|
|
224
|
+
},
|
|
225
|
+
});
|
|
226
|
+
// Listening for the callback (and its deadline) starts before the browser can possibly call back.
|
|
227
|
+
const pending = callback.wait(() => provider.expectedState);
|
|
228
|
+
pending.catch(() => undefined);
|
|
229
|
+
const authOptions = {
|
|
230
|
+
serverUrl: settings.serverUrl,
|
|
231
|
+
fetchFn,
|
|
232
|
+
...(resourceMetadataUrl === undefined ? {} : { resourceMetadataUrl }),
|
|
233
|
+
...(scope === undefined ? {} : { scope }),
|
|
234
|
+
};
|
|
235
|
+
const first = await auth(provider, authOptions);
|
|
236
|
+
if (first !== 'REDIRECT')
|
|
237
|
+
throw new OAuthLoginError('the authorization server did not request an interactive authorization');
|
|
238
|
+
const params = await pending;
|
|
239
|
+
const issuer = params.get('iss');
|
|
240
|
+
if (issuer !== null) {
|
|
241
|
+
const metadataIssuer = provider.discoveryState()?.authorizationServerMetadata?.issuer;
|
|
242
|
+
if (metadataIssuer !== undefined && metadataIssuer !== issuer) {
|
|
243
|
+
throw new OAuthLoginError('the callback\'s iss parameter does not match the authorization server; refused');
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
const denied = params.get('error');
|
|
247
|
+
if (denied !== null) {
|
|
248
|
+
throw new OAuthLoginError(`the authorization server refused the login (${denied.replace(/[^A-Za-z0-9_.-]/g, '').slice(0, 64) || 'error'})`);
|
|
249
|
+
}
|
|
250
|
+
const code = params.get('code');
|
|
251
|
+
if (code === null || code === '')
|
|
252
|
+
throw new OAuthLoginError('the callback carried no authorization code');
|
|
253
|
+
const second = await auth(provider, { ...authOptions, authorizationCode: code });
|
|
254
|
+
if (second !== 'AUTHORIZED')
|
|
255
|
+
throw new OAuthLoginError('the code exchange did not authorize');
|
|
256
|
+
await writeOAuthRecord(provider.buildRecord());
|
|
257
|
+
log(`Logged in to ${settings.name}.`);
|
|
258
|
+
}
|
|
259
|
+
finally {
|
|
260
|
+
await callback.close();
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
//# sourceMappingURL=oauth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AAC,CAAC;QACnC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;YACpB,MAAM,IAAI,eAAe,CAAC,+CAA+C,MAAM,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,OAAO,GAAG,CAAC,CAAC;QAC9I,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAChC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,EAAE;YAAE,MAAM,IAAI,eAAe,CAAC,4CAA4C,CAAC,CAAC;QAE1G,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,EAAE,EAAE,GAAG,WAAW,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;QACjF,IAAI,MAAM,KAAK,YAAY;YAAE,MAAM,IAAI,eAAe,CAAC,qCAAqC,CAAC,CAAC;QAC9F,MAAM,gBAAgB,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAC;QAC/C,GAAG,CAAC,gBAAgB,QAAQ,CAAC,IAAI,GAAG,CAAC,CAAC;IACxC,CAAC;YAAS,CAAC;QACT,MAAM,QAAQ,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/** A refusal by the OAuth network policy. The message is safe to show: it never carries a secret. */
|
|
2
|
+
export declare class OAuthPolicyError extends Error {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
}
|
|
5
|
+
/** Longest URL accepted from any metadata document. */
|
|
6
|
+
export declare const MAX_OAUTH_URL_LENGTH = 2048;
|
|
7
|
+
/** Largest response body any OAuth request may return. */
|
|
8
|
+
export declare const MAX_OAUTH_RESPONSE_BYTES: number;
|
|
9
|
+
/** Per-request ceiling, connect through last byte. */
|
|
10
|
+
export declare const OAUTH_REQUEST_TIMEOUT_MS = 15000;
|
|
11
|
+
/**
|
|
12
|
+
* Whether an address is anything but a globally routable unicast one: loopback, private,
|
|
13
|
+
* link-local (cloud metadata lives at 169.254.169.254), CGNAT, multicast, reserved,
|
|
14
|
+
* unspecified — and IPv4-mapped / NAT64 IPv6 forms of those. Unparseable text counts as
|
|
15
|
+
* non-public: the safe direction.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isNonPublicAddress(address: string): boolean;
|
|
18
|
+
/** `localhost`, `*.localhost`, or a loopback literal. */
|
|
19
|
+
export declare function isLoopbackHost(hostname: string): boolean;
|
|
20
|
+
/** A host that is `localhost` or an IP literal in a non-public range: a local/private MCP server. */
|
|
21
|
+
export declare function isPrivateLiteralHost(hostname: string): boolean;
|
|
22
|
+
export interface OAuthUrlContext {
|
|
23
|
+
/** Whether loopback / private destinations are acceptable (a local MCP server, or user opt-in). */
|
|
24
|
+
readonly allowPrivate: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Parses and vets one URL that discovery, configuration or a redirect produced. Returns the parsed
|
|
28
|
+
* URL, or throws {@link OAuthPolicyError} naming `what` and the rule — never the URL's query.
|
|
29
|
+
*/
|
|
30
|
+
export declare function validateOAuthUrl(raw: string | URL, what: string, context: OAuthUrlContext): URL;
|
|
31
|
+
type FetchLike = (url: string | URL, init?: RequestInit) => Promise<Response>;
|
|
32
|
+
export interface GuardedFetchOptions extends OAuthUrlContext {
|
|
33
|
+
readonly signal?: AbortSignal;
|
|
34
|
+
readonly timeoutMs?: number;
|
|
35
|
+
readonly maxBytes?: number;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* The SDK `FetchLike` for interactive login: every request URL is vetted by
|
|
39
|
+
* {@link validateOAuthUrl}, the socket's addresses are vetted again by the lookup hook, redirects
|
|
40
|
+
* are followed by hand (at most {@link MAX_REDIRECTS}, GET only, each hop re-vetted), and the
|
|
41
|
+
* response is bounded in size and time. It is the only fetch the login flow uses.
|
|
42
|
+
*/
|
|
43
|
+
export declare function createGuardedFetch(options: GuardedFetchOptions): FetchLike;
|
|
44
|
+
/**
|
|
45
|
+
* Resolves `hostname` and refuses when any address is non-public (unless private destinations are
|
|
46
|
+
* allowed). Used as a pre-flight on the runtime refresh path, where the SDK — not darwin — opens
|
|
47
|
+
* the socket, so the lookup hook above cannot see it.
|
|
48
|
+
*/
|
|
49
|
+
export declare function assertHostResolvesPublic(hostname: string, context: OAuthUrlContext): Promise<void>;
|
|
50
|
+
export {};
|