@tokenoftrust/storefront-runner 7.9.1 → 7.9.3

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.
@@ -116,6 +116,8 @@ declare global {
116
116
  interface Locals {
117
117
  /** Tenant resolved from the request Host by src/middleware. */
118
118
  tenant: TenantConfig;
119
+ /** Set on the exact, tenant-routed Bearer readiness GET. */
120
+ couponDoorReadinessRouted?: { hasQuery: boolean };
119
121
  /**
120
122
  * THE route-tier answer for this request (ADR 0013), resolved once by the
121
123
  * middleware from the TENANT-RELATIVE path and used to pick which branch
@@ -50,6 +50,8 @@ import {
50
50
  type AgentRoleId,
51
51
  } from "./agentRoles.js";
52
52
 
53
+ export const COUPON_DOOR_READINESS_PATH = "/api/admin/coupon-operations-readiness";
54
+
53
55
  /** Exact non-content routes an agent session may reach, by method. */
54
56
  export const AGENT_ALLOWED_ROUTES: ReadonlyArray<{ method: string; path: string }> = [
55
57
  { method: "GET", path: "/api/dev/cli-session" },
@@ -5,7 +5,7 @@
5
5
 
6
6
  /** The vendored artifact's schema and the digest tot20 stamped on it. */
7
7
  export const CAPABILITY_CATALOG_SCHEMA = "tot.capability-catalog/v1" as const;
8
- export const CAPABILITY_CATALOG_DIGEST = "sha256:d919aef43b1e2db030a87bebdf87946a29c18f24c0feb89494ea55a65b4bc943" as const;
8
+ export const CAPABILITY_CATALOG_DIGEST = "sha256:8f33674432d761bc772d155be1097472ca9847e56619fb1479019f7c2702f4b1" as const;
9
9
 
10
10
  /** Every capability row id the catalog names. */
11
11
  export const CATALOG_CAPABILITY_IDS = [
@@ -63,6 +63,7 @@ export const CATALOG_CAPABILITY_IDS = [
63
63
  "core:view-verification-health",
64
64
  "core:view-verificationSummary",
65
65
  "core:view-wordpressIntegration",
66
+ "coupons:execute-approved",
66
67
  "coupons:propose",
67
68
  "customers:read-minimal",
68
69
  "feedbackRecord:delete",
@@ -144,6 +145,7 @@ export type AgentRoleId = (typeof AGENT_ROLE_IDS)[number];
144
145
  export const APP_AUDIENCE_CAPABILITY_IDS = [
145
146
  "attribution:write",
146
147
  "catalog:read",
148
+ "coupons:execute-approved",
147
149
  "coupons:propose",
148
150
  "customers:read-minimal",
149
151
  "fulfillment:process",
@@ -53,6 +53,8 @@ export interface McpServiceRequest {
53
53
  path: string;
54
54
  query?: Record<string, string>;
55
55
  body?: unknown;
56
+ /** A credential-bearing body requires fixed transport diagnostics. */
57
+ sensitiveBody?: true;
56
58
  /**
57
59
  * A proof over a typed tuple, computed here from the service secret and merged into an object
58
60
  * `body` under `proof.field`. The caller supplies labels and values and receives only the proof;
@@ -165,8 +167,9 @@ export async function callMcpService(req: McpServiceRequest): Promise<McpService
165
167
  res = await req.transport.post(url, headers, body);
166
168
  }
167
169
  } catch (thrown) {
170
+ const detail = req.sensitiveBody ? "" : transportErrorDetail(thrown, secret);
168
171
  console.error(
169
- `[mcp-service-seam] ${req.method} ${req.path} transport-error: ${transportErrorClass(thrown)} (${urlEnv})${transportErrorDetail(thrown, secret)}`,
172
+ `[mcp-service-seam] ${req.method} ${req.path} transport-error: ${transportErrorClass(thrown)} (${urlEnv})${detail}`,
170
173
  );
171
174
  return { kind: "transport-error", message: MCP_SERVICE_TRANSPORT_FAILURE };
172
175
  }
@@ -44,7 +44,9 @@ import { ServerTiming, withServerTiming } from "@/lib/observability/shared/serve
44
44
  import { observeDeployVersion } from "@/lib/activity/deployVersion";
45
45
  import { primeActivityKillSwitch } from "@/lib/activity/killSwitch";
46
46
  import {
47
+ isAstroErrorRouteV1,
47
48
  isPlatformPublicDiscoveryPath,
49
+ middlewareRewriteTargetV1,
48
50
  platformStaticRootLocationV1,
49
51
  publicationRedirectLocationV1,
50
52
  resolveMiddlewareBranchV1,
@@ -59,7 +61,7 @@ import {
59
61
  import { mirrorBalanceKey, parseMirrorBalances, publicMirrorStage } from "@/lib/inventory/mirrorBalanceProjection";
60
62
  import { serveControlPlane } from "./controlPlane.js";
61
63
  import { KvSessionStore, readSession, SESSION_COOKIE } from "@/lib/access/auth/session";
62
- import { agentMayReach, agentSessionGateRefusal, holdReadMixedCredentialsRefusal } from "@/lib/access/auth/agentSessionGate";
64
+ import { agentMayReach, agentSessionGateRefusal, COUPON_DOOR_READINESS_PATH, holdReadMixedCredentialsRefusal } from "@/lib/access/auth/agentSessionGate";
63
65
  import { mintOpaqueBrokerAssertion } from "@/lib/access/auth/brokerAssertion";
64
66
  import { withDeclaredTenantConfig } from "@/config/declaredTenantConfig";
65
67
  import { closedCatalogPath, resolveShopperAccessPolicy } from "@tot/public-runtime/declared-tenant-config";
@@ -96,6 +98,7 @@ export const onRequest = defineMiddleware(async (context, next) => {
96
98
  context.locals.serverTiming = timing;
97
99
  const seen: RequestDelivery = { cdnForwarded: false };
98
100
  const served = await serveRequest(context, next, seen, timing);
101
+ if (seen.couponDoorReadiness) return outer ? withServerTiming(served, timing) : served;
99
102
  // Registered responsive renditions on a rendered page, by the same addresses and markup the static
100
103
  // bundle carries. The materialize render is left to the bundle build, which owns its renditions.
101
104
  const { withRegisteredRenditions } = await import("@/lib/assets/registeredRenditions");
@@ -120,6 +123,7 @@ export const onRequest = defineMiddleware(async (context, next) => {
120
123
 
121
124
  interface RequestDelivery {
122
125
  cdnForwarded: boolean;
126
+ couponDoorReadiness?: boolean;
123
127
  assetBasePath?: string;
124
128
  privateCatalog?: boolean;
125
129
  }
@@ -264,6 +268,20 @@ async function serveRequest(
264
268
  seen.assetBasePath = basePath;
265
269
  if (imageBasePath) context.locals.imageBasePath = imageBasePath;
266
270
 
271
+ // The Bearer-only readiness route owns its admission and needs only the routed tenant.
272
+ if (request.method === "GET" && renderPath === COUPON_DOOR_READINESS_PATH &&
273
+ url.pathname === `${basePath}${renderPath}` && (!routedByFallback || basePath !== "") &&
274
+ !isAstroErrorRouteV1(context.routePattern)) {
275
+ seen.couponDoorReadiness = true;
276
+ locals.tenant = tenant;
277
+ locals.basePath = basePath;
278
+ locals.couponDoorReadinessRouted = { hasQuery: request.url.includes("?") };
279
+ const rewrite = middlewareRewriteTargetV1({ requestPath: url.pathname, basePath, renderPath, search: "" });
280
+ const response = await (rewrite === undefined ? next() : next(rewrite));
281
+ applySecurityHeaders(response.headers);
282
+ return response;
283
+ }
284
+
267
285
  // ---- The one route classification -----------------------------------------
268
286
  // An EXPLICITLY unpaid store is never fully public: the ONLY way to reach its
269
287
  // hosted URL is to sign in, regardless of the demo-gate host list or mode —
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/storefront-runner",
3
- "version": "7.9.1",
3
+ "version": "7.9.3",
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",