@tool-bridge/server 0.26.0 → 0.26.2
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/admin.js
CHANGED
|
@@ -216,7 +216,7 @@ var BootstrapStateStore = class {
|
|
|
216
216
|
// package.json
|
|
217
217
|
var package_default = {
|
|
218
218
|
name: "@tool-bridge/server",
|
|
219
|
-
version: "0.26.
|
|
219
|
+
version: "0.26.2",
|
|
220
220
|
description: "Self-hosted Tool Bridge Node server with PostgreSQL, S3 object storage and WebSocket device channels",
|
|
221
221
|
type: "module",
|
|
222
222
|
license: "MIT",
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
import {
|
|
11
11
|
BootstrapStateStore,
|
|
12
12
|
package_default
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-KTWFYFDL.js";
|
|
14
14
|
import {
|
|
15
15
|
createGuardedFetch
|
|
16
16
|
} from "./chunk-NXLE6ZEK.js";
|
|
@@ -21153,7 +21153,7 @@ function consentPage(action, redirectUri, invalidKey = false) {
|
|
|
21153
21153
|
}
|
|
21154
21154
|
|
|
21155
21155
|
// src/mcpOAuth.ts
|
|
21156
|
-
var
|
|
21156
|
+
var MCP_AUTHORIZE_PATH = "/~oauth/mcp/authorize";
|
|
21157
21157
|
var TOKEN = "/~oauth/mcp/token";
|
|
21158
21158
|
var FORM_TYPE = "application/x-www-form-urlencoded";
|
|
21159
21159
|
var MAX_REQUEST = 8192;
|
|
@@ -21199,7 +21199,7 @@ async function boundedText(message, limit) {
|
|
|
21199
21199
|
reader.releaseLock();
|
|
21200
21200
|
}
|
|
21201
21201
|
}
|
|
21202
|
-
function parameters(encoded, allowed) {
|
|
21202
|
+
function parameters(encoded, allowed, ignoreExtensions = false) {
|
|
21203
21203
|
if (Buffer.byteLength(encoded) > MAX_REQUEST) throw new EndpointError("invalid_request", 413);
|
|
21204
21204
|
if (encoded.startsWith("?")) throw new EndpointError("invalid_request");
|
|
21205
21205
|
try {
|
|
@@ -21207,11 +21207,14 @@ function parameters(encoded, allowed) {
|
|
|
21207
21207
|
} catch {
|
|
21208
21208
|
throw new EndpointError("invalid_request");
|
|
21209
21209
|
}
|
|
21210
|
-
const params = new URLSearchParams(
|
|
21211
|
-
const
|
|
21212
|
-
|
|
21213
|
-
|
|
21214
|
-
|
|
21210
|
+
const params = new URLSearchParams();
|
|
21211
|
+
for (const [name, value] of new URLSearchParams(encoded)) {
|
|
21212
|
+
if (!allowed.includes(name)) {
|
|
21213
|
+
if (ignoreExtensions) continue;
|
|
21214
|
+
throw new EndpointError("invalid_request");
|
|
21215
|
+
}
|
|
21216
|
+
if (params.has(name) || !value && name !== "sk") throw new EndpointError("invalid_request");
|
|
21217
|
+
params.append(name, value);
|
|
21215
21218
|
}
|
|
21216
21219
|
return params;
|
|
21217
21220
|
}
|
|
@@ -21277,7 +21280,7 @@ function createMcpOAuth(state, canonicalOrigin, fetchClientMetadata) {
|
|
|
21277
21280
|
scopesSupported: [MCP_OAUTH_SCOPE],
|
|
21278
21281
|
oauthMetadata: {
|
|
21279
21282
|
issuer,
|
|
21280
|
-
authorization_endpoint: issuer +
|
|
21283
|
+
authorization_endpoint: issuer + MCP_AUTHORIZE_PATH,
|
|
21281
21284
|
token_endpoint: issuer + TOKEN,
|
|
21282
21285
|
scopes_supported: [MCP_OAUTH_SCOPE],
|
|
21283
21286
|
response_types_supported: ["code"],
|
|
@@ -21304,21 +21307,21 @@ function createMcpOAuth(state, canonicalOrigin, fetchClientMetadata) {
|
|
|
21304
21307
|
}
|
|
21305
21308
|
return Response.json({ error: "server_error" }, { status: 500, headers: noStore });
|
|
21306
21309
|
});
|
|
21307
|
-
routes.all(
|
|
21310
|
+
routes.all(MCP_AUTHORIZE_PATH, async (c) => {
|
|
21308
21311
|
const request2 = c.req.raw;
|
|
21309
21312
|
if (!["GET", "POST"].includes(request2.method)) return methodError("GET, POST");
|
|
21310
21313
|
if (request2.method === "POST" && request2.headers.get("origin") !== issuer) {
|
|
21311
21314
|
throw new EndpointError("access_denied", 403);
|
|
21312
21315
|
}
|
|
21313
21316
|
const search = new URL(request2.url).search;
|
|
21314
|
-
const params = parameters(search.slice(1), authorizeFields);
|
|
21317
|
+
const params = parameters(search.slice(1), authorizeFields, true);
|
|
21315
21318
|
checkBinding(params, resourceServerUrl.href);
|
|
21316
21319
|
if (params.get("response_type") !== "code") throw new EndpointError("unsupported_response_type");
|
|
21317
21320
|
if (params.get("code_challenge_method") !== "S256" || !/^[\w-]{43}$/.test(params.get("code_challenge") ?? "")) {
|
|
21318
21321
|
throw new EndpointError("invalid_request");
|
|
21319
21322
|
}
|
|
21320
21323
|
if (params.has("state") && !/^[\x20-\x7e]+$/.test(params.get("state"))) throw new EndpointError("invalid_request");
|
|
21321
|
-
const action = issuer +
|
|
21324
|
+
const action = issuer + MCP_AUTHORIZE_PATH + "?" + params.toString();
|
|
21322
21325
|
if (request2.method === "GET") return consentPage(action, MCP_OAUTH_REDIRECT_URI);
|
|
21323
21326
|
const body = await form(request2, ["sk", "decision"]);
|
|
21324
21327
|
if (body.get("decision") === "deny") return authorizationResponse(issuer, params, { error: "access_denied" });
|
|
@@ -21355,7 +21358,7 @@ function createMcpOAuth(state, canonicalOrigin, fetchClientMetadata) {
|
|
|
21355
21358
|
resourceMetadataUrl: getOAuthProtectedResourceMetadataUrl(resourceServerUrl),
|
|
21356
21359
|
async handlePublic(request2) {
|
|
21357
21360
|
const path = new URL(request2.url).pathname;
|
|
21358
|
-
if (path ===
|
|
21361
|
+
if (path === MCP_AUTHORIZE_PATH || path === TOKEN) return routes.fetch(request2);
|
|
21359
21362
|
return oauthMetadataResponse(request2, metadata);
|
|
21360
21363
|
},
|
|
21361
21364
|
identify: (authorization, now) => identifyMcpToken(state, issuer, authorization, now)
|
|
@@ -22141,7 +22144,9 @@ async function createManagedServer(options) {
|
|
|
22141
22144
|
const replicaId = randomUUID11();
|
|
22142
22145
|
const assets = resolveUiAssets(options.uiDir);
|
|
22143
22146
|
const app = new Hono5();
|
|
22144
|
-
|
|
22147
|
+
const defaults = secureHeaders();
|
|
22148
|
+
const consent = secureHeaders({ referrerPolicy: "same-origin" });
|
|
22149
|
+
app.use("*", (c, next) => c.req.path === MCP_AUTHORIZE_PATH ? consent(c, next) : defaults(c, next));
|
|
22145
22150
|
app.use("/~setup/*", bodyLimit({ maxSize: 65536 }));
|
|
22146
22151
|
app.use("/~setup/*", async (c, next) => {
|
|
22147
22152
|
c.header("Cache-Control", "no-store");
|
|
@@ -22364,19 +22369,19 @@ async function createManagedServer(options) {
|
|
|
22364
22369
|
c.req.header("x-tb-setup-token"),
|
|
22365
22370
|
phase === "recovery" ? "recovery" : "setup"
|
|
22366
22371
|
);
|
|
22367
|
-
const
|
|
22372
|
+
const defaults2 = await store.defaults();
|
|
22368
22373
|
return c.json({
|
|
22369
|
-
databaseConfigured: Boolean(
|
|
22370
|
-
storageConfigured: Boolean(
|
|
22371
|
-
...
|
|
22372
|
-
...
|
|
22374
|
+
databaseConfigured: Boolean(defaults2?.databaseUrl),
|
|
22375
|
+
storageConfigured: Boolean(defaults2?.storage),
|
|
22376
|
+
...defaults2?.databaseUrl ? { databaseHost: new URL(defaults2.databaseUrl).hostname } : {},
|
|
22377
|
+
...defaults2?.storage ? {
|
|
22373
22378
|
storage: {
|
|
22374
|
-
endpoint:
|
|
22375
|
-
bucket:
|
|
22376
|
-
region:
|
|
22379
|
+
endpoint: defaults2.storage.endpoint,
|
|
22380
|
+
bucket: defaults2.storage.bucket,
|
|
22381
|
+
region: defaults2.storage.region
|
|
22377
22382
|
}
|
|
22378
22383
|
} : {},
|
|
22379
|
-
redisConfigured: Boolean(
|
|
22384
|
+
redisConfigured: Boolean(defaults2?.redisUrl)
|
|
22380
22385
|
});
|
|
22381
22386
|
});
|
|
22382
22387
|
const configure = async (request2, recovery) => store.exclusive(async () => {
|
|
@@ -22413,12 +22418,12 @@ async function createManagedServer(options) {
|
|
|
22413
22418
|
...backup.signingRetireAfter ? { signingRetireAfter: backup.signingRetireAfter } : {}
|
|
22414
22419
|
};
|
|
22415
22420
|
}
|
|
22416
|
-
const
|
|
22421
|
+
const defaults2 = await store.defaults();
|
|
22417
22422
|
const input = {
|
|
22418
|
-
...
|
|
22423
|
+
...defaults2,
|
|
22419
22424
|
...body,
|
|
22420
|
-
databaseUrl: body.databaseUrl ??
|
|
22421
|
-
storage: body.storage ??
|
|
22425
|
+
databaseUrl: body.databaseUrl ?? defaults2?.databaseUrl,
|
|
22426
|
+
storage: body.storage ?? defaults2?.storage
|
|
22422
22427
|
};
|
|
22423
22428
|
if (!input.databaseUrl || !recovery && !input.storage) {
|
|
22424
22429
|
throw new TBError(
|
|
@@ -22432,7 +22437,7 @@ async function createManagedServer(options) {
|
|
|
22432
22437
|
databaseUrl: input.databaseUrl,
|
|
22433
22438
|
redisUrl: input.redisUrl,
|
|
22434
22439
|
// Trust comes only from the local installer defaults, never from the web form.
|
|
22435
|
-
internalS3Origin:
|
|
22440
|
+
internalS3Origin: defaults2?.storage ? new URL(defaults2.storage.endpoint).origin : current.internalS3Origin,
|
|
22436
22441
|
revision: current.revision + 1
|
|
22437
22442
|
};
|
|
22438
22443
|
phase = "installing";
|
package/dist/index.js
CHANGED
|
@@ -19,11 +19,11 @@ import {
|
|
|
19
19
|
createTbServer,
|
|
20
20
|
probeS3ObjectStore,
|
|
21
21
|
runtimeAppSettings
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-VKZYPURU.js";
|
|
23
23
|
import "./chunk-U7PTOA3U.js";
|
|
24
24
|
import {
|
|
25
25
|
BootstrapStateStore
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-KTWFYFDL.js";
|
|
27
27
|
import "./chunk-NXLE6ZEK.js";
|
|
28
28
|
import "./chunk-6W5WJCKR.js";
|
|
29
29
|
import "./chunk-4WDQGEOC.js";
|
package/dist/main.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
createManagedServer
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-VKZYPURU.js";
|
|
5
5
|
import "./chunk-U7PTOA3U.js";
|
|
6
6
|
import {
|
|
7
7
|
package_default
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-KTWFYFDL.js";
|
|
9
9
|
import "./chunk-NXLE6ZEK.js";
|
|
10
10
|
import "./chunk-6W5WJCKR.js";
|
|
11
11
|
import "./chunk-4WDQGEOC.js";
|
package/package.json
CHANGED