@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.
@@ -2970,58 +2970,81 @@
2970
2970
  };
2971
2971
  var uri$2 = {};
2972
2972
  var fastUri$1 = { exports: {} };
2973
- const isUUID$1 = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
2974
- 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);
2975
- function stringArrayToHexStripped(input) {
2976
- let acc = "";
2977
- let code2 = 0;
2978
- let i = 0;
2979
- for (i = 0; i < input.length; i++) {
2980
- code2 = input[i].charCodeAt(0);
2981
- if (code2 === 48) {
2982
- continue;
2983
- }
2984
- if (!(code2 >= 48 && code2 <= 57 || code2 >= 65 && code2 <= 70 || code2 >= 97 && code2 <= 102)) {
2985
- return "";
2986
- }
2987
- acc += input[i];
2988
- break;
2989
- }
2990
- for (i += 1; i < input.length; i++) {
2991
- code2 = input[i].charCodeAt(0);
2992
- if (!(code2 >= 48 && code2 <= 57 || code2 >= 65 && code2 <= 70 || code2 >= 97 && code2 <= 102)) {
2993
- return "";
2994
- }
2995
- acc += input[i];
2973
+ const HEX$1 = {
2974
+ 0: 0,
2975
+ 1: 1,
2976
+ 2: 2,
2977
+ 3: 3,
2978
+ 4: 4,
2979
+ 5: 5,
2980
+ 6: 6,
2981
+ 7: 7,
2982
+ 8: 8,
2983
+ 9: 9,
2984
+ a: 10,
2985
+ A: 10,
2986
+ b: 11,
2987
+ B: 11,
2988
+ c: 12,
2989
+ C: 12,
2990
+ d: 13,
2991
+ D: 13,
2992
+ e: 14,
2993
+ E: 14,
2994
+ f: 15,
2995
+ F: 15
2996
+ };
2997
+ var scopedChars = {
2998
+ HEX: HEX$1
2999
+ };
3000
+ const { HEX } = scopedChars;
3001
+ 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;
3002
+ function normalizeIPv4$1(host) {
3003
+ if (findToken(host, ".") < 3) {
3004
+ return { host, isIPV4: false };
3005
+ }
3006
+ const matches = host.match(IPV4_REG) || [];
3007
+ const [address] = matches;
3008
+ if (address) {
3009
+ return { host: stripLeadingZeros(address, "."), isIPV4: true };
3010
+ } else {
3011
+ return { host, isIPV4: false };
2996
3012
  }
2997
- return acc;
2998
3013
  }
2999
- const nonSimpleDomain$1 = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
3000
- function consumeIsZone(buffer) {
3001
- buffer.length = 0;
3002
- return true;
3003
- }
3004
- function consumeHextets(buffer, address, output) {
3005
- if (buffer.length) {
3006
- const hex = stringArrayToHexStripped(buffer);
3007
- if (hex !== "") {
3008
- address.push(hex);
3009
- } else {
3010
- output.error = true;
3011
- return false;
3012
- }
3013
- buffer.length = 0;
3014
+ function stringArrayToHexStripped(input, keepZero = false) {
3015
+ let acc = "";
3016
+ let strip = true;
3017
+ for (const c of input) {
3018
+ if (HEX[c] === void 0) return void 0;
3019
+ if (c !== "0" && strip === true) strip = false;
3020
+ if (!strip) acc += c;
3014
3021
  }
3015
- return true;
3022
+ if (keepZero && acc.length === 0) acc = "0";
3023
+ return acc;
3016
3024
  }
3017
3025
  function getIPV6(input) {
3018
3026
  let tokenCount = 0;
3019
3027
  const output = { error: false, address: "", zone: "" };
3020
3028
  const address = [];
3021
3029
  const buffer = [];
3030
+ let isZone = false;
3022
3031
  let endipv6Encountered = false;
3023
3032
  let endIpv6 = false;
3024
- let consume = consumeHextets;
3033
+ function consume() {
3034
+ if (buffer.length) {
3035
+ if (isZone === false) {
3036
+ const hex = stringArrayToHexStripped(buffer);
3037
+ if (hex !== void 0) {
3038
+ address.push(hex);
3039
+ } else {
3040
+ output.error = true;
3041
+ return false;
3042
+ }
3043
+ }
3044
+ buffer.length = 0;
3045
+ }
3046
+ return true;
3047
+ }
3025
3048
  for (let i = 0; i < input.length; i++) {
3026
3049
  const cursor = input[i];
3027
3050
  if (cursor === "[" || cursor === "]") {
@@ -3031,30 +3054,31 @@
3031
3054
  if (endipv6Encountered === true) {
3032
3055
  endIpv6 = true;
3033
3056
  }
3034
- if (!consume(buffer, address, output)) {
3057
+ if (!consume()) {
3035
3058
  break;
3036
3059
  }
3037
- if (++tokenCount > 7) {
3060
+ tokenCount++;
3061
+ address.push(":");
3062
+ if (tokenCount > 7) {
3038
3063
  output.error = true;
3039
3064
  break;
3040
3065
  }
3041
- if (i > 0 && input[i - 1] === ":") {
3066
+ if (i - 1 >= 0 && input[i - 1] === ":") {
3042
3067
  endipv6Encountered = true;
3043
3068
  }
3044
- address.push(":");
3045
3069
  continue;
3046
3070
  } else if (cursor === "%") {
3047
- if (!consume(buffer, address, output)) {
3071
+ if (!consume()) {
3048
3072
  break;
3049
3073
  }
3050
- consume = consumeIsZone;
3074
+ isZone = true;
3051
3075
  } else {
3052
3076
  buffer.push(cursor);
3053
3077
  continue;
3054
3078
  }
3055
3079
  }
3056
3080
  if (buffer.length) {
3057
- if (consume === consumeIsZone) {
3081
+ if (isZone) {
3058
3082
  output.zone = buffer.join("");
3059
3083
  } else if (endIpv6) {
3060
3084
  address.push(buffer.join(""));
@@ -3077,11 +3101,33 @@
3077
3101
  newHost += "%" + ipv6.zone;
3078
3102
  escapedHost += "%25" + ipv6.zone;
3079
3103
  }
3080
- return { host: newHost, isIPV6: true, escapedHost };
3104
+ return { host: newHost, escapedHost, isIPV6: true };
3081
3105
  } else {
3082
3106
  return { host, isIPV6: false };
3083
3107
  }
3084
3108
  }
3109
+ function stripLeadingZeros(str, token) {
3110
+ let out = "";
3111
+ let skip = true;
3112
+ const l = str.length;
3113
+ for (let i = 0; i < l; i++) {
3114
+ const c = str[i];
3115
+ if (c === "0" && skip) {
3116
+ if (i + 1 <= l && str[i + 1] === token || i + 1 === l) {
3117
+ out += c;
3118
+ skip = false;
3119
+ }
3120
+ } else {
3121
+ if (c === token) {
3122
+ skip = true;
3123
+ } else {
3124
+ skip = false;
3125
+ }
3126
+ out += c;
3127
+ }
3128
+ }
3129
+ return out;
3130
+ }
3085
3131
  function findToken(str, token) {
3086
3132
  let ind = 0;
3087
3133
  for (let i = 0; i < str.length; i++) {
@@ -3089,339 +3135,246 @@
3089
3135
  }
3090
3136
  return ind;
3091
3137
  }
3092
- function removeDotSegments$1(path) {
3093
- let input = path;
3138
+ const RDS1 = /^\.\.?\//u;
3139
+ const RDS2 = /^\/\.(?:\/|$)/u;
3140
+ const RDS3 = /^\/\.\.(?:\/|$)/u;
3141
+ const RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/u;
3142
+ function removeDotSegments$1(input) {
3094
3143
  const output = [];
3095
- let nextSlash = -1;
3096
- let len = 0;
3097
- while (len = input.length) {
3098
- if (len === 1) {
3099
- if (input === ".") {
3100
- break;
3101
- } else if (input === "/") {
3102
- output.push("/");
3103
- break;
3144
+ while (input.length) {
3145
+ if (input.match(RDS1)) {
3146
+ input = input.replace(RDS1, "");
3147
+ } else if (input.match(RDS2)) {
3148
+ input = input.replace(RDS2, "/");
3149
+ } else if (input.match(RDS3)) {
3150
+ input = input.replace(RDS3, "/");
3151
+ output.pop();
3152
+ } else if (input === "." || input === "..") {
3153
+ input = "";
3154
+ } else {
3155
+ const im = input.match(RDS5);
3156
+ if (im) {
3157
+ const s = im[0];
3158
+ input = input.slice(s.length);
3159
+ output.push(s);
3104
3160
  } else {
3105
- output.push(input);
3106
- break;
3107
- }
3108
- } else if (len === 2) {
3109
- if (input[0] === ".") {
3110
- if (input[1] === ".") {
3111
- break;
3112
- } else if (input[1] === "/") {
3113
- input = input.slice(2);
3114
- continue;
3115
- }
3116
- } else if (input[0] === "/") {
3117
- if (input[1] === "." || input[1] === "/") {
3118
- output.push("/");
3119
- break;
3120
- }
3121
- }
3122
- } else if (len === 3) {
3123
- if (input === "/..") {
3124
- if (output.length !== 0) {
3125
- output.pop();
3126
- }
3127
- output.push("/");
3128
- break;
3129
- }
3130
- }
3131
- if (input[0] === ".") {
3132
- if (input[1] === ".") {
3133
- if (input[2] === "/") {
3134
- input = input.slice(3);
3135
- continue;
3136
- }
3137
- } else if (input[1] === "/") {
3138
- input = input.slice(2);
3139
- continue;
3161
+ throw new Error("Unexpected dot segment condition");
3140
3162
  }
3141
- } else if (input[0] === "/") {
3142
- if (input[1] === ".") {
3143
- if (input[2] === "/") {
3144
- input = input.slice(2);
3145
- continue;
3146
- } else if (input[2] === ".") {
3147
- if (input[3] === "/") {
3148
- input = input.slice(3);
3149
- if (output.length !== 0) {
3150
- output.pop();
3151
- }
3152
- continue;
3153
- }
3154
- }
3155
- }
3156
- }
3157
- if ((nextSlash = input.indexOf("/", 1)) === -1) {
3158
- output.push(input);
3159
- break;
3160
- } else {
3161
- output.push(input.slice(0, nextSlash));
3162
- input = input.slice(nextSlash);
3163
3163
  }
3164
3164
  }
3165
3165
  return output.join("");
3166
3166
  }
3167
- function normalizeComponentEncoding$1(component, esc) {
3167
+ function normalizeComponentEncoding$1(components, esc) {
3168
3168
  const func = esc !== true ? escape : unescape;
3169
- if (component.scheme !== void 0) {
3170
- component.scheme = func(component.scheme);
3169
+ if (components.scheme !== void 0) {
3170
+ components.scheme = func(components.scheme);
3171
3171
  }
3172
- if (component.userinfo !== void 0) {
3173
- component.userinfo = func(component.userinfo);
3172
+ if (components.userinfo !== void 0) {
3173
+ components.userinfo = func(components.userinfo);
3174
3174
  }
3175
- if (component.host !== void 0) {
3176
- component.host = func(component.host);
3175
+ if (components.host !== void 0) {
3176
+ components.host = func(components.host);
3177
3177
  }
3178
- if (component.path !== void 0) {
3179
- component.path = func(component.path);
3178
+ if (components.path !== void 0) {
3179
+ components.path = func(components.path);
3180
3180
  }
3181
- if (component.query !== void 0) {
3182
- component.query = func(component.query);
3181
+ if (components.query !== void 0) {
3182
+ components.query = func(components.query);
3183
3183
  }
3184
- if (component.fragment !== void 0) {
3185
- component.fragment = func(component.fragment);
3184
+ if (components.fragment !== void 0) {
3185
+ components.fragment = func(components.fragment);
3186
3186
  }
3187
- return component;
3187
+ return components;
3188
3188
  }
3189
- function recomposeAuthority$1(component) {
3189
+ function recomposeAuthority$1(components) {
3190
3190
  const uriTokens = [];
3191
- if (component.userinfo !== void 0) {
3192
- uriTokens.push(component.userinfo);
3191
+ if (components.userinfo !== void 0) {
3192
+ uriTokens.push(components.userinfo);
3193
3193
  uriTokens.push("@");
3194
3194
  }
3195
- if (component.host !== void 0) {
3196
- let host = unescape(component.host);
3197
- if (!isIPv4$1(host)) {
3198
- const ipV6res = normalizeIPv6$1(host);
3195
+ if (components.host !== void 0) {
3196
+ let host = unescape(components.host);
3197
+ const ipV4res = normalizeIPv4$1(host);
3198
+ if (ipV4res.isIPV4) {
3199
+ host = ipV4res.host;
3200
+ } else {
3201
+ const ipV6res = normalizeIPv6$1(ipV4res.host);
3199
3202
  if (ipV6res.isIPV6 === true) {
3200
3203
  host = `[${ipV6res.escapedHost}]`;
3201
3204
  } else {
3202
- host = component.host;
3205
+ host = components.host;
3203
3206
  }
3204
3207
  }
3205
3208
  uriTokens.push(host);
3206
3209
  }
3207
- if (typeof component.port === "number" || typeof component.port === "string") {
3210
+ if (typeof components.port === "number" || typeof components.port === "string") {
3208
3211
  uriTokens.push(":");
3209
- uriTokens.push(String(component.port));
3212
+ uriTokens.push(String(components.port));
3210
3213
  }
3211
3214
  return uriTokens.length ? uriTokens.join("") : void 0;
3212
3215
  }
3213
3216
  var utils = {
3214
- nonSimpleDomain: nonSimpleDomain$1,
3215
3217
  recomposeAuthority: recomposeAuthority$1,
3216
3218
  normalizeComponentEncoding: normalizeComponentEncoding$1,
3217
3219
  removeDotSegments: removeDotSegments$1,
3218
- isIPv4: isIPv4$1,
3219
- isUUID: isUUID$1,
3220
+ normalizeIPv4: normalizeIPv4$1,
3220
3221
  normalizeIPv6: normalizeIPv6$1
3221
3222
  };
3222
- const { isUUID } = utils;
3223
+ const UUID_REG = /^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu;
3223
3224
  const URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
3224
- function wsIsSecure(wsComponent) {
3225
- if (wsComponent.secure === true) {
3226
- return true;
3227
- } else if (wsComponent.secure === false) {
3228
- return false;
3229
- } else if (wsComponent.scheme) {
3230
- 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");
3231
- } else {
3232
- return false;
3233
- }
3225
+ function isSecure(wsComponents) {
3226
+ return typeof wsComponents.secure === "boolean" ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss";
3234
3227
  }
3235
- function httpParse(component) {
3236
- if (!component.host) {
3237
- component.error = component.error || "HTTP URIs must have a host.";
3228
+ function httpParse(components) {
3229
+ if (!components.host) {
3230
+ components.error = components.error || "HTTP URIs must have a host.";
3238
3231
  }
3239
- return component;
3232
+ return components;
3240
3233
  }
3241
- function httpSerialize(component) {
3242
- const secure = String(component.scheme).toLowerCase() === "https";
3243
- if (component.port === (secure ? 443 : 80) || component.port === "") {
3244
- component.port = void 0;
3234
+ function httpSerialize(components) {
3235
+ const secure = String(components.scheme).toLowerCase() === "https";
3236
+ if (components.port === (secure ? 443 : 80) || components.port === "") {
3237
+ components.port = void 0;
3245
3238
  }
3246
- if (!component.path) {
3247
- component.path = "/";
3239
+ if (!components.path) {
3240
+ components.path = "/";
3248
3241
  }
3249
- return component;
3242
+ return components;
3250
3243
  }
3251
- function wsParse(wsComponent) {
3252
- wsComponent.secure = wsIsSecure(wsComponent);
3253
- wsComponent.resourceName = (wsComponent.path || "/") + (wsComponent.query ? "?" + wsComponent.query : "");
3254
- wsComponent.path = void 0;
3255
- wsComponent.query = void 0;
3256
- return wsComponent;
3244
+ function wsParse(wsComponents) {
3245
+ wsComponents.secure = isSecure(wsComponents);
3246
+ wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : "");
3247
+ wsComponents.path = void 0;
3248
+ wsComponents.query = void 0;
3249
+ return wsComponents;
3257
3250
  }
3258
- function wsSerialize(wsComponent) {
3259
- if (wsComponent.port === (wsIsSecure(wsComponent) ? 443 : 80) || wsComponent.port === "") {
3260
- wsComponent.port = void 0;
3251
+ function wsSerialize(wsComponents) {
3252
+ if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") {
3253
+ wsComponents.port = void 0;
3261
3254
  }
3262
- if (typeof wsComponent.secure === "boolean") {
3263
- wsComponent.scheme = wsComponent.secure ? "wss" : "ws";
3264
- wsComponent.secure = void 0;
3255
+ if (typeof wsComponents.secure === "boolean") {
3256
+ wsComponents.scheme = wsComponents.secure ? "wss" : "ws";
3257
+ wsComponents.secure = void 0;
3265
3258
  }
3266
- if (wsComponent.resourceName) {
3267
- const [path, query] = wsComponent.resourceName.split("?");
3268
- wsComponent.path = path && path !== "/" ? path : void 0;
3269
- wsComponent.query = query;
3270
- wsComponent.resourceName = void 0;
3259
+ if (wsComponents.resourceName) {
3260
+ const [path, query] = wsComponents.resourceName.split("?");
3261
+ wsComponents.path = path && path !== "/" ? path : void 0;
3262
+ wsComponents.query = query;
3263
+ wsComponents.resourceName = void 0;
3271
3264
  }
3272
- wsComponent.fragment = void 0;
3273
- return wsComponent;
3265
+ wsComponents.fragment = void 0;
3266
+ return wsComponents;
3274
3267
  }
3275
- function urnParse(urnComponent, options) {
3276
- if (!urnComponent.path) {
3277
- urnComponent.error = "URN can not be parsed";
3278
- return urnComponent;
3268
+ function urnParse(urnComponents, options) {
3269
+ if (!urnComponents.path) {
3270
+ urnComponents.error = "URN can not be parsed";
3271
+ return urnComponents;
3279
3272
  }
3280
- const matches = urnComponent.path.match(URN_REG);
3273
+ const matches = urnComponents.path.match(URN_REG);
3281
3274
  if (matches) {
3282
- const scheme = options.scheme || urnComponent.scheme || "urn";
3283
- urnComponent.nid = matches[1].toLowerCase();
3284
- urnComponent.nss = matches[2];
3285
- const urnScheme = `${scheme}:${options.nid || urnComponent.nid}`;
3286
- const schemeHandler = getSchemeHandler$1(urnScheme);
3287
- urnComponent.path = void 0;
3275
+ const scheme = options.scheme || urnComponents.scheme || "urn";
3276
+ urnComponents.nid = matches[1].toLowerCase();
3277
+ urnComponents.nss = matches[2];
3278
+ const urnScheme = `${scheme}:${options.nid || urnComponents.nid}`;
3279
+ const schemeHandler = SCHEMES$1[urnScheme];
3280
+ urnComponents.path = void 0;
3288
3281
  if (schemeHandler) {
3289
- urnComponent = schemeHandler.parse(urnComponent, options);
3282
+ urnComponents = schemeHandler.parse(urnComponents, options);
3290
3283
  }
3291
3284
  } else {
3292
- urnComponent.error = urnComponent.error || "URN can not be parsed.";
3285
+ urnComponents.error = urnComponents.error || "URN can not be parsed.";
3293
3286
  }
3294
- return urnComponent;
3287
+ return urnComponents;
3295
3288
  }
3296
- function urnSerialize(urnComponent, options) {
3297
- if (urnComponent.nid === void 0) {
3298
- throw new Error("URN without nid cannot be serialized");
3299
- }
3300
- const scheme = options.scheme || urnComponent.scheme || "urn";
3301
- const nid = urnComponent.nid.toLowerCase();
3289
+ function urnSerialize(urnComponents, options) {
3290
+ const scheme = options.scheme || urnComponents.scheme || "urn";
3291
+ const nid = urnComponents.nid.toLowerCase();
3302
3292
  const urnScheme = `${scheme}:${options.nid || nid}`;
3303
- const schemeHandler = getSchemeHandler$1(urnScheme);
3293
+ const schemeHandler = SCHEMES$1[urnScheme];
3304
3294
  if (schemeHandler) {
3305
- urnComponent = schemeHandler.serialize(urnComponent, options);
3295
+ urnComponents = schemeHandler.serialize(urnComponents, options);
3306
3296
  }
3307
- const uriComponent = urnComponent;
3308
- const nss = urnComponent.nss;
3309
- uriComponent.path = `${nid || options.nid}:${nss}`;
3297
+ const uriComponents = urnComponents;
3298
+ const nss = urnComponents.nss;
3299
+ uriComponents.path = `${nid || options.nid}:${nss}`;
3310
3300
  options.skipEscape = true;
3311
- return uriComponent;
3312
- }
3313
- function urnuuidParse(urnComponent, options) {
3314
- const uuidComponent = urnComponent;
3315
- uuidComponent.uuid = uuidComponent.nss;
3316
- uuidComponent.nss = void 0;
3317
- if (!options.tolerant && (!uuidComponent.uuid || !isUUID(uuidComponent.uuid))) {
3318
- uuidComponent.error = uuidComponent.error || "UUID is not valid.";
3319
- }
3320
- return uuidComponent;
3321
- }
3322
- function urnuuidSerialize(uuidComponent) {
3323
- const urnComponent = uuidComponent;
3324
- urnComponent.nss = (uuidComponent.uuid || "").toLowerCase();
3325
- return urnComponent;
3326
- }
3327
- const http = (
3328
- /** @type {SchemeHandler} */
3329
- {
3330
- scheme: "http",
3331
- domainHost: true,
3332
- parse: httpParse,
3333
- serialize: httpSerialize
3334
- }
3335
- );
3336
- const https = (
3337
- /** @type {SchemeHandler} */
3338
- {
3339
- scheme: "https",
3340
- domainHost: http.domainHost,
3341
- parse: httpParse,
3342
- serialize: httpSerialize
3343
- }
3344
- );
3345
- const ws = (
3346
- /** @type {SchemeHandler} */
3347
- {
3348
- scheme: "ws",
3349
- domainHost: true,
3350
- parse: wsParse,
3351
- serialize: wsSerialize
3352
- }
3353
- );
3354
- const wss = (
3355
- /** @type {SchemeHandler} */
3356
- {
3357
- scheme: "wss",
3358
- domainHost: ws.domainHost,
3359
- parse: ws.parse,
3360
- serialize: ws.serialize
3361
- }
3362
- );
3363
- const urn = (
3364
- /** @type {SchemeHandler} */
3365
- {
3366
- scheme: "urn",
3367
- parse: urnParse,
3368
- serialize: urnSerialize,
3369
- skipNormalize: true
3370
- }
3371
- );
3372
- const urnuuid = (
3373
- /** @type {SchemeHandler} */
3374
- {
3375
- scheme: "urn:uuid",
3376
- parse: urnuuidParse,
3377
- serialize: urnuuidSerialize,
3378
- skipNormalize: true
3379
- }
3380
- );
3381
- const SCHEMES$1 = (
3382
- /** @type {Record<SchemeName, SchemeHandler>} */
3383
- {
3384
- http,
3385
- https,
3386
- ws,
3387
- wss,
3388
- urn,
3389
- "urn:uuid": urnuuid
3390
- }
3391
- );
3392
- Object.setPrototypeOf(SCHEMES$1, null);
3393
- function getSchemeHandler$1(scheme) {
3394
- return scheme && (SCHEMES$1[
3395
- /** @type {SchemeName} */
3396
- scheme
3397
- ] || SCHEMES$1[
3398
- /** @type {SchemeName} */
3399
- scheme.toLowerCase()
3400
- ]) || void 0;
3401
- }
3402
- var schemes = {
3403
- SCHEMES: SCHEMES$1,
3404
- getSchemeHandler: getSchemeHandler$1
3301
+ return uriComponents;
3302
+ }
3303
+ function urnuuidParse(urnComponents, options) {
3304
+ const uuidComponents = urnComponents;
3305
+ uuidComponents.uuid = uuidComponents.nss;
3306
+ uuidComponents.nss = void 0;
3307
+ if (!options.tolerant && (!uuidComponents.uuid || !UUID_REG.test(uuidComponents.uuid))) {
3308
+ uuidComponents.error = uuidComponents.error || "UUID is not valid.";
3309
+ }
3310
+ return uuidComponents;
3311
+ }
3312
+ function urnuuidSerialize(uuidComponents) {
3313
+ const urnComponents = uuidComponents;
3314
+ urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
3315
+ return urnComponents;
3316
+ }
3317
+ const http = {
3318
+ scheme: "http",
3319
+ domainHost: true,
3320
+ parse: httpParse,
3321
+ serialize: httpSerialize
3322
+ };
3323
+ const https = {
3324
+ scheme: "https",
3325
+ domainHost: http.domainHost,
3326
+ parse: httpParse,
3327
+ serialize: httpSerialize
3328
+ };
3329
+ const ws = {
3330
+ scheme: "ws",
3331
+ domainHost: true,
3332
+ parse: wsParse,
3333
+ serialize: wsSerialize
3334
+ };
3335
+ const wss = {
3336
+ scheme: "wss",
3337
+ domainHost: ws.domainHost,
3338
+ parse: ws.parse,
3339
+ serialize: ws.serialize
3405
3340
  };
3406
- const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = utils;
3407
- const { SCHEMES, getSchemeHandler } = schemes;
3341
+ const urn = {
3342
+ scheme: "urn",
3343
+ parse: urnParse,
3344
+ serialize: urnSerialize,
3345
+ skipNormalize: true
3346
+ };
3347
+ const urnuuid = {
3348
+ scheme: "urn:uuid",
3349
+ parse: urnuuidParse,
3350
+ serialize: urnuuidSerialize,
3351
+ skipNormalize: true
3352
+ };
3353
+ const SCHEMES$1 = {
3354
+ http,
3355
+ https,
3356
+ ws,
3357
+ wss,
3358
+ urn,
3359
+ "urn:uuid": urnuuid
3360
+ };
3361
+ var schemes = SCHEMES$1;
3362
+ const { normalizeIPv6, normalizeIPv4, removeDotSegments, recomposeAuthority, normalizeComponentEncoding } = utils;
3363
+ const SCHEMES = schemes;
3408
3364
  function normalize(uri2, options) {
3409
3365
  if (typeof uri2 === "string") {
3410
- uri2 = /** @type {T} */
3411
- serialize(parse(uri2, options), options);
3366
+ uri2 = serialize(parse(uri2, options), options);
3412
3367
  } else if (typeof uri2 === "object") {
3413
- uri2 = /** @type {T} */
3414
- parse(serialize(uri2, options), options);
3368
+ uri2 = parse(serialize(uri2, options), options);
3415
3369
  }
3416
3370
  return uri2;
3417
3371
  }
3418
3372
  function resolve$4(baseURI, relativeURI, options) {
3419
- const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
3420
- const resolved = resolveComponent(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
3421
- schemelessOptions.skipEscape = true;
3422
- return serialize(resolved, schemelessOptions);
3373
+ const schemelessOptions = Object.assign({ scheme: "null" }, options);
3374
+ const resolved = resolveComponents(parse(baseURI, schemelessOptions), parse(relativeURI, schemelessOptions), schemelessOptions, true);
3375
+ return serialize(resolved, { ...schemelessOptions, skipEscape: true });
3423
3376
  }
3424
- function resolveComponent(base, relative, options, skipNormalization) {
3377
+ function resolveComponents(base, relative, options, skipNormalization) {
3425
3378
  const target = {};
3426
3379
  if (!skipNormalization) {
3427
3380
  base = parse(serialize(base, options), options);
@@ -3451,7 +3404,7 @@
3451
3404
  target.query = base.query;
3452
3405
  }
3453
3406
  } else {
3454
- if (relative.path[0] === "/") {
3407
+ if (relative.path.charAt(0) === "/") {
3455
3408
  target.path = removeDotSegments(relative.path);
3456
3409
  } else {
3457
3410
  if ((base.userinfo !== void 0 || base.host !== void 0 || base.port !== void 0) && !base.path) {
@@ -3490,7 +3443,7 @@
3490
3443
  return uriA.toLowerCase() === uriB.toLowerCase();
3491
3444
  }
3492
3445
  function serialize(cmpts, opts) {
3493
- const component = {
3446
+ const components = {
3494
3447
  host: cmpts.host,
3495
3448
  scheme: cmpts.scheme,
3496
3449
  userinfo: cmpts.userinfo,
@@ -3508,49 +3461,60 @@
3508
3461
  };
3509
3462
  const options = Object.assign({}, opts);
3510
3463
  const uriTokens = [];
3511
- const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
3512
- if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
3513
- if (component.path !== void 0) {
3464
+ const schemeHandler = SCHEMES[(options.scheme || components.scheme || "").toLowerCase()];
3465
+ if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(components, options);
3466
+ if (components.path !== void 0) {
3514
3467
  if (!options.skipEscape) {
3515
- component.path = escape(component.path);
3516
- if (component.scheme !== void 0) {
3517
- component.path = component.path.split("%3A").join(":");
3468
+ components.path = escape(components.path);
3469
+ if (components.scheme !== void 0) {
3470
+ components.path = components.path.split("%3A").join(":");
3518
3471
  }
3519
3472
  } else {
3520
- component.path = unescape(component.path);
3473
+ components.path = unescape(components.path);
3521
3474
  }
3522
3475
  }
3523
- if (options.reference !== "suffix" && component.scheme) {
3524
- uriTokens.push(component.scheme, ":");
3476
+ if (options.reference !== "suffix" && components.scheme) {
3477
+ uriTokens.push(components.scheme, ":");
3525
3478
  }
3526
- const authority = recomposeAuthority(component);
3479
+ const authority = recomposeAuthority(components);
3527
3480
  if (authority !== void 0) {
3528
3481
  if (options.reference !== "suffix") {
3529
3482
  uriTokens.push("//");
3530
3483
  }
3531
3484
  uriTokens.push(authority);
3532
- if (component.path && component.path[0] !== "/") {
3485
+ if (components.path && components.path.charAt(0) !== "/") {
3533
3486
  uriTokens.push("/");
3534
3487
  }
3535
3488
  }
3536
- if (component.path !== void 0) {
3537
- let s = component.path;
3489
+ if (components.path !== void 0) {
3490
+ let s = components.path;
3538
3491
  if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
3539
3492
  s = removeDotSegments(s);
3540
3493
  }
3541
- if (authority === void 0 && s[0] === "/" && s[1] === "/") {
3542
- s = "/%2F" + s.slice(2);
3494
+ if (authority === void 0) {
3495
+ s = s.replace(/^\/\//u, "/%2F");
3543
3496
  }
3544
3497
  uriTokens.push(s);
3545
3498
  }
3546
- if (component.query !== void 0) {
3547
- uriTokens.push("?", component.query);
3499
+ if (components.query !== void 0) {
3500
+ uriTokens.push("?", components.query);
3548
3501
  }
3549
- if (component.fragment !== void 0) {
3550
- uriTokens.push("#", component.fragment);
3502
+ if (components.fragment !== void 0) {
3503
+ uriTokens.push("#", components.fragment);
3551
3504
  }
3552
3505
  return uriTokens.join("");
3553
3506
  }
3507
+ const hexLookUp = Array.from({ length: 127 }, (_v, k) => /[^!"$&'()*+,\-.;=_`a-z{}~]/u.test(String.fromCharCode(k)));
3508
+ function nonSimpleDomain(value) {
3509
+ let code2 = 0;
3510
+ for (let i = 0, len = value.length; i < len; ++i) {
3511
+ code2 = value.charCodeAt(i);
3512
+ if (code2 > 126 || hexLookUp[code2]) {
3513
+ return true;
3514
+ }
3515
+ }
3516
+ return false;
3517
+ }
3554
3518
  const URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
3555
3519
  function parse(uri2, opts) {
3556
3520
  const options = Object.assign({}, opts);
@@ -3563,14 +3527,9 @@
3563
3527
  query: void 0,
3564
3528
  fragment: void 0
3565
3529
  };
3530
+ const gotEncoding = uri2.indexOf("%") !== -1;
3566
3531
  let isIP = false;
3567
- if (options.reference === "suffix") {
3568
- if (options.scheme) {
3569
- uri2 = options.scheme + ":" + uri2;
3570
- } else {
3571
- uri2 = "//" + uri2;
3572
- }
3573
- }
3532
+ if (options.reference === "suffix") uri2 = (options.scheme ? options.scheme + ":" : "") + "//" + uri2;
3574
3533
  const matches = uri2.match(URI_PARSE);
3575
3534
  if (matches) {
3576
3535
  parsed.scheme = matches[1];
@@ -3584,12 +3543,13 @@
3584
3543
  parsed.port = matches[5];
3585
3544
  }
3586
3545
  if (parsed.host) {
3587
- const ipv4result = isIPv4(parsed.host);
3588
- if (ipv4result === false) {
3589
- const ipv6result = normalizeIPv6(parsed.host);
3546
+ const ipv4result = normalizeIPv4(parsed.host);
3547
+ if (ipv4result.isIPV4 === false) {
3548
+ const ipv6result = normalizeIPv6(ipv4result.host);
3590
3549
  parsed.host = ipv6result.host.toLowerCase();
3591
3550
  isIP = ipv6result.isIPV6;
3592
3551
  } else {
3552
+ parsed.host = ipv4result.host;
3593
3553
  isIP = true;
3594
3554
  }
3595
3555
  }
@@ -3605,7 +3565,7 @@
3605
3565
  if (options.reference && options.reference !== "suffix" && options.reference !== parsed.reference) {
3606
3566
  parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
3607
3567
  }
3608
- const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
3568
+ const schemeHandler = SCHEMES[(options.scheme || parsed.scheme || "").toLowerCase()];
3609
3569
  if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
3610
3570
  if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
3611
3571
  try {
@@ -3616,13 +3576,11 @@
3616
3576
  }
3617
3577
  }
3618
3578
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
3619
- if (uri2.indexOf("%") !== -1) {
3620
- if (parsed.scheme !== void 0) {
3621
- parsed.scheme = unescape(parsed.scheme);
3622
- }
3623
- if (parsed.host !== void 0) {
3624
- parsed.host = unescape(parsed.host);
3625
- }
3579
+ if (gotEncoding && parsed.scheme !== void 0) {
3580
+ parsed.scheme = unescape(parsed.scheme);
3581
+ }
3582
+ if (gotEncoding && parsed.host !== void 0) {
3583
+ parsed.host = unescape(parsed.host);
3626
3584
  }
3627
3585
  if (parsed.path) {
3628
3586
  parsed.path = escape(unescape(parsed.path));
@@ -3643,7 +3601,7 @@
3643
3601
  SCHEMES,
3644
3602
  normalize,
3645
3603
  resolve: resolve$4,
3646
- resolveComponent,
3604
+ resolveComponents,
3647
3605
  equal: equal$4,
3648
3606
  serialize,
3649
3607
  parse
@@ -10179,7 +10137,12 @@
10179
10137
  void: voidType
10180
10138
  }, Symbol.toStringTag, { value: "Module" }));
10181
10139
  const LATEST_PROTOCOL_VERSION = "2025-06-18";
10182
- const SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-03-26", "2024-11-05", "2024-10-07"];
10140
+ const SUPPORTED_PROTOCOL_VERSIONS = [
10141
+ LATEST_PROTOCOL_VERSION,
10142
+ "2025-03-26",
10143
+ "2024-11-05",
10144
+ "2024-10-07"
10145
+ ];
10183
10146
  const JSONRPC_VERSION = "2.0";
10184
10147
  const ProgressTokenSchema = unionType([stringType(), numberType().int()]);
10185
10148
  const CursorSchema = stringType();
@@ -10259,7 +10222,12 @@
10259
10222
  })
10260
10223
  }).strict();
10261
10224
  const isJSONRPCError = (value) => JSONRPCErrorSchema.safeParse(value).success;
10262
- const JSONRPCMessageSchema = unionType([JSONRPCRequestSchema, JSONRPCNotificationSchema, JSONRPCResponseSchema, JSONRPCErrorSchema]);
10225
+ const JSONRPCMessageSchema = unionType([
10226
+ JSONRPCRequestSchema,
10227
+ JSONRPCNotificationSchema,
10228
+ JSONRPCResponseSchema,
10229
+ JSONRPCErrorSchema
10230
+ ]);
10263
10231
  const EmptyResultSchema = ResultSchema.strict();
10264
10232
  const CancelledNotificationSchema = NotificationSchema.extend({
10265
10233
  method: literalType("notifications/cancelled"),
@@ -10276,57 +10244,22 @@
10276
10244
  reason: stringType().optional()
10277
10245
  })
10278
10246
  });
10279
- const IconSchema = objectType({
10280
- /**
10281
- * URL or data URI for the icon.
10282
- */
10283
- src: stringType(),
10284
- /**
10285
- * Optional MIME type for the icon.
10286
- */
10287
- mimeType: optionalType(stringType()),
10288
- /**
10289
- * Optional array of strings that specify sizes at which the icon can be used.
10290
- * Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG.
10291
- *
10292
- * If not provided, the client should assume that the icon can be used at any size.
10293
- */
10294
- sizes: optionalType(arrayType(stringType()))
10295
- }).passthrough();
10296
- const IconsSchema = objectType({
10297
- /**
10298
- * Optional set of sized icons that the client can display in a user interface.
10299
- *
10300
- * Clients that support rendering icons MUST support at least the following MIME types:
10301
- * - `image/png` - PNG images (safe, universal compatibility)
10302
- * - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)
10303
- *
10304
- * Clients that support rendering icons SHOULD also support:
10305
- * - `image/svg+xml` - SVG images (scalable but requires security precautions)
10306
- * - `image/webp` - WebP images (modern, efficient format)
10307
- */
10308
- icons: arrayType(IconSchema).optional()
10309
- }).passthrough();
10310
10247
  const BaseMetadataSchema = objectType({
10311
10248
  /** Intended for programmatic or logical use, but used as a display name in past specs or fallback */
10312
10249
  name: stringType(),
10313
10250
  /**
10314
- * Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
10315
- * even by those unfamiliar with domain-specific terminology.
10316
- *
10317
- * If not provided, the name should be used for display (except for Tool,
10318
- * where `annotations.title` should be given precedence over using `name`,
10319
- * if present).
10320
- */
10251
+ * Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
10252
+ * even by those unfamiliar with domain-specific terminology.
10253
+ *
10254
+ * If not provided, the name should be used for display (except for Tool,
10255
+ * where `annotations.title` should be given precedence over using `name`,
10256
+ * if present).
10257
+ */
10321
10258
  title: optionalType(stringType())
10322
10259
  }).passthrough();
10323
10260
  const ImplementationSchema = BaseMetadataSchema.extend({
10324
- version: stringType(),
10325
- /**
10326
- * An optional URL of the website for this implementation.
10327
- */
10328
- websiteUrl: optionalType(stringType())
10329
- }).merge(IconsSchema);
10261
+ version: stringType()
10262
+ });
10330
10263
  const ClientCapabilitiesSchema = objectType({
10331
10264
  /**
10332
10265
  * Experimental, non-standard capabilities that the client supports.
@@ -10521,7 +10454,7 @@
10521
10454
  * for notes on _meta usage.
10522
10455
  */
10523
10456
  _meta: optionalType(objectType({}).passthrough())
10524
- }).merge(IconsSchema);
10457
+ });
10525
10458
  const ResourceTemplateSchema = BaseMetadataSchema.extend({
10526
10459
  /**
10527
10460
  * A URI template (according to RFC 6570) that can be used to construct resource URIs.
@@ -10542,7 +10475,7 @@
10542
10475
  * for notes on _meta usage.
10543
10476
  */
10544
10477
  _meta: optionalType(objectType({}).passthrough())
10545
- }).merge(IconsSchema);
10478
+ });
10546
10479
  const ListResourcesRequestSchema = PaginatedRequestSchema.extend({
10547
10480
  method: literalType("resources/list")
10548
10481
  });
@@ -10625,7 +10558,7 @@
10625
10558
  * for notes on _meta usage.
10626
10559
  */
10627
10560
  _meta: optionalType(objectType({}).passthrough())
10628
- }).merge(IconsSchema);
10561
+ });
10629
10562
  const ListPromptsRequestSchema = PaginatedRequestSchema.extend({
10630
10563
  method: literalType("prompts/list")
10631
10564
  });
@@ -10792,7 +10725,7 @@
10792
10725
  * for notes on _meta usage.
10793
10726
  */
10794
10727
  _meta: optionalType(objectType({}).passthrough())
10795
- }).merge(IconsSchema);
10728
+ });
10796
10729
  const ListToolsRequestSchema = PaginatedRequestSchema.extend({
10797
10730
  method: literalType("tools/list")
10798
10731
  });
@@ -10842,7 +10775,16 @@
10842
10775
  const ToolListChangedNotificationSchema = NotificationSchema.extend({
10843
10776
  method: literalType("notifications/tools/list_changed")
10844
10777
  });
10845
- const LoggingLevelSchema = enumType(["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"]);
10778
+ const LoggingLevelSchema = enumType([
10779
+ "debug",
10780
+ "info",
10781
+ "notice",
10782
+ "warning",
10783
+ "error",
10784
+ "critical",
10785
+ "alert",
10786
+ "emergency"
10787
+ ]);
10846
10788
  const SetLevelRequestSchema = RequestSchema.extend({
10847
10789
  method: literalType("logging/setLevel"),
10848
10790
  params: BaseRequestParamsSchema.extend({
@@ -10935,7 +10877,11 @@
10935
10877
  */
10936
10878
  stopReason: optionalType(enumType(["endTurn", "stopSequence", "maxTokens"]).or(stringType())),
10937
10879
  role: enumType(["user", "assistant"]),
10938
- content: discriminatedUnionType("type", [TextContentSchema, ImageContentSchema, AudioContentSchema])
10880
+ content: discriminatedUnionType("type", [
10881
+ TextContentSchema,
10882
+ ImageContentSchema,
10883
+ AudioContentSchema
10884
+ ])
10939
10885
  });
10940
10886
  const BooleanSchemaSchema = objectType({
10941
10887
  type: literalType("boolean"),
@@ -10965,7 +10911,12 @@
10965
10911
  enum: arrayType(stringType()),
10966
10912
  enumNames: optionalType(arrayType(stringType()))
10967
10913
  }).passthrough();
10968
- const PrimitiveSchemaDefinitionSchema = unionType([BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema, EnumSchemaSchema]);
10914
+ const PrimitiveSchemaDefinitionSchema = unionType([
10915
+ BooleanSchemaSchema,
10916
+ StringSchemaSchema,
10917
+ NumberSchemaSchema,
10918
+ EnumSchemaSchema
10919
+ ]);
10969
10920
  const ElicitRequestSchema = RequestSchema.extend({
10970
10921
  method: literalType("elicitation/create"),
10971
10922
  params: BaseRequestParamsSchema.extend({
@@ -11093,8 +11044,18 @@
11093
11044
  InitializedNotificationSchema,
11094
11045
  RootsListChangedNotificationSchema
11095
11046
  ]);
11096
- unionType([EmptyResultSchema, CreateMessageResultSchema, ElicitResultSchema, ListRootsResultSchema]);
11097
- unionType([PingRequestSchema, CreateMessageRequestSchema, ElicitRequestSchema, ListRootsRequestSchema]);
11047
+ unionType([
11048
+ EmptyResultSchema,
11049
+ CreateMessageResultSchema,
11050
+ ElicitResultSchema,
11051
+ ListRootsResultSchema
11052
+ ]);
11053
+ unionType([
11054
+ PingRequestSchema,
11055
+ CreateMessageRequestSchema,
11056
+ ElicitRequestSchema,
11057
+ ListRootsRequestSchema
11058
+ ]);
11098
11059
  unionType([
11099
11060
  CancelledNotificationSchema,
11100
11061
  ProgressNotificationSchema,
@@ -11166,10 +11127,7 @@
11166
11127
  const totalElapsed = Date.now() - info.startTime;
11167
11128
  if (info.maxTotalTimeout && totalElapsed >= info.maxTotalTimeout) {
11168
11129
  this._timeoutInfo.delete(messageId);
11169
- throw new McpError(ErrorCode.RequestTimeout, "Maximum total timeout exceeded", {
11170
- maxTotalTimeout: info.maxTotalTimeout,
11171
- totalElapsed
11172
- });
11130
+ throw new McpError(ErrorCode.RequestTimeout, "Maximum total timeout exceeded", { maxTotalTimeout: info.maxTotalTimeout, totalElapsed });
11173
11131
  }
11174
11132
  clearTimeout(info.timeoutId);
11175
11133
  info.timeoutId = setTimeout(info.onTimeout, info.timeout);
@@ -11241,11 +11199,10 @@
11241
11199
  Promise.resolve().then(() => handler(notification)).catch((error2) => this._onerror(new Error(`Uncaught error in notification handler: ${error2}`)));
11242
11200
  }
11243
11201
  _onrequest(request, extra) {
11244
- var _a, _b;
11202
+ var _a, _b, _c, _d;
11245
11203
  const handler = (_a = this._requestHandlers.get(request.method)) !== null && _a !== void 0 ? _a : this.fallbackRequestHandler;
11246
- const capturedTransport = this._transport;
11247
11204
  if (handler === void 0) {
11248
- capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send({
11205
+ (_b = this._transport) === null || _b === void 0 ? void 0 : _b.send({
11249
11206
  jsonrpc: "2.0",
11250
11207
  id: request.id,
11251
11208
  error: {
@@ -11259,8 +11216,8 @@
11259
11216
  this._requestHandlerAbortControllers.set(request.id, abortController);
11260
11217
  const fullExtra = {
11261
11218
  signal: abortController.signal,
11262
- sessionId: capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId,
11263
- _meta: (_b = request.params) === null || _b === void 0 ? void 0 : _b._meta,
11219
+ sessionId: (_c = this._transport) === null || _c === void 0 ? void 0 : _c.sessionId,
11220
+ _meta: (_d = request.params) === null || _d === void 0 ? void 0 : _d._meta,
11264
11221
  sendNotification: (notification) => this.notification(notification, { relatedRequestId: request.id }),
11265
11222
  sendRequest: (r, resultSchema, options) => this.request(r, resultSchema, { ...options, relatedRequestId: request.id }),
11266
11223
  authInfo: extra === null || extra === void 0 ? void 0 : extra.authInfo,
@@ -11268,25 +11225,26 @@
11268
11225
  requestInfo: extra === null || extra === void 0 ? void 0 : extra.requestInfo
11269
11226
  };
11270
11227
  Promise.resolve().then(() => handler(request, fullExtra)).then((result) => {
11228
+ var _a2;
11271
11229
  if (abortController.signal.aborted) {
11272
11230
  return;
11273
11231
  }
11274
- return capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send({
11232
+ return (_a2 = this._transport) === null || _a2 === void 0 ? void 0 : _a2.send({
11275
11233
  result,
11276
11234
  jsonrpc: "2.0",
11277
11235
  id: request.id
11278
11236
  });
11279
11237
  }, (error2) => {
11280
- var _a2;
11238
+ var _a2, _b2;
11281
11239
  if (abortController.signal.aborted) {
11282
11240
  return;
11283
11241
  }
11284
- return capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send({
11242
+ return (_a2 = this._transport) === null || _a2 === void 0 ? void 0 : _a2.send({
11285
11243
  jsonrpc: "2.0",
11286
11244
  id: request.id,
11287
11245
  error: {
11288
11246
  code: Number.isSafeInteger(error2["code"]) ? error2["code"] : ErrorCode.InternalError,
11289
- message: (_a2 = error2.message) !== null && _a2 !== void 0 ? _a2 : "Internal error"
11247
+ message: (_b2 = error2.message) !== null && _b2 !== void 0 ? _b2 : "Internal error"
11290
11248
  }
11291
11249
  });
11292
11250
  }).catch((error2) => this._onerror(new Error(`Failed to send response: ${error2}`))).finally(() => {
@@ -12117,24 +12075,24 @@
12117
12075
  }
12118
12076
  return uriTokens.length ? uriTokens.join("") : void 0;
12119
12077
  }
12120
- var RDS1 = /^\.\.?\//;
12121
- var RDS2 = /^\/\.(\/|$)/;
12122
- var RDS3 = /^\/\.\.(\/|$)/;
12123
- var RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/;
12078
+ var RDS12 = /^\.\.?\//;
12079
+ var RDS22 = /^\/\.(\/|$)/;
12080
+ var RDS32 = /^\/\.\.(\/|$)/;
12081
+ var RDS52 = /^\/?(?:.|\n)*?(?=\/|$)/;
12124
12082
  function removeDotSegments2(input) {
12125
12083
  var output = [];
12126
12084
  while (input.length) {
12127
- if (input.match(RDS1)) {
12128
- input = input.replace(RDS1, "");
12129
- } else if (input.match(RDS2)) {
12130
- input = input.replace(RDS2, "/");
12131
- } else if (input.match(RDS3)) {
12132
- input = input.replace(RDS3, "/");
12085
+ if (input.match(RDS12)) {
12086
+ input = input.replace(RDS12, "");
12087
+ } else if (input.match(RDS22)) {
12088
+ input = input.replace(RDS22, "/");
12089
+ } else if (input.match(RDS32)) {
12090
+ input = input.replace(RDS32, "/");
12133
12091
  output.pop();
12134
12092
  } else if (input === "." || input === "..") {
12135
12093
  input = "";
12136
12094
  } else {
12137
- var im = input.match(RDS5);
12095
+ var im = input.match(RDS52);
12138
12096
  if (im) {
12139
12097
  var s = im[0];
12140
12098
  input = input.slice(s.length);
@@ -12197,7 +12155,7 @@
12197
12155
  }
12198
12156
  return uriTokens.join("");
12199
12157
  }
12200
- function resolveComponents(base2, relative) {
12158
+ function resolveComponents2(base2, relative) {
12201
12159
  var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
12202
12160
  var skipNormalization = arguments[3];
12203
12161
  var target = {};
@@ -12254,7 +12212,7 @@
12254
12212
  }
12255
12213
  function resolve2(baseURI, relativeURI, options) {
12256
12214
  var schemelessOptions = assign({ scheme: "null" }, options);
12257
- return serialize2(resolveComponents(parse2(baseURI, schemelessOptions), parse2(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
12215
+ return serialize2(resolveComponents2(parse2(baseURI, schemelessOptions), parse2(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
12258
12216
  }
12259
12217
  function normalize2(uri2, options) {
12260
12218
  if (typeof uri2 === "string") {
@@ -12309,7 +12267,7 @@
12309
12267
  parse: handler.parse,
12310
12268
  serialize: handler.serialize
12311
12269
  };
12312
- function isSecure(wsComponents) {
12270
+ function isSecure2(wsComponents) {
12313
12271
  return typeof wsComponents.secure === "boolean" ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss";
12314
12272
  }
12315
12273
  var handler$2 = {
@@ -12317,14 +12275,14 @@
12317
12275
  domainHost: true,
12318
12276
  parse: function parse3(components, options) {
12319
12277
  var wsComponents = components;
12320
- wsComponents.secure = isSecure(wsComponents);
12278
+ wsComponents.secure = isSecure2(wsComponents);
12321
12279
  wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : "");
12322
12280
  wsComponents.path = void 0;
12323
12281
  wsComponents.query = void 0;
12324
12282
  return wsComponents;
12325
12283
  },
12326
12284
  serialize: function serialize3(wsComponents, options) {
12327
- if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") {
12285
+ if (wsComponents.port === (isSecure2(wsComponents) ? 443 : 80) || wsComponents.port === "") {
12328
12286
  wsComponents.port = void 0;
12329
12287
  }
12330
12288
  if (typeof wsComponents.secure === "boolean") {
@@ -12515,7 +12473,7 @@
12515
12473
  exports4.parse = parse2;
12516
12474
  exports4.removeDotSegments = removeDotSegments2;
12517
12475
  exports4.serialize = serialize2;
12518
- exports4.resolveComponents = resolveComponents;
12476
+ exports4.resolveComponents = resolveComponents2;
12519
12477
  exports4.resolve = resolve2;
12520
12478
  exports4.normalize = normalize2;
12521
12479
  exports4.equal = equal2;
@@ -17771,7 +17729,7 @@
17771
17729
  const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
17772
17730
  `, searchIndex);
17773
17731
  let lineEnd = -1;
17774
- 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) {
17732
+ if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = Math.min(crIndex, lfIndex) : crIndex !== -1 ? lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) {
17775
17733
  incompleteLine = chunk.slice(searchIndex);
17776
17734
  break;
17777
17735
  } else {
@@ -18084,22 +18042,9 @@
18084
18042
  code_challenge: challenge
18085
18043
  };
18086
18044
  }
18087
- const SafeUrlSchema = stringType().url().superRefine((val, ctx) => {
18088
- if (!URL.canParse(val)) {
18089
- ctx.addIssue({
18090
- code: ZodIssueCode.custom,
18091
- message: "URL must be parseable",
18092
- fatal: true
18093
- });
18094
- return NEVER;
18095
- }
18096
- }).refine((url) => {
18097
- const u = new URL(url);
18098
- return u.protocol !== "javascript:" && u.protocol !== "data:" && u.protocol !== "vbscript:";
18099
- }, { message: "URL cannot use javascript:, data:, or vbscript: scheme" });
18100
18045
  const OAuthProtectedResourceMetadataSchema = objectType({
18101
18046
  resource: stringType().url(),
18102
- authorization_servers: arrayType(SafeUrlSchema).optional(),
18047
+ authorization_servers: arrayType(stringType().url()).optional(),
18103
18048
  jwks_uri: stringType().url().optional(),
18104
18049
  scopes_supported: arrayType(stringType()).optional(),
18105
18050
  bearer_methods_supported: arrayType(stringType()).optional(),
@@ -18115,17 +18060,17 @@
18115
18060
  }).passthrough();
18116
18061
  const OAuthMetadataSchema = objectType({
18117
18062
  issuer: stringType(),
18118
- authorization_endpoint: SafeUrlSchema,
18119
- token_endpoint: SafeUrlSchema,
18120
- registration_endpoint: SafeUrlSchema.optional(),
18063
+ authorization_endpoint: stringType(),
18064
+ token_endpoint: stringType(),
18065
+ registration_endpoint: stringType().optional(),
18121
18066
  scopes_supported: arrayType(stringType()).optional(),
18122
18067
  response_types_supported: arrayType(stringType()),
18123
18068
  response_modes_supported: arrayType(stringType()).optional(),
18124
18069
  grant_types_supported: arrayType(stringType()).optional(),
18125
18070
  token_endpoint_auth_methods_supported: arrayType(stringType()).optional(),
18126
18071
  token_endpoint_auth_signing_alg_values_supported: arrayType(stringType()).optional(),
18127
- service_documentation: SafeUrlSchema.optional(),
18128
- revocation_endpoint: SafeUrlSchema.optional(),
18072
+ service_documentation: stringType().optional(),
18073
+ revocation_endpoint: stringType().optional(),
18129
18074
  revocation_endpoint_auth_methods_supported: arrayType(stringType()).optional(),
18130
18075
  revocation_endpoint_auth_signing_alg_values_supported: arrayType(stringType()).optional(),
18131
18076
  introspection_endpoint: stringType().optional(),
@@ -18135,11 +18080,11 @@
18135
18080
  }).passthrough();
18136
18081
  const OpenIdProviderMetadataSchema = objectType({
18137
18082
  issuer: stringType(),
18138
- authorization_endpoint: SafeUrlSchema,
18139
- token_endpoint: SafeUrlSchema,
18140
- userinfo_endpoint: SafeUrlSchema.optional(),
18141
- jwks_uri: SafeUrlSchema,
18142
- registration_endpoint: SafeUrlSchema.optional(),
18083
+ authorization_endpoint: stringType(),
18084
+ token_endpoint: stringType(),
18085
+ userinfo_endpoint: stringType().optional(),
18086
+ jwks_uri: stringType(),
18087
+ registration_endpoint: stringType().optional(),
18143
18088
  scopes_supported: arrayType(stringType()).optional(),
18144
18089
  response_types_supported: arrayType(stringType()),
18145
18090
  response_modes_supported: arrayType(stringType()).optional(),
@@ -18167,8 +18112,8 @@
18167
18112
  request_parameter_supported: booleanType().optional(),
18168
18113
  request_uri_parameter_supported: booleanType().optional(),
18169
18114
  require_request_uri_registration: booleanType().optional(),
18170
- op_policy_uri: SafeUrlSchema.optional(),
18171
- op_tos_uri: SafeUrlSchema.optional()
18115
+ op_policy_uri: stringType().optional(),
18116
+ op_tos_uri: stringType().optional()
18172
18117
  }).passthrough();
18173
18118
  const OpenIdProviderDiscoveryMetadataSchema = OpenIdProviderMetadataSchema.merge(OAuthMetadataSchema.pick({
18174
18119
  code_challenge_methods_supported: true
@@ -18187,20 +18132,19 @@
18187
18132
  error_description: stringType().optional(),
18188
18133
  error_uri: stringType().optional()
18189
18134
  });
18190
- const OptionalSafeUrlSchema = SafeUrlSchema.optional().or(literalType("").transform(() => void 0));
18191
18135
  const OAuthClientMetadataSchema = objectType({
18192
- redirect_uris: arrayType(SafeUrlSchema),
18136
+ redirect_uris: arrayType(stringType()).refine((uris) => uris.every((uri2) => URL.canParse(uri2)), { message: "redirect_uris must contain valid URLs" }),
18193
18137
  token_endpoint_auth_method: stringType().optional(),
18194
18138
  grant_types: arrayType(stringType()).optional(),
18195
18139
  response_types: arrayType(stringType()).optional(),
18196
18140
  client_name: stringType().optional(),
18197
- client_uri: SafeUrlSchema.optional(),
18198
- logo_uri: OptionalSafeUrlSchema,
18141
+ client_uri: stringType().optional(),
18142
+ logo_uri: stringType().optional(),
18199
18143
  scope: stringType().optional(),
18200
18144
  contacts: arrayType(stringType()).optional(),
18201
- tos_uri: OptionalSafeUrlSchema,
18145
+ tos_uri: stringType().optional(),
18202
18146
  policy_uri: stringType().optional(),
18203
- jwks_uri: SafeUrlSchema.optional(),
18147
+ jwks_uri: stringType().optional(),
18204
18148
  jwks: anyType().optional(),
18205
18149
  software_id: stringType().optional(),
18206
18150
  software_version: stringType().optional(),
@@ -18333,8 +18277,6 @@
18333
18277
  super(message !== null && message !== void 0 ? message : "Unauthorized");
18334
18278
  }
18335
18279
  }
18336
- const AUTHORIZATION_CODE_RESPONSE_TYPE = "code";
18337
- const AUTHORIZATION_CODE_CHALLENGE_METHOD = "S256";
18338
18280
  function selectClientAuthMethod(clientInformation, supportedMethods) {
18339
18281
  const hasClientSecret = clientInformation.client_secret !== void 0;
18340
18282
  if (supportedMethods.length === 0) {
@@ -18438,8 +18380,7 @@
18438
18380
  }
18439
18381
  const fullInformation = await registerClient(authorizationServerUrl, {
18440
18382
  metadata: metadata2,
18441
- clientMetadata: provider.clientMetadata,
18442
- fetchFn
18383
+ clientMetadata: provider.clientMetadata
18443
18384
  });
18444
18385
  await provider.saveClientInformation(fullInformation);
18445
18386
  clientInformation = fullInformation;
@@ -18467,8 +18408,7 @@
18467
18408
  clientInformation,
18468
18409
  refreshToken: tokens.refresh_token,
18469
18410
  resource,
18470
- addClientAuthentication: provider.addClientAuthentication,
18471
- fetchFn
18411
+ addClientAuthentication: provider.addClientAuthentication
18472
18412
  });
18473
18413
  await provider.saveTokens(newTokens);
18474
18414
  return "AUTHORIZED";
@@ -18565,7 +18505,7 @@
18565
18505
  return await fetchWithCorsRetry(url, headers, fetchFn);
18566
18506
  }
18567
18507
  function shouldAttemptFallback(response, pathname) {
18568
- return !response || response.status >= 400 && response.status < 500 && pathname !== "/";
18508
+ return !response || response.status === 404 && pathname !== "/";
18569
18509
  }
18570
18510
  async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, opts) {
18571
18511
  var _a, _b;
@@ -18624,15 +18564,13 @@
18624
18564
  return urlsToTry;
18625
18565
  }
18626
18566
  async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn = fetch, protocolVersion = LATEST_PROTOCOL_VERSION } = {}) {
18627
- const headers = {
18628
- "MCP-Protocol-Version": protocolVersion,
18629
- Accept: "application/json"
18630
- };
18567
+ var _a;
18568
+ const headers = { "MCP-Protocol-Version": protocolVersion };
18631
18569
  const urlsToTry = buildDiscoveryUrls(authorizationServerUrl);
18632
18570
  for (const { url: endpointUrl, type: type2 } of urlsToTry) {
18633
18571
  const response = await fetchWithCorsRetry(endpointUrl, headers, fetchFn);
18634
18572
  if (!response) {
18635
- continue;
18573
+ throw new Error(`CORS error trying to load ${type2 === "oauth" ? "OAuth" : "OpenID provider"} metadata from ${endpointUrl}`);
18636
18574
  }
18637
18575
  if (!response.ok) {
18638
18576
  if (response.status >= 400 && response.status < 500) {
@@ -18643,20 +18581,26 @@
18643
18581
  if (type2 === "oauth") {
18644
18582
  return OAuthMetadataSchema.parse(await response.json());
18645
18583
  } else {
18646
- return OpenIdProviderDiscoveryMetadataSchema.parse(await response.json());
18584
+ const metadata2 = OpenIdProviderDiscoveryMetadataSchema.parse(await response.json());
18585
+ if (!((_a = metadata2.code_challenge_methods_supported) === null || _a === void 0 ? void 0 : _a.includes("S256"))) {
18586
+ throw new Error(`Incompatible OIDC provider at ${endpointUrl}: does not support S256 code challenge method required by MCP specification`);
18587
+ }
18588
+ return metadata2;
18647
18589
  }
18648
18590
  }
18649
18591
  return void 0;
18650
18592
  }
18651
18593
  async function startAuthorization(authorizationServerUrl, { metadata: metadata2, clientInformation, redirectUrl, scope: scope2, state, resource }) {
18594
+ const responseType = "code";
18595
+ const codeChallengeMethod = "S256";
18652
18596
  let authorizationUrl;
18653
18597
  if (metadata2) {
18654
18598
  authorizationUrl = new URL(metadata2.authorization_endpoint);
18655
- if (!metadata2.response_types_supported.includes(AUTHORIZATION_CODE_RESPONSE_TYPE)) {
18656
- throw new Error(`Incompatible auth server: does not support response type ${AUTHORIZATION_CODE_RESPONSE_TYPE}`);
18599
+ if (!metadata2.response_types_supported.includes(responseType)) {
18600
+ throw new Error(`Incompatible auth server: does not support response type ${responseType}`);
18657
18601
  }
18658
- if (metadata2.code_challenge_methods_supported && !metadata2.code_challenge_methods_supported.includes(AUTHORIZATION_CODE_CHALLENGE_METHOD)) {
18659
- throw new Error(`Incompatible auth server: does not support code challenge method ${AUTHORIZATION_CODE_CHALLENGE_METHOD}`);
18602
+ if (!metadata2.code_challenge_methods_supported || !metadata2.code_challenge_methods_supported.includes(codeChallengeMethod)) {
18603
+ throw new Error(`Incompatible auth server: does not support code challenge method ${codeChallengeMethod}`);
18660
18604
  }
18661
18605
  } else {
18662
18606
  authorizationUrl = new URL("/authorize", authorizationServerUrl);
@@ -18664,10 +18608,10 @@
18664
18608
  const challenge = await pkceChallenge();
18665
18609
  const codeVerifier = challenge.code_verifier;
18666
18610
  const codeChallenge = challenge.code_challenge;
18667
- authorizationUrl.searchParams.set("response_type", AUTHORIZATION_CODE_RESPONSE_TYPE);
18611
+ authorizationUrl.searchParams.set("response_type", responseType);
18668
18612
  authorizationUrl.searchParams.set("client_id", clientInformation.client_id);
18669
18613
  authorizationUrl.searchParams.set("code_challenge", codeChallenge);
18670
- authorizationUrl.searchParams.set("code_challenge_method", AUTHORIZATION_CODE_CHALLENGE_METHOD);
18614
+ authorizationUrl.searchParams.set("code_challenge_method", codeChallengeMethod);
18671
18615
  authorizationUrl.searchParams.set("redirect_uri", String(redirectUrl));
18672
18616
  if (state) {
18673
18617
  authorizationUrl.searchParams.set("state", state);
@@ -18692,7 +18636,7 @@
18692
18636
  }
18693
18637
  const headers = new Headers({
18694
18638
  "Content-Type": "application/x-www-form-urlencoded",
18695
- Accept: "application/json"
18639
+ "Accept": "application/json"
18696
18640
  });
18697
18641
  const params = new URLSearchParams({
18698
18642
  grant_type: grantType,
@@ -18804,11 +18748,7 @@
18804
18748
  }
18805
18749
  let result;
18806
18750
  try {
18807
- result = await auth(this._authProvider, {
18808
- serverUrl: this._url,
18809
- resourceMetadataUrl: this._resourceMetadataUrl,
18810
- fetchFn: this._fetch
18811
- });
18751
+ result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
18812
18752
  } catch (error2) {
18813
18753
  (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error2);
18814
18754
  throw error2;
@@ -18907,12 +18847,7 @@
18907
18847
  if (!this._authProvider) {
18908
18848
  throw new UnauthorizedError("No auth provider");
18909
18849
  }
18910
- const result = await auth(this._authProvider, {
18911
- serverUrl: this._url,
18912
- authorizationCode,
18913
- resourceMetadataUrl: this._resourceMetadataUrl,
18914
- fetchFn: this._fetch
18915
- });
18850
+ const result = await auth(this._authProvider, { serverUrl: this._url, authorizationCode, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
18916
18851
  if (result !== "AUTHORIZED") {
18917
18852
  throw new UnauthorizedError("Failed to authorize");
18918
18853
  }
@@ -18942,11 +18877,7 @@
18942
18877
  if (!response.ok) {
18943
18878
  if (response.status === 401 && this._authProvider) {
18944
18879
  this._resourceMetadataUrl = extractResourceMetadataUrl(response);
18945
- const result = await auth(this._authProvider, {
18946
- serverUrl: this._url,
18947
- resourceMetadataUrl: this._resourceMetadataUrl,
18948
- fetchFn: this._fetch
18949
- });
18880
+ const result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
18950
18881
  if (result !== "AUTHORIZED") {
18951
18882
  throw new UnauthorizedError();
18952
18883
  }
@@ -19001,7 +18932,6 @@
19001
18932
  class StreamableHTTPClientTransport {
19002
18933
  constructor(url, opts) {
19003
18934
  var _a;
19004
- this._hasCompletedAuthFlow = false;
19005
18935
  this._url = url;
19006
18936
  this._resourceMetadataUrl = void 0;
19007
18937
  this._requestInit = opts === null || opts === void 0 ? void 0 : opts.requestInit;
@@ -19017,11 +18947,7 @@
19017
18947
  }
19018
18948
  let result;
19019
18949
  try {
19020
- result = await auth(this._authProvider, {
19021
- serverUrl: this._url,
19022
- resourceMetadataUrl: this._resourceMetadataUrl,
19023
- fetchFn: this._fetch
19024
- });
18950
+ result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
19025
18951
  } catch (error2) {
19026
18952
  (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error2);
19027
18953
  throw error2;
@@ -19187,12 +19113,7 @@
19187
19113
  if (!this._authProvider) {
19188
19114
  throw new UnauthorizedError("No auth provider");
19189
19115
  }
19190
- const result = await auth(this._authProvider, {
19191
- serverUrl: this._url,
19192
- authorizationCode,
19193
- resourceMetadataUrl: this._resourceMetadataUrl,
19194
- fetchFn: this._fetch
19195
- });
19116
+ const result = await auth(this._authProvider, { serverUrl: this._url, authorizationCode, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
19196
19117
  if (result !== "AUTHORIZED") {
19197
19118
  throw new UnauthorizedError("Failed to authorize");
19198
19119
  }
@@ -19230,25 +19151,16 @@
19230
19151
  }
19231
19152
  if (!response.ok) {
19232
19153
  if (response.status === 401 && this._authProvider) {
19233
- if (this._hasCompletedAuthFlow) {
19234
- throw new StreamableHTTPError(401, "Server returned 401 after successful authentication");
19235
- }
19236
19154
  this._resourceMetadataUrl = extractResourceMetadataUrl(response);
19237
- const result = await auth(this._authProvider, {
19238
- serverUrl: this._url,
19239
- resourceMetadataUrl: this._resourceMetadataUrl,
19240
- fetchFn: this._fetch
19241
- });
19155
+ const result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
19242
19156
  if (result !== "AUTHORIZED") {
19243
19157
  throw new UnauthorizedError();
19244
19158
  }
19245
- this._hasCompletedAuthFlow = true;
19246
19159
  return this.send(message);
19247
19160
  }
19248
19161
  const text = await response.text().catch(() => null);
19249
19162
  throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
19250
19163
  }
19251
- this._hasCompletedAuthFlow = false;
19252
19164
  if (response.status === 202) {
19253
19165
  if (isInitializedNotification(message)) {
19254
19166
  this._startOrAuthSse({ resumptionToken: void 0 }).catch((err) => {
@@ -20178,12 +20090,6 @@
20178
20090
  var _a;
20179
20091
  super(options);
20180
20092
  this._serverInfo = _serverInfo;
20181
- this._loggingLevels = /* @__PURE__ */ new Map();
20182
- this.LOG_LEVEL_SEVERITY = new Map(LoggingLevelSchema.options.map((level, index) => [level, index]));
20183
- this.isMessageIgnored = (level, sessionId) => {
20184
- const currentLevel = this._loggingLevels.get(sessionId);
20185
- return currentLevel ? this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(currentLevel) : false;
20186
- };
20187
20093
  this._capabilities = (_a = options === null || options === void 0 ? void 0 : options.capabilities) !== null && _a !== void 0 ? _a : {};
20188
20094
  this._instructions = options === null || options === void 0 ? void 0 : options.instructions;
20189
20095
  this.setRequestHandler(InitializeRequestSchema, (request) => this._oninitialize(request));
@@ -20191,18 +20097,6 @@
20191
20097
  var _a2;
20192
20098
  return (_a2 = this.oninitialized) === null || _a2 === void 0 ? void 0 : _a2.call(this);
20193
20099
  });
20194
- if (this._capabilities.logging) {
20195
- this.setRequestHandler(SetLevelRequestSchema, async (request, extra) => {
20196
- var _a2;
20197
- const transportSessionId = extra.sessionId || ((_a2 = extra.requestInfo) === null || _a2 === void 0 ? void 0 : _a2.headers["mcp-session-id"]) || void 0;
20198
- const { level } = request.params;
20199
- const parseResult = LoggingLevelSchema.safeParse(level);
20200
- if (parseResult.success) {
20201
- this._loggingLevels.set(transportSessionId, parseResult.data);
20202
- }
20203
- return {};
20204
- });
20205
- }
20206
20100
  }
20207
20101
  /**
20208
20102
  * Registers new capabilities. This can only be called before connecting to a transport.
@@ -20348,19 +20242,8 @@
20348
20242
  async listRoots(params, options) {
20349
20243
  return this.request({ method: "roots/list", params }, ListRootsResultSchema, options);
20350
20244
  }
20351
- /**
20352
- * Sends a logging message to the client, if connected.
20353
- * Note: You only need to send the parameters object, not the entire JSON RPC message
20354
- * @see LoggingMessageNotification
20355
- * @param params
20356
- * @param sessionId optional for stateless and backward compatibility
20357
- */
20358
- async sendLoggingMessage(params, sessionId) {
20359
- if (this._capabilities.logging) {
20360
- if (!this.isMessageIgnored(params.level, sessionId)) {
20361
- return this.notification({ method: "notifications/message", params });
20362
- }
20363
- }
20245
+ async sendLoggingMessage(params) {
20246
+ return this.notification({ method: "notifications/message", params });
20364
20247
  }
20365
20248
  async sendResourceUpdated(params) {
20366
20249
  return this.notification({
@@ -21909,13 +21792,10 @@
21909
21792
  inputSchema: tool.inputSchema ? zodToJsonSchema(tool.inputSchema, {
21910
21793
  strictUnions: true
21911
21794
  }) : EMPTY_OBJECT_JSON_SCHEMA,
21912
- annotations: tool.annotations,
21913
- _meta: tool._meta
21795
+ annotations: tool.annotations
21914
21796
  };
21915
21797
  if (tool.outputSchema) {
21916
- toolDefinition.outputSchema = zodToJsonSchema(tool.outputSchema, {
21917
- strictUnions: true
21918
- });
21798
+ toolDefinition.outputSchema = zodToJsonSchema(tool.outputSchema, { strictUnions: true });
21919
21799
  }
21920
21800
  return toolDefinition;
21921
21801
  })
@@ -22278,14 +22158,13 @@
22278
22158
  this._registeredPrompts[name] = registeredPrompt;
22279
22159
  return registeredPrompt;
22280
22160
  }
22281
- _createRegisteredTool(name, title2, description2, inputSchema, outputSchema, annotations, _meta, callback) {
22161
+ _createRegisteredTool(name, title2, description2, inputSchema, outputSchema, annotations, callback) {
22282
22162
  const registeredTool = {
22283
22163
  title: title2,
22284
22164
  description: description2,
22285
22165
  inputSchema: inputSchema === void 0 ? void 0 : objectType(inputSchema),
22286
22166
  outputSchema: outputSchema === void 0 ? void 0 : objectType(outputSchema),
22287
22167
  annotations,
22288
- _meta,
22289
22168
  callback,
22290
22169
  enabled: true,
22291
22170
  disable: () => registeredTool.update({ enabled: false }),
@@ -22307,8 +22186,6 @@
22307
22186
  registeredTool.callback = updates.callback;
22308
22187
  if (typeof updates.annotations !== "undefined")
22309
22188
  registeredTool.annotations = updates.annotations;
22310
- if (typeof updates._meta !== "undefined")
22311
- registeredTool._meta = updates._meta;
22312
22189
  if (typeof updates.enabled !== "undefined")
22313
22190
  registeredTool.enabled = updates.enabled;
22314
22191
  this.sendToolListChanged();
@@ -22345,7 +22222,7 @@
22345
22222
  }
22346
22223
  }
22347
22224
  const callback = rest[0];
22348
- return this._createRegisteredTool(name, void 0, description2, inputSchema, outputSchema, annotations, void 0, callback);
22225
+ return this._createRegisteredTool(name, void 0, description2, inputSchema, outputSchema, annotations, callback);
22349
22226
  }
22350
22227
  /**
22351
22228
  * Registers a tool with a config object and callback.
@@ -22354,8 +22231,8 @@
22354
22231
  if (this._registeredTools[name]) {
22355
22232
  throw new Error(`Tool ${name} is already registered`);
22356
22233
  }
22357
- const { title: title2, description: description2, inputSchema, outputSchema, annotations, _meta } = config;
22358
- return this._createRegisteredTool(name, title2, description2, inputSchema, outputSchema, annotations, _meta, cb);
22234
+ const { title: title2, description: description2, inputSchema, outputSchema, annotations } = config;
22235
+ return this._createRegisteredTool(name, title2, description2, inputSchema, outputSchema, annotations, cb);
22359
22236
  }
22360
22237
  prompt(name, ...rest) {
22361
22238
  if (this._registeredPrompts[name]) {
@@ -22395,16 +22272,6 @@
22395
22272
  isConnected() {
22396
22273
  return this.server.transport !== void 0;
22397
22274
  }
22398
- /**
22399
- * Sends a logging message to the client, if connected.
22400
- * Note: You only need to send the parameters object, not the entire JSON RPC message
22401
- * @see LoggingMessageNotification
22402
- * @param params
22403
- * @param sessionId optional for stateless and backward compatibility
22404
- */
22405
- async sendLoggingMessage(params, sessionId) {
22406
- return this.server.sendLoggingMessage(params, sessionId);
22407
- }
22408
22275
  /**
22409
22276
  * Sends a resource list changed event to the client, if connected.
22410
22277
  */