@tokenoftrust/storefront-runner 6.7.1 → 6.7.2
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.
|
@@ -89,3 +89,14 @@ export async function readCheckoutRequirements(tenantId: string, env: Customizat
|
|
|
89
89
|
return null;
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* What the Checkout requirements panel shows. A regulated store's compliance profile enforces every
|
|
95
|
+
* requirement whatever it saved, so it gets a statement and no switches; the save route refuses it too.
|
|
96
|
+
*/
|
|
97
|
+
export type CheckoutRequirementsPanelState = "own-store" | "enforced" | "unreadable" | "switches";
|
|
98
|
+
export function checkoutRequirementsPanelState(input: { shared: boolean; regulated: boolean; saved: CheckoutRequirements | null }): CheckoutRequirementsPanelState {
|
|
99
|
+
if (!input.shared) return "own-store";
|
|
100
|
+
if (input.regulated) return "enforced";
|
|
101
|
+
return input.saved === null ? "unreadable" : "switches";
|
|
102
|
+
}
|
|
@@ -45,6 +45,10 @@ export const SHARED_STORE_POLICY_SOURCE = "shared-test-store-default";
|
|
|
45
45
|
export const SHARED_STORE_POLICY_REVISION = "shared-test-store-v1";
|
|
46
46
|
/** Provenance stamped on verification the live provider confirmed for a store that requires it. */
|
|
47
47
|
export const SHARED_STORE_VERIFICATION_SOURCE = "tot-verification-provider";
|
|
48
|
+
/** Provenance stamped on verification the sandbox profile simulated for an internal-test tenant. */
|
|
49
|
+
export const SHARED_STORE_SANDBOX_VERIFICATION_SOURCE = "tot-sandbox-verification";
|
|
50
|
+
/** The cart's signed `verification` ref that asks the sandbox profile to simulate a cleared verification. */
|
|
51
|
+
export const SANDBOX_CLEARED_REF = /^sandbox-cleared:[a-zA-Z0-9._-]{1,64}$/;
|
|
48
52
|
|
|
49
53
|
/**
|
|
50
54
|
* What the shared test store requires of a tenant. A regulated tenant (`isRegulated`) always
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { APIContext } from "astro";
|
|
3
3
|
import { createLocalJWKSet, decodeProtectedHeader, jwtVerify, type JSONWebKeySet } from "jose";
|
|
4
4
|
import {
|
|
5
|
-
commerceTenantId, isRegulated, totalsMatch, shippingMinorFor, isContentVersionId, catalogPinDigestFinding, cartLineKey,
|
|
5
|
+
commerceTenantId, isRegulated, isInternalTestTenant, totalsMatch, shippingMinorFor, isContentVersionId, catalogPinDigestFinding, cartLineKey,
|
|
6
6
|
type CallerToken, type CatalogProduct, type CatalogVariant, type CommerceEvidence, type CommerceEvidenceProvenance,
|
|
7
7
|
type CommerceProviderCartSnapshot, type FinalCartBinding, type TenantConfig,
|
|
8
8
|
} from "@tot/public-runtime";
|
|
@@ -16,8 +16,9 @@ import { admissionMatches, readCommerceAdmission, admissionSnapshotStatement } f
|
|
|
16
16
|
import { evaluatePreflight } from "../compliance/preflight.js";
|
|
17
17
|
import {
|
|
18
18
|
admitSharedStoreTenant, testStoreEvidencePolicy, SHARED_STORE_POLICY_REVISION, SHARED_STORE_POLICY_SOURCE,
|
|
19
|
-
SHARED_STORE_VERIFICATION_SOURCE, type SharedStoreEvidencePolicy,
|
|
19
|
+
SHARED_STORE_VERIFICATION_SOURCE, SHARED_STORE_SANDBOX_VERIFICATION_SOURCE, SANDBOX_CLEARED_REF, type SharedStoreEvidencePolicy,
|
|
20
20
|
} from "@/lib/checkout/commerce/sharedStoreAdmission.js";
|
|
21
|
+
import { isSandboxVerificationProvider } from "@/lib/compliance/enforcement.js";
|
|
21
22
|
import { readCheckoutRequirements } from "@/lib/checkout/commerce/checkoutRequirements.js";
|
|
22
23
|
import { DeclaredTenantConfigUnreadError, withDeclaredTenantConfig } from "@/config/declaredTenantConfig";
|
|
23
24
|
import { resolveStoreCurrency } from "@tot/public-runtime/declared-tenant-config";
|
|
@@ -100,7 +101,25 @@ function keyedLines(wire: CommerceProviderCartSnapshot): CommerceProviderCartSna
|
|
|
100
101
|
* cart's verification ref goes to preflight, whose live provider re-reads its real status
|
|
101
102
|
* server-side; `verified` is true only when that read satisfied the requirement.
|
|
102
103
|
*/
|
|
103
|
-
async function seam(context: APIContext, snapshot: CommerceProviderCartSnapshot, selected: ReadonlyMap<string, CatalogProduct>, policy: SharedStoreEvidencePolicy): Promise<SeamView & { verified: boolean }> {
|
|
104
|
+
async function seam(context: APIContext, snapshot: CommerceProviderCartSnapshot, selected: ReadonlyMap<string, CatalogProduct>, policy: SharedStoreEvidencePolicy): Promise<SeamView & { verified: boolean; sandbox: boolean }> {
|
|
105
|
+
const sandbox = await sandboxVerificationApplies(context.locals.tenant, snapshot);
|
|
106
|
+
const view = await evaluateSeam(context, snapshot, selected, policy, sandbox);
|
|
107
|
+
return { ...view, sandbox: sandbox && view.verified };
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* The sandbox verification profile satisfies the final cart's verification only when ALL hold:
|
|
111
|
+
* the resolved provider is an explicit sandbox value, the checkout resolves to the shared test
|
|
112
|
+
* store on the test tier (already enforced by admission), the tenant is internal-test, and the cart
|
|
113
|
+
* carries the signed sandbox-cleared verification ref. Any other tenant, tier or provider keeps
|
|
114
|
+
* the real provider's outcome as the only evidence.
|
|
115
|
+
*/
|
|
116
|
+
async function sandboxVerificationApplies(tenant: TenantConfig, snapshot: CommerceProviderCartSnapshot): Promise<boolean> {
|
|
117
|
+
return isSandboxVerificationProvider((await readEnv("TOT_VERIFICATION_PROVIDER")) || undefined)
|
|
118
|
+
&& (await readEnv("COMMERCE_DEMO_CHECKOUT_TIER")) === "test"
|
|
119
|
+
&& isInternalTestTenant(tenant)
|
|
120
|
+
&& SANDBOX_CLEARED_REF.test(snapshot.verificationRef ?? "");
|
|
121
|
+
}
|
|
122
|
+
async function evaluateSeam(context: APIContext, snapshot: CommerceProviderCartSnapshot, selected: ReadonlyMap<string, CatalogProduct>, policy: SharedStoreEvidencePolicy, sandbox: boolean): Promise<SeamView & { verified: boolean }> {
|
|
104
123
|
if (policy.rules === "off" && policy.verification === "not-required") return { status: "clear", verified: false };
|
|
105
124
|
const products = [...selected.values()];
|
|
106
125
|
try {
|
|
@@ -114,6 +133,7 @@ async function seam(context: APIContext, snapshot: CommerceProviderCartSnapshot,
|
|
|
114
133
|
}),
|
|
115
134
|
destination: snapshot.destination,
|
|
116
135
|
...(policy.verification === "required" && snapshot.verificationRef ? { verificationRef: snapshot.verificationRef } : {}),
|
|
136
|
+
...(sandbox ? { ageAffirmed: true } : {}),
|
|
117
137
|
}, { verification: policy.verification, rules: policy.rules });
|
|
118
138
|
const verified = policy.verification === "required" && decision.requirements.ageVerification === "satisfied";
|
|
119
139
|
const blocks = decision.blocks;
|
|
@@ -330,7 +350,7 @@ async function authorize(context: APIContext): Promise<Response> {
|
|
|
330
350
|
}
|
|
331
351
|
if (policy.verification === "required" && seamView.verified) {
|
|
332
352
|
evidence.verification = "fresh";
|
|
333
|
-
provenance.verification = { requirement: "required", state: "satisfied", source: SHARED_STORE_VERIFICATION_SOURCE, policyRevision: SHARED_STORE_POLICY_REVISION, expiresAt };
|
|
353
|
+
provenance.verification = { requirement: "required", state: "satisfied", source: seamView.sandbox ? SHARED_STORE_SANDBOX_VERIFICATION_SOURCE : SHARED_STORE_VERIFICATION_SOURCE, policyRevision: SHARED_STORE_POLICY_REVISION, expiresAt };
|
|
334
354
|
}
|
|
335
355
|
const decision = await evaluateFinalCart({ now, routedTenantId: commerceTenantId(tenant), quoted: presented, presented, evidence,
|
|
336
356
|
seam: seamView, catalogAvailable: true, browserConfirmed: false, token,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "6.7.
|
|
3
|
+
"version": "6.7.2",
|
|
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",
|