@opentiny/next-sdk 0.1.13 → 0.1.14

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.
@@ -2966,58 +2966,81 @@ const require$$9 = {
2966
2966
  };
2967
2967
  var uri$2 = {};
2968
2968
  var fastUri$1 = { exports: {} };
2969
- const isUUID$1 = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
2970
- const isIPv4$1 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
2971
- function stringArrayToHexStripped(input) {
2972
- let acc = "";
2973
- let code2 = 0;
2974
- let i = 0;
2975
- for (i = 0; i < input.length; i++) {
2976
- code2 = input[i].charCodeAt(0);
2977
- if (code2 === 48) {
2978
- continue;
2979
- }
2980
- if (!(code2 >= 48 && code2 <= 57 || code2 >= 65 && code2 <= 70 || code2 >= 97 && code2 <= 102)) {
2981
- return "";
2982
- }
2983
- acc += input[i];
2984
- break;
2985
- }
2986
- for (i += 1; i < input.length; i++) {
2987
- code2 = input[i].charCodeAt(0);
2988
- if (!(code2 >= 48 && code2 <= 57 || code2 >= 65 && code2 <= 70 || code2 >= 97 && code2 <= 102)) {
2989
- return "";
2990
- }
2991
- acc += input[i];
2969
+ const HEX$1 = {
2970
+ 0: 0,
2971
+ 1: 1,
2972
+ 2: 2,
2973
+ 3: 3,
2974
+ 4: 4,
2975
+ 5: 5,
2976
+ 6: 6,
2977
+ 7: 7,
2978
+ 8: 8,
2979
+ 9: 9,
2980
+ a: 10,
2981
+ A: 10,
2982
+ b: 11,
2983
+ B: 11,
2984
+ c: 12,
2985
+ C: 12,
2986
+ d: 13,
2987
+ D: 13,
2988
+ e: 14,
2989
+ E: 14,
2990
+ f: 15,
2991
+ F: 15
2992
+ };
2993
+ var scopedChars = {
2994
+ HEX: HEX$1
2995
+ };
2996
+ const { HEX } = scopedChars;
2997
+ const IPV4_REG = /^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u;
2998
+ function normalizeIPv4$1(host) {
2999
+ if (findToken(host, ".") < 3) {
3000
+ return { host, isIPV4: false };
3001
+ }
3002
+ const matches = host.match(IPV4_REG) || [];
3003
+ const [address] = matches;
3004
+ if (address) {
3005
+ return { host: stripLeadingZeros(address, "."), isIPV4: true };
3006
+ } else {
3007
+ return { host, isIPV4: false };
2992
3008
  }
2993
- return acc;
2994
3009
  }
2995
- const nonSimpleDomain$1 = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
2996
- function consumeIsZone(buffer) {
2997
- buffer.length = 0;
2998
- return true;
2999
- }
3000
- function consumeHextets(buffer, address, output) {
3001
- if (buffer.length) {
3002
- const hex = stringArrayToHexStripped(buffer);
3003
- if (hex !== "") {
3004
- address.push(hex);
3005
- } else {
3006
- output.error = true;
3007
- return false;
3008
- }
3009
- buffer.length = 0;
3010
+ function stringArrayToHexStripped(input, keepZero = false) {
3011
+ let acc = "";
3012
+ let strip = true;
3013
+ for (const c of input) {
3014
+ if (HEX[c] === void 0) return void 0;
3015
+ if (c !== "0" && strip === true) strip = false;
3016
+ if (!strip) acc += c;
3010
3017
  }
3011
- return true;
3018
+ if (keepZero && acc.length === 0) acc = "0";
3019
+ return acc;
3012
3020
  }
3013
3021
  function getIPV6(input) {
3014
3022
  let tokenCount = 0;
3015
3023
  const output = { error: false, address: "", zone: "" };
3016
3024
  const address = [];
3017
3025
  const buffer = [];
3026
+ let isZone = false;
3018
3027
  let endipv6Encountered = false;
3019
3028
  let endIpv6 = false;
3020
- let consume = consumeHextets;
3029
+ function consume() {
3030
+ if (buffer.length) {
3031
+ if (isZone === false) {
3032
+ const hex = stringArrayToHexStripped(buffer);
3033
+ if (hex !== void 0) {
3034
+ address.push(hex);
3035
+ } else {
3036
+ output.error = true;
3037
+ return false;
3038
+ }
3039
+ }
3040
+ buffer.length = 0;
3041
+ }
3042
+ return true;
3043
+ }
3021
3044
  for (let i = 0; i < input.length; i++) {
3022
3045
  const cursor = input[i];
3023
3046
  if (cursor === "[" || cursor === "]") {
@@ -3027,30 +3050,31 @@ function getIPV6(input) {
3027
3050
  if (endipv6Encountered === true) {
3028
3051
  endIpv6 = true;
3029
3052
  }
3030
- if (!consume(buffer, address, output)) {
3053
+ if (!consume()) {
3031
3054
  break;
3032
3055
  }
3033
- if (++tokenCount > 7) {
3056
+ tokenCount++;
3057
+ address.push(":");
3058
+ if (tokenCount > 7) {
3034
3059
  output.error = true;
3035
3060
  break;
3036
3061
  }
3037
- if (i > 0 && input[i - 1] === ":") {
3062
+ if (i - 1 >= 0 && input[i - 1] === ":") {
3038
3063
  endipv6Encountered = true;
3039
3064
  }
3040
- address.push(":");
3041
3065
  continue;
3042
3066
  } else if (cursor === "%") {
3043
- if (!consume(buffer, address, output)) {
3067
+ if (!consume()) {
3044
3068
  break;
3045
3069
  }
3046
- consume = consumeIsZone;
3070
+ isZone = true;
3047
3071
  } else {
3048
3072
  buffer.push(cursor);
3049
3073
  continue;
3050
3074
  }
3051
3075
  }
3052
3076
  if (buffer.length) {
3053
- if (consume === consumeIsZone) {
3077
+ if (isZone) {
3054
3078
  output.zone = buffer.join("");
3055
3079
  } else if (endIpv6) {
3056
3080
  address.push(buffer.join(""));
@@ -3073,11 +3097,33 @@ function normalizeIPv6$1(host) {
3073
3097
  newHost += "%" + ipv6.zone;
3074
3098
  escapedHost += "%25" + ipv6.zone;
3075
3099
  }
3076
- return { host: newHost, isIPV6: true, escapedHost };
3100
+ return { host: newHost, escapedHost, isIPV6: true };
3077
3101
  } else {
3078
3102
  return { host, isIPV6: false };
3079
3103
  }
3080
3104
  }
3105
+ function stripLeadingZeros(str, token) {
3106
+ let out = "";
3107
+ let skip = true;
3108
+ const l = str.length;
3109
+ for (let i = 0; i < l; i++) {
3110
+ const c = str[i];
3111
+ if (c === "0" && skip) {
3112
+ if (i + 1 <= l && str[i + 1] === token || i + 1 === l) {
3113
+ out += c;
3114
+ skip = false;
3115
+ }
3116
+ } else {
3117
+ if (c === token) {
3118
+ skip = true;
3119
+ } else {
3120
+ skip = false;
3121
+ }
3122
+ out += c;
3123
+ }
3124
+ }
3125
+ return out;
3126
+ }
3081
3127
  function findToken(str, token) {
3082
3128
  let ind = 0;
3083
3129
  for (let i = 0; i < str.length; i++) {
@@ -3085,339 +3131,246 @@ function findToken(str, token) {
3085
3131
  }
3086
3132
  return ind;
3087
3133
  }
3088
- function removeDotSegments$1(path) {
3089
- let input = path;
3134
+ const RDS1 = /^\.\.?\//u;
3135
+ const RDS2 = /^\/\.(?:\/|$)/u;
3136
+ const RDS3 = /^\/\.\.(?:\/|$)/u;
3137
+ const RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/u;
3138
+ function removeDotSegments$1(input) {
3090
3139
  const output = [];
3091
- let nextSlash = -1;
3092
- let len = 0;
3093
- while (len = input.length) {
3094
- if (len === 1) {
3095
- if (input === ".") {
3096
- break;
3097
- } else if (input === "/") {
3098
- output.push("/");
3099
- break;
3140
+ while (input.length) {
3141
+ if (input.match(RDS1)) {
3142
+ input = input.replace(RDS1, "");
3143
+ } else if (input.match(RDS2)) {
3144
+ input = input.replace(RDS2, "/");
3145
+ } else if (input.match(RDS3)) {
3146
+ input = input.replace(RDS3, "/");
3147
+ output.pop();
3148
+ } else if (input === "." || input === "..") {
3149
+ input = "";
3150
+ } else {
3151
+ const im = input.match(RDS5);
3152
+ if (im) {
3153
+ const s = im[0];
3154
+ input = input.slice(s.length);
3155
+ output.push(s);
3100
3156
  } else {
3101
- output.push(input);
3102
- break;
3103
- }
3104
- } else if (len === 2) {
3105
- if (input[0] === ".") {
3106
- if (input[1] === ".") {
3107
- break;
3108
- } else if (input[1] === "/") {
3109
- input = input.slice(2);
3110
- continue;
3111
- }
3112
- } else if (input[0] === "/") {
3113
- if (input[1] === "." || input[1] === "/") {
3114
- output.push("/");
3115
- break;
3116
- }
3117
- }
3118
- } else if (len === 3) {
3119
- if (input === "/..") {
3120
- if (output.length !== 0) {
3121
- output.pop();
3122
- }
3123
- output.push("/");
3124
- break;
3125
- }
3126
- }
3127
- if (input[0] === ".") {
3128
- if (input[1] === ".") {
3129
- if (input[2] === "/") {
3130
- input = input.slice(3);
3131
- continue;
3132
- }
3133
- } else if (input[1] === "/") {
3134
- input = input.slice(2);
3135
- continue;
3136
- }
3137
- } else if (input[0] === "/") {
3138
- if (input[1] === ".") {
3139
- if (input[2] === "/") {
3140
- input = input.slice(2);
3141
- continue;
3142
- } else if (input[2] === ".") {
3143
- if (input[3] === "/") {
3144
- input = input.slice(3);
3145
- if (output.length !== 0) {
3146
- output.pop();
3147
- }
3148
- continue;
3149
- }
3150
- }
3157
+ throw new Error("Unexpected dot segment condition");
3151
3158
  }
3152
3159
  }
3153
- if ((nextSlash = input.indexOf("/", 1)) === -1) {
3154
- output.push(input);
3155
- break;
3156
- } else {
3157
- output.push(input.slice(0, nextSlash));
3158
- input = input.slice(nextSlash);
3159
- }
3160
3160
  }
3161
3161
  return output.join("");
3162
3162
  }
3163
- function normalizeComponentEncoding$1(component, esc) {
3163
+ function normalizeComponentEncoding$1(components, esc) {
3164
3164
  const func = esc !== true ? escape : unescape;
3165
- if (component.scheme !== void 0) {
3166
- component.scheme = func(component.scheme);
3165
+ if (components.scheme !== void 0) {
3166
+ components.scheme = func(components.scheme);
3167
3167
  }
3168
- if (component.userinfo !== void 0) {
3169
- component.userinfo = func(component.userinfo);
3168
+ if (components.userinfo !== void 0) {
3169
+ components.userinfo = func(components.userinfo);
3170
3170
  }
3171
- if (component.host !== void 0) {
3172
- component.host = func(component.host);
3171
+ if (components.host !== void 0) {
3172
+ components.host = func(components.host);
3173
3173
  }
3174
- if (component.path !== void 0) {
3175
- component.path = func(component.path);
3174
+ if (components.path !== void 0) {
3175
+ components.path = func(components.path);
3176
3176
  }
3177
- if (component.query !== void 0) {
3178
- component.query = func(component.query);
3177
+ if (components.query !== void 0) {
3178
+ components.query = func(components.query);
3179
3179
  }
3180
- if (component.fragment !== void 0) {
3181
- component.fragment = func(component.fragment);
3180
+ if (components.fragment !== void 0) {
3181
+ components.fragment = func(components.fragment);
3182
3182
  }
3183
- return component;
3183
+ return components;
3184
3184
  }
3185
- function recomposeAuthority$1(component) {
3185
+ function recomposeAuthority$1(components) {
3186
3186
  const uriTokens = [];
3187
- if (component.userinfo !== void 0) {
3188
- uriTokens.push(component.userinfo);
3187
+ if (components.userinfo !== void 0) {
3188
+ uriTokens.push(components.userinfo);
3189
3189
  uriTokens.push("@");
3190
3190
  }
3191
- if (component.host !== void 0) {
3192
- let host = unescape(component.host);
3193
- if (!isIPv4$1(host)) {
3194
- const ipV6res = normalizeIPv6$1(host);
3191
+ if (components.host !== void 0) {
3192
+ let host = unescape(components.host);
3193
+ const ipV4res = normalizeIPv4$1(host);
3194
+ if (ipV4res.isIPV4) {
3195
+ host = ipV4res.host;
3196
+ } else {
3197
+ const ipV6res = normalizeIPv6$1(ipV4res.host);
3195
3198
  if (ipV6res.isIPV6 === true) {
3196
3199
  host = `[${ipV6res.escapedHost}]`;
3197
3200
  } else {
3198
- host = component.host;
3201
+ host = components.host;
3199
3202
  }
3200
3203
  }
3201
3204
  uriTokens.push(host);
3202
3205
  }
3203
- if (typeof component.port === "number" || typeof component.port === "string") {
3206
+ if (typeof components.port === "number" || typeof components.port === "string") {
3204
3207
  uriTokens.push(":");
3205
- uriTokens.push(String(component.port));
3208
+ uriTokens.push(String(components.port));
3206
3209
  }
3207
3210
  return uriTokens.length ? uriTokens.join("") : void 0;
3208
3211
  }
3209
3212
  var utils = {
3210
- nonSimpleDomain: nonSimpleDomain$1,
3211
3213
  recomposeAuthority: recomposeAuthority$1,
3212
3214
  normalizeComponentEncoding: normalizeComponentEncoding$1,
3213
3215
  removeDotSegments: removeDotSegments$1,
3214
- isIPv4: isIPv4$1,
3215
- isUUID: isUUID$1,
3216
+ normalizeIPv4: normalizeIPv4$1,
3216
3217
  normalizeIPv6: normalizeIPv6$1
3217
3218
  };
3218
- const { isUUID } = utils;
3219
+ const UUID_REG = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu;
3219
3220
  const URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
3220
- function wsIsSecure(wsComponent) {
3221
- if (wsComponent.secure === true) {
3222
- return true;
3223
- } else if (wsComponent.secure === false) {
3224
- return false;
3225
- } else if (wsComponent.scheme) {
3226
- return wsComponent.scheme.length === 3 && (wsComponent.scheme[0] === "w" || wsComponent.scheme[0] === "W") && (wsComponent.scheme[1] === "s" || wsComponent.scheme[1] === "S") && (wsComponent.scheme[2] === "s" || wsComponent.scheme[2] === "S");
3227
- } else {
3228
- return false;
3229
- }
3221
+ function isSecure(wsComponents) {
3222
+ return typeof wsComponents.secure === "boolean" ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss";
3230
3223
  }
3231
- function httpParse(component) {
3232
- if (!component.host) {
3233
- component.error = component.error || "HTTP URIs must have a host.";
3224
+ function httpParse(components) {
3225
+ if (!components.host) {
3226
+ components.error = components.error || "HTTP URIs must have a host.";
3234
3227
  }
3235
- return component;
3228
+ return components;
3236
3229
  }
3237
- function httpSerialize(component) {
3238
- const secure = String(component.scheme).toLowerCase() === "https";
3239
- if (component.port === (secure ? 443 : 80) || component.port === "") {
3240
- component.port = void 0;
3230
+ function httpSerialize(components) {
3231
+ const secure = String(components.scheme).toLowerCase() === "https";
3232
+ if (components.port === (secure ? 443 : 80) || components.port === "") {
3233
+ components.port = void 0;
3241
3234
  }
3242
- if (!component.path) {
3243
- component.path = "/";
3235
+ if (!components.path) {
3236
+ components.path = "/";
3244
3237
  }
3245
- return component;
3238
+ return components;
3246
3239
  }
3247
- function wsParse(wsComponent) {
3248
- wsComponent.secure = wsIsSecure(wsComponent);
3249
- wsComponent.resourceName = (wsComponent.path || "/") + (wsComponent.query ? "?" + wsComponent.query : "");
3250
- wsComponent.path = void 0;
3251
- wsComponent.query = void 0;
3252
- return wsComponent;
3240
+ function wsParse(wsComponents) {
3241
+ wsComponents.secure = isSecure(wsComponents);
3242
+ wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : "");
3243
+ wsComponents.path = void 0;
3244
+ wsComponents.query = void 0;
3245
+ return wsComponents;
3253
3246
  }
3254
- function wsSerialize(wsComponent) {
3255
- if (wsComponent.port === (wsIsSecure(wsComponent) ? 443 : 80) || wsComponent.port === "") {
3256
- wsComponent.port = void 0;
3247
+ function wsSerialize(wsComponents) {
3248
+ if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") {
3249
+ wsComponents.port = void 0;
3257
3250
  }
3258
- if (typeof wsComponent.secure === "boolean") {
3259
- wsComponent.scheme = wsComponent.secure ? "wss" : "ws";
3260
- wsComponent.secure = void 0;
3251
+ if (typeof wsComponents.secure === "boolean") {
3252
+ wsComponents.scheme = wsComponents.secure ? "wss" : "ws";
3253
+ wsComponents.secure = void 0;
3261
3254
  }
3262
- if (wsComponent.resourceName) {
3263
- const [path, query] = wsComponent.resourceName.split("?");
3264
- wsComponent.path = path && path !== "/" ? path : void 0;
3265
- wsComponent.query = query;
3266
- wsComponent.resourceName = void 0;
3255
+ if (wsComponents.resourceName) {
3256
+ const [path, query] = wsComponents.resourceName.split("?");
3257
+ wsComponents.path = path && path !== "/" ? path : void 0;
3258
+ wsComponents.query = query;
3259
+ wsComponents.resourceName = void 0;
3267
3260
  }
3268
- wsComponent.fragment = void 0;
3269
- return wsComponent;
3261
+ wsComponents.fragment = void 0;
3262
+ return wsComponents;
3270
3263
  }
3271
- function urnParse(urnComponent, options) {
3272
- if (!urnComponent.path) {
3273
- urnComponent.error = "URN can not be parsed";
3274
- return urnComponent;
3264
+ function urnParse(urnComponents, options) {
3265
+ if (!urnComponents.path) {
3266
+ urnComponents.error = "URN can not be parsed";
3267
+ return urnComponents;
3275
3268
  }
3276
- const matches = urnComponent.path.match(URN_REG);
3269
+ const matches = urnComponents.path.match(URN_REG);
3277
3270
  if (matches) {
3278
- const scheme = options.scheme || urnComponent.scheme || "urn";
3279
- urnComponent.nid = matches[1].toLowerCase();
3280
- urnComponent.nss = matches[2];
3281
- const urnScheme = `${scheme}:${options.nid || urnComponent.nid}`;
3282
- const schemeHandler = getSchemeHandler$1(urnScheme);
3283
- urnComponent.path = void 0;
3271
+ const scheme = options.scheme || urnComponents.scheme || "urn";
3272
+ urnComponents.nid = matches[1].toLowerCase();
3273
+ urnComponents.nss = matches[2];
3274
+ const urnScheme = `${scheme}:${options.nid || urnComponents.nid}`;
3275
+ const schemeHandler = SCHEMES$1[urnScheme];
3276
+ urnComponents.path = void 0;
3284
3277
  if (schemeHandler) {
3285
- urnComponent = schemeHandler.parse(urnComponent, options);
3278
+ urnComponents = schemeHandler.parse(urnComponents, options);
3286
3279
  }
3287
3280
  } else {
3288
- urnComponent.error = urnComponent.error || "URN can not be parsed.";
3281
+ urnComponents.error = urnComponents.error || "URN can not be parsed.";
3289
3282
  }
3290
- return urnComponent;
3283
+ return urnComponents;
3291
3284
  }
3292
- function urnSerialize(urnComponent, options) {
3293
- if (urnComponent.nid === void 0) {
3294
- throw new Error("URN without nid cannot be serialized");
3295
- }
3296
- const scheme = options.scheme || urnComponent.scheme || "urn";
3297
- const nid = urnComponent.nid.toLowerCase();
3285
+ function urnSerialize(urnComponents, options) {
3286
+ const scheme = options.scheme || urnComponents.scheme || "urn";
3287
+ const nid = urnComponents.nid.toLowerCase();
3298
3288
  const urnScheme = `${scheme}:${options.nid || nid}`;
3299
- const schemeHandler = getSchemeHandler$1(urnScheme);
3289
+ const schemeHandler = SCHEMES$1[urnScheme];
3300
3290
  if (schemeHandler) {
3301
- urnComponent = schemeHandler.serialize(urnComponent, options);
3291
+ urnComponents = schemeHandler.serialize(urnComponents, options);
3302
3292
  }
3303
- const uriComponent = urnComponent;
3304
- const nss = urnComponent.nss;
3305
- uriComponent.path = `${nid || options.nid}:${nss}`;
3293
+ const uriComponents = urnComponents;
3294
+ const nss = urnComponents.nss;
3295
+ uriComponents.path = `${nid || options.nid}:${nss}`;
3306
3296
  options.skipEscape = true;
3307
- return uriComponent;
3308
- }
3309
- function urnuuidParse(urnComponent, options) {
3310
- const uuidComponent = urnComponent;
3311
- uuidComponent.uuid = uuidComponent.nss;
3312
- uuidComponent.nss = void 0;
3313
- if (!options.tolerant && (!uuidComponent.uuid || !isUUID(uuidComponent.uuid))) {
3314
- uuidComponent.error = uuidComponent.error || "UUID is not valid.";
3315
- }
3316
- return uuidComponent;
3317
- }
3318
- function urnuuidSerialize(uuidComponent) {
3319
- const urnComponent = uuidComponent;
3320
- urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
3321
- return urnComponent;
3322
- }
3323
- const http = (
3324
- /** @type {SchemeHandler} */
3325
- {
3326
- scheme: "http",
3327
- domainHost: true,
3328
- parse: httpParse,
3329
- serialize: httpSerialize
3330
- }
3331
- );
3332
- const https = (
3333
- /** @type {SchemeHandler} */
3334
- {
3335
- scheme: "https",
3336
- domainHost: http.domainHost,
3337
- parse: httpParse,
3338
- serialize: httpSerialize
3339
- }
3340
- );
3341
- const ws = (
3342
- /** @type {SchemeHandler} */
3343
- {
3344
- scheme: "ws",
3345
- domainHost: true,
3346
- parse: wsParse,
3347
- serialize: wsSerialize
3348
- }
3349
- );
3350
- const wss = (
3351
- /** @type {SchemeHandler} */
3352
- {
3353
- scheme: "wss",
3354
- domainHost: ws.domainHost,
3355
- parse: ws.parse,
3356
- serialize: ws.serialize
3357
- }
3358
- );
3359
- const urn = (
3360
- /** @type {SchemeHandler} */
3361
- {
3362
- scheme: "urn",
3363
- parse: urnParse,
3364
- serialize: urnSerialize,
3365
- skipNormalize: true
3366
- }
3367
- );
3368
- const urnuuid = (
3369
- /** @type {SchemeHandler} */
3370
- {
3371
- scheme: "urn:uuid",
3372
- parse: urnuuidParse,
3373
- serialize: urnuuidSerialize,
3374
- skipNormalize: true
3375
- }
3376
- );
3377
- const SCHEMES$1 = (
3378
- /** @type {Record<SchemeName, SchemeHandler>} */
3379
- {
3380
- http,
3381
- https,
3382
- ws,
3383
- wss,
3384
- urn,
3385
- "urn:uuid": urnuuid
3386
- }
3387
- );
3388
- Object.setPrototypeOf(SCHEMES$1, null);
3389
- function getSchemeHandler$1(scheme) {
3390
- return scheme && (SCHEMES$1[
3391
- /** @type {SchemeName} */
3392
- scheme
3393
- ] || SCHEMES$1[
3394
- /** @type {SchemeName} */
3395
- scheme.toLowerCase()
3396
- ]) || void 0;
3397
- }
3398
- var schemes = {
3399
- SCHEMES: SCHEMES$1,
3400
- getSchemeHandler: getSchemeHandler$1
3297
+ return uriComponents;
3298
+ }
3299
+ function urnuuidParse(urnComponents, options) {
3300
+ const uuidComponents = urnComponents;
3301
+ uuidComponents.uuid = uuidComponents.nss;
3302
+ uuidComponents.nss = void 0;
3303
+ if (!options.tolerant && (!uuidComponents.uuid || !UUID_REG.test(uuidComponents.uuid))) {
3304
+ uuidComponents.error = uuidComponents.error || "UUID is not valid.";
3305
+ }
3306
+ return uuidComponents;
3307
+ }
3308
+ function urnuuidSerialize(uuidComponents) {
3309
+ const urnComponents = uuidComponents;
3310
+ urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
3311
+ return urnComponents;
3312
+ }
3313
+ const http = {
3314
+ scheme: "http",
3315
+ domainHost: true,
3316
+ parse: httpParse,
3317
+ serialize: httpSerialize
3318
+ };
3319
+ const https = {
3320
+ scheme: "https",
3321
+ domainHost: http.domainHost,
3322
+ parse: httpParse,
3323
+ serialize: httpSerialize
3324
+ };
3325
+ const ws = {
3326
+ scheme: "ws",
3327
+ domainHost: true,
3328
+ parse: wsParse,
3329
+ serialize: wsSerialize
3330
+ };
3331
+ const wss = {
3332
+ scheme: "wss",
3333
+ domainHost: ws.domainHost,
3334
+ parse: ws.parse,
3335
+ serialize: ws.serialize
3401
3336
  };
3402
- const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = utils;
3403
- const { SCHEMES, getSchemeHandler } = schemes;
3337
+ const urn = {
3338
+ scheme: "urn",
3339
+ parse: urnParse,
3340
+ serialize: urnSerialize,
3341
+ skipNormalize: true
3342
+ };
3343
+ const urnuuid = {
3344
+ scheme: "urn:uuid",
3345
+ parse: urnuuidParse,
3346
+ serialize: urnuuidSerialize,
3347
+ skipNormalize: true
3348
+ };
3349
+ const SCHEMES$1 = {
3350
+ http,
3351
+ https,
3352
+ ws,
3353
+ wss,
3354
+ urn,
3355
+ "urn:uuid": urnuuid
3356
+ };
3357
+ var schemes = SCHEMES$1;
3358
+ const { normalizeIPv6, normalizeIPv4, removeDotSegments, recomposeAuthority, normalizeComponentEncoding } = utils;
3359
+ const SCHEMES = schemes;
3404
3360
  function normalize(uri2, options) {
3405
3361
  if (typeof uri2 === "string") {
3406
- uri2 = /** @type {T} */
3407
- serialize(parse(uri2, options), options);
3362
+ uri2 = serialize(parse(uri2, options), options);
3408
3363
  } else if (typeof uri2 === "object") {
3409
- uri2 = /** @type {T} */
3410
- parse(serialize(uri2, options), options);
3364
+ uri2 = parse(serialize(uri2, options), options);
3411
3365
  }
3412
3366
  return uri2;
3413
3367
  }
3414
3368
  function resolve$4(baseURI, relativeURI, options) {
3415
- const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
3416
- const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
3417
- schemelessOptions.skipEscape = true;
3418
- return serialize(resolved, schemelessOptions);
3369
+ const schemelessOptions = Object.assign({ scheme: "null" }, options);
3370
+ const resolved = resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
3371
+ return serialize(resolved, { ...schemelessOptions, skipEscape: true });
3419
3372
  }
3420
- function resolveComponent(base, relative, options, skipNormalization) {
3373
+ function resolveComponents(base, relative, options, skipNormalization) {
3421
3374
  const target = {};
3422
3375
  if (!skipNormalization) {
3423
3376
  base = parse(serialize(base, options), options);
@@ -3447,7 +3400,7 @@ function resolveComponent(base, relative, options, skipNormalization) {
3447
3400
  target.query = base.query;
3448
3401
  }
3449
3402
  } else {
3450
- if (relative.path[0] === "/") {
3403
+ if (relative.path.charAt(0) === "/") {
3451
3404
  target.path = removeDotSegments(relative.path);
3452
3405
  } else {
3453
3406
  if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
@@ -3486,7 +3439,7 @@ function equal$4(uriA, uriB, options) {
3486
3439
  return uriA.toLowerCase() === uriB.toLowerCase();
3487
3440
  }
3488
3441
  function serialize(cmpts, opts) {
3489
- const component = {
3442
+ const components = {
3490
3443
  host: cmpts.host,
3491
3444
  scheme: cmpts.scheme,
3492
3445
  userinfo: cmpts.userinfo,
@@ -3504,49 +3457,60 @@ function serialize(cmpts, opts) {
3504
3457
  };
3505
3458
  const options = Object.assign({}, opts);
3506
3459
  const uriTokens = [];
3507
- const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
3508
- if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
3509
- if (component.path !== void 0) {
3460
+ const schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
3461
+ if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(components, options);
3462
+ if (components.path !== void 0) {
3510
3463
  if (!options.skipEscape) {
3511
- component.path = escape(component.path);
3512
- if (component.scheme !== void 0) {
3513
- component.path = component.path.split("%3A").join(":");
3464
+ components.path = escape(components.path);
3465
+ if (components.scheme !== void 0) {
3466
+ components.path = components.path.split("%3A").join(":");
3514
3467
  }
3515
3468
  } else {
3516
- component.path = unescape(component.path);
3469
+ components.path = unescape(components.path);
3517
3470
  }
3518
3471
  }
3519
- if (options.reference !== "suffix" && component.scheme) {
3520
- uriTokens.push(component.scheme, ":");
3472
+ if (options.reference !== "suffix" && components.scheme) {
3473
+ uriTokens.push(components.scheme, ":");
3521
3474
  }
3522
- const authority = recomposeAuthority(component);
3475
+ const authority = recomposeAuthority(components);
3523
3476
  if (authority !== void 0) {
3524
3477
  if (options.reference !== "suffix") {
3525
3478
  uriTokens.push("//");
3526
3479
  }
3527
3480
  uriTokens.push(authority);
3528
- if (component.path && component.path[0] !== "/") {
3481
+ if (components.path && components.path.charAt(0) !== "/") {
3529
3482
  uriTokens.push("/");
3530
3483
  }
3531
3484
  }
3532
- if (component.path !== void 0) {
3533
- let s = component.path;
3485
+ if (components.path !== void 0) {
3486
+ let s = components.path;
3534
3487
  if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
3535
3488
  s = removeDotSegments(s);
3536
3489
  }
3537
- if (authority === void 0 && s[0] === "/" && s[1] === "/") {
3538
- s = "/%2F" + s.slice(2);
3490
+ if (authority === void 0) {
3491
+ s = s.replace(/^\/\//u, "/%2F");
3539
3492
  }
3540
3493
  uriTokens.push(s);
3541
3494
  }
3542
- if (component.query !== void 0) {
3543
- uriTokens.push("?", component.query);
3495
+ if (components.query !== void 0) {
3496
+ uriTokens.push("?", components.query);
3544
3497
  }
3545
- if (component.fragment !== void 0) {
3546
- uriTokens.push("#", component.fragment);
3498
+ if (components.fragment !== void 0) {
3499
+ uriTokens.push("#", components.fragment);
3547
3500
  }
3548
3501
  return uriTokens.join("");
3549
3502
  }
3503
+ const hexLookUp = Array.from({ length: 127 }, (_v, k) => /[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(k)));
3504
+ function nonSimpleDomain(value) {
3505
+ let code2 = 0;
3506
+ for (let i = 0, len = value.length; i < len; ++i) {
3507
+ code2 = value.charCodeAt(i);
3508
+ if (code2 > 126 || hexLookUp[code2]) {
3509
+ return true;
3510
+ }
3511
+ }
3512
+ return false;
3513
+ }
3550
3514
  const URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
3551
3515
  function parse(uri2, opts) {
3552
3516
  const options = Object.assign({}, opts);
@@ -3559,14 +3523,9 @@ function parse(uri2, opts) {
3559
3523
  query: void 0,
3560
3524
  fragment: void 0
3561
3525
  };
3526
+ const gotEncoding = uri2.indexOf("%") !== -1;
3562
3527
  let isIP = false;
3563
- if (options.reference === "suffix") {
3564
- if (options.scheme) {
3565
- uri2 = options.scheme + ":" + uri2;
3566
- } else {
3567
- uri2 = "//" + uri2;
3568
- }
3569
- }
3528
+ if (options.reference === "suffix") uri2 = (options.scheme ? options.scheme + ":" : "") + "//" + uri2;
3570
3529
  const matches = uri2.match(URI_PARSE);
3571
3530
  if (matches) {
3572
3531
  parsed.scheme = matches[1];
@@ -3580,12 +3539,13 @@ function parse(uri2, opts) {
3580
3539
  parsed.port = matches[5];
3581
3540
  }
3582
3541
  if (parsed.host) {
3583
- const ipv4result = isIPv4(parsed.host);
3584
- if (ipv4result === false) {
3585
- const ipv6result = normalizeIPv6(parsed.host);
3542
+ const ipv4result = normalizeIPv4(parsed.host);
3543
+ if (ipv4result.isIPV4 === false) {
3544
+ const ipv6result = normalizeIPv6(ipv4result.host);
3586
3545
  parsed.host = ipv6result.host.toLowerCase();
3587
3546
  isIP = ipv6result.isIPV6;
3588
3547
  } else {
3548
+ parsed.host = ipv4result.host;
3589
3549
  isIP = true;
3590
3550
  }
3591
3551
  }
@@ -3601,7 +3561,7 @@ function parse(uri2, opts) {
3601
3561
  if (options.reference && options.reference !== "suffix" && options.reference !== parsed.reference) {
3602
3562
  parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
3603
3563
  }
3604
- const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
3564
+ const schemeHandler = SCHEMES[(options.scheme || parsed.scheme || "").toLowerCase()];
3605
3565
  if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
3606
3566
  if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
3607
3567
  try {
@@ -3612,13 +3572,11 @@ function parse(uri2, opts) {
3612
3572
  }
3613
3573
  }
3614
3574
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
3615
- if (uri2.indexOf("%") !== -1) {
3616
- if (parsed.scheme !== void 0) {
3617
- parsed.scheme = unescape(parsed.scheme);
3618
- }
3619
- if (parsed.host !== void 0) {
3620
- parsed.host = unescape(parsed.host);
3621
- }
3575
+ if (gotEncoding && parsed.scheme !== void 0) {
3576
+ parsed.scheme = unescape(parsed.scheme);
3577
+ }
3578
+ if (gotEncoding && parsed.host !== void 0) {
3579
+ parsed.host = unescape(parsed.host);
3622
3580
  }
3623
3581
  if (parsed.path) {
3624
3582
  parsed.path = escape(unescape(parsed.path));
@@ -3639,7 +3597,7 @@ const fastUri = {
3639
3597
  SCHEMES,
3640
3598
  normalize,
3641
3599
  resolve: resolve$4,
3642
- resolveComponent,
3600
+ resolveComponents,
3643
3601
  equal: equal$4,
3644
3602
  serialize,
3645
3603
  parse
@@ -9881,10 +9839,14 @@ const enumType = ZodEnum.create;
9881
9839
  ZodPromise.create;
9882
9840
  const optionalType = ZodOptional.create;
9883
9841
  ZodNullable.create;
9884
- const NEVER = INVALID;
9885
9842
  const LATEST_PROTOCOL_VERSION = "2025-06-18";
9886
9843
  const DEFAULT_NEGOTIATED_PROTOCOL_VERSION = "2025-03-26";
9887
- const SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-03-26", "2024-11-05", "2024-10-07"];
9844
+ const SUPPORTED_PROTOCOL_VERSIONS = [
9845
+ LATEST_PROTOCOL_VERSION,
9846
+ "2025-03-26",
9847
+ "2024-11-05",
9848
+ "2024-10-07"
9849
+ ];
9888
9850
  const JSONRPC_VERSION = "2.0";
9889
9851
  const ProgressTokenSchema = unionType([stringType(), numberType().int()]);
9890
9852
  const CursorSchema = stringType();
@@ -9964,7 +9926,12 @@ const JSONRPCErrorSchema = objectType({
9964
9926
  })
9965
9927
  }).strict();
9966
9928
  const isJSONRPCError = (value) => JSONRPCErrorSchema.safeParse(value).success;
9967
- const JSONRPCMessageSchema = unionType([JSONRPCRequestSchema, JSONRPCNotificationSchema, JSONRPCResponseSchema, JSONRPCErrorSchema]);
9929
+ const JSONRPCMessageSchema = unionType([
9930
+ JSONRPCRequestSchema,
9931
+ JSONRPCNotificationSchema,
9932
+ JSONRPCResponseSchema,
9933
+ JSONRPCErrorSchema
9934
+ ]);
9968
9935
  const EmptyResultSchema = ResultSchema.strict();
9969
9936
  const CancelledNotificationSchema = NotificationSchema.extend({
9970
9937
  method: literalType("notifications/cancelled"),
@@ -9981,57 +9948,22 @@ const CancelledNotificationSchema = NotificationSchema.extend({
9981
9948
  reason: stringType().optional()
9982
9949
  })
9983
9950
  });
9984
- const IconSchema = objectType({
9985
- /**
9986
- * URL or data URI for the icon.
9987
- */
9988
- src: stringType(),
9989
- /**
9990
- * Optional MIME type for the icon.
9991
- */
9992
- mimeType: optionalType(stringType()),
9993
- /**
9994
- * Optional array of strings that specify sizes at which the icon can be used.
9995
- * Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG.
9996
- *
9997
- * If not provided, the client should assume that the icon can be used at any size.
9998
- */
9999
- sizes: optionalType(arrayType(stringType()))
10000
- }).passthrough();
10001
- const IconsSchema = objectType({
10002
- /**
10003
- * Optional set of sized icons that the client can display in a user interface.
10004
- *
10005
- * Clients that support rendering icons MUST support at least the following MIME types:
10006
- * - `image/png` - PNG images (safe, universal compatibility)
10007
- * - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)
10008
- *
10009
- * Clients that support rendering icons SHOULD also support:
10010
- * - `image/svg+xml` - SVG images (scalable but requires security precautions)
10011
- * - `image/webp` - WebP images (modern, efficient format)
10012
- */
10013
- icons: arrayType(IconSchema).optional()
10014
- }).passthrough();
10015
9951
  const BaseMetadataSchema = objectType({
10016
9952
  /** Intended for programmatic or logical use, but used as a display name in past specs or fallback */
10017
9953
  name: stringType(),
10018
9954
  /**
10019
- * Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
10020
- * even by those unfamiliar with domain-specific terminology.
10021
- *
10022
- * If not provided, the name should be used for display (except for Tool,
10023
- * where `annotations.title` should be given precedence over using `name`,
10024
- * if present).
10025
- */
9955
+ * Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
9956
+ * even by those unfamiliar with domain-specific terminology.
9957
+ *
9958
+ * If not provided, the name should be used for display (except for Tool,
9959
+ * where `annotations.title` should be given precedence over using `name`,
9960
+ * if present).
9961
+ */
10026
9962
  title: optionalType(stringType())
10027
9963
  }).passthrough();
10028
9964
  const ImplementationSchema = BaseMetadataSchema.extend({
10029
- version: stringType(),
10030
- /**
10031
- * An optional URL of the website for this implementation.
10032
- */
10033
- websiteUrl: optionalType(stringType())
10034
- }).merge(IconsSchema);
9965
+ version: stringType()
9966
+ });
10035
9967
  const ClientCapabilitiesSchema = objectType({
10036
9968
  /**
10037
9969
  * Experimental, non-standard capabilities that the client supports.
@@ -10227,7 +10159,7 @@ const ResourceSchema = BaseMetadataSchema.extend({
10227
10159
  * for notes on _meta usage.
10228
10160
  */
10229
10161
  _meta: optionalType(objectType({}).passthrough())
10230
- }).merge(IconsSchema);
10162
+ });
10231
10163
  const ResourceTemplateSchema = BaseMetadataSchema.extend({
10232
10164
  /**
10233
10165
  * A URI template (according to RFC 6570) that can be used to construct resource URIs.
@@ -10248,7 +10180,7 @@ const ResourceTemplateSchema = BaseMetadataSchema.extend({
10248
10180
  * for notes on _meta usage.
10249
10181
  */
10250
10182
  _meta: optionalType(objectType({}).passthrough())
10251
- }).merge(IconsSchema);
10183
+ });
10252
10184
  const ListResourcesRequestSchema = PaginatedRequestSchema.extend({
10253
10185
  method: literalType("resources/list")
10254
10186
  });
@@ -10331,7 +10263,7 @@ const PromptSchema = BaseMetadataSchema.extend({
10331
10263
  * for notes on _meta usage.
10332
10264
  */
10333
10265
  _meta: optionalType(objectType({}).passthrough())
10334
- }).merge(IconsSchema);
10266
+ });
10335
10267
  const ListPromptsRequestSchema = PaginatedRequestSchema.extend({
10336
10268
  method: literalType("prompts/list")
10337
10269
  });
@@ -10498,7 +10430,7 @@ const ToolSchema = BaseMetadataSchema.extend({
10498
10430
  * for notes on _meta usage.
10499
10431
  */
10500
10432
  _meta: optionalType(objectType({}).passthrough())
10501
- }).merge(IconsSchema);
10433
+ });
10502
10434
  const ListToolsRequestSchema = PaginatedRequestSchema.extend({
10503
10435
  method: literalType("tools/list")
10504
10436
  });
@@ -10548,7 +10480,16 @@ const CallToolRequestSchema = RequestSchema.extend({
10548
10480
  const ToolListChangedNotificationSchema = NotificationSchema.extend({
10549
10481
  method: literalType("notifications/tools/list_changed")
10550
10482
  });
10551
- const LoggingLevelSchema = enumType(["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"]);
10483
+ const LoggingLevelSchema = enumType([
10484
+ "debug",
10485
+ "info",
10486
+ "notice",
10487
+ "warning",
10488
+ "error",
10489
+ "critical",
10490
+ "alert",
10491
+ "emergency"
10492
+ ]);
10552
10493
  const SetLevelRequestSchema = RequestSchema.extend({
10553
10494
  method: literalType("logging/setLevel"),
10554
10495
  params: BaseRequestParamsSchema.extend({
@@ -10641,7 +10582,11 @@ const CreateMessageResultSchema = ResultSchema.extend({
10641
10582
  */
10642
10583
  stopReason: optionalType(enumType(["endTurn", "stopSequence", "maxTokens"]).or(stringType())),
10643
10584
  role: enumType(["user", "assistant"]),
10644
- content: discriminatedUnionType("type", [TextContentSchema, ImageContentSchema, AudioContentSchema])
10585
+ content: discriminatedUnionType("type", [
10586
+ TextContentSchema,
10587
+ ImageContentSchema,
10588
+ AudioContentSchema
10589
+ ])
10645
10590
  });
10646
10591
  const BooleanSchemaSchema = objectType({
10647
10592
  type: literalType("boolean"),
@@ -10671,7 +10616,12 @@ const EnumSchemaSchema = objectType({
10671
10616
  enum: arrayType(stringType()),
10672
10617
  enumNames: optionalType(arrayType(stringType()))
10673
10618
  }).passthrough();
10674
- const PrimitiveSchemaDefinitionSchema = unionType([BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema, EnumSchemaSchema]);
10619
+ const PrimitiveSchemaDefinitionSchema = unionType([
10620
+ BooleanSchemaSchema,
10621
+ StringSchemaSchema,
10622
+ NumberSchemaSchema,
10623
+ EnumSchemaSchema
10624
+ ]);
10675
10625
  const ElicitRequestSchema = RequestSchema.extend({
10676
10626
  method: literalType("elicitation/create"),
10677
10627
  params: BaseRequestParamsSchema.extend({
@@ -10800,8 +10750,18 @@ const ClientNotificationSchema = unionType([
10800
10750
  InitializedNotificationSchema,
10801
10751
  RootsListChangedNotificationSchema
10802
10752
  ]);
10803
- const ClientResultSchema = unionType([EmptyResultSchema, CreateMessageResultSchema, ElicitResultSchema, ListRootsResultSchema]);
10804
- const ServerRequestSchema = unionType([PingRequestSchema, CreateMessageRequestSchema, ElicitRequestSchema, ListRootsRequestSchema]);
10753
+ const ClientResultSchema = unionType([
10754
+ EmptyResultSchema,
10755
+ CreateMessageResultSchema,
10756
+ ElicitResultSchema,
10757
+ ListRootsResultSchema
10758
+ ]);
10759
+ const ServerRequestSchema = unionType([
10760
+ PingRequestSchema,
10761
+ CreateMessageRequestSchema,
10762
+ ElicitRequestSchema,
10763
+ ListRootsRequestSchema
10764
+ ]);
10805
10765
  const ServerNotificationSchema = unionType([
10806
10766
  CancelledNotificationSchema,
10807
10767
  ProgressNotificationSchema,
@@ -11159,10 +11119,7 @@ class Protocol {
11159
11119
  const totalElapsed = Date.now() - info.startTime;
11160
11120
  if (info.maxTotalTimeout && totalElapsed >= info.maxTotalTimeout) {
11161
11121
  this._timeoutInfo.delete(messageId);
11162
- throw new McpError(ErrorCode.RequestTimeout, "Maximum total timeout exceeded", {
11163
- maxTotalTimeout: info.maxTotalTimeout,
11164
- totalElapsed
11165
- });
11122
+ throw new McpError(ErrorCode.RequestTimeout, "Maximum total timeout exceeded", { maxTotalTimeout: info.maxTotalTimeout, totalElapsed });
11166
11123
  }
11167
11124
  clearTimeout(info.timeoutId);
11168
11125
  info.timeoutId = setTimeout(info.onTimeout, info.timeout);
@@ -11234,11 +11191,10 @@ class Protocol {
11234
11191
  Promise.resolve().then(() => handler(notification)).catch((error2) => this._onerror(new Error(`Uncaught error in notification handler: ${error2}`)));
11235
11192
  }
11236
11193
  _onrequest(request, extra) {
11237
- var _a, _b;
11194
+ var _a, _b, _c, _d;
11238
11195
  const handler = (_a = this._requestHandlers.get(request.method)) !== null && _a !== void 0 ? _a : this.fallbackRequestHandler;
11239
- const capturedTransport = this._transport;
11240
11196
  if (handler === void 0) {
11241
- capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send({
11197
+ (_b = this._transport) === null || _b === void 0 ? void 0 : _b.send({
11242
11198
  jsonrpc: "2.0",
11243
11199
  id: request.id,
11244
11200
  error: {
@@ -11252,8 +11208,8 @@ class Protocol {
11252
11208
  this._requestHandlerAbortControllers.set(request.id, abortController);
11253
11209
  const fullExtra = {
11254
11210
  signal: abortController.signal,
11255
- sessionId: capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId,
11256
- _meta: (_b = request.params) === null || _b === void 0 ? void 0 : _b._meta,
11211
+ sessionId: (_c = this._transport) === null || _c === void 0 ? void 0 : _c.sessionId,
11212
+ _meta: (_d = request.params) === null || _d === void 0 ? void 0 : _d._meta,
11257
11213
  sendNotification: (notification) => this.notification(notification, { relatedRequestId: request.id }),
11258
11214
  sendRequest: (r, resultSchema, options) => this.request(r, resultSchema, { ...options, relatedRequestId: request.id }),
11259
11215
  authInfo: extra === null || extra === void 0 ? void 0 : extra.authInfo,
@@ -11261,25 +11217,26 @@ class Protocol {
11261
11217
  requestInfo: extra === null || extra === void 0 ? void 0 : extra.requestInfo
11262
11218
  };
11263
11219
  Promise.resolve().then(() => handler(request, fullExtra)).then((result) => {
11220
+ var _a2;
11264
11221
  if (abortController.signal.aborted) {
11265
11222
  return;
11266
11223
  }
11267
- return capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send({
11224
+ return (_a2 = this._transport) === null || _a2 === void 0 ? void 0 : _a2.send({
11268
11225
  result,
11269
11226
  jsonrpc: "2.0",
11270
11227
  id: request.id
11271
11228
  });
11272
11229
  }, (error2) => {
11273
- var _a2;
11230
+ var _a2, _b2;
11274
11231
  if (abortController.signal.aborted) {
11275
11232
  return;
11276
11233
  }
11277
- return capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send({
11234
+ return (_a2 = this._transport) === null || _a2 === void 0 ? void 0 : _a2.send({
11278
11235
  jsonrpc: "2.0",
11279
11236
  id: request.id,
11280
11237
  error: {
11281
11238
  code: Number.isSafeInteger(error2["code"]) ? error2["code"] : ErrorCode.InternalError,
11282
- message: (_a2 = error2.message) !== null && _a2 !== void 0 ? _a2 : "Internal error"
11239
+ message: (_b2 = error2.message) !== null && _b2 !== void 0 ? _b2 : "Internal error"
11283
11240
  }
11284
11241
  });
11285
11242
  }).catch((error2) => this._onerror(new Error(`Failed to send response: ${error2}`))).finally(() => {
@@ -12110,24 +12067,24 @@ var uri_all = { exports: {} };
12110
12067
  }
12111
12068
  return uriTokens.length ? uriTokens.join("") : void 0;
12112
12069
  }
12113
- var RDS1 = /^\.\.?\//;
12114
- var RDS2 = /^\/\.(\/|$)/;
12115
- var RDS3 = /^\/\.\.(\/|$)/;
12116
- var RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/;
12070
+ var RDS12 = /^\.\.?\//;
12071
+ var RDS22 = /^\/\.(\/|$)/;
12072
+ var RDS32 = /^\/\.\.(\/|$)/;
12073
+ var RDS52 = /^\/?(?:.|\n)*?(?=\/|$)/;
12117
12074
  function removeDotSegments2(input) {
12118
12075
  var output = [];
12119
12076
  while (input.length) {
12120
- if (input.match(RDS1)) {
12121
- input = input.replace(RDS1, "");
12122
- } else if (input.match(RDS2)) {
12123
- input = input.replace(RDS2, "/");
12124
- } else if (input.match(RDS3)) {
12125
- input = input.replace(RDS3, "/");
12077
+ if (input.match(RDS12)) {
12078
+ input = input.replace(RDS12, "");
12079
+ } else if (input.match(RDS22)) {
12080
+ input = input.replace(RDS22, "/");
12081
+ } else if (input.match(RDS32)) {
12082
+ input = input.replace(RDS32, "/");
12126
12083
  output.pop();
12127
12084
  } else if (input === "." || input === "..") {
12128
12085
  input = "";
12129
12086
  } else {
12130
- var im = input.match(RDS5);
12087
+ var im = input.match(RDS52);
12131
12088
  if (im) {
12132
12089
  var s = im[0];
12133
12090
  input = input.slice(s.length);
@@ -12190,7 +12147,7 @@ var uri_all = { exports: {} };
12190
12147
  }
12191
12148
  return uriTokens.join("");
12192
12149
  }
12193
- function resolveComponents(base2, relative) {
12150
+ function resolveComponents2(base2, relative) {
12194
12151
  var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
12195
12152
  var skipNormalization = arguments[3];
12196
12153
  var target = {};
@@ -12247,7 +12204,7 @@ var uri_all = { exports: {} };
12247
12204
  }
12248
12205
  function resolve2(baseURI, relativeURI, options) {
12249
12206
  var schemelessOptions = assign({ scheme: "null" }, options);
12250
- return serialize2(resolveComponents(parse2(baseURI, schemelessOptions), parse2(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
12207
+ return serialize2(resolveComponents2(parse2(baseURI, schemelessOptions), parse2(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
12251
12208
  }
12252
12209
  function normalize2(uri2, options) {
12253
12210
  if (typeof uri2 === "string") {
@@ -12302,7 +12259,7 @@ var uri_all = { exports: {} };
12302
12259
  parse: handler.parse,
12303
12260
  serialize: handler.serialize
12304
12261
  };
12305
- function isSecure(wsComponents) {
12262
+ function isSecure2(wsComponents) {
12306
12263
  return typeof wsComponents.secure === "boolean" ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss";
12307
12264
  }
12308
12265
  var handler$2 = {
@@ -12310,14 +12267,14 @@ var uri_all = { exports: {} };
12310
12267
  domainHost: true,
12311
12268
  parse: function parse3(components, options) {
12312
12269
  var wsComponents = components;
12313
- wsComponents.secure = isSecure(wsComponents);
12270
+ wsComponents.secure = isSecure2(wsComponents);
12314
12271
  wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : "");
12315
12272
  wsComponents.path = void 0;
12316
12273
  wsComponents.query = void 0;
12317
12274
  return wsComponents;
12318
12275
  },
12319
12276
  serialize: function serialize3(wsComponents, options) {
12320
- if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") {
12277
+ if (wsComponents.port === (isSecure2(wsComponents) ? 443 : 80) || wsComponents.port === "") {
12321
12278
  wsComponents.port = void 0;
12322
12279
  }
12323
12280
  if (typeof wsComponents.secure === "boolean") {
@@ -12508,7 +12465,7 @@ var uri_all = { exports: {} };
12508
12465
  exports2.parse = parse2;
12509
12466
  exports2.removeDotSegments = removeDotSegments2;
12510
12467
  exports2.serialize = serialize2;
12511
- exports2.resolveComponents = resolveComponents;
12468
+ exports2.resolveComponents = resolveComponents2;
12512
12469
  exports2.resolve = resolve2;
12513
12470
  exports2.normalize = normalize2;
12514
12471
  exports2.equal = equal3;
@@ -17709,22 +17666,9 @@ async function pkceChallenge(length) {
17709
17666
  code_challenge: challenge
17710
17667
  };
17711
17668
  }
17712
- const SafeUrlSchema = stringType().url().superRefine((val, ctx) => {
17713
- if (!URL.canParse(val)) {
17714
- ctx.addIssue({
17715
- code: ZodIssueCode.custom,
17716
- message: "URL must be parseable",
17717
- fatal: true
17718
- });
17719
- return NEVER;
17720
- }
17721
- }).refine((url) => {
17722
- const u = new URL(url);
17723
- return u.protocol !== "javascript:" && u.protocol !== "data:" && u.protocol !== "vbscript:";
17724
- }, { message: "URL cannot use javascript:, data:, or vbscript: scheme" });
17725
17669
  const OAuthProtectedResourceMetadataSchema = objectType({
17726
17670
  resource: stringType().url(),
17727
- authorization_servers: arrayType(SafeUrlSchema).optional(),
17671
+ authorization_servers: arrayType(stringType().url()).optional(),
17728
17672
  jwks_uri: stringType().url().optional(),
17729
17673
  scopes_supported: arrayType(stringType()).optional(),
17730
17674
  bearer_methods_supported: arrayType(stringType()).optional(),
@@ -17740,17 +17684,17 @@ const OAuthProtectedResourceMetadataSchema = objectType({
17740
17684
  }).passthrough();
17741
17685
  const OAuthMetadataSchema = objectType({
17742
17686
  issuer: stringType(),
17743
- authorization_endpoint: SafeUrlSchema,
17744
- token_endpoint: SafeUrlSchema,
17745
- registration_endpoint: SafeUrlSchema.optional(),
17687
+ authorization_endpoint: stringType(),
17688
+ token_endpoint: stringType(),
17689
+ registration_endpoint: stringType().optional(),
17746
17690
  scopes_supported: arrayType(stringType()).optional(),
17747
17691
  response_types_supported: arrayType(stringType()),
17748
17692
  response_modes_supported: arrayType(stringType()).optional(),
17749
17693
  grant_types_supported: arrayType(stringType()).optional(),
17750
17694
  token_endpoint_auth_methods_supported: arrayType(stringType()).optional(),
17751
17695
  token_endpoint_auth_signing_alg_values_supported: arrayType(stringType()).optional(),
17752
- service_documentation: SafeUrlSchema.optional(),
17753
- revocation_endpoint: SafeUrlSchema.optional(),
17696
+ service_documentation: stringType().optional(),
17697
+ revocation_endpoint: stringType().optional(),
17754
17698
  revocation_endpoint_auth_methods_supported: arrayType(stringType()).optional(),
17755
17699
  revocation_endpoint_auth_signing_alg_values_supported: arrayType(stringType()).optional(),
17756
17700
  introspection_endpoint: stringType().optional(),
@@ -17760,11 +17704,11 @@ const OAuthMetadataSchema = objectType({
17760
17704
  }).passthrough();
17761
17705
  const OpenIdProviderMetadataSchema = objectType({
17762
17706
  issuer: stringType(),
17763
- authorization_endpoint: SafeUrlSchema,
17764
- token_endpoint: SafeUrlSchema,
17765
- userinfo_endpoint: SafeUrlSchema.optional(),
17766
- jwks_uri: SafeUrlSchema,
17767
- registration_endpoint: SafeUrlSchema.optional(),
17707
+ authorization_endpoint: stringType(),
17708
+ token_endpoint: stringType(),
17709
+ userinfo_endpoint: stringType().optional(),
17710
+ jwks_uri: stringType(),
17711
+ registration_endpoint: stringType().optional(),
17768
17712
  scopes_supported: arrayType(stringType()).optional(),
17769
17713
  response_types_supported: arrayType(stringType()),
17770
17714
  response_modes_supported: arrayType(stringType()).optional(),
@@ -17792,8 +17736,8 @@ const OpenIdProviderMetadataSchema = objectType({
17792
17736
  request_parameter_supported: booleanType().optional(),
17793
17737
  request_uri_parameter_supported: booleanType().optional(),
17794
17738
  require_request_uri_registration: booleanType().optional(),
17795
- op_policy_uri: SafeUrlSchema.optional(),
17796
- op_tos_uri: SafeUrlSchema.optional()
17739
+ op_policy_uri: stringType().optional(),
17740
+ op_tos_uri: stringType().optional()
17797
17741
  }).passthrough();
17798
17742
  const OpenIdProviderDiscoveryMetadataSchema = OpenIdProviderMetadataSchema.merge(OAuthMetadataSchema.pick({
17799
17743
  code_challenge_methods_supported: true
@@ -17812,20 +17756,19 @@ const OAuthErrorResponseSchema = objectType({
17812
17756
  error_description: stringType().optional(),
17813
17757
  error_uri: stringType().optional()
17814
17758
  });
17815
- const OptionalSafeUrlSchema = SafeUrlSchema.optional().or(literalType("").transform(() => void 0));
17816
17759
  const OAuthClientMetadataSchema = objectType({
17817
- redirect_uris: arrayType(SafeUrlSchema),
17760
+ redirect_uris: arrayType(stringType()).refine((uris) => uris.every((uri2) => URL.canParse(uri2)), { message: "redirect_uris must contain valid URLs" }),
17818
17761
  token_endpoint_auth_method: stringType().optional(),
17819
17762
  grant_types: arrayType(stringType()).optional(),
17820
17763
  response_types: arrayType(stringType()).optional(),
17821
17764
  client_name: stringType().optional(),
17822
- client_uri: SafeUrlSchema.optional(),
17823
- logo_uri: OptionalSafeUrlSchema,
17765
+ client_uri: stringType().optional(),
17766
+ logo_uri: stringType().optional(),
17824
17767
  scope: stringType().optional(),
17825
17768
  contacts: arrayType(stringType()).optional(),
17826
- tos_uri: OptionalSafeUrlSchema,
17769
+ tos_uri: stringType().optional(),
17827
17770
  policy_uri: stringType().optional(),
17828
- jwks_uri: SafeUrlSchema.optional(),
17771
+ jwks_uri: stringType().optional(),
17829
17772
  jwks: anyType().optional(),
17830
17773
  software_id: stringType().optional(),
17831
17774
  software_version: stringType().optional(),
@@ -17958,8 +17901,6 @@ class UnauthorizedError extends Error {
17958
17901
  super(message !== null && message !== void 0 ? message : "Unauthorized");
17959
17902
  }
17960
17903
  }
17961
- const AUTHORIZATION_CODE_RESPONSE_TYPE = "code";
17962
- const AUTHORIZATION_CODE_CHALLENGE_METHOD = "S256";
17963
17904
  function selectClientAuthMethod(clientInformation, supportedMethods) {
17964
17905
  const hasClientSecret = clientInformation.client_secret !== void 0;
17965
17906
  if (supportedMethods.length === 0) {
@@ -18063,8 +18004,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope: sco
18063
18004
  }
18064
18005
  const fullInformation = await registerClient(authorizationServerUrl, {
18065
18006
  metadata: metadata2,
18066
- clientMetadata: provider.clientMetadata,
18067
- fetchFn
18007
+ clientMetadata: provider.clientMetadata
18068
18008
  });
18069
18009
  await provider.saveClientInformation(fullInformation);
18070
18010
  clientInformation = fullInformation;
@@ -18092,8 +18032,7 @@ async function authInternal(provider, { serverUrl, authorizationCode, scope: sco
18092
18032
  clientInformation,
18093
18033
  refreshToken: tokens.refresh_token,
18094
18034
  resource,
18095
- addClientAuthentication: provider.addClientAuthentication,
18096
- fetchFn
18035
+ addClientAuthentication: provider.addClientAuthentication
18097
18036
  });
18098
18037
  await provider.saveTokens(newTokens);
18099
18038
  return "AUTHORIZED";
@@ -18190,7 +18129,7 @@ async function tryMetadataDiscovery(url, protocolVersion, fetchFn = fetch) {
18190
18129
  return await fetchWithCorsRetry(url, headers, fetchFn);
18191
18130
  }
18192
18131
  function shouldAttemptFallback(response, pathname) {
18193
- return !response || response.status >= 400 && response.status < 500 && pathname !== "/";
18132
+ return !response || response.status === 404 && pathname !== "/";
18194
18133
  }
18195
18134
  async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, opts) {
18196
18135
  var _a, _b;
@@ -18272,15 +18211,13 @@ function buildDiscoveryUrls(authorizationServerUrl) {
18272
18211
  return urlsToTry;
18273
18212
  }
18274
18213
  async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn = fetch, protocolVersion = LATEST_PROTOCOL_VERSION } = {}) {
18275
- const headers = {
18276
- "MCP-Protocol-Version": protocolVersion,
18277
- Accept: "application/json"
18278
- };
18214
+ var _a;
18215
+ const headers = { "MCP-Protocol-Version": protocolVersion };
18279
18216
  const urlsToTry = buildDiscoveryUrls(authorizationServerUrl);
18280
18217
  for (const { url: endpointUrl, type: type2 } of urlsToTry) {
18281
18218
  const response = await fetchWithCorsRetry(endpointUrl, headers, fetchFn);
18282
18219
  if (!response) {
18283
- continue;
18220
+ throw new Error(`CORS error trying to load ${type2 === "oauth" ? "OAuth" : "OpenID provider"} metadata from ${endpointUrl}`);
18284
18221
  }
18285
18222
  if (!response.ok) {
18286
18223
  if (response.status >= 400 && response.status < 500) {
@@ -18291,20 +18228,26 @@ async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fet
18291
18228
  if (type2 === "oauth") {
18292
18229
  return OAuthMetadataSchema.parse(await response.json());
18293
18230
  } else {
18294
- return OpenIdProviderDiscoveryMetadataSchema.parse(await response.json());
18231
+ const metadata2 = OpenIdProviderDiscoveryMetadataSchema.parse(await response.json());
18232
+ if (!((_a = metadata2.code_challenge_methods_supported) === null || _a === void 0 ? void 0 : _a.includes("S256"))) {
18233
+ throw new Error(`Incompatible OIDC provider at ${endpointUrl}: does not support S256 code challenge method required by MCP specification`);
18234
+ }
18235
+ return metadata2;
18295
18236
  }
18296
18237
  }
18297
18238
  return void 0;
18298
18239
  }
18299
18240
  async function startAuthorization(authorizationServerUrl, { metadata: metadata2, clientInformation, redirectUrl, scope: scope2, state, resource }) {
18241
+ const responseType = "code";
18242
+ const codeChallengeMethod = "S256";
18300
18243
  let authorizationUrl;
18301
18244
  if (metadata2) {
18302
18245
  authorizationUrl = new URL(metadata2.authorization_endpoint);
18303
- if (!metadata2.response_types_supported.includes(AUTHORIZATION_CODE_RESPONSE_TYPE)) {
18304
- throw new Error(`Incompatible auth server: does not support response type ${AUTHORIZATION_CODE_RESPONSE_TYPE}`);
18246
+ if (!metadata2.response_types_supported.includes(responseType)) {
18247
+ throw new Error(`Incompatible auth server: does not support response type ${responseType}`);
18305
18248
  }
18306
- if (metadata2.code_challenge_methods_supported && !metadata2.code_challenge_methods_supported.includes(AUTHORIZATION_CODE_CHALLENGE_METHOD)) {
18307
- throw new Error(`Incompatible auth server: does not support code challenge method ${AUTHORIZATION_CODE_CHALLENGE_METHOD}`);
18249
+ if (!metadata2.code_challenge_methods_supported || !metadata2.code_challenge_methods_supported.includes(codeChallengeMethod)) {
18250
+ throw new Error(`Incompatible auth server: does not support code challenge method ${codeChallengeMethod}`);
18308
18251
  }
18309
18252
  } else {
18310
18253
  authorizationUrl = new URL("/authorize", authorizationServerUrl);
@@ -18312,10 +18255,10 @@ async function startAuthorization(authorizationServerUrl, { metadata: metadata2,
18312
18255
  const challenge = await pkceChallenge();
18313
18256
  const codeVerifier = challenge.code_verifier;
18314
18257
  const codeChallenge = challenge.code_challenge;
18315
- authorizationUrl.searchParams.set("response_type", AUTHORIZATION_CODE_RESPONSE_TYPE);
18258
+ authorizationUrl.searchParams.set("response_type", responseType);
18316
18259
  authorizationUrl.searchParams.set("client_id", clientInformation.client_id);
18317
18260
  authorizationUrl.searchParams.set("code_challenge", codeChallenge);
18318
- authorizationUrl.searchParams.set("code_challenge_method", AUTHORIZATION_CODE_CHALLENGE_METHOD);
18261
+ authorizationUrl.searchParams.set("code_challenge_method", codeChallengeMethod);
18319
18262
  authorizationUrl.searchParams.set("redirect_uri", String(redirectUrl));
18320
18263
  if (state) {
18321
18264
  authorizationUrl.searchParams.set("state", state);
@@ -18340,7 +18283,7 @@ async function exchangeAuthorization(authorizationServerUrl, { metadata: metadat
18340
18283
  }
18341
18284
  const headers = new Headers({
18342
18285
  "Content-Type": "application/x-www-form-urlencoded",
18343
- Accept: "application/json"
18286
+ "Accept": "application/json"
18344
18287
  });
18345
18288
  const params = new URLSearchParams({
18346
18289
  grant_type: grantType,
@@ -18519,7 +18462,7 @@ function splitLines(chunk) {
18519
18462
  const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
18520
18463
  `, searchIndex);
18521
18464
  let lineEnd = -1;
18522
- if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = Math.min(crIndex, lfIndex) : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) {
18465
+ if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = Math.min(crIndex, lfIndex) : crIndex !== -1 ? lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) {
18523
18466
  incompleteLine = chunk.slice(searchIndex);
18524
18467
  break;
18525
18468
  } else {
@@ -18820,11 +18763,7 @@ class SSEClientTransport {
18820
18763
  }
18821
18764
  let result;
18822
18765
  try {
18823
- result = await auth(this._authProvider, {
18824
- serverUrl: this._url,
18825
- resourceMetadataUrl: this._resourceMetadataUrl,
18826
- fetchFn: this._fetch
18827
- });
18766
+ result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
18828
18767
  } catch (error2) {
18829
18768
  (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error2);
18830
18769
  throw error2;
@@ -18923,12 +18862,7 @@ class SSEClientTransport {
18923
18862
  if (!this._authProvider) {
18924
18863
  throw new UnauthorizedError("No auth provider");
18925
18864
  }
18926
- const result = await auth(this._authProvider, {
18927
- serverUrl: this._url,
18928
- authorizationCode,
18929
- resourceMetadataUrl: this._resourceMetadataUrl,
18930
- fetchFn: this._fetch
18931
- });
18865
+ const result = await auth(this._authProvider, { serverUrl: this._url, authorizationCode, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
18932
18866
  if (result !== "AUTHORIZED") {
18933
18867
  throw new UnauthorizedError("Failed to authorize");
18934
18868
  }
@@ -18958,11 +18892,7 @@ class SSEClientTransport {
18958
18892
  if (!response.ok) {
18959
18893
  if (response.status === 401 && this._authProvider) {
18960
18894
  this._resourceMetadataUrl = extractResourceMetadataUrl(response);
18961
- const result = await auth(this._authProvider, {
18962
- serverUrl: this._url,
18963
- resourceMetadataUrl: this._resourceMetadataUrl,
18964
- fetchFn: this._fetch
18965
- });
18895
+ const result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
18966
18896
  if (result !== "AUTHORIZED") {
18967
18897
  throw new UnauthorizedError();
18968
18898
  }
@@ -19017,7 +18947,6 @@ class StreamableHTTPError extends Error {
19017
18947
  class StreamableHTTPClientTransport {
19018
18948
  constructor(url, opts) {
19019
18949
  var _a;
19020
- this._hasCompletedAuthFlow = false;
19021
18950
  this._url = url;
19022
18951
  this._resourceMetadataUrl = void 0;
19023
18952
  this._requestInit = opts === null || opts === void 0 ? void 0 : opts.requestInit;
@@ -19033,11 +18962,7 @@ class StreamableHTTPClientTransport {
19033
18962
  }
19034
18963
  let result;
19035
18964
  try {
19036
- result = await auth(this._authProvider, {
19037
- serverUrl: this._url,
19038
- resourceMetadataUrl: this._resourceMetadataUrl,
19039
- fetchFn: this._fetch
19040
- });
18965
+ result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
19041
18966
  } catch (error2) {
19042
18967
  (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error2);
19043
18968
  throw error2;
@@ -19203,12 +19128,7 @@ class StreamableHTTPClientTransport {
19203
19128
  if (!this._authProvider) {
19204
19129
  throw new UnauthorizedError("No auth provider");
19205
19130
  }
19206
- const result = await auth(this._authProvider, {
19207
- serverUrl: this._url,
19208
- authorizationCode,
19209
- resourceMetadataUrl: this._resourceMetadataUrl,
19210
- fetchFn: this._fetch
19211
- });
19131
+ const result = await auth(this._authProvider, { serverUrl: this._url, authorizationCode, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
19212
19132
  if (result !== "AUTHORIZED") {
19213
19133
  throw new UnauthorizedError("Failed to authorize");
19214
19134
  }
@@ -19246,25 +19166,16 @@ class StreamableHTTPClientTransport {
19246
19166
  }
19247
19167
  if (!response.ok) {
19248
19168
  if (response.status === 401 && this._authProvider) {
19249
- if (this._hasCompletedAuthFlow) {
19250
- throw new StreamableHTTPError(401, "Server returned 401 after successful authentication");
19251
- }
19252
19169
  this._resourceMetadataUrl = extractResourceMetadataUrl(response);
19253
- const result = await auth(this._authProvider, {
19254
- serverUrl: this._url,
19255
- resourceMetadataUrl: this._resourceMetadataUrl,
19256
- fetchFn: this._fetch
19257
- });
19170
+ const result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
19258
19171
  if (result !== "AUTHORIZED") {
19259
19172
  throw new UnauthorizedError();
19260
19173
  }
19261
- this._hasCompletedAuthFlow = true;
19262
19174
  return this.send(message);
19263
19175
  }
19264
19176
  const text = await response.text().catch(() => null);
19265
19177
  throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
19266
19178
  }
19267
- this._hasCompletedAuthFlow = false;
19268
19179
  if (response.status === 202) {
19269
19180
  if (isInitializedNotification(message)) {
19270
19181
  this._startOrAuthSse({ resumptionToken: void 0 }).catch((err) => {
@@ -19347,12 +19258,6 @@ class Server extends Protocol {
19347
19258
  var _a;
19348
19259
  super(options);
19349
19260
  this._serverInfo = _serverInfo;
19350
- this._loggingLevels = /* @__PURE__ */ new Map();
19351
- this.LOG_LEVEL_SEVERITY = new Map(LoggingLevelSchema.options.map((level, index) => [level, index]));
19352
- this.isMessageIgnored = (level, sessionId) => {
19353
- const currentLevel = this._loggingLevels.get(sessionId);
19354
- return currentLevel ? this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(currentLevel) : false;
19355
- };
19356
19261
  this._capabilities = (_a = options === null || options === void 0 ? void 0 : options.capabilities) !== null && _a !== void 0 ? _a : {};
19357
19262
  this._instructions = options === null || options === void 0 ? void 0 : options.instructions;
19358
19263
  this.setRequestHandler(InitializeRequestSchema, (request) => this._oninitialize(request));
@@ -19360,18 +19265,6 @@ class Server extends Protocol {
19360
19265
  var _a2;
19361
19266
  return (_a2 = this.oninitialized) === null || _a2 === void 0 ? void 0 : _a2.call(this);
19362
19267
  });
19363
- if (this._capabilities.logging) {
19364
- this.setRequestHandler(SetLevelRequestSchema, async (request, extra) => {
19365
- var _a2;
19366
- const transportSessionId = extra.sessionId || ((_a2 = extra.requestInfo) === null || _a2 === void 0 ? void 0 : _a2.headers["mcp-session-id"]) || void 0;
19367
- const { level } = request.params;
19368
- const parseResult = LoggingLevelSchema.safeParse(level);
19369
- if (parseResult.success) {
19370
- this._loggingLevels.set(transportSessionId, parseResult.data);
19371
- }
19372
- return {};
19373
- });
19374
- }
19375
19268
  }
19376
19269
  /**
19377
19270
  * Registers new capabilities. This can only be called before connecting to a transport.
@@ -19517,19 +19410,8 @@ class Server extends Protocol {
19517
19410
  async listRoots(params, options) {
19518
19411
  return this.request({ method: "roots/list", params }, ListRootsResultSchema, options);
19519
19412
  }
19520
- /**
19521
- * Sends a logging message to the client, if connected.
19522
- * Note: You only need to send the parameters object, not the entire JSON RPC message
19523
- * @see LoggingMessageNotification
19524
- * @param params
19525
- * @param sessionId optional for stateless and backward compatibility
19526
- */
19527
- async sendLoggingMessage(params, sessionId) {
19528
- if (this._capabilities.logging) {
19529
- if (!this.isMessageIgnored(params.level, sessionId)) {
19530
- return this.notification({ method: "notifications/message", params });
19531
- }
19532
- }
19413
+ async sendLoggingMessage(params) {
19414
+ return this.notification({ method: "notifications/message", params });
19533
19415
  }
19534
19416
  async sendResourceUpdated(params) {
19535
19417
  return this.notification({
@@ -20805,13 +20687,10 @@ class McpServer {
20805
20687
  inputSchema: tool.inputSchema ? zodToJsonSchema(tool.inputSchema, {
20806
20688
  strictUnions: true
20807
20689
  }) : EMPTY_OBJECT_JSON_SCHEMA,
20808
- annotations: tool.annotations,
20809
- _meta: tool._meta
20690
+ annotations: tool.annotations
20810
20691
  };
20811
20692
  if (tool.outputSchema) {
20812
- toolDefinition.outputSchema = zodToJsonSchema(tool.outputSchema, {
20813
- strictUnions: true
20814
- });
20693
+ toolDefinition.outputSchema = zodToJsonSchema(tool.outputSchema, { strictUnions: true });
20815
20694
  }
20816
20695
  return toolDefinition;
20817
20696
  })
@@ -21174,14 +21053,13 @@ class McpServer {
21174
21053
  this._registeredPrompts[name] = registeredPrompt;
21175
21054
  return registeredPrompt;
21176
21055
  }
21177
- _createRegisteredTool(name, title2, description2, inputSchema, outputSchema, annotations, _meta, callback) {
21056
+ _createRegisteredTool(name, title2, description2, inputSchema, outputSchema, annotations, callback) {
21178
21057
  const registeredTool = {
21179
21058
  title: title2,
21180
21059
  description: description2,
21181
21060
  inputSchema: inputSchema === void 0 ? void 0 : objectType(inputSchema),
21182
21061
  outputSchema: outputSchema === void 0 ? void 0 : objectType(outputSchema),
21183
21062
  annotations,
21184
- _meta,
21185
21063
  callback,
21186
21064
  enabled: true,
21187
21065
  disable: () => registeredTool.update({ enabled: false }),
@@ -21203,8 +21081,6 @@ class McpServer {
21203
21081
  registeredTool.callback = updates.callback;
21204
21082
  if (typeof updates.annotations !== "undefined")
21205
21083
  registeredTool.annotations = updates.annotations;
21206
- if (typeof updates._meta !== "undefined")
21207
- registeredTool._meta = updates._meta;
21208
21084
  if (typeof updates.enabled !== "undefined")
21209
21085
  registeredTool.enabled = updates.enabled;
21210
21086
  this.sendToolListChanged();
@@ -21241,7 +21117,7 @@ class McpServer {
21241
21117
  }
21242
21118
  }
21243
21119
  const callback = rest[0];
21244
- return this._createRegisteredTool(name, void 0, description2, inputSchema, outputSchema, annotations, void 0, callback);
21120
+ return this._createRegisteredTool(name, void 0, description2, inputSchema, outputSchema, annotations, callback);
21245
21121
  }
21246
21122
  /**
21247
21123
  * Registers a tool with a config object and callback.
@@ -21250,8 +21126,8 @@ class McpServer {
21250
21126
  if (this._registeredTools[name]) {
21251
21127
  throw new Error(`Tool ${name} is already registered`);
21252
21128
  }
21253
- const { title: title2, description: description2, inputSchema, outputSchema, annotations, _meta } = config;
21254
- return this._createRegisteredTool(name, title2, description2, inputSchema, outputSchema, annotations, _meta, cb);
21129
+ const { title: title2, description: description2, inputSchema, outputSchema, annotations } = config;
21130
+ return this._createRegisteredTool(name, title2, description2, inputSchema, outputSchema, annotations, cb);
21255
21131
  }
21256
21132
  prompt(name, ...rest) {
21257
21133
  if (this._registeredPrompts[name]) {
@@ -21291,16 +21167,6 @@ class McpServer {
21291
21167
  isConnected() {
21292
21168
  return this.server.transport !== void 0;
21293
21169
  }
21294
- /**
21295
- * Sends a logging message to the client, if connected.
21296
- * Note: You only need to send the parameters object, not the entire JSON RPC message
21297
- * @see LoggingMessageNotification
21298
- * @param params
21299
- * @param sessionId optional for stateless and backward compatibility
21300
- */
21301
- async sendLoggingMessage(params, sessionId) {
21302
- return this.server.sendLoggingMessage(params, sessionId);
21303
- }
21304
21170
  /**
21305
21171
  * Sends a resource list changed event to the client, if connected.
21306
21172
  */
@@ -21418,8 +21284,6 @@ export {
21418
21284
  ErrorCode,
21419
21285
  GetPromptRequestSchema,
21420
21286
  GetPromptResultSchema,
21421
- IconSchema,
21422
- IconsSchema,
21423
21287
  ImageContentSchema,
21424
21288
  ImplementationSchema,
21425
21289
  InitializeRequestSchema,