@solongate/proxy 0.3.0 → 0.3.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.
Files changed (2) hide show
  1. package/dist/index.js +33 -0
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2037,6 +2037,14 @@ function matchParts(pathParts, pi, patternParts, qi) {
2037
2037
  qi++;
2038
2038
  continue;
2039
2039
  }
2040
+ if (pattern.includes("*")) {
2041
+ if (!matchSegmentGlob(pathParts[pi], pattern)) {
2042
+ return false;
2043
+ }
2044
+ pi++;
2045
+ qi++;
2046
+ continue;
2047
+ }
2040
2048
  if (pattern !== pathParts[pi]) {
2041
2049
  return false;
2042
2050
  }
@@ -2073,6 +2081,31 @@ function isPathAllowed(path, constraints) {
2073
2081
  }
2074
2082
  return true;
2075
2083
  }
2084
+ function matchSegmentGlob(segment, pattern) {
2085
+ const startsWithStar = pattern.startsWith("*");
2086
+ const endsWithStar = pattern.endsWith("*");
2087
+ if (pattern === "*") return true;
2088
+ if (startsWithStar && endsWithStar) {
2089
+ const infix = pattern.slice(1, -1);
2090
+ return segment.toLowerCase().includes(infix.toLowerCase());
2091
+ }
2092
+ if (startsWithStar) {
2093
+ const suffix = pattern.slice(1);
2094
+ return segment.toLowerCase().endsWith(suffix.toLowerCase());
2095
+ }
2096
+ if (endsWithStar) {
2097
+ const prefix = pattern.slice(0, -1);
2098
+ return segment.toLowerCase().startsWith(prefix.toLowerCase());
2099
+ }
2100
+ const starIdx = pattern.indexOf("*");
2101
+ if (starIdx !== -1) {
2102
+ const prefix = pattern.slice(0, starIdx);
2103
+ const suffix = pattern.slice(starIdx + 1);
2104
+ const seg = segment.toLowerCase();
2105
+ return seg.startsWith(prefix.toLowerCase()) && seg.endsWith(suffix.toLowerCase()) && seg.length >= prefix.length + suffix.length;
2106
+ }
2107
+ return segment === pattern;
2108
+ }
2076
2109
  function extractPathArguments(args) {
2077
2110
  const paths = [];
2078
2111
  for (const value of Object.values(args)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solongate/proxy",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "MCP security proxy — protect any MCP server with customizable policies, path/command constraints, rate limiting, and audit logging. Zero code changes required.",
5
5
  "type": "module",
6
6
  "bin": {