@automattic/mcp-wordpress-remote 0.5.0 → 0.5.2
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 +36 -9
- package/dist/lib.d.ts +7 -7
- package/dist/lib.js +47 -18
- package/dist/proxy.js +393 -209
- package/package.json +1 -1
package/dist/proxy.js
CHANGED
|
@@ -4939,7 +4939,7 @@ async function toFormData(Body2, ct) {
|
|
|
4939
4939
|
let headerValue2;
|
|
4940
4940
|
let entryValue;
|
|
4941
4941
|
let entryName;
|
|
4942
|
-
let
|
|
4942
|
+
let contentType2;
|
|
4943
4943
|
let filename;
|
|
4944
4944
|
const entryChunks = [];
|
|
4945
4945
|
const formData = new FormData();
|
|
@@ -4950,7 +4950,7 @@ async function toFormData(Body2, ct) {
|
|
|
4950
4950
|
entryChunks.push(ui8a);
|
|
4951
4951
|
};
|
|
4952
4952
|
const appendFileToFormData = () => {
|
|
4953
|
-
const file2 = new file_default(entryChunks, filename, { type:
|
|
4953
|
+
const file2 = new file_default(entryChunks, filename, { type: contentType2 });
|
|
4954
4954
|
formData.append(entryName, file2);
|
|
4955
4955
|
};
|
|
4956
4956
|
const appendEntryToFormData = () => {
|
|
@@ -4965,7 +4965,7 @@ async function toFormData(Body2, ct) {
|
|
|
4965
4965
|
headerValue2 = "";
|
|
4966
4966
|
entryValue = "";
|
|
4967
4967
|
entryName = "";
|
|
4968
|
-
|
|
4968
|
+
contentType2 = "";
|
|
4969
4969
|
filename = null;
|
|
4970
4970
|
entryChunks.length = 0;
|
|
4971
4971
|
};
|
|
@@ -4989,7 +4989,7 @@ async function toFormData(Body2, ct) {
|
|
|
4989
4989
|
parser.onPartEnd = appendFileToFormData;
|
|
4990
4990
|
}
|
|
4991
4991
|
} else if (headerField === "content-type") {
|
|
4992
|
-
|
|
4992
|
+
contentType2 = headerValue2;
|
|
4993
4993
|
}
|
|
4994
4994
|
headerValue2 = "";
|
|
4995
4995
|
headerField = "";
|
|
@@ -5749,9 +5749,9 @@ var init_response = __esm({
|
|
|
5749
5749
|
const status = options.status != null ? options.status : 200;
|
|
5750
5750
|
const headers = new Headers2(options.headers);
|
|
5751
5751
|
if (body !== null && !headers.has("Content-Type")) {
|
|
5752
|
-
const
|
|
5753
|
-
if (
|
|
5754
|
-
headers.append("Content-Type",
|
|
5752
|
+
const contentType2 = extractContentType(body, this);
|
|
5753
|
+
if (contentType2) {
|
|
5754
|
+
headers.append("Content-Type", contentType2);
|
|
5755
5755
|
}
|
|
5756
5756
|
}
|
|
5757
5757
|
this[INTERNALS2] = {
|
|
@@ -6073,9 +6073,9 @@ var init_request = __esm({
|
|
|
6073
6073
|
});
|
|
6074
6074
|
const headers = new Headers2(init.headers || input.headers || {});
|
|
6075
6075
|
if (inputBody !== null && !headers.has("Content-Type")) {
|
|
6076
|
-
const
|
|
6077
|
-
if (
|
|
6078
|
-
headers.set("Content-Type",
|
|
6076
|
+
const contentType2 = extractContentType(inputBody, this);
|
|
6077
|
+
if (contentType2) {
|
|
6078
|
+
headers.set("Content-Type", contentType2);
|
|
6079
6079
|
}
|
|
6080
6080
|
}
|
|
6081
6081
|
let signal = isRequest(input) ? input.signal : null;
|
|
@@ -6547,6 +6547,110 @@ var init_src = __esm({
|
|
|
6547
6547
|
}
|
|
6548
6548
|
});
|
|
6549
6549
|
|
|
6550
|
+
// node_modules/content-type/index.js
|
|
6551
|
+
var require_content_type = __commonJS({
|
|
6552
|
+
"node_modules/content-type/index.js"(exports) {
|
|
6553
|
+
"use strict";
|
|
6554
|
+
var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g;
|
|
6555
|
+
var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/;
|
|
6556
|
+
var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
6557
|
+
var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g;
|
|
6558
|
+
var QUOTE_REGEXP = /([\\"])/g;
|
|
6559
|
+
var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
6560
|
+
exports.format = format;
|
|
6561
|
+
exports.parse = parse3;
|
|
6562
|
+
function format(obj) {
|
|
6563
|
+
if (!obj || typeof obj !== "object") {
|
|
6564
|
+
throw new TypeError("argument obj is required");
|
|
6565
|
+
}
|
|
6566
|
+
var parameters = obj.parameters;
|
|
6567
|
+
var type = obj.type;
|
|
6568
|
+
if (!type || !TYPE_REGEXP.test(type)) {
|
|
6569
|
+
throw new TypeError("invalid type");
|
|
6570
|
+
}
|
|
6571
|
+
var string4 = type;
|
|
6572
|
+
if (parameters && typeof parameters === "object") {
|
|
6573
|
+
var param;
|
|
6574
|
+
var params = Object.keys(parameters).sort();
|
|
6575
|
+
for (var i2 = 0; i2 < params.length; i2++) {
|
|
6576
|
+
param = params[i2];
|
|
6577
|
+
if (!TOKEN_REGEXP.test(param)) {
|
|
6578
|
+
throw new TypeError("invalid parameter name");
|
|
6579
|
+
}
|
|
6580
|
+
string4 += "; " + param + "=" + qstring(parameters[param]);
|
|
6581
|
+
}
|
|
6582
|
+
}
|
|
6583
|
+
return string4;
|
|
6584
|
+
}
|
|
6585
|
+
function parse3(string4) {
|
|
6586
|
+
if (!string4) {
|
|
6587
|
+
throw new TypeError("argument string is required");
|
|
6588
|
+
}
|
|
6589
|
+
var header = typeof string4 === "object" ? getcontenttype(string4) : string4;
|
|
6590
|
+
if (typeof header !== "string") {
|
|
6591
|
+
throw new TypeError("argument string is required to be a string");
|
|
6592
|
+
}
|
|
6593
|
+
var index = header.indexOf(";");
|
|
6594
|
+
var type = index !== -1 ? header.slice(0, index).trim() : header.trim();
|
|
6595
|
+
if (!TYPE_REGEXP.test(type)) {
|
|
6596
|
+
throw new TypeError("invalid media type");
|
|
6597
|
+
}
|
|
6598
|
+
var obj = new ContentType(type.toLowerCase());
|
|
6599
|
+
if (index !== -1) {
|
|
6600
|
+
var key;
|
|
6601
|
+
var match;
|
|
6602
|
+
var value;
|
|
6603
|
+
PARAM_REGEXP.lastIndex = index;
|
|
6604
|
+
while (match = PARAM_REGEXP.exec(header)) {
|
|
6605
|
+
if (match.index !== index) {
|
|
6606
|
+
throw new TypeError("invalid parameter format");
|
|
6607
|
+
}
|
|
6608
|
+
index += match[0].length;
|
|
6609
|
+
key = match[1].toLowerCase();
|
|
6610
|
+
value = match[2];
|
|
6611
|
+
if (value.charCodeAt(0) === 34) {
|
|
6612
|
+
value = value.slice(1, -1);
|
|
6613
|
+
if (value.indexOf("\\") !== -1) {
|
|
6614
|
+
value = value.replace(QESC_REGEXP, "$1");
|
|
6615
|
+
}
|
|
6616
|
+
}
|
|
6617
|
+
obj.parameters[key] = value;
|
|
6618
|
+
}
|
|
6619
|
+
if (index !== header.length) {
|
|
6620
|
+
throw new TypeError("invalid parameter format");
|
|
6621
|
+
}
|
|
6622
|
+
}
|
|
6623
|
+
return obj;
|
|
6624
|
+
}
|
|
6625
|
+
function getcontenttype(obj) {
|
|
6626
|
+
var header;
|
|
6627
|
+
if (typeof obj.getHeader === "function") {
|
|
6628
|
+
header = obj.getHeader("content-type");
|
|
6629
|
+
} else if (typeof obj.headers === "object") {
|
|
6630
|
+
header = obj.headers && obj.headers["content-type"];
|
|
6631
|
+
}
|
|
6632
|
+
if (typeof header !== "string") {
|
|
6633
|
+
throw new TypeError("content-type header is missing from object");
|
|
6634
|
+
}
|
|
6635
|
+
return header;
|
|
6636
|
+
}
|
|
6637
|
+
function qstring(val) {
|
|
6638
|
+
var str = String(val);
|
|
6639
|
+
if (TOKEN_REGEXP.test(str)) {
|
|
6640
|
+
return str;
|
|
6641
|
+
}
|
|
6642
|
+
if (str.length > 0 && !TEXT_REGEXP.test(str)) {
|
|
6643
|
+
throw new TypeError("invalid parameter value");
|
|
6644
|
+
}
|
|
6645
|
+
return '"' + str.replace(QUOTE_REGEXP, "\\$1") + '"';
|
|
6646
|
+
}
|
|
6647
|
+
function ContentType(type) {
|
|
6648
|
+
this.parameters = /* @__PURE__ */ Object.create(null);
|
|
6649
|
+
this.type = type;
|
|
6650
|
+
}
|
|
6651
|
+
}
|
|
6652
|
+
});
|
|
6653
|
+
|
|
6550
6654
|
// node_modules/ms/index.js
|
|
6551
6655
|
var require_ms = __commonJS({
|
|
6552
6656
|
"node_modules/ms/index.js"(exports, module) {
|
|
@@ -21818,7 +21922,7 @@ var require_mime_types = __commonJS({
|
|
|
21818
21922
|
var TEXT_TYPE_REGEXP = /^text\//i;
|
|
21819
21923
|
exports.charset = charset;
|
|
21820
21924
|
exports.charsets = { lookup: charset };
|
|
21821
|
-
exports.contentType =
|
|
21925
|
+
exports.contentType = contentType2;
|
|
21822
21926
|
exports.extension = extension;
|
|
21823
21927
|
exports.extensions = /* @__PURE__ */ Object.create(null);
|
|
21824
21928
|
exports.lookup = lookup;
|
|
@@ -21839,7 +21943,7 @@ var require_mime_types = __commonJS({
|
|
|
21839
21943
|
}
|
|
21840
21944
|
return false;
|
|
21841
21945
|
}
|
|
21842
|
-
function
|
|
21946
|
+
function contentType2(str) {
|
|
21843
21947
|
if (!str || typeof str !== "string") {
|
|
21844
21948
|
return false;
|
|
21845
21949
|
}
|
|
@@ -21981,7 +22085,7 @@ var require_media_typer = __commonJS({
|
|
|
21981
22085
|
var require_type_is = __commonJS({
|
|
21982
22086
|
"node_modules/type-is/index.js"(exports, module) {
|
|
21983
22087
|
"use strict";
|
|
21984
|
-
var
|
|
22088
|
+
var contentType2 = require_dist();
|
|
21985
22089
|
var mime = require_mime_types();
|
|
21986
22090
|
var typer = require_media_typer();
|
|
21987
22091
|
module.exports = typeofrequest;
|
|
@@ -22062,7 +22166,7 @@ var require_type_is = __commonJS({
|
|
|
22062
22166
|
}
|
|
22063
22167
|
function normalizeType(value) {
|
|
22064
22168
|
if (!value) return null;
|
|
22065
|
-
var type =
|
|
22169
|
+
var type = contentType2.parse(value, { parameters: false }).type;
|
|
22066
22170
|
return typer.test(type) ? type : null;
|
|
22067
22171
|
}
|
|
22068
22172
|
}
|
|
@@ -22212,7 +22316,7 @@ var require_utils = __commonJS({
|
|
|
22212
22316
|
"node_modules/body-parser/lib/utils.js"(exports, module) {
|
|
22213
22317
|
"use strict";
|
|
22214
22318
|
var bytes = require_bytes();
|
|
22215
|
-
var
|
|
22319
|
+
var contentType2 = require_dist2();
|
|
22216
22320
|
var typeis = require_type_is();
|
|
22217
22321
|
module.exports = {
|
|
22218
22322
|
getCharset,
|
|
@@ -22222,7 +22326,7 @@ var require_utils = __commonJS({
|
|
|
22222
22326
|
function getCharset(req) {
|
|
22223
22327
|
const header = req.headers["content-type"];
|
|
22224
22328
|
if (!header) return void 0;
|
|
22225
|
-
return
|
|
22329
|
+
return contentType2.parse(header).parameters.charset?.toLowerCase();
|
|
22226
22330
|
}
|
|
22227
22331
|
function typeChecker(type) {
|
|
22228
22332
|
return function checkType(req) {
|
|
@@ -25646,110 +25750,6 @@ var require_view = __commonJS({
|
|
|
25646
25750
|
}
|
|
25647
25751
|
});
|
|
25648
25752
|
|
|
25649
|
-
// node_modules/content-type/index.js
|
|
25650
|
-
var require_content_type = __commonJS({
|
|
25651
|
-
"node_modules/content-type/index.js"(exports) {
|
|
25652
|
-
"use strict";
|
|
25653
|
-
var PARAM_REGEXP = /; *([!#$%&'*+.^_`|~0-9A-Za-z-]+) *= *("(?:[\u000b\u0020\u0021\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u000b\u0020-\u00ff])*"|[!#$%&'*+.^_`|~0-9A-Za-z-]+) */g;
|
|
25654
|
-
var TEXT_REGEXP = /^[\u000b\u0020-\u007e\u0080-\u00ff]+$/;
|
|
25655
|
-
var TOKEN_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
25656
|
-
var QESC_REGEXP = /\\([\u000b\u0020-\u00ff])/g;
|
|
25657
|
-
var QUOTE_REGEXP = /([\\"])/g;
|
|
25658
|
-
var TYPE_REGEXP = /^[!#$%&'*+.^_`|~0-9A-Za-z-]+\/[!#$%&'*+.^_`|~0-9A-Za-z-]+$/;
|
|
25659
|
-
exports.format = format;
|
|
25660
|
-
exports.parse = parse3;
|
|
25661
|
-
function format(obj) {
|
|
25662
|
-
if (!obj || typeof obj !== "object") {
|
|
25663
|
-
throw new TypeError("argument obj is required");
|
|
25664
|
-
}
|
|
25665
|
-
var parameters = obj.parameters;
|
|
25666
|
-
var type = obj.type;
|
|
25667
|
-
if (!type || !TYPE_REGEXP.test(type)) {
|
|
25668
|
-
throw new TypeError("invalid type");
|
|
25669
|
-
}
|
|
25670
|
-
var string4 = type;
|
|
25671
|
-
if (parameters && typeof parameters === "object") {
|
|
25672
|
-
var param;
|
|
25673
|
-
var params = Object.keys(parameters).sort();
|
|
25674
|
-
for (var i2 = 0; i2 < params.length; i2++) {
|
|
25675
|
-
param = params[i2];
|
|
25676
|
-
if (!TOKEN_REGEXP.test(param)) {
|
|
25677
|
-
throw new TypeError("invalid parameter name");
|
|
25678
|
-
}
|
|
25679
|
-
string4 += "; " + param + "=" + qstring(parameters[param]);
|
|
25680
|
-
}
|
|
25681
|
-
}
|
|
25682
|
-
return string4;
|
|
25683
|
-
}
|
|
25684
|
-
function parse3(string4) {
|
|
25685
|
-
if (!string4) {
|
|
25686
|
-
throw new TypeError("argument string is required");
|
|
25687
|
-
}
|
|
25688
|
-
var header = typeof string4 === "object" ? getcontenttype(string4) : string4;
|
|
25689
|
-
if (typeof header !== "string") {
|
|
25690
|
-
throw new TypeError("argument string is required to be a string");
|
|
25691
|
-
}
|
|
25692
|
-
var index = header.indexOf(";");
|
|
25693
|
-
var type = index !== -1 ? header.slice(0, index).trim() : header.trim();
|
|
25694
|
-
if (!TYPE_REGEXP.test(type)) {
|
|
25695
|
-
throw new TypeError("invalid media type");
|
|
25696
|
-
}
|
|
25697
|
-
var obj = new ContentType(type.toLowerCase());
|
|
25698
|
-
if (index !== -1) {
|
|
25699
|
-
var key;
|
|
25700
|
-
var match;
|
|
25701
|
-
var value;
|
|
25702
|
-
PARAM_REGEXP.lastIndex = index;
|
|
25703
|
-
while (match = PARAM_REGEXP.exec(header)) {
|
|
25704
|
-
if (match.index !== index) {
|
|
25705
|
-
throw new TypeError("invalid parameter format");
|
|
25706
|
-
}
|
|
25707
|
-
index += match[0].length;
|
|
25708
|
-
key = match[1].toLowerCase();
|
|
25709
|
-
value = match[2];
|
|
25710
|
-
if (value.charCodeAt(0) === 34) {
|
|
25711
|
-
value = value.slice(1, -1);
|
|
25712
|
-
if (value.indexOf("\\") !== -1) {
|
|
25713
|
-
value = value.replace(QESC_REGEXP, "$1");
|
|
25714
|
-
}
|
|
25715
|
-
}
|
|
25716
|
-
obj.parameters[key] = value;
|
|
25717
|
-
}
|
|
25718
|
-
if (index !== header.length) {
|
|
25719
|
-
throw new TypeError("invalid parameter format");
|
|
25720
|
-
}
|
|
25721
|
-
}
|
|
25722
|
-
return obj;
|
|
25723
|
-
}
|
|
25724
|
-
function getcontenttype(obj) {
|
|
25725
|
-
var header;
|
|
25726
|
-
if (typeof obj.getHeader === "function") {
|
|
25727
|
-
header = obj.getHeader("content-type");
|
|
25728
|
-
} else if (typeof obj.headers === "object") {
|
|
25729
|
-
header = obj.headers && obj.headers["content-type"];
|
|
25730
|
-
}
|
|
25731
|
-
if (typeof header !== "string") {
|
|
25732
|
-
throw new TypeError("content-type header is missing from object");
|
|
25733
|
-
}
|
|
25734
|
-
return header;
|
|
25735
|
-
}
|
|
25736
|
-
function qstring(val) {
|
|
25737
|
-
var str = String(val);
|
|
25738
|
-
if (TOKEN_REGEXP.test(str)) {
|
|
25739
|
-
return str;
|
|
25740
|
-
}
|
|
25741
|
-
if (str.length > 0 && !TEXT_REGEXP.test(str)) {
|
|
25742
|
-
throw new TypeError("invalid parameter value");
|
|
25743
|
-
}
|
|
25744
|
-
return '"' + str.replace(QUOTE_REGEXP, "\\$1") + '"';
|
|
25745
|
-
}
|
|
25746
|
-
function ContentType(type) {
|
|
25747
|
-
this.parameters = /* @__PURE__ */ Object.create(null);
|
|
25748
|
-
this.type = type;
|
|
25749
|
-
}
|
|
25750
|
-
}
|
|
25751
|
-
});
|
|
25752
|
-
|
|
25753
25753
|
// node_modules/etag/index.js
|
|
25754
25754
|
var require_etag = __commonJS({
|
|
25755
25755
|
"node_modules/etag/index.js"(exports, module) {
|
|
@@ -35204,7 +35204,7 @@ var require_mime_types2 = __commonJS({
|
|
|
35204
35204
|
var TEXT_TYPE_REGEXP = /^text\//i;
|
|
35205
35205
|
exports.charset = charset;
|
|
35206
35206
|
exports.charsets = { lookup: charset };
|
|
35207
|
-
exports.contentType =
|
|
35207
|
+
exports.contentType = contentType2;
|
|
35208
35208
|
exports.extension = extension;
|
|
35209
35209
|
exports.extensions = /* @__PURE__ */ Object.create(null);
|
|
35210
35210
|
exports.lookup = lookup;
|
|
@@ -35225,7 +35225,7 @@ var require_mime_types2 = __commonJS({
|
|
|
35225
35225
|
}
|
|
35226
35226
|
return false;
|
|
35227
35227
|
}
|
|
35228
|
-
function
|
|
35228
|
+
function contentType2(str) {
|
|
35229
35229
|
if (!str || typeof str !== "string") {
|
|
35230
35230
|
return false;
|
|
35231
35231
|
}
|
|
@@ -36149,7 +36149,7 @@ var require_utils3 = __commonJS({
|
|
|
36149
36149
|
"node_modules/express/lib/utils.js"(exports) {
|
|
36150
36150
|
"use strict";
|
|
36151
36151
|
var { METHODS } = __require("node:http");
|
|
36152
|
-
var
|
|
36152
|
+
var contentType2 = require_content_type();
|
|
36153
36153
|
var etag = require_etag();
|
|
36154
36154
|
var mime = require_mime_types2();
|
|
36155
36155
|
var proxyaddr = require_proxy_addr();
|
|
@@ -36253,9 +36253,9 @@ var require_utils3 = __commonJS({
|
|
|
36253
36253
|
if (!type || !charset) {
|
|
36254
36254
|
return type;
|
|
36255
36255
|
}
|
|
36256
|
-
var parsed =
|
|
36256
|
+
var parsed = contentType2.parse(type);
|
|
36257
36257
|
parsed.parameters.charset = charset;
|
|
36258
|
-
return
|
|
36258
|
+
return contentType2.format(parsed);
|
|
36259
36259
|
};
|
|
36260
36260
|
function createETagGenerator(options) {
|
|
36261
36261
|
return function generateETag(body, encoding) {
|
|
@@ -37800,14 +37800,14 @@ var require_dist4 = __commonJS({
|
|
|
37800
37800
|
var require_accept = __commonJS({
|
|
37801
37801
|
"node_modules/negotiator/lib/accept.js"(exports, module) {
|
|
37802
37802
|
"use strict";
|
|
37803
|
-
var
|
|
37803
|
+
var contentType2 = require_dist4();
|
|
37804
37804
|
module.exports = parseAccept;
|
|
37805
37805
|
function parseAccept(header) {
|
|
37806
37806
|
var values = [];
|
|
37807
37807
|
var index = 0;
|
|
37808
37808
|
while (index < header.length) {
|
|
37809
37809
|
var start = skipOptionalWhitespace(header, index);
|
|
37810
|
-
var parsed =
|
|
37810
|
+
var parsed = contentType2.parse(header, { comma: true, start });
|
|
37811
37811
|
parsed.type = header.slice(start, start + parsed.type.length);
|
|
37812
37812
|
values.push(parsed);
|
|
37813
37813
|
index = parsed.index + 1;
|
|
@@ -38000,7 +38000,7 @@ var require_encoding = __commonJS({
|
|
|
38000
38000
|
var require_language = __commonJS({
|
|
38001
38001
|
"node_modules/negotiator/lib/language.js"(exports, module) {
|
|
38002
38002
|
"use strict";
|
|
38003
|
-
var
|
|
38003
|
+
var contentType2 = require_dist4();
|
|
38004
38004
|
var parseAccept = require_accept();
|
|
38005
38005
|
module.exports = preferredLanguages;
|
|
38006
38006
|
module.exports.preferredLanguages = preferredLanguages;
|
|
@@ -38037,7 +38037,7 @@ var require_language = __commonJS({
|
|
|
38037
38037
|
return priority;
|
|
38038
38038
|
}
|
|
38039
38039
|
function specify(language, spec, index) {
|
|
38040
|
-
var p = formatLanguage(
|
|
38040
|
+
var p = formatLanguage(contentType2.parse(language), 0);
|
|
38041
38041
|
if (!p) return null;
|
|
38042
38042
|
var s2 = 0;
|
|
38043
38043
|
if (spec.full.toLowerCase() === p.full.toLowerCase()) {
|
|
@@ -38084,7 +38084,7 @@ var require_language = __commonJS({
|
|
|
38084
38084
|
var require_mediaType = __commonJS({
|
|
38085
38085
|
"node_modules/negotiator/lib/mediaType.js"(exports, module) {
|
|
38086
38086
|
"use strict";
|
|
38087
|
-
var
|
|
38087
|
+
var contentType2 = require_dist4();
|
|
38088
38088
|
var parseAcceptHeader = require_accept();
|
|
38089
38089
|
module.exports = preferredMediaTypes;
|
|
38090
38090
|
module.exports.preferredMediaTypes = preferredMediaTypes;
|
|
@@ -38121,7 +38121,7 @@ var require_mediaType = __commonJS({
|
|
|
38121
38121
|
return priority;
|
|
38122
38122
|
}
|
|
38123
38123
|
function specify(type, spec, index) {
|
|
38124
|
-
var p = formatMediaType(
|
|
38124
|
+
var p = formatMediaType(contentType2.parse(type), 0);
|
|
38125
38125
|
var s2 = 0;
|
|
38126
38126
|
if (!p) {
|
|
38127
38127
|
return null;
|
|
@@ -47645,7 +47645,7 @@ var require_mime_types3 = __commonJS({
|
|
|
47645
47645
|
var TEXT_TYPE_REGEXP = /^text\//i;
|
|
47646
47646
|
exports.charset = charset;
|
|
47647
47647
|
exports.charsets = { lookup: charset };
|
|
47648
|
-
exports.contentType =
|
|
47648
|
+
exports.contentType = contentType2;
|
|
47649
47649
|
exports.extension = extension;
|
|
47650
47650
|
exports.extensions = /* @__PURE__ */ Object.create(null);
|
|
47651
47651
|
exports.lookup = lookup;
|
|
@@ -47666,7 +47666,7 @@ var require_mime_types3 = __commonJS({
|
|
|
47666
47666
|
}
|
|
47667
47667
|
return false;
|
|
47668
47668
|
}
|
|
47669
|
-
function
|
|
47669
|
+
function contentType2(str) {
|
|
47670
47670
|
if (!str || typeof str !== "string") {
|
|
47671
47671
|
return false;
|
|
47672
47672
|
}
|
|
@@ -57927,7 +57927,7 @@ var require_mime_types4 = __commonJS({
|
|
|
57927
57927
|
var TEXT_TYPE_REGEXP = /^text\//i;
|
|
57928
57928
|
exports.charset = charset;
|
|
57929
57929
|
exports.charsets = { lookup: charset };
|
|
57930
|
-
exports.contentType =
|
|
57930
|
+
exports.contentType = contentType2;
|
|
57931
57931
|
exports.extension = extension;
|
|
57932
57932
|
exports.extensions = /* @__PURE__ */ Object.create(null);
|
|
57933
57933
|
exports.lookup = lookup;
|
|
@@ -57948,7 +57948,7 @@ var require_mime_types4 = __commonJS({
|
|
|
57948
57948
|
}
|
|
57949
57949
|
return false;
|
|
57950
57950
|
}
|
|
57951
|
-
function
|
|
57951
|
+
function contentType2(str) {
|
|
57952
57952
|
if (!str || typeof str !== "string") {
|
|
57953
57953
|
return false;
|
|
57954
57954
|
}
|
|
@@ -58809,7 +58809,7 @@ var require_response = __commonJS({
|
|
|
58809
58809
|
var fullPath = !opts.root ? resolve(path7) : path7;
|
|
58810
58810
|
return this.sendFile(fullPath, opts, done);
|
|
58811
58811
|
};
|
|
58812
|
-
res.contentType = res.type = function
|
|
58812
|
+
res.contentType = res.type = function contentType2(type) {
|
|
58813
58813
|
var ct = type.indexOf("/") === -1 ? mime.contentType(type) || "application/octet-stream" : type;
|
|
58814
58814
|
return this.set("Content-Type", ct);
|
|
58815
58815
|
};
|
|
@@ -73726,10 +73726,9 @@ var ProgressTokenSchema = union([string2(), number2().int()]);
|
|
|
73726
73726
|
var CursorSchema = string2();
|
|
73727
73727
|
var TaskCreationParamsSchema = looseObject({
|
|
73728
73728
|
/**
|
|
73729
|
-
*
|
|
73730
|
-
* If null, the task has unlimited lifetime until manually cleaned up.
|
|
73729
|
+
* Requested duration in milliseconds to retain task from creation.
|
|
73731
73730
|
*/
|
|
73732
|
-
ttl:
|
|
73731
|
+
ttl: number2().optional(),
|
|
73733
73732
|
/**
|
|
73734
73733
|
* Time in milliseconds to wait between task status requests.
|
|
73735
73734
|
*/
|
|
@@ -74026,7 +74025,11 @@ var ClientCapabilitiesSchema = object({
|
|
|
74026
74025
|
/**
|
|
74027
74026
|
* Present if the client supports task creation.
|
|
74028
74027
|
*/
|
|
74029
|
-
tasks: ClientTasksCapabilitySchema.optional()
|
|
74028
|
+
tasks: ClientTasksCapabilitySchema.optional(),
|
|
74029
|
+
/**
|
|
74030
|
+
* Extensions that the client supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
74031
|
+
*/
|
|
74032
|
+
extensions: record(string2(), AssertObjectSchema).optional()
|
|
74030
74033
|
});
|
|
74031
74034
|
var InitializeRequestParamsSchema = BaseRequestParamsSchema.extend({
|
|
74032
74035
|
/**
|
|
@@ -74087,7 +74090,11 @@ var ServerCapabilitiesSchema = object({
|
|
|
74087
74090
|
/**
|
|
74088
74091
|
* Present if the server supports task creation.
|
|
74089
74092
|
*/
|
|
74090
|
-
tasks: ServerTasksCapabilitySchema.optional()
|
|
74093
|
+
tasks: ServerTasksCapabilitySchema.optional(),
|
|
74094
|
+
/**
|
|
74095
|
+
* Extensions that the server supports. Keys are extension identifiers (vendor-prefix/extension-name).
|
|
74096
|
+
*/
|
|
74097
|
+
extensions: record(string2(), AssertObjectSchema).optional()
|
|
74091
74098
|
});
|
|
74092
74099
|
var InitializeResultSchema = ResultSchema.extend({
|
|
74093
74100
|
/**
|
|
@@ -74280,6 +74287,12 @@ var ResourceSchema = object({
|
|
|
74280
74287
|
* The MIME type of this resource, if known.
|
|
74281
74288
|
*/
|
|
74282
74289
|
mimeType: optional(string2()),
|
|
74290
|
+
/**
|
|
74291
|
+
* The size of the raw resource content, in bytes (i.e., before base64 encoding or any tokenization), if known.
|
|
74292
|
+
*
|
|
74293
|
+
* This can be used by Hosts to display file sizes and estimate context window usage.
|
|
74294
|
+
*/
|
|
74295
|
+
size: optional(number2()),
|
|
74283
74296
|
/**
|
|
74284
74297
|
* Optional annotations for the client.
|
|
74285
74298
|
*/
|
|
@@ -75221,8 +75234,17 @@ var UrlElicitationRequiredError = class extends McpError {
|
|
|
75221
75234
|
};
|
|
75222
75235
|
|
|
75223
75236
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js
|
|
75237
|
+
var STDIO_DEFAULT_MAX_BUFFER_SIZE = 10 * 1024 * 1024;
|
|
75224
75238
|
var ReadBuffer = class {
|
|
75239
|
+
constructor(options) {
|
|
75240
|
+
this._maxBufferSize = options?.maxBufferSize ?? STDIO_DEFAULT_MAX_BUFFER_SIZE;
|
|
75241
|
+
}
|
|
75225
75242
|
append(chunk) {
|
|
75243
|
+
const newSize = (this._buffer?.length ?? 0) + chunk.length;
|
|
75244
|
+
if (newSize > this._maxBufferSize) {
|
|
75245
|
+
this.clear();
|
|
75246
|
+
throw new Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);
|
|
75247
|
+
}
|
|
75226
75248
|
this._buffer = this._buffer ? Buffer.concat([this._buffer, chunk]) : chunk;
|
|
75227
75249
|
}
|
|
75228
75250
|
readMessage() {
|
|
@@ -75250,18 +75272,24 @@ function serializeMessage(message) {
|
|
|
75250
75272
|
|
|
75251
75273
|
// node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js
|
|
75252
75274
|
var StdioServerTransport = class {
|
|
75253
|
-
constructor(_stdin = process3.stdin, _stdout = process3.stdout) {
|
|
75275
|
+
constructor(_stdin = process3.stdin, _stdout = process3.stdout, options) {
|
|
75254
75276
|
this._stdin = _stdin;
|
|
75255
75277
|
this._stdout = _stdout;
|
|
75256
|
-
this._readBuffer = new ReadBuffer();
|
|
75257
75278
|
this._started = false;
|
|
75258
75279
|
this._ondata = (chunk) => {
|
|
75259
|
-
|
|
75260
|
-
|
|
75280
|
+
try {
|
|
75281
|
+
this._readBuffer.append(chunk);
|
|
75282
|
+
this.processReadBuffer();
|
|
75283
|
+
} catch (error51) {
|
|
75284
|
+
this.onerror?.(error51);
|
|
75285
|
+
this.close().catch(() => {
|
|
75286
|
+
});
|
|
75287
|
+
}
|
|
75261
75288
|
};
|
|
75262
75289
|
this._onerror = (error51) => {
|
|
75263
75290
|
this.onerror?.(error51);
|
|
75264
75291
|
};
|
|
75292
|
+
this._readBuffer = new ReadBuffer({ maxBufferSize: options?.maxBufferSize });
|
|
75265
75293
|
}
|
|
75266
75294
|
/**
|
|
75267
75295
|
* Starts listening for messages on stdin.
|
|
@@ -75580,7 +75608,12 @@ var OAuthTokensSchema = object({
|
|
|
75580
75608
|
token_type: string2(),
|
|
75581
75609
|
expires_in: coerce_exports.number().optional(),
|
|
75582
75610
|
scope: string2().optional(),
|
|
75583
|
-
refresh_token: string2().optional()
|
|
75611
|
+
refresh_token: string2().optional(),
|
|
75612
|
+
/**
|
|
75613
|
+
* Not part of the wire format: the authorization server this value was obtained from, added by
|
|
75614
|
+
* the client's `auth()` before it is stored and compared when it is read back.
|
|
75615
|
+
*/
|
|
75616
|
+
issuer: string2().optional().catch(void 0)
|
|
75584
75617
|
}).strip();
|
|
75585
75618
|
var OAuthErrorResponseSchema = object({
|
|
75586
75619
|
error: string2(),
|
|
@@ -75610,7 +75643,12 @@ var OAuthClientInformationSchema = object({
|
|
|
75610
75643
|
client_id: string2(),
|
|
75611
75644
|
client_secret: string2().optional(),
|
|
75612
75645
|
client_id_issued_at: number2().optional(),
|
|
75613
|
-
client_secret_expires_at: number2().optional()
|
|
75646
|
+
client_secret_expires_at: number2().optional(),
|
|
75647
|
+
/**
|
|
75648
|
+
* Not part of the wire format: the authorization server this value was obtained from, added by
|
|
75649
|
+
* the client's `auth()` before it is stored and compared when it is read back.
|
|
75650
|
+
*/
|
|
75651
|
+
issuer: string2().optional().catch(void 0)
|
|
75614
75652
|
}).strip();
|
|
75615
75653
|
var OAuthClientInformationFullSchema = OAuthClientMetadataSchema.merge(OAuthClientInformationSchema);
|
|
75616
75654
|
var OAuthClientRegistrationErrorSchema = object({
|
|
@@ -75750,12 +75788,12 @@ var AUTHORIZATION_CODE_RESPONSE_TYPE = "code";
|
|
|
75750
75788
|
var AUTHORIZATION_CODE_CHALLENGE_METHOD = "S256";
|
|
75751
75789
|
function selectClientAuthMethod(clientInformation, supportedMethods) {
|
|
75752
75790
|
const hasClientSecret = clientInformation.client_secret !== void 0;
|
|
75753
|
-
if (supportedMethods.length === 0) {
|
|
75754
|
-
return hasClientSecret ? "client_secret_post" : "none";
|
|
75755
|
-
}
|
|
75756
|
-
if ("token_endpoint_auth_method" in clientInformation && clientInformation.token_endpoint_auth_method && isClientAuthMethod(clientInformation.token_endpoint_auth_method) && supportedMethods.includes(clientInformation.token_endpoint_auth_method)) {
|
|
75791
|
+
if ("token_endpoint_auth_method" in clientInformation && clientInformation.token_endpoint_auth_method && isClientAuthMethod(clientInformation.token_endpoint_auth_method) && (supportedMethods.length === 0 || supportedMethods.includes(clientInformation.token_endpoint_auth_method))) {
|
|
75757
75792
|
return clientInformation.token_endpoint_auth_method;
|
|
75758
75793
|
}
|
|
75794
|
+
if (supportedMethods.length === 0) {
|
|
75795
|
+
return hasClientSecret ? "client_secret_basic" : "none";
|
|
75796
|
+
}
|
|
75759
75797
|
if (hasClientSecret && supportedMethods.includes("client_secret_basic")) {
|
|
75760
75798
|
return "client_secret_basic";
|
|
75761
75799
|
}
|
|
@@ -75812,6 +75850,26 @@ async function parseErrorResponse(input) {
|
|
|
75812
75850
|
return new ServerError(errorMessage);
|
|
75813
75851
|
}
|
|
75814
75852
|
}
|
|
75853
|
+
function issuersMatch(a, b) {
|
|
75854
|
+
let [x2, y] = [a, b];
|
|
75855
|
+
try {
|
|
75856
|
+
[x2, y] = [new URL(a).href, new URL(b).href];
|
|
75857
|
+
} catch {
|
|
75858
|
+
}
|
|
75859
|
+
return x2 === y || x2.endsWith("/") && x2.slice(0, -1) === y || y.endsWith("/") && y.slice(0, -1) === x2;
|
|
75860
|
+
}
|
|
75861
|
+
function discardIfIssuerMismatch(stored, issuer) {
|
|
75862
|
+
if (!stored)
|
|
75863
|
+
return void 0;
|
|
75864
|
+
if (typeof stored.issuer !== "string")
|
|
75865
|
+
return stored.issuer == null ? stored : { ...stored, issuer: void 0 };
|
|
75866
|
+
return issuersMatch(stored.issuer, issuer) ? stored : void 0;
|
|
75867
|
+
}
|
|
75868
|
+
var TokenResponseSchema = OAuthTokensSchema.omit({ issuer: true });
|
|
75869
|
+
var RegistrationResponseSchema = OAuthClientInformationFullSchema.omit({ issuer: true });
|
|
75870
|
+
function boundElsewhereError(stored, issuer) {
|
|
75871
|
+
return new Error(`OAuth client information is bound to authorization server ${stored.issuer} and is not presented to ${issuer}. Clear the stored client information, or correct \`expectedIssuer\`, if the authorization server has moved.`);
|
|
75872
|
+
}
|
|
75815
75873
|
async function auth(provider, options) {
|
|
75816
75874
|
try {
|
|
75817
75875
|
return await authInternal(provider, options);
|
|
@@ -75827,23 +75885,62 @@ async function auth(provider, options) {
|
|
|
75827
75885
|
}
|
|
75828
75886
|
}
|
|
75829
75887
|
async function authInternal(provider, { serverUrl, authorizationCode, scope, resourceMetadataUrl, fetchFn }) {
|
|
75888
|
+
const cachedState = await provider.discoveryState?.();
|
|
75830
75889
|
let resourceMetadata;
|
|
75831
75890
|
let authorizationServerUrl;
|
|
75832
|
-
|
|
75833
|
-
|
|
75834
|
-
|
|
75835
|
-
|
|
75891
|
+
let metadata;
|
|
75892
|
+
let effectiveResourceMetadataUrl = resourceMetadataUrl;
|
|
75893
|
+
if (!effectiveResourceMetadataUrl && cachedState?.resourceMetadataUrl) {
|
|
75894
|
+
effectiveResourceMetadataUrl = new URL(cachedState.resourceMetadataUrl);
|
|
75895
|
+
}
|
|
75896
|
+
if (cachedState?.authorizationServerUrl) {
|
|
75897
|
+
authorizationServerUrl = cachedState.authorizationServerUrl;
|
|
75898
|
+
resourceMetadata = cachedState.resourceMetadata;
|
|
75899
|
+
metadata = cachedState.authorizationServerMetadata ?? await discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn });
|
|
75900
|
+
if (!resourceMetadata) {
|
|
75901
|
+
try {
|
|
75902
|
+
resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl: effectiveResourceMetadataUrl }, fetchFn);
|
|
75903
|
+
} catch {
|
|
75904
|
+
}
|
|
75836
75905
|
}
|
|
75837
|
-
|
|
75838
|
-
|
|
75839
|
-
|
|
75840
|
-
|
|
75906
|
+
if (metadata !== cachedState.authorizationServerMetadata || resourceMetadata !== cachedState.resourceMetadata) {
|
|
75907
|
+
await provider.saveDiscoveryState?.({
|
|
75908
|
+
authorizationServerUrl: String(authorizationServerUrl),
|
|
75909
|
+
resourceMetadataUrl: effectiveResourceMetadataUrl?.toString(),
|
|
75910
|
+
resourceMetadata,
|
|
75911
|
+
authorizationServerMetadata: metadata
|
|
75912
|
+
});
|
|
75913
|
+
}
|
|
75914
|
+
} else {
|
|
75915
|
+
const serverInfo = await discoverOAuthServerInfo(serverUrl, { resourceMetadataUrl: effectiveResourceMetadataUrl, fetchFn });
|
|
75916
|
+
authorizationServerUrl = serverInfo.authorizationServerUrl;
|
|
75917
|
+
metadata = serverInfo.authorizationServerMetadata;
|
|
75918
|
+
resourceMetadata = serverInfo.resourceMetadata;
|
|
75919
|
+
await provider.saveDiscoveryState?.({
|
|
75920
|
+
authorizationServerUrl: String(authorizationServerUrl),
|
|
75921
|
+
resourceMetadataUrl: effectiveResourceMetadataUrl?.toString(),
|
|
75922
|
+
resourceMetadata,
|
|
75923
|
+
authorizationServerMetadata: metadata
|
|
75924
|
+
});
|
|
75841
75925
|
}
|
|
75842
|
-
const
|
|
75843
|
-
const
|
|
75844
|
-
|
|
75845
|
-
|
|
75846
|
-
|
|
75926
|
+
const issuer = String(authorizationServerUrl);
|
|
75927
|
+
const selectedResource = await selectResourceURL(serverUrl, provider, resourceMetadata);
|
|
75928
|
+
const resource = selectedResource && resourceMetadata && !provider.validateResourceURL ? resourceMetadata.resource : selectedResource;
|
|
75929
|
+
const resolvedScope = scope || resourceMetadata?.scopes_supported?.join(" ") || provider.clientMetadata.scope;
|
|
75930
|
+
const storedClientInformation = await Promise.resolve(provider.clientInformation());
|
|
75931
|
+
let clientInformation = discardIfIssuerMismatch(storedClientInformation, issuer);
|
|
75932
|
+
const canRegisterAgain = provider.saveClientInformation !== void 0 && !!provider.redirectUrl;
|
|
75933
|
+
if (storedClientInformation && !clientInformation && !canRegisterAgain) {
|
|
75934
|
+
throw boundElsewhereError(storedClientInformation, issuer);
|
|
75935
|
+
}
|
|
75936
|
+
const unstampedClientInformation = clientInformation?.issuer == null ? clientInformation : void 0;
|
|
75937
|
+
const bindClientInformation = async () => {
|
|
75938
|
+
try {
|
|
75939
|
+
if (unstampedClientInformation)
|
|
75940
|
+
await provider.saveClientInformation?.({ ...unstampedClientInformation, issuer });
|
|
75941
|
+
} catch {
|
|
75942
|
+
}
|
|
75943
|
+
};
|
|
75847
75944
|
if (!clientInformation) {
|
|
75848
75945
|
if (authorizationCode !== void 0) {
|
|
75849
75946
|
throw new Error("Existing OAuth client information is required when exchanging an authorization code");
|
|
@@ -75855,9 +75952,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
75855
75952
|
}
|
|
75856
75953
|
const shouldUseUrlBasedClientId = supportsUrlBasedClientId && clientMetadataUrl;
|
|
75857
75954
|
if (shouldUseUrlBasedClientId) {
|
|
75858
|
-
clientInformation = {
|
|
75859
|
-
client_id: clientMetadataUrl
|
|
75860
|
-
};
|
|
75955
|
+
clientInformation = { client_id: clientMetadataUrl, issuer };
|
|
75861
75956
|
await provider.saveClientInformation?.(clientInformation);
|
|
75862
75957
|
} else {
|
|
75863
75958
|
if (!provider.saveClientInformation) {
|
|
@@ -75866,10 +75961,11 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
75866
75961
|
const fullInformation = await registerClient(authorizationServerUrl, {
|
|
75867
75962
|
metadata,
|
|
75868
75963
|
clientMetadata: provider.clientMetadata,
|
|
75964
|
+
scope: resolvedScope,
|
|
75869
75965
|
fetchFn
|
|
75870
75966
|
});
|
|
75871
|
-
|
|
75872
|
-
clientInformation
|
|
75967
|
+
clientInformation = { ...fullInformation, issuer };
|
|
75968
|
+
await provider.saveClientInformation(clientInformation);
|
|
75873
75969
|
}
|
|
75874
75970
|
}
|
|
75875
75971
|
const nonInteractiveFlow = !provider.redirectUrl;
|
|
@@ -75880,10 +75976,14 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
75880
75976
|
authorizationCode,
|
|
75881
75977
|
fetchFn
|
|
75882
75978
|
});
|
|
75883
|
-
await
|
|
75979
|
+
await bindClientInformation();
|
|
75980
|
+
await provider.saveTokens({ ...tokens2, issuer });
|
|
75884
75981
|
return "AUTHORIZED";
|
|
75885
75982
|
}
|
|
75886
|
-
const tokens = await provider.tokens();
|
|
75983
|
+
const tokens = discardIfIssuerMismatch(await provider.tokens(), issuer);
|
|
75984
|
+
if (tokens?.refresh_token && tokens.issuer == null) {
|
|
75985
|
+
console.warn("[mcp-sdk] stored OAuth tokens have no 'issuer' property (saved by an earlier version, or by a provider that does not keep it) and are used as-is; make sure your OAuthClientProvider stores what saveTokens() and saveClientInformation() receive unchanged.");
|
|
75986
|
+
}
|
|
75887
75987
|
if (tokens?.refresh_token) {
|
|
75888
75988
|
try {
|
|
75889
75989
|
const newTokens = await refreshAuthorization(authorizationServerUrl, {
|
|
@@ -75894,7 +75994,8 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
75894
75994
|
addClientAuthentication: provider.addClientAuthentication,
|
|
75895
75995
|
fetchFn
|
|
75896
75996
|
});
|
|
75897
|
-
await
|
|
75997
|
+
await bindClientInformation();
|
|
75998
|
+
await provider.saveTokens({ ...newTokens, issuer });
|
|
75898
75999
|
return "AUTHORIZED";
|
|
75899
76000
|
} catch (error51) {
|
|
75900
76001
|
if (!(error51 instanceof OAuthError) || error51 instanceof ServerError) {
|
|
@@ -75909,7 +76010,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope, res
|
|
|
75909
76010
|
clientInformation,
|
|
75910
76011
|
state,
|
|
75911
76012
|
redirectUrl: provider.redirectUrl,
|
|
75912
|
-
scope:
|
|
76013
|
+
scope: resolvedScope,
|
|
75913
76014
|
resource
|
|
75914
76015
|
});
|
|
75915
76016
|
await provider.saveCodeVerifier(codeVerifier);
|
|
@@ -76097,6 +76198,29 @@ async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fet
|
|
|
76097
76198
|
}
|
|
76098
76199
|
return void 0;
|
|
76099
76200
|
}
|
|
76201
|
+
async function discoverOAuthServerInfo(serverUrl, opts) {
|
|
76202
|
+
let resourceMetadata;
|
|
76203
|
+
let authorizationServerUrl;
|
|
76204
|
+
try {
|
|
76205
|
+
resourceMetadata = await discoverOAuthProtectedResourceMetadata(serverUrl, { resourceMetadataUrl: opts?.resourceMetadataUrl }, opts?.fetchFn);
|
|
76206
|
+
if (resourceMetadata.authorization_servers && resourceMetadata.authorization_servers.length > 0) {
|
|
76207
|
+
authorizationServerUrl = resourceMetadata.authorization_servers[0];
|
|
76208
|
+
}
|
|
76209
|
+
} catch {
|
|
76210
|
+
}
|
|
76211
|
+
if (!authorizationServerUrl) {
|
|
76212
|
+
authorizationServerUrl = String(new URL("/", serverUrl));
|
|
76213
|
+
}
|
|
76214
|
+
const authorizationServerMetadata = await discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn: opts?.fetchFn });
|
|
76215
|
+
return {
|
|
76216
|
+
authorizationServerUrl,
|
|
76217
|
+
authorizationServerMetadata,
|
|
76218
|
+
resourceMetadata
|
|
76219
|
+
};
|
|
76220
|
+
}
|
|
76221
|
+
function resourceIndicatorToString(resource) {
|
|
76222
|
+
return typeof resource === "string" ? resource : resource.href;
|
|
76223
|
+
}
|
|
76100
76224
|
async function startAuthorization(authorizationServerUrl, { metadata, clientInformation, redirectUrl, scope, state, resource }) {
|
|
76101
76225
|
let authorizationUrl;
|
|
76102
76226
|
if (metadata) {
|
|
@@ -76128,7 +76252,7 @@ async function startAuthorization(authorizationServerUrl, { metadata, clientInfo
|
|
|
76128
76252
|
authorizationUrl.searchParams.append("prompt", "consent");
|
|
76129
76253
|
}
|
|
76130
76254
|
if (resource) {
|
|
76131
|
-
authorizationUrl.searchParams.set("resource", resource
|
|
76255
|
+
authorizationUrl.searchParams.set("resource", resourceIndicatorToString(resource));
|
|
76132
76256
|
}
|
|
76133
76257
|
return { authorizationUrl, codeVerifier };
|
|
76134
76258
|
}
|
|
@@ -76147,7 +76271,7 @@ async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequ
|
|
|
76147
76271
|
Accept: "application/json"
|
|
76148
76272
|
});
|
|
76149
76273
|
if (resource) {
|
|
76150
|
-
tokenRequestParams.set("resource", resource
|
|
76274
|
+
tokenRequestParams.set("resource", resourceIndicatorToString(resource));
|
|
76151
76275
|
}
|
|
76152
76276
|
if (addClientAuthentication) {
|
|
76153
76277
|
await addClientAuthentication(headers, tokenRequestParams, tokenUrl, metadata);
|
|
@@ -76164,7 +76288,7 @@ async function executeTokenRequest(authorizationServerUrl, { metadata, tokenRequ
|
|
|
76164
76288
|
if (!response.ok) {
|
|
76165
76289
|
throw await parseErrorResponse(response);
|
|
76166
76290
|
}
|
|
76167
|
-
return
|
|
76291
|
+
return TokenResponseSchema.parse(await response.json());
|
|
76168
76292
|
}
|
|
76169
76293
|
async function refreshAuthorization(authorizationServerUrl, { metadata, clientInformation, refreshToken, resource, addClientAuthentication, fetchFn }) {
|
|
76170
76294
|
const tokenRequestParams = new URLSearchParams({
|
|
@@ -76182,6 +76306,15 @@ async function refreshAuthorization(authorizationServerUrl, { metadata, clientIn
|
|
|
76182
76306
|
return { refresh_token: refreshToken, ...tokens };
|
|
76183
76307
|
}
|
|
76184
76308
|
async function fetchToken(provider, authorizationServerUrl, { metadata, resource, authorizationCode, fetchFn } = {}) {
|
|
76309
|
+
const readClientInformation = async () => {
|
|
76310
|
+
const storedClientInformation = await provider.clientInformation();
|
|
76311
|
+
const checked = discardIfIssuerMismatch(storedClientInformation, String(authorizationServerUrl));
|
|
76312
|
+
if (storedClientInformation && !checked) {
|
|
76313
|
+
throw boundElsewhereError(storedClientInformation, String(authorizationServerUrl));
|
|
76314
|
+
}
|
|
76315
|
+
return checked;
|
|
76316
|
+
};
|
|
76317
|
+
let clientInformation = await readClientInformation();
|
|
76185
76318
|
const scope = provider.clientMetadata.scope;
|
|
76186
76319
|
let tokenRequestParams;
|
|
76187
76320
|
if (provider.prepareTokenRequest) {
|
|
@@ -76197,17 +76330,17 @@ async function fetchToken(provider, authorizationServerUrl, { metadata, resource
|
|
|
76197
76330
|
const codeVerifier = await provider.codeVerifier();
|
|
76198
76331
|
tokenRequestParams = prepareAuthorizationCodeRequest(authorizationCode, codeVerifier, provider.redirectUrl);
|
|
76199
76332
|
}
|
|
76200
|
-
|
|
76333
|
+
clientInformation ?? (clientInformation = await readClientInformation());
|
|
76201
76334
|
return executeTokenRequest(authorizationServerUrl, {
|
|
76202
76335
|
metadata,
|
|
76203
76336
|
tokenRequestParams,
|
|
76204
|
-
clientInformation
|
|
76337
|
+
clientInformation,
|
|
76205
76338
|
addClientAuthentication: provider.addClientAuthentication,
|
|
76206
76339
|
resource,
|
|
76207
76340
|
fetchFn
|
|
76208
76341
|
});
|
|
76209
76342
|
}
|
|
76210
|
-
async function registerClient(authorizationServerUrl, { metadata, clientMetadata, fetchFn }) {
|
|
76343
|
+
async function registerClient(authorizationServerUrl, { metadata, clientMetadata, scope, fetchFn }) {
|
|
76211
76344
|
let registrationUrl;
|
|
76212
76345
|
if (metadata) {
|
|
76213
76346
|
if (!metadata.registration_endpoint) {
|
|
@@ -76222,12 +76355,15 @@ async function registerClient(authorizationServerUrl, { metadata, clientMetadata
|
|
|
76222
76355
|
headers: {
|
|
76223
76356
|
"Content-Type": "application/json"
|
|
76224
76357
|
},
|
|
76225
|
-
body: JSON.stringify(
|
|
76358
|
+
body: JSON.stringify({
|
|
76359
|
+
...clientMetadata,
|
|
76360
|
+
...scope !== void 0 ? { scope } : {}
|
|
76361
|
+
})
|
|
76226
76362
|
});
|
|
76227
76363
|
if (!response.ok) {
|
|
76228
76364
|
throw await parseErrorResponse(response);
|
|
76229
76365
|
}
|
|
76230
|
-
return
|
|
76366
|
+
return RegistrationResponseSchema.parse(await response.json());
|
|
76231
76367
|
}
|
|
76232
76368
|
|
|
76233
76369
|
// src/lib/utils.ts
|
|
@@ -76507,7 +76643,7 @@ async function selectCallbackPort(serverUrl, specifiedPort, _unused) {
|
|
|
76507
76643
|
}
|
|
76508
76644
|
|
|
76509
76645
|
// src/lib/config.ts
|
|
76510
|
-
var MCP_WORDPRESS_REMOTE_VERSION = "0.5.
|
|
76646
|
+
var MCP_WORDPRESS_REMOTE_VERSION = "0.5.2";
|
|
76511
76647
|
function parsePositiveIntEnv(value, defaultValue) {
|
|
76512
76648
|
if (!value) {
|
|
76513
76649
|
return defaultValue;
|
|
@@ -76577,7 +76713,7 @@ var CONFIG = {
|
|
|
76577
76713
|
NODE_ENV: process.env.NODE_ENV || "development",
|
|
76578
76714
|
// Proxy Configuration
|
|
76579
76715
|
USE_SYSTEM_PROXY: process.env.USE_SYSTEM_PROXY === "true"
|
|
76580
|
-
// Enable system proxy detection (PAC
|
|
76716
|
+
// Enable macOS system proxy detection (PAC file, system SOCKS)
|
|
76581
76717
|
};
|
|
76582
76718
|
var getConfig = () => ({
|
|
76583
76719
|
/** WordPress site API endpoint */
|
|
@@ -76944,6 +77080,11 @@ async function doInitializeProxy(detectMacOs) {
|
|
|
76944
77080
|
logger.info(`Proxy configured from environment: ${sanitizeProxyUrl(envProxy.url)}`, "PROXY");
|
|
76945
77081
|
return;
|
|
76946
77082
|
}
|
|
77083
|
+
if (!getConfig().useSystemProxy) {
|
|
77084
|
+
logger.debug("No proxy configured (system proxy detection disabled)", "PROXY");
|
|
77085
|
+
proxyConfig = { type: "none" };
|
|
77086
|
+
return;
|
|
77087
|
+
}
|
|
76947
77088
|
const macProxy = detectMacOs();
|
|
76948
77089
|
if (macProxy?.pacUrl) {
|
|
76949
77090
|
try {
|
|
@@ -77056,11 +77197,7 @@ async function setupFetchPolyfill() {
|
|
|
77056
77197
|
} else {
|
|
77057
77198
|
logger.info("Using native fetch API", "SYSTEM");
|
|
77058
77199
|
}
|
|
77059
|
-
|
|
77060
|
-
await initializeProxy();
|
|
77061
|
-
} else {
|
|
77062
|
-
logger.debug("System proxy support disabled (USE_SYSTEM_PROXY=false)", "PROXY");
|
|
77063
|
-
}
|
|
77200
|
+
await initializeProxy();
|
|
77064
77201
|
}
|
|
77065
77202
|
async function proxyFetch(url2, init) {
|
|
77066
77203
|
const headers = new Headers(init?.headers);
|
|
@@ -77068,9 +77205,6 @@ async function proxyFetch(url2, init) {
|
|
|
77068
77205
|
headers.set("User-Agent", clientProduct ? `${clientProduct} ${PROXY_PRODUCT}` : PROXY_PRODUCT);
|
|
77069
77206
|
}
|
|
77070
77207
|
init = { ...init, headers };
|
|
77071
|
-
if (!getConfig().useSystemProxy) {
|
|
77072
|
-
return fetch(url2, init);
|
|
77073
|
-
}
|
|
77074
77208
|
const agent = await getAgentForUrl(url2);
|
|
77075
77209
|
if (agent) {
|
|
77076
77210
|
const nodeFetch = (await Promise.resolve().then(() => (init_src(), src_exports))).default;
|
|
@@ -77082,6 +77216,23 @@ async function proxyFetch(url2, init) {
|
|
|
77082
77216
|
// src/lib/wordpress-transport.ts
|
|
77083
77217
|
import { Readable } from "node:stream";
|
|
77084
77218
|
|
|
77219
|
+
// node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js
|
|
77220
|
+
var import_content_type = __toESM(require_content_type(), 1);
|
|
77221
|
+
function mediaTypeEssence(header) {
|
|
77222
|
+
if (!header) {
|
|
77223
|
+
return void 0;
|
|
77224
|
+
}
|
|
77225
|
+
try {
|
|
77226
|
+
return import_content_type.default.parse(header).type;
|
|
77227
|
+
} catch {
|
|
77228
|
+
const essence = (header.split(";", 1)[0] ?? "").trim().toLowerCase();
|
|
77229
|
+
if (essence === "" || header.slice(essence.length).includes(",")) {
|
|
77230
|
+
return void 0;
|
|
77231
|
+
}
|
|
77232
|
+
return essence;
|
|
77233
|
+
}
|
|
77234
|
+
}
|
|
77235
|
+
|
|
77085
77236
|
// node_modules/eventsource-parser/dist/stream.js
|
|
77086
77237
|
var EventSourceParserStream = class extends TransformStream {
|
|
77087
77238
|
constructor({ onError, onRetry, onComment } = {}) {
|
|
@@ -77422,11 +77573,12 @@ var StreamableHTTPClientTransport = class {
|
|
|
77422
77573
|
}
|
|
77423
77574
|
const messages = Array.isArray(message) ? message : [message];
|
|
77424
77575
|
const hasRequests = messages.filter((msg) => "method" in msg && "id" in msg && msg.id !== void 0).length > 0;
|
|
77425
|
-
const
|
|
77576
|
+
const contentType2 = response.headers.get("content-type");
|
|
77577
|
+
const responseMediaType = mediaTypeEssence(contentType2);
|
|
77426
77578
|
if (hasRequests) {
|
|
77427
|
-
if (
|
|
77579
|
+
if (responseMediaType === "text/event-stream") {
|
|
77428
77580
|
this._handleSseStream(response.body, { onresumptiontoken }, false);
|
|
77429
|
-
} else if (
|
|
77581
|
+
} else if (responseMediaType === "application/json") {
|
|
77430
77582
|
const data = await response.json();
|
|
77431
77583
|
const responseMessages = Array.isArray(data) ? data.map((msg) => JSONRPCMessageSchema.parse(msg)) : [JSONRPCMessageSchema.parse(data)];
|
|
77432
77584
|
for (const msg of responseMessages) {
|
|
@@ -77434,7 +77586,7 @@ var StreamableHTTPClientTransport = class {
|
|
|
77434
77586
|
}
|
|
77435
77587
|
} else {
|
|
77436
77588
|
await response.body?.cancel();
|
|
77437
|
-
throw new StreamableHTTPError(-1, `Unexpected content type: ${
|
|
77589
|
+
throw new StreamableHTTPError(-1, `Unexpected content type: ${contentType2}`);
|
|
77438
77590
|
}
|
|
77439
77591
|
} else {
|
|
77440
77592
|
await response.body?.cancel();
|
|
@@ -78647,7 +78799,11 @@ var OAuthCallbackServer = class {
|
|
|
78647
78799
|
async start() {
|
|
78648
78800
|
return new Promise((resolve, reject) => {
|
|
78649
78801
|
try {
|
|
78650
|
-
this.server = this.app.listen(this.options.port, this.options.host, () => {
|
|
78802
|
+
this.server = this.app.listen(this.options.port, this.options.host, (error51) => {
|
|
78803
|
+
if (error51) {
|
|
78804
|
+
reject(error51);
|
|
78805
|
+
return;
|
|
78806
|
+
}
|
|
78651
78807
|
logger.oauth(
|
|
78652
78808
|
`OAuth callback server listening on http://${this.options.host}:${this.options.port}`
|
|
78653
78809
|
);
|
|
@@ -79790,6 +79946,19 @@ async function getOAuthTokens() {
|
|
|
79790
79946
|
return null;
|
|
79791
79947
|
}
|
|
79792
79948
|
}
|
|
79949
|
+
async function discardRejectedOAuthToken(authorization) {
|
|
79950
|
+
if (!CONFIG.OAUTH_ENABLED || CONFIG.JWT_TOKEN) {
|
|
79951
|
+
return false;
|
|
79952
|
+
}
|
|
79953
|
+
const serverUrlHash = generateServerUrlHash(CONFIG.WP_API_URL);
|
|
79954
|
+
const tokens = await readTokens(serverUrlHash);
|
|
79955
|
+
if (!tokens || authorization !== `Bearer ${tokens.access_token}`) {
|
|
79956
|
+
return false;
|
|
79957
|
+
}
|
|
79958
|
+
logger.warn("WordPress rejected the stored OAuth token; signing in again", "AUTH");
|
|
79959
|
+
await deleteTokens(serverUrlHash);
|
|
79960
|
+
return true;
|
|
79961
|
+
}
|
|
79793
79962
|
function getCurrentApiUrl() {
|
|
79794
79963
|
return process.env.WP_API_URL || CONFIG.WP_API_URL;
|
|
79795
79964
|
}
|
|
@@ -79889,6 +80058,9 @@ function collectHeaderParams(schema, path6 = []) {
|
|
|
79889
80058
|
return [...own, ...collectHeaderParams(child, [...path6, key])];
|
|
79890
80059
|
});
|
|
79891
80060
|
}
|
|
80061
|
+
function isBearerChallenge(challenge) {
|
|
80062
|
+
return challenge === null || /^Bearer\b/i.test(challenge);
|
|
80063
|
+
}
|
|
79892
80064
|
function valueAtPath(value, path6) {
|
|
79893
80065
|
return path6.reduce(
|
|
79894
80066
|
(node, key) => node && typeof node === "object" ? node[key] : void 0,
|
|
@@ -79898,25 +80070,24 @@ function valueAtPath(value, path6) {
|
|
|
79898
80070
|
function createWordPressTransport(onFailure) {
|
|
79899
80071
|
const inflight = /* @__PURE__ */ new Map();
|
|
79900
80072
|
const toolHeaders = /* @__PURE__ */ new Map();
|
|
79901
|
-
const
|
|
80073
|
+
const send = async (url2, init, retried) => {
|
|
79902
80074
|
const message = typeof init?.body === "string" ? JSON.parse(init.body) : void 0;
|
|
79903
80075
|
const request = message && "method" in message && "id" in message ? message : void 0;
|
|
79904
80076
|
const controller = new AbortController();
|
|
79905
|
-
const abort = () => controller.abort();
|
|
79906
80077
|
let cancelled = false;
|
|
79907
80078
|
const cancel = () => {
|
|
79908
80079
|
cancelled = true;
|
|
79909
|
-
abort();
|
|
80080
|
+
controller.abort();
|
|
79910
80081
|
};
|
|
79911
80082
|
if (request) inflight.set(request.id, cancel);
|
|
79912
|
-
init?.signal?.addEventListener("abort",
|
|
79913
|
-
if (init?.signal?.aborted)
|
|
80083
|
+
init?.signal?.addEventListener("abort", cancel, { once: true });
|
|
80084
|
+
if (init?.signal?.aborted) cancel();
|
|
79914
80085
|
const timeoutMs = message && "method" in message && message.method === "initialize" ? CONFIG.WP_API_INIT_TIMEOUT : CONFIG.WP_API_TIMEOUT;
|
|
79915
80086
|
let timedOut = false;
|
|
79916
80087
|
let timer;
|
|
79917
80088
|
const cleanup = () => {
|
|
79918
80089
|
clearTimeout(timer);
|
|
79919
|
-
init?.signal?.removeEventListener("abort",
|
|
80090
|
+
init?.signal?.removeEventListener("abort", cancel);
|
|
79920
80091
|
if (request && inflight.get(request.id) === cancel) inflight.delete(request.id);
|
|
79921
80092
|
};
|
|
79922
80093
|
const failure = (error51) => {
|
|
@@ -79965,17 +80136,28 @@ function createWordPressTransport(onFailure) {
|
|
|
79965
80136
|
headers,
|
|
79966
80137
|
signal: controller.signal
|
|
79967
80138
|
});
|
|
80139
|
+
if (response.status === 401 && !retried && isBearerChallenge(response.headers.get("WWW-Authenticate")) && await discardRejectedOAuthToken(headers.get("Authorization"))) {
|
|
80140
|
+
const unread = response.body;
|
|
80141
|
+
if (typeof unread?.cancel === "function") await unread.cancel();
|
|
80142
|
+
else unread?.destroy?.();
|
|
80143
|
+
cleanup();
|
|
80144
|
+
if (cancelled) return new Response(null, { status: 202 });
|
|
80145
|
+
return send(url2, init, true);
|
|
80146
|
+
}
|
|
79968
80147
|
const body = response.body && typeof response.body.getReader !== "function" ? Readable.toWeb(response.body) : response.body;
|
|
79969
80148
|
const reader = body?.getReader();
|
|
80149
|
+
let released = false;
|
|
79970
80150
|
const stream = reader ? new ReadableStream({
|
|
79971
80151
|
async pull(output) {
|
|
79972
80152
|
try {
|
|
79973
80153
|
const { value, done } = await reader.read();
|
|
80154
|
+
if (released) return;
|
|
79974
80155
|
if (done) {
|
|
79975
80156
|
cleanup();
|
|
79976
80157
|
output.close();
|
|
79977
80158
|
} else output.enqueue(value);
|
|
79978
80159
|
} catch (error51) {
|
|
80160
|
+
if (released) return;
|
|
79979
80161
|
if (cancelled) {
|
|
79980
80162
|
cleanup();
|
|
79981
80163
|
output.close();
|
|
@@ -79983,6 +80165,7 @@ function createWordPressTransport(onFailure) {
|
|
|
79983
80165
|
}
|
|
79984
80166
|
},
|
|
79985
80167
|
async cancel(reason) {
|
|
80168
|
+
released = true;
|
|
79986
80169
|
cleanup();
|
|
79987
80170
|
await reader.cancel(reason);
|
|
79988
80171
|
}
|
|
@@ -80021,6 +80204,7 @@ function createWordPressTransport(onFailure) {
|
|
|
80021
80204
|
throw failure(error51);
|
|
80022
80205
|
}
|
|
80023
80206
|
};
|
|
80207
|
+
const fetch3 = (url2, init) => send(url2, init, false);
|
|
80024
80208
|
return Object.assign(new StreamableHTTPClientTransport(new URL(getRequestUrl()), { fetch: fetch3 }), {
|
|
80025
80209
|
cancelRequest(id) {
|
|
80026
80210
|
inflight.get(id)?.();
|
|
@@ -80287,6 +80471,13 @@ formdata-polyfill/esm.min.js:
|
|
|
80287
80471
|
node-domexception/index.js:
|
|
80288
80472
|
(*! node-domexception. MIT License. Jimmy Wärting <https://jimmy.warting.se/opensource> *)
|
|
80289
80473
|
|
|
80474
|
+
content-type/index.js:
|
|
80475
|
+
(*!
|
|
80476
|
+
* content-type
|
|
80477
|
+
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
80478
|
+
* MIT Licensed
|
|
80479
|
+
*)
|
|
80480
|
+
|
|
80290
80481
|
depd/index.js:
|
|
80291
80482
|
(*!
|
|
80292
80483
|
* depd
|
|
@@ -80484,13 +80675,6 @@ express/lib/view.js:
|
|
|
80484
80675
|
* MIT Licensed
|
|
80485
80676
|
*)
|
|
80486
80677
|
|
|
80487
|
-
content-type/index.js:
|
|
80488
|
-
(*!
|
|
80489
|
-
* content-type
|
|
80490
|
-
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
80491
|
-
* MIT Licensed
|
|
80492
|
-
*)
|
|
80493
|
-
|
|
80494
80678
|
etag/index.js:
|
|
80495
80679
|
(*!
|
|
80496
80680
|
* etag
|