@vincemakes/kiso-mcp-ext 0.32.1 → 0.32.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/kiso-mcp.mjs +409 -126
  2. package/package.json +2 -2
package/dist/kiso-mcp.mjs CHANGED
@@ -3111,9 +3111,28 @@ var require_utils = __commonJS({
3111
3111
  "use strict";
3112
3112
  var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
3113
3113
  var isIPv4 = 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);
3114
+ var isPort = RegExp.prototype.test.bind(/^\d*$/u);
3114
3115
  var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
3115
3116
  var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
3116
- var isPathCharacter = RegExp.prototype.test.bind(/^[\da-z\-._~!$&'()*+,;=:@/]$/iu);
3117
+ var isPathCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u);
3118
+ var isQueryFragmentCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/?]$/u);
3119
+ var isUserinfoCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:]$/u);
3120
+ var BYTE_HEX = new Array(256);
3121
+ {
3122
+ const HEX_DIGITS = "0123456789ABCDEF";
3123
+ for (let i = 0; i < 256; i++) {
3124
+ BYTE_HEX[i] = "%" + HEX_DIGITS[i >> 4] + HEX_DIGITS[i & 15];
3125
+ }
3126
+ }
3127
+ function percentEncodeNonAscii(cp) {
3128
+ if (cp < 2048) {
3129
+ return BYTE_HEX[192 | cp >> 6] + BYTE_HEX[128 | cp & 63];
3130
+ }
3131
+ if (cp < 65536) {
3132
+ return BYTE_HEX[224 | cp >> 12] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
3133
+ }
3134
+ return BYTE_HEX[240 | cp >> 18] + BYTE_HEX[128 | cp >> 12 & 63] + BYTE_HEX[128 | cp >> 6 & 63] + BYTE_HEX[128 | cp & 63];
3135
+ }
3117
3136
  function stringArrayToHexStripped(input) {
3118
3137
  let acc = "";
3119
3138
  let code = 0;
@@ -3138,91 +3157,105 @@ var require_utils = __commonJS({
3138
3157
  }
3139
3158
  return acc;
3140
3159
  }
3160
+ var isHextet = RegExp.prototype.test.bind(/^[\dA-Fa-f]{1,4}$/);
3161
+ var isIPvFuture = RegExp.prototype.test.bind(/^[vV][\dA-Fa-f]+\.[A-Za-z\d\-._~!$&'()*+,;=:]+$/);
3162
+ var isZoneCharacter = RegExp.prototype.test.bind(/^[A-Za-z\d\-._~]$/);
3141
3163
  var nonSimpleDomain = RegExp.prototype.test.bind(/[^!"$&'()*+,\-.;=_`a-z{}~]/u);
3142
- function consumeIsZone(buffer) {
3143
- buffer.length = 0;
3144
- return true;
3145
- }
3146
- function consumeHextets(buffer, address, output) {
3147
- if (buffer.length) {
3148
- const hex = stringArrayToHexStripped(buffer);
3149
- if (hex !== "") {
3150
- address.push(hex);
3151
- } else {
3152
- output.error = true;
3153
- return false;
3164
+ function isZoneIdentifier(zone) {
3165
+ if (zone.length === 0) return false;
3166
+ for (let i = 0; i < zone.length; i++) {
3167
+ if (isZoneCharacter(zone[i])) continue;
3168
+ if (zone[i] === "%" && i + 2 < zone.length && isHexPair(zone.slice(i + 1, i + 3))) {
3169
+ i += 2;
3170
+ continue;
3154
3171
  }
3155
- buffer.length = 0;
3172
+ return false;
3156
3173
  }
3157
3174
  return true;
3158
3175
  }
3159
- function getIPV6(input) {
3160
- let tokenCount = 0;
3161
- const output = { error: false, address: "", zone: "" };
3162
- const address = [];
3163
- const buffer = [];
3164
- let endipv6Encountered = false;
3165
- let endIpv6 = false;
3166
- let consume = consumeHextets;
3167
- for (let i = 0; i < input.length; i++) {
3168
- const cursor = input[i];
3169
- if (cursor === "[" || cursor === "]") {
3170
- continue;
3171
- }
3172
- if (cursor === ":") {
3173
- if (endipv6Encountered === true) {
3174
- endIpv6 = true;
3175
- }
3176
- if (!consume(buffer, address, output)) {
3177
- break;
3178
- }
3179
- if (++tokenCount > 7) {
3180
- output.error = true;
3181
- break;
3176
+ function compressIPv6ZeroRun(hextets) {
3177
+ let bestStart = -1;
3178
+ let bestLength = 0;
3179
+ let runStart = -1;
3180
+ let runLength = 0;
3181
+ for (let i = 0; i < hextets.length; i++) {
3182
+ if (hextets[i] === "0") {
3183
+ if (runStart === -1) runStart = i;
3184
+ runLength++;
3185
+ if (runLength > bestLength) {
3186
+ bestLength = runLength;
3187
+ bestStart = runStart;
3182
3188
  }
3183
- if (i > 0 && input[i - 1] === ":") {
3184
- endipv6Encountered = true;
3185
- }
3186
- address.push(":");
3187
- continue;
3188
- } else if (cursor === "%") {
3189
- if (!consume(buffer, address, output)) {
3190
- break;
3191
- }
3192
- consume = consumeIsZone;
3193
3189
  } else {
3194
- buffer.push(cursor);
3190
+ runStart = -1;
3191
+ runLength = 0;
3192
+ }
3193
+ }
3194
+ if (bestLength < 2) return hextets.join(":");
3195
+ const head = hextets.slice(0, bestStart).join(":");
3196
+ const tail = hextets.slice(bestStart + bestLength).join(":");
3197
+ return head + "::" + tail;
3198
+ }
3199
+ function normalizeIPv6Address(input) {
3200
+ const compression = input.indexOf("::");
3201
+ if (compression !== -1 && input.indexOf("::", compression + 1) !== -1) return void 0;
3202
+ const left = compression === -1 ? input.split(":") : input.slice(0, compression).split(":");
3203
+ const right = compression === -1 ? [] : input.slice(compression + 2).split(":");
3204
+ if (compression !== -1) {
3205
+ if (left.length === 1 && left[0] === "") left.length = 0;
3206
+ if (right.length === 1 && right[0] === "") right.length = 0;
3207
+ }
3208
+ const parts = left.concat(right);
3209
+ let hextetCount = 0;
3210
+ for (let i = 0; i < parts.length; i++) {
3211
+ const part = parts[i];
3212
+ if (part === "") return void 0;
3213
+ if (part.indexOf(".") !== -1) {
3214
+ if (i !== parts.length - 1 || compression !== -1 && right.length === 0 || !isIPv4(part)) return void 0;
3215
+ hextetCount += 2;
3195
3216
  continue;
3196
3217
  }
3218
+ if (!isHextet(part)) return void 0;
3219
+ parts[i] = parseInt(part, 16).toString(16);
3220
+ hextetCount++;
3197
3221
  }
3198
- if (buffer.length) {
3199
- if (consume === consumeIsZone) {
3200
- output.zone = buffer.join("");
3201
- } else if (endIpv6) {
3202
- address.push(buffer.join(""));
3203
- } else {
3204
- address.push(stringArrayToHexStripped(buffer));
3205
- }
3222
+ if (compression === -1) {
3223
+ if (hextetCount !== 8) return void 0;
3224
+ return compressIPv6ZeroRun(parts);
3206
3225
  }
3207
- output.address = address.join("");
3208
- return output;
3226
+ if (hextetCount >= 8) return void 0;
3227
+ const expanded = parts.slice(0, left.length);
3228
+ for (let i = hextetCount; i < 8; i++) expanded.push("0");
3229
+ for (let i = left.length; i < parts.length; i++) expanded.push(parts[i]);
3230
+ return compressIPv6ZeroRun(expanded);
3209
3231
  }
3210
3232
  function normalizeIPv6(host) {
3211
- if (findToken(host, ":") < 2) {
3212
- return { host, isIPV6: false };
3213
- }
3214
- const ipv62 = getIPV6(host);
3215
- if (!ipv62.error) {
3216
- let newHost = ipv62.address;
3217
- let escapedHost = ipv62.address;
3218
- if (ipv62.zone) {
3219
- newHost += "%" + ipv62.zone;
3220
- escapedHost += "%25" + ipv62.zone;
3221
- }
3222
- return { host: newHost, isIPV6: true, escapedHost };
3223
- } else {
3224
- return { host, isIPV6: false };
3225
- }
3233
+ const bracketed = host[0] === "[" && host[host.length - 1] === "]";
3234
+ const hasBracket = host[0] === "[" || host[host.length - 1] === "]";
3235
+ if (hasBracket && !bracketed) return { host, isIPV6: false, error: true };
3236
+ let input = bracketed ? host.slice(1, -1) : host;
3237
+ if (bracketed && isIPvFuture(input)) {
3238
+ input = input.toLowerCase();
3239
+ return { host: `[${input}]`, escapedHost: input, isIPV6: false, isIPVFuture: true };
3240
+ }
3241
+ if (findToken(input, ":") < 2) {
3242
+ return { host, isIPV6: false, error: bracketed };
3243
+ }
3244
+ let zoneIdentifier = "";
3245
+ const zoneSeparator = input.indexOf("%");
3246
+ if (zoneSeparator !== -1) {
3247
+ const separatorLength = input.slice(zoneSeparator, zoneSeparator + 3).toLowerCase() === "%25" ? 3 : 1;
3248
+ zoneIdentifier = input.slice(zoneSeparator + separatorLength);
3249
+ if (!isZoneIdentifier(zoneIdentifier)) return { host, isIPV6: false, error: true };
3250
+ input = input.slice(0, zoneSeparator);
3251
+ }
3252
+ const address = normalizeIPv6Address(input);
3253
+ if (address === void 0) return { host, isIPV6: false, error: true };
3254
+ return {
3255
+ host: address + (zoneIdentifier ? "%" + zoneIdentifier : ""),
3256
+ escapedHost: address + (zoneIdentifier ? "%25" + zoneIdentifier : ""),
3257
+ isIPV6: true
3258
+ };
3226
3259
  }
3227
3260
  function findToken(str, token) {
3228
3261
  let ind = 0;
@@ -3341,7 +3374,8 @@ var require_utils = __commonJS({
3341
3374
  function normalizePathEncoding(input) {
3342
3375
  let output = "";
3343
3376
  for (let i = 0; i < input.length; i++) {
3344
- if (input[i] === "%" && i + 2 < input.length) {
3377
+ const ch = input[i];
3378
+ if (ch === "%" && i + 2 < input.length) {
3345
3379
  const hex = input.slice(i + 1, i + 3);
3346
3380
  if (isHexPair(hex)) {
3347
3381
  const normalizedHex = hex.toUpperCase();
@@ -3355,10 +3389,152 @@ var require_utils = __commonJS({
3355
3389
  continue;
3356
3390
  }
3357
3391
  }
3358
- if (isPathCharacter(input[i])) {
3359
- output += input[i];
3392
+ if (isPathCharacter(ch)) {
3393
+ output += ch;
3360
3394
  } else {
3361
- output += escape(input[i]);
3395
+ const code = input.charCodeAt(i);
3396
+ if (code < 128) {
3397
+ output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
3398
+ } else if (code < 55296 || code > 57343) {
3399
+ output += percentEncodeNonAscii(code);
3400
+ } else if (code <= 56319 && i + 1 < input.length) {
3401
+ const low = input.charCodeAt(i + 1);
3402
+ if (low >= 56320 && low <= 57343) {
3403
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3404
+ i++;
3405
+ } else {
3406
+ output += percentEncodeNonAscii(65533);
3407
+ }
3408
+ } else {
3409
+ output += percentEncodeNonAscii(65533);
3410
+ }
3411
+ }
3412
+ }
3413
+ return output;
3414
+ }
3415
+ function serializePathEncoding(input, pathNoScheme = false) {
3416
+ let output = "";
3417
+ let firstSegment = pathNoScheme && input[0] !== "/";
3418
+ for (let i = 0; i < input.length; i++) {
3419
+ const ch = input[i];
3420
+ if (ch === "%" && i + 2 < input.length) {
3421
+ const hex = input.slice(i + 1, i + 3);
3422
+ if (isHexPair(hex)) {
3423
+ output += "%" + hex.toUpperCase();
3424
+ i += 2;
3425
+ continue;
3426
+ }
3427
+ }
3428
+ if (ch === "/") {
3429
+ firstSegment = false;
3430
+ }
3431
+ if (isPathCharacter(ch) && (ch !== ":" || !firstSegment)) {
3432
+ output += ch;
3433
+ } else {
3434
+ const code = input.charCodeAt(i);
3435
+ if (code < 128) {
3436
+ output += BYTE_HEX[code];
3437
+ } else if (code < 55296 || code > 57343) {
3438
+ output += percentEncodeNonAscii(code);
3439
+ } else if (code <= 56319 && i + 1 < input.length) {
3440
+ const low = input.charCodeAt(i + 1);
3441
+ if (low >= 56320 && low <= 57343) {
3442
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3443
+ i++;
3444
+ } else {
3445
+ output += percentEncodeNonAscii(65533);
3446
+ }
3447
+ } else {
3448
+ output += percentEncodeNonAscii(65533);
3449
+ }
3450
+ }
3451
+ }
3452
+ return output;
3453
+ }
3454
+ function encodeComponent(input, isAllowed) {
3455
+ let output = "";
3456
+ for (let i = 0; i < input.length; i++) {
3457
+ const ch = input[i];
3458
+ if (ch === "%" && i + 2 < input.length) {
3459
+ const hex = input.slice(i + 1, i + 3);
3460
+ if (isHexPair(hex)) {
3461
+ output += "%" + hex.toUpperCase();
3462
+ i += 2;
3463
+ continue;
3464
+ }
3465
+ }
3466
+ if (isAllowed(ch)) {
3467
+ output += ch;
3468
+ } else {
3469
+ const code = input.charCodeAt(i);
3470
+ if (code < 128) {
3471
+ output += BYTE_HEX[code];
3472
+ } else if (code < 55296 || code > 57343) {
3473
+ output += percentEncodeNonAscii(code);
3474
+ } else if (code <= 56319 && i + 1 < input.length) {
3475
+ const low = input.charCodeAt(i + 1);
3476
+ if (low >= 56320 && low <= 57343) {
3477
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3478
+ i++;
3479
+ } else {
3480
+ output += percentEncodeNonAscii(65533);
3481
+ }
3482
+ } else {
3483
+ output += percentEncodeNonAscii(65533);
3484
+ }
3485
+ }
3486
+ }
3487
+ return output;
3488
+ }
3489
+ function encodeUserinfo(input) {
3490
+ return encodeComponent(input, isUserinfoCharacter);
3491
+ }
3492
+ function encodeQuery(input) {
3493
+ return encodeComponent(input, isQueryFragmentCharacter);
3494
+ }
3495
+ function encodeFragment(input) {
3496
+ return encodeComponent(input, isQueryFragmentCharacter);
3497
+ }
3498
+ function isEscapeSafe(cp) {
3499
+ return cp >= 48 && cp <= 57 || cp >= 65 && cp <= 90 || cp >= 97 && cp <= 122 || cp === 42 || cp === 43 || cp === 45 || cp === 46 || cp === 47 || cp === 64 || cp === 95;
3500
+ }
3501
+ function normalizeQueryFragmentEncoding(input) {
3502
+ let output = "";
3503
+ for (let i = 0; i < input.length; i++) {
3504
+ const ch = input[i];
3505
+ if (ch === "%" && i + 2 < input.length) {
3506
+ const hex = input.slice(i + 1, i + 3);
3507
+ if (isHexPair(hex)) {
3508
+ const normalizedHex = hex.toUpperCase();
3509
+ const decoded = String.fromCharCode(parseInt(normalizedHex, 16));
3510
+ if (isUnreserved(decoded)) {
3511
+ output += decoded;
3512
+ } else {
3513
+ output += "%" + normalizedHex;
3514
+ }
3515
+ i += 2;
3516
+ continue;
3517
+ }
3518
+ }
3519
+ if (isQueryFragmentCharacter(ch)) {
3520
+ output += ch;
3521
+ } else {
3522
+ const code = input.charCodeAt(i);
3523
+ if (code < 128) {
3524
+ output += isEscapeSafe(code) ? ch : BYTE_HEX[code];
3525
+ } else if (code < 55296 || code > 57343) {
3526
+ output += percentEncodeNonAscii(code);
3527
+ } else if (code <= 56319 && i + 1 < input.length) {
3528
+ const low = input.charCodeAt(i + 1);
3529
+ if (low >= 56320 && low <= 57343) {
3530
+ output += percentEncodeNonAscii(65536 + (code - 55296 << 10) + (low - 56320));
3531
+ i++;
3532
+ } else {
3533
+ output += percentEncodeNonAscii(65533);
3534
+ }
3535
+ } else {
3536
+ output += percentEncodeNonAscii(65533);
3537
+ }
3362
3538
  }
3363
3539
  }
3364
3540
  return output;
@@ -3381,14 +3557,18 @@ var require_utils = __commonJS({
3381
3557
  function recomposeAuthority(component) {
3382
3558
  const uriTokens = [];
3383
3559
  if (component.userinfo !== void 0) {
3384
- uriTokens.push(component.userinfo);
3560
+ uriTokens.push(encodeUserinfo(component.userinfo));
3385
3561
  uriTokens.push("@");
3386
3562
  }
3387
3563
  if (component.host !== void 0) {
3388
- let host = unescape(component.host);
3564
+ let host = component.host;
3389
3565
  if (!isIPv4(host)) {
3390
- const ipV6res = normalizeIPv6(host);
3391
- if (ipV6res.isIPV6 === true) {
3566
+ let ipV6res = normalizeIPv6(host);
3567
+ if (ipV6res.isIPV6 !== true && ipV6res.isIPVFuture !== true) {
3568
+ host = normalizePercentEncoding(host, true);
3569
+ ipV6res = normalizeIPv6(host);
3570
+ }
3571
+ if (ipV6res.isIPV6 === true || ipV6res.isIPVFuture === true) {
3392
3572
  host = `[${ipV6res.escapedHost}]`;
3393
3573
  } else {
3394
3574
  host = reescapeHostDelimiters(host, false);
@@ -3397,8 +3577,12 @@ var require_utils = __commonJS({
3397
3577
  uriTokens.push(host);
3398
3578
  }
3399
3579
  if (typeof component.port === "number" || typeof component.port === "string") {
3580
+ const port = String(component.port);
3581
+ if (!isPort(port)) {
3582
+ throw new TypeError("URI port is malformed.");
3583
+ }
3400
3584
  uriTokens.push(":");
3401
- uriTokens.push(String(component.port));
3585
+ uriTokens.push(port);
3402
3586
  }
3403
3587
  return uriTokens.length ? uriTokens.join("") : void 0;
3404
3588
  }
@@ -3408,6 +3592,11 @@ var require_utils = __commonJS({
3408
3592
  reescapeHostDelimiters,
3409
3593
  normalizePercentEncoding,
3410
3594
  normalizePathEncoding,
3595
+ serializePathEncoding,
3596
+ normalizeQueryFragmentEncoding,
3597
+ encodeUserinfo,
3598
+ encodeQuery,
3599
+ encodeFragment,
3411
3600
  escapePreservingEscapes,
3412
3601
  removeDotSegments,
3413
3602
  isIPv4,
@@ -3423,7 +3612,7 @@ var require_schemes = __commonJS({
3423
3612
  "../../node_modules/fast-uri/lib/schemes.js"(exports, module) {
3424
3613
  "use strict";
3425
3614
  var { isUUID } = require_utils();
3426
- var URN_REG = /([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-.:;=@]|%[\da-f]{2})+)/iu;
3615
+ var URN_REG = /^([\da-z][\d\-a-z]{0,31}):((?:[\w!$'()*+,\-./:;=@]|%[\da-f]{2})+)$/iu;
3427
3616
  var supportedSchemeNames = (
3428
3617
  /** @type {const} */
3429
3618
  [
@@ -3484,9 +3673,10 @@ var require_schemes = __commonJS({
3484
3673
  wsComponent.secure = void 0;
3485
3674
  }
3486
3675
  if (wsComponent.resourceName) {
3487
- const [path, query] = wsComponent.resourceName.split("?");
3676
+ const queryIndex = wsComponent.resourceName.indexOf("?");
3677
+ const path = queryIndex === -1 ? wsComponent.resourceName : wsComponent.resourceName.slice(0, queryIndex);
3488
3678
  wsComponent.path = path && path !== "/" ? path : void 0;
3489
- wsComponent.query = query;
3679
+ wsComponent.query = queryIndex === -1 ? void 0 : wsComponent.resourceName.slice(queryIndex + 1);
3490
3680
  wsComponent.resourceName = void 0;
3491
3681
  }
3492
3682
  wsComponent.fragment = void 0;
@@ -3498,7 +3688,7 @@ var require_schemes = __commonJS({
3498
3688
  return urnComponent;
3499
3689
  }
3500
3690
  const matches = urnComponent.path.match(URN_REG);
3501
- if (matches) {
3691
+ if (matches && matches[0] === urnComponent.path) {
3502
3692
  const scheme = options.scheme || urnComponent.scheme || "urn";
3503
3693
  urnComponent.nid = matches[1].toLowerCase();
3504
3694
  urnComponent.nss = matches[2];
@@ -3632,8 +3822,17 @@ var require_schemes = __commonJS({
3632
3822
  var require_fast_uri = __commonJS({
3633
3823
  "../../node_modules/fast-uri/index.js"(exports, module) {
3634
3824
  "use strict";
3635
- var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, escapePreservingEscapes, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3825
+ var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils();
3636
3826
  var { SCHEMES, getSchemeHandler } = require_schemes();
3827
+ var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
3828
+ var MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
3829
+ function decodeValidScheme(scheme) {
3830
+ const decodedScheme = unescape(String(scheme));
3831
+ if (!VALID_SCHEME.test(decodedScheme)) {
3832
+ throw new TypeError(MALFORMED_SCHEME_ERROR);
3833
+ }
3834
+ return decodedScheme;
3835
+ }
3637
3836
  function normalize(uri, options) {
3638
3837
  if (typeof uri === "string") {
3639
3838
  uri = /** @type {T} */
@@ -3646,12 +3845,34 @@ var require_fast_uri = __commonJS({
3646
3845
  }
3647
3846
  function resolve(baseURI, relativeURI, options) {
3648
3847
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
3649
- const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
3650
- const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
3651
- if (baseMalformed || relativeMalformed) {
3848
+ const {
3849
+ parsed: baseParsed,
3850
+ malformedAuthorityOrPort: baseMalformed,
3851
+ malformedPercentEncoding: baseMalformedPercentEncoding,
3852
+ malformedSchemeSpecific: baseMalformedSchemeSpecific,
3853
+ malformedHost: baseMalformedHost,
3854
+ malformedScheme: baseMalformedScheme
3855
+ } = parseWithStatus(baseURI, schemelessOptions);
3856
+ const {
3857
+ parsed: relativeParsed,
3858
+ malformedAuthorityOrPort: relativeMalformed,
3859
+ malformedPercentEncoding: relativeMalformedPercentEncoding,
3860
+ malformedSchemeSpecific: relativeMalformedSchemeSpecific,
3861
+ malformedHost: relativeMalformedHost,
3862
+ malformedScheme: relativeMalformedScheme
3863
+ } = parseWithStatus(relativeURI, schemelessOptions);
3864
+ if (baseMalformed || relativeMalformed || baseMalformedPercentEncoding || relativeMalformedPercentEncoding || baseMalformedSchemeSpecific || relativeMalformedSchemeSpecific || baseMalformedHost || relativeMalformedHost || baseMalformedScheme || relativeMalformedScheme) {
3652
3865
  throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
3653
3866
  }
3654
3867
  const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
3868
+ const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
3869
+ const resolvedHost = resolved.host;
3870
+ const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv4(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
3871
+ canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
3872
+ const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !new RegExp("\\P{ASCII}", "u").test(resolvedHost);
3873
+ if (resolved.error && !encodedASCIIHost) {
3874
+ throw new Error(resolved.error);
3875
+ }
3655
3876
  schemelessOptions.skipEscape = true;
3656
3877
  return serialize(resolved, schemelessOptions);
3657
3878
  }
@@ -3711,7 +3932,7 @@ var require_fast_uri = __commonJS({
3711
3932
  function equal(uriA, uriB, options) {
3712
3933
  const normalizedA = normalizeComparableURI(uriA, options);
3713
3934
  const normalizedB = normalizeComparableURI(uriB, options);
3714
- return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA.toLowerCase() === normalizedB.toLowerCase();
3935
+ return normalizedA !== void 0 && normalizedB !== void 0 && normalizedA === normalizedB;
3715
3936
  }
3716
3937
  function serialize(cmpts, opts) {
3717
3938
  const component = {
@@ -3732,19 +3953,22 @@ var require_fast_uri = __commonJS({
3732
3953
  };
3733
3954
  const options = Object.assign({}, opts);
3734
3955
  const uriTokens = [];
3956
+ if (component.scheme) {
3957
+ component.scheme = decodeValidScheme(component.scheme);
3958
+ }
3735
3959
  const schemeHandler = getSchemeHandler(options.scheme || component.scheme);
3736
3960
  if (schemeHandler && schemeHandler.serialize) schemeHandler.serialize(component, options);
3961
+ const hasAuthority = component.userinfo !== void 0 || component.host !== void 0 || component.port !== void 0;
3962
+ const pathNoScheme = !options.skipEscape && component.scheme === void 0 && !hasAuthority;
3737
3963
  if (component.path !== void 0) {
3738
3964
  if (!options.skipEscape) {
3739
- component.path = escapePreservingEscapes(component.path);
3740
- if (component.scheme !== void 0) {
3741
- component.path = component.path.split("%3A").join(":");
3742
- }
3965
+ component.path = serializePathEncoding(component.path, pathNoScheme);
3743
3966
  } else {
3744
3967
  component.path = normalizePercentEncoding(component.path);
3745
3968
  }
3746
3969
  }
3747
3970
  if (options.reference !== "suffix" && component.scheme) {
3971
+ component.scheme = decodeValidScheme(component.scheme);
3748
3972
  uriTokens.push(component.scheme, ":");
3749
3973
  }
3750
3974
  const authority = recomposeAuthority(component);
@@ -3762,16 +3986,19 @@ var require_fast_uri = __commonJS({
3762
3986
  if (!options.absolutePath && (!schemeHandler || !schemeHandler.absolutePath)) {
3763
3987
  s = removeDotSegments(s);
3764
3988
  }
3989
+ if (pathNoScheme) {
3990
+ s = serializePathEncoding(s, true);
3991
+ }
3765
3992
  if (authority === void 0 && s[0] === "/" && s[1] === "/") {
3766
3993
  s = "/%2F" + s.slice(2);
3767
3994
  }
3768
3995
  uriTokens.push(s);
3769
3996
  }
3770
3997
  if (component.query !== void 0) {
3771
- uriTokens.push("?", component.query);
3998
+ uriTokens.push("?", encodeQuery(component.query));
3772
3999
  }
3773
4000
  if (component.fragment !== void 0) {
3774
- uriTokens.push("#", component.fragment);
4001
+ uriTokens.push("#", encodeFragment(component.fragment));
3775
4002
  }
3776
4003
  return uriTokens.join("");
3777
4004
  }
@@ -3787,6 +4014,35 @@ var require_fast_uri = __commonJS({
3787
4014
  }
3788
4015
  return void 0;
3789
4016
  }
4017
+ function hasMalformedPercentEncoding(component) {
4018
+ if (component === void 0) return false;
4019
+ let percent = component.indexOf("%");
4020
+ while (percent !== -1) {
4021
+ if (percent + 2 >= component.length || !/^[\da-f]{2}$/iu.test(component.slice(percent + 1, percent + 3))) {
4022
+ return true;
4023
+ }
4024
+ percent = component.indexOf("%", percent + 3);
4025
+ }
4026
+ return false;
4027
+ }
4028
+ function isIPLiteral(host) {
4029
+ return host[0] === "[" && host[host.length - 1] === "]";
4030
+ }
4031
+ function hasMalformedComponentPercentEncoding(matches) {
4032
+ const host = matches[4];
4033
+ return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
4034
+ }
4035
+ function canonicalizeHost(parsed, options, schemeHandler, isIP) {
4036
+ if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
4037
+ try {
4038
+ parsed.host = new URL("http://" + parsed.host).hostname;
4039
+ } catch (e) {
4040
+ parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
4041
+ return true;
4042
+ }
4043
+ }
4044
+ return false;
4045
+ }
3790
4046
  function parseWithStatus(uri, opts) {
3791
4047
  const options = Object.assign({}, opts);
3792
4048
  const parsed = {
@@ -3799,6 +4055,11 @@ var require_fast_uri = __commonJS({
3799
4055
  fragment: void 0
3800
4056
  };
3801
4057
  let malformedAuthorityOrPort = false;
4058
+ let malformedPercentEncoding = false;
4059
+ let malformedSchemeSpecific = false;
4060
+ let malformedHost = false;
4061
+ let malformedIPLiteral = false;
4062
+ let malformedScheme = false;
3802
4063
  let isIP = false;
3803
4064
  if (options.reference === "suffix") {
3804
4065
  if (options.scheme) {
@@ -3835,6 +4096,19 @@ var require_fast_uri = __commonJS({
3835
4096
  parsed.path = matches[6] || "";
3836
4097
  parsed.query = matches[7];
3837
4098
  parsed.fragment = matches[8];
4099
+ if (parsed.scheme !== void 0) {
4100
+ const decodedScheme = unescape(parsed.scheme);
4101
+ if (VALID_SCHEME.test(decodedScheme)) {
4102
+ parsed.scheme = decodedScheme.toLowerCase();
4103
+ } else {
4104
+ parsed.error = parsed.error || MALFORMED_SCHEME_ERROR;
4105
+ malformedScheme = true;
4106
+ }
4107
+ }
4108
+ malformedPercentEncoding = hasMalformedComponentPercentEncoding(matches);
4109
+ if (malformedPercentEncoding) {
4110
+ parsed.error = parsed.error || "URI contains malformed percent-encoding.";
4111
+ }
3838
4112
  if (isNaN(parsed.port)) {
3839
4113
  parsed.port = matches[5];
3840
4114
  }
@@ -3846,9 +4120,16 @@ var require_fast_uri = __commonJS({
3846
4120
  if (parsed.host) {
3847
4121
  const ipv4result = isIPv4(parsed.host);
3848
4122
  if (ipv4result === false) {
4123
+ const bracketedIPLiteral = isIPLiteral(parsed.host);
4124
+ const hasIPLiteralBracket = parsed.host.indexOf("[") !== -1 || parsed.host.indexOf("]") !== -1;
3849
4125
  const ipv6result = normalizeIPv6(parsed.host);
3850
- parsed.host = ipv6result.host.toLowerCase();
3851
- isIP = ipv6result.isIPV6;
4126
+ isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
4127
+ malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
4128
+ parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
4129
+ if (malformedIPLiteral) {
4130
+ parsed.error = parsed.error || "URI host is malformed.";
4131
+ malformedAuthorityOrPort = true;
4132
+ }
3852
4133
  } else {
3853
4134
  isIP = true;
3854
4135
  }
@@ -3866,42 +4147,36 @@ var require_fast_uri = __commonJS({
3866
4147
  parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
3867
4148
  }
3868
4149
  const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
3869
- if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport)) {
3870
- if (parsed.host && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
3871
- try {
3872
- parsed.host = new URL("http://" + parsed.host).hostname;
3873
- } catch (e) {
3874
- parsed.error = parsed.error || "Host's domain name can not be converted to ASCII: " + e;
3875
- }
3876
- }
4150
+ if (!malformedIPLiteral) {
4151
+ malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
3877
4152
  }
3878
4153
  if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
3879
4154
  if (uri.indexOf("%") !== -1) {
3880
- if (parsed.scheme !== void 0) {
3881
- parsed.scheme = unescape(parsed.scheme);
3882
- }
3883
- if (parsed.host !== void 0) {
3884
- parsed.host = reescapeHostDelimiters(unescape(parsed.host), isIP);
4155
+ if (parsed.host !== void 0 && !malformedIPLiteral) {
4156
+ const host = isIP ? parsed.host : normalizePercentEncoding(parsed.host, true);
4157
+ parsed.host = reescapeHostDelimiters(host, isIP);
3885
4158
  }
3886
4159
  }
3887
4160
  if (parsed.path) {
3888
4161
  parsed.path = normalizePathEncoding(parsed.path);
3889
4162
  }
4163
+ if (parsed.query) {
4164
+ parsed.query = normalizeQueryFragmentEncoding(parsed.query);
4165
+ }
3890
4166
  if (parsed.fragment) {
3891
- try {
3892
- parsed.fragment = encodeURI(decodeURIComponent(parsed.fragment));
3893
- } catch {
3894
- parsed.error = parsed.error || "URI malformed";
3895
- }
4167
+ parsed.fragment = normalizeQueryFragmentEncoding(parsed.fragment);
3896
4168
  }
3897
4169
  }
3898
4170
  if (schemeHandler && schemeHandler.parse) {
3899
4171
  schemeHandler.parse(parsed, options);
4172
+ if (schemeHandler === SCHEMES.urn && parsed.nid === void 0) {
4173
+ malformedSchemeSpecific = true;
4174
+ }
3900
4175
  }
3901
4176
  } else {
3902
4177
  parsed.error = parsed.error || "URI can not be parsed.";
3903
4178
  }
3904
- return { parsed, malformedAuthorityOrPort };
4179
+ return { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme };
3905
4180
  }
3906
4181
  function parse3(uri, opts) {
3907
4182
  return parseWithStatus(uri, opts).parsed;
@@ -3910,20 +4185,28 @@ var require_fast_uri = __commonJS({
3910
4185
  return normalizeStringWithStatus(uri, opts).normalized;
3911
4186
  }
3912
4187
  function normalizeStringWithStatus(uri, opts) {
3913
- const { parsed, malformedAuthorityOrPort } = parseWithStatus(uri, opts);
4188
+ const { parsed, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = parseWithStatus(uri, opts);
3914
4189
  return {
3915
- normalized: malformedAuthorityOrPort ? uri : serialize(parsed, opts),
3916
- malformedAuthorityOrPort
4190
+ normalized: malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? uri : serialize(parsed, opts),
4191
+ malformedAuthorityOrPort,
4192
+ malformedPercentEncoding,
4193
+ malformedSchemeSpecific,
4194
+ malformedHost,
4195
+ malformedScheme
3917
4196
  };
3918
4197
  }
3919
4198
  function normalizeComparableURI(uri, opts) {
3920
- if (typeof uri === "string") {
3921
- const { normalized, malformedAuthorityOrPort } = normalizeStringWithStatus(uri, opts);
3922
- return malformedAuthorityOrPort ? void 0 : normalized;
4199
+ if (typeof uri !== "string" && typeof uri !== "object") {
4200
+ return void 0;
3923
4201
  }
3924
- if (typeof uri === "object") {
3925
- return serialize(uri, opts);
4202
+ let value;
4203
+ try {
4204
+ value = typeof uri === "string" ? uri : serialize(uri, opts);
4205
+ } catch {
4206
+ return void 0;
3926
4207
  }
4208
+ const { normalized, malformedAuthorityOrPort, malformedPercentEncoding, malformedSchemeSpecific, malformedHost, malformedScheme } = normalizeStringWithStatus(value, opts);
4209
+ return malformedAuthorityOrPort || malformedPercentEncoding || malformedSchemeSpecific || malformedHost || malformedScheme ? void 0 : normalized;
3927
4210
  }
3928
4211
  var fastUri = {
3929
4212
  SCHEMES,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vincemakes/kiso-mcp-ext",
3
- "version": "0.32.1",
3
+ "version": "0.32.2",
4
4
  "description": "kiso official MCP bridge extension — MCP servers become mcp__ tools, kernel untouched",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "devDependencies": {
26
26
  "@modelcontextprotocol/sdk": "^1.0.0",
27
- "@vincemakes/kiso-core": "0.32.1",
27
+ "@vincemakes/kiso-core": "0.32.2",
28
28
  "@types/node": "^26.1.2",
29
29
  "esbuild": "^0.24.0",
30
30
  "typescript": "^5.7.2",