@tokenoftrust/storefront-runner 7.5.1 → 7.5.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.
@@ -24,6 +24,7 @@
24
24
  */
25
25
  import { SignJWT, importPKCS8, type CryptoKey } from "jose";
26
26
  import { readEnv } from "@/lib/publication/shared/env";
27
+ import { AGENT_SUBJECT_RE } from "@/lib/access/auth/session";
27
28
  import { isCatalogCapabilityId, type CatalogCapabilityId } from "@/lib/access/shared/generated/capabilityCatalog.generated";
28
29
 
29
30
  /** The audience tot20's broker verifier pins. */
@@ -152,8 +153,7 @@ export async function mintBrokerAssertion(
152
153
  return mintBrokerAssertionSubject(sub, overrides);
153
154
  }
154
155
 
155
- /** The agent subject grammar shared with tot-mcp and tot20: `agent:` + `[A-Za-z0-9._-]+`. */
156
- export const AGENT_SUBJECT_RE = /^agent:[A-Za-z0-9._-]+$/;
156
+ export { AGENT_SUBJECT_RE };
157
157
 
158
158
  /** A delegated (sponsored-agent) assertion's subject and delegation claims. */
159
159
  export interface DelegatedBrokerAssertionInput {
@@ -74,6 +74,9 @@ export interface AgentActor {
74
74
  /** An agent session's lifetime ceiling (the grant's own expiry may cut it shorter). */
75
75
  export const AGENT_SESSION_MAX_TTL_SECONDS = 3600;
76
76
 
77
+ /** The agent subject grammar shared with tot-mcp and tot20: `agent:` + `[A-Za-z0-9._-]+`. */
78
+ export const AGENT_SUBJECT_RE = /^agent:[A-Za-z0-9._-]+$/;
79
+
77
80
  /** True when the record belongs to a sponsored agent rather than a human viewer. */
78
81
  export function isAgentSession(
79
82
  record: Pick<SessionRecord, "actor"> | null | undefined,
@@ -157,6 +160,13 @@ export interface SessionRecord {
157
160
  * human viewer, whose behaviour is unchanged.
158
161
  */
159
162
  actor?: AgentActor;
163
+ /**
164
+ * Positive interactive-origin marker set ONLY by the three interactive browser sign-in
165
+ * routes that mint from a tot20-verified id_token (`/api/auth/verify`,
166
+ * `/api/auth/magic-exchange`, `/api/auth/step-up-verify`). Absent on CLI, test, agent,
167
+ * and unmarked sessions.
168
+ */
169
+ origin?: "interactive";
160
170
  /** Issued-at, epoch seconds. */
161
171
  createdAt: number;
162
172
  /** Expiry, epoch seconds. The store TTL mirrors this; we re-check on read. */
@@ -248,6 +258,7 @@ export async function readSession(
248
258
  typeof record.email !== "string" ||
249
259
  typeof record.resource !== "string" ||
250
260
  (record.subject !== undefined && typeof record.subject !== "string") ||
261
+ (record.origin !== undefined && record.origin !== "interactive") ||
251
262
  typeof record.exp !== "number"
252
263
  ) {
253
264
  await store.delete(id);
@@ -119,6 +119,14 @@ export async function exciseLinesDigest(
119
119
  return sha256Hex(JSON.stringify(triples));
120
120
  }
121
121
 
122
+ /** A computed excise must have been computed over exactly this snapshot's lines and destination. */
123
+ export async function exciseBindsSnapshot(
124
+ wire: { lines: readonly FinalCartLine[]; destinationDigest: string; excise?: ExciseCarrier },
125
+ ): Promise<boolean> {
126
+ if (wire.excise?.status !== "computed") return true;
127
+ return wire.excise.destinationDigest === wire.destinationDigest && wire.excise.linesDigest === await exciseLinesDigest(wire.lines);
128
+ }
129
+
122
130
  export interface ResolveTaxEvidenceInput {
123
131
  wireLines: readonly FinalCartLine[];
124
132
  destinationDigest: string;
@@ -136,6 +136,7 @@ export async function POST(context: APIContext): Promise<Response> {
136
136
  staff: derived.staff,
137
137
  acr: derived.acr,
138
138
  authTime: derived.authTime,
139
+ origin: "interactive",
139
140
  },
140
141
  DEFAULT_SESSION_TTL_SECONDS,
141
142
  nowSeconds,
@@ -122,6 +122,7 @@ export async function POST(context: APIContext): Promise<Response> {
122
122
  // credential established (e.g. `tot:aal:sms`) on the session.
123
123
  acr: derived.acr,
124
124
  authTime: derived.authTime,
125
+ origin: "interactive",
125
126
  },
126
127
  DEFAULT_SESSION_TTL_SECONDS,
127
128
  nowSeconds,
@@ -153,6 +153,7 @@ export async function POST(context: APIContext): Promise<Response> {
153
153
  // satisfying a step-up would arrive with `acr: 'tot:aal:sms'`).
154
154
  acr: derived.acr,
155
155
  authTime: derived.authTime,
156
+ origin: "interactive",
156
157
  },
157
158
  DEFAULT_SESSION_TTL_SECONDS,
158
159
  nowSeconds,
@@ -18,7 +18,7 @@ import { evaluatePreflight } from "../compliance/preflight.js";
18
18
  import {
19
19
  admitSharedStoreTenant, testStoreEvidencePolicy, SHARED_STORE_POLICY_REVISION, SHARED_STORE_POLICY_SOURCE,
20
20
  SHARED_STORE_VERIFICATION_SOURCE, SHARED_STORE_SANDBOX_VERIFICATION_SOURCE, SANDBOX_CLEARED_REF,
21
- checkoutStoreHasExciseProducer, exciseLinesDigest, exciseReconcilesWithTotals, exciseRequiredForTenant, resolveTaxEvidence, type SharedStoreEvidencePolicy,
21
+ checkoutStoreHasExciseProducer, exciseBindsSnapshot, exciseLinesDigest, exciseReconcilesWithTotals, exciseRequiredForTenant, resolveTaxEvidence, type SharedStoreEvidencePolicy,
22
22
  } from "@/lib/checkout/commerce/sharedStoreAdmission.js";
23
23
  import { resolveTenantCommerce } from "@/lib/checkout/shared/checkoutCommerce";
24
24
  import { isSandboxVerificationProvider } from "@/lib/compliance/enforcement.js";
@@ -89,11 +89,6 @@ export function readExcise(value: unknown): ExciseCarrier | null {
89
89
  if (e.status === "computed" ? !Number.isSafeInteger(e.amountMinor) || Number(e.amountMinor) < 0 : !(EXCISE_REASONS as readonly unknown[]).includes(e.reason)) return null;
90
90
  return e as unknown as ExciseCarrier;
91
91
  }
92
- /** A computed excise must have been computed over exactly this snapshot's lines and destination. */
93
- async function exciseBindsSnapshot(wire: FinalCartWire): Promise<boolean> {
94
- if (wire.excise?.status !== "computed") return true;
95
- return wire.excise.destinationDigest === wire.destinationDigest && wire.excise.linesDigest === await exciseLinesDigest(wire.lines);
96
- }
97
92
  function readSnapshot(value: unknown): FinalCartWire | null {
98
93
  if (!value || typeof value !== "object" || Array.isArray(value)) return null;
99
94
  const v = value as Record<string, unknown>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/storefront-runner",
3
- "version": "7.5.1",
3
+ "version": "7.5.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",