@google/gemini-cli 0.58.0-preview.0 → 0.59.0-nightly.20260827.g3c311beac
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/bundle/{chunk-WHCFVERV.js → chunk-3H74G2KH.js} +2 -2
- package/bundle/{chunk-JCGNL7TH.js → chunk-6OSDC4MV.js} +1 -1
- package/bundle/{chunk-6EGII27G.js → chunk-73ARSGJ5.js} +3 -3
- package/bundle/{chunk-OEY2TDVE.js → chunk-AAN2QRPE.js} +9 -8
- package/bundle/{chunk-RBQHWQSS.js → chunk-CGCFZQES.js} +1 -1
- package/bundle/{chunk-7HQEQECM.js → chunk-DGLYMH2T.js} +1 -1
- package/bundle/{chunk-GNLIR4RW.js → chunk-DQLD7SRF.js} +2 -2
- package/bundle/{chunk-2XOTT2FI.js → chunk-EHRHGSM5.js} +2 -2
- package/bundle/{chunk-CNAVMEMA.js → chunk-FDFJPHIC.js} +1 -1
- package/bundle/{chunk-2DH4DX65.js → chunk-FPLVZKRG.js} +1 -1
- package/bundle/{chunk-TYMOJXZO.js → chunk-GWEARCHO.js} +187 -48
- package/bundle/{chunk-JPMNKIVX.js → chunk-H7KEIAN2.js} +1 -1
- package/bundle/chunk-HYHVTGWR.js +512 -0
- package/bundle/chunk-ITFKYJXW.js +154 -0
- package/bundle/{chunk-FMLOQLUD.js → chunk-KS6XFVYS.js} +8 -5
- package/bundle/chunk-LVO7EBCZ.js +17332 -0
- package/bundle/{chunk-JO5YRKX4.js → chunk-MUOWXVE6.js} +7 -7
- package/bundle/{chunk-2BLMLPHM.js → chunk-O4XIHHTD.js} +1 -1
- package/bundle/{chunk-BOI2NL3I.js → chunk-O63N3LT7.js} +1 -1
- package/bundle/{chunk-M33HH4UA.js → chunk-ODUNYZB6.js} +7802 -14347
- package/bundle/{chunk-WE4JKUV6.js → chunk-OQVMARW3.js} +67 -54
- package/bundle/chunk-PUL47DYI.js +397876 -0
- package/bundle/{chunk-PGYTXBPD.js → chunk-S4W7SI4J.js} +3 -3
- package/bundle/chunk-U7KQWUOC.js +398 -0
- package/bundle/{chunk-4KFMA4KD.js → chunk-VCMGZEXX.js} +239 -48
- package/bundle/{chunk-FJTXPUG2.js → chunk-VF5Q6XU3.js} +1 -1
- package/bundle/{chunk-4FKXMALD.js → chunk-WLKCYQYS.js} +3 -3
- package/bundle/chunk-XZCFBDS3.js +118 -0
- package/bundle/{chunk-E7K62ODO.js → chunk-XZE7LM3J.js} +7 -7
- package/bundle/{chunk-PXFYRLFH.js → chunk-Y3UNBWYJ.js} +1 -1
- package/bundle/chunk-ZGYMSSP2.js +1571 -0
- package/bundle/chunk-ZZ3FVTFN.js +102506 -0
- package/bundle/{cleanup-KTXX3JEU.js → cleanup-7WNWQR7E.js} +2 -2
- package/bundle/{cleanup-NLNXSTS6.js → cleanup-HQZLY6HE.js} +2 -2
- package/bundle/{cleanup-RW3JYSTT.js → cleanup-SBV5JFL5.js} +2 -2
- package/bundle/cleanup-WWTWD4MN.js +32 -0
- package/bundle/{core-WFITWJMX.js → core-ON42NX7T.js} +7 -1
- package/bundle/{devtoolsService-BUAVSMN6.js → devtoolsService-CRNIBM2W.js} +2 -2
- package/bundle/{devtoolsService-P42LXPJX.js → devtoolsService-IU2PKUN3.js} +4 -3
- package/bundle/devtoolsService-NP7X7NHB.js +4359 -0
- package/bundle/{devtoolsService-MNBGW66M.js → devtoolsService-OXXEGIOW.js} +2 -2
- package/bundle/{dist-2CGQYGZC.js → dist-IVR5MNET.js} +7 -1
- package/bundle/{core-SU4ABXSV.js → dist-JOGPJW3K.js} +7 -1
- package/bundle/dist-ZNQBPG2J.js +2188 -0
- package/bundle/docs/changelogs/preview.md +30 -78
- package/bundle/{gemini-3PHRRMWS.js → gemini-2U2DKKTC.js} +14 -14
- package/bundle/{gemini-VIRT6VT3.js → gemini-4FNOTKMA.js} +214 -198
- package/bundle/{gemini-BUCCXM4N.js → gemini-7XLLDX3V.js} +14 -14
- package/bundle/gemini-ZVGS65WU.js +17337 -0
- package/bundle/gemini.js +7 -7
- package/bundle/{interactiveCli-N6VXS5Z4.js → interactiveCli-3LR2RUMG.js} +8 -8
- package/bundle/{interactiveCli-GGARXT6P.js → interactiveCli-6P6JTL7B.js} +8 -8
- package/bundle/{interactiveCli-BP2ZFGLX.js → interactiveCli-H7FAQ5H2.js} +315 -296
- package/bundle/interactiveCli-OGAWMEBW.js +34983 -0
- package/bundle/{liteRtServerManager-QUODN3RR.js → liteRtServerManager-ADZEETTJ.js} +4 -4
- package/bundle/{liteRtServerManager-YLOGF7RQ.js → liteRtServerManager-NRZL24G2.js} +4 -4
- package/bundle/{liteRtServerManager-L46MRFSW.js → liteRtServerManager-RIMFEC3W.js} +4 -4
- package/bundle/liteRtServerManager-VQ5WPOBH.js +65 -0
- package/bundle/{oauth2-provider-KVIL4ITH.js → oauth2-provider-3SYE4YDY.js} +1 -1
- package/bundle/{oauth2-provider-BKWSLZJ6.js → oauth2-provider-CHWWHQSU.js} +38 -72
- package/bundle/{oauth2-provider-IIC2YPC5.js → oauth2-provider-ERBITDXD.js} +1 -1
- package/bundle/oauth2-provider-XF5P7FXN.js +235 -0
- package/bundle/{start-VPQOFEIR.js → start-2HQ3RUXZ.js} +6 -6
- package/bundle/{start-Y7LKFE47.js → start-ALGR2CCO.js} +6 -6
- package/bundle/{start-2365H4YX.js → start-ESJMZM5I.js} +6 -6
- package/bundle/start-V5BFQKKK.js +18 -0
- package/package.json +1 -1
|
@@ -4767,11 +4767,11 @@ var require_suffix_array = __commonJS({
|
|
|
4767
4767
|
}
|
|
4768
4768
|
}
|
|
4769
4769
|
}
|
|
4770
|
-
function compare(string4,
|
|
4771
|
-
return string4[m] - string4[n3] || (m % 3 === 2 ? string4[m + 1] - string4[n3 + 1] ||
|
|
4770
|
+
function compare(string4, lookup3, m, n3) {
|
|
4771
|
+
return string4[m] - string4[n3] || (m % 3 === 2 ? string4[m + 1] - string4[n3 + 1] || lookup3[m + 2] - lookup3[n3 + 2] : lookup3[m + 1] - lookup3[n3 + 1]);
|
|
4772
4772
|
}
|
|
4773
4773
|
function build(string4, l2) {
|
|
4774
|
-
var a2 = [], b = [], al = 2 * l2 / 3 | 0, bl = l2 - al, r2 = al + 1 >> 1, i3 = al, j = 0, k,
|
|
4774
|
+
var a2 = [], b = [], al = 2 * l2 / 3 | 0, bl = l2 - al, r2 = al + 1 >> 1, i3 = al, j = 0, k, lookup3 = [], result2 = [];
|
|
4775
4775
|
if (l2 === 1)
|
|
4776
4776
|
return [0];
|
|
4777
4777
|
while (i3--)
|
|
@@ -4790,9 +4790,9 @@ var require_suffix_array = __commonJS({
|
|
|
4790
4790
|
a2[i3] = b[i3] < r2 ? b[i3] * 3 + 1 : (b[i3] - r2) * 3 + 2;
|
|
4791
4791
|
}
|
|
4792
4792
|
for (i3 = al; i3--; )
|
|
4793
|
-
|
|
4794
|
-
|
|
4795
|
-
|
|
4793
|
+
lookup3[a2[i3]] = i3;
|
|
4794
|
+
lookup3[l2] = -1;
|
|
4795
|
+
lookup3[l2 + 1] = -2;
|
|
4796
4796
|
b = l2 % 3 === 1 ? [l2 - 1] : [];
|
|
4797
4797
|
for (i3 = 0; i3 < al; i3++) {
|
|
4798
4798
|
if (a2[i3] % 3 === 1)
|
|
@@ -4800,7 +4800,7 @@ var require_suffix_array = __commonJS({
|
|
|
4800
4800
|
}
|
|
4801
4801
|
sort(string4, b, 0);
|
|
4802
4802
|
for (i3 = 0, j = 0, k = 0; i3 < al && j < bl; )
|
|
4803
|
-
result2[k++] = compare(string4,
|
|
4803
|
+
result2[k++] = compare(string4, lookup3, a2[i3], b[j]) < 0 ? a2[i3++] : b[j++];
|
|
4804
4804
|
while (i3 < al)
|
|
4805
4805
|
result2[k++] = a2[i3++];
|
|
4806
4806
|
while (j < bl)
|
|
@@ -9580,12 +9580,12 @@ var require_base64_js = __commonJS({
|
|
|
9580
9580
|
exports2.byteLength = byteLength;
|
|
9581
9581
|
exports2.toByteArray = toByteArray;
|
|
9582
9582
|
exports2.fromByteArray = fromByteArray;
|
|
9583
|
-
var
|
|
9583
|
+
var lookup3 = [];
|
|
9584
9584
|
var revLookup = [];
|
|
9585
9585
|
var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
|
|
9586
9586
|
var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
|
9587
9587
|
for (i3 = 0, len = code.length; i3 < len; ++i3) {
|
|
9588
|
-
|
|
9588
|
+
lookup3[i3] = code[i3];
|
|
9589
9589
|
revLookup[code.charCodeAt(i3)] = i3;
|
|
9590
9590
|
}
|
|
9591
9591
|
var i3;
|
|
@@ -9638,7 +9638,7 @@ var require_base64_js = __commonJS({
|
|
|
9638
9638
|
return arr;
|
|
9639
9639
|
}
|
|
9640
9640
|
function tripletToBase64(num) {
|
|
9641
|
-
return
|
|
9641
|
+
return lookup3[num >> 18 & 63] + lookup3[num >> 12 & 63] + lookup3[num >> 6 & 63] + lookup3[num & 63];
|
|
9642
9642
|
}
|
|
9643
9643
|
function encodeChunk(uint8, start2, end) {
|
|
9644
9644
|
var tmp;
|
|
@@ -9661,12 +9661,12 @@ var require_base64_js = __commonJS({
|
|
|
9661
9661
|
if (extraBytes === 1) {
|
|
9662
9662
|
tmp = uint8[len2 - 1];
|
|
9663
9663
|
parts2.push(
|
|
9664
|
-
|
|
9664
|
+
lookup3[tmp >> 2] + lookup3[tmp << 4 & 63] + "=="
|
|
9665
9665
|
);
|
|
9666
9666
|
} else if (extraBytes === 2) {
|
|
9667
9667
|
tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
|
|
9668
9668
|
parts2.push(
|
|
9669
|
-
|
|
9669
|
+
lookup3[tmp >> 10] + lookup3[tmp >> 4 & 63] + lookup3[tmp << 2 & 63] + "="
|
|
9670
9670
|
);
|
|
9671
9671
|
}
|
|
9672
9672
|
return parts2.join("");
|
|
@@ -48814,7 +48814,7 @@ var require_namespace = __commonJS({
|
|
|
48814
48814
|
});
|
|
48815
48815
|
return this;
|
|
48816
48816
|
};
|
|
48817
|
-
Namespace.prototype.lookup = function
|
|
48817
|
+
Namespace.prototype.lookup = function lookup3(path114, filterTypes, parentAlreadyChecked) {
|
|
48818
48818
|
if (typeof filterTypes === "boolean") {
|
|
48819
48819
|
parentAlreadyChecked = filterTypes;
|
|
48820
48820
|
filterTypes = void 0;
|
|
@@ -48849,7 +48849,7 @@ var require_namespace = __commonJS({
|
|
|
48849
48849
|
}
|
|
48850
48850
|
return null;
|
|
48851
48851
|
};
|
|
48852
|
-
Namespace.prototype._lookupImpl = function
|
|
48852
|
+
Namespace.prototype._lookupImpl = function lookup3(path114, flatPath) {
|
|
48853
48853
|
if (Object.prototype.hasOwnProperty.call(this._lookupCache, flatPath)) {
|
|
48854
48854
|
return this._lookupCache[flatPath];
|
|
48855
48855
|
}
|
|
@@ -221842,7 +221842,7 @@ var require_dns = __commonJS({
|
|
|
221842
221842
|
"packages/core/node_modules/undici/lib/interceptor/dns.js"(exports2, module2) {
|
|
221843
221843
|
"use strict";
|
|
221844
221844
|
var { isIP } = __require("node:net");
|
|
221845
|
-
var { lookup:
|
|
221845
|
+
var { lookup: lookup3 } = __require("node:dns");
|
|
221846
221846
|
var DecoratorHandler = require_decorator_handler();
|
|
221847
221847
|
var { InvalidArgumentError, InformationalError } = require_errors6();
|
|
221848
221848
|
var maxInt = Math.pow(2, 31) - 1;
|
|
@@ -221932,7 +221932,7 @@ var require_dns = __commonJS({
|
|
|
221932
221932
|
}
|
|
221933
221933
|
}
|
|
221934
221934
|
#defaultLookup(origin, opts, cb) {
|
|
221935
|
-
|
|
221935
|
+
lookup3(
|
|
221936
221936
|
origin.hostname,
|
|
221937
221937
|
{
|
|
221938
221938
|
all: true,
|
|
@@ -282634,8 +282634,8 @@ function isValidToolName(name3, options = {}) {
|
|
|
282634
282634
|
}
|
|
282635
282635
|
|
|
282636
282636
|
// packages/core/dist/src/generated/git-commit.js
|
|
282637
|
-
var GIT_COMMIT_INFO = "
|
|
282638
|
-
var CLI_VERSION = "0.
|
|
282637
|
+
var GIT_COMMIT_INFO = "3c311beac";
|
|
282638
|
+
var CLI_VERSION = "0.59.0-nightly.20260825.g812f7a2bc";
|
|
282639
282639
|
|
|
282640
282640
|
// packages/core/dist/src/ide/detect-ide.js
|
|
282641
282641
|
var IDE_DEFINITIONS = {
|
|
@@ -305929,7 +305929,7 @@ function getVersion() {
|
|
|
305929
305929
|
}
|
|
305930
305930
|
versionPromise = (async () => {
|
|
305931
305931
|
const pkgJson = await getPackageJson(__dirname4);
|
|
305932
|
-
return "0.
|
|
305932
|
+
return "0.59.0-nightly.20260827.g3c311beac";
|
|
305933
305933
|
})();
|
|
305934
305934
|
return versionPromise;
|
|
305935
305935
|
}
|
|
@@ -338540,12 +338540,90 @@ var HttpAuthProvider = class extends BaseA2AAuthProvider {
|
|
|
338540
338540
|
var import_google_auth_library5 = __toESM(require_src10(), 1);
|
|
338541
338541
|
|
|
338542
338542
|
// packages/core/dist/src/mcp/oauth-utils.js
|
|
338543
|
+
import { lookup as lookup2 } from "node:dns/promises";
|
|
338543
338544
|
var ResourceMismatchError = class extends Error {
|
|
338544
338545
|
constructor(message) {
|
|
338545
338546
|
super(message);
|
|
338546
338547
|
this.name = "ResourceMismatchError";
|
|
338547
338548
|
}
|
|
338548
338549
|
};
|
|
338550
|
+
var OAuthSecurityError = class extends Error {
|
|
338551
|
+
constructor(message) {
|
|
338552
|
+
super(message);
|
|
338553
|
+
this.name = "OAuthSecurityError";
|
|
338554
|
+
}
|
|
338555
|
+
};
|
|
338556
|
+
function isLoopbackUrl(urlStr) {
|
|
338557
|
+
try {
|
|
338558
|
+
const url3 = new URL(urlStr);
|
|
338559
|
+
return isLoopbackHost(url3.hostname);
|
|
338560
|
+
} catch {
|
|
338561
|
+
return false;
|
|
338562
|
+
}
|
|
338563
|
+
}
|
|
338564
|
+
async function validateOAuthEndpointUrl(urlStr, options) {
|
|
338565
|
+
let resolvedUrl = urlStr.trim();
|
|
338566
|
+
if (options?.allowRelative && options.baseUri) {
|
|
338567
|
+
try {
|
|
338568
|
+
resolvedUrl = new URL(resolvedUrl, options.baseUri).toString();
|
|
338569
|
+
} catch (e2) {
|
|
338570
|
+
throw new OAuthSecurityError(`Failed to resolve relative OAuth URL "${urlStr}" against base "${options.baseUri}": ${getErrorMessage(e2)}`);
|
|
338571
|
+
}
|
|
338572
|
+
}
|
|
338573
|
+
let parsed;
|
|
338574
|
+
try {
|
|
338575
|
+
parsed = new URL(resolvedUrl);
|
|
338576
|
+
} catch (e2) {
|
|
338577
|
+
throw new OAuthSecurityError(`Invalid OAuth endpoint URL "${resolvedUrl}": ${getErrorMessage(e2)}`);
|
|
338578
|
+
}
|
|
338579
|
+
const isHttp = parsed.protocol === "http:";
|
|
338580
|
+
const isHttps = parsed.protocol === "https:";
|
|
338581
|
+
if (!isHttp && !isHttps) {
|
|
338582
|
+
throw new OAuthSecurityError(`Invalid OAuth endpoint protocol "${parsed.protocol}". Only HTTPS (and HTTP for local development) is supported.`);
|
|
338583
|
+
}
|
|
338584
|
+
const hostname3 = sanitizeHostname(parsed.hostname);
|
|
338585
|
+
const isLoopback = isLoopbackHost(hostname3);
|
|
338586
|
+
if (isHttp && (!options?.allowLoopback || !isLoopback)) {
|
|
338587
|
+
throw new OAuthSecurityError(`Insecure HTTP OAuth endpoint "${resolvedUrl}" is not allowed. OAuth endpoints must use HTTPS unless connecting to localhost.`);
|
|
338588
|
+
}
|
|
338589
|
+
if (options?.expectedOrigin) {
|
|
338590
|
+
let expected;
|
|
338591
|
+
try {
|
|
338592
|
+
expected = new URL(options.expectedOrigin).origin;
|
|
338593
|
+
} catch {
|
|
338594
|
+
throw new OAuthSecurityError(`Invalid expected origin "${options.expectedOrigin}".`);
|
|
338595
|
+
}
|
|
338596
|
+
if (parsed.origin !== expected) {
|
|
338597
|
+
throw new OAuthSecurityError(`OAuth endpoint origin "${parsed.origin}" does not match expected origin "${expected}".`);
|
|
338598
|
+
}
|
|
338599
|
+
}
|
|
338600
|
+
if (isLoopback) {
|
|
338601
|
+
if (!options?.allowLoopback) {
|
|
338602
|
+
throw new OAuthSecurityError(`Loopback OAuth endpoint "${resolvedUrl}" is not allowed for remote MCP servers.`);
|
|
338603
|
+
}
|
|
338604
|
+
return parsed.toString();
|
|
338605
|
+
}
|
|
338606
|
+
if (isAddressPrivate(hostname3)) {
|
|
338607
|
+
throw new OAuthSecurityError(`OAuth endpoint "${resolvedUrl}" points to private or reserved IP address which is blocked.`);
|
|
338608
|
+
}
|
|
338609
|
+
try {
|
|
338610
|
+
const addresses = await lookup2(hostname3, { all: true });
|
|
338611
|
+
if (!addresses || addresses.length === 0) {
|
|
338612
|
+
throw new OAuthSecurityError(`Failed to resolve hostname "${hostname3}" for OAuth endpoint "${resolvedUrl}".`);
|
|
338613
|
+
}
|
|
338614
|
+
for (const addr2 of addresses) {
|
|
338615
|
+
if (isAddressPrivate(addr2.address)) {
|
|
338616
|
+
throw new OAuthSecurityError(`OAuth endpoint "${resolvedUrl}" resolves to private network address "${addr2.address}" which is blocked.`);
|
|
338617
|
+
}
|
|
338618
|
+
}
|
|
338619
|
+
} catch (error40) {
|
|
338620
|
+
if (error40 instanceof OAuthSecurityError) {
|
|
338621
|
+
throw error40;
|
|
338622
|
+
}
|
|
338623
|
+
throw new OAuthSecurityError(`DNS lookup failed for OAuth endpoint host "${hostname3}": ${getErrorMessage(error40)}`);
|
|
338624
|
+
}
|
|
338625
|
+
return parsed.toString();
|
|
338626
|
+
}
|
|
338549
338627
|
var FIVE_MIN_BUFFER_MS = 5 * 60 * 1e3;
|
|
338550
338628
|
var OAuthUtils = class {
|
|
338551
338629
|
/**
|
|
@@ -338575,16 +338653,24 @@ var OAuthUtils = class {
|
|
|
338575
338653
|
* Fetch OAuth protected resource metadata.
|
|
338576
338654
|
*
|
|
338577
338655
|
* @param resourceMetadataUrl The protected resource metadata URL
|
|
338656
|
+
* @param options Validation options including loopback allowance and expected origin
|
|
338578
338657
|
* @returns The protected resource metadata or null if not available
|
|
338579
338658
|
*/
|
|
338580
|
-
static async fetchProtectedResourceMetadata(resourceMetadataUrl) {
|
|
338659
|
+
static async fetchProtectedResourceMetadata(resourceMetadataUrl, options) {
|
|
338581
338660
|
try {
|
|
338582
|
-
const
|
|
338661
|
+
const validatedUrl = await validateOAuthEndpointUrl(resourceMetadataUrl, {
|
|
338662
|
+
allowLoopback: options?.allowLoopback,
|
|
338663
|
+
expectedOrigin: options?.expectedOrigin
|
|
338664
|
+
});
|
|
338665
|
+
const response = await fetch(validatedUrl);
|
|
338583
338666
|
if (!response.ok) {
|
|
338584
338667
|
return null;
|
|
338585
338668
|
}
|
|
338586
338669
|
return await response.json();
|
|
338587
338670
|
} catch (error40) {
|
|
338671
|
+
if (error40 instanceof OAuthSecurityError) {
|
|
338672
|
+
throw error40;
|
|
338673
|
+
}
|
|
338588
338674
|
debugLogger.debug(`Failed to fetch protected resource metadata from ${resourceMetadataUrl}: ${getErrorMessage(error40)}`);
|
|
338589
338675
|
return null;
|
|
338590
338676
|
}
|
|
@@ -338593,16 +338679,23 @@ var OAuthUtils = class {
|
|
|
338593
338679
|
* Fetch OAuth authorization server metadata.
|
|
338594
338680
|
*
|
|
338595
338681
|
* @param authServerMetadataUrl The authorization server metadata URL
|
|
338682
|
+
* @param options Validation options including loopback allowance
|
|
338596
338683
|
* @returns The authorization server metadata or null if not available
|
|
338597
338684
|
*/
|
|
338598
|
-
static async fetchAuthorizationServerMetadata(authServerMetadataUrl) {
|
|
338685
|
+
static async fetchAuthorizationServerMetadata(authServerMetadataUrl, options) {
|
|
338599
338686
|
try {
|
|
338600
|
-
const
|
|
338687
|
+
const validatedUrl = await validateOAuthEndpointUrl(authServerMetadataUrl, {
|
|
338688
|
+
allowLoopback: options?.allowLoopback
|
|
338689
|
+
});
|
|
338690
|
+
const response = await fetch(validatedUrl);
|
|
338601
338691
|
if (!response.ok) {
|
|
338602
338692
|
return null;
|
|
338603
338693
|
}
|
|
338604
338694
|
return await response.json();
|
|
338605
338695
|
} catch (error40) {
|
|
338696
|
+
if (error40 instanceof OAuthSecurityError) {
|
|
338697
|
+
throw error40;
|
|
338698
|
+
}
|
|
338606
338699
|
debugLogger.debug(`Failed to fetch authorization server metadata from ${authServerMetadataUrl}: ${getErrorMessage(error40)}`);
|
|
338607
338700
|
return null;
|
|
338608
338701
|
}
|
|
@@ -338627,10 +338720,14 @@ var OAuthUtils = class {
|
|
|
338627
338720
|
* trying the standard well-known endpoints.
|
|
338628
338721
|
*
|
|
338629
338722
|
* @param authServerUrl The authorization server URL
|
|
338723
|
+
* @param options Validation options including loopback allowance
|
|
338630
338724
|
* @returns The authorization server metadata or null if not found
|
|
338631
338725
|
*/
|
|
338632
|
-
static async discoverAuthorizationServerMetadata(authServerUrl) {
|
|
338633
|
-
const
|
|
338726
|
+
static async discoverAuthorizationServerMetadata(authServerUrl, options) {
|
|
338727
|
+
const validatedBaseUrl = await validateOAuthEndpointUrl(authServerUrl, {
|
|
338728
|
+
allowLoopback: options?.allowLoopback
|
|
338729
|
+
});
|
|
338730
|
+
const authServerUrlObj = new URL(validatedBaseUrl);
|
|
338634
338731
|
const base = `${authServerUrlObj.protocol}//${authServerUrlObj.host}`;
|
|
338635
338732
|
const endpointsToTry = [];
|
|
338636
338733
|
if (authServerUrlObj.pathname !== "/") {
|
|
@@ -338641,7 +338738,7 @@ var OAuthUtils = class {
|
|
|
338641
338738
|
endpointsToTry.push(new URL("/.well-known/oauth-authorization-server", base).toString());
|
|
338642
338739
|
endpointsToTry.push(new URL("/.well-known/openid-configuration", base).toString());
|
|
338643
338740
|
for (const endpoint of endpointsToTry) {
|
|
338644
|
-
const authServerMetadata = await this.fetchAuthorizationServerMetadata(endpoint);
|
|
338741
|
+
const authServerMetadata = await this.fetchAuthorizationServerMetadata(endpoint, options);
|
|
338645
338742
|
if (authServerMetadata) {
|
|
338646
338743
|
return authServerMetadata;
|
|
338647
338744
|
}
|
|
@@ -338657,13 +338754,15 @@ var OAuthUtils = class {
|
|
|
338657
338754
|
*/
|
|
338658
338755
|
static async discoverOAuthConfig(serverUrl) {
|
|
338659
338756
|
try {
|
|
338757
|
+
const allowLoopback = isLoopbackUrl(serverUrl);
|
|
338758
|
+
const expectedOrigin = new URL(serverUrl).origin;
|
|
338660
338759
|
const wellKnownUrls = this.buildWellKnownUrls(serverUrl);
|
|
338661
|
-
let resourceMetadata = await this.fetchProtectedResourceMetadata(wellKnownUrls.protectedResource);
|
|
338760
|
+
let resourceMetadata = await this.fetchProtectedResourceMetadata(wellKnownUrls.protectedResource, { allowLoopback, expectedOrigin });
|
|
338662
338761
|
if (!resourceMetadata) {
|
|
338663
338762
|
const url3 = new URL(serverUrl);
|
|
338664
338763
|
if (url3.pathname && url3.pathname !== "/") {
|
|
338665
338764
|
const rootBasedUrls = this.buildWellKnownUrls(serverUrl, true);
|
|
338666
|
-
resourceMetadata = await this.fetchProtectedResourceMetadata(rootBasedUrls.protectedResource);
|
|
338765
|
+
resourceMetadata = await this.fetchProtectedResourceMetadata(rootBasedUrls.protectedResource, { allowLoopback, expectedOrigin });
|
|
338667
338766
|
}
|
|
338668
338767
|
}
|
|
338669
338768
|
if (resourceMetadata) {
|
|
@@ -338674,7 +338773,9 @@ var OAuthUtils = class {
|
|
|
338674
338773
|
}
|
|
338675
338774
|
if (resourceMetadata?.authorization_servers?.length) {
|
|
338676
338775
|
const authServerUrl = resourceMetadata.authorization_servers[0];
|
|
338677
|
-
const authServerMetadata2 = await this.discoverAuthorizationServerMetadata(authServerUrl
|
|
338776
|
+
const authServerMetadata2 = await this.discoverAuthorizationServerMetadata(authServerUrl, {
|
|
338777
|
+
allowLoopback
|
|
338778
|
+
});
|
|
338678
338779
|
if (authServerMetadata2) {
|
|
338679
338780
|
const config2 = this.metadataToOAuthConfig(authServerMetadata2);
|
|
338680
338781
|
if (authServerMetadata2.registration_endpoint) {
|
|
@@ -338684,7 +338785,9 @@ var OAuthUtils = class {
|
|
|
338684
338785
|
}
|
|
338685
338786
|
}
|
|
338686
338787
|
debugLogger.debug(`Trying OAuth discovery fallback at ${serverUrl}`);
|
|
338687
|
-
const authServerMetadata = await this.discoverAuthorizationServerMetadata(serverUrl
|
|
338788
|
+
const authServerMetadata = await this.discoverAuthorizationServerMetadata(serverUrl, {
|
|
338789
|
+
allowLoopback
|
|
338790
|
+
});
|
|
338688
338791
|
if (authServerMetadata) {
|
|
338689
338792
|
const config2 = this.metadataToOAuthConfig(authServerMetadata);
|
|
338690
338793
|
if (authServerMetadata.registration_endpoint) {
|
|
@@ -338694,7 +338797,7 @@ var OAuthUtils = class {
|
|
|
338694
338797
|
}
|
|
338695
338798
|
return null;
|
|
338696
338799
|
} catch (error40) {
|
|
338697
|
-
if (error40 instanceof ResourceMismatchError) {
|
|
338800
|
+
if (error40 instanceof ResourceMismatchError || error40 instanceof OAuthSecurityError) {
|
|
338698
338801
|
throw error40;
|
|
338699
338802
|
}
|
|
338700
338803
|
debugLogger.debug(`Failed to discover OAuth configuration: ${getErrorMessage(error40)}`);
|
|
@@ -338708,9 +338811,9 @@ var OAuthUtils = class {
|
|
|
338708
338811
|
* @returns The resource metadata URI if found
|
|
338709
338812
|
*/
|
|
338710
338813
|
static parseWWWAuthenticateHeader(header) {
|
|
338711
|
-
const match2 = header.match(/resource_metadata="([^"]+)"/);
|
|
338814
|
+
const match2 = header.match(/resource_metadata=(?:"([^"]+)"|([^\s,]+))/);
|
|
338712
338815
|
if (match2) {
|
|
338713
|
-
return match2[1];
|
|
338816
|
+
return match2[1] || match2[2] || null;
|
|
338714
338817
|
}
|
|
338715
338818
|
return null;
|
|
338716
338819
|
}
|
|
@@ -338726,7 +338829,18 @@ var OAuthUtils = class {
|
|
|
338726
338829
|
if (!resourceMetadataUri) {
|
|
338727
338830
|
return null;
|
|
338728
338831
|
}
|
|
338729
|
-
const
|
|
338832
|
+
const allowLoopback = mcpServerUrl ? isLoopbackUrl(mcpServerUrl) : false;
|
|
338833
|
+
const expectedOrigin = mcpServerUrl ? new URL(mcpServerUrl).origin : void 0;
|
|
338834
|
+
const validatedResourceMetadataUrl = await validateOAuthEndpointUrl(resourceMetadataUri, {
|
|
338835
|
+
allowLoopback,
|
|
338836
|
+
expectedOrigin,
|
|
338837
|
+
allowRelative: true,
|
|
338838
|
+
baseUri: mcpServerUrl
|
|
338839
|
+
});
|
|
338840
|
+
const resourceMetadata = await this.fetchProtectedResourceMetadata(validatedResourceMetadataUrl, {
|
|
338841
|
+
allowLoopback,
|
|
338842
|
+
expectedOrigin
|
|
338843
|
+
});
|
|
338730
338844
|
if (resourceMetadata && mcpServerUrl) {
|
|
338731
338845
|
const expectedResource = this.buildResourceParameter(mcpServerUrl);
|
|
338732
338846
|
if (!this.isEquivalentResourceIdentifier(resourceMetadata.resource, expectedResource)) {
|
|
@@ -338737,7 +338851,9 @@ var OAuthUtils = class {
|
|
|
338737
338851
|
return null;
|
|
338738
338852
|
}
|
|
338739
338853
|
const authServerUrl = resourceMetadata.authorization_servers[0];
|
|
338740
|
-
const authServerMetadata = await this.discoverAuthorizationServerMetadata(authServerUrl
|
|
338854
|
+
const authServerMetadata = await this.discoverAuthorizationServerMetadata(authServerUrl, {
|
|
338855
|
+
allowLoopback
|
|
338856
|
+
});
|
|
338741
338857
|
if (authServerMetadata) {
|
|
338742
338858
|
return this.metadataToOAuthConfig(authServerMetadata);
|
|
338743
338859
|
}
|
|
@@ -338920,7 +339036,7 @@ var A2AAuthProviderFactory = class _A2AAuthProviderFactory {
|
|
|
338920
339036
|
return provider;
|
|
338921
339037
|
}
|
|
338922
339038
|
case "oauth2": {
|
|
338923
|
-
const { OAuth2AuthProvider } = await import("./oauth2-provider-
|
|
339039
|
+
const { OAuth2AuthProvider } = await import("./oauth2-provider-3SYE4YDY.js");
|
|
338924
339040
|
const provider = new OAuth2AuthProvider(authConfig, options.agentName ?? "unknown", agentCard, options.agentCardUrl);
|
|
338925
339041
|
await provider.initialize();
|
|
338926
339042
|
return provider;
|
|
@@ -366579,7 +366695,11 @@ async function exchangeCodeForToken(config2, code, codeVerifier, redirectPort, r
|
|
|
366579
366695
|
if (resource) {
|
|
366580
366696
|
params.append("resource", resource);
|
|
366581
366697
|
}
|
|
366582
|
-
const
|
|
366698
|
+
const allowLoopback = resource ? isLoopbackUrl(resource) : isLoopbackUrl(config2.tokenUrl);
|
|
366699
|
+
const validatedTokenUrl = await validateOAuthEndpointUrl(config2.tokenUrl, {
|
|
366700
|
+
allowLoopback
|
|
366701
|
+
});
|
|
366702
|
+
const response = await fetch(validatedTokenUrl, {
|
|
366583
366703
|
method: "POST",
|
|
366584
366704
|
headers: {
|
|
366585
366705
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
@@ -366607,7 +366727,11 @@ async function refreshAccessToken(config2, refreshToken, tokenUrl, resource) {
|
|
|
366607
366727
|
if (resource) {
|
|
366608
366728
|
params.append("resource", resource);
|
|
366609
366729
|
}
|
|
366610
|
-
const
|
|
366730
|
+
const allowLoopback = resource ? isLoopbackUrl(resource) : isLoopbackUrl(tokenUrl);
|
|
366731
|
+
const validatedTokenUrl = await validateOAuthEndpointUrl(tokenUrl, {
|
|
366732
|
+
allowLoopback
|
|
366733
|
+
});
|
|
366734
|
+
const response = await fetch(validatedTokenUrl, {
|
|
366611
366735
|
method: "POST",
|
|
366612
366736
|
headers: {
|
|
366613
366737
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
@@ -366632,7 +366756,11 @@ var MCPOAuthProvider = class {
|
|
|
366632
366756
|
* @param redirectPort The port to use for the redirect URI
|
|
366633
366757
|
* @returns The registered client information
|
|
366634
366758
|
*/
|
|
366635
|
-
async registerClient(registrationUrl, config2, redirectPort) {
|
|
366759
|
+
async registerClient(registrationUrl, config2, redirectPort, mcpServerUrl) {
|
|
366760
|
+
const allowLoopback = mcpServerUrl ? isLoopbackUrl(mcpServerUrl) : isLoopbackUrl(registrationUrl);
|
|
366761
|
+
const validatedRegistrationUrl = await validateOAuthEndpointUrl(registrationUrl, {
|
|
366762
|
+
allowLoopback
|
|
366763
|
+
});
|
|
366636
366764
|
const redirectUri = getRedirectUri(config2, redirectPort);
|
|
366637
366765
|
const registrationRequest = {
|
|
366638
366766
|
client_name: "Gemini CLI MCP Client",
|
|
@@ -366643,7 +366771,7 @@ var MCPOAuthProvider = class {
|
|
|
366643
366771
|
// Public client
|
|
366644
366772
|
scope: config2.scopes?.join(" ") || ""
|
|
366645
366773
|
};
|
|
366646
|
-
const response = await fetch(
|
|
366774
|
+
const response = await fetch(validatedRegistrationUrl, {
|
|
366647
366775
|
method: "POST",
|
|
366648
366776
|
headers: {
|
|
366649
366777
|
"Content-Type": "application/json"
|
|
@@ -366665,7 +366793,8 @@ var MCPOAuthProvider = class {
|
|
|
366665
366793
|
async discoverOAuthFromMCPServer(mcpServerUrl) {
|
|
366666
366794
|
return OAuthUtils.discoverOAuthConfig(mcpServerUrl);
|
|
366667
366795
|
}
|
|
366668
|
-
async discoverAuthServerMetadataForRegistration(issuer) {
|
|
366796
|
+
async discoverAuthServerMetadataForRegistration(issuer, mcpServerUrl) {
|
|
366797
|
+
const allowLoopback = mcpServerUrl ? isLoopbackUrl(mcpServerUrl) : isLoopbackUrl(issuer);
|
|
366669
366798
|
const authUrl = new URL7(issuer);
|
|
366670
366799
|
const oidcPatterns = [
|
|
366671
366800
|
"/protocol/openid-connect/auth",
|
|
@@ -366698,11 +366827,11 @@ var MCPOAuthProvider = class {
|
|
|
366698
366827
|
const attemptedIssuers = Array.from(issuerCandidates);
|
|
366699
366828
|
let selectedIssuer = attemptedIssuers[0];
|
|
366700
366829
|
let discoveredMetadata = null;
|
|
366701
|
-
for (const
|
|
366702
|
-
debugLogger.debug(` Trying issuer URL: ${
|
|
366703
|
-
const metadata2 = await OAuthUtils.discoverAuthorizationServerMetadata(
|
|
366830
|
+
for (const issuerCandidate of attemptedIssuers) {
|
|
366831
|
+
debugLogger.debug(` Trying issuer URL: ${issuerCandidate}`);
|
|
366832
|
+
const metadata2 = await OAuthUtils.discoverAuthorizationServerMetadata(issuerCandidate, { allowLoopback });
|
|
366704
366833
|
if (metadata2) {
|
|
366705
|
-
selectedIssuer =
|
|
366834
|
+
selectedIssuer = issuerCandidate;
|
|
366706
366835
|
discoveredMetadata = metadata2;
|
|
366707
366836
|
break;
|
|
366708
366837
|
}
|
|
@@ -366791,7 +366920,7 @@ var MCPOAuthProvider = class {
|
|
|
366791
366920
|
}
|
|
366792
366921
|
}
|
|
366793
366922
|
} catch (error40) {
|
|
366794
|
-
if (error40 instanceof ResourceMismatchError) {
|
|
366923
|
+
if (error40 instanceof ResourceMismatchError || error40 instanceof OAuthSecurityError) {
|
|
366795
366924
|
throw error40;
|
|
366796
366925
|
}
|
|
366797
366926
|
debugLogger.debug(`Failed to check endpoint for authentication requirements: ${getErrorMessage(error40)}`);
|
|
@@ -366827,11 +366956,11 @@ var MCPOAuthProvider = class {
|
|
|
366827
366956
|
throw new Error("Cannot perform dynamic registration without issuer");
|
|
366828
366957
|
}
|
|
366829
366958
|
debugLogger.debug("\u2192 Attempting dynamic client registration...");
|
|
366830
|
-
const { metadata: authServerMetadata } = await this.discoverAuthServerMetadataForRegistration(config2.issuer);
|
|
366959
|
+
const { metadata: authServerMetadata } = await this.discoverAuthServerMetadataForRegistration(config2.issuer, mcpServerUrl);
|
|
366831
366960
|
registrationUrl = authServerMetadata.registration_endpoint;
|
|
366832
366961
|
}
|
|
366833
366962
|
if (registrationUrl) {
|
|
366834
|
-
const clientRegistration = await this.registerClient(registrationUrl, config2, redirectPort);
|
|
366963
|
+
const clientRegistration = await this.registerClient(registrationUrl, config2, redirectPort, mcpServerUrl);
|
|
366835
366964
|
config2.clientId = clientRegistration.client_id;
|
|
366836
366965
|
if (clientRegistration.client_secret) {
|
|
366837
366966
|
config2.clientSecret = clientRegistration.client_secret;
|
|
@@ -366844,6 +366973,13 @@ var MCPOAuthProvider = class {
|
|
|
366844
366973
|
if (!config2.clientId || !config2.authorizationUrl || !config2.tokenUrl) {
|
|
366845
366974
|
throw new Error("Missing required OAuth configuration after discovery and registration");
|
|
366846
366975
|
}
|
|
366976
|
+
const allowLoopback = mcpServerUrl ? isLoopbackUrl(mcpServerUrl) : (config2.authorizationUrl ? isLoopbackUrl(config2.authorizationUrl) : false) || (config2.tokenUrl ? isLoopbackUrl(config2.tokenUrl) : false);
|
|
366977
|
+
await validateOAuthEndpointUrl(config2.authorizationUrl, {
|
|
366978
|
+
allowLoopback
|
|
366979
|
+
});
|
|
366980
|
+
await validateOAuthEndpointUrl(config2.tokenUrl, {
|
|
366981
|
+
allowLoopback
|
|
366982
|
+
});
|
|
366847
366983
|
const flowConfig = {
|
|
366848
366984
|
clientId: config2.clientId,
|
|
366849
366985
|
clientSecret: config2.clientSecret,
|
|
@@ -396833,6 +396969,9 @@ export {
|
|
|
396833
396969
|
markdownToAgentDefinition,
|
|
396834
396970
|
loadAgentsFromDirectory,
|
|
396835
396971
|
BaseA2AAuthProvider,
|
|
396972
|
+
OAuthSecurityError,
|
|
396973
|
+
isLoopbackUrl,
|
|
396974
|
+
validateOAuthEndpointUrl,
|
|
396836
396975
|
OAuthUtils,
|
|
396837
396976
|
DefaultAgentCardResolver,
|
|
396838
396977
|
MCPOAuthTokenStorage,
|