@solongate/proxy 0.5.1 → 0.5.3

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.js CHANGED
@@ -128,9 +128,20 @@ function parseArgs(argv) {
128
128
  break;
129
129
  }
130
130
  }
131
+ if (apiKey && /^\$\{.+\}$/.test(apiKey)) {
132
+ apiKey = void 0;
133
+ }
134
+ if (!apiKey) {
135
+ const dotenvPath = resolve(".env");
136
+ if (existsSync(dotenvPath)) {
137
+ const dotenvContent = readFileSync(dotenvPath, "utf-8");
138
+ const match = dotenvContent.match(/^SOLONGATE_API_KEY=(sg_(?:live|test)_\w+)/m);
139
+ if (match) apiKey = match[1];
140
+ }
141
+ }
131
142
  if (!apiKey) {
132
143
  const envKey = process.env.SOLONGATE_API_KEY;
133
- if (envKey) {
144
+ if (envKey && !/^\$\{.+\}$/.test(envKey)) {
134
145
  apiKey = envKey;
135
146
  } else {
136
147
  throw new Error(
@@ -570,7 +581,9 @@ function isAlreadyProtected(server) {
570
581
  return false;
571
582
  }
572
583
  function wrapServer(server, policy) {
573
- const result = {
584
+ const env = { ...server.env ?? {} };
585
+ env.SOLONGATE_API_KEY = "${SOLONGATE_API_KEY}";
586
+ return {
574
587
  command: "npx",
575
588
  args: [
576
589
  "-y",
@@ -581,12 +594,9 @@ function wrapServer(server, policy) {
581
594
  "--",
582
595
  server.command,
583
596
  ...server.args ?? []
584
- ]
597
+ ],
598
+ env
585
599
  };
586
- if (server.env && Object.keys(server.env).length > 0) {
587
- result.env = { ...server.env };
588
- }
589
- return result;
590
600
  }
591
601
  async function prompt(question) {
592
602
  const rl = createInterface({ input: process.stdin, output: process.stderr });
package/dist/init.js CHANGED
@@ -66,7 +66,9 @@ function isAlreadyProtected(server) {
66
66
  return false;
67
67
  }
68
68
  function wrapServer(server, policy) {
69
- const result = {
69
+ const env = { ...server.env ?? {} };
70
+ env.SOLONGATE_API_KEY = "${SOLONGATE_API_KEY}";
71
+ return {
70
72
  command: "npx",
71
73
  args: [
72
74
  "-y",
@@ -77,12 +79,9 @@ function wrapServer(server, policy) {
77
79
  "--",
78
80
  server.command,
79
81
  ...server.args ?? []
80
- ]
82
+ ],
83
+ env
81
84
  };
82
- if (server.env && Object.keys(server.env).length > 0) {
83
- result.env = { ...server.env };
84
- }
85
- return result;
86
85
  }
87
86
  async function prompt(question) {
88
87
  const rl = createInterface({ input: process.stdin, output: process.stderr });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@solongate/proxy",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
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": {