@tokenoftrust/storefront-runner 4.11.6 → 4.11.7
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.
|
@@ -143,12 +143,22 @@ export async function resolveNamedSubjectGrant(
|
|
|
143
143
|
});
|
|
144
144
|
if (outcome.kind !== "ok") return false;
|
|
145
145
|
const payload = (await outcome.json()) as Record<string, unknown> | null;
|
|
146
|
-
|
|
146
|
+
if (payload?.capability === capability) return true;
|
|
147
|
+
console.warn(`[mcp-service-seam] named grant ${capability} not held: ${namedGrantRefusal(payload)}`);
|
|
148
|
+
return false;
|
|
147
149
|
} catch {
|
|
150
|
+
console.warn(`[mcp-service-seam] named grant ${capability} not held: unparseable answer`);
|
|
148
151
|
return false;
|
|
149
152
|
}
|
|
150
153
|
}
|
|
151
154
|
|
|
155
|
+
/** Why a 2xx named-grant answer did not grant, in the seam's own fixed vocabulary. Never the subject. */
|
|
156
|
+
function namedGrantRefusal(payload: Record<string, unknown> | null): string {
|
|
157
|
+
const reason = typeof payload?.reason === "string" && /^[a-z_-]{1,40}$/.test(payload.reason) ? payload.reason : null;
|
|
158
|
+
if (payload?.capability === null) return reason ? `capability null, reason ${reason}` : "capability null (no grant)";
|
|
159
|
+
return "unexpected capability";
|
|
160
|
+
}
|
|
161
|
+
|
|
152
162
|
/**
|
|
153
163
|
* Resolve the viewer's LIVE ship capability over `appDomain`. Returns the granted
|
|
154
164
|
* `Capability` — `"ship-on-behalf"` ONLY on an explicit `200 { capability:
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
* A thrown transport failure comes back as one fixed diagnostic, never the thrown value: a
|
|
13
13
|
* fetch error can carry the request URL (and so its subject query) to every downstream sink.
|
|
14
14
|
*
|
|
15
|
+
* Every outcome but `ok` logs one `[mcp-service-seam]` line naming the method, the contract path
|
|
16
|
+
* and a fixed reason: the env name for `not-configured` / `bad-url`, the error class (from a fixed
|
|
17
|
+
* list) for `transport-error`, the status otherwise. Never the URL, query, secret or thrown text.
|
|
18
|
+
*
|
|
15
19
|
* A 401 or 404 from a seam route is misconfiguration, never a business answer: tot-mcp's
|
|
16
20
|
* routes answer 200 for every absent/unknown case, so 401 means the secret or URL is wrong
|
|
17
21
|
* and 404 means the path is not served. Both log LOUDLY and come back as `misconfigured`
|
|
@@ -75,11 +79,23 @@ function misconfigurationReason(status: 401 | 404, urlEnv: string): string {
|
|
|
75
79
|
: "tot-mcp does not serve this path; storefront and tot-mcp disagree on the service-seam contract";
|
|
76
80
|
}
|
|
77
81
|
|
|
82
|
+
/** Error classes a transport failure may name in a log line; anything else reads `Error`. */
|
|
83
|
+
const TRANSPORT_ERROR_CLASSES = new Set(["TimeoutError", "AbortError", "TypeError", "SyntaxError"]);
|
|
84
|
+
|
|
85
|
+
/** The class of a thrown transport failure, from a fixed list. Never its message. */
|
|
86
|
+
export function transportErrorClass(thrown: unknown): string {
|
|
87
|
+
return thrown instanceof Error && TRANSPORT_ERROR_CLASSES.has(thrown.name) ? thrown.name : "Error";
|
|
88
|
+
}
|
|
89
|
+
|
|
78
90
|
export async function callMcpService(req: McpServiceRequest): Promise<McpServiceOutcome> {
|
|
79
91
|
const urlEnv = AUTHORITY_ENV[req.authority ?? "binding"];
|
|
80
92
|
const authorityUrl = await readEnv(urlEnv);
|
|
81
93
|
const secret = await readEnv("MCP_SERVICE_SHARED_SECRET");
|
|
82
|
-
if (!authorityUrl || !secret)
|
|
94
|
+
if (!authorityUrl || !secret) {
|
|
95
|
+
const missing = [!authorityUrl && urlEnv, !secret && "MCP_SERVICE_SHARED_SECRET"].filter(Boolean).join(" and ");
|
|
96
|
+
console.warn(`[mcp-service-seam] ${req.method} ${req.path} not-configured: ${missing} unset`);
|
|
97
|
+
return { kind: "not-configured" };
|
|
98
|
+
}
|
|
83
99
|
|
|
84
100
|
let origin: string | null;
|
|
85
101
|
if (req.authority === "grant") {
|
|
@@ -91,7 +107,10 @@ export async function callMcpService(req: McpServiceRequest): Promise<McpService
|
|
|
91
107
|
origin = null;
|
|
92
108
|
}
|
|
93
109
|
}
|
|
94
|
-
if (!origin)
|
|
110
|
+
if (!origin) {
|
|
111
|
+
console.error(`[mcp-service-seam] ${req.method} ${req.path} bad-url: ${urlEnv} is not a usable origin`);
|
|
112
|
+
return { kind: "bad-url" };
|
|
113
|
+
}
|
|
95
114
|
let url = `${origin}${req.path}`;
|
|
96
115
|
if (req.query) url += `?${new URLSearchParams(req.query).toString()}`;
|
|
97
116
|
|
|
@@ -105,7 +124,8 @@ export async function callMcpService(req: McpServiceRequest): Promise<McpService
|
|
|
105
124
|
if (!req.transport.post) throw new Error("transport has no post()");
|
|
106
125
|
res = await req.transport.post(url, headers, req.body);
|
|
107
126
|
}
|
|
108
|
-
} catch {
|
|
127
|
+
} catch (thrown) {
|
|
128
|
+
console.error(`[mcp-service-seam] ${req.method} ${req.path} transport-error: ${transportErrorClass(thrown)} (${urlEnv})`);
|
|
109
129
|
return { kind: "transport-error", message: MCP_SERVICE_TRANSPORT_FAILURE };
|
|
110
130
|
}
|
|
111
131
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "4.11.
|
|
3
|
+
"version": "4.11.7",
|
|
4
4
|
"license": "SEE LICENSE IN LICENSE",
|
|
5
5
|
"description": "World-shareable storefront runner: multi-tenant renderer on Astro/Cloudflare. No control plane.",
|
|
6
6
|
"packageManager": "pnpm@11.9.0",
|