@relayrail/server 0.1.7 → 0.1.9

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/cli.js CHANGED
@@ -149,6 +149,17 @@ function getApiKeyPrefix(apiKey) {
149
149
  }
150
150
  return apiKey.substring(0, API_KEY_PREFIX.length + 7);
151
151
  }
152
+ function getApiKeyPrefixes(apiKey) {
153
+ if (!apiKey.startsWith(API_KEY_PREFIX)) {
154
+ return [];
155
+ }
156
+ return [
157
+ apiKey.substring(0, API_KEY_PREFIX.length + 7),
158
+ // 10 chars (current)
159
+ apiKey.substring(0, API_KEY_PREFIX.length + 8)
160
+ // 11 chars (legacy)
161
+ ];
162
+ }
152
163
  async function authenticateApiKey(supabase, apiKey) {
153
164
  if (!apiKey || !apiKey.startsWith(API_KEY_PREFIX)) {
154
165
  return {
@@ -173,11 +184,23 @@ async function authenticateApiKey(supabase, apiKey) {
173
184
  }
174
185
  };
175
186
  }
176
- const prefix = getApiKeyPrefix(apiKey);
187
+ const prefixes = getApiKeyPrefixes(apiKey);
177
188
  const hash = hashApiKey(apiKey);
178
- const agentQuery = supabase.from("agents").select("*").eq("api_key_prefix", prefix);
179
- const agentResult = await agentQuery;
180
- if (agentResult.error || !agentResult.data || agentResult.data.length === 0) {
189
+ let agent = null;
190
+ let anyPrefixFound = false;
191
+ for (const prefix of prefixes) {
192
+ const agentQuery = supabase.from("agents").select("*").eq("api_key_prefix", prefix);
193
+ const agentResult = await agentQuery;
194
+ if (agentResult.data && agentResult.data.length > 0) {
195
+ anyPrefixFound = true;
196
+ const matchingAgent = agentResult.data.find((a) => a.api_key_hash === hash);
197
+ if (matchingAgent) {
198
+ agent = matchingAgent;
199
+ break;
200
+ }
201
+ }
202
+ }
203
+ if (!anyPrefixFound) {
181
204
  return {
182
205
  success: false,
183
206
  error: "API key not found",
@@ -188,7 +211,6 @@ async function authenticateApiKey(supabase, apiKey) {
188
211
  }
189
212
  };
190
213
  }
191
- const agent = agentResult.data.find((a) => a.api_key_hash === hash);
192
214
  if (!agent) {
193
215
  return {
194
216
  success: false,
@@ -1803,6 +1825,12 @@ var RelayRailServer = class {
1803
1825
  };
1804
1826
  }
1805
1827
  try {
1828
+ if (this.isProxyMode()) {
1829
+ const result2 = await this.proxyApiCall("get-pending-commands", params);
1830
+ return {
1831
+ content: [{ type: "text", text: JSON.stringify(result2) }]
1832
+ };
1833
+ }
1806
1834
  const result = await getPendingCommands(
1807
1835
  params,
1808
1836
  {
package/dist/index.d.ts CHANGED
@@ -296,6 +296,7 @@ declare function createServer(config: ServerConfig): RelayRailServer;
296
296
  declare function hashApiKey(apiKey: string): string;
297
297
  /**
298
298
  * Extract the prefix from an API key for lookup
299
+ * Returns the current 10-char prefix format (rr_ + 7 chars)
299
300
  */
300
301
  declare function getApiKeyPrefix(apiKey: string): string;
301
302
  /**
package/dist/index.js CHANGED
@@ -147,6 +147,17 @@ function getApiKeyPrefix(apiKey) {
147
147
  }
148
148
  return apiKey.substring(0, API_KEY_PREFIX.length + 7);
149
149
  }
150
+ function getApiKeyPrefixes(apiKey) {
151
+ if (!apiKey.startsWith(API_KEY_PREFIX)) {
152
+ return [];
153
+ }
154
+ return [
155
+ apiKey.substring(0, API_KEY_PREFIX.length + 7),
156
+ // 10 chars (current)
157
+ apiKey.substring(0, API_KEY_PREFIX.length + 8)
158
+ // 11 chars (legacy)
159
+ ];
160
+ }
150
161
  async function authenticateApiKey(supabase, apiKey) {
151
162
  if (!apiKey || !apiKey.startsWith(API_KEY_PREFIX)) {
152
163
  return {
@@ -171,11 +182,23 @@ async function authenticateApiKey(supabase, apiKey) {
171
182
  }
172
183
  };
173
184
  }
174
- const prefix = getApiKeyPrefix(apiKey);
185
+ const prefixes = getApiKeyPrefixes(apiKey);
175
186
  const hash = hashApiKey(apiKey);
176
- const agentQuery = supabase.from("agents").select("*").eq("api_key_prefix", prefix);
177
- const agentResult = await agentQuery;
178
- if (agentResult.error || !agentResult.data || agentResult.data.length === 0) {
187
+ let agent = null;
188
+ let anyPrefixFound = false;
189
+ for (const prefix of prefixes) {
190
+ const agentQuery = supabase.from("agents").select("*").eq("api_key_prefix", prefix);
191
+ const agentResult = await agentQuery;
192
+ if (agentResult.data && agentResult.data.length > 0) {
193
+ anyPrefixFound = true;
194
+ const matchingAgent = agentResult.data.find((a) => a.api_key_hash === hash);
195
+ if (matchingAgent) {
196
+ agent = matchingAgent;
197
+ break;
198
+ }
199
+ }
200
+ }
201
+ if (!anyPrefixFound) {
179
202
  return {
180
203
  success: false,
181
204
  error: "API key not found",
@@ -186,7 +209,6 @@ async function authenticateApiKey(supabase, apiKey) {
186
209
  }
187
210
  };
188
211
  }
189
- const agent = agentResult.data.find((a) => a.api_key_hash === hash);
190
212
  if (!agent) {
191
213
  return {
192
214
  success: false,
@@ -1801,6 +1823,12 @@ var RelayRailServer = class {
1801
1823
  };
1802
1824
  }
1803
1825
  try {
1826
+ if (this.isProxyMode()) {
1827
+ const result2 = await this.proxyApiCall("get-pending-commands", params);
1828
+ return {
1829
+ content: [{ type: "text", text: JSON.stringify(result2) }]
1830
+ };
1831
+ }
1804
1832
  const result = await getPendingCommands(
1805
1833
  params,
1806
1834
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relayrail/server",
3
- "version": "0.1.7",
3
+ "version": "0.1.9",
4
4
  "description": "RelayRail MCP Server - SMS/Email connectivity for AI agents",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",