@tokenoftrust/storefront-runner 7.15.1 → 8.0.0
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.
- package/apps/storefront/src/config/compliance/rulesets.ts +475 -50
- package/apps/storefront/src/lib/checkout/commerce/finalCartAuthorization.ts +6 -0
- package/apps/storefront/src/lib/compliance/enforcement.ts +29 -0
- package/apps/storefront/src/pages/api/commerce/final-cart-authorization.ts +6 -0
- package/package.json +1 -1
- package/packages/public-runtime/src/compliance/evaluate.ts +600 -126
- package/packages/public-runtime/src/compliance/evidence-signals.ts +3 -1
- package/packages/public-runtime/src/compliance/profile.ts +184 -166
- package/packages/public-runtime/src/compliance/ruleset.ts +743 -78
- package/packages/public-runtime/src/compliance/state-directory.ts +116 -4
- package/packages/public-runtime/src/tenant.ts +1 -1
- package/packages/public-runtime/tests/fixtures/compliance-decisions.golden.json +100 -38
|
@@ -1,40 +1,479 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Compliance RULE DATA by PROFILE —
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
* data edit reviewed against the ruleset shape, not a code change.
|
|
2
|
+
* Compliance RULE DATA by PROFILE — pure declarative, versioned rule packs evaluated
|
|
3
|
+
* by `@tot/public-runtime`'s compliance engine. Rules are inert serializable data so
|
|
4
|
+
* jurisdiction/PACT/directory updates are audited data edits, never evaluator branches.
|
|
6
5
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
6
|
+
* `counsel-coverage-decision`: the rule packs below provide best-effort compliance
|
|
7
|
+
* coverage declarations without external counsel; merchants and their counsel remain
|
|
8
|
+
* responsible for authoritative legal review and statutory filings (including monthly
|
|
9
|
+
* PACT Act reports). Each pack carries `version`, `updatedAt`, and `source` provenance.
|
|
10
10
|
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
* The verification `provider` is intentionally omitted here — operational env
|
|
12
|
+
* (`TOT_VERIFICATION_PROVIDER`) wires it at resolve time in `enforcement.ts`, failing
|
|
13
|
+
* closed when absent.
|
|
14
|
+
*/
|
|
15
|
+
import type {
|
|
16
|
+
ComplianceRule,
|
|
17
|
+
ComplianceRulePack,
|
|
18
|
+
ComplianceRuleProfile,
|
|
19
|
+
ComplianceRuleset,
|
|
20
|
+
RegistryJurisdictionCode,
|
|
21
|
+
RulePredicate,
|
|
22
|
+
} from "@tot/public-runtime";
|
|
23
|
+
|
|
24
|
+
const COUNSEL_COVERAGE_SOURCE =
|
|
25
|
+
"ToT storefront compliance rule pack under counsel-coverage-decision (best-effort coverage, NOT legal advice). " +
|
|
26
|
+
"Merchant + counsel own authoritative legal review and statutory filings.";
|
|
27
|
+
|
|
28
|
+
const NICOTINE_OR_ENDS_SUBJECT: RulePredicate = {
|
|
29
|
+
any: [
|
|
30
|
+
{ field: "subject.containsNicotine", op: "is_true" },
|
|
31
|
+
{ field: "subject.category", op: "in", value: ["ends", "e-liquid", "other-nicotine"] },
|
|
32
|
+
],
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const CONTAINS_NICOTINE_SUBJECT: RulePredicate = {
|
|
36
|
+
field: "subject.containsNicotine",
|
|
37
|
+
op: "is_true",
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const E_LIQUID_SUBJECT: RulePredicate = {
|
|
41
|
+
field: "subject.category",
|
|
42
|
+
op: "eq",
|
|
43
|
+
value: "e-liquid",
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const LITHIUM_BATTERY_SUBJECT: RulePredicate = {
|
|
47
|
+
field: "catalog.containsLithiumBattery",
|
|
48
|
+
op: "is_true",
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
function stateRegistryRule(
|
|
52
|
+
region: string,
|
|
53
|
+
jurisdiction: RegistryJurisdictionCode,
|
|
54
|
+
label: string,
|
|
55
|
+
): ComplianceRule {
|
|
56
|
+
return {
|
|
57
|
+
id: `ovs-registry-${jurisdiction.toLowerCase()}`,
|
|
58
|
+
note: `${label} ENDS product directory`,
|
|
59
|
+
when: {
|
|
60
|
+
destination: { country: "US", regions: [region] },
|
|
61
|
+
channels: ["b2c", "b2b"],
|
|
62
|
+
subjectMatch: NICOTINE_OR_ENDS_SUBJECT,
|
|
63
|
+
},
|
|
64
|
+
effect: {
|
|
65
|
+
kind: "require_predicate",
|
|
66
|
+
code: "registry_prohibited",
|
|
67
|
+
predicate: { field: "catalog.registryListings", op: "registry_listed", value: jurisdiction },
|
|
68
|
+
blockOnUnclassified: true,
|
|
69
|
+
message: `Product is not listed on the ${label} regulated ENDS directory (${jurisdiction}).`,
|
|
70
|
+
failClosedMessage: `Product ${label} directory (${jurisdiction}) listing could not be confirmed (safe default = BLOCK).`,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Pilot US vape/nicotine rule pack (`v1.0.0`): preserves state-level DTC prohibitions,
|
|
77
|
+
* flavor bans, California cooling-agent ban, and retail per-order caps as pure declarative rules.
|
|
22
78
|
*/
|
|
23
|
-
|
|
79
|
+
export const VAPE_NICOTINE_US_PACK: ComplianceRulePack = {
|
|
80
|
+
packId: "vape-nicotine-us",
|
|
81
|
+
version: "1.0.0",
|
|
82
|
+
updatedAt: "2026-07-23",
|
|
83
|
+
source:
|
|
84
|
+
"ToT storefront pilot starter ruleset (representative, NOT legal advice). " +
|
|
85
|
+
"Merchant + counsel own the authoritative rule data and PACT filings.",
|
|
86
|
+
defaultChannel: "b2c",
|
|
87
|
+
rules: [
|
|
88
|
+
{
|
|
89
|
+
id: "pilot-ut-ban",
|
|
90
|
+
note: "UT restricts DTC vapor shipment",
|
|
91
|
+
when: { destination: { regions: ["UT"] } },
|
|
92
|
+
effect: { kind: "ban_shipment" },
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
id: "pilot-vt-ban",
|
|
96
|
+
note: "VT prohibits DTC e-cigarette shipment to consumers",
|
|
97
|
+
when: { destination: { regions: ["VT"] } },
|
|
98
|
+
effect: { kind: "ban_shipment" },
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
id: "pilot-ar-ban",
|
|
102
|
+
note: "AR restricts DTC vapor shipment",
|
|
103
|
+
when: { destination: { regions: ["AR"] } },
|
|
104
|
+
effect: { kind: "ban_shipment" },
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
id: "pilot-ma-flavor",
|
|
108
|
+
note: "MA flavored tobacco/ENDS ban",
|
|
109
|
+
when: { destination: { regions: ["MA"] } },
|
|
110
|
+
effect: { kind: "ban_flavored" },
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
id: "pilot-ny-flavor",
|
|
114
|
+
note: "NY flavored e-cigarette ban",
|
|
115
|
+
when: { destination: { regions: ["NY"] } },
|
|
116
|
+
effect: { kind: "ban_flavored" },
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: "pilot-nj-flavor",
|
|
120
|
+
note: "NJ flavored vape ban",
|
|
121
|
+
when: { destination: { regions: ["NJ"] } },
|
|
122
|
+
effect: { kind: "ban_flavored" },
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
id: "pilot-ri-flavor",
|
|
126
|
+
note: "RI flavored ENDS ban",
|
|
127
|
+
when: { destination: { regions: ["RI"] } },
|
|
128
|
+
effect: { kind: "ban_flavored" },
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: "pilot-ca-flavor",
|
|
132
|
+
note: "CA SB-793 flavored tobacco ban; CA bans synthetic cooling agents",
|
|
133
|
+
when: { destination: { regions: ["CA"] } },
|
|
134
|
+
effect: { kind: "ban_flavored" },
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
id: "pilot-ca-cooling",
|
|
138
|
+
note: "CA SB-793 flavored tobacco ban; CA bans synthetic cooling agents",
|
|
139
|
+
when: { destination: { regions: ["CA"] } },
|
|
140
|
+
effect: { kind: "ban_cooling_agent" },
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
id: "pilot-me-limit",
|
|
144
|
+
note: "ME per-order limit",
|
|
145
|
+
when: { destination: { regions: ["ME"] } },
|
|
146
|
+
effect: { kind: "per_order_limit", limit: 5 },
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
id: "pilot-me-signature",
|
|
150
|
+
note: "ME per-order limit",
|
|
151
|
+
when: { destination: { regions: ["ME"] } },
|
|
152
|
+
effect: { kind: "require_adult_signature" },
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
id: "pilot-ct-limit",
|
|
156
|
+
note: "CT per-order limit",
|
|
157
|
+
when: { destination: { regions: ["CT"] } },
|
|
158
|
+
effect: { kind: "per_order_limit", limit: 5 },
|
|
159
|
+
},
|
|
160
|
+
],
|
|
161
|
+
};
|
|
24
162
|
|
|
25
163
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
164
|
+
* OVS + KY/LA declarative rule pack (`v2.0.0`, under `counsel-coverage-decision`):
|
|
165
|
+
* covers all 12 OVS priority jurisdictions (`AL`, `CA-UTL`, `MS`, `NJ`, `NY`, `NC`,
|
|
166
|
+
* `OK`, `PA`, `RI`, `SF` / `941xx`, `VA`, `WI`) plus `KY` and `LA`, San Francisco
|
|
167
|
+
* `941xx` ZIP-scoped restrictions, B2B/B2C channels, per-SKU/order caps, FDA/nicotineOrigin
|
|
168
|
+
* gates, and PACT Act physical fact declarations.
|
|
29
169
|
*/
|
|
30
|
-
|
|
170
|
+
export const VAPE_NICOTINE_US_OVS_PACK: ComplianceRulePack = {
|
|
171
|
+
packId: "vape-nicotine-us-ovs",
|
|
172
|
+
version: "2.0.0",
|
|
173
|
+
updatedAt: "2026-11-29",
|
|
174
|
+
source: COUNSEL_COVERAGE_SOURCE,
|
|
175
|
+
defaultChannel: "b2c",
|
|
176
|
+
rules: [
|
|
177
|
+
// --- B2C statewide no-ship bans ---
|
|
178
|
+
{
|
|
179
|
+
id: "ovs-ut-dtc-ban",
|
|
180
|
+
note: "UT restricts DTC vapor shipment",
|
|
181
|
+
when: { destination: { country: "US", regions: ["UT"] }, channels: ["b2c"] },
|
|
182
|
+
effect: { kind: "ban_shipment" },
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
id: "ovs-vt-dtc-ban",
|
|
186
|
+
note: "VT prohibits DTC e-cigarette shipment to consumers",
|
|
187
|
+
when: { destination: { country: "US", regions: ["VT"] }, channels: ["b2c"] },
|
|
188
|
+
effect: { kind: "ban_shipment" },
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
id: "ovs-ar-dtc-ban",
|
|
192
|
+
note: "AR restricts DTC vapor shipment",
|
|
193
|
+
when: { destination: { country: "US", regions: ["AR"] }, channels: ["b2c"] },
|
|
194
|
+
effect: { kind: "ban_shipment" },
|
|
195
|
+
},
|
|
196
|
+
|
|
197
|
+
// --- B2C state flavor & cooling-agent prohibitions ---
|
|
198
|
+
{
|
|
199
|
+
id: "ovs-ma-flavor",
|
|
200
|
+
note: "MA flavored tobacco/ENDS ban",
|
|
201
|
+
when: { destination: { country: "US", regions: ["MA"] }, channels: ["b2c"] },
|
|
202
|
+
effect: { kind: "ban_flavored" },
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
id: "ovs-ny-flavor",
|
|
206
|
+
note: "NY flavored e-cigarette ban",
|
|
207
|
+
when: { destination: { country: "US", regions: ["NY"] }, channels: ["b2c"] },
|
|
208
|
+
effect: { kind: "ban_flavored" },
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
id: "ovs-nj-flavor",
|
|
212
|
+
note: "NJ flavored vape ban",
|
|
213
|
+
when: { destination: { country: "US", regions: ["NJ"] }, channels: ["b2c"] },
|
|
214
|
+
effect: { kind: "ban_flavored" },
|
|
215
|
+
},
|
|
216
|
+
{
|
|
217
|
+
id: "ovs-ri-flavor",
|
|
218
|
+
note: "RI flavored ENDS ban",
|
|
219
|
+
when: { destination: { country: "US", regions: ["RI"] }, channels: ["b2c"] },
|
|
220
|
+
effect: { kind: "ban_flavored" },
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
id: "ovs-ca-flavor",
|
|
224
|
+
note: "CA SB-793 flavored tobacco ban; CA bans synthetic cooling agents",
|
|
225
|
+
when: { destination: { country: "US", regions: ["CA"] }, channels: ["b2c"] },
|
|
226
|
+
effect: { kind: "ban_flavored" },
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
id: "ovs-ca-cooling",
|
|
230
|
+
note: "CA SB-793 flavored tobacco ban; CA bans synthetic cooling agents",
|
|
231
|
+
when: { destination: { country: "US", regions: ["CA"] }, channels: ["b2c"] },
|
|
232
|
+
effect: { kind: "ban_cooling_agent" },
|
|
233
|
+
},
|
|
234
|
+
|
|
235
|
+
// --- 12 OVS Priority Registries + KY & LA ---
|
|
236
|
+
stateRegistryRule("AL", "AL", "Alabama"),
|
|
237
|
+
stateRegistryRule("CA", "CA-UTL", "California (CA-UTL)"),
|
|
238
|
+
stateRegistryRule("KY", "KY", "Kentucky"),
|
|
239
|
+
stateRegistryRule("LA", "LA", "Louisiana"),
|
|
240
|
+
stateRegistryRule("MS", "MS", "Mississippi"),
|
|
241
|
+
stateRegistryRule("NJ", "NJ", "New Jersey"),
|
|
242
|
+
stateRegistryRule("NY", "NY", "New York"),
|
|
243
|
+
stateRegistryRule("NC", "NC", "North Carolina"),
|
|
244
|
+
stateRegistryRule("OK", "OK", "Oklahoma"),
|
|
245
|
+
stateRegistryRule("PA", "PA", "Pennsylvania"),
|
|
246
|
+
stateRegistryRule("RI", "RI", "Rhode Island"),
|
|
247
|
+
{
|
|
248
|
+
id: "ovs-registry-sf-941xx",
|
|
249
|
+
note: "San Francisco (ZIP zone 941xx) municipal ENDS registry",
|
|
250
|
+
when: {
|
|
251
|
+
destination: { country: "US", regions: ["CA"], zipPrefixes: ["941"] },
|
|
252
|
+
channels: ["b2c", "b2b"],
|
|
253
|
+
subjectMatch: NICOTINE_OR_ENDS_SUBJECT,
|
|
254
|
+
},
|
|
255
|
+
effect: {
|
|
256
|
+
kind: "require_predicate",
|
|
257
|
+
code: "registry_prohibited",
|
|
258
|
+
predicate: { field: "catalog.registryListings", op: "registry_listed", value: "SF" },
|
|
259
|
+
blockOnUnclassified: true,
|
|
260
|
+
message: "Product is not listed on the San Francisco (SF) regulated ENDS registry for ZIP zone 941xx.",
|
|
261
|
+
failClosedMessage: "Product San Francisco (SF) registry listing for ZIP zone 941xx could not be confirmed (safe default = BLOCK).",
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
id: "ovs-sf-941xx-b2c-fda-strict",
|
|
266
|
+
note: "San Francisco ZIP zone 941xx requires finalized FDA marketing authorization",
|
|
267
|
+
when: {
|
|
268
|
+
destination: { country: "US", regions: ["CA"], zipPrefixes: ["941"] },
|
|
269
|
+
channels: ["b2c"],
|
|
270
|
+
subjectMatch: NICOTINE_OR_ENDS_SUBJECT,
|
|
271
|
+
},
|
|
272
|
+
effect: {
|
|
273
|
+
kind: "require_predicate",
|
|
274
|
+
code: "fact_prohibited",
|
|
275
|
+
predicate: {
|
|
276
|
+
field: "catalog.fdaAuthorization",
|
|
277
|
+
op: "in",
|
|
278
|
+
value: ["pmta-mgo", "se-order", "pre-existing"],
|
|
279
|
+
},
|
|
280
|
+
blockOnUnclassified: true,
|
|
281
|
+
message: "San Francisco ZIP zone 941xx B2C shipments require granted FDA authorization (MGO, SE order, or pre-existing status).",
|
|
282
|
+
failClosedMessage: "Product FDA authorization status could not be verified for San Francisco ZIP zone 941xx (safe default = BLOCK).",
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
{
|
|
286
|
+
id: "ovs-sf-941xx-signature",
|
|
287
|
+
note: "San Francisco ZIP zone 941xx adult signature requirement",
|
|
288
|
+
when: { destination: { country: "US", regions: ["CA"], zipPrefixes: ["941"] }, channels: ["b2c"] },
|
|
289
|
+
effect: { kind: "require_adult_signature" },
|
|
290
|
+
},
|
|
291
|
+
stateRegistryRule("VA", "VA", "Virginia"),
|
|
292
|
+
stateRegistryRule("WI", "WI", "Wisconsin"),
|
|
293
|
+
|
|
294
|
+
// --- Federal FDA authorization & nicotine origin gates ---
|
|
295
|
+
{
|
|
296
|
+
id: "ovs-us-fda-authorization",
|
|
297
|
+
note: "FDA PMTA / SE / pre-existing marketing authorization coverage",
|
|
298
|
+
when: {
|
|
299
|
+
destination: { country: "US" },
|
|
300
|
+
channels: ["b2c", "b2b"],
|
|
301
|
+
subjectMatch: NICOTINE_OR_ENDS_SUBJECT,
|
|
302
|
+
},
|
|
303
|
+
effect: {
|
|
304
|
+
kind: "require_predicate",
|
|
305
|
+
code: "fact_prohibited",
|
|
306
|
+
predicate: {
|
|
307
|
+
field: "catalog.fdaAuthorization",
|
|
308
|
+
op: "in",
|
|
309
|
+
value: ["pmta-mgo", "pmta-pending", "se-order", "pre-existing"],
|
|
310
|
+
},
|
|
311
|
+
blockOnUnclassified: true,
|
|
312
|
+
message: "Product lacks an eligible FDA authorization status for regulated ENDS commerce.",
|
|
313
|
+
failClosedMessage: "Product FDA authorization status is unverified (safe default = BLOCK).",
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
id: "ovs-us-nicotine-origin",
|
|
318
|
+
note: "FDA nicotine origin declaration requirement",
|
|
319
|
+
when: {
|
|
320
|
+
destination: { country: "US" },
|
|
321
|
+
channels: ["b2c", "b2b"],
|
|
322
|
+
subjectMatch: CONTAINS_NICOTINE_SUBJECT,
|
|
323
|
+
},
|
|
324
|
+
effect: {
|
|
325
|
+
kind: "require_predicate",
|
|
326
|
+
code: "fact_prohibited",
|
|
327
|
+
predicate: {
|
|
328
|
+
field: "catalog.nicotineOrigin",
|
|
329
|
+
op: "in",
|
|
330
|
+
value: ["tobacco-derived", "synthetic-ntn"],
|
|
331
|
+
},
|
|
332
|
+
blockOnUnclassified: true,
|
|
333
|
+
message: "Nicotine product requires an eligible declared nicotine origin (tobacco-derived or synthetic-ntn).",
|
|
334
|
+
failClosedMessage: "Product nicotine origin could not be verified (safe default = BLOCK).",
|
|
335
|
+
},
|
|
336
|
+
},
|
|
337
|
+
|
|
338
|
+
// --- PACT Act & physical package fact gates ---
|
|
339
|
+
{
|
|
340
|
+
id: "ovs-pact-manufacturer-name",
|
|
341
|
+
note: "PACT Act manufacturer legal identity declaration",
|
|
342
|
+
when: {
|
|
343
|
+
destination: { country: "US" },
|
|
344
|
+
channels: ["b2c", "b2b"],
|
|
345
|
+
subjectMatch: NICOTINE_OR_ENDS_SUBJECT,
|
|
346
|
+
},
|
|
347
|
+
effect: {
|
|
348
|
+
kind: "require_predicate",
|
|
349
|
+
code: "pact_requirement_failed",
|
|
350
|
+
predicate: { field: "catalog.manufacturerLegalName", op: "is_known" },
|
|
351
|
+
blockOnUnclassified: true,
|
|
352
|
+
message: "PACT Act shipment requires a verified manufacturer legal name.",
|
|
353
|
+
failClosedMessage: "PACT manufacturer legal name is missing or invalid (safe default = BLOCK).",
|
|
354
|
+
},
|
|
355
|
+
},
|
|
356
|
+
{
|
|
357
|
+
id: "ovs-pact-unit-weight",
|
|
358
|
+
note: "PACT Act shipping weight bounds",
|
|
359
|
+
when: {
|
|
360
|
+
destination: { country: "US" },
|
|
361
|
+
channels: ["b2c", "b2b"],
|
|
362
|
+
subjectMatch: NICOTINE_OR_ENDS_SUBJECT,
|
|
363
|
+
},
|
|
364
|
+
effect: {
|
|
365
|
+
kind: "require_predicate",
|
|
366
|
+
code: "pact_requirement_failed",
|
|
367
|
+
predicate: {
|
|
368
|
+
all: [
|
|
369
|
+
{ field: "catalog.unitWeightGrams", op: "gt", value: 0 },
|
|
370
|
+
{ field: "catalog.unitWeightGrams", op: "lte", value: 5000 },
|
|
371
|
+
],
|
|
372
|
+
},
|
|
373
|
+
blockOnUnclassified: true,
|
|
374
|
+
message: "PACT Act shipment requires unit weight between 0g and 5000g.",
|
|
375
|
+
failClosedMessage: "PACT unit weight declaration is missing or invalid (safe default = BLOCK).",
|
|
376
|
+
},
|
|
377
|
+
},
|
|
378
|
+
{
|
|
379
|
+
id: "ovs-pact-lithium-battery-known",
|
|
380
|
+
note: "PACT / carrier lithium battery hazard disclosure",
|
|
381
|
+
when: {
|
|
382
|
+
destination: { country: "US" },
|
|
383
|
+
channels: ["b2c", "b2b"],
|
|
384
|
+
subjectMatch: NICOTINE_OR_ENDS_SUBJECT,
|
|
385
|
+
},
|
|
386
|
+
effect: {
|
|
387
|
+
kind: "require_predicate",
|
|
388
|
+
code: "pact_requirement_failed",
|
|
389
|
+
predicate: { field: "catalog.containsLithiumBattery", op: "is_known" },
|
|
390
|
+
blockOnUnclassified: true,
|
|
391
|
+
message: "Carrier lithium-battery classification is required for shipment.",
|
|
392
|
+
failClosedMessage: "Carrier lithium-battery status is missing or conflicting (safe default = BLOCK).",
|
|
393
|
+
},
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
id: "ovs-pact-child-resistant-eliquid",
|
|
397
|
+
note: "CNPP Act child-resistant packaging for liquid nicotine",
|
|
398
|
+
when: {
|
|
399
|
+
destination: { country: "US" },
|
|
400
|
+
channels: ["b2c", "b2b"],
|
|
401
|
+
subjectMatch: E_LIQUID_SUBJECT,
|
|
402
|
+
},
|
|
403
|
+
effect: {
|
|
404
|
+
kind: "require_predicate",
|
|
405
|
+
code: "pact_requirement_failed",
|
|
406
|
+
predicate: { field: "catalog.childResistantPackaging", op: "is_true" },
|
|
407
|
+
blockOnUnclassified: true,
|
|
408
|
+
message: "Liquid nicotine products require certified child-resistant packaging.",
|
|
409
|
+
failClosedMessage: "Child-resistant packaging status is unverified for liquid nicotine (safe default = BLOCK).",
|
|
410
|
+
},
|
|
411
|
+
},
|
|
412
|
+
|
|
413
|
+
// --- Channel & jurisdiction unit caps ---
|
|
414
|
+
{
|
|
415
|
+
id: "ovs-me-b2c-limit",
|
|
416
|
+
note: "ME per-order limit",
|
|
417
|
+
when: { destination: { country: "US", regions: ["ME"] }, channels: ["b2c"] },
|
|
418
|
+
effect: { kind: "per_order_limit", limit: 5 },
|
|
419
|
+
},
|
|
420
|
+
{
|
|
421
|
+
id: "ovs-me-b2c-signature",
|
|
422
|
+
note: "ME per-order limit",
|
|
423
|
+
when: { destination: { country: "US", regions: ["ME"] }, channels: ["b2c"] },
|
|
424
|
+
effect: { kind: "require_adult_signature" },
|
|
425
|
+
},
|
|
426
|
+
{
|
|
427
|
+
id: "ovs-ct-b2c-limit",
|
|
428
|
+
note: "CT per-order limit",
|
|
429
|
+
when: { destination: { country: "US", regions: ["CT"] }, channels: ["b2c"] },
|
|
430
|
+
effect: { kind: "per_order_limit", limit: 5 },
|
|
431
|
+
},
|
|
432
|
+
{
|
|
433
|
+
id: "ovs-us-b2c-sku-limit",
|
|
434
|
+
note: "OVS B2C per-SKU unit limit",
|
|
435
|
+
when: { destination: { country: "US" }, channels: ["b2c"] },
|
|
436
|
+
effect: { kind: "per_sku_limit", limit: 5 },
|
|
437
|
+
},
|
|
438
|
+
{
|
|
439
|
+
id: "ovs-us-b2c-order-limit",
|
|
440
|
+
note: "OVS B2C per-order unit limit",
|
|
441
|
+
when: { destination: { country: "US" }, channels: ["b2c"] },
|
|
442
|
+
effect: { kind: "per_order_limit", limit: 10 },
|
|
443
|
+
},
|
|
444
|
+
{
|
|
445
|
+
id: "ovs-us-b2c-battery-order-limit",
|
|
446
|
+
note: "B2C lithium-battery carrier unit cap",
|
|
447
|
+
when: {
|
|
448
|
+
destination: { country: "US" },
|
|
449
|
+
channels: ["b2c"],
|
|
450
|
+
subjectMatch: LITHIUM_BATTERY_SUBJECT,
|
|
451
|
+
},
|
|
452
|
+
effect: { kind: "per_order_limit", limit: 5 },
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
id: "ovs-us-b2b-sku-limit",
|
|
456
|
+
note: "OVS B2B wholesale per-SKU unit limit",
|
|
457
|
+
when: { destination: { country: "US" }, channels: ["b2b"] },
|
|
458
|
+
effect: { kind: "per_sku_limit", limit: 200 },
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
id: "ovs-us-b2b-order-limit",
|
|
462
|
+
note: "OVS B2B wholesale per-order unit limit",
|
|
463
|
+
when: { destination: { country: "US" }, channels: ["b2b"] },
|
|
464
|
+
effect: { kind: "per_order_limit", limit: 500 },
|
|
465
|
+
},
|
|
466
|
+
],
|
|
467
|
+
};
|
|
468
|
+
|
|
469
|
+
function rulesetFromPack(tenantId: string, pack: ComplianceRulePack): ComplianceRuleset {
|
|
31
470
|
return {
|
|
32
471
|
tenantId,
|
|
33
472
|
minAge: 21,
|
|
34
473
|
verification: {
|
|
35
474
|
required: true,
|
|
36
475
|
minAge: 21,
|
|
37
|
-
// provider:
|
|
476
|
+
// provider: resolved from operational env by resolveTenantRuleset (fail-closed if absent).
|
|
38
477
|
},
|
|
39
478
|
excise: {
|
|
40
479
|
required: true,
|
|
@@ -47,42 +486,28 @@ function vapeRuleset(tenantId: string): ComplianceRuleset {
|
|
|
47
486
|
pactAct: {
|
|
48
487
|
enabled: true,
|
|
49
488
|
adultSignatureRequired: true,
|
|
50
|
-
// PACT Act bars USPS from carrying ENDS; carrier selection is merchant-external.
|
|
51
489
|
prohibitedCarriers: ["USPS"],
|
|
52
490
|
reportingRequired: true,
|
|
53
491
|
},
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
{ region: "VT", banAll: true, note: "VT prohibits DTC e-cigarette shipment to consumers" },
|
|
58
|
-
{ region: "AR", banAll: true, note: "AR restricts DTC vapor shipment" },
|
|
59
|
-
// --- Flavored-ENDS bans (plain tobacco/unflavoured only; menthol is a characterizing flavour) ---
|
|
60
|
-
{ region: "MA", banFlavored: true, note: "MA flavored tobacco/ENDS ban" },
|
|
61
|
-
{ region: "NY", banFlavored: true, note: "NY flavored e-cigarette ban" },
|
|
62
|
-
{ region: "NJ", banFlavored: true, note: "NJ flavored vape ban" },
|
|
63
|
-
{ region: "RI", banFlavored: true, note: "RI flavored ENDS ban" },
|
|
64
|
-
{ region: "CA", banFlavored: true, banCoolingAgents: true, note: "CA SB-793 flavored tobacco ban; CA bans synthetic cooling agents" },
|
|
65
|
-
// --- Tighter per-order caps ---
|
|
66
|
-
{ region: "ME", perOrderUnitLimit: 5, adultSignatureRequired: true, note: "ME per-order limit" },
|
|
67
|
-
{ region: "CT", perOrderUnitLimit: 5, note: "CT per-order limit" },
|
|
68
|
-
],
|
|
69
|
-
updatedAt: "2026-07-23",
|
|
70
|
-
source:
|
|
71
|
-
"ToT storefront pilot starter ruleset (representative, NOT legal advice). " +
|
|
72
|
-
"Merchant + counsel own the authoritative rule data and PACT filings.",
|
|
492
|
+
rulePack: pack,
|
|
493
|
+
updatedAt: pack.updatedAt,
|
|
494
|
+
source: pack.source,
|
|
73
495
|
};
|
|
74
496
|
}
|
|
75
497
|
|
|
498
|
+
export const COMPLIANCE_RULE_PACKS: Record<ComplianceRuleProfile, ComplianceRulePack> = {
|
|
499
|
+
"vape-nicotine-us": VAPE_NICOTINE_US_PACK,
|
|
500
|
+
"vape-nicotine-us-ovs": VAPE_NICOTINE_US_OVS_PACK,
|
|
501
|
+
};
|
|
502
|
+
|
|
76
503
|
/**
|
|
77
|
-
* Rule
|
|
78
|
-
* never by which tenant it is.
|
|
79
|
-
* rules; a tenant declaring none resolves to no ruleset and fails closed. Onboarding
|
|
80
|
-
* a regulated merchant is a declaration in that tenant's own config, not an edit
|
|
81
|
-
* here — this file holds only the reviewed rule bodies.
|
|
504
|
+
* Rule packs keyed by the PROFILE a tenant declares (`compliance.ruleProfile`),
|
|
505
|
+
* never by which tenant it is.
|
|
82
506
|
*/
|
|
83
507
|
export const COMPLIANCE_RULE_PROFILES: Record<
|
|
84
508
|
ComplianceRuleProfile,
|
|
85
509
|
(tenantId: string) => ComplianceRuleset
|
|
86
510
|
> = {
|
|
87
|
-
"vape-nicotine-us":
|
|
511
|
+
"vape-nicotine-us": (tenantId) => rulesetFromPack(tenantId, VAPE_NICOTINE_US_PACK),
|
|
512
|
+
"vape-nicotine-us-ovs": (tenantId) => rulesetFromPack(tenantId, VAPE_NICOTINE_US_OVS_PACK),
|
|
88
513
|
};
|
|
@@ -150,9 +150,15 @@ function evidenceFinding(evidence: CommerceEvidence | null, stockTracked: boolea
|
|
|
150
150
|
}
|
|
151
151
|
|
|
152
152
|
const RULE_BLOCK_CODES: ReadonlySet<string> = new Set([
|
|
153
|
+
"invalid_ruleset",
|
|
154
|
+
"postal_code_required",
|
|
153
155
|
"flavored_prohibited",
|
|
154
156
|
"cooling_agent_prohibited",
|
|
155
157
|
"region_prohibited",
|
|
158
|
+
"registry_prohibited",
|
|
159
|
+
"fact_prohibited",
|
|
160
|
+
"pact_requirement_failed",
|
|
161
|
+
"sku_limit_exceeded",
|
|
156
162
|
"purchase_limit_exceeded",
|
|
157
163
|
]);
|
|
158
164
|
|
|
@@ -14,14 +14,17 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import type {
|
|
16
16
|
TenantConfig,
|
|
17
|
+
ComplianceRule,
|
|
17
18
|
ComplianceRuleset,
|
|
18
19
|
EnforcementEvidenceSignals,
|
|
20
|
+
TenantComplianceOverrides,
|
|
19
21
|
} from "@tot/public-runtime";
|
|
20
22
|
import {
|
|
21
23
|
ageVerificationRequired,
|
|
22
24
|
arrivalPopupEnabled,
|
|
23
25
|
enforcementSignals,
|
|
24
26
|
isRegulated,
|
|
27
|
+
normalizeRegionCode,
|
|
25
28
|
} from "@tot/public-runtime";
|
|
26
29
|
import { readEnv } from "@/lib/publication/shared/env";
|
|
27
30
|
import { COMPLIANCE_RULE_PROFILES } from "@/config/compliance/rulesets";
|
|
@@ -91,6 +94,30 @@ export function isLiveTotVerificationProvider(
|
|
|
91
94
|
*/
|
|
92
95
|
const PACT_REPORTING_CAPTURE_WIRED = true;
|
|
93
96
|
|
|
97
|
+
function tenantOverridesFromConfig(
|
|
98
|
+
compliance: TenantConfig["compliance"],
|
|
99
|
+
): TenantComplianceOverrides | undefined {
|
|
100
|
+
const elig = compliance?.stateEligibility;
|
|
101
|
+
if (!elig) return undefined;
|
|
102
|
+
const extraRules: ComplianceRule[] = [];
|
|
103
|
+
for (const [index, raw] of (elig.restrictedStates ?? []).entries()) {
|
|
104
|
+
const code = normalizeRegionCode(raw);
|
|
105
|
+
if (!code) continue;
|
|
106
|
+
extraRules.push({
|
|
107
|
+
id: `tenant-restricted-${code}-${index}`,
|
|
108
|
+
note: elig.note ?? "Merchant restricted destination",
|
|
109
|
+
when: { destination: { regions: [code] } },
|
|
110
|
+
effect: { kind: "ban_shipment" },
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
const hasFootprint = Array.isArray(elig.eligibleStates);
|
|
114
|
+
if (!hasFootprint && extraRules.length === 0) return undefined;
|
|
115
|
+
return {
|
|
116
|
+
...(hasFootprint ? { licensedStates: elig.eligibleStates } : {}),
|
|
117
|
+
...(extraRules.length > 0 ? { extraRules } : {}),
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
94
121
|
/**
|
|
95
122
|
* Resolve a tenant's compliance ruleset, or `null` when it can't be resolved for a
|
|
96
123
|
* regulated tenant (the caller must then fail closed). Wires the live verification
|
|
@@ -109,8 +136,10 @@ export async function resolveTenantRuleset(
|
|
|
109
136
|
const base = buildRuleset(tenant.tenant_id);
|
|
110
137
|
const provider = (await readEnv("TOT_VERIFICATION_PROVIDER")) || undefined;
|
|
111
138
|
const required = base.verification.required && ageVerificationRequired(tenant);
|
|
139
|
+
const tenantOverrides = tenantOverridesFromConfig(tenant.compliance);
|
|
112
140
|
return {
|
|
113
141
|
...base,
|
|
142
|
+
...(tenantOverrides ? { tenantOverrides } : {}),
|
|
114
143
|
verification: { ...base.verification, required, provider },
|
|
115
144
|
};
|
|
116
145
|
}
|
|
@@ -210,9 +210,15 @@ async function evaluateSeam(context: APIContext, snapshot: CommerceProviderCartS
|
|
|
210
210
|
const flavors = [...new Set(blocks.flatMap(block => block.code === "flavored_prohibited" ? block.flavors ?? [] : []))];
|
|
211
211
|
const hasRuleBlock = blocks.some(
|
|
212
212
|
block =>
|
|
213
|
+
block.code === "invalid_ruleset" ||
|
|
214
|
+
block.code === "postal_code_required" ||
|
|
213
215
|
block.code === "flavored_prohibited" ||
|
|
214
216
|
block.code === "cooling_agent_prohibited" ||
|
|
215
217
|
block.code === "region_prohibited" ||
|
|
218
|
+
block.code === "registry_prohibited" ||
|
|
219
|
+
block.code === "fact_prohibited" ||
|
|
220
|
+
block.code === "pact_requirement_failed" ||
|
|
221
|
+
block.code === "sku_limit_exceeded" ||
|
|
216
222
|
block.code === "purchase_limit_exceeded",
|
|
217
223
|
);
|
|
218
224
|
const titleOf = (sku: string) => products.find(p => p.variants.some(v => v.sku === sku))?.title;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tokenoftrust/storefront-runner",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
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",
|