@kubb/mcp 5.1.0 → 5.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -38,7 +38,7 @@ let node_module = require("node:module");
38
38
  let node_process = require("node:process");
39
39
  node_process = __toESM(node_process, 1);
40
40
  //#region package.json
41
- var version = "5.1.0";
41
+ var version = "5.2.1";
42
42
  //#endregion
43
43
  //#region src/schemas/generateSchema.ts
44
44
  const generateSchema = valibot.object({
@@ -4362,12 +4362,12 @@ var import_jiti = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((expor
4362
4362
  value: E
4363
4363
  });
4364
4364
  }, je.readInt = function(e, t, i) {
4365
- for (var n = this.options.ecmaVersion >= 12 && void 0 === t, a = i && 48 === this.input.charCodeAt(this.pos), c = this.pos, l = 0, y = 0, E = 0, w = null == t ? Infinity : t; E < w; ++E, ++this.pos) {
4365
+ for (var n = this.options.ecmaVersion >= 12 && void 0 === t, a = i && 48 === this.input.charCodeAt(this.pos), c = this.pos, l = 0, y = 0, E = 0, w = null == t ? 1 / 0 : t; E < w; ++E, ++this.pos) {
4366
4366
  var C = this.input.charCodeAt(this.pos);
4367
4367
  var S = void 0;
4368
4368
  if (n && 95 === C) a && this.raiseRecoverable(this.pos, "Numeric separator is not allowed in legacy octal numeric literals"), 95 === y && this.raiseRecoverable(this.pos, "Numeric separator must be exactly one underscore"), 0 === E && this.raiseRecoverable(this.pos, "Numeric separator is not allowed at the first of digits"), y = C;
4369
4369
  else {
4370
- if ((S = C >= 97 ? C - 97 + 10 : C >= 65 ? C - 65 + 10 : C >= 48 && C <= 57 ? C - 48 : Infinity) >= e) break;
4370
+ if ((S = C >= 97 ? C - 97 + 10 : C >= 65 ? C - 65 + 10 : C >= 48 && C <= 57 ? C - 48 : 1 / 0) >= e) break;
4371
4371
  y = C, l = l * e + S;
4372
4372
  }
4373
4373
  }
@@ -4388,8 +4388,8 @@ var import_jiti = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((expor
4388
4388
  return ++this.pos, isIdentifierStart(this.fullCharCodeAtPos()) && this.raise(this.pos, "Identifier directly after number"), this.finishToken(O.num, a);
4389
4389
  }
4390
4390
  i && /[89]/.test(this.input.slice(t, this.pos)) && (i = !1), 46 !== n || i || (++this.pos, this.readInt(10), n = this.input.charCodeAt(this.pos)), 69 !== n && 101 !== n || i || (43 !== (n = this.input.charCodeAt(++this.pos)) && 45 !== n || ++this.pos, null === this.readInt(10) && this.raise(t, "Invalid number")), isIdentifierStart(this.fullCharCodeAtPos()) && this.raise(this.pos, "Identifier directly after number");
4391
- var c;
4392
- var l = (c = this.input.slice(t, this.pos), i ? parseInt(c, 8) : parseFloat(c.replace(/_/g, "")));
4391
+ var c = this.input.slice(t, this.pos);
4392
+ var l = i ? parseInt(c, 8) : parseFloat(c.replace(/_/g, ""));
4393
4393
  return this.finishToken(O.num, l);
4394
4394
  }, je.readCodePoint = function() {
4395
4395
  var e;
@@ -6011,6 +6011,29 @@ function createModuleLoader() {
6011
6011
  } };
6012
6012
  }
6013
6013
  //#endregion
6014
+ //#region ../../internals/utils/src/fs.ts
6015
+ /**
6016
+ * Resolves to `true` when `path` is `parent` itself or nested inside it. Both sides are resolved
6017
+ * to absolute paths first, so relative and `..`-containing inputs compare correctly.
6018
+ *
6019
+ * Guards a destructive or an out-of-tree operation: before wiping an output directory, check that
6020
+ * it does not contain the project root, and before loading a path a caller supplied, check that it
6021
+ * did not escape the directory it is allowed to read from.
6022
+ *
6023
+ * @example
6024
+ * isPathInside('./src/gen', '.') // true — nested inside the root
6025
+ * isPathInside('.', '.') // true — the same directory counts as inside
6026
+ * isPathInside('.', './src/gen') // false — the root is not inside its own output
6027
+ * isPathInside('../other', '.') // false — escapes the root
6028
+ */
6029
+ function isPathInside(path, parent) {
6030
+ const resolvedPath = (0, node_path.resolve)(path);
6031
+ const resolvedParent = (0, node_path.resolve)(parent);
6032
+ if (resolvedPath === resolvedParent) return true;
6033
+ const rel = (0, node_path.relative)(resolvedParent, resolvedPath);
6034
+ return rel !== "" && !rel.startsWith("..") && !(0, node_path.isAbsolute)(rel);
6035
+ }
6036
+ //#endregion
6014
6037
  //#region ../../internals/utils/src/promise.ts
6015
6038
  /** Returns `true` when `result` is a thenable `Promise`.
6016
6039
  *
@@ -6082,8 +6105,7 @@ async function loadUserConfig(configPath, { notify }) {
6082
6105
  }
6083
6106
  const base = node_path.default.resolve(process.cwd());
6084
6107
  const resolvedConfigPath = node_path.default.resolve(base, configPath);
6085
- const relative = node_path.default.relative(base, resolvedConfigPath);
6086
- if (relative.startsWith("..") || node_path.default.isAbsolute(relative)) {
6108
+ if (!isPathInside(resolvedConfigPath, base)) {
6087
6109
  const msg = "Invalid config file path: must be within the current working directory";
6088
6110
  await notify("CONFIG_ERROR", msg);
6089
6111
  throw new Error(msg);