@mcp-use/client 2.0.0-beta.1 → 2.0.0-beta.11
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/.tsbuildinfo +1 -1
- package/dist/auth/browser.d.ts +8 -4
- package/dist/auth/browser.d.ts.map +1 -1
- package/dist/auth/session-store.d.ts +6 -1
- package/dist/auth/session-store.d.ts.map +1 -1
- package/dist/index-browser.d.ts +1 -1
- package/dist/index-browser.d.ts.map +1 -1
- package/dist/index-browser.js +139 -166
- package/dist/index-browser.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +65 -170
- package/dist/index.js.map +1 -1
- package/dist/react/index.js +406 -233
- package/dist/react/index.js.map +1 -1
- package/dist/react/types.d.ts +9 -3
- package/dist/react/types.d.ts.map +1 -1
- package/dist/react/useMcp-helpers.d.ts.map +1 -1
- package/dist/react/useMcp-operations.d.ts.map +1 -1
- package/dist/react/useMcp.d.ts.map +1 -1
- package/dist/react/view/ViewRenderer.d.ts +2 -1
- package/dist/react/view/ViewRenderer.d.ts.map +1 -1
- package/dist/react/view/inject-openai-file-apis.d.ts +6 -0
- package/dist/react/view/inject-openai-file-apis.d.ts.map +1 -0
- package/dist/react/view/types.d.ts +16 -0
- package/dist/react/view/types.d.ts.map +1 -1
- package/dist/react/view/use-display-mode.d.ts +1 -0
- package/dist/react/view/use-display-mode.d.ts.map +1 -1
- package/dist/telemetry/index.d.ts +1 -1
- package/dist/telemetry/index.d.ts.map +1 -1
- package/dist/telemetry/tel-fetch.d.ts +0 -6
- package/dist/telemetry/tel-fetch.d.ts.map +1 -1
- package/dist/telemetry/telemetry-node.d.ts.map +1 -1
- package/dist/telemetry/telemetry.d.ts +0 -8
- package/dist/telemetry/telemetry.d.ts.map +1 -1
- package/dist/transport/http.d.ts +6 -6
- package/package.json +2 -2
package/dist/auth/browser.d.ts
CHANGED
|
@@ -85,10 +85,12 @@ export declare class BrowserOAuthClientProvider implements OAuthClientProvider {
|
|
|
85
85
|
* therefore never alters fetch behavior for other servers, other
|
|
86
86
|
* connections, or the rest of the page.
|
|
87
87
|
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
88
|
+
* OAuth metadata is always fetched with `cache: "no-store"`, including in
|
|
89
|
+
* direct mode. Authorization servers commonly vary CORS headers by Origin;
|
|
90
|
+
* bypassing the browser HTTP cache prevents a revalidated response cached
|
|
91
|
+
* for another localhost origin from poisoning discovery. When OAuth proxying
|
|
92
|
+
* is disabled or no `oauthProxyUrl` is configured, all requests still go
|
|
93
|
+
* directly to their original URLs.
|
|
92
94
|
*
|
|
93
95
|
* @param baseFetch - The fetch used for non-OAuth requests and for the
|
|
94
96
|
* underlying proxy calls. Defaults to the global `fetch`.
|
|
@@ -116,6 +118,8 @@ export declare class BrowserOAuthClientProvider implements OAuthClientProvider {
|
|
|
116
118
|
* Returns `null` before a successful authorization discovery.
|
|
117
119
|
*/
|
|
118
120
|
getTokenEndpoint(): Promise<string | null>;
|
|
121
|
+
/** Return the protected-resource URL selected during OAuth discovery. */
|
|
122
|
+
getResource(): Promise<string | null>;
|
|
119
123
|
/**
|
|
120
124
|
* Return the stored public OAuth client ID. Browser providers do not retain
|
|
121
125
|
* client secrets.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/auth/browser.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,sBAAsB,EACtB,6BAA6B,EAC7B,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACnB,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAiBtC,6EAA6E;AAC7E,MAAM,WAAW,mBAAmB;IAClC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CA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,IAAI,CAAC;IAqDnE;;OAEG;IACH,uBAAuB,IAAI,MAAM,GAAG,IAAI;IAiCxC,YAAY,IAAI,MAAM;CAqCvB;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,mBAAwB,GAChC,OAAO,CAAC,mBAAmB,CAAC,CAE9B;AAED,YAAY,EAAE,mBAAmB,IAAI,oBAAoB,EAAE,CAAC"}
|
|
@@ -86,7 +86,7 @@ export declare class OAuthSessionStore {
|
|
|
86
86
|
saveClientInformation(clientInformation: OAuthClientInformation, ctx?: OAuthClientInformationContext): Promise<void>;
|
|
87
87
|
saveCodeVerifier(codeVerifier: string): Promise<void>;
|
|
88
88
|
codeVerifier(): Promise<string>;
|
|
89
|
-
invalidateCredentials(scope: "all" | "client" | "tokens" | "verifier" | "discovery"): Promise<void>;
|
|
89
|
+
invalidateCredentials(scope: "all" | "registration" | "client" | "tokens" | "verifier" | "discovery"): Promise<void>;
|
|
90
90
|
/**
|
|
91
91
|
* Persist the OAuth discovery state (authorization-server metadata resolved
|
|
92
92
|
* during the auth flow). Stored with the same durability as the code
|
|
@@ -109,6 +109,11 @@ export declare class OAuthSessionStore {
|
|
|
109
109
|
* persists this state during `auth()`, avoiding a second discovery flow.
|
|
110
110
|
*/
|
|
111
111
|
getTokenEndpoint(): Promise<string | null>;
|
|
112
|
+
/**
|
|
113
|
+
* Return the protected-resource URL selected during OAuth discovery.
|
|
114
|
+
* Consumers can persist it and reuse it for server-side refresh exchanges.
|
|
115
|
+
*/
|
|
116
|
+
getResource(): Promise<string | null>;
|
|
112
117
|
}
|
|
113
118
|
export {};
|
|
114
119
|
//# sourceMappingURL=session-store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-store.d.ts","sourceRoot":"","sources":["../../src/auth/session-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,sBAAsB,EACtB,6BAA6B,EAC7B,mBAAmB,EACnB,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KAAK,GACL,cAAc,GACd,QAAQ,GACR,QAAQ,GACR,UAAU,GACV,WAAW,GACd,OAAO,CAAC,IAAI,CAAC;IAoDhB;;;;;OAKG;IACG,kBAAkB,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAInE,mEAAmE;IAC7D,cAAc,IAAI,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC;IAahE;;;;;;OAMG;IACG,uBAAuB,CAC3B,gBAAgB,EAAE,GAAG,EACrB,IAAI,GAAE,8BAAmC,GACxC,OAAO,CAAC,MAAM,CAAC;IAqClB;;;OAGG;IACG,gBAAgB,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAOhD;;;OAGG;IACG,WAAW,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAI5C"}
|
package/dist/index-browser.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export * from "./transport/http.js";
|
|
|
19
19
|
export * from "./utils/json-schema-validator.js";
|
|
20
20
|
export { logger } from "./utils/logging.js";
|
|
21
21
|
export { Tel, Telemetry, setTelemetrySource, setProductVersion, } from "./telemetry/telemetry-browser.js";
|
|
22
|
-
export { telFetch, capturePostHog,
|
|
22
|
+
export { telFetch, capturePostHog, POSTHOG_HOST, POSTHOG_API_KEY, } from "./telemetry/tel-fetch.js";
|
|
23
23
|
export { getPackageVersion, VERSION } from "./utils/version.js";
|
|
24
24
|
export { detectFavicon } from "./utils/favicon.js";
|
|
25
25
|
//# sourceMappingURL=index-browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-browser.d.ts","sourceRoot":"","sources":["../src/index-browser.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,kCAAkC,CAAC;AAE1C,OAAO,EACL,mBAAmB,EACnB,KAAK,oBAAoB,GAC1B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,0BAA0B,EAC1B,KAAK,mBAAmB,GACzB,MAA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Ac,kCAAkC,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EACL,GAAG,EACH,SAAS,EACT,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,eAAe,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index-browser.js
CHANGED
|
@@ -128,7 +128,7 @@ var Logger = class {
|
|
|
128
128
|
var logger = Logger.get();
|
|
129
129
|
|
|
130
130
|
// src/utils/version.ts
|
|
131
|
-
var VERSION = "2.0.0-beta.
|
|
131
|
+
var VERSION = "2.0.0-beta.10";
|
|
132
132
|
function getPackageVersion() {
|
|
133
133
|
return VERSION;
|
|
134
134
|
}
|
|
@@ -265,62 +265,6 @@ async function telFetch(url, init) {
|
|
|
265
265
|
}
|
|
266
266
|
var POSTHOG_HOST = "https://eu.i.posthog.com";
|
|
267
267
|
var POSTHOG_API_KEY = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";
|
|
268
|
-
var SCARF_GATEWAY_URL = "https://mcpuse.gateway.scarf.sh/events-ts";
|
|
269
|
-
var SCARF_GATEWAY_BEACON_URL = "https://mcpuse.gateway.scarf.sh/simple/";
|
|
270
|
-
var SCARF_BEACON_MAX_URL = 1800;
|
|
271
|
-
var SCARF_BEACON_TRUNCATED_KEYS = /* @__PURE__ */ new Set(["query", "response", "messages"]);
|
|
272
|
-
function stringifyScarfValue(value) {
|
|
273
|
-
if (value === null || value === void 0) return "";
|
|
274
|
-
if (typeof value === "string") return value;
|
|
275
|
-
if (typeof value === "number" || typeof value === "boolean") {
|
|
276
|
-
return String(value);
|
|
277
|
-
}
|
|
278
|
-
try {
|
|
279
|
-
return JSON.stringify(value);
|
|
280
|
-
} catch {
|
|
281
|
-
return String(value);
|
|
282
|
-
}
|
|
283
|
-
}
|
|
284
|
-
function buildScarfBeaconUrl(properties, baseUrl = SCARF_GATEWAY_BEACON_URL) {
|
|
285
|
-
const params = new URLSearchParams();
|
|
286
|
-
for (const [key, value] of Object.entries(properties)) {
|
|
287
|
-
let serialized = stringifyScarfValue(value);
|
|
288
|
-
if (SCARF_BEACON_TRUNCATED_KEYS.has(key) && serialized.length > 120) {
|
|
289
|
-
serialized = `${serialized.slice(0, 117)}...`;
|
|
290
|
-
}
|
|
291
|
-
if (serialized !== "") params.set(key, serialized);
|
|
292
|
-
}
|
|
293
|
-
let url = `${baseUrl}${baseUrl.includes("?") ? "&" : "?"}${params.toString()}`;
|
|
294
|
-
if (url.length <= SCARF_BEACON_MAX_URL) return url;
|
|
295
|
-
const keys = [...params.keys()].sort(
|
|
296
|
-
(a, b) => (params.get(b)?.length ?? 0) - (params.get(a)?.length ?? 0)
|
|
297
|
-
);
|
|
298
|
-
for (const key of keys) {
|
|
299
|
-
if (url.length <= SCARF_BEACON_MAX_URL) break;
|
|
300
|
-
if (key === "event" || key === "user_id") continue;
|
|
301
|
-
params.delete(key);
|
|
302
|
-
url = `${baseUrl}${baseUrl.includes("?") ? "&" : "?"}${params.toString()}`;
|
|
303
|
-
}
|
|
304
|
-
return url.slice(0, SCARF_BEACON_MAX_URL);
|
|
305
|
-
}
|
|
306
|
-
function captureScarfPost(properties, endpoint) {
|
|
307
|
-
return telFetch(endpoint, {
|
|
308
|
-
method: "POST",
|
|
309
|
-
headers: { "Content-Type": "application/json" },
|
|
310
|
-
keepalive: true,
|
|
311
|
-
body: JSON.stringify(properties)
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
function captureScarfBeacon(properties, endpoint) {
|
|
315
|
-
try {
|
|
316
|
-
const url = buildScarfBeaconUrl(properties, endpoint);
|
|
317
|
-
const img = new Image();
|
|
318
|
-
img.referrerPolicy = "no-referrer-when-downgrade";
|
|
319
|
-
img.src = url;
|
|
320
|
-
} catch {
|
|
321
|
-
}
|
|
322
|
-
return Promise.resolve();
|
|
323
|
-
}
|
|
324
268
|
function capturePostHog(params) {
|
|
325
269
|
const host = params.host ?? POSTHOG_HOST;
|
|
326
270
|
const apiKey = params.apiKey ?? POSTHOG_API_KEY;
|
|
@@ -337,13 +281,6 @@ function capturePostHog(params) {
|
|
|
337
281
|
})
|
|
338
282
|
});
|
|
339
283
|
}
|
|
340
|
-
function captureScarf(properties, endpoint = SCARF_GATEWAY_URL) {
|
|
341
|
-
if (typeof window !== "undefined") {
|
|
342
|
-
const beaconEndpoint = endpoint === SCARF_GATEWAY_URL ? SCARF_GATEWAY_BEACON_URL : endpoint;
|
|
343
|
-
return captureScarfBeacon(properties, beaconEndpoint);
|
|
344
|
-
}
|
|
345
|
-
return captureScarfPost(properties, endpoint);
|
|
346
|
-
}
|
|
347
284
|
|
|
348
285
|
// src/telemetry/telemetry.ts
|
|
349
286
|
function generateUUID() {
|
|
@@ -354,18 +291,6 @@ function secureRandomString() {
|
|
|
354
291
|
globalThis.crypto.getRandomValues(array);
|
|
355
292
|
return Array.from(array, (v) => v.toString(16).padStart(2, "0")).join("");
|
|
356
293
|
}
|
|
357
|
-
function isVersionGreater(a, b) {
|
|
358
|
-
const parse = (v) => v.split("-")[0].split(".").map((n) => parseInt(n, 10) || 0);
|
|
359
|
-
const pa = parse(a);
|
|
360
|
-
const pb = parse(b);
|
|
361
|
-
const len = Math.max(pa.length, pb.length);
|
|
362
|
-
for (let i = 0; i < len; i++) {
|
|
363
|
-
const da = pa[i] ?? 0;
|
|
364
|
-
const db = pb[i] ?? 0;
|
|
365
|
-
if (da !== db) return da > db;
|
|
366
|
-
}
|
|
367
|
-
return false;
|
|
368
|
-
}
|
|
369
294
|
var USER_ID_STORAGE_KEY = "mcp_use_user_id";
|
|
370
295
|
var PROJECT_API_KEY = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";
|
|
371
296
|
var HOST = "https://eu.i.posthog.com";
|
|
@@ -394,10 +319,7 @@ function createLocalStorageBackend() {
|
|
|
394
319
|
localStorage.setItem(USER_ID_STORAGE_KEY, id);
|
|
395
320
|
} catch {
|
|
396
321
|
}
|
|
397
|
-
}
|
|
398
|
-
// Package-download dedup is node/Scarf-oriented; localStorage unused.
|
|
399
|
-
getDownloadedVersion: () => null,
|
|
400
|
-
setDownloadedVersion: () => void 0
|
|
322
|
+
}
|
|
401
323
|
};
|
|
402
324
|
}
|
|
403
325
|
function detectRuntimeEnvironment() {
|
|
@@ -465,17 +387,13 @@ var Telemetry = class _Telemetry {
|
|
|
465
387
|
_currUserId = null;
|
|
466
388
|
_telemetryEnabled = false;
|
|
467
389
|
_pending = /* @__PURE__ */ new Set();
|
|
468
|
-
_scarfEnabled = false;
|
|
469
390
|
_runtimeEnvironment;
|
|
470
391
|
_storageCapability;
|
|
471
392
|
_storage;
|
|
472
|
-
/** True when node entry installed fs storage (package-download dedup). */
|
|
473
|
-
_fsBacked;
|
|
474
393
|
_source;
|
|
475
394
|
_productVersion;
|
|
476
395
|
constructor() {
|
|
477
396
|
this._runtimeEnvironment = detectRuntimeEnvironment();
|
|
478
|
-
this._fsBacked = configuredStorage !== null;
|
|
479
397
|
this._storage = configuredStorage ?? createLocalStorageBackend() ?? null;
|
|
480
398
|
this._storageCapability = this._storage ? "persistent" : "session-only";
|
|
481
399
|
this._source = readSourceHint() || this._runtimeEnvironment;
|
|
@@ -494,14 +412,6 @@ var Telemetry = class _Telemetry {
|
|
|
494
412
|
"Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."
|
|
495
413
|
);
|
|
496
414
|
this._telemetryEnabled = true;
|
|
497
|
-
this._scarfEnabled = true;
|
|
498
|
-
if (this._fsBacked) {
|
|
499
|
-
setTimeout(() => {
|
|
500
|
-
this.trackPackageDownload({ triggered_by: "initialization" }).catch(
|
|
501
|
-
(e) => logger.debug(`Failed to track package download: ${e}`)
|
|
502
|
-
);
|
|
503
|
-
}, 0);
|
|
504
|
-
}
|
|
505
415
|
}
|
|
506
416
|
}
|
|
507
417
|
get runtimeEnvironment() {
|
|
@@ -533,7 +443,7 @@ var Telemetry = class _Telemetry {
|
|
|
533
443
|
this._productVersion = version;
|
|
534
444
|
}
|
|
535
445
|
get isEnabled() {
|
|
536
|
-
return this._telemetryEnabled
|
|
446
|
+
return this._telemetryEnabled;
|
|
537
447
|
}
|
|
538
448
|
get userId() {
|
|
539
449
|
if (this._currUserId) return this._currUserId;
|
|
@@ -556,7 +466,7 @@ var Telemetry = class _Telemetry {
|
|
|
556
466
|
return this._currUserId;
|
|
557
467
|
}
|
|
558
468
|
async capture(event) {
|
|
559
|
-
if (!this._telemetryEnabled
|
|
469
|
+
if (!this._telemetryEnabled) return;
|
|
560
470
|
const currentUserId = this.userId;
|
|
561
471
|
const properties = {
|
|
562
472
|
...event.properties,
|
|
@@ -565,52 +475,15 @@ var Telemetry = class _Telemetry {
|
|
|
565
475
|
source: this._source,
|
|
566
476
|
runtime: this._runtimeEnvironment
|
|
567
477
|
};
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
properties
|
|
575
|
-
});
|
|
576
|
-
this._pending.add(p);
|
|
577
|
-
void p.finally(() => this._pending.delete(p));
|
|
578
|
-
}
|
|
579
|
-
if (this._scarfEnabled) {
|
|
580
|
-
const p = captureScarf({
|
|
581
|
-
...properties,
|
|
582
|
-
user_id: currentUserId,
|
|
583
|
-
event: event.name
|
|
584
|
-
});
|
|
585
|
-
this._pending.add(p);
|
|
586
|
-
void p.finally(() => this._pending.delete(p));
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
async trackPackageDownload(properties) {
|
|
590
|
-
if (!this._scarfEnabled || !this._fsBacked || !this._storage) return;
|
|
591
|
-
const currentVersion = getPackageVersion();
|
|
592
|
-
const saved = this._storage.getDownloadedVersion();
|
|
593
|
-
let firstDownload = false;
|
|
594
|
-
let shouldTrack = false;
|
|
595
|
-
if (!saved) {
|
|
596
|
-
shouldTrack = true;
|
|
597
|
-
firstDownload = true;
|
|
598
|
-
this._storage.setDownloadedVersion(currentVersion);
|
|
599
|
-
} else if (isVersionGreater(currentVersion, saved)) {
|
|
600
|
-
shouldTrack = true;
|
|
601
|
-
this._storage.setDownloadedVersion(currentVersion);
|
|
602
|
-
}
|
|
603
|
-
if (!shouldTrack) return;
|
|
604
|
-
await captureScarf({
|
|
605
|
-
...properties || {},
|
|
606
|
-
mcp_use_version: currentVersion,
|
|
607
|
-
user_id: this.userId,
|
|
608
|
-
event: "package_download",
|
|
609
|
-
first_download: firstDownload,
|
|
610
|
-
language: "typescript",
|
|
611
|
-
source: this._source,
|
|
612
|
-
runtime: this._runtimeEnvironment
|
|
478
|
+
const p = capturePostHog({
|
|
479
|
+
host: HOST,
|
|
480
|
+
apiKey: PROJECT_API_KEY,
|
|
481
|
+
event: event.name,
|
|
482
|
+
distinctId: currentUserId,
|
|
483
|
+
properties
|
|
613
484
|
});
|
|
485
|
+
this._pending.add(p);
|
|
486
|
+
void p.finally(() => this._pending.delete(p));
|
|
614
487
|
}
|
|
615
488
|
async trackAgentExecution(data) {
|
|
616
489
|
if (!this.isEnabled) return;
|
|
@@ -868,29 +741,39 @@ var OAuthSessionStore = class _OAuthSessionStore {
|
|
|
868
741
|
if (ctx) await this.store.set(this.credentialKey("tokens"), serialized);
|
|
869
742
|
await this.store.remove(this.getKey("code_verifier"));
|
|
870
743
|
await this.store.remove(this.getKey("last_auth_url"));
|
|
744
|
+
await this.store.remove(this.getKey("last_auth_callback_url"));
|
|
871
745
|
}
|
|
872
746
|
async clientInformation(ctx) {
|
|
747
|
+
if (!this.allowClientSecret) {
|
|
748
|
+
const registeredRedirectUri = await this.store.get(
|
|
749
|
+
this.getKey("client_info_redirect_uri")
|
|
750
|
+
);
|
|
751
|
+
if (registeredRedirectUri !== this.redirectUrl) {
|
|
752
|
+
await this.invalidateCredentials("registration");
|
|
753
|
+
console.info(
|
|
754
|
+
`[${this.storageKeyPrefix}] Re-registering browser OAuth client after its Inspector callback changed or could not be verified.`
|
|
755
|
+
);
|
|
756
|
+
return void 0;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
873
759
|
const stored = await this.readCredential("client_info", ctx);
|
|
874
760
|
if (!stored) return void 0;
|
|
875
761
|
const { key, value: clientInfo } = stored;
|
|
876
762
|
try {
|
|
877
763
|
if (!this.allowClientSecret && clientInfo.client_secret) {
|
|
878
|
-
await this.
|
|
879
|
-
if (ctx) await this.store.remove(this.credentialKey("client_info"));
|
|
764
|
+
await this.invalidateCredentials("registration");
|
|
880
765
|
console.warn(
|
|
881
|
-
`[${this.storageKeyPrefix}]
|
|
766
|
+
`[${this.storageKeyPrefix}] Recovered stale browser OAuth credentials containing a client_secret.`
|
|
882
767
|
);
|
|
883
768
|
return void 0;
|
|
884
769
|
}
|
|
885
770
|
const storedRedirectUris = Array.isArray(clientInfo.redirect_uris) ? clientInfo.redirect_uris : [];
|
|
886
|
-
const hasMatchingRedirect = storedRedirectUris.length === 0 || storedRedirectUris.includes(this.redirectUrl);
|
|
771
|
+
const hasMatchingRedirect = storedRedirectUris.length === 0 && this.allowClientSecret || storedRedirectUris.includes(this.redirectUrl);
|
|
887
772
|
if (!hasMatchingRedirect) {
|
|
888
773
|
console.info(
|
|
889
|
-
`[${this.storageKeyPrefix}]
|
|
774
|
+
`[${this.storageKeyPrefix}] Recovering cached OAuth credentials after a redirect URI change.`
|
|
890
775
|
);
|
|
891
|
-
await this.
|
|
892
|
-
await this.store.remove(this.credentialKey("tokens", ctx));
|
|
893
|
-
await this.store.remove(this.getKey("last_auth_url"));
|
|
776
|
+
await this.invalidateCredentials("registration");
|
|
894
777
|
return void 0;
|
|
895
778
|
}
|
|
896
779
|
return clientInfo;
|
|
@@ -908,11 +791,20 @@ var OAuthSessionStore = class _OAuthSessionStore {
|
|
|
908
791
|
"Browser OAuth clients must be public clients; client_secret persistence is not allowed."
|
|
909
792
|
);
|
|
910
793
|
}
|
|
911
|
-
const
|
|
794
|
+
const persistedClientInformation = !this.allowClientSecret && (!("redirect_uris" in clientInformation) || !Array.isArray(
|
|
795
|
+
clientInformation.redirect_uris
|
|
796
|
+
) || clientInformation.redirect_uris.length === 0) ? { ...clientInformation, redirect_uris: [this.redirectUrl] } : clientInformation;
|
|
797
|
+
const serialized = JSON.stringify(persistedClientInformation);
|
|
912
798
|
await this.store.set(this.credentialKey("client_info", ctx), serialized);
|
|
913
799
|
if (ctx) {
|
|
914
800
|
await this.store.set(this.credentialKey("client_info"), serialized);
|
|
915
801
|
}
|
|
802
|
+
if (!this.allowClientSecret) {
|
|
803
|
+
await this.store.set(
|
|
804
|
+
this.getKey("client_info_redirect_uri"),
|
|
805
|
+
this.redirectUrl
|
|
806
|
+
);
|
|
807
|
+
}
|
|
916
808
|
}
|
|
917
809
|
async saveCodeVerifier(codeVerifier) {
|
|
918
810
|
await this.store.set(this.getKey("code_verifier"), codeVerifier);
|
|
@@ -937,11 +829,22 @@ var OAuthSessionStore = class _OAuthSessionStore {
|
|
|
937
829
|
}
|
|
938
830
|
};
|
|
939
831
|
switch (scope) {
|
|
832
|
+
case "registration":
|
|
833
|
+
await removeCredentialKeys("tokens");
|
|
834
|
+
await removeCredentialKeys("client_info");
|
|
835
|
+
await this.store.remove(this.getKey("code_verifier"));
|
|
836
|
+
await this.store.remove(this.getKey("last_auth_url"));
|
|
837
|
+
await this.store.remove(this.getKey("last_auth_callback_url"));
|
|
838
|
+
await this.store.remove(this.getKey("client_info_redirect_uri"));
|
|
839
|
+
await this.store.remove(this.getKey("token_endpoint"));
|
|
840
|
+
break;
|
|
940
841
|
case "all":
|
|
941
842
|
await removeCredentialKeys("tokens");
|
|
942
843
|
await removeCredentialKeys("client_info");
|
|
943
844
|
await this.store.remove(this.getKey("code_verifier"));
|
|
944
845
|
await this.store.remove(this.getKey("last_auth_url"));
|
|
846
|
+
await this.store.remove(this.getKey("last_auth_callback_url"));
|
|
847
|
+
await this.store.remove(this.getKey("client_info_redirect_uri"));
|
|
945
848
|
await this.store.remove(this.getKey("discovery_state"));
|
|
946
849
|
await this.store.remove(this.getKey("token_endpoint"));
|
|
947
850
|
break;
|
|
@@ -1011,6 +914,10 @@ var OAuthSessionStore = class _OAuthSessionStore {
|
|
|
1011
914
|
authorizationUrl.searchParams.set("state", state);
|
|
1012
915
|
const sanitizedAuthUrl = sanitizeUrl(authorizationUrl.toString());
|
|
1013
916
|
await this.store.set(stateKey, JSON.stringify(stateData));
|
|
917
|
+
await this.store.set(
|
|
918
|
+
this.getKey("last_auth_callback_url"),
|
|
919
|
+
this.redirectUrl
|
|
920
|
+
);
|
|
1014
921
|
await this.store.set(this.getKey("last_auth_url"), sanitizedAuthUrl);
|
|
1015
922
|
return sanitizedAuthUrl;
|
|
1016
923
|
}
|
|
@@ -1021,6 +928,14 @@ var OAuthSessionStore = class _OAuthSessionStore {
|
|
|
1021
928
|
async getTokenEndpoint() {
|
|
1022
929
|
return (await this.discoveryState())?.authorizationServerMetadata?.token_endpoint ?? null;
|
|
1023
930
|
}
|
|
931
|
+
/**
|
|
932
|
+
* Return the protected-resource URL selected during OAuth discovery.
|
|
933
|
+
* Consumers can persist it and reuse it for server-side refresh exchanges.
|
|
934
|
+
*/
|
|
935
|
+
async getResource() {
|
|
936
|
+
const resource = (await this.discoveryState())?.resourceMetadata?.resource;
|
|
937
|
+
return typeof resource === "string" ? resource : null;
|
|
938
|
+
}
|
|
1024
939
|
};
|
|
1025
940
|
|
|
1026
941
|
// src/auth/browser.ts
|
|
@@ -1138,20 +1053,19 @@ var BrowserOAuthClientProvider = class {
|
|
|
1138
1053
|
* therefore never alters fetch behavior for other servers, other
|
|
1139
1054
|
* connections, or the rest of the page.
|
|
1140
1055
|
*
|
|
1141
|
-
*
|
|
1142
|
-
*
|
|
1143
|
-
*
|
|
1144
|
-
*
|
|
1056
|
+
* OAuth metadata is always fetched with `cache: "no-store"`, including in
|
|
1057
|
+
* direct mode. Authorization servers commonly vary CORS headers by Origin;
|
|
1058
|
+
* bypassing the browser HTTP cache prevents a revalidated response cached
|
|
1059
|
+
* for another localhost origin from poisoning discovery. When OAuth proxying
|
|
1060
|
+
* is disabled or no `oauthProxyUrl` is configured, all requests still go
|
|
1061
|
+
* directly to their original URLs.
|
|
1145
1062
|
*
|
|
1146
1063
|
* @param baseFetch - The fetch used for non-OAuth requests and for the
|
|
1147
1064
|
* underlying proxy calls. Defaults to the global `fetch`.
|
|
1148
1065
|
*/
|
|
1149
1066
|
getProxyFetch(baseFetch) {
|
|
1150
|
-
if (!this.proxyOAuthRequests || !this.oauthProxyUrl) {
|
|
1151
|
-
return baseFetch;
|
|
1152
|
-
}
|
|
1153
1067
|
const base = baseFetch ?? globalThis.fetch.bind(globalThis);
|
|
1154
|
-
const oauthProxyUrl = this.oauthProxyUrl;
|
|
1068
|
+
const oauthProxyUrl = this.proxyOAuthRequests && this.oauthProxyUrl ? this.oauthProxyUrl : void 0;
|
|
1155
1069
|
const discoveredEndpoints = /* @__PURE__ */ new Set();
|
|
1156
1070
|
let restoredDiscovery = false;
|
|
1157
1071
|
return async (input, init) => {
|
|
@@ -1164,6 +1078,12 @@ var BrowserOAuthClientProvider = class {
|
|
|
1164
1078
|
return await base(input, init);
|
|
1165
1079
|
}
|
|
1166
1080
|
const isMetadata = pathname.includes("/.well-known/");
|
|
1081
|
+
if (!oauthProxyUrl) {
|
|
1082
|
+
return await base(
|
|
1083
|
+
isMetadata ? url : input,
|
|
1084
|
+
isMetadata ? { ...init, cache: "no-store" } : init
|
|
1085
|
+
);
|
|
1086
|
+
}
|
|
1167
1087
|
if (!restoredDiscovery) {
|
|
1168
1088
|
restoredDiscovery = true;
|
|
1169
1089
|
const metadata = (await this.discoveryState())?.authorizationServerMetadata;
|
|
@@ -1198,7 +1118,8 @@ var BrowserOAuthClientProvider = class {
|
|
|
1198
1118
|
if (isMetadata) {
|
|
1199
1119
|
const response2 = await base(proxyEndpoint, {
|
|
1200
1120
|
...init,
|
|
1201
|
-
method: "GET"
|
|
1121
|
+
method: "GET",
|
|
1122
|
+
cache: "no-store"
|
|
1202
1123
|
});
|
|
1203
1124
|
try {
|
|
1204
1125
|
const metadata = await response2.clone().json();
|
|
@@ -1216,23 +1137,40 @@ var BrowserOAuthClientProvider = class {
|
|
|
1216
1137
|
}
|
|
1217
1138
|
return response2;
|
|
1218
1139
|
}
|
|
1219
|
-
const
|
|
1140
|
+
const inputRequest = input instanceof Request ? input : void 0;
|
|
1141
|
+
const method = init?.method ?? inputRequest?.method ?? "POST";
|
|
1142
|
+
const requestHeaders = init?.headers ?? inputRequest?.headers;
|
|
1143
|
+
let body;
|
|
1144
|
+
if (init?.body !== void 0 && init.body !== null) {
|
|
1145
|
+
body = await serializeBody(init.body);
|
|
1146
|
+
} else if (inputRequest?.body && method !== "GET" && method !== "HEAD") {
|
|
1147
|
+
body = await inputRequest.clone().text();
|
|
1148
|
+
}
|
|
1220
1149
|
const response = await base(proxyEndpoint, {
|
|
1221
1150
|
method: "POST",
|
|
1222
1151
|
headers: { "Content-Type": "application/json" },
|
|
1223
1152
|
body: JSON.stringify({
|
|
1224
1153
|
serverUrl: this.serverUrl,
|
|
1225
1154
|
url,
|
|
1226
|
-
method
|
|
1227
|
-
headers:
|
|
1155
|
+
method,
|
|
1156
|
+
headers: requestHeaders ? Object.fromEntries(new Headers(requestHeaders)) : {},
|
|
1228
1157
|
body
|
|
1229
1158
|
})
|
|
1230
1159
|
});
|
|
1231
1160
|
const data = await response.json();
|
|
1161
|
+
if (!response.ok || typeof data.status !== "number") {
|
|
1162
|
+
return new Response(JSON.stringify(data), {
|
|
1163
|
+
status: response.status,
|
|
1164
|
+
statusText: response.statusText,
|
|
1165
|
+
headers: response.headers
|
|
1166
|
+
});
|
|
1167
|
+
}
|
|
1232
1168
|
return new Response(JSON.stringify(data.body), {
|
|
1233
1169
|
status: data.status,
|
|
1234
|
-
statusText: data.statusText,
|
|
1235
|
-
headers: new Headers(
|
|
1170
|
+
statusText: typeof data.statusText === "string" ? data.statusText : void 0,
|
|
1171
|
+
headers: new Headers(
|
|
1172
|
+
data.headers && typeof data.headers === "object" ? data.headers : void 0
|
|
1173
|
+
)
|
|
1236
1174
|
});
|
|
1237
1175
|
};
|
|
1238
1176
|
}
|
|
@@ -1255,7 +1193,16 @@ var BrowserOAuthClientProvider = class {
|
|
|
1255
1193
|
}
|
|
1256
1194
|
async saveClientInformation(clientInformation, ctx) {
|
|
1257
1195
|
if (this.staticClientInfo) return;
|
|
1258
|
-
|
|
1196
|
+
const { client_secret: discardedClientSecret, ...publicClientInformation } = clientInformation;
|
|
1197
|
+
if (discardedClientSecret) {
|
|
1198
|
+
console.info(
|
|
1199
|
+
`[${this.storageKeyPrefix}] Discarded client_secret returned for a public browser OAuth client.`
|
|
1200
|
+
);
|
|
1201
|
+
}
|
|
1202
|
+
return this.session.saveClientInformation(
|
|
1203
|
+
publicClientInformation,
|
|
1204
|
+
ctx
|
|
1205
|
+
);
|
|
1259
1206
|
}
|
|
1260
1207
|
codeVerifier() {
|
|
1261
1208
|
return this.session.codeVerifier();
|
|
@@ -1285,6 +1232,10 @@ var BrowserOAuthClientProvider = class {
|
|
|
1285
1232
|
getTokenEndpoint() {
|
|
1286
1233
|
return this.session.getTokenEndpoint();
|
|
1287
1234
|
}
|
|
1235
|
+
/** Return the protected-resource URL selected during OAuth discovery. */
|
|
1236
|
+
getResource() {
|
|
1237
|
+
return this.session.getResource();
|
|
1238
|
+
}
|
|
1288
1239
|
/**
|
|
1289
1240
|
* Return the stored public OAuth client ID. Browser providers do not retain
|
|
1290
1241
|
* client secrets.
|
|
@@ -1363,7 +1314,31 @@ var BrowserOAuthClientProvider = class {
|
|
|
1363
1314
|
getLastAttemptedAuthUrl() {
|
|
1364
1315
|
const storedUrl = localStorage.getItem(this.getKey("last_auth_url"));
|
|
1365
1316
|
if (!storedUrl) return null;
|
|
1366
|
-
|
|
1317
|
+
const storedCallbackUrl = localStorage.getItem(
|
|
1318
|
+
this.getKey("last_auth_callback_url")
|
|
1319
|
+
);
|
|
1320
|
+
if (storedCallbackUrl !== this.callbackUrl) {
|
|
1321
|
+
console.info(
|
|
1322
|
+
`[${this.storageKeyPrefix}] Recovering stale OAuth state whose callback cannot be verified.`
|
|
1323
|
+
);
|
|
1324
|
+
this.clearStorage();
|
|
1325
|
+
return null;
|
|
1326
|
+
}
|
|
1327
|
+
const sanitized = sanitizeUrl(storedUrl);
|
|
1328
|
+
try {
|
|
1329
|
+
const redirectUri = new URL(sanitized).searchParams.get("redirect_uri");
|
|
1330
|
+
if (redirectUri && new URL(redirectUri).toString() !== new URL(this.callbackUrl).toString()) {
|
|
1331
|
+
console.info(
|
|
1332
|
+
`[${this.storageKeyPrefix}] Recovering stale OAuth state after the Inspector callback path changed.`
|
|
1333
|
+
);
|
|
1334
|
+
this.clearStorage();
|
|
1335
|
+
return null;
|
|
1336
|
+
}
|
|
1337
|
+
} catch {
|
|
1338
|
+
this.clearStorage();
|
|
1339
|
+
return null;
|
|
1340
|
+
}
|
|
1341
|
+
return sanitized;
|
|
1367
1342
|
}
|
|
1368
1343
|
clearStorage() {
|
|
1369
1344
|
const prefixPattern = `${this.storageKeyPrefix}_${this.serverUrlHash}_`;
|
|
@@ -4123,14 +4098,12 @@ export {
|
|
|
4123
4098
|
MCPConnection as MCPSession,
|
|
4124
4099
|
POSTHOG_API_KEY,
|
|
4125
4100
|
POSTHOG_HOST,
|
|
4126
|
-
SCARF_GATEWAY_URL,
|
|
4127
4101
|
Tel,
|
|
4128
4102
|
Telemetry,
|
|
4129
4103
|
UnauthorizedError3 as UnauthorizedError,
|
|
4130
4104
|
VERSION,
|
|
4131
4105
|
auth2 as auth,
|
|
4132
4106
|
capturePostHog,
|
|
4133
|
-
captureScarf,
|
|
4134
4107
|
completeOAuthFlow,
|
|
4135
4108
|
createConnectorFromConfig,
|
|
4136
4109
|
createOAuthProvider,
|