@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
- }
2999
- const nonSimpleDomain$1 = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
3000
- function consumeIsZone(buffer) {
3001
- buffer.length = 0;
3002
- return true;
3003
3013
  }
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;
3140
- }
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
- }
3161
+ throw new Error("Unexpected dot segment condition");
3155
3162
  }
3156
3163
  }
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
- }
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
3405
3334
  };
3406
- const { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizeComponentEncoding, isIPv4, nonSimpleDomain } = utils;
3407
- const { SCHEMES, getSchemeHandler } = schemes;
3335
+ const wss = {
3336
+ scheme: "wss",
3337
+ domainHost: ws.domainHost,
3338
+ parse: ws.parse,
3339
+ serialize: ws.serialize
3340
+ };
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
@@ -9885,10 +9843,14 @@
9885
9843
  ZodPromise.create;
9886
9844
  const optionalType = ZodOptional.create;
9887
9845
  ZodNullable.create;
9888
- const NEVER = INVALID;
9889
9846
  const LATEST_PROTOCOL_VERSION = "2025-06-18";
9890
9847
  const DEFAULT_NEGOTIATED_PROTOCOL_VERSION = "2025-03-26";
9891
- const SUPPORTED_PROTOCOL_VERSIONS = [LATEST_PROTOCOL_VERSION, "2025-03-26", "2024-11-05", "2024-10-07"];
9848
+ const SUPPORTED_PROTOCOL_VERSIONS = [
9849
+ LATEST_PROTOCOL_VERSION,
9850
+ "2025-03-26",
9851
+ "2024-11-05",
9852
+ "2024-10-07"
9853
+ ];
9892
9854
  const JSONRPC_VERSION = "2.0";
9893
9855
  const ProgressTokenSchema = unionType([stringType(), numberType().int()]);
9894
9856
  const CursorSchema = stringType();
@@ -9968,7 +9930,12 @@
9968
9930
  })
9969
9931
  }).strict();
9970
9932
  const isJSONRPCError = (value) => JSONRPCErrorSchema.safeParse(value).success;
9971
- const JSONRPCMessageSchema = unionType([JSONRPCRequestSchema, JSONRPCNotificationSchema, JSONRPCResponseSchema, JSONRPCErrorSchema]);
9933
+ const JSONRPCMessageSchema = unionType([
9934
+ JSONRPCRequestSchema,
9935
+ JSONRPCNotificationSchema,
9936
+ JSONRPCResponseSchema,
9937
+ JSONRPCErrorSchema
9938
+ ]);
9972
9939
  const EmptyResultSchema = ResultSchema.strict();
9973
9940
  const CancelledNotificationSchema = NotificationSchema.extend({
9974
9941
  method: literalType("notifications/cancelled"),
@@ -9985,57 +9952,22 @@
9985
9952
  reason: stringType().optional()
9986
9953
  })
9987
9954
  });
9988
- const IconSchema = objectType({
9989
- /**
9990
- * URL or data URI for the icon.
9991
- */
9992
- src: stringType(),
9993
- /**
9994
- * Optional MIME type for the icon.
9995
- */
9996
- mimeType: optionalType(stringType()),
9997
- /**
9998
- * Optional array of strings that specify sizes at which the icon can be used.
9999
- * Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG.
10000
- *
10001
- * If not provided, the client should assume that the icon can be used at any size.
10002
- */
10003
- sizes: optionalType(arrayType(stringType()))
10004
- }).passthrough();
10005
- const IconsSchema = objectType({
10006
- /**
10007
- * Optional set of sized icons that the client can display in a user interface.
10008
- *
10009
- * Clients that support rendering icons MUST support at least the following MIME types:
10010
- * - `image/png` - PNG images (safe, universal compatibility)
10011
- * - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)
10012
- *
10013
- * Clients that support rendering icons SHOULD also support:
10014
- * - `image/svg+xml` - SVG images (scalable but requires security precautions)
10015
- * - `image/webp` - WebP images (modern, efficient format)
10016
- */
10017
- icons: arrayType(IconSchema).optional()
10018
- }).passthrough();
10019
9955
  const BaseMetadataSchema = objectType({
10020
9956
  /** Intended for programmatic or logical use, but used as a display name in past specs or fallback */
10021
9957
  name: stringType(),
10022
9958
  /**
10023
- * Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
10024
- * even by those unfamiliar with domain-specific terminology.
10025
- *
10026
- * If not provided, the name should be used for display (except for Tool,
10027
- * where `annotations.title` should be given precedence over using `name`,
10028
- * if present).
10029
- */
9959
+ * Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
9960
+ * even by those unfamiliar with domain-specific terminology.
9961
+ *
9962
+ * If not provided, the name should be used for display (except for Tool,
9963
+ * where `annotations.title` should be given precedence over using `name`,
9964
+ * if present).
9965
+ */
10030
9966
  title: optionalType(stringType())
10031
9967
  }).passthrough();
10032
9968
  const ImplementationSchema = BaseMetadataSchema.extend({
10033
- version: stringType(),
10034
- /**
10035
- * An optional URL of the website for this implementation.
10036
- */
10037
- websiteUrl: optionalType(stringType())
10038
- }).merge(IconsSchema);
9969
+ version: stringType()
9970
+ });
10039
9971
  const ClientCapabilitiesSchema = objectType({
10040
9972
  /**
10041
9973
  * Experimental, non-standard capabilities that the client supports.
@@ -10231,7 +10163,7 @@
10231
10163
  * for notes on _meta usage.
10232
10164
  */
10233
10165
  _meta: optionalType(objectType({}).passthrough())
10234
- }).merge(IconsSchema);
10166
+ });
10235
10167
  const ResourceTemplateSchema = BaseMetadataSchema.extend({
10236
10168
  /**
10237
10169
  * A URI template (according to RFC 6570) that can be used to construct resource URIs.
@@ -10252,7 +10184,7 @@
10252
10184
  * for notes on _meta usage.
10253
10185
  */
10254
10186
  _meta: optionalType(objectType({}).passthrough())
10255
- }).merge(IconsSchema);
10187
+ });
10256
10188
  const ListResourcesRequestSchema = PaginatedRequestSchema.extend({
10257
10189
  method: literalType("resources/list")
10258
10190
  });
@@ -10335,7 +10267,7 @@
10335
10267
  * for notes on _meta usage.
10336
10268
  */
10337
10269
  _meta: optionalType(objectType({}).passthrough())
10338
- }).merge(IconsSchema);
10270
+ });
10339
10271
  const ListPromptsRequestSchema = PaginatedRequestSchema.extend({
10340
10272
  method: literalType("prompts/list")
10341
10273
  });
@@ -10502,7 +10434,7 @@
10502
10434
  * for notes on _meta usage.
10503
10435
  */
10504
10436
  _meta: optionalType(objectType({}).passthrough())
10505
- }).merge(IconsSchema);
10437
+ });
10506
10438
  const ListToolsRequestSchema = PaginatedRequestSchema.extend({
10507
10439
  method: literalType("tools/list")
10508
10440
  });
@@ -10552,7 +10484,16 @@
10552
10484
  const ToolListChangedNotificationSchema = NotificationSchema.extend({
10553
10485
  method: literalType("notifications/tools/list_changed")
10554
10486
  });
10555
- const LoggingLevelSchema = enumType(["debug", "info", "notice", "warning", "error", "critical", "alert", "emergency"]);
10487
+ const LoggingLevelSchema = enumType([
10488
+ "debug",
10489
+ "info",
10490
+ "notice",
10491
+ "warning",
10492
+ "error",
10493
+ "critical",
10494
+ "alert",
10495
+ "emergency"
10496
+ ]);
10556
10497
  const SetLevelRequestSchema = RequestSchema.extend({
10557
10498
  method: literalType("logging/setLevel"),
10558
10499
  params: BaseRequestParamsSchema.extend({
@@ -10645,7 +10586,11 @@
10645
10586
  */
10646
10587
  stopReason: optionalType(enumType(["endTurn", "stopSequence", "maxTokens"]).or(stringType())),
10647
10588
  role: enumType(["user", "assistant"]),
10648
- content: discriminatedUnionType("type", [TextContentSchema, ImageContentSchema, AudioContentSchema])
10589
+ content: discriminatedUnionType("type", [
10590
+ TextContentSchema,
10591
+ ImageContentSchema,
10592
+ AudioContentSchema
10593
+ ])
10649
10594
  });
10650
10595
  const BooleanSchemaSchema = objectType({
10651
10596
  type: literalType("boolean"),
@@ -10675,7 +10620,12 @@
10675
10620
  enum: arrayType(stringType()),
10676
10621
  enumNames: optionalType(arrayType(stringType()))
10677
10622
  }).passthrough();
10678
- const PrimitiveSchemaDefinitionSchema = unionType([BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema, EnumSchemaSchema]);
10623
+ const PrimitiveSchemaDefinitionSchema = unionType([
10624
+ BooleanSchemaSchema,
10625
+ StringSchemaSchema,
10626
+ NumberSchemaSchema,
10627
+ EnumSchemaSchema
10628
+ ]);
10679
10629
  const ElicitRequestSchema = RequestSchema.extend({
10680
10630
  method: literalType("elicitation/create"),
10681
10631
  params: BaseRequestParamsSchema.extend({
@@ -10804,8 +10754,18 @@
10804
10754
  InitializedNotificationSchema,
10805
10755
  RootsListChangedNotificationSchema
10806
10756
  ]);
10807
- const ClientResultSchema = unionType([EmptyResultSchema, CreateMessageResultSchema, ElicitResultSchema, ListRootsResultSchema]);
10808
- const ServerRequestSchema = unionType([PingRequestSchema, CreateMessageRequestSchema, ElicitRequestSchema, ListRootsRequestSchema]);
10757
+ const ClientResultSchema = unionType([
10758
+ EmptyResultSchema,
10759
+ CreateMessageResultSchema,
10760
+ ElicitResultSchema,
10761
+ ListRootsResultSchema
10762
+ ]);
10763
+ const ServerRequestSchema = unionType([
10764
+ PingRequestSchema,
10765
+ CreateMessageRequestSchema,
10766
+ ElicitRequestSchema,
10767
+ ListRootsRequestSchema
10768
+ ]);
10809
10769
  const ServerNotificationSchema = unionType([
10810
10770
  CancelledNotificationSchema,
10811
10771
  ProgressNotificationSchema,
@@ -11163,10 +11123,7 @@
11163
11123
  const totalElapsed = Date.now() - info.startTime;
11164
11124
  if (info.maxTotalTimeout && totalElapsed >= info.maxTotalTimeout) {
11165
11125
  this._timeoutInfo.delete(messageId);
11166
- throw new McpError(exports2.ErrorCode.RequestTimeout, "Maximum total timeout exceeded", {
11167
- maxTotalTimeout: info.maxTotalTimeout,
11168
- totalElapsed
11169
- });
11126
+ throw new McpError(exports2.ErrorCode.RequestTimeout, "Maximum total timeout exceeded", { maxTotalTimeout: info.maxTotalTimeout, totalElapsed });
11170
11127
  }
11171
11128
  clearTimeout(info.timeoutId);
11172
11129
  info.timeoutId = setTimeout(info.onTimeout, info.timeout);
@@ -11238,11 +11195,10 @@
11238
11195
  Promise.resolve().then(() => handler(notification)).catch((error2) => this._onerror(new Error(`Uncaught error in notification handler: ${error2}`)));
11239
11196
  }
11240
11197
  _onrequest(request, extra) {
11241
- var _a, _b;
11198
+ var _a, _b, _c, _d;
11242
11199
  const handler = (_a = this._requestHandlers.get(request.method)) !== null && _a !== void 0 ? _a : this.fallbackRequestHandler;
11243
- const capturedTransport = this._transport;
11244
11200
  if (handler === void 0) {
11245
- capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send({
11201
+ (_b = this._transport) === null || _b === void 0 ? void 0 : _b.send({
11246
11202
  jsonrpc: "2.0",
11247
11203
  id: request.id,
11248
11204
  error: {
@@ -11256,8 +11212,8 @@
11256
11212
  this._requestHandlerAbortControllers.set(request.id, abortController);
11257
11213
  const fullExtra = {
11258
11214
  signal: abortController.signal,
11259
- sessionId: capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.sessionId,
11260
- _meta: (_b = request.params) === null || _b === void 0 ? void 0 : _b._meta,
11215
+ sessionId: (_c = this._transport) === null || _c === void 0 ? void 0 : _c.sessionId,
11216
+ _meta: (_d = request.params) === null || _d === void 0 ? void 0 : _d._meta,
11261
11217
  sendNotification: (notification) => this.notification(notification, { relatedRequestId: request.id }),
11262
11218
  sendRequest: (r, resultSchema, options) => this.request(r, resultSchema, { ...options, relatedRequestId: request.id }),
11263
11219
  authInfo: extra === null || extra === void 0 ? void 0 : extra.authInfo,
@@ -11265,25 +11221,26 @@
11265
11221
  requestInfo: extra === null || extra === void 0 ? void 0 : extra.requestInfo
11266
11222
  };
11267
11223
  Promise.resolve().then(() => handler(request, fullExtra)).then((result) => {
11224
+ var _a2;
11268
11225
  if (abortController.signal.aborted) {
11269
11226
  return;
11270
11227
  }
11271
- return capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send({
11228
+ return (_a2 = this._transport) === null || _a2 === void 0 ? void 0 : _a2.send({
11272
11229
  result,
11273
11230
  jsonrpc: "2.0",
11274
11231
  id: request.id
11275
11232
  });
11276
11233
  }, (error2) => {
11277
- var _a2;
11234
+ var _a2, _b2;
11278
11235
  if (abortController.signal.aborted) {
11279
11236
  return;
11280
11237
  }
11281
- return capturedTransport === null || capturedTransport === void 0 ? void 0 : capturedTransport.send({
11238
+ return (_a2 = this._transport) === null || _a2 === void 0 ? void 0 : _a2.send({
11282
11239
  jsonrpc: "2.0",
11283
11240
  id: request.id,
11284
11241
  error: {
11285
11242
  code: Number.isSafeInteger(error2["code"]) ? error2["code"] : exports2.ErrorCode.InternalError,
11286
- message: (_a2 = error2.message) !== null && _a2 !== void 0 ? _a2 : "Internal error"
11243
+ message: (_b2 = error2.message) !== null && _b2 !== void 0 ? _b2 : "Internal error"
11287
11244
  }
11288
11245
  });
11289
11246
  }).catch((error2) => this._onerror(new Error(`Failed to send response: ${error2}`))).finally(() => {
@@ -12114,24 +12071,24 @@
12114
12071
  }
12115
12072
  return uriTokens.length ? uriTokens.join("") : void 0;
12116
12073
  }
12117
- var RDS1 = /^\.\.?\//;
12118
- var RDS2 = /^\/\.(\/|$)/;
12119
- var RDS3 = /^\/\.\.(\/|$)/;
12120
- var RDS5 = /^\/?(?:.|\n)*?(?=\/|$)/;
12074
+ var RDS12 = /^\.\.?\//;
12075
+ var RDS22 = /^\/\.(\/|$)/;
12076
+ var RDS32 = /^\/\.\.(\/|$)/;
12077
+ var RDS52 = /^\/?(?:.|\n)*?(?=\/|$)/;
12121
12078
  function removeDotSegments2(input) {
12122
12079
  var output = [];
12123
12080
  while (input.length) {
12124
- if (input.match(RDS1)) {
12125
- input = input.replace(RDS1, "");
12126
- } else if (input.match(RDS2)) {
12127
- input = input.replace(RDS2, "/");
12128
- } else if (input.match(RDS3)) {
12129
- input = input.replace(RDS3, "/");
12081
+ if (input.match(RDS12)) {
12082
+ input = input.replace(RDS12, "");
12083
+ } else if (input.match(RDS22)) {
12084
+ input = input.replace(RDS22, "/");
12085
+ } else if (input.match(RDS32)) {
12086
+ input = input.replace(RDS32, "/");
12130
12087
  output.pop();
12131
12088
  } else if (input === "." || input === "..") {
12132
12089
  input = "";
12133
12090
  } else {
12134
- var im = input.match(RDS5);
12091
+ var im = input.match(RDS52);
12135
12092
  if (im) {
12136
12093
  var s = im[0];
12137
12094
  input = input.slice(s.length);
@@ -12194,7 +12151,7 @@
12194
12151
  }
12195
12152
  return uriTokens.join("");
12196
12153
  }
12197
- function resolveComponents(base2, relative) {
12154
+ function resolveComponents2(base2, relative) {
12198
12155
  var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
12199
12156
  var skipNormalization = arguments[3];
12200
12157
  var target = {};
@@ -12251,7 +12208,7 @@
12251
12208
  }
12252
12209
  function resolve2(baseURI, relativeURI, options) {
12253
12210
  var schemelessOptions = assign({ scheme: "null" }, options);
12254
- return serialize2(resolveComponents(parse2(baseURI, schemelessOptions), parse2(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
12211
+ return serialize2(resolveComponents2(parse2(baseURI, schemelessOptions), parse2(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
12255
12212
  }
12256
12213
  function normalize2(uri2, options) {
12257
12214
  if (typeof uri2 === "string") {
@@ -12306,7 +12263,7 @@
12306
12263
  parse: handler.parse,
12307
12264
  serialize: handler.serialize
12308
12265
  };
12309
- function isSecure(wsComponents) {
12266
+ function isSecure2(wsComponents) {
12310
12267
  return typeof wsComponents.secure === "boolean" ? wsComponents.secure : String(wsComponents.scheme).toLowerCase() === "wss";
12311
12268
  }
12312
12269
  var handler$2 = {
@@ -12314,14 +12271,14 @@
12314
12271
  domainHost: true,
12315
12272
  parse: function parse3(components, options) {
12316
12273
  var wsComponents = components;
12317
- wsComponents.secure = isSecure(wsComponents);
12274
+ wsComponents.secure = isSecure2(wsComponents);
12318
12275
  wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : "");
12319
12276
  wsComponents.path = void 0;
12320
12277
  wsComponents.query = void 0;
12321
12278
  return wsComponents;
12322
12279
  },
12323
12280
  serialize: function serialize3(wsComponents, options) {
12324
- if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") {
12281
+ if (wsComponents.port === (isSecure2(wsComponents) ? 443 : 80) || wsComponents.port === "") {
12325
12282
  wsComponents.port = void 0;
12326
12283
  }
12327
12284
  if (typeof wsComponents.secure === "boolean") {
@@ -12512,7 +12469,7 @@
12512
12469
  exports4.parse = parse2;
12513
12470
  exports4.removeDotSegments = removeDotSegments2;
12514
12471
  exports4.serialize = serialize2;
12515
- exports4.resolveComponents = resolveComponents;
12472
+ exports4.resolveComponents = resolveComponents2;
12516
12473
  exports4.resolve = resolve2;
12517
12474
  exports4.normalize = normalize2;
12518
12475
  exports4.equal = equal2;
@@ -17713,22 +17670,9 @@
17713
17670
  code_challenge: challenge
17714
17671
  };
17715
17672
  }
17716
- const SafeUrlSchema = stringType().url().superRefine((val, ctx) => {
17717
- if (!URL.canParse(val)) {
17718
- ctx.addIssue({
17719
- code: ZodIssueCode.custom,
17720
- message: "URL must be parseable",
17721
- fatal: true
17722
- });
17723
- return NEVER;
17724
- }
17725
- }).refine((url) => {
17726
- const u = new URL(url);
17727
- return u.protocol !== "javascript:" && u.protocol !== "data:" && u.protocol !== "vbscript:";
17728
- }, { message: "URL cannot use javascript:, data:, or vbscript: scheme" });
17729
17673
  const OAuthProtectedResourceMetadataSchema = objectType({
17730
17674
  resource: stringType().url(),
17731
- authorization_servers: arrayType(SafeUrlSchema).optional(),
17675
+ authorization_servers: arrayType(stringType().url()).optional(),
17732
17676
  jwks_uri: stringType().url().optional(),
17733
17677
  scopes_supported: arrayType(stringType()).optional(),
17734
17678
  bearer_methods_supported: arrayType(stringType()).optional(),
@@ -17744,17 +17688,17 @@
17744
17688
  }).passthrough();
17745
17689
  const OAuthMetadataSchema = objectType({
17746
17690
  issuer: stringType(),
17747
- authorization_endpoint: SafeUrlSchema,
17748
- token_endpoint: SafeUrlSchema,
17749
- registration_endpoint: SafeUrlSchema.optional(),
17691
+ authorization_endpoint: stringType(),
17692
+ token_endpoint: stringType(),
17693
+ registration_endpoint: stringType().optional(),
17750
17694
  scopes_supported: arrayType(stringType()).optional(),
17751
17695
  response_types_supported: arrayType(stringType()),
17752
17696
  response_modes_supported: arrayType(stringType()).optional(),
17753
17697
  grant_types_supported: arrayType(stringType()).optional(),
17754
17698
  token_endpoint_auth_methods_supported: arrayType(stringType()).optional(),
17755
17699
  token_endpoint_auth_signing_alg_values_supported: arrayType(stringType()).optional(),
17756
- service_documentation: SafeUrlSchema.optional(),
17757
- revocation_endpoint: SafeUrlSchema.optional(),
17700
+ service_documentation: stringType().optional(),
17701
+ revocation_endpoint: stringType().optional(),
17758
17702
  revocation_endpoint_auth_methods_supported: arrayType(stringType()).optional(),
17759
17703
  revocation_endpoint_auth_signing_alg_values_supported: arrayType(stringType()).optional(),
17760
17704
  introspection_endpoint: stringType().optional(),
@@ -17764,11 +17708,11 @@
17764
17708
  }).passthrough();
17765
17709
  const OpenIdProviderMetadataSchema = objectType({
17766
17710
  issuer: stringType(),
17767
- authorization_endpoint: SafeUrlSchema,
17768
- token_endpoint: SafeUrlSchema,
17769
- userinfo_endpoint: SafeUrlSchema.optional(),
17770
- jwks_uri: SafeUrlSchema,
17771
- registration_endpoint: SafeUrlSchema.optional(),
17711
+ authorization_endpoint: stringType(),
17712
+ token_endpoint: stringType(),
17713
+ userinfo_endpoint: stringType().optional(),
17714
+ jwks_uri: stringType(),
17715
+ registration_endpoint: stringType().optional(),
17772
17716
  scopes_supported: arrayType(stringType()).optional(),
17773
17717
  response_types_supported: arrayType(stringType()),
17774
17718
  response_modes_supported: arrayType(stringType()).optional(),
@@ -17796,8 +17740,8 @@
17796
17740
  request_parameter_supported: booleanType().optional(),
17797
17741
  request_uri_parameter_supported: booleanType().optional(),
17798
17742
  require_request_uri_registration: booleanType().optional(),
17799
- op_policy_uri: SafeUrlSchema.optional(),
17800
- op_tos_uri: SafeUrlSchema.optional()
17743
+ op_policy_uri: stringType().optional(),
17744
+ op_tos_uri: stringType().optional()
17801
17745
  }).passthrough();
17802
17746
  const OpenIdProviderDiscoveryMetadataSchema = OpenIdProviderMetadataSchema.merge(OAuthMetadataSchema.pick({
17803
17747
  code_challenge_methods_supported: true
@@ -17816,20 +17760,19 @@
17816
17760
  error_description: stringType().optional(),
17817
17761
  error_uri: stringType().optional()
17818
17762
  });
17819
- const OptionalSafeUrlSchema = SafeUrlSchema.optional().or(literalType("").transform(() => void 0));
17820
17763
  const OAuthClientMetadataSchema = objectType({
17821
- redirect_uris: arrayType(SafeUrlSchema),
17764
+ redirect_uris: arrayType(stringType()).refine((uris) => uris.every((uri2) => URL.canParse(uri2)), { message: "redirect_uris must contain valid URLs" }),
17822
17765
  token_endpoint_auth_method: stringType().optional(),
17823
17766
  grant_types: arrayType(stringType()).optional(),
17824
17767
  response_types: arrayType(stringType()).optional(),
17825
17768
  client_name: stringType().optional(),
17826
- client_uri: SafeUrlSchema.optional(),
17827
- logo_uri: OptionalSafeUrlSchema,
17769
+ client_uri: stringType().optional(),
17770
+ logo_uri: stringType().optional(),
17828
17771
  scope: stringType().optional(),
17829
17772
  contacts: arrayType(stringType()).optional(),
17830
- tos_uri: OptionalSafeUrlSchema,
17773
+ tos_uri: stringType().optional(),
17831
17774
  policy_uri: stringType().optional(),
17832
- jwks_uri: SafeUrlSchema.optional(),
17775
+ jwks_uri: stringType().optional(),
17833
17776
  jwks: anyType().optional(),
17834
17777
  software_id: stringType().optional(),
17835
17778
  software_version: stringType().optional(),
@@ -17962,8 +17905,6 @@
17962
17905
  super(message !== null && message !== void 0 ? message : "Unauthorized");
17963
17906
  }
17964
17907
  }
17965
- const AUTHORIZATION_CODE_RESPONSE_TYPE = "code";
17966
- const AUTHORIZATION_CODE_CHALLENGE_METHOD = "S256";
17967
17908
  function selectClientAuthMethod(clientInformation, supportedMethods) {
17968
17909
  const hasClientSecret = clientInformation.client_secret !== void 0;
17969
17910
  if (supportedMethods.length === 0) {
@@ -18067,8 +18008,7 @@
18067
18008
  }
18068
18009
  const fullInformation = await registerClient(authorizationServerUrl, {
18069
18010
  metadata: metadata2,
18070
- clientMetadata: provider.clientMetadata,
18071
- fetchFn
18011
+ clientMetadata: provider.clientMetadata
18072
18012
  });
18073
18013
  await provider.saveClientInformation(fullInformation);
18074
18014
  clientInformation = fullInformation;
@@ -18096,8 +18036,7 @@
18096
18036
  clientInformation,
18097
18037
  refreshToken: tokens.refresh_token,
18098
18038
  resource,
18099
- addClientAuthentication: provider.addClientAuthentication,
18100
- fetchFn
18039
+ addClientAuthentication: provider.addClientAuthentication
18101
18040
  });
18102
18041
  await provider.saveTokens(newTokens);
18103
18042
  return "AUTHORIZED";
@@ -18194,7 +18133,7 @@
18194
18133
  return await fetchWithCorsRetry(url, headers, fetchFn);
18195
18134
  }
18196
18135
  function shouldAttemptFallback(response, pathname) {
18197
- return !response || response.status >= 400 && response.status < 500 && pathname !== "/";
18136
+ return !response || response.status === 404 && pathname !== "/";
18198
18137
  }
18199
18138
  async function discoverMetadataWithFallback(serverUrl, wellKnownType, fetchFn, opts) {
18200
18139
  var _a, _b;
@@ -18276,15 +18215,13 @@
18276
18215
  return urlsToTry;
18277
18216
  }
18278
18217
  async function discoverAuthorizationServerMetadata(authorizationServerUrl, { fetchFn = fetch, protocolVersion = LATEST_PROTOCOL_VERSION } = {}) {
18279
- const headers = {
18280
- "MCP-Protocol-Version": protocolVersion,
18281
- Accept: "application/json"
18282
- };
18218
+ var _a;
18219
+ const headers = { "MCP-Protocol-Version": protocolVersion };
18283
18220
  const urlsToTry = buildDiscoveryUrls(authorizationServerUrl);
18284
18221
  for (const { url: endpointUrl, type: type2 } of urlsToTry) {
18285
18222
  const response = await fetchWithCorsRetry(endpointUrl, headers, fetchFn);
18286
18223
  if (!response) {
18287
- continue;
18224
+ throw new Error(`CORS error trying to load ${type2 === "oauth" ? "OAuth" : "OpenID provider"} metadata from ${endpointUrl}`);
18288
18225
  }
18289
18226
  if (!response.ok) {
18290
18227
  if (response.status >= 400 && response.status < 500) {
@@ -18295,20 +18232,26 @@
18295
18232
  if (type2 === "oauth") {
18296
18233
  return OAuthMetadataSchema.parse(await response.json());
18297
18234
  } else {
18298
- return OpenIdProviderDiscoveryMetadataSchema.parse(await response.json());
18235
+ const metadata2 = OpenIdProviderDiscoveryMetadataSchema.parse(await response.json());
18236
+ if (!((_a = metadata2.code_challenge_methods_supported) === null || _a === void 0 ? void 0 : _a.includes("S256"))) {
18237
+ throw new Error(`Incompatible OIDC provider at ${endpointUrl}: does not support S256 code challenge method required by MCP specification`);
18238
+ }
18239
+ return metadata2;
18299
18240
  }
18300
18241
  }
18301
18242
  return void 0;
18302
18243
  }
18303
18244
  async function startAuthorization(authorizationServerUrl, { metadata: metadata2, clientInformation, redirectUrl, scope: scope2, state, resource }) {
18245
+ const responseType = "code";
18246
+ const codeChallengeMethod = "S256";
18304
18247
  let authorizationUrl;
18305
18248
  if (metadata2) {
18306
18249
  authorizationUrl = new URL(metadata2.authorization_endpoint);
18307
- if (!metadata2.response_types_supported.includes(AUTHORIZATION_CODE_RESPONSE_TYPE)) {
18308
- throw new Error(`Incompatible auth server: does not support response type ${AUTHORIZATION_CODE_RESPONSE_TYPE}`);
18250
+ if (!metadata2.response_types_supported.includes(responseType)) {
18251
+ throw new Error(`Incompatible auth server: does not support response type ${responseType}`);
18309
18252
  }
18310
- if (metadata2.code_challenge_methods_supported && !metadata2.code_challenge_methods_supported.includes(AUTHORIZATION_CODE_CHALLENGE_METHOD)) {
18311
- throw new Error(`Incompatible auth server: does not support code challenge method ${AUTHORIZATION_CODE_CHALLENGE_METHOD}`);
18253
+ if (!metadata2.code_challenge_methods_supported || !metadata2.code_challenge_methods_supported.includes(codeChallengeMethod)) {
18254
+ throw new Error(`Incompatible auth server: does not support code challenge method ${codeChallengeMethod}`);
18312
18255
  }
18313
18256
  } else {
18314
18257
  authorizationUrl = new URL("/authorize", authorizationServerUrl);
@@ -18316,10 +18259,10 @@
18316
18259
  const challenge = await pkceChallenge();
18317
18260
  const codeVerifier = challenge.code_verifier;
18318
18261
  const codeChallenge = challenge.code_challenge;
18319
- authorizationUrl.searchParams.set("response_type", AUTHORIZATION_CODE_RESPONSE_TYPE);
18262
+ authorizationUrl.searchParams.set("response_type", responseType);
18320
18263
  authorizationUrl.searchParams.set("client_id", clientInformation.client_id);
18321
18264
  authorizationUrl.searchParams.set("code_challenge", codeChallenge);
18322
- authorizationUrl.searchParams.set("code_challenge_method", AUTHORIZATION_CODE_CHALLENGE_METHOD);
18265
+ authorizationUrl.searchParams.set("code_challenge_method", codeChallengeMethod);
18323
18266
  authorizationUrl.searchParams.set("redirect_uri", String(redirectUrl));
18324
18267
  if (state) {
18325
18268
  authorizationUrl.searchParams.set("state", state);
@@ -18344,7 +18287,7 @@
18344
18287
  }
18345
18288
  const headers = new Headers({
18346
18289
  "Content-Type": "application/x-www-form-urlencoded",
18347
- Accept: "application/json"
18290
+ "Accept": "application/json"
18348
18291
  });
18349
18292
  const params = new URLSearchParams({
18350
18293
  grant_type: grantType,
@@ -18523,7 +18466,7 @@
18523
18466
  const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
18524
18467
  `, searchIndex);
18525
18468
  let lineEnd = -1;
18526
- 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) {
18469
+ if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = Math.min(crIndex, lfIndex) : crIndex !== -1 ? lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) {
18527
18470
  incompleteLine = chunk.slice(searchIndex);
18528
18471
  break;
18529
18472
  } else {
@@ -18824,11 +18767,7 @@
18824
18767
  }
18825
18768
  let result;
18826
18769
  try {
18827
- result = await auth(this._authProvider, {
18828
- serverUrl: this._url,
18829
- resourceMetadataUrl: this._resourceMetadataUrl,
18830
- fetchFn: this._fetch
18831
- });
18770
+ result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
18832
18771
  } catch (error2) {
18833
18772
  (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error2);
18834
18773
  throw error2;
@@ -18927,12 +18866,7 @@
18927
18866
  if (!this._authProvider) {
18928
18867
  throw new UnauthorizedError("No auth provider");
18929
18868
  }
18930
- const result = await auth(this._authProvider, {
18931
- serverUrl: this._url,
18932
- authorizationCode,
18933
- resourceMetadataUrl: this._resourceMetadataUrl,
18934
- fetchFn: this._fetch
18935
- });
18869
+ const result = await auth(this._authProvider, { serverUrl: this._url, authorizationCode, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
18936
18870
  if (result !== "AUTHORIZED") {
18937
18871
  throw new UnauthorizedError("Failed to authorize");
18938
18872
  }
@@ -18962,11 +18896,7 @@
18962
18896
  if (!response.ok) {
18963
18897
  if (response.status === 401 && this._authProvider) {
18964
18898
  this._resourceMetadataUrl = extractResourceMetadataUrl(response);
18965
- const result = await auth(this._authProvider, {
18966
- serverUrl: this._url,
18967
- resourceMetadataUrl: this._resourceMetadataUrl,
18968
- fetchFn: this._fetch
18969
- });
18899
+ const result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
18970
18900
  if (result !== "AUTHORIZED") {
18971
18901
  throw new UnauthorizedError();
18972
18902
  }
@@ -19021,7 +18951,6 @@
19021
18951
  class StreamableHTTPClientTransport {
19022
18952
  constructor(url, opts) {
19023
18953
  var _a;
19024
- this._hasCompletedAuthFlow = false;
19025
18954
  this._url = url;
19026
18955
  this._resourceMetadataUrl = void 0;
19027
18956
  this._requestInit = opts === null || opts === void 0 ? void 0 : opts.requestInit;
@@ -19037,11 +18966,7 @@
19037
18966
  }
19038
18967
  let result;
19039
18968
  try {
19040
- result = await auth(this._authProvider, {
19041
- serverUrl: this._url,
19042
- resourceMetadataUrl: this._resourceMetadataUrl,
19043
- fetchFn: this._fetch
19044
- });
18969
+ result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
19045
18970
  } catch (error2) {
19046
18971
  (_a = this.onerror) === null || _a === void 0 ? void 0 : _a.call(this, error2);
19047
18972
  throw error2;
@@ -19207,12 +19132,7 @@
19207
19132
  if (!this._authProvider) {
19208
19133
  throw new UnauthorizedError("No auth provider");
19209
19134
  }
19210
- const result = await auth(this._authProvider, {
19211
- serverUrl: this._url,
19212
- authorizationCode,
19213
- resourceMetadataUrl: this._resourceMetadataUrl,
19214
- fetchFn: this._fetch
19215
- });
19135
+ const result = await auth(this._authProvider, { serverUrl: this._url, authorizationCode, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
19216
19136
  if (result !== "AUTHORIZED") {
19217
19137
  throw new UnauthorizedError("Failed to authorize");
19218
19138
  }
@@ -19250,25 +19170,16 @@
19250
19170
  }
19251
19171
  if (!response.ok) {
19252
19172
  if (response.status === 401 && this._authProvider) {
19253
- if (this._hasCompletedAuthFlow) {
19254
- throw new StreamableHTTPError(401, "Server returned 401 after successful authentication");
19255
- }
19256
19173
  this._resourceMetadataUrl = extractResourceMetadataUrl(response);
19257
- const result = await auth(this._authProvider, {
19258
- serverUrl: this._url,
19259
- resourceMetadataUrl: this._resourceMetadataUrl,
19260
- fetchFn: this._fetch
19261
- });
19174
+ const result = await auth(this._authProvider, { serverUrl: this._url, resourceMetadataUrl: this._resourceMetadataUrl, fetchFn: this._fetch });
19262
19175
  if (result !== "AUTHORIZED") {
19263
19176
  throw new UnauthorizedError();
19264
19177
  }
19265
- this._hasCompletedAuthFlow = true;
19266
19178
  return this.send(message);
19267
19179
  }
19268
19180
  const text = await response.text().catch(() => null);
19269
19181
  throw new Error(`Error POSTing to endpoint (HTTP ${response.status}): ${text}`);
19270
19182
  }
19271
- this._hasCompletedAuthFlow = false;
19272
19183
  if (response.status === 202) {
19273
19184
  if (isInitializedNotification(message)) {
19274
19185
  this._startOrAuthSse({ resumptionToken: void 0 }).catch((err) => {
@@ -19351,12 +19262,6 @@
19351
19262
  var _a;
19352
19263
  super(options);
19353
19264
  this._serverInfo = _serverInfo;
19354
- this._loggingLevels = /* @__PURE__ */ new Map();
19355
- this.LOG_LEVEL_SEVERITY = new Map(LoggingLevelSchema.options.map((level, index) => [level, index]));
19356
- this.isMessageIgnored = (level, sessionId) => {
19357
- const currentLevel = this._loggingLevels.get(sessionId);
19358
- return currentLevel ? this.LOG_LEVEL_SEVERITY.get(level) < this.LOG_LEVEL_SEVERITY.get(currentLevel) : false;
19359
- };
19360
19265
  this._capabilities = (_a = options === null || options === void 0 ? void 0 : options.capabilities) !== null && _a !== void 0 ? _a : {};
19361
19266
  this._instructions = options === null || options === void 0 ? void 0 : options.instructions;
19362
19267
  this.setRequestHandler(InitializeRequestSchema, (request) => this._oninitialize(request));
@@ -19364,18 +19269,6 @@
19364
19269
  var _a2;
19365
19270
  return (_a2 = this.oninitialized) === null || _a2 === void 0 ? void 0 : _a2.call(this);
19366
19271
  });
19367
- if (this._capabilities.logging) {
19368
- this.setRequestHandler(SetLevelRequestSchema, async (request, extra) => {
19369
- var _a2;
19370
- const transportSessionId = extra.sessionId || ((_a2 = extra.requestInfo) === null || _a2 === void 0 ? void 0 : _a2.headers["mcp-session-id"]) || void 0;
19371
- const { level } = request.params;
19372
- const parseResult = LoggingLevelSchema.safeParse(level);
19373
- if (parseResult.success) {
19374
- this._loggingLevels.set(transportSessionId, parseResult.data);
19375
- }
19376
- return {};
19377
- });
19378
- }
19379
19272
  }
19380
19273
  /**
19381
19274
  * Registers new capabilities. This can only be called before connecting to a transport.
@@ -19521,19 +19414,8 @@
19521
19414
  async listRoots(params, options) {
19522
19415
  return this.request({ method: "roots/list", params }, ListRootsResultSchema, options);
19523
19416
  }
19524
- /**
19525
- * Sends a logging message to the client, if connected.
19526
- * Note: You only need to send the parameters object, not the entire JSON RPC message
19527
- * @see LoggingMessageNotification
19528
- * @param params
19529
- * @param sessionId optional for stateless and backward compatibility
19530
- */
19531
- async sendLoggingMessage(params, sessionId) {
19532
- if (this._capabilities.logging) {
19533
- if (!this.isMessageIgnored(params.level, sessionId)) {
19534
- return this.notification({ method: "notifications/message", params });
19535
- }
19536
- }
19417
+ async sendLoggingMessage(params) {
19418
+ return this.notification({ method: "notifications/message", params });
19537
19419
  }
19538
19420
  async sendResourceUpdated(params) {
19539
19421
  return this.notification({
@@ -20809,13 +20691,10 @@
20809
20691
  inputSchema: tool.inputSchema ? zodToJsonSchema(tool.inputSchema, {
20810
20692
  strictUnions: true
20811
20693
  }) : EMPTY_OBJECT_JSON_SCHEMA,
20812
- annotations: tool.annotations,
20813
- _meta: tool._meta
20694
+ annotations: tool.annotations
20814
20695
  };
20815
20696
  if (tool.outputSchema) {
20816
- toolDefinition.outputSchema = zodToJsonSchema(tool.outputSchema, {
20817
- strictUnions: true
20818
- });
20697
+ toolDefinition.outputSchema = zodToJsonSchema(tool.outputSchema, { strictUnions: true });
20819
20698
  }
20820
20699
  return toolDefinition;
20821
20700
  })
@@ -21178,14 +21057,13 @@
21178
21057
  this._registeredPrompts[name] = registeredPrompt;
21179
21058
  return registeredPrompt;
21180
21059
  }
21181
- _createRegisteredTool(name, title2, description2, inputSchema, outputSchema, annotations, _meta, callback) {
21060
+ _createRegisteredTool(name, title2, description2, inputSchema, outputSchema, annotations, callback) {
21182
21061
  const registeredTool = {
21183
21062
  title: title2,
21184
21063
  description: description2,
21185
21064
  inputSchema: inputSchema === void 0 ? void 0 : objectType(inputSchema),
21186
21065
  outputSchema: outputSchema === void 0 ? void 0 : objectType(outputSchema),
21187
21066
  annotations,
21188
- _meta,
21189
21067
  callback,
21190
21068
  enabled: true,
21191
21069
  disable: () => registeredTool.update({ enabled: false }),
@@ -21207,8 +21085,6 @@
21207
21085
  registeredTool.callback = updates.callback;
21208
21086
  if (typeof updates.annotations !== "undefined")
21209
21087
  registeredTool.annotations = updates.annotations;
21210
- if (typeof updates._meta !== "undefined")
21211
- registeredTool._meta = updates._meta;
21212
21088
  if (typeof updates.enabled !== "undefined")
21213
21089
  registeredTool.enabled = updates.enabled;
21214
21090
  this.sendToolListChanged();
@@ -21245,7 +21121,7 @@
21245
21121
  }
21246
21122
  }
21247
21123
  const callback = rest[0];
21248
- return this._createRegisteredTool(name, void 0, description2, inputSchema, outputSchema, annotations, void 0, callback);
21124
+ return this._createRegisteredTool(name, void 0, description2, inputSchema, outputSchema, annotations, callback);
21249
21125
  }
21250
21126
  /**
21251
21127
  * Registers a tool with a config object and callback.
@@ -21254,8 +21130,8 @@
21254
21130
  if (this._registeredTools[name]) {
21255
21131
  throw new Error(`Tool ${name} is already registered`);
21256
21132
  }
21257
- const { title: title2, description: description2, inputSchema, outputSchema, annotations, _meta } = config;
21258
- return this._createRegisteredTool(name, title2, description2, inputSchema, outputSchema, annotations, _meta, cb);
21133
+ const { title: title2, description: description2, inputSchema, outputSchema, annotations } = config;
21134
+ return this._createRegisteredTool(name, title2, description2, inputSchema, outputSchema, annotations, cb);
21259
21135
  }
21260
21136
  prompt(name, ...rest) {
21261
21137
  if (this._registeredPrompts[name]) {
@@ -21295,16 +21171,6 @@
21295
21171
  isConnected() {
21296
21172
  return this.server.transport !== void 0;
21297
21173
  }
21298
- /**
21299
- * Sends a logging message to the client, if connected.
21300
- * Note: You only need to send the parameters object, not the entire JSON RPC message
21301
- * @see LoggingMessageNotification
21302
- * @param params
21303
- * @param sessionId optional for stateless and backward compatibility
21304
- */
21305
- async sendLoggingMessage(params, sessionId) {
21306
- return this.server.sendLoggingMessage(params, sessionId);
21307
- }
21308
21174
  /**
21309
21175
  * Sends a resource list changed event to the client, if connected.
21310
21176
  */
@@ -21420,8 +21286,6 @@
21420
21286
  exports2.EnumSchemaSchema = EnumSchemaSchema;
21421
21287
  exports2.GetPromptRequestSchema = GetPromptRequestSchema;
21422
21288
  exports2.GetPromptResultSchema = GetPromptResultSchema;
21423
- exports2.IconSchema = IconSchema;
21424
- exports2.IconsSchema = IconsSchema;
21425
21289
  exports2.ImageContentSchema = ImageContentSchema;
21426
21290
  exports2.ImplementationSchema = ImplementationSchema;
21427
21291
  exports2.InitializeRequestSchema = InitializeRequestSchema;