@tokenoftrust/storefront-runner 7.8.5 → 7.8.6

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.
@@ -413,7 +413,7 @@ export function safeLoginHref(href: string | null | undefined): string {
413
413
  * repeated, encoded or dot segment, a trailing slash or an extra suffix matches
414
414
  * nothing.
415
415
  */
416
- const PREVIEW_APP_ORDER_SEGMENT = "(?!\\.{1,2}/)[A-Za-z0-9._~-]+";
416
+ const PREVIEW_APP_ORDER_SEGMENT = "(?!\\.{1,2}/)(?:[A-Za-z0-9._~:-]|%3[Aa])+";
417
417
  const PREVIEW_APP_ROUTES: ReadonlyArray<{ method: string; path: RegExp }> = [
418
418
  { method: "POST", path: /^\/api\/apps\/oauth\/token$/ },
419
419
  { method: "GET", path: /^\/api\/apps\/v1\/fulfillment\/assignments$/ },
@@ -429,7 +429,7 @@ export function isPreviewAppBootstrapRoute(method: string | undefined, renderPat
429
429
  }
430
430
 
431
431
  const APP_TOKEN_PATH = "/api/apps/oauth/token";
432
- const APP_V1_PATH = /^\/api\/apps\/v1(?:\/(?!\.{1,2}(?:\/|$))[A-Za-z0-9._~-]+)+$/;
432
+ const APP_V1_PATH = /^\/api\/apps\/v1(?:\/(?!\.{1,2}(?:\/|$))(?:[A-Za-z0-9._~:-]|%3[Aa])+)+$/;
433
433
 
434
434
  export interface AppCredentialRequest {
435
435
  method: string | undefined;
@@ -6,7 +6,10 @@ import {
6
6
  } from "@tot/public-runtime";
7
7
  export const SOURCE_SCHEMA = "commerce-source-authority/v1";
8
8
  export const SOURCE_LIMIT = 64;
9
+ /** In-flight source-check lease: how long a pending check stays active before replacement. */
9
10
  export const SOURCE_LEASE_MS = 120_000;
11
+ /** Accepted healthy source-proof validity window between recovery sweeps. */
12
+ export const SOURCE_PROOF_TTL_MS = 2 * 60 * 60_000;
10
13
  export const FAULT_KINDS = [
11
14
  "fork",
12
15
  "committed-payload-missing",
@@ -3,6 +3,7 @@ import type { Queryable, QueryStatement } from "../../catalog/d1/catalog.js";
3
3
  import type { CommerceStage } from "@tot/public-runtime";
4
4
  import {
5
5
  SOURCE_LEASE_MS,
6
+ SOURCE_PROOF_TTL_MS,
6
7
  isHash,
7
8
  canonicalInstant,
8
9
  isSourceId,
@@ -665,7 +666,7 @@ export class SourceAuthorityStore {
665
666
  state.accepted = event.tipGeneration;
666
667
  state.businessDigest = event.businessEventSetDigest;
667
668
  state.pairs = event.businessEventDigestPairs;
668
- state.expires = new Date(issued + SOURCE_LEASE_MS).toISOString();
669
+ state.expires = new Date(issued + SOURCE_PROOF_TTL_MS).toISOString();
669
670
  state.sync = (await digestJson(persisted)) !== state.businessDigest;
670
671
  }
671
672
  const ack: ResultAck = {
@@ -35,6 +35,10 @@ import { shopperVariantPrice } from "@/lib/customers/accounts/pricing";
35
35
  import { resolveShopperAccessPolicy } from "@tot/public-runtime/declared-tenant-config";
36
36
  export const prerender = false;
37
37
  const HEX = /^[a-f0-9]{64}$/;
38
+ /** Checkout authorization window (reservation + payment completion). */
39
+ const CHECKOUT_ADMISSION_TTL_MS = 5 * 60_000;
40
+ /** Post-capture compliance evidence validity horizon for order fulfillment. */
41
+ const FULFILLMENT_EVIDENCE_TTL_MS = 30 * 24 * 60 * 60_000;
38
42
  /** The shopper's verification correlation handle, as the signed `verification` cart option carries it. */
39
43
  const VERIFICATION_REF = /^[a-zA-Z0-9][a-zA-Z0-9._:-]{0,199}$/;
40
44
  function json(body: unknown, status = 200): Response {
@@ -398,18 +402,21 @@ async function authorize(context: APIContext): Promise<Response> {
398
402
  shopperCheckout?.licensedDestinationDigest, snapshot.totals.totalMinor, new Date(now)) : null;
399
403
  if (orgKybRequired && !orgKyb) return deny("shopper-org-kyb-review-required");
400
404
  if (existing && orgKyb && Date.parse(existing.expiresAt) > Date.parse(orgKyb.expiresAt)) return deny("admission-expired");
401
- const expiresAt = existing?.expiresAt ?? new Date(Math.min(Date.now() + 5 * 60_000, stockExpiry,
405
+ const expiresAt = existing?.expiresAt ?? new Date(Math.min(Date.now() + CHECKOUT_ADMISSION_TTL_MS, stockExpiry,
402
406
  scopedProof?.expiresAt ?? Infinity, orgKyb ? Date.parse(orgKyb.expiresAt) : Infinity)).toISOString();
407
+ const evidenceExpiresAt = existing
408
+ ? new Date(Math.min(...Object.values(existing.provenance).map((proof) => Date.parse(proof.expiresAt)))).toISOString()
409
+ : new Date(Math.min(Date.now() + FULFILLMENT_EVIDENCE_TTL_MS, orgKyb ? Date.parse(orgKyb.expiresAt) : Infinity)).toISOString();
403
410
  const provenance = {} as CommerceEvidenceProvenance;
404
411
  for (const field of ["verification", "tax", "risk"] as const) {
405
412
  if (policy[field] === "not-required") {
406
413
  evidence[field] = "not-required";
407
- provenance[field] = { requirement: "not-required", state: "not-required", source: SHARED_STORE_POLICY_SOURCE, policyRevision: SHARED_STORE_POLICY_REVISION, expiresAt };
414
+ provenance[field] = { requirement: "not-required", state: "not-required", source: SHARED_STORE_POLICY_SOURCE, policyRevision: SHARED_STORE_POLICY_REVISION, expiresAt: evidenceExpiresAt };
408
415
  }
409
416
  }
410
417
  provenance.stock = stockTracked
411
- ? { requirement: "required", state: "satisfied", source: "tenant-inventory-movements", policyRevision: "mirror-v1", expiresAt }
412
- : { requirement: "not-required", state: "not-required", source: "tenant-inventory-undeclared", policyRevision: "untracked-v1", expiresAt };
418
+ ? { requirement: "required", state: "satisfied", source: "tenant-inventory-movements", policyRevision: "mirror-v1", expiresAt: evidenceExpiresAt }
419
+ : { requirement: "not-required", state: "not-required", source: "tenant-inventory-undeclared", policyRevision: "untracked-v1", expiresAt: evidenceExpiresAt };
413
420
  const presented: FinalCartBinding = { tenantId: snapshot.tenantId, stage: snapshot.stage, currency: snapshot.currency, lines: snapshot.lines,
414
421
  destinationDigest: snapshot.destinationDigest, verificationExpiresAt: expiresAt, taxExpiresAt: expiresAt };
415
422
  const seamView = await seam(authorityContext, snapshot, selected, orgKyb ? { ...policy, verification: "not-required" } : policy);
@@ -423,7 +430,7 @@ async function authorize(context: APIContext): Promise<Response> {
423
430
  excise: snapshot.excise,
424
431
  hasProducer,
425
432
  policyRevision: SHARED_STORE_POLICY_REVISION,
426
- expiresAt,
433
+ expiresAt: evidenceExpiresAt,
427
434
  });
428
435
  evidence.tax = taxResolution.evidenceState;
429
436
  provenance.tax = taxResolution.provenance;
@@ -431,10 +438,10 @@ async function authorize(context: APIContext): Promise<Response> {
431
438
  }
432
439
  if (orgKyb) {
433
440
  evidence.verification = "fresh";
434
- provenance.verification = { requirement: "required", state: "satisfied", source: "org-kyb", policyRevision: "org-kyb-v1", expiresAt };
441
+ provenance.verification = { requirement: "required", state: "satisfied", source: "org-kyb", policyRevision: "org-kyb-v1", expiresAt: evidenceExpiresAt };
435
442
  } else if (policy.verification === "required" && seamView.verified) {
436
443
  evidence.verification = "fresh";
437
- provenance.verification = { requirement: "required", state: "satisfied", source: seamView.sandbox ? SHARED_STORE_SANDBOX_VERIFICATION_SOURCE : SHARED_STORE_VERIFICATION_SOURCE, policyRevision: SHARED_STORE_POLICY_REVISION, expiresAt };
444
+ provenance.verification = { requirement: "required", state: "satisfied", source: seamView.sandbox ? SHARED_STORE_SANDBOX_VERIFICATION_SOURCE : SHARED_STORE_VERIFICATION_SOURCE, policyRevision: SHARED_STORE_POLICY_REVISION, expiresAt: evidenceExpiresAt };
438
445
  }
439
446
  const exciseRequired = exciseRequiredForTenant(tenant);
440
447
  const decision = await evaluateFinalCart({ now, routedTenantId: commerceTenantId(tenant), quoted: presented, presented, evidence,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tokenoftrust/storefront-runner",
3
- "version": "7.8.5",
3
+ "version": "7.8.6",
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",