@sota-io/mcp 1.5.0 → 1.6.0
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/README.md +8 -2
- package/dist/auth/token-bridge.d.ts +16 -0
- package/dist/auth/token-bridge.d.ts.map +1 -1
- package/dist/auth/token-bridge.js +49 -9
- package/dist/auth/token-bridge.js.map +1 -1
- package/dist/auth/verify-jwt.js +6 -6
- package/dist/auth/verify-jwt.js.map +1 -1
- package/dist/http-app.d.ts +27 -0
- package/dist/http-app.d.ts.map +1 -0
- package/dist/http-app.js +310 -0
- package/dist/http-app.js.map +1 -0
- package/dist/http.d.ts +3 -15
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +13 -251
- package/dist/http.js.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/archive-builder.d.ts +25 -5
- package/dist/lib/archive-builder.d.ts.map +1 -1
- package/dist/lib/archive-builder.js +105 -34
- package/dist/lib/archive-builder.js.map +1 -1
- package/dist/lib/auth-config.d.ts +37 -0
- package/dist/lib/auth-config.d.ts.map +1 -0
- package/dist/lib/auth-config.js +95 -0
- package/dist/lib/auth-config.js.map +1 -0
- package/dist/lib/hosted-guard.d.ts +26 -0
- package/dist/lib/hosted-guard.d.ts.map +1 -0
- package/dist/lib/hosted-guard.js +48 -0
- package/dist/lib/hosted-guard.js.map +1 -0
- package/dist/lib/log.d.ts +17 -0
- package/dist/lib/log.d.ts.map +1 -0
- package/dist/lib/log.js +41 -0
- package/dist/lib/log.js.map +1 -0
- package/dist/lib/version.d.ts +22 -0
- package/dist/lib/version.d.ts.map +1 -0
- package/dist/lib/version.js +36 -0
- package/dist/lib/version.js.map +1 -0
- package/dist/oauth-proxy.d.ts +31 -0
- package/dist/oauth-proxy.d.ts.map +1 -0
- package/dist/oauth-proxy.js +212 -0
- package/dist/oauth-proxy.js.map +1 -0
- package/dist/tools/create-account.d.ts.map +1 -1
- package/dist/tools/create-account.js +23 -1
- package/dist/tools/create-account.js.map +1 -1
- package/dist/tools/deploy.d.ts +11 -1
- package/dist/tools/deploy.d.ts.map +1 -1
- package/dist/tools/deploy.js +92 -74
- package/dist/tools/deploy.js.map +1 -1
- package/dist/tools/env.js +1 -1
- package/dist/tools/env.js.map +1 -1
- package/package.json +1 -1
package/dist/http.js
CHANGED
|
@@ -1,259 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
* sota.io MCP Server — HTTP
|
|
3
|
+
* sota.io MCP Server — HTTP entry point (mcp.sota.io).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* and Claude.ai.
|
|
8
|
-
*
|
|
9
|
-
* Phase 57-01 (this file): scaffold + transport + RFC 9728 metadata.
|
|
10
|
-
* Auth is currently a pass-through Bearer API key — clients send their
|
|
11
|
-
* existing sota_xxx key as `Authorization: Bearer <key>` and it gets
|
|
12
|
-
* forwarded to sota-api. No OAuth validation yet.
|
|
13
|
-
*
|
|
14
|
-
* Phase 57-02 (next): OAuth 2.1 + JWT validation against Supabase JWKS,
|
|
15
|
-
* token-to-API-key bridge with `source=claude` audit tagging.
|
|
16
|
-
*
|
|
17
|
-
* Phase 57-03 (next): `create_account` tool for net-new user signup from
|
|
18
|
-
* inside Claude + plan-based capability gating.
|
|
5
|
+
* The Express app lives in http-app.ts so tests can start it on an
|
|
6
|
+
* ephemeral port; this file only binds it.
|
|
19
7
|
*/
|
|
20
|
-
import
|
|
21
|
-
import
|
|
22
|
-
import {
|
|
23
|
-
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
24
|
-
import { SotaClient } from '@sota-io/sdk';
|
|
25
|
-
import { registerProjectTools } from './tools/projects.js';
|
|
26
|
-
import { registerDeployTool } from './tools/deploy.js';
|
|
27
|
-
import { registerLogsTool } from './tools/logs.js';
|
|
28
|
-
import { registerEnvTools } from './tools/env.js';
|
|
29
|
-
import { registerRollbackTool } from './tools/rollback.js';
|
|
30
|
-
import { registerStatusTool } from './tools/status.js';
|
|
31
|
-
import { registerDomainTools } from './tools/domains.js';
|
|
32
|
-
import { verifyJwt, JwtVerificationError } from './auth/verify-jwt.js';
|
|
33
|
-
import { getOrProvisionApiKey } from './auth/token-bridge.js';
|
|
34
|
-
import { registerCreateAccountTool } from './tools/create-account.js';
|
|
35
|
-
// Tools that may be invoked WITHOUT authentication. Currently only
|
|
36
|
-
// create_account — net-new users obviously don't have an API key yet.
|
|
37
|
-
// Discovery requests (initialize, tools/list) are also allowed
|
|
38
|
-
// unauthenticated so Claude can fetch capabilities before OAuth.
|
|
39
|
-
const UNAUTHENTICATED_TOOLS = new Set(['create_account']);
|
|
40
|
-
const UNAUTHENTICATED_METHODS = new Set(['initialize', 'notifications/initialized', 'tools/list']);
|
|
41
|
-
function isUnauthenticatedAllowed(body) {
|
|
42
|
-
if (!body || typeof body !== 'object')
|
|
43
|
-
return false;
|
|
44
|
-
const b = body;
|
|
45
|
-
const method = typeof b.method === 'string' ? b.method : '';
|
|
46
|
-
if (UNAUTHENTICATED_METHODS.has(method))
|
|
47
|
-
return true;
|
|
48
|
-
if (method === 'tools/call') {
|
|
49
|
-
const params = (b.params ?? {});
|
|
50
|
-
const name = typeof params.name === 'string' ? params.name : '';
|
|
51
|
-
return UNAUTHENTICATED_TOOLS.has(name);
|
|
52
|
-
}
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
8
|
+
import { app, PUBLIC_ORIGIN } from './http-app.js';
|
|
9
|
+
import { logEvent } from './lib/log.js';
|
|
10
|
+
import { GIT_SHA, PACKAGE_VERSION } from './lib/version.js';
|
|
55
11
|
const PORT = Number(process.env.PORT ?? 8080);
|
|
56
|
-
const SOTA_API_URL = process.env.SOTA_API_URL ?? 'https://api.sota.io';
|
|
57
|
-
const PUBLIC_ORIGIN = process.env.PUBLIC_ORIGIN ?? 'https://mcp.sota.io';
|
|
58
|
-
const AUTH_SERVER = process.env.AUTH_SERVER ?? 'https://auth.sota.io/auth/v1';
|
|
59
|
-
const VERSION = process.env.MCP_SERVER_VERSION ?? '1.4.0-pre';
|
|
60
|
-
const app = express();
|
|
61
|
-
app.use(express.json({ limit: '4mb' }));
|
|
62
|
-
// ───────────────────────────────────────────────────────────────────────────
|
|
63
|
-
// /health — Traefik / Docker healthcheck target
|
|
64
|
-
// ───────────────────────────────────────────────────────────────────────────
|
|
65
|
-
app.get('/health', (_req, res) => {
|
|
66
|
-
res.json({
|
|
67
|
-
ok: true,
|
|
68
|
-
service: 'sota-mcp',
|
|
69
|
-
version: VERSION,
|
|
70
|
-
transport: 'streamable-http',
|
|
71
|
-
ts: new Date().toISOString(),
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
// ───────────────────────────────────────────────────────────────────────────
|
|
75
|
-
// RFC 9728 Protected Resource Metadata
|
|
76
|
-
// ───────────────────────────────────────────────────────────────────────────
|
|
77
|
-
// MCP clients fetch this BEFORE attempting auth. It points them at the
|
|
78
|
-
// Authorization Server (Supabase) and declares the audience binding.
|
|
79
|
-
// Spec: https://datatracker.ietf.org/doc/html/rfc9728
|
|
80
|
-
// MCP requirement: https://modelcontextprotocol.io/specification/2025-06-18/basic/authorization
|
|
81
|
-
app.get('/.well-known/oauth-protected-resource', (_req, res) => {
|
|
82
|
-
res.json({
|
|
83
|
-
resource: PUBLIC_ORIGIN,
|
|
84
|
-
authorization_servers: [AUTH_SERVER],
|
|
85
|
-
bearer_methods_supported: ['header'],
|
|
86
|
-
resource_documentation: 'https://sota.io/docs/integrations/claude',
|
|
87
|
-
scopes_supported: ['openid', 'profile', 'email'],
|
|
88
|
-
resource_signing_alg_values_supported: ['RS256', 'ES256'],
|
|
89
|
-
});
|
|
90
|
-
});
|
|
91
|
-
// ───────────────────────────────────────────────────────────────────────────
|
|
92
|
-
// /mcp — Streamable HTTP transport endpoint
|
|
93
|
-
// ───────────────────────────────────────────────────────────────────────────
|
|
94
|
-
// Stateless mode: every request gets a fresh McpServer + transport instance.
|
|
95
|
-
// Adequate for low-traffic; revisit if we see > 100 RPS sustained.
|
|
96
|
-
function unauthorized(res, reason, detail) {
|
|
97
|
-
res
|
|
98
|
-
.status(401)
|
|
99
|
-
.header('WWW-Authenticate', `Bearer realm="${PUBLIC_ORIGIN}", error="${reason}", resource_metadata="${PUBLIC_ORIGIN}/.well-known/oauth-protected-resource"`)
|
|
100
|
-
.json({ error: 'unauthorized', reason, detail });
|
|
101
|
-
}
|
|
102
|
-
async function handleMcpRequest(req, res) {
|
|
103
|
-
// ── 57-02 Auth: OAuth JWT validation + token-to-key bridge ──
|
|
104
|
-
// Accept Bearer <jwt> (Claude/MCP path) OR Bearer <sota_xxx> (testing/CLI path).
|
|
105
|
-
// sota_-prefixed tokens skip JWT validation and pass through directly.
|
|
106
|
-
const authHeader = req.headers.authorization ?? '';
|
|
107
|
-
const rawToken = authHeader.startsWith('Bearer ')
|
|
108
|
-
? authHeader.slice('Bearer '.length).trim()
|
|
109
|
-
: '';
|
|
110
|
-
const startedAt = Date.now();
|
|
111
|
-
const auditMeta = {
|
|
112
|
-
request_id: crypto.randomUUID(),
|
|
113
|
-
started_at: new Date(startedAt).toISOString(),
|
|
114
|
-
};
|
|
115
|
-
// Anonymous path for discovery + create_account. The MCP server is still
|
|
116
|
-
// constructed, but with a "phantom" apiKey that never reaches sota-api
|
|
117
|
-
// (only the create_account tool is registered and it doesn't use SotaClient).
|
|
118
|
-
let apiKey = '';
|
|
119
|
-
const allowAnonymous = !rawToken && isUnauthenticatedAllowed(req.body);
|
|
120
|
-
if (!rawToken && !allowAnonymous) {
|
|
121
|
-
unauthorized(res, 'missing_token', 'Pass Authorization: Bearer <jwt>');
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
if (allowAnonymous) {
|
|
125
|
-
auditMeta.auth_path = 'anonymous';
|
|
126
|
-
apiKey = 'anonymous';
|
|
127
|
-
}
|
|
128
|
-
else if (rawToken.startsWith('sota_')) {
|
|
129
|
-
// Direct API-key path — legacy testing + CLI use, no OAuth involved.
|
|
130
|
-
apiKey = rawToken;
|
|
131
|
-
auditMeta.auth_path = 'direct_api_key';
|
|
132
|
-
auditMeta.key_prefix = rawToken.slice(0, 13);
|
|
133
|
-
}
|
|
134
|
-
else {
|
|
135
|
-
// JWT path — Claude OAuth
|
|
136
|
-
try {
|
|
137
|
-
const claims = await verifyJwt(rawToken);
|
|
138
|
-
auditMeta.auth_path = 'jwt';
|
|
139
|
-
auditMeta.user_id = claims.sub;
|
|
140
|
-
auditMeta.email = claims.email;
|
|
141
|
-
auditMeta.iss = claims.iss;
|
|
142
|
-
const bridge = await getOrProvisionApiKey(claims.sub);
|
|
143
|
-
apiKey = bridge.apiKey;
|
|
144
|
-
auditMeta.key_provisioned = bridge.created;
|
|
145
|
-
auditMeta.key_rotated = bridge.rotated;
|
|
146
|
-
}
|
|
147
|
-
catch (err) {
|
|
148
|
-
if (err instanceof JwtVerificationError) {
|
|
149
|
-
// eslint-disable-next-line no-console
|
|
150
|
-
console.log(JSON.stringify({
|
|
151
|
-
...auditMeta,
|
|
152
|
-
event: 'auth_failed',
|
|
153
|
-
error_code: err.code,
|
|
154
|
-
error_message: err.message,
|
|
155
|
-
}));
|
|
156
|
-
unauthorized(res, err.code, err.message);
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
// Database / network problem during bridge — surface as 503, not 401
|
|
160
|
-
// eslint-disable-next-line no-console
|
|
161
|
-
console.error(JSON.stringify({
|
|
162
|
-
...auditMeta,
|
|
163
|
-
event: 'bridge_error',
|
|
164
|
-
error_message: err instanceof Error ? err.message : String(err),
|
|
165
|
-
}));
|
|
166
|
-
res.status(503).json({
|
|
167
|
-
error: 'bridge_unavailable',
|
|
168
|
-
message: 'Could not provision an API key for this Claude session — try again in a moment.',
|
|
169
|
-
});
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
// Build a fresh MCP server per request (stateless mode).
|
|
174
|
-
const server = new McpServer({
|
|
175
|
-
name: 'sota',
|
|
176
|
-
version: VERSION,
|
|
177
|
-
title: 'sota.io',
|
|
178
|
-
});
|
|
179
|
-
// create_account is registered ALWAYS — it's the wedge tool that lets
|
|
180
|
-
// brand-new users sign up from inside Claude before they have an API key.
|
|
181
|
-
registerCreateAccountTool(server);
|
|
182
|
-
// The sota-api-backed tools are only registered when the request carries
|
|
183
|
-
// valid auth. For anonymous requests (initialize / tools/list / tools/call
|
|
184
|
-
// create_account), the user just sees create_account in the catalog.
|
|
185
|
-
if (!allowAnonymous) {
|
|
186
|
-
const client = new SotaClient({ apiKey, baseUrl: SOTA_API_URL });
|
|
187
|
-
registerProjectTools(server, client);
|
|
188
|
-
registerDeployTool(server, client);
|
|
189
|
-
registerLogsTool(server, client);
|
|
190
|
-
registerEnvTools(server, client);
|
|
191
|
-
registerRollbackTool(server, client);
|
|
192
|
-
registerStatusTool(server, client);
|
|
193
|
-
registerDomainTools(server, client);
|
|
194
|
-
}
|
|
195
|
-
// Stateless transport — no session header required.
|
|
196
|
-
const transport = new StreamableHTTPServerTransport({
|
|
197
|
-
sessionIdGenerator: undefined,
|
|
198
|
-
});
|
|
199
|
-
res.on('close', () => {
|
|
200
|
-
transport.close().catch(() => { });
|
|
201
|
-
server.close().catch(() => { });
|
|
202
|
-
});
|
|
203
|
-
try {
|
|
204
|
-
await server.connect(transport);
|
|
205
|
-
await transport.handleRequest(req, res, req.body);
|
|
206
|
-
// Structured audit log per request (Claude path only — direct API key calls don't audit here)
|
|
207
|
-
// eslint-disable-next-line no-console
|
|
208
|
-
console.log(JSON.stringify({
|
|
209
|
-
...auditMeta,
|
|
210
|
-
event: 'mcp_request',
|
|
211
|
-
method: req.body?.method,
|
|
212
|
-
duration_ms: Date.now() - startedAt,
|
|
213
|
-
}));
|
|
214
|
-
}
|
|
215
|
-
catch (err) {
|
|
216
|
-
// eslint-disable-next-line no-console
|
|
217
|
-
console.error(JSON.stringify({
|
|
218
|
-
...auditMeta,
|
|
219
|
-
event: 'mcp_error',
|
|
220
|
-
error_message: err instanceof Error ? err.message : String(err),
|
|
221
|
-
duration_ms: Date.now() - startedAt,
|
|
222
|
-
}));
|
|
223
|
-
if (!res.headersSent) {
|
|
224
|
-
res.status(500).json({
|
|
225
|
-
jsonrpc: '2.0',
|
|
226
|
-
error: { code: -32603, message: err instanceof Error ? err.message : String(err) },
|
|
227
|
-
id: null,
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
app.post('/mcp', handleMcpRequest);
|
|
233
|
-
app.get('/mcp', (_req, res) => {
|
|
234
|
-
// GET on /mcp without an active session = 405 Method Not Allowed.
|
|
235
|
-
// (Stateful mode would use GET for the SSE response stream; we're stateless.)
|
|
236
|
-
res.status(405).json({ error: 'method_not_allowed', allowed: 'POST' });
|
|
237
|
-
});
|
|
238
|
-
// ───────────────────────────────────────────────────────────────────────────
|
|
239
|
-
// Root index for humans hitting mcp.sota.io directly
|
|
240
|
-
// ───────────────────────────────────────────────────────────────────────────
|
|
241
|
-
app.get('/', (_req, res) => {
|
|
242
|
-
res.json({
|
|
243
|
-
service: 'sota-mcp',
|
|
244
|
-
version: VERSION,
|
|
245
|
-
description: 'MCP server for sota.io — EU-native PaaS. Use the Streamable HTTP transport at /mcp.',
|
|
246
|
-
docs: 'https://sota.io/docs/integrations/claude',
|
|
247
|
-
endpoints: {
|
|
248
|
-
health: `${PUBLIC_ORIGIN}/health`,
|
|
249
|
-
mcp: `${PUBLIC_ORIGIN}/mcp`,
|
|
250
|
-
protected_resource_metadata: `${PUBLIC_ORIGIN}/.well-known/oauth-protected-resource`,
|
|
251
|
-
},
|
|
252
|
-
});
|
|
253
|
-
});
|
|
254
|
-
// ───────────────────────────────────────────────────────────────────────────
|
|
255
12
|
app.listen(PORT, '0.0.0.0', () => {
|
|
256
|
-
|
|
257
|
-
|
|
13
|
+
logEvent('info', {
|
|
14
|
+
event: 'listening',
|
|
15
|
+
version: PACKAGE_VERSION,
|
|
16
|
+
commit: GIT_SHA,
|
|
17
|
+
url: `http://0.0.0.0:${PORT}`,
|
|
18
|
+
public_origin: PUBLIC_ORIGIN,
|
|
19
|
+
});
|
|
258
20
|
});
|
|
259
21
|
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";AAEA
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAEH,OAAO,EAAE,GAAG,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAE5D,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,IAAI,CAAC,CAAC;AAE9C,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE;IAC/B,QAAQ,CAAC,MAAM,EAAE;QACf,KAAK,EAAE,WAAW;QAClB,OAAO,EAAE,eAAe;QACxB,MAAM,EAAE,OAAO;QACf,GAAG,EAAE,kBAAkB,IAAI,EAAE;QAC7B,aAAa,EAAE,aAAa;KAC7B,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,7 @@ import { registerEnvTools } from './tools/env.js';
|
|
|
33
33
|
import { registerRollbackTool } from './tools/rollback.js';
|
|
34
34
|
import { registerStatusTool } from './tools/status.js';
|
|
35
35
|
import { registerDomainTools } from './tools/domains.js';
|
|
36
|
+
import { PACKAGE_VERSION } from './lib/version.js';
|
|
36
37
|
async function main() {
|
|
37
38
|
const apiKey = process.env.SOTA_API_KEY;
|
|
38
39
|
if (!apiKey) {
|
|
@@ -44,7 +45,7 @@ async function main() {
|
|
|
44
45
|
const client = new SotaClient({ apiKey, baseUrl: apiURL });
|
|
45
46
|
const server = new McpServer({
|
|
46
47
|
name: 'sota',
|
|
47
|
-
version:
|
|
48
|
+
version: PACKAGE_VERSION,
|
|
48
49
|
});
|
|
49
50
|
// Register all tools
|
|
50
51
|
registerProjectTools(server, client);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAm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,EAAE,MAAM,CAAC,CAAC;IAEpC,wBAAwB;IACxB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -12,20 +12,28 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Limits (deliberately generous — we want to lean permissive at launch):
|
|
14
14
|
* files: MAX_INLINE_FILES entries, MAX_INLINE_TOTAL_BYTES total
|
|
15
|
-
* git_url: MAX_CLONE_BYTES
|
|
15
|
+
* git_url: MAX_CLONE_BYTES of archived files after `git clone --depth=1`
|
|
16
|
+
*
|
|
17
|
+
* The hosted server (mcp.sota.io) only uses `files`; directory and git_url
|
|
18
|
+
* are local (stdio) modes, see tools/deploy.ts and lib/hosted-guard.ts.
|
|
16
19
|
*
|
|
17
20
|
* Security:
|
|
21
|
+
* - .git, node_modules, .DS_Store and the local/secret env files (.env,
|
|
22
|
+
* .env.local, .env.*.local, .envrc; any depth, any case) are left out
|
|
23
|
+
* of every archive, whatever the mode.
|
|
24
|
+
* - git and tar run via execFile (no shell).
|
|
18
25
|
* - Inline file paths are normalised + rejected if they contain ".." or
|
|
19
26
|
* start with "/" or contain NUL.
|
|
20
27
|
* - Symlinks are not honoured for inline files (we only write regular files).
|
|
21
28
|
* - Git clone uses `--depth=1` and `--single-branch` to bound bandwidth.
|
|
22
29
|
* - Both modes write to a fresh /tmp dir which is removed after tar.gz is read.
|
|
23
30
|
*/
|
|
31
|
+
export declare function isExcludedName(name: string): boolean;
|
|
24
32
|
/** Upper bound on inline file count (per single `deploy` call). */
|
|
25
33
|
export declare const MAX_INLINE_FILES = 200;
|
|
26
34
|
/** Upper bound on combined inline content length, in bytes. */
|
|
27
35
|
export declare const MAX_INLINE_TOTAL_BYTES: number;
|
|
28
|
-
/** Upper bound on a cloned git repo size
|
|
36
|
+
/** Upper bound on a cloned git repo, in bytes: the summed size of the files the tree walk would archive (collectEntries), so excluded paths such as .git do not count. */
|
|
29
37
|
export declare const MAX_CLONE_BYTES: number;
|
|
30
38
|
export declare class ArchiveBuilderError extends Error {
|
|
31
39
|
readonly code: string;
|
|
@@ -51,9 +59,21 @@ export declare function archiveFromFiles(files: Record<string, string>): Buffer;
|
|
|
51
59
|
export declare function archiveFromGitUrl(gitUrl: string, gitBranch?: string): Buffer;
|
|
52
60
|
/**
|
|
53
61
|
* Pack an existing local directory into a tar.gz Buffer using the same
|
|
54
|
-
* ignore rules as
|
|
55
|
-
* .env
|
|
56
|
-
* code path for archive construction.
|
|
62
|
+
* ignore rules as every other mode (see isExcludedName: .git, node_modules,
|
|
63
|
+
* .DS_Store and the local/secret .env files). Exported so the deploy tool can re-use a
|
|
64
|
+
* single code path for archive construction.
|
|
57
65
|
*/
|
|
58
66
|
export declare function archiveFromDirectory(dir: string): Buffer;
|
|
67
|
+
/**
|
|
68
|
+
* Walk `root` and return the archive entries ("./rel/path", parents before
|
|
69
|
+
* children) plus the byte size of the regular files. Excluded names are
|
|
70
|
+
* skipped at every depth, and excluded directories are not descended into.
|
|
71
|
+
* Symlinks are archived as links and never followed.
|
|
72
|
+
*/
|
|
73
|
+
export declare function collectEntries(root: string): {
|
|
74
|
+
entries: string[];
|
|
75
|
+
totalBytes: number;
|
|
76
|
+
};
|
|
77
|
+
/** True when tar refused to start because it does not know `--null`. */
|
|
78
|
+
export declare function isUnknownNullOption(err: unknown): boolean;
|
|
59
79
|
//# sourceMappingURL=archive-builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archive-builder.d.ts","sourceRoot":"","sources":["../../src/lib/archive-builder.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"archive-builder.d.ts","sourceRoot":"","sources":["../../src/lib/archive-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AA0BH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAGpD;AAED,mEAAmE;AACnE,eAAO,MAAM,gBAAgB,MAAM,CAAC;AACpC,+DAA+D;AAC/D,eAAO,MAAM,sBAAsB,QAAmB,CAAC;AACvD,0KAA0K;AAC1K,eAAO,MAAM,eAAe,QAAoB,CAAC;AAIjD,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;gBACV,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK1C;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAsCtE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,MAAM,CAsD5E;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAYxD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAqBtF;AAoDD,wEAAwE;AACxE,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAGzD"}
|
|
@@ -12,24 +12,45 @@
|
|
|
12
12
|
*
|
|
13
13
|
* Limits (deliberately generous — we want to lean permissive at launch):
|
|
14
14
|
* files: MAX_INLINE_FILES entries, MAX_INLINE_TOTAL_BYTES total
|
|
15
|
-
* git_url: MAX_CLONE_BYTES
|
|
15
|
+
* git_url: MAX_CLONE_BYTES of archived files after `git clone --depth=1`
|
|
16
|
+
*
|
|
17
|
+
* The hosted server (mcp.sota.io) only uses `files`; directory and git_url
|
|
18
|
+
* are local (stdio) modes, see tools/deploy.ts and lib/hosted-guard.ts.
|
|
16
19
|
*
|
|
17
20
|
* Security:
|
|
21
|
+
* - .git, node_modules, .DS_Store and the local/secret env files (.env,
|
|
22
|
+
* .env.local, .env.*.local, .envrc; any depth, any case) are left out
|
|
23
|
+
* of every archive, whatever the mode.
|
|
24
|
+
* - git and tar run via execFile (no shell).
|
|
18
25
|
* - Inline file paths are normalised + rejected if they contain ".." or
|
|
19
26
|
* start with "/" or contain NUL.
|
|
20
27
|
* - Symlinks are not honoured for inline files (we only write regular files).
|
|
21
28
|
* - Git clone uses `--depth=1` and `--single-branch` to bound bandwidth.
|
|
22
29
|
* - Both modes write to a fresh /tmp dir which is removed after tar.gz is read.
|
|
23
30
|
*/
|
|
24
|
-
import {
|
|
25
|
-
import { mkdtempSync, mkdirSync, writeFileSync, readFileSync, rmSync, statSync, } from 'fs';
|
|
31
|
+
import { execFileSync } from 'child_process';
|
|
32
|
+
import { lstatSync, mkdtempSync, mkdirSync, readdirSync, writeFileSync, readFileSync, rmSync, statSync, } from 'fs';
|
|
26
33
|
import { tmpdir } from 'os';
|
|
27
34
|
import { dirname, join, resolve, sep } from 'path';
|
|
35
|
+
/**
|
|
36
|
+
* Names excluded from every archive, at any directory depth, in any case:
|
|
37
|
+
* the local/secret env files `.env`, `.env.local`, `.env.<anything>.local`
|
|
38
|
+
* and direnv's `.envrc`. Committed variants such as `.env.production`,
|
|
39
|
+
* `.env.development`, `.env.test` and `.env.example` are KEPT: sota builds
|
|
40
|
+
* (railpack, docker build) never see set-env values, so apps rely on them
|
|
41
|
+
* for build-time values like NEXT_PUBLIC_*.
|
|
42
|
+
*/
|
|
43
|
+
const LOCAL_ENV_FILE = /^\.env(?:(?:\.[^/]+)?\.local|rc)?$/i;
|
|
44
|
+
export function isExcludedName(name) {
|
|
45
|
+
if (name === '.git' || name === 'node_modules' || name === '.DS_Store')
|
|
46
|
+
return true;
|
|
47
|
+
return LOCAL_ENV_FILE.test(name);
|
|
48
|
+
}
|
|
28
49
|
/** Upper bound on inline file count (per single `deploy` call). */
|
|
29
50
|
export const MAX_INLINE_FILES = 200;
|
|
30
51
|
/** Upper bound on combined inline content length, in bytes. */
|
|
31
52
|
export const MAX_INLINE_TOTAL_BYTES = 10 * 1024 * 1024; // 10 MB
|
|
32
|
-
/** Upper bound on a cloned git repo size
|
|
53
|
+
/** Upper bound on a cloned git repo, in bytes: the summed size of the files the tree walk would archive (collectEntries), so excluded paths such as .git do not count. */
|
|
33
54
|
export const MAX_CLONE_BYTES = 200 * 1024 * 1024; // 200 MB
|
|
34
55
|
/** Upper bound on path component count, to defeat absurd nesting attacks. */
|
|
35
56
|
const MAX_PATH_DEPTH = 32;
|
|
@@ -111,7 +132,7 @@ export function archiveFromGitUrl(gitUrl, gitBranch) {
|
|
|
111
132
|
}
|
|
112
133
|
args.push('--', url, workdir);
|
|
113
134
|
try {
|
|
114
|
-
|
|
135
|
+
execFileSync('git', args, {
|
|
115
136
|
stdio: 'pipe',
|
|
116
137
|
timeout: 120_000,
|
|
117
138
|
});
|
|
@@ -121,7 +142,7 @@ export function archiveFromGitUrl(gitUrl, gitBranch) {
|
|
|
121
142
|
throw new ArchiveBuilderError('git_clone_failed', `git clone failed (URL=${url.slice(0, 120)}${branch ? `, branch=${branch}` : ''}): ${detail.slice(0, 300)}`);
|
|
122
143
|
}
|
|
123
144
|
// Hard size cap: refuse repos that ballooned past MAX_CLONE_BYTES.
|
|
124
|
-
const sizeBytes =
|
|
145
|
+
const sizeBytes = collectEntries(workdir).totalBytes;
|
|
125
146
|
if (sizeBytes > MAX_CLONE_BYTES) {
|
|
126
147
|
throw new ArchiveBuilderError('clone_too_large', `cloned repo is ${(sizeBytes / 1024 / 1024).toFixed(1)} MB (max ${(MAX_CLONE_BYTES / 1024 / 1024).toFixed(0)} MB)`);
|
|
127
148
|
}
|
|
@@ -133,34 +154,100 @@ export function archiveFromGitUrl(gitUrl, gitBranch) {
|
|
|
133
154
|
}
|
|
134
155
|
/**
|
|
135
156
|
* Pack an existing local directory into a tar.gz Buffer using the same
|
|
136
|
-
* ignore rules as
|
|
137
|
-
* .env
|
|
138
|
-
* code path for archive construction.
|
|
157
|
+
* ignore rules as every other mode (see isExcludedName: .git, node_modules,
|
|
158
|
+
* .DS_Store and the local/secret .env files). Exported so the deploy tool can re-use a
|
|
159
|
+
* single code path for archive construction.
|
|
139
160
|
*/
|
|
140
161
|
export function archiveFromDirectory(dir) {
|
|
141
162
|
const abs = resolve(dir);
|
|
163
|
+
let isDir = false;
|
|
142
164
|
try {
|
|
143
|
-
statSync(abs);
|
|
165
|
+
isDir = statSync(abs).isDirectory();
|
|
144
166
|
}
|
|
145
167
|
catch {
|
|
146
168
|
throw new ArchiveBuilderError('not_found', `Directory not found: ${abs}`);
|
|
147
169
|
}
|
|
170
|
+
if (!isDir) {
|
|
171
|
+
throw new ArchiveBuilderError('not_a_directory', `Not a directory: ${abs}`);
|
|
172
|
+
}
|
|
148
173
|
return tarGzWorkdir(abs);
|
|
149
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Walk `root` and return the archive entries ("./rel/path", parents before
|
|
177
|
+
* children) plus the byte size of the regular files. Excluded names are
|
|
178
|
+
* skipped at every depth, and excluded directories are not descended into.
|
|
179
|
+
* Symlinks are archived as links and never followed.
|
|
180
|
+
*/
|
|
181
|
+
export function collectEntries(root) {
|
|
182
|
+
const entries = [];
|
|
183
|
+
let totalBytes = 0;
|
|
184
|
+
const walk = (absDir, relDir) => {
|
|
185
|
+
const dirents = readdirSync(absDir, { withFileTypes: true }).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
186
|
+
for (const d of dirents) {
|
|
187
|
+
if (isExcludedName(d.name))
|
|
188
|
+
continue;
|
|
189
|
+
const abs = join(absDir, d.name);
|
|
190
|
+
const rel = `${relDir}/${d.name}`;
|
|
191
|
+
entries.push(rel);
|
|
192
|
+
if (d.isDirectory()) {
|
|
193
|
+
walk(abs, rel);
|
|
194
|
+
}
|
|
195
|
+
else if (d.isFile()) {
|
|
196
|
+
totalBytes += lstatSync(abs).size;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
walk(root, '.');
|
|
201
|
+
return { entries, totalBytes };
|
|
202
|
+
}
|
|
150
203
|
function tarGzWorkdir(workdir) {
|
|
151
|
-
const
|
|
204
|
+
const { entries } = collectEntries(workdir);
|
|
205
|
+
// The explicit NUL-separated file list (instead of tar --exclude patterns)
|
|
206
|
+
// makes the exclusions identical on GNU tar and bsdtar (macOS, Windows)
|
|
207
|
+
// and case-insensitive for the .env names.
|
|
208
|
+
const scratch = mkdtempSync(join(tmpdir(), 'sota-deploy-'));
|
|
209
|
+
const archivePath = join(scratch, 'source.tar.gz');
|
|
210
|
+
const listPath = join(scratch, 'files.list');
|
|
152
211
|
try {
|
|
153
|
-
|
|
154
|
-
return readFileSync(archivePath);
|
|
155
|
-
}
|
|
156
|
-
finally {
|
|
212
|
+
writeFileSync(listPath, entries.map((e) => `${e}\0`).join(''));
|
|
157
213
|
try {
|
|
158
|
-
|
|
214
|
+
execFileSync('tar', ['-czf', archivePath, '-C', workdir, '--no-recursion', '--null', '-T', listPath], { stdio: 'pipe' });
|
|
159
215
|
}
|
|
160
|
-
catch {
|
|
161
|
-
|
|
216
|
+
catch (err) {
|
|
217
|
+
if (!isUnknownNullOption(err))
|
|
218
|
+
throw tarFailed(err);
|
|
219
|
+
// BusyBox tar (Alpine) has no --null. It reads the list line by line
|
|
220
|
+
// and takes every line literally, so a newline-separated list is the
|
|
221
|
+
// same thing as long as no name contains a newline.
|
|
222
|
+
if (entries.some((e) => e.includes('\n'))) {
|
|
223
|
+
throw new ArchiveBuilderError('tar_failed', 'a file name contains a line break, and the tar on this system (BusyBox) cannot pack such names; rename the file or install GNU tar');
|
|
224
|
+
}
|
|
225
|
+
rmSync(archivePath, { force: true });
|
|
226
|
+
writeFileSync(listPath, entries.map((e) => `${e}\n`).join(''));
|
|
227
|
+
try {
|
|
228
|
+
execFileSync('tar', ['-czf', archivePath, '-C', workdir, '--no-recursion', '-T', listPath], { stdio: 'pipe' });
|
|
229
|
+
}
|
|
230
|
+
catch (err2) {
|
|
231
|
+
throw tarFailed(err2);
|
|
232
|
+
}
|
|
162
233
|
}
|
|
234
|
+
return readFileSync(archivePath);
|
|
163
235
|
}
|
|
236
|
+
finally {
|
|
237
|
+
rmSync(scratch, { recursive: true, force: true });
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
function tarStderr(err) {
|
|
241
|
+
const raw = err?.stderr;
|
|
242
|
+
return raw ? raw.toString() : err instanceof Error ? err.message : String(err);
|
|
243
|
+
}
|
|
244
|
+
/** True when tar refused to start because it does not know `--null`. */
|
|
245
|
+
export function isUnknownNullOption(err) {
|
|
246
|
+
const text = tarStderr(err);
|
|
247
|
+
return /(unrecognized|unknown|invalid|illegal) option/i.test(text) && /null/i.test(text);
|
|
248
|
+
}
|
|
249
|
+
function tarFailed(err) {
|
|
250
|
+
return new ArchiveBuilderError('tar_failed', `could not pack the source archive: ${tarStderr(err).trim().slice(0, 300)}`);
|
|
164
251
|
}
|
|
165
252
|
function sanitiseInlinePath(raw) {
|
|
166
253
|
if (!raw || typeof raw !== 'string') {
|
|
@@ -202,20 +289,4 @@ function isPlausibleGitURL(s) {
|
|
|
202
289
|
return true;
|
|
203
290
|
return false;
|
|
204
291
|
}
|
|
205
|
-
function shellQuote(arg) {
|
|
206
|
-
// Single-quote and escape any embedded single quotes for safe shell pasting.
|
|
207
|
-
return `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
208
|
-
}
|
|
209
|
-
function duBytes(dir) {
|
|
210
|
-
try {
|
|
211
|
-
const out = execSync(`du -sb ${shellQuote(dir)}`, { stdio: ['ignore', 'pipe', 'pipe'] })
|
|
212
|
-
.toString()
|
|
213
|
-
.trim();
|
|
214
|
-
const n = parseInt(out.split(/\s+/)[0] ?? '0', 10);
|
|
215
|
-
return Number.isFinite(n) ? n : 0;
|
|
216
|
-
}
|
|
217
|
-
catch {
|
|
218
|
-
return 0;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
292
|
//# sourceMappingURL=archive-builder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archive-builder.js","sourceRoot":"","sources":["../../src/lib/archive-builder.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"archive-builder.js","sourceRoot":"","sources":["../../src/lib/archive-builder.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EACL,SAAS,EACT,WAAW,EACX,SAAS,EACT,WAAW,EACX,aAAa,EACb,YAAY,EACZ,MAAM,EACN,QAAQ,GACT,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEnD;;;;;;;GAOG;AACH,MAAM,cAAc,GAAG,qCAAqC,CAAC;AAE7D,MAAM,UAAU,cAAc,CAAC,IAAY;IACzC,IAAI,IAAI,KAAK,MAAM,IAAI,IAAI,KAAK,cAAc,IAAI,IAAI,KAAK,WAAW;QAAE,OAAO,IAAI,CAAC;IACpF,OAAO,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACnC,CAAC;AAED,mEAAmE;AACnE,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,QAAQ;AAChE,0KAA0K;AAC1K,MAAM,CAAC,MAAM,eAAe,GAAG,GA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