@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/index.d.ts
CHANGED
|
@@ -18,6 +18,6 @@ export * from "./transport/http.js";
|
|
|
18
18
|
export * from "./transport/stdio.js";
|
|
19
19
|
export * from "./utils/json-schema-validator.js";
|
|
20
20
|
export * from "./code-mode/connector.js";
|
|
21
|
-
export { setTelemetrySource, setProductVersion, Tel, Telemetry, telFetch, capturePostHog,
|
|
21
|
+
export { setTelemetrySource, setProductVersion, Tel, Telemetry, telFetch, capturePostHog, POSTHOG_HOST, POSTHOG_API_KEY, } from "./telemetry/index.js";
|
|
22
22
|
export { logger } from "./utils/logging.js";
|
|
23
23
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,+BAA+B,CAAC;AAEvC,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAGlC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,kCAAkC,CAAC;AAGjD,cAAc,0BAA0B,CAAC;AAGzC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,GAAG,EACH,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,+BAA+B,CAAC;AAEvC,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACvE,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACnE,OAAO,EACL,mBAAmB,EACnB,uBAAuB,EACvB,cAAc,EACd,KAAK,gBAAgB,EACrB,KAAK,oBAAoB,GAC1B,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,mBAAmB,CAAC;AAGlC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,sBAAsB,CAAC;AAGrC,cAAc,kCAAkC,CAAC;AAGjD,cAAc,0BAA0B,CAAC;AAGzC,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,GAAG,EACH,SAAS,EACT,QAAQ,EACR,cAAc,EACd,YAAY,EACZ,eAAe,GAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1108,7 +1108,7 @@ init_connector_telemetry();
|
|
|
1108
1108
|
init_logging();
|
|
1109
1109
|
|
|
1110
1110
|
// src/utils/version.ts
|
|
1111
|
-
var VERSION = "2.0.0-beta.
|
|
1111
|
+
var VERSION = "2.0.0-beta.10";
|
|
1112
1112
|
function getPackageVersion() {
|
|
1113
1113
|
return VERSION;
|
|
1114
1114
|
}
|
|
@@ -1245,62 +1245,6 @@ async function telFetch(url, init) {
|
|
|
1245
1245
|
}
|
|
1246
1246
|
var POSTHOG_HOST = "https://eu.i.posthog.com";
|
|
1247
1247
|
var POSTHOG_API_KEY = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";
|
|
1248
|
-
var SCARF_GATEWAY_URL = "https://mcpuse.gateway.scarf.sh/events-ts";
|
|
1249
|
-
var SCARF_GATEWAY_BEACON_URL = "https://mcpuse.gateway.scarf.sh/simple/";
|
|
1250
|
-
var SCARF_BEACON_MAX_URL = 1800;
|
|
1251
|
-
var SCARF_BEACON_TRUNCATED_KEYS = /* @__PURE__ */ new Set(["query", "response", "messages"]);
|
|
1252
|
-
function stringifyScarfValue(value) {
|
|
1253
|
-
if (value === null || value === void 0) return "";
|
|
1254
|
-
if (typeof value === "string") return value;
|
|
1255
|
-
if (typeof value === "number" || typeof value === "boolean") {
|
|
1256
|
-
return String(value);
|
|
1257
|
-
}
|
|
1258
|
-
try {
|
|
1259
|
-
return JSON.stringify(value);
|
|
1260
|
-
} catch {
|
|
1261
|
-
return String(value);
|
|
1262
|
-
}
|
|
1263
|
-
}
|
|
1264
|
-
function buildScarfBeaconUrl(properties, baseUrl = SCARF_GATEWAY_BEACON_URL) {
|
|
1265
|
-
const params = new URLSearchParams();
|
|
1266
|
-
for (const [key, value] of Object.entries(properties)) {
|
|
1267
|
-
let serialized = stringifyScarfValue(value);
|
|
1268
|
-
if (SCARF_BEACON_TRUNCATED_KEYS.has(key) && serialized.length > 120) {
|
|
1269
|
-
serialized = `${serialized.slice(0, 117)}...`;
|
|
1270
|
-
}
|
|
1271
|
-
if (serialized !== "") params.set(key, serialized);
|
|
1272
|
-
}
|
|
1273
|
-
let url = `${baseUrl}${baseUrl.includes("?") ? "&" : "?"}${params.toString()}`;
|
|
1274
|
-
if (url.length <= SCARF_BEACON_MAX_URL) return url;
|
|
1275
|
-
const keys = [...params.keys()].sort(
|
|
1276
|
-
(a, b) => (params.get(b)?.length ?? 0) - (params.get(a)?.length ?? 0)
|
|
1277
|
-
);
|
|
1278
|
-
for (const key of keys) {
|
|
1279
|
-
if (url.length <= SCARF_BEACON_MAX_URL) break;
|
|
1280
|
-
if (key === "event" || key === "user_id") continue;
|
|
1281
|
-
params.delete(key);
|
|
1282
|
-
url = `${baseUrl}${baseUrl.includes("?") ? "&" : "?"}${params.toString()}`;
|
|
1283
|
-
}
|
|
1284
|
-
return url.slice(0, SCARF_BEACON_MAX_URL);
|
|
1285
|
-
}
|
|
1286
|
-
function captureScarfPost(properties, endpoint) {
|
|
1287
|
-
return telFetch(endpoint, {
|
|
1288
|
-
method: "POST",
|
|
1289
|
-
headers: { "Content-Type": "application/json" },
|
|
1290
|
-
keepalive: true,
|
|
1291
|
-
body: JSON.stringify(properties)
|
|
1292
|
-
});
|
|
1293
|
-
}
|
|
1294
|
-
function captureScarfBeacon(properties, endpoint) {
|
|
1295
|
-
try {
|
|
1296
|
-
const url = buildScarfBeaconUrl(properties, endpoint);
|
|
1297
|
-
const img = new Image();
|
|
1298
|
-
img.referrerPolicy = "no-referrer-when-downgrade";
|
|
1299
|
-
img.src = url;
|
|
1300
|
-
} catch {
|
|
1301
|
-
}
|
|
1302
|
-
return Promise.resolve();
|
|
1303
|
-
}
|
|
1304
1248
|
function capturePostHog(params) {
|
|
1305
1249
|
const host = params.host ?? POSTHOG_HOST;
|
|
1306
1250
|
const apiKey = params.apiKey ?? POSTHOG_API_KEY;
|
|
@@ -1317,13 +1261,6 @@ function capturePostHog(params) {
|
|
|
1317
1261
|
})
|
|
1318
1262
|
});
|
|
1319
1263
|
}
|
|
1320
|
-
function captureScarf(properties, endpoint = SCARF_GATEWAY_URL) {
|
|
1321
|
-
if (typeof window !== "undefined") {
|
|
1322
|
-
const beaconEndpoint = endpoint === SCARF_GATEWAY_URL ? SCARF_GATEWAY_BEACON_URL : endpoint;
|
|
1323
|
-
return captureScarfBeacon(properties, beaconEndpoint);
|
|
1324
|
-
}
|
|
1325
|
-
return captureScarfPost(properties, endpoint);
|
|
1326
|
-
}
|
|
1327
1264
|
|
|
1328
1265
|
// src/telemetry/telemetry.ts
|
|
1329
1266
|
function generateUUID() {
|
|
@@ -1334,18 +1271,6 @@ function secureRandomString() {
|
|
|
1334
1271
|
globalThis.crypto.getRandomValues(array);
|
|
1335
1272
|
return Array.from(array, (v) => v.toString(16).padStart(2, "0")).join("");
|
|
1336
1273
|
}
|
|
1337
|
-
function isVersionGreater(a, b) {
|
|
1338
|
-
const parse = (v) => v.split("-")[0].split(".").map((n) => parseInt(n, 10) || 0);
|
|
1339
|
-
const pa = parse(a);
|
|
1340
|
-
const pb = parse(b);
|
|
1341
|
-
const len = Math.max(pa.length, pb.length);
|
|
1342
|
-
for (let i = 0; i < len; i++) {
|
|
1343
|
-
const da = pa[i] ?? 0;
|
|
1344
|
-
const db = pb[i] ?? 0;
|
|
1345
|
-
if (da !== db) return da > db;
|
|
1346
|
-
}
|
|
1347
|
-
return false;
|
|
1348
|
-
}
|
|
1349
1274
|
var USER_ID_STORAGE_KEY = "mcp_use_user_id";
|
|
1350
1275
|
var PROJECT_API_KEY = "phc_lyTtbYwvkdSbrcMQNPiKiiRWrrM1seyKIMjycSvItEI";
|
|
1351
1276
|
var HOST = "https://eu.i.posthog.com";
|
|
@@ -1377,10 +1302,7 @@ function createLocalStorageBackend() {
|
|
|
1377
1302
|
localStorage.setItem(USER_ID_STORAGE_KEY, id);
|
|
1378
1303
|
} catch {
|
|
1379
1304
|
}
|
|
1380
|
-
}
|
|
1381
|
-
// Package-download dedup is node/Scarf-oriented; localStorage unused.
|
|
1382
|
-
getDownloadedVersion: () => null,
|
|
1383
|
-
setDownloadedVersion: () => void 0
|
|
1305
|
+
}
|
|
1384
1306
|
};
|
|
1385
1307
|
}
|
|
1386
1308
|
function detectRuntimeEnvironment() {
|
|
@@ -1448,17 +1370,13 @@ var Telemetry = class _Telemetry {
|
|
|
1448
1370
|
_currUserId = null;
|
|
1449
1371
|
_telemetryEnabled = false;
|
|
1450
1372
|
_pending = /* @__PURE__ */ new Set();
|
|
1451
|
-
_scarfEnabled = false;
|
|
1452
1373
|
_runtimeEnvironment;
|
|
1453
1374
|
_storageCapability;
|
|
1454
1375
|
_storage;
|
|
1455
|
-
/** True when node entry installed fs storage (package-download dedup). */
|
|
1456
|
-
_fsBacked;
|
|
1457
1376
|
_source;
|
|
1458
1377
|
_productVersion;
|
|
1459
1378
|
constructor() {
|
|
1460
1379
|
this._runtimeEnvironment = detectRuntimeEnvironment();
|
|
1461
|
-
this._fsBacked = configuredStorage !== null;
|
|
1462
1380
|
this._storage = configuredStorage ?? createLocalStorageBackend() ?? null;
|
|
1463
1381
|
this._storageCapability = this._storage ? "persistent" : "session-only";
|
|
1464
1382
|
this._source = readSourceHint() || this._runtimeEnvironment;
|
|
@@ -1477,14 +1395,6 @@ var Telemetry = class _Telemetry {
|
|
|
1477
1395
|
"Anonymized telemetry enabled. Set MCP_USE_ANONYMIZED_TELEMETRY=false to disable."
|
|
1478
1396
|
);
|
|
1479
1397
|
this._telemetryEnabled = true;
|
|
1480
|
-
this._scarfEnabled = true;
|
|
1481
|
-
if (this._fsBacked) {
|
|
1482
|
-
setTimeout(() => {
|
|
1483
|
-
this.trackPackageDownload({ triggered_by: "initialization" }).catch(
|
|
1484
|
-
(e) => logger.debug(`Failed to track package download: ${e}`)
|
|
1485
|
-
);
|
|
1486
|
-
}, 0);
|
|
1487
|
-
}
|
|
1488
1398
|
}
|
|
1489
1399
|
}
|
|
1490
1400
|
get runtimeEnvironment() {
|
|
@@ -1516,7 +1426,7 @@ var Telemetry = class _Telemetry {
|
|
|
1516
1426
|
this._productVersion = version;
|
|
1517
1427
|
}
|
|
1518
1428
|
get isEnabled() {
|
|
1519
|
-
return this._telemetryEnabled
|
|
1429
|
+
return this._telemetryEnabled;
|
|
1520
1430
|
}
|
|
1521
1431
|
get userId() {
|
|
1522
1432
|
if (this._currUserId) return this._currUserId;
|
|
@@ -1539,7 +1449,7 @@ var Telemetry = class _Telemetry {
|
|
|
1539
1449
|
return this._currUserId;
|
|
1540
1450
|
}
|
|
1541
1451
|
async capture(event) {
|
|
1542
|
-
if (!this._telemetryEnabled
|
|
1452
|
+
if (!this._telemetryEnabled) return;
|
|
1543
1453
|
const currentUserId = this.userId;
|
|
1544
1454
|
const properties = {
|
|
1545
1455
|
...event.properties,
|
|
@@ -1548,52 +1458,15 @@ var Telemetry = class _Telemetry {
|
|
|
1548
1458
|
source: this._source,
|
|
1549
1459
|
runtime: this._runtimeEnvironment
|
|
1550
1460
|
};
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
properties
|
|
1558
|
-
});
|
|
1559
|
-
this._pending.add(p);
|
|
1560
|
-
void p.finally(() => this._pending.delete(p));
|
|
1561
|
-
}
|
|
1562
|
-
if (this._scarfEnabled) {
|
|
1563
|
-
const p = captureScarf({
|
|
1564
|
-
...properties,
|
|
1565
|
-
user_id: currentUserId,
|
|
1566
|
-
event: event.name
|
|
1567
|
-
});
|
|
1568
|
-
this._pending.add(p);
|
|
1569
|
-
void p.finally(() => this._pending.delete(p));
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
async trackPackageDownload(properties) {
|
|
1573
|
-
if (!this._scarfEnabled || !this._fsBacked || !this._storage) return;
|
|
1574
|
-
const currentVersion = getPackageVersion();
|
|
1575
|
-
const saved = this._storage.getDownloadedVersion();
|
|
1576
|
-
let firstDownload = false;
|
|
1577
|
-
let shouldTrack = false;
|
|
1578
|
-
if (!saved) {
|
|
1579
|
-
shouldTrack = true;
|
|
1580
|
-
firstDownload = true;
|
|
1581
|
-
this._storage.setDownloadedVersion(currentVersion);
|
|
1582
|
-
} else if (isVersionGreater(currentVersion, saved)) {
|
|
1583
|
-
shouldTrack = true;
|
|
1584
|
-
this._storage.setDownloadedVersion(currentVersion);
|
|
1585
|
-
}
|
|
1586
|
-
if (!shouldTrack) return;
|
|
1587
|
-
await captureScarf({
|
|
1588
|
-
...properties || {},
|
|
1589
|
-
mcp_use_version: currentVersion,
|
|
1590
|
-
user_id: this.userId,
|
|
1591
|
-
event: "package_download",
|
|
1592
|
-
first_download: firstDownload,
|
|
1593
|
-
language: "typescript",
|
|
1594
|
-
source: this._source,
|
|
1595
|
-
runtime: this._runtimeEnvironment
|
|
1461
|
+
const p = capturePostHog({
|
|
1462
|
+
host: HOST,
|
|
1463
|
+
apiKey: PROJECT_API_KEY,
|
|
1464
|
+
event: event.name,
|
|
1465
|
+
distinctId: currentUserId,
|
|
1466
|
+
properties
|
|
1596
1467
|
});
|
|
1468
|
+
this._pending.add(p);
|
|
1469
|
+
void p.finally(() => this._pending.delete(p));
|
|
1597
1470
|
}
|
|
1598
1471
|
async trackAgentExecution(data) {
|
|
1599
1472
|
if (!this.isEnabled) return;
|
|
@@ -1718,14 +1591,11 @@ function createFsStorage() {
|
|
|
1718
1591
|
} catch {
|
|
1719
1592
|
return {
|
|
1720
1593
|
getUserId: () => null,
|
|
1721
|
-
setUserId: () => void 0
|
|
1722
|
-
getDownloadedVersion: () => null,
|
|
1723
|
-
setDownloadedVersion: () => void 0
|
|
1594
|
+
setUserId: () => void 0
|
|
1724
1595
|
};
|
|
1725
1596
|
}
|
|
1726
1597
|
const cacheHome = getCacheHome(os, path2);
|
|
1727
1598
|
const userIdPath = path2.join(cacheHome, "mcp_use_3", "telemetry_user_id");
|
|
1728
|
-
const versionPath = path2.join(cacheHome, "mcp_use", "download_version");
|
|
1729
1599
|
return {
|
|
1730
1600
|
getUserId() {
|
|
1731
1601
|
try {
|
|
@@ -1741,21 +1611,6 @@ function createFsStorage() {
|
|
|
1741
1611
|
fs2.writeFileSync(userIdPath, id);
|
|
1742
1612
|
} catch {
|
|
1743
1613
|
}
|
|
1744
|
-
},
|
|
1745
|
-
getDownloadedVersion() {
|
|
1746
|
-
try {
|
|
1747
|
-
if (!fs2.existsSync(versionPath)) return null;
|
|
1748
|
-
return fs2.readFileSync(versionPath, "utf-8").trim() || null;
|
|
1749
|
-
} catch {
|
|
1750
|
-
return null;
|
|
1751
|
-
}
|
|
1752
|
-
},
|
|
1753
|
-
setDownloadedVersion(version) {
|
|
1754
|
-
try {
|
|
1755
|
-
fs2.mkdirSync(path2.dirname(versionPath), { recursive: true });
|
|
1756
|
-
fs2.writeFileSync(versionPath, version);
|
|
1757
|
-
} catch {
|
|
1758
|
-
}
|
|
1759
1614
|
}
|
|
1760
1615
|
};
|
|
1761
1616
|
}
|
|
@@ -2199,29 +2054,39 @@ var OAuthSessionStore = class _OAuthSessionStore {
|
|
|
2199
2054
|
if (ctx) await this.store.set(this.credentialKey("tokens"), serialized);
|
|
2200
2055
|
await this.store.remove(this.getKey("code_verifier"));
|
|
2201
2056
|
await this.store.remove(this.getKey("last_auth_url"));
|
|
2057
|
+
await this.store.remove(this.getKey("last_auth_callback_url"));
|
|
2202
2058
|
}
|
|
2203
2059
|
async clientInformation(ctx) {
|
|
2060
|
+
if (!this.allowClientSecret) {
|
|
2061
|
+
const registeredRedirectUri = await this.store.get(
|
|
2062
|
+
this.getKey("client_info_redirect_uri")
|
|
2063
|
+
);
|
|
2064
|
+
if (registeredRedirectUri !== this.redirectUrl) {
|
|
2065
|
+
await this.invalidateCredentials("registration");
|
|
2066
|
+
console.info(
|
|
2067
|
+
`[${this.storageKeyPrefix}] Re-registering browser OAuth client after its Inspector callback changed or could not be verified.`
|
|
2068
|
+
);
|
|
2069
|
+
return void 0;
|
|
2070
|
+
}
|
|
2071
|
+
}
|
|
2204
2072
|
const stored = await this.readCredential("client_info", ctx);
|
|
2205
2073
|
if (!stored) return void 0;
|
|
2206
2074
|
const { key, value: clientInfo } = stored;
|
|
2207
2075
|
try {
|
|
2208
2076
|
if (!this.allowClientSecret && clientInfo.client_secret) {
|
|
2209
|
-
await this.
|
|
2210
|
-
if (ctx) await this.store.remove(this.credentialKey("client_info"));
|
|
2077
|
+
await this.invalidateCredentials("registration");
|
|
2211
2078
|
console.warn(
|
|
2212
|
-
`[${this.storageKeyPrefix}]
|
|
2079
|
+
`[${this.storageKeyPrefix}] Recovered stale browser OAuth credentials containing a client_secret.`
|
|
2213
2080
|
);
|
|
2214
2081
|
return void 0;
|
|
2215
2082
|
}
|
|
2216
2083
|
const storedRedirectUris = Array.isArray(clientInfo.redirect_uris) ? clientInfo.redirect_uris : [];
|
|
2217
|
-
const hasMatchingRedirect = storedRedirectUris.length === 0 || storedRedirectUris.includes(this.redirectUrl);
|
|
2084
|
+
const hasMatchingRedirect = storedRedirectUris.length === 0 && this.allowClientSecret || storedRedirectUris.includes(this.redirectUrl);
|
|
2218
2085
|
if (!hasMatchingRedirect) {
|
|
2219
2086
|
console.info(
|
|
2220
|
-
`[${this.storageKeyPrefix}]
|
|
2087
|
+
`[${this.storageKeyPrefix}] Recovering cached OAuth credentials after a redirect URI change.`
|
|
2221
2088
|
);
|
|
2222
|
-
await this.
|
|
2223
|
-
await this.store.remove(this.credentialKey("tokens", ctx));
|
|
2224
|
-
await this.store.remove(this.getKey("last_auth_url"));
|
|
2089
|
+
await this.invalidateCredentials("registration");
|
|
2225
2090
|
return void 0;
|
|
2226
2091
|
}
|
|
2227
2092
|
return clientInfo;
|
|
@@ -2239,11 +2104,20 @@ var OAuthSessionStore = class _OAuthSessionStore {
|
|
|
2239
2104
|
"Browser OAuth clients must be public clients; client_secret persistence is not allowed."
|
|
2240
2105
|
);
|
|
2241
2106
|
}
|
|
2242
|
-
const
|
|
2107
|
+
const persistedClientInformation = !this.allowClientSecret && (!("redirect_uris" in clientInformation) || !Array.isArray(
|
|
2108
|
+
clientInformation.redirect_uris
|
|
2109
|
+
) || clientInformation.redirect_uris.length === 0) ? { ...clientInformation, redirect_uris: [this.redirectUrl] } : clientInformation;
|
|
2110
|
+
const serialized = JSON.stringify(persistedClientInformation);
|
|
2243
2111
|
await this.store.set(this.credentialKey("client_info", ctx), serialized);
|
|
2244
2112
|
if (ctx) {
|
|
2245
2113
|
await this.store.set(this.credentialKey("client_info"), serialized);
|
|
2246
2114
|
}
|
|
2115
|
+
if (!this.allowClientSecret) {
|
|
2116
|
+
await this.store.set(
|
|
2117
|
+
this.getKey("client_info_redirect_uri"),
|
|
2118
|
+
this.redirectUrl
|
|
2119
|
+
);
|
|
2120
|
+
}
|
|
2247
2121
|
}
|
|
2248
2122
|
async saveCodeVerifier(codeVerifier) {
|
|
2249
2123
|
await this.store.set(this.getKey("code_verifier"), codeVerifier);
|
|
@@ -2268,11 +2142,22 @@ var OAuthSessionStore = class _OAuthSessionStore {
|
|
|
2268
2142
|
}
|
|
2269
2143
|
};
|
|
2270
2144
|
switch (scope) {
|
|
2145
|
+
case "registration":
|
|
2146
|
+
await removeCredentialKeys("tokens");
|
|
2147
|
+
await removeCredentialKeys("client_info");
|
|
2148
|
+
await this.store.remove(this.getKey("code_verifier"));
|
|
2149
|
+
await this.store.remove(this.getKey("last_auth_url"));
|
|
2150
|
+
await this.store.remove(this.getKey("last_auth_callback_url"));
|
|
2151
|
+
await this.store.remove(this.getKey("client_info_redirect_uri"));
|
|
2152
|
+
await this.store.remove(this.getKey("token_endpoint"));
|
|
2153
|
+
break;
|
|
2271
2154
|
case "all":
|
|
2272
2155
|
await removeCredentialKeys("tokens");
|
|
2273
2156
|
await removeCredentialKeys("client_info");
|
|
2274
2157
|
await this.store.remove(this.getKey("code_verifier"));
|
|
2275
2158
|
await this.store.remove(this.getKey("last_auth_url"));
|
|
2159
|
+
await this.store.remove(this.getKey("last_auth_callback_url"));
|
|
2160
|
+
await this.store.remove(this.getKey("client_info_redirect_uri"));
|
|
2276
2161
|
await this.store.remove(this.getKey("discovery_state"));
|
|
2277
2162
|
await this.store.remove(this.getKey("token_endpoint"));
|
|
2278
2163
|
break;
|
|
@@ -2342,6 +2227,10 @@ var OAuthSessionStore = class _OAuthSessionStore {
|
|
|
2342
2227
|
authorizationUrl.searchParams.set("state", state);
|
|
2343
2228
|
const sanitizedAuthUrl = sanitizeUrl(authorizationUrl.toString());
|
|
2344
2229
|
await this.store.set(stateKey, JSON.stringify(stateData));
|
|
2230
|
+
await this.store.set(
|
|
2231
|
+
this.getKey("last_auth_callback_url"),
|
|
2232
|
+
this.redirectUrl
|
|
2233
|
+
);
|
|
2345
2234
|
await this.store.set(this.getKey("last_auth_url"), sanitizedAuthUrl);
|
|
2346
2235
|
return sanitizedAuthUrl;
|
|
2347
2236
|
}
|
|
@@ -2352,6 +2241,14 @@ var OAuthSessionStore = class _OAuthSessionStore {
|
|
|
2352
2241
|
async getTokenEndpoint() {
|
|
2353
2242
|
return (await this.discoveryState())?.authorizationServerMetadata?.token_endpoint ?? null;
|
|
2354
2243
|
}
|
|
2244
|
+
/**
|
|
2245
|
+
* Return the protected-resource URL selected during OAuth discovery.
|
|
2246
|
+
* Consumers can persist it and reuse it for server-side refresh exchanges.
|
|
2247
|
+
*/
|
|
2248
|
+
async getResource() {
|
|
2249
|
+
const resource = (await this.discoveryState())?.resourceMetadata?.resource;
|
|
2250
|
+
return typeof resource === "string" ? resource : null;
|
|
2251
|
+
}
|
|
2355
2252
|
};
|
|
2356
2253
|
|
|
2357
2254
|
// src/auth/node.ts
|
|
@@ -4327,7 +4224,7 @@ var E2BCodeExecutor = class extends BaseCodeExecutor {
|
|
|
4327
4224
|
this.SandboxClass = e2b.Sandbox;
|
|
4328
4225
|
} catch (error) {
|
|
4329
4226
|
throw new Error(
|
|
4330
|
-
"@e2b/code-interpreter is not installed. The E2B code executor requires this optional dependency. Install it with:
|
|
4227
|
+
"@e2b/code-interpreter is not installed. The E2B code executor requires this optional dependency. Install it with: npm install @e2b/code-interpreter, pnpm add @e2b/code-interpreter, or bun add @e2b/code-interpreter"
|
|
4331
4228
|
);
|
|
4332
4229
|
}
|
|
4333
4230
|
}
|
|
@@ -5563,7 +5460,6 @@ export {
|
|
|
5563
5460
|
OAuthFlowError,
|
|
5564
5461
|
POSTHOG_API_KEY,
|
|
5565
5462
|
POSTHOG_HOST,
|
|
5566
|
-
SCARF_GATEWAY_URL,
|
|
5567
5463
|
StdioConnectionManager,
|
|
5568
5464
|
StdioConnector,
|
|
5569
5465
|
Tel,
|
|
@@ -5576,7 +5472,6 @@ export {
|
|
|
5576
5472
|
auth2 as auth,
|
|
5577
5473
|
cancel,
|
|
5578
5474
|
capturePostHog,
|
|
5579
|
-
captureScarf,
|
|
5580
5475
|
completeOAuthFlow,
|
|
5581
5476
|
createConnectorFromConfig,
|
|
5582
5477
|
createOAuthProvider,
|