@konneal/engine 0.2.96 → 0.2.97
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.
|
@@ -1415,12 +1415,14 @@ async function healthRoute(c) {
|
|
|
1415
1415
|
}
|
|
1416
1416
|
async function tierFor(c) {
|
|
1417
1417
|
const isApi = c.path.startsWith("/v1/");
|
|
1418
|
+
const isMcp = c.path === "/mcp";
|
|
1419
|
+
const bearer = c.req.headers.get("authorization")?.replace(/^Bearer\s+/i, "").trim();
|
|
1418
1420
|
let key = null;
|
|
1419
|
-
if (isApi) {
|
|
1421
|
+
if (isApi || isMcp && bearer) {
|
|
1420
1422
|
key = await authenticate(c.env, c.req);
|
|
1421
1423
|
if (!key) return err(401, "unauthorized", `Provide a valid API key: Authorization: Bearer ${P().publisher.id}_...`);
|
|
1422
1424
|
}
|
|
1423
|
-
let tier =
|
|
1425
|
+
let tier = key ? "key" : "anon";
|
|
1424
1426
|
if (!isApi && await sessionFrom(c.req, c.env)) tier = "member";
|
|
1425
1427
|
else if (!isApi && await opTokenMember(c.env, opCfg(c.env), c.req)) tier = "member";
|
|
1426
1428
|
return { tier, key };
|
package/package.json
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"playwright": "^1.62.1",
|
|
28
28
|
"yaml": "^2.9.1"
|
|
29
29
|
},
|
|
30
|
-
"version": "0.2.
|
|
30
|
+
"version": "0.2.97",
|
|
31
31
|
"description": "The Konneal engine: the publisher-agnostic build pipeline and API plane for standards intelligence (retrieval, answer contract, verdicts, evaluation).",
|
|
32
32
|
"license": "BSD-3-Clause",
|
|
33
33
|
"type": "module",
|
|
@@ -186,12 +186,18 @@ async function healthRoute(c: RouteContext): Promise<Response> {
|
|
|
186
186
|
* key. */
|
|
187
187
|
async function tierFor(c: RouteContext): Promise<{ tier: "anon" | "key" | "member"; key: ApiKey | null } | Response> {
|
|
188
188
|
const isApi = c.path.startsWith("/v1/");
|
|
189
|
+
// /mcp rides the same key tiering: a bearer presented to the JSON-RPC
|
|
190
|
+
// endpoint authenticates like /v1 (key tier, the caller's quota and
|
|
191
|
+
// telemetry) — but the endpoint stays open to anonymous agents, so an
|
|
192
|
+
// ABSENT bearer is not an error, only a PRESENT-but-invalid one is.
|
|
193
|
+
const isMcp = c.path === "/mcp";
|
|
194
|
+
const bearer = c.req.headers.get("authorization")?.replace(/^Bearer\s+/i, "").trim();
|
|
189
195
|
let key: ApiKey | null = null;
|
|
190
|
-
if (isApi) {
|
|
196
|
+
if (isApi || (isMcp && bearer)) {
|
|
191
197
|
key = await authenticate(c.env, c.req);
|
|
192
198
|
if (!key) return err(401, "unauthorized", `Provide a valid API key: Authorization: Bearer ${P().publisher.id}_...`);
|
|
193
199
|
}
|
|
194
|
-
let tier: "anon" | "key" | "member" =
|
|
200
|
+
let tier: "anon" | "key" | "member" = key ? "key" : "anon";
|
|
195
201
|
// No SESSION_SECRET precondition: the delegated bearer (the platform
|
|
196
202
|
// bubble's OP-minted JWT, delegated.ts) admits the member lane on its
|
|
197
203
|
// own — sessionFrom returns null honestly when neither lane applies.
|