@tokenoftrust/storefront-runner 7.3.1 → 7.5.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.
Files changed (414) hide show
  1. package/agency-kit/tools/lib/catalog-model/files.mjs +11 -4
  2. package/agency-kit/tools/lib/catalog-model/model.mjs +5 -1
  3. package/agency-kit/tools/lib/redirect-shadows.mjs +261 -0
  4. package/apps/storefront/astro.config.mjs +8 -2
  5. package/apps/storefront/package.json +1 -2
  6. package/apps/storefront/src/components/catalog/storefront/ProductCard.astro +20 -6
  7. package/apps/storefront/src/components/catalog/storefront/islands/ImageGallery.tsx +17 -6
  8. package/apps/storefront/src/components/compliance/storefront/islands/CheckoutComplianceGate.tsx +1 -32
  9. package/apps/storefront/src/config/compliance/rulesets.ts +1 -1
  10. package/apps/storefront/src/layouts/Layout.astro +17 -0
  11. package/apps/storefront/src/lib/access/auth/agentRoles.ts +20 -0
  12. package/apps/storefront/src/lib/access/auth/agentSessionGate.ts +147 -0
  13. package/apps/storefront/src/lib/access/auth/brokerAssertion.ts +67 -1
  14. package/apps/storefront/src/lib/access/auth/contactReaderAuthority.ts +39 -0
  15. package/apps/storefront/src/lib/access/auth/loginGate.ts +15 -17
  16. package/apps/storefront/src/lib/access/auth/session.ts +79 -0
  17. package/apps/storefront/src/lib/access/dashboard/staffAdmission.ts +5 -0
  18. package/apps/storefront/src/lib/access/dashboard/tenantSelection.ts +2 -0
  19. package/apps/storefront/src/lib/access/shared/capability.ts +14 -6
  20. package/apps/storefront/src/lib/access/shared/generated/capabilityCatalog.generated.ts +161 -0
  21. package/apps/storefront/src/lib/activity/activityScope.ts +36 -0
  22. package/apps/storefront/src/lib/activity/recordActivity.ts +23 -1
  23. package/apps/storefront/src/lib/activity/serverFanOut.ts +31 -0
  24. package/apps/storefront/src/lib/activity/store.ts +9 -3
  25. package/apps/storefront/src/lib/checkout/commerce/cardCartForm.ts +2 -0
  26. package/apps/storefront/src/lib/checkout/commerce/cartSession.ts +109 -12
  27. package/apps/storefront/src/lib/checkout/commerce/checkoutHandoffRoute.ts +53 -25
  28. package/apps/storefront/src/lib/checkout/commerce/finalCartAuthorization.ts +48 -6
  29. package/apps/storefront/src/lib/checkout/proposal/cartProposal.ts +388 -0
  30. package/apps/storefront/src/lib/checkout/proposal/listMatcher.ts +149 -0
  31. package/apps/storefront/src/lib/checkout/proposal/proposalRoutes.ts +447 -0
  32. package/apps/storefront/src/lib/checkout/proposal/reviewHtml.ts +100 -0
  33. package/apps/storefront/src/lib/compliance/browser/checkoutVerificationFlow.ts +26 -2
  34. package/apps/storefront/src/lib/content/shared/redirects.ts +21 -4
  35. package/apps/storefront/src/lib/publication/shared/edgeCache.ts +5 -2
  36. package/apps/storefront/src/lib/publication/shared/previewAnnotations/renderDecorator.ts +15 -8
  37. package/apps/storefront/src/lib/publication/shared/runtimeEnv.ts +1 -1
  38. package/apps/storefront/src/middleware/controlPlane.ts +15 -1
  39. package/apps/storefront/src/middleware/index.ts +40 -1
  40. package/apps/storefront/src/middleware/renderChain.ts +46 -33
  41. package/apps/storefront/src/pages/api/cart-proposal/confirm.ts +12 -0
  42. package/apps/storefront/src/pages/api/cart-proposal/review.ts +26 -0
  43. package/apps/storefront/src/pages/api/commerce/final-cart-authorization.ts +29 -6
  44. package/apps/storefront/src/pages/api/compliance/preflight.ts +25 -1
  45. package/apps/storefront/src/pages/products/[handle].astro +2 -15
  46. package/apps/storefront/tsconfig.astro.json +11 -0
  47. package/package.json +1 -1
  48. package/packages/public-runtime/src/activity/README.md +12 -0
  49. package/packages/public-runtime/src/activity/catalog.ts +7 -0
  50. package/packages/public-runtime/src/activity/event.ts +19 -0
  51. package/packages/public-runtime/src/activity/redaction.ts +31 -2
  52. package/packages/public-runtime/src/catalog-files.ts +3 -2
  53. package/packages/public-runtime/src/checkout-orders.ts +18 -19
  54. package/packages/public-runtime/src/checkout.ts +70 -0
  55. package/packages/public-runtime/src/compliance/evaluate.ts +60 -1
  56. package/packages/public-runtime/src/compliance/index.ts +1 -1
  57. package/packages/public-runtime/src/compliance/pact-report.ts +184 -3
  58. package/packages/public-runtime/src/compliance/profile.ts +268 -20
  59. package/packages/public-runtime/src/compliance/ruleset.ts +42 -0
  60. package/packages/public-runtime/src/customization-runtime.ts +1 -1
  61. package/packages/public-runtime/src/product.ts +9 -1
  62. package/packages/public-runtime/src/publication-content-redirects.ts +16 -3
  63. package/packages/public-runtime/tests/fixtures/compliance-decisions.golden.json +252 -52
  64. package/pnpm-lock.runner.yaml +0 -15
  65. package/scripts/tenant/materialize-tenant-content.mjs +3 -0
  66. package/scripts/tenant/validate.mjs +128 -0
  67. package/apps/storefront/dev-plugins/dev-publish.mjs +0 -55
  68. package/apps/storefront/drizzle.config.apps.ts +0 -13
  69. package/apps/storefront/integrations/preview-annotations-client-bundle.mjs +0 -80
  70. package/apps/storefront/migrations-apps/0000_fast_millenium_guard.sql +0 -129
  71. package/apps/storefront/migrations-apps/0001_woozy_lyja.sql +0 -22
  72. package/apps/storefront/migrations-apps/0002_good_switch.sql +0 -26
  73. package/apps/storefront/migrations-apps/0003_mute_marauders.sql +0 -12
  74. package/apps/storefront/migrations-apps/0004_deep_morph.sql +0 -36
  75. package/apps/storefront/migrations-apps/0005_common_mystique.sql +0 -23
  76. package/apps/storefront/migrations-apps/0006_broad_microchip.sql +0 -16
  77. package/apps/storefront/migrations-apps/0007_brave_outlaw_kid.sql +0 -15
  78. package/apps/storefront/migrations-apps/0008_blue_dazzler.sql +0 -11
  79. package/apps/storefront/migrations-apps/0009_bored_shinobi_shaw.sql +0 -15
  80. package/apps/storefront/migrations-apps/0010_ws4_verified_provider_measurement.sql +0 -35
  81. package/apps/storefront/migrations-apps/0011_dt_tracking_tenant_databases.sql +0 -23
  82. package/apps/storefront/migrations-apps/0012_test_destinations.sql +0 -29
  83. package/apps/storefront/migrations-apps/0013_publication_space_editorial.sql +0 -64
  84. package/apps/storefront/migrations-apps/0014_retire_candidate_ledger.sql +0 -12
  85. package/apps/storefront/migrations-apps/0015_merchant_calculation_settings.sql +0 -31
  86. package/apps/storefront/migrations-apps/0016_scrappy_commerce_contract.sql +0 -166
  87. package/apps/storefront/migrations-apps/0017_commerce_durable_projection.sql +0 -28
  88. package/apps/storefront/migrations-apps/0018_commerce_provider_cart_identity.sql +0 -13
  89. package/apps/storefront/migrations-apps/0019_commerce_source_authority.sql +0 -23
  90. package/apps/storefront/migrations-apps/0020_contact_messages.sql +0 -18
  91. package/apps/storefront/migrations-apps/0021_contact_vault.sql +0 -166
  92. package/apps/storefront/migrations-apps/0022_contact_vault_fields.sql +0 -342
  93. package/apps/storefront/migrations-apps/0023_principal_grant_contacts.sql +0 -15
  94. package/apps/storefront/migrations-apps/0024_order_contact_erasure_state.sql +0 -22
  95. package/apps/storefront/migrations-apps/0025_shipment_audit_order_lookup.sql +0 -2
  96. package/apps/storefront/migrations-apps/0026_fulfillment_assignment.sql +0 -44
  97. package/apps/storefront/migrations-apps/0027_app_contact_authority.sql +0 -70
  98. package/apps/storefront/migrations-apps/0028_app_jwk_and_candidates.sql +0 -133
  99. package/apps/storefront/migrations-apps/0029_inventory_locations_wms.sql +0 -38
  100. package/apps/storefront/migrations-apps/0030_assignment_split_shipments.sql +0 -149
  101. package/apps/storefront/migrations-apps/meta/0000_snapshot.json +0 -843
  102. package/apps/storefront/migrations-apps/meta/0001_snapshot.json +0 -990
  103. package/apps/storefront/migrations-apps/meta/0002_snapshot.json +0 -1160
  104. package/apps/storefront/migrations-apps/meta/0003_snapshot.json +0 -1235
  105. package/apps/storefront/migrations-apps/meta/0004_snapshot.json +0 -1474
  106. package/apps/storefront/migrations-apps/meta/0005_snapshot.json +0 -1617
  107. package/apps/storefront/migrations-apps/meta/0006_snapshot.json +0 -1716
  108. package/apps/storefront/migrations-apps/meta/0007_snapshot.json +0 -1812
  109. package/apps/storefront/migrations-apps/meta/0008_snapshot.json +0 -1881
  110. package/apps/storefront/migrations-apps/meta/0009_snapshot.json +0 -1979
  111. package/apps/storefront/migrations-apps/meta/_journal.json +0 -76
  112. package/apps/storefront/perf/README.md +0 -64
  113. package/apps/storefront/perf/assert-budgets.ts +0 -159
  114. package/apps/storefront/platform-reconcile-tenants.json +0 -3
  115. package/apps/storefront/playwright.config.ts +0 -23
  116. package/apps/storefront/public/js/dashboard-access-banner.js +0 -53
  117. package/apps/storefront/public/js/dashboard-apps.js +0 -183
  118. package/apps/storefront/public/js/dashboard-contact-capture.js +0 -52
  119. package/apps/storefront/public/js/dashboard-delegate.js +0 -167
  120. package/apps/storefront/public/js/dashboard-team.js +0 -356
  121. package/apps/storefront/public/js/dashboard-vendor-search.js +0 -115
  122. package/apps/storefront/src/components/content/storefront/AsyncStylesheet.astro +0 -26
  123. package/apps/storefront/src/components/integrations/storefront/WidgetFrame.astro +0 -34
  124. package/apps/storefront/src/config/adminTenantLookup.ts +0 -35
  125. package/apps/storefront/src/config/evidenceTenantRoster.ts +0 -25
  126. package/apps/storefront/src/config/staffProvisionProjection.ts +0 -24
  127. package/apps/storefront/src/config/storeName.ts +0 -34
  128. package/apps/storefront/src/lib/access/admin/README.md +0 -122
  129. package/apps/storefront/src/lib/access/admin/adminShell.ts +0 -281
  130. package/apps/storefront/src/lib/access/admin/envelope.ts +0 -9
  131. package/apps/storefront/src/lib/access/admin/viewmodels/settings.ts +0 -64
  132. package/apps/storefront/src/lib/access/auth/adminApiGuard.ts +0 -66
  133. package/apps/storefront/src/lib/access/auth/adminEntry.ts +0 -126
  134. package/apps/storefront/src/lib/access/auth/mcpClientAssertion.ts +0 -217
  135. package/apps/storefront/src/lib/access/auth/operatorSession.ts +0 -120
  136. package/apps/storefront/src/lib/access/dashboard/delegateGate.ts +0 -130
  137. package/apps/storefront/src/lib/access/dashboard/staffStoreEntry.ts +0 -150
  138. package/apps/storefront/src/lib/access/dashboard/staffVendorAccess.ts +0 -452
  139. package/apps/storefront/src/lib/access/dashboard/vendorQuery.ts +0 -61
  140. package/apps/storefront/src/lib/access/fixtures/settings.ts +0 -67
  141. package/apps/storefront/src/lib/access/fixtures/tenants.ts +0 -29
  142. package/apps/storefront/src/lib/access/notifications/magicLinkInviteEmail.ts +0 -62
  143. package/apps/storefront/src/lib/access/shared/grantContactLookup.ts +0 -97
  144. package/apps/storefront/src/lib/access/shared/principalGrants.ts +0 -775
  145. package/apps/storefront/src/lib/activity/alerts.ts +0 -426
  146. package/apps/storefront/src/lib/activity/candidateSubmitLease.ts +0 -87
  147. package/apps/storefront/src/lib/activity/changeActorAttribution.ts +0 -181
  148. package/apps/storefront/src/lib/activity/evidence/evidenceReference.ts +0 -32
  149. package/apps/storefront/src/lib/activity/fixtures/evidence.ts +0 -99
  150. package/apps/storefront/src/lib/activity/query.ts +0 -403
  151. package/apps/storefront/src/lib/activity/uiActor.ts +0 -152
  152. package/apps/storefront/src/lib/admin/services/mock/index.ts +0 -12
  153. package/apps/storefront/src/lib/assets/addons/catalog.ts +0 -60
  154. package/apps/storefront/src/lib/assets/addons/storeEntitlements.ts +0 -260
  155. package/apps/storefront/src/lib/assets/durableAssetsRoute.ts +0 -65
  156. package/apps/storefront/src/lib/assets/durableR2.ts +0 -473
  157. package/apps/storefront/src/lib/assets/durableR2Bindings.ts +0 -33
  158. package/apps/storefront/src/lib/automation/admin/viewmodels/aiWorkflows.ts +0 -65
  159. package/apps/storefront/src/lib/automation/ai/approvalMode.ts +0 -20
  160. package/apps/storefront/src/lib/automation/ai/askEnvelope.ts +0 -47
  161. package/apps/storefront/src/lib/automation/ai/audit.ts +0 -12
  162. package/apps/storefront/src/lib/automation/ai/operationalRuns.ts +0 -155
  163. package/apps/storefront/src/lib/automation/ai/recommendation.ts +0 -20
  164. package/apps/storefront/src/lib/automation/fixtures/aiWorkflows.ts +0 -59
  165. package/apps/storefront/src/lib/catalog/admin/catalogSettingsClient.ts +0 -250
  166. package/apps/storefront/src/lib/catalog/admin/catalogSettingsFields.ts +0 -134
  167. package/apps/storefront/src/lib/catalog/admin/catalogSettingsPreview.ts +0 -37
  168. package/apps/storefront/src/lib/catalog/admin/catalogSettingsPricingView.ts +0 -39
  169. package/apps/storefront/src/lib/catalog/admin/catalogSettingsRuleView.ts +0 -44
  170. package/apps/storefront/src/lib/catalog/admin/catalogSettingsSkuView.ts +0 -21
  171. package/apps/storefront/src/lib/catalog/admin/catalogSettingsState.ts +0 -132
  172. package/apps/storefront/src/lib/catalog/admin/productSetupPhoto.ts +0 -23
  173. package/apps/storefront/src/lib/catalog/admin/productsTabClient.ts +0 -193
  174. package/apps/storefront/src/lib/catalog/admin/services/catalogProducts.ts +0 -32
  175. package/apps/storefront/src/lib/catalog/admin/viewmodels/catalogProducts.ts +0 -164
  176. package/apps/storefront/src/lib/catalog/admin/viewmodels/products.ts +0 -267
  177. package/apps/storefront/src/lib/catalog/fixtures/products.ts +0 -105
  178. package/apps/storefront/src/lib/catalog/tot/syncState.ts +0 -111
  179. package/apps/storefront/src/lib/checkout/admin/checkoutStyleInput.ts +0 -172
  180. package/apps/storefront/src/lib/checkout/admin/checkoutStyleTarget.ts +0 -65
  181. package/apps/storefront/src/lib/checkout/browser/checkoutExciseForm.ts +0 -152
  182. package/apps/storefront/src/lib/checkout/browser/checkoutRequirementsForm.ts +0 -72
  183. package/apps/storefront/src/lib/checkout/browser/checkoutStyleForm.ts +0 -110
  184. package/apps/storefront/src/lib/checkout/browser/settingDraftActions.ts +0 -367
  185. package/apps/storefront/src/lib/checkout/commerce/checkoutSettings.ts +0 -246
  186. package/apps/storefront/src/lib/checkout/fixtures/checkoutSettings.ts +0 -77
  187. package/apps/storefront/src/lib/content/blog/markdown.ts +0 -174
  188. package/apps/storefront/src/lib/content/chrome/examples/tokenoftrust.chrome-assignments.example.json +0 -6
  189. package/apps/storefront/src/lib/content/chrome/examples/tokenoftrust.chrome.example.json +0 -79
  190. package/apps/storefront/src/lib/content/index.ts +0 -27
  191. package/apps/storefront/src/lib/content/the-build/readingTime.ts +0 -35
  192. package/apps/storefront/src/lib/content/the-build/toc.ts +0 -95
  193. package/apps/storefront/src/lib/customers/admin/viewmodels/customers.ts +0 -56
  194. package/apps/storefront/src/lib/customers/contactVault/blindIndex.ts +0 -28
  195. package/apps/storefront/src/lib/customers/contactVault/contactAudit.ts +0 -149
  196. package/apps/storefront/src/lib/customers/contactVault/dataKeys.ts +0 -283
  197. package/apps/storefront/src/lib/customers/contactVault/fieldEnvelope.ts +0 -88
  198. package/apps/storefront/src/lib/customers/contactVault/isolateMetrics.ts +0 -37
  199. package/apps/storefront/src/lib/customers/contactVault/kms.ts +0 -292
  200. package/apps/storefront/src/lib/customers/contactVault/retention.ts +0 -302
  201. package/apps/storefront/src/lib/customers/contactVault/retentionPolicy.ts +0 -290
  202. package/apps/storefront/src/lib/customers/contactVault/zip3.ts +0 -24
  203. package/apps/storefront/src/lib/customers/fixtures/customers.ts +0 -86
  204. package/apps/storefront/src/lib/developer-experience/admin/memoizeByEnvelope.ts +0 -27
  205. package/apps/storefront/src/lib/developer-experience/admin/seed.ts +0 -54
  206. package/apps/storefront/src/lib/developer-experience/dev/activityIngestToken.ts +0 -85
  207. package/apps/storefront/src/lib/developer-experience/dev/activityStore.ts +0 -82
  208. package/apps/storefront/src/lib/developer-experience/dev/ai-widget-client.js +0 -308
  209. package/apps/storefront/src/lib/developer-experience/dev/apiBase.ts +0 -17
  210. package/apps/storefront/src/lib/developer-experience/dev/cliSignInCode.ts +0 -124
  211. package/apps/storefront/src/lib/developer-experience/dev/cockpit/ask.ts +0 -49
  212. package/apps/storefront/src/lib/developer-experience/dev/cockpit/clickToSource.ts +0 -71
  213. package/apps/storefront/src/lib/developer-experience/dev/cockpit/copyCommand.ts +0 -227
  214. package/apps/storefront/src/lib/developer-experience/dev/cockpit/files.ts +0 -249
  215. package/apps/storefront/src/lib/developer-experience/dev/cockpit/hostedActivity.ts +0 -500
  216. package/apps/storefront/src/lib/developer-experience/dev/cockpit/infoPopover.ts +0 -12
  217. package/apps/storefront/src/lib/developer-experience/dev/cockpit/mcpCopy.ts +0 -34
  218. package/apps/storefront/src/lib/developer-experience/dev/cockpit/monitor.ts +0 -107
  219. package/apps/storefront/src/lib/developer-experience/dev/cockpit/stepper.ts +0 -116
  220. package/apps/storefront/src/lib/developer-experience/dev/cockpit/themeToggle.ts +0 -23
  221. package/apps/storefront/src/lib/developer-experience/dev/livePreview.ts +0 -77
  222. package/apps/storefront/src/lib/developer-experience/dev/obstacleStore.ts +0 -214
  223. package/apps/storefront/src/lib/developer-experience/dev/previewStatus.ts +0 -87
  224. package/apps/storefront/src/lib/developer-experience/dev/rendezvousBroker.ts +0 -226
  225. package/apps/storefront/src/lib/developer-experience/dev/runtimeStore.ts +0 -291
  226. package/apps/storefront/src/lib/developer-experience/dev/storeStatus.ts +0 -142
  227. package/apps/storefront/src/lib/developer-experience/dev/subjectReissue.ts +0 -67
  228. package/apps/storefront/src/lib/developer-experience/fixtures/regulated-commerce-truth/index.ts +0 -540
  229. package/apps/storefront/src/lib/developer-experience/fixtures/ws3-readonly-clone-preflight/index.ts +0 -495
  230. package/apps/storefront/src/lib/engagement/contact/contactMessages.ts +0 -671
  231. package/apps/storefront/src/lib/engagement/contact/messagesTabClient.ts +0 -175
  232. package/apps/storefront/src/lib/engagement/contact/submission.ts +0 -112
  233. package/apps/storefront/src/lib/engagement/messaging/messagesClient.ts +0 -149
  234. package/apps/storefront/src/lib/engagement/newsletter/digest.ts +0 -117
  235. package/apps/storefront/src/lib/engagement/newsletter/resendClient.ts +0 -79
  236. package/apps/storefront/src/lib/engagement/newsletter/send.ts +0 -265
  237. package/apps/storefront/src/lib/engagement/social/golive.ts +0 -212
  238. package/apps/storefront/src/lib/engagement/social/notify.ts +0 -32
  239. package/apps/storefront/src/lib/engagement/social/tokenStore.ts +0 -171
  240. package/apps/storefront/src/lib/fulfillment/admin/commerceDesk.ts +0 -180
  241. package/apps/storefront/src/lib/fulfillment/admin/commerceDeskRouting.ts +0 -45
  242. package/apps/storefront/src/lib/fulfillment/admin/viewmodels/fulfillment.ts +0 -1071
  243. package/apps/storefront/src/lib/fulfillment/appShipmentEvidence.ts +0 -271
  244. package/apps/storefront/src/lib/fulfillment/carrierEvidence.ts +0 -105
  245. package/apps/storefront/src/lib/fulfillment/commerceProjection.ts +0 -157
  246. package/apps/storefront/src/lib/fulfillment/commerceReadback.ts +0 -60
  247. package/apps/storefront/src/lib/fulfillment/commerceRecovery.ts +0 -84
  248. package/apps/storefront/src/lib/fulfillment/commerceRuntime.ts +0 -41
  249. package/apps/storefront/src/lib/fulfillment/fulfillmentService.ts +0 -2842
  250. package/apps/storefront/src/lib/fulfillment/readiness.ts +0 -217
  251. package/apps/storefront/src/lib/fulfillment/splitShipments.ts +0 -388
  252. package/apps/storefront/src/lib/fulfillment/syntheticPreviewOrders.ts +0 -292
  253. package/apps/storefront/src/lib/integrations/apps/appContactAuthority.ts +0 -27
  254. package/apps/storefront/src/lib/integrations/apps/appContactConsents.ts +0 -118
  255. package/apps/storefront/src/lib/integrations/apps/appInstallEnv.ts +0 -28
  256. package/apps/storefront/src/lib/integrations/apps/gtmMigrationDraft.ts +0 -103
  257. package/apps/storefront/src/lib/integrations/apps/inventoryWrite.ts +0 -906
  258. package/apps/storefront/src/lib/integrations/apps/orders/customerHash.ts +0 -28
  259. package/apps/storefront/src/lib/integrations/apps/orders/idempotency.ts +0 -100
  260. package/apps/storefront/src/lib/integrations/apps/reports/salesVelocityReport.ts +0 -96
  261. package/apps/storefront/src/lib/integrations/apps/routeParams.ts +0 -45
  262. package/apps/storefront/src/lib/integrations/webhooks/cloudflareQueueDispatcher.ts +0 -82
  263. package/apps/storefront/src/lib/integrations/webhooks/commercePayloads.ts +0 -159
  264. package/apps/storefront/src/lib/integrations/webhooks/deliveryEngine.ts +0 -379
  265. package/apps/storefront/src/lib/integrations/webhooks/deliveryMapper.ts +0 -34
  266. package/apps/storefront/src/lib/integrations/webhooks/deliveryStore.ts +0 -903
  267. package/apps/storefront/src/lib/integrations/webhooks/dispatcher.ts +0 -168
  268. package/apps/storefront/src/lib/integrations/webhooks/emit.ts +0 -245
  269. package/apps/storefront/src/lib/integrations/webhooks/events.ts +0 -105
  270. package/apps/storefront/src/lib/integrations/webhooks/getDispatcher.ts +0 -77
  271. package/apps/storefront/src/lib/integrations/webhooks/orderFulfilledClaim.ts +0 -75
  272. package/apps/storefront/src/lib/measurement/admin/analyticsRegionPolicy.ts +0 -151
  273. package/apps/storefront/src/lib/measurement/admin/analyticsRegionsClient.ts +0 -84
  274. package/apps/storefront/src/lib/measurement/admin/consentSettingsClient.ts +0 -113
  275. package/apps/storefront/src/lib/measurement/analytics/index.ts +0 -44
  276. package/apps/storefront/src/lib/measurement/attribution/attributionService.ts +0 -206
  277. package/apps/storefront/src/lib/measurement/attribution/orderConversionD1.ts +0 -150
  278. package/apps/storefront/src/lib/measurement/attribution/verifiedProviderMeasurement.ts +0 -118
  279. package/apps/storefront/src/lib/measurement/tracking/interactionCollector.ts +0 -205
  280. package/apps/storefront/src/lib/measurement/tracking/pruneRollup.ts +0 -260
  281. package/apps/storefront/src/lib/measurement/tracking/tenantReadAccess.ts +0 -138
  282. package/apps/storefront/src/lib/measurement/tracking-writeback/rewriteTrackingIds.ts +0 -175
  283. package/apps/storefront/src/lib/measurement/tracking-writeback/writebackCandidate.ts +0 -110
  284. package/apps/storefront/src/lib/observability/diag/capture.ts +0 -162
  285. package/apps/storefront/src/lib/observability/diag/consoleLine.ts +0 -76
  286. package/apps/storefront/src/lib/observability/diag/debugConsole.ts +0 -118
  287. package/apps/storefront/src/lib/observability/diag/debugMode.ts +0 -163
  288. package/apps/storefront/src/lib/observability/diag/debugWindow.ts +0 -111
  289. package/apps/storefront/src/lib/observability/diag/redact.ts +0 -17
  290. package/apps/storefront/src/lib/observability/diag/reference.ts +0 -148
  291. package/apps/storefront/src/lib/observability/diag/referenceStore.ts +0 -113
  292. package/apps/storefront/src/lib/observability/diag/report.ts +0 -110
  293. package/apps/storefront/src/lib/observability/diag/serverResponseTime.ts +0 -91
  294. package/apps/storefront/src/lib/observability/diag/session.ts +0 -93
  295. package/apps/storefront/src/lib/observability/monitoring/manifest.ts +0 -301
  296. package/apps/storefront/src/lib/observability/performance/lighthouseReport.ts +0 -109
  297. package/apps/storefront/src/lib/observability/performance/rumAlert.ts +0 -179
  298. package/apps/storefront/src/lib/orders/admin/orderActions.ts +0 -556
  299. package/apps/storefront/src/lib/orders/admin/orderClient.ts +0 -248
  300. package/apps/storefront/src/lib/orders/admin/orderSource.ts +0 -410
  301. package/apps/storefront/src/lib/orders/admin/services/orders.ts +0 -922
  302. package/apps/storefront/src/lib/orders/admin/viewmodels/orders.ts +0 -135
  303. package/apps/storefront/src/lib/orders/data/commerceCallerConfig.ts +0 -37
  304. package/apps/storefront/src/lib/orders/data/ledgerContractOrders.ts +0 -148
  305. package/apps/storefront/src/lib/orders/data/orderForwardReceiver.ts +0 -532
  306. package/apps/storefront/src/lib/orders/data/orderMapper.ts +0 -454
  307. package/apps/storefront/src/lib/orders/data/ordersStore.ts +0 -623
  308. package/apps/storefront/src/lib/orders/data/sourceAuthorityContract.ts +0 -380
  309. package/apps/storefront/src/lib/orders/data/sourceAuthorityStore.ts +0 -830
  310. package/apps/storefront/src/lib/orders/fixtures/orders.ts +0 -186
  311. package/apps/storefront/src/lib/orders/providers/foxyOrderClient.ts +0 -207
  312. package/apps/storefront/src/lib/orders/vault/appRecipientRead.ts +0 -222
  313. package/apps/storefront/src/lib/orders/vault/contactIntake.ts +0 -63
  314. package/apps/storefront/src/lib/orders/vault/contactRoutes.ts +0 -110
  315. package/apps/storefront/src/lib/orders/vault/kmsEnv.ts +0 -11
  316. package/apps/storefront/src/lib/orders/vault/orderContact.ts +0 -96
  317. package/apps/storefront/src/lib/orders/vault/orderContactVault.ts +0 -1427
  318. package/apps/storefront/src/lib/orders/vault/vault-test-support.ts +0 -258
  319. package/apps/storefront/src/lib/publication/d1/schema-apps.ts +0 -808
  320. package/apps/storefront/src/lib/publication/notifications/candidateConflictEmail.ts +0 -80
  321. package/apps/storefront/src/lib/publication/servingMode.ts +0 -52
  322. package/apps/storefront/src/lib/publication/shared/previewAnnotations/moduleAsset.ts +0 -65
  323. package/apps/storefront/src/lib/publication/shared/routedApiParam.ts +0 -38
  324. package/apps/storefront/src/lib/reporting/admin/viewmodels/reporting.ts +0 -34
  325. package/apps/storefront/src/lib/reporting/fixtures/reporting.ts +0 -51
  326. package/apps/storefront/src/lib/subscriptions/admin/viewmodels/subscriptions.ts +0 -106
  327. package/apps/storefront/src/lib/subscriptions/fixtures/subscriptions.ts +0 -398
  328. package/apps/storefront/src/pages/api/admin/activity-alerts.ts +0 -58
  329. package/apps/storefront/src/pages/api/admin/commerce-readiness.ts +0 -172
  330. package/apps/storefront/src/pages/api/admin/fulfillment/batches.ts +0 -59
  331. package/apps/storefront/src/pages/api/admin/fulfillment/orders/[id]/address.ts +0 -66
  332. package/apps/storefront/src/pages/api/admin/fulfillment/orders/[id].ts +0 -118
  333. package/apps/storefront/src/pages/api/admin/fulfillment/orders/contact-search.ts +0 -26
  334. package/apps/storefront/src/pages/api/admin/fulfillment/orders/contacts.ts +0 -22
  335. package/apps/storefront/src/pages/api/admin/interaction-insights.ts +0 -101
  336. package/apps/storefront/src/pages/api/admin/orders/[id].ts +0 -63
  337. package/apps/storefront/src/pages/api/admin/orders.ts +0 -65
  338. package/apps/storefront/src/pages/api/contact.ts +0 -144
  339. package/apps/storefront/src/scheduled/contactVaultSweep.ts +0 -113
  340. package/apps/storefront/src/styles/admin.css +0 -1161
  341. package/apps/storefront/test/pipeline/fake-preview-services.ts +0 -288
  342. package/apps/storefront/test/pipeline/harness.ts +0 -209
  343. package/apps/storefront/test/pipeline/intake-worker.mjs +0 -14
  344. package/apps/storefront/test/pipeline/matrix-faults.ts +0 -366
  345. package/apps/storefront/test/pipeline/pipeline-host.ts +0 -418
  346. package/apps/storefront/test/pipeline/pool-config.cjs +0 -85
  347. package/apps/storefront/test/pipeline/publish-kinds.ts +0 -279
  348. package/apps/storefront/test/pipeline/synthetic-job.ts +0 -303
  349. package/apps/storefront/test/pipeline-faults/matrix-lib.ts +0 -696
  350. package/apps/storefront/vitest.config.cts +0 -44
  351. package/apps/storefront/vitest.faults.config.cts +0 -13
  352. package/apps/storefront/vitest.workers.config.cts +0 -7
  353. package/packages/feedback/fixtures/v1/expected-findings.json +0 -16
  354. package/packages/feedback/fixtures/v1/feedback-action/invalid/carries-transport-credential.json +0 -14
  355. package/packages/feedback/fixtures/v1/feedback-action/invalid/control-char-in-description.json +0 -13
  356. package/packages/feedback/fixtures/v1/feedback-action/invalid/legacy-schema-version.json +0 -13
  357. package/packages/feedback/fixtures/v1/feedback-action/invalid/page-path-with-query.json +0 -14
  358. package/packages/feedback/fixtures/v1/feedback-action/invalid/title-too-short.json +0 -13
  359. package/packages/feedback/fixtures/v1/feedback-action/valid/element-problem.json +0 -33
  360. package/packages/feedback/fixtures/v1/feedback-action/valid/page-comment.json +0 -20
  361. package/packages/feedback/fixtures/v1/feedback-action/valid/region-improvement.json +0 -24
  362. package/packages/feedback/fixtures/v1/feedback-action/valid/text-selection-feature.json +0 -30
  363. package/packages/feedback/fixtures/v1/submission-receipt/invalid/accepted-at-not-utc.json +0 -9
  364. package/packages/feedback/fixtures/v1/submission-receipt/invalid/bad-feedback-id.json +0 -9
  365. package/packages/feedback/fixtures/v1/submission-receipt/invalid/legacy-contract-version.json +0 -9
  366. package/packages/feedback/fixtures/v1/submission-receipt/invalid/missing-replayed.json +0 -8
  367. package/packages/feedback/fixtures/v1/submission-receipt/valid/accepted.json +0 -9
  368. package/packages/feedback/fixtures/v1/submission-receipt/valid/fractional-seconds.json +0 -9
  369. package/packages/feedback/fixtures/v1/submission-receipt/valid/replayed.json +0 -9
  370. package/packages/feedback/fixtures/v1/target-evidence/invalid/page-kind-claims-structure.json +0 -6
  371. package/packages/feedback/fixtures/v1/target-evidence/invalid/path-too-deep.json +0 -17
  372. package/packages/feedback/fixtures/v1/target-evidence/invalid/relative-region-out-of-range.json +0 -11
  373. package/packages/feedback/fixtures/v1/target-evidence/invalid/selector-uses-class.json +0 -7
  374. package/packages/feedback/fixtures/v1/target-evidence/invalid/source-precision-without-anchor.json +0 -6
  375. package/packages/feedback/fixtures/v1/target-evidence/valid/element-structure.json +0 -21
  376. package/packages/feedback/fixtures/v1/target-evidence/valid/host-iframe.json +0 -14
  377. package/packages/feedback/fixtures/v1/target-evidence/valid/source-anchor.json +0 -12
  378. package/packages/feedback/fixtures/v1/target-evidence/valid/text-selection.json +0 -26
  379. package/packages/feedback/package.json +0 -35
  380. package/packages/feedback/scripts/build-player.mjs +0 -28
  381. package/packages/feedback/src/index.ts +0 -1
  382. package/packages/feedback/src/primitives/composer.ts +0 -639
  383. package/packages/feedback/src/primitives/dialog.ts +0 -263
  384. package/packages/feedback/src/primitives/hostAdapter.ts +0 -116
  385. package/packages/feedback/src/primitives/index.ts +0 -10
  386. package/packages/feedback/src/primitives/launcher.ts +0 -200
  387. package/packages/feedback/src/primitives/picker.ts +0 -663
  388. package/packages/feedback/src/primitives/redaction.ts +0 -204
  389. package/packages/feedback/src/primitives/selection.ts +0 -49
  390. package/packages/feedback/src/primitives/shiftAccelerator.ts +0 -160
  391. package/packages/feedback/src/primitives/styles.ts +0 -77
  392. package/packages/feedback/src/primitives/surface.ts +0 -124
  393. package/packages/feedback/src/primitives/target.ts +0 -293
  394. package/packages/feedback/src/tour/canonical.ts +0 -27
  395. package/packages/feedback/src/tour/index.ts +0 -3
  396. package/packages/feedback/src/tour/player/browser.ts +0 -5
  397. package/packages/feedback/src/tour/player/host.ts +0 -12
  398. package/packages/feedback/src/tour/player/index.ts +0 -205
  399. package/packages/feedback/src/tour/player/manifest.ts +0 -76
  400. package/packages/feedback/src/tour/player/player.css +0 -130
  401. package/packages/feedback/src/tour/player/resolver.ts +0 -12
  402. package/packages/feedback/src/tour/player/surface.ts +0 -295
  403. package/packages/feedback/src/tour/player/types.ts +0 -8
  404. package/packages/feedback/src/tour/resolve/core.ts +0 -267
  405. package/packages/feedback/src/tour/resolve/dom.ts +0 -115
  406. package/packages/feedback/src/tour/resolve/index.ts +0 -29
  407. package/packages/feedback/src/tour/sanitize.ts +0 -76
  408. package/packages/feedback/src/tour/schema.ts +0 -362
  409. package/packages/feedback/src/v1/guards.ts +0 -335
  410. package/packages/feedback/src/v1/index.ts +0 -3
  411. package/packages/feedback/src/v1/protectedSurfaces.ts +0 -32
  412. package/packages/feedback/src/v1/types.ts +0 -177
  413. package/packages/feedback/tsconfig.json +0 -9
  414. package/packages/feedback/vitest.config.cts +0 -21
@@ -1,174 +0,0 @@
1
- /**
2
- * Minimal, dependency-free Markdown -> sanitized HTML for the admin blog editor
3
- * (see docs/plans/2026-08-21-blog-platform-workstream.md). The storefront
4
- * ships no markdown library (see the "No new deps" convention in §1), and the
5
- * migration package's `sanitize-html` is a node-only devtool — so authoring from
6
- * the admin gets this small hand-rolled renderer instead.
7
- *
8
- * SAFETY: the output is fed to `set:html` in the reader route
9
- * (`the-build/[slug].astro`), so it must never emit author-supplied HTML
10
- * verbatim. All text is HTML-escaped BEFORE any tag is emitted, only the tag set
11
- * this renderer produces can appear, and link hrefs / image `src`s are
12
- * scheme-checked (`http(s)`/`mailto`/site-relative/anchor only — `javascript:`
13
- * etc. fall back to plain text). Admin is already gated, but escaping is
14
- * defense-in-depth.
15
- *
16
- * SCOPE (v1): headings, bold, italic, inline code, fenced code, links, images,
17
- * blockquotes, unordered/ordered lists, horizontal rules, paragraphs. NOT a
18
- * CommonMark implementation — no nested lists or tables.
19
- */
20
-
21
- // A control char that never appears in authored prose and is untouched by
22
- // escapeHtml — a collision-free placeholder while code spans are set aside.
23
- const CODE_MARK = String.fromCharCode(0);
24
- const CODE_RE = new RegExp(`${CODE_MARK}(\\d+)${CODE_MARK}`, "g");
25
-
26
- function escapeHtml(s: string): string {
27
- return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
28
- }
29
-
30
- // Closes the one gap `escapeHtml` leaves open for attribute interpolation.
31
- // The url substring reaching this point has ALREADY passed through the single
32
- // escapeHtml(t) pass over the whole inline text (renderInline escapes before
33
- // running the link regex), so `&`/`<`/`>` are already entity-encoded — only
34
- // `"`/`'` remain untouched. Re-running full escapeHtml here would double-encode
35
- // those already-escaped entities, so this only needs to close the quote gap.
36
- function escapeAttrQuotes(s: string): string {
37
- return s.replace(/"/g, "&quot;").replace(/'/g, "&#39;");
38
- }
39
-
40
- // Only permit hrefs that can't execute script. Text is already escaped by the
41
- // time a URL reaches here, so a `javascript:`/`data:` payload arrives intact and
42
- // is rejected -> the link renders as its (escaped) label text instead. Quote/
43
- // angle-bracket characters are rejected outright (second line of defense on
44
- // top of escapeAttrQuotes at the call site) so an attribute-breakout payload
45
- // never matches the scheme allowlist in the first place.
46
- function sanitizeUrl(url: string): string | null {
47
- const u = url.trim();
48
- if (/["'<>]/.test(u)) return null;
49
- // `//host/path` is protocol-relative — a browser resolves it to an absolute
50
- // cross-origin URL using the current scheme, so it must NOT be accepted
51
- // under the "site-relative" `/` allowance (only a single, non-doubled slash
52
- // is genuinely site-relative).
53
- if (/^\/\//.test(u)) return null;
54
- return /^(https?:\/\/|mailto:|\/|#)/i.test(u) ? u : null;
55
- }
56
-
57
- // Inline spans, applied to already-block-split text. Code spans are extracted
58
- // first (and their contents escaped) so emphasis/link syntax inside `code` is
59
- // left literal; everything else is escaped, then link/bold/italic tags are woven
60
- // back in, then the code spans are restored.
61
- function renderInline(text: string): string {
62
- const codes: string[] = [];
63
- let t = text.replace(/`([^`]+)`/g, (_m, code: string) => {
64
- codes.push(`<code>${escapeHtml(code)}</code>`);
65
- return `${CODE_MARK}${codes.length - 1}${CODE_MARK}`;
66
- });
67
- t = escapeHtml(t);
68
- // Images before links: `![alt](url)` embeds a link-like `[alt](url)` span, so
69
- // the link regex would otherwise claim it. Each emitted `<img>` is stashed in
70
- // `codes` (same placeholder machinery as code spans) so the later link and
71
- // emphasis passes can't reach into its `src`/`alt` attribute values — an
72
- // `alt` of `a*b*c` must stay literal inside the attribute, not sprout an
73
- // `<em>`. `src` is scheme-checked (data:/protocol-relative rejected) and both
74
- // attribute values are quote-encoded on top of the whole-text escapeHtml pass.
75
- t = t.replace(/!\[([^\]]*)\]\(([^)\s]+)\)/g, (_m, alt: string, url: string) => {
76
- const safe = sanitizeUrl(url);
77
- if (!safe) return alt;
78
- const img = `<img src="${escapeAttrQuotes(safe)}" alt="${escapeAttrQuotes(alt)}" loading="lazy" decoding="async">`;
79
- codes.push(img);
80
- return `${CODE_MARK}${codes.length - 1}${CODE_MARK}`;
81
- });
82
- t = t.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g, (_m, label: string, url: string) => {
83
- const safe = sanitizeUrl(url);
84
- return safe ? `<a href="${escapeAttrQuotes(safe)}">${label}</a>` : label;
85
- });
86
- t = t
87
- .replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>")
88
- .replace(/__([^_]+)__/g, "<strong>$1</strong>");
89
- t = t
90
- .replace(/\*([^*]+)\*/g, "<em>$1</em>")
91
- .replace(/(^|[^a-zA-Z0-9])_([^_]+)_(?=[^a-zA-Z0-9]|$)/g, "$1<em>$2</em>");
92
- return t.replace(CODE_RE, (_m, i: string) => codes[Number(i)]!);
93
- }
94
-
95
- const isBlank = (l: string): boolean => l.trim() === "";
96
- const startsBlock = (l: string): boolean =>
97
- /^```/.test(l) ||
98
- /^#{1,6}\s+/.test(l) ||
99
- /^>\s?/.test(l) ||
100
- /^\s*[-*+]\s+/.test(l) ||
101
- /^\s*\d+\.\s+/.test(l) ||
102
- /^\s*(-{3,}|\*{3,}|_{3,})\s*$/.test(l);
103
-
104
- export function renderMarkdown(md: string): string {
105
- const lines = md.replace(/\r\n?/g, "\n").split("\n");
106
- const out: string[] = [];
107
- let i = 0;
108
-
109
- while (i < lines.length) {
110
- const line = lines[i]!;
111
-
112
- if (isBlank(line)) {
113
- i++;
114
- continue;
115
- }
116
-
117
- const fence = line.match(/^```\s*([a-zA-Z0-9_-]*)\s*$/);
118
- if (fence) {
119
- const buf: string[] = [];
120
- i++;
121
- while (i < lines.length && !/^```\s*$/.test(lines[i]!)) buf.push(lines[i++]!);
122
- i++; // consume closing fence (tolerate an unterminated block at EOF)
123
- const cls = fence[1] ? ` class="language-${fence[1]}"` : "";
124
- out.push(`<pre><code${cls}>${escapeHtml(buf.join("\n"))}</code></pre>`);
125
- continue;
126
- }
127
-
128
- const heading = line.match(/^(#{1,6})\s+(.*)$/);
129
- if (heading) {
130
- const level = heading[1]!.length;
131
- out.push(`<h${level}>${renderInline(heading[2]!.trim())}</h${level}>`);
132
- i++;
133
- continue;
134
- }
135
-
136
- if (/^\s*(-{3,}|\*{3,}|_{3,})\s*$/.test(line)) {
137
- out.push("<hr>");
138
- i++;
139
- continue;
140
- }
141
-
142
- if (/^>\s?/.test(line)) {
143
- const buf: string[] = [];
144
- while (i < lines.length && /^>\s?/.test(lines[i]!)) buf.push(lines[i++]!.replace(/^>\s?/, ""));
145
- out.push(`<blockquote>${renderMarkdown(buf.join("\n"))}</blockquote>`);
146
- continue;
147
- }
148
-
149
- if (/^\s*[-*+]\s+/.test(line)) {
150
- const items: string[] = [];
151
- while (i < lines.length && /^\s*[-*+]\s+/.test(lines[i]!)) {
152
- items.push(lines[i++]!.replace(/^\s*[-*+]\s+/, "").trim());
153
- }
154
- out.push(`<ul>${items.map((it) => `<li>${renderInline(it)}</li>`).join("")}</ul>`);
155
- continue;
156
- }
157
-
158
- if (/^\s*\d+\.\s+/.test(line)) {
159
- const items: string[] = [];
160
- while (i < lines.length && /^\s*\d+\.\s+/.test(lines[i]!)) {
161
- items.push(lines[i++]!.replace(/^\s*\d+\.\s+/, "").trim());
162
- }
163
- out.push(`<ol>${items.map((it) => `<li>${renderInline(it)}</li>`).join("")}</ol>`);
164
- continue;
165
- }
166
-
167
- const buf: string[] = [];
168
- while (i < lines.length && !isBlank(lines[i]!) && !startsBlock(lines[i]!)) buf.push(lines[i++]!);
169
- const text = buf.join(" ").trim();
170
- if (text) out.push(`<p>${renderInline(text)}</p>`);
171
- }
172
-
173
- return out.join("\n");
174
- }
@@ -1,6 +0,0 @@
1
- {
2
- "assignments": {
3
- "/contact/contact-sales": { "headerVariant": "minimal" },
4
- "/contact/contact-sales/thank-you": { "headerVariant": "minimal", "footerVariant": "minimal" }
5
- }
6
- }
@@ -1,79 +0,0 @@
1
- {
2
- "lang": "en",
3
- "head": {
4
- "favicon": "/tenants/tokenoftrust.com/favicon.png",
5
- "themeStylesheets": ["/tenants/tokenoftrust.com/themes/tot-navy.css"]
6
- },
7
- "sharedMarketingCss": true,
8
- "header": {
9
- "variant": "primary",
10
- "brand": {
11
- "href": "/",
12
- "label": "Token of Trust",
13
- "logo": {
14
- "src": "/tenants/tokenoftrust.com/logo-wordmark.png",
15
- "alt": "Token of Trust",
16
- "width": 180,
17
- "height": 32
18
- }
19
- },
20
- "nav": [
21
- { "id": "nav-platform", "action": "nav-platform", "label": "Platform", "href": "/#platform" },
22
- { "id": "nav-industries", "action": "nav-industries", "label": "Industries", "href": "/#industries" },
23
- { "id": "nav-resources", "action": "nav-resources", "label": "Resources", "href": "https://help.tokenoftrust.com", "external": true },
24
- { "id": "nav-pricing", "action": "nav-pricing", "label": "Pricing", "href": "https://tokenoftrust.com/pricing/", "external": true },
25
- { "id": "nav-login", "action": "nav-login", "label": "Login", "href": "https://app.tokenoftrust.com", "external": true }
26
- ],
27
- "ctas": [
28
- { "id": "cta-book-demo", "action": "cta-book-demo", "label": "Book Demo", "href": "https://tokenoftrust.com/contact/", "variant": "secondary" },
29
- { "id": "cta-start-free", "action": "cta-start-for-free", "label": "Start For Free", "href": "https://app.tokenoftrust.com", "variant": "primary" }
30
- ]
31
- },
32
- "footer": {
33
- "variant": "default",
34
- "brand": {
35
- "text": "Customer verification and compliance for regulated ecommerce. 200+ countries. We will never sell your data."
36
- },
37
- "columns": [
38
- {
39
- "title": "Platform",
40
- "links": [
41
- { "id": "ftr-platform-idv", "action": "nav-identity-verification", "label": "Identity Verification", "href": "/#platform" },
42
- { "id": "ftr-platform-age", "action": "nav-age-assurance", "label": "Age Assurance", "href": "/#platform" },
43
- { "id": "ftr-platform-fraud", "action": "nav-fraud-prevention", "label": "Fraud Prevention", "href": "/#platform" },
44
- { "id": "ftr-platform-evidence", "action": "nav-compliance-evidence", "label": "Compliance Evidence", "href": "/#platform" },
45
- { "id": "ftr-platform-aml", "action": "nav-aml-pact-act-tax", "label": "AML · PACT Act · Tax", "href": "/#platform" }
46
- ]
47
- },
48
- {
49
- "title": "Industries",
50
- "links": [
51
- { "id": "ftr-industries-alcohol", "action": "nav-alcohol", "label": "Alcohol", "href": "/#industries" },
52
- { "id": "ftr-industries-vape", "action": "nav-tobacco-and-vape", "label": "Tobacco & Vape", "href": "/#industries" },
53
- { "id": "ftr-industries-age-restricted", "action": "nav-age-restricted-goods", "label": "Age-Restricted Goods", "href": "/#industries" },
54
- { "id": "ftr-industries-marketplaces", "action": "nav-marketplaces", "label": "Marketplaces", "href": "/#industries" }
55
- ]
56
- },
57
- {
58
- "title": "Company",
59
- "links": [
60
- { "id": "ftr-company-pricing", "action": "nav-pricing", "label": "Pricing", "href": "https://tokenoftrust.com/pricing/", "external": true },
61
- { "id": "ftr-company-contact", "action": "nav-contact-sales", "label": "Contact Sales", "href": "https://tokenoftrust.com/contact/", "external": true },
62
- { "id": "ftr-company-resources", "action": "nav-resources", "label": "Resources", "href": "https://help.tokenoftrust.com", "external": true },
63
- { "id": "ftr-company-login", "action": "nav-login", "label": "Login", "href": "https://app.tokenoftrust.com", "external": true }
64
- ]
65
- },
66
- {
67
- "title": "Legal",
68
- "links": [
69
- { "id": "ftr-legal-privacy", "action": "nav-privacy-policy", "label": "Privacy Policy", "href": "https://tokenoftrust.com/privacy/", "external": true },
70
- { "id": "ftr-legal-terms", "action": "nav-terms", "label": "Terms", "href": "https://tokenoftrust.com/terms/", "external": true }
71
- ]
72
- }
73
- ],
74
- "social": [],
75
- "bottom": {
76
- "note": "GDPR · CCPA · PIPEDA compliant. 256-bit SSL. We will never sell your data."
77
- }
78
- }
79
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * Structured content contracts — ONE import surface for the
3
- * data-driven framework widgets, so tenant content (JSON) and the .astro
4
- * components share a single typed vocabulary and a tenant never copies HTML/CSS.
5
- *
6
- * New contracts: rich text, callouts, needs-review, prose/policy sections,
7
- * trust strip. Re-exported here alongside the tier/comparison contracts already
8
- * defined in lib/membership/model, so a membership page and a policy page
9
- * import from the same place. (The <BrandGrid> `Brand` contract lives with its
10
- * component in components/catalog/storefront/commerce/BrandGrid.astro.)
11
- */
12
- export * from "./richtext.js";
13
- export * from "./callout.js";
14
- export * from "./needsReview.js";
15
- export * from "./prose.js";
16
- export * from "./trustStrip.js";
17
-
18
- // Reused tier contracts — surfaced here so all structured widgets share
19
- // one contract entry point.
20
- export type {
21
- Tier,
22
- TierFigure,
23
- TierFeature,
24
- TierCta,
25
- ComparisonRow,
26
- } from "@/lib/membership/model";
27
- export { isIllustrative } from "@/lib/membership/model";
@@ -1,35 +0,0 @@
1
- // Estimated reading time for a post's rendered HTML (B1.5). Pure + Node-free
2
- // (parse5 is Workers-safe), so it's unit-testable and usable on any render path.
3
- import { parseFragment } from "parse5";
4
-
5
- /** Minimal structural view of a parse5 node (duck-typed, as scripts/dev/locate.mjs does). */
6
- interface P5Node {
7
- nodeName: string;
8
- tagName?: string;
9
- value?: string;
10
- childNodes?: P5Node[];
11
- }
12
-
13
- const WORDS_PER_MINUTE = 225;
14
-
15
- function collectText(node: P5Node, out: string[]): void {
16
- if (node.nodeName === "#text") {
17
- if (node.value) out.push(node.value);
18
- return;
19
- }
20
- // Non-visible/text-irrelevant subtrees never count toward reading time.
21
- if (node.tagName === "script" || node.tagName === "style") return;
22
- for (const child of node.childNodes ?? []) collectText(child, out);
23
- }
24
-
25
- /**
26
- * Reading time in whole minutes: visible word count / 225 wpm, rounded up, min 1.
27
- * Ignores markup, script, and style content.
28
- */
29
- export function readingTime(html: string): number {
30
- const frag = parseFragment(html ?? "") as unknown as P5Node;
31
- const parts: string[] = [];
32
- collectText(frag, parts);
33
- const words = parts.join(" ").trim().split(/\s+/).filter(Boolean);
34
- return Math.max(1, Math.ceil(words.length / WORDS_PER_MINUTE));
35
- }
@@ -1,95 +0,0 @@
1
- // Table of contents for a post's rendered HTML (B1.5): parse h2/h3 headings and
2
- // derive stable anchor ids. Pure + Node-free (parse5 is Workers-safe).
3
- //
4
- // `toc()` and `htmlWithHeadingIds()` derive ids from the SAME deterministic pass
5
- // (`annotate`), so a render path can feed `htmlWithHeadingIds(post.contentHtml)`
6
- // to `set:html` and `toc(post.contentHtml)` to the aside and the anchors line up.
7
- import { parseFragment, serialize } from "parse5";
8
- import { slugifyHeading } from "../prose.js";
9
-
10
- /** Minimal structural view of a parse5 node (duck-typed, as scripts/dev/locate.mjs does). */
11
- interface P5Node {
12
- nodeName: string;
13
- tagName?: string;
14
- value?: string;
15
- attrs?: { name: string; value: string }[];
16
- childNodes?: P5Node[];
17
- }
18
-
19
- export interface TocEntry {
20
- id: string;
21
- text: string;
22
- level: 2 | 3;
23
- }
24
-
25
- function textOf(node: P5Node): string {
26
- if (node.nodeName === "#text") return node.value ?? "";
27
- return (node.childNodes ?? []).map(textOf).join("");
28
- }
29
-
30
- function getId(node: P5Node): string | undefined {
31
- return node.attrs?.find((a) => a.name === "id")?.value?.trim() || undefined;
32
- }
33
-
34
- function* headings(node: P5Node): Generator<P5Node> {
35
- for (const child of node.childNodes ?? []) {
36
- if (child.tagName === "h2" || child.tagName === "h3") yield child;
37
- yield* headings(child);
38
- }
39
- }
40
-
41
- interface AnnotatedHeading {
42
- node: P5Node;
43
- id: string;
44
- text: string;
45
- level: 2 | 3;
46
- }
47
-
48
- /**
49
- * Walk headings in document order, assigning each a unique anchor id: an
50
- * author-supplied `id` is kept as-is; otherwise the slugified text, de-duped
51
- * with a numeric suffix on collision. Empty headings are skipped.
52
- */
53
- function* annotate(root: P5Node): Generator<AnnotatedHeading> {
54
- const seen = new Map<string, number>();
55
- for (const node of headings(root)) {
56
- const text = textOf(node).replace(/\s+/g, " ").trim();
57
- if (!text) continue;
58
- const level: 2 | 3 = node.tagName === "h2" ? 2 : 3;
59
- const explicit = getId(node);
60
- let id: string;
61
- if (explicit) {
62
- id = explicit;
63
- seen.set(id, (seen.get(id) ?? 0) + 1);
64
- } else {
65
- const base = slugifyHeading(text) || "section";
66
- const n = seen.get(base) ?? 0;
67
- seen.set(base, n + 1);
68
- id = n === 0 ? base : `${base}-${n + 1}`;
69
- }
70
- yield { node, id, text, level };
71
- }
72
- }
73
-
74
- /** TOC entries (one per h2/h3) with stable anchor ids, in document order. */
75
- export function toc(html: string): TocEntry[] {
76
- const frag = parseFragment(html ?? "") as unknown as P5Node;
77
- return [...annotate(frag)].map(({ id, text, level }) => ({ id, text, level }));
78
- }
79
-
80
- /**
81
- * The same HTML with anchor ids added to any h2/h3 that lacks one (author ids
82
- * untouched). Returns the input unchanged when every heading already has an id,
83
- * so posts without generated anchors are byte-for-byte preserved.
84
- */
85
- export function htmlWithHeadingIds(html: string): string {
86
- const frag = parseFragment(html ?? "") as unknown as P5Node;
87
- let changed = false;
88
- for (const { node, id } of annotate(frag)) {
89
- if (!getId(node)) {
90
- node.attrs = [...(node.attrs ?? []), { name: "id", value: id }];
91
- changed = true;
92
- }
93
- }
94
- return changed ? serialize(frag as never) : (html ?? "");
95
- }
@@ -1,56 +0,0 @@
1
- /**
2
- * Customers view model (baseline §Customers) — directory + detail, and the
3
- * `Valuable But Blocked` first-class reach-out/unblock queue.
4
- */
5
-
6
- export type VerificationState = "verified" | "pending" | "blocked" | "not_required";
7
-
8
- export type CustomerSegment = "new" | "returning" | "vip";
9
-
10
- export interface CustomerRow {
11
- id: string;
12
- name: string;
13
- email: string;
14
- orderCount: number;
15
- lifetimeValue: number;
16
- lastOrderAt: string | null;
17
- segment: CustomerSegment;
18
- supportFlags: string[];
19
- verificationState: VerificationState;
20
- }
21
-
22
- export type BlockedReason = "verification" | "destination" | "address" | "support";
23
-
24
- export interface CustomerBlockedQueueRow {
25
- customerId: string;
26
- name: string;
27
- recoverableValue: number;
28
- blocker: BlockedReason;
29
- blockerDetail: string;
30
- action: string;
31
- }
32
-
33
- export interface CustomerOrderRef {
34
- orderId: string;
35
- placedAt: string;
36
- total: number;
37
- }
38
-
39
- export interface CustomerActivityEvent {
40
- title: string;
41
- detail: string;
42
- at: string;
43
- }
44
-
45
- export interface CustomerDetail extends CustomerRow {
46
- orders: CustomerOrderRef[];
47
- activity: CustomerActivityEvent[];
48
- notes: string[];
49
- }
50
-
51
- export interface CustomersViewModel {
52
- targetTenant: string;
53
- directory: CustomerRow[];
54
- detailsById: Record<string, CustomerDetail>;
55
- valuableButBlocked: CustomerBlockedQueueRow[];
56
- }
@@ -1,28 +0,0 @@
1
- /**
2
- * Blind indexes for exact-match contact search: base64url HMAC-SHA256 of a normalized value under
3
- * the tenant's blind-index data key, so equal values match within one tenant and stage and never
4
- * across tenants. Normalization is part of the index contract: changing it orphans every stored
5
- * index.
6
- */
7
-
8
- /** Trim, NFKC, lowercase. Null when nothing remains. */
9
- export function normalizeEmail(value: string): string | null {
10
- const normalized = value.trim().normalize("NFKC").toLowerCase();
11
- return normalized === "" ? null : normalized;
12
- }
13
-
14
- /** NFKC, then a leading '+' (if the trimmed value starts with one) and ASCII digits only. Null when no digit remains. */
15
- export function normalizePhone(value: string): string | null {
16
- const folded = value.normalize("NFKC").trim();
17
- const digits = folded.replace(/[^0-9]/g, "");
18
- if (digits === "") return null;
19
- return folded.startsWith("+") ? `+${digits}` : digits;
20
- }
21
-
22
- /** base64url (no padding) HMAC-SHA256 of an already-normalized value. */
23
- export async function blindIndex(hmacKey: CryptoKey, normalized: string): Promise<string> {
24
- const mac = new Uint8Array(await crypto.subtle.sign("HMAC", hmacKey, new TextEncoder().encode(normalized) as BufferSource));
25
- let binary = "";
26
- for (const byte of mac) binary += String.fromCharCode(byte);
27
- return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
28
- }
@@ -1,149 +0,0 @@
1
- /**
2
- * The contact access audit (`contact_access_audit`, append-only): every read, list and erase of
3
- * sealed customer contact writes its row BEFORE anything is decrypted. Staff rows carry the
4
- * 30-per-hour quota in the same statement, so concurrent reads can never pass it together.
5
- * Rows hold opaque ids, codes and times only — never a contact field or a searched value. A list
6
- * or search row names the record ids it returned (comma-joined in record_id, at most
7
- * {@link AUDIT_RECORD_IDS_MAX}) and their count; an erase row names the field groups it cleared.
8
- */
9
-
10
- export type VaultStage = "preview" | "publication";
11
-
12
- export const STAFF_READS_PER_HOUR = 30;
13
- /** The most ids one list or search audit row names; every list and search is capped at or below it. */
14
- export const AUDIT_RECORD_IDS_MAX = 200;
15
-
16
- /** A list or search row's record_id: the returned ids comma-joined, or null when it returned none. */
17
- export function auditRecordIds(ids: readonly string[]): string | null {
18
- if (ids.length > AUDIT_RECORD_IDS_MAX) throw new Error("contact audit: too many record ids");
19
- return ids.length === 0 ? null : ids.join(",");
20
- }
21
- /** The quota window. A row counts while its `at` is strictly after `now - HOUR_MS`: one exactly an hour old no longer counts. */
22
- export const HOUR_MS = 3_600_000;
23
-
24
- export interface ContactActor {
25
- actorId: string;
26
- role: "owner" | "staff";
27
- reasonCode?: string;
28
- ticketRef?: string;
29
- }
30
-
31
- export interface AuditStatement {
32
- sql: string;
33
- params: readonly unknown[];
34
- }
35
-
36
- /** The SQL surface the audit needs; D1's `fromD1` and the sqlite test harness both satisfy it. */
37
- export interface AuditDb {
38
- all<T = Record<string, unknown>>(sql: string, ...params: unknown[]): Promise<T[]>;
39
- }
40
-
41
- /**
42
- * The audit insert. RETURNING tells admitted from refused (quota, or `requireRow` absent); an
43
- * error means the audit could not be written.
44
- */
45
- export function auditStatement(input: {
46
- auditId: string;
47
- tenantId: string;
48
- stage: VaultStage;
49
- recordKind: "order-contact" | "contact-message";
50
- recordId: string | null;
51
- recordCount?: number;
52
- groups?: readonly string[];
53
- actor: ContactActor;
54
- action: "read" | "list" | "erase" | "search";
55
- now: Date;
56
- requireRow?: AuditStatement;
57
- }): AuditStatement {
58
- const { auditId, tenantId, stage, recordKind, recordId, actor, action, now } = input;
59
- const recordCount = input.recordCount ?? null;
60
- const groups = input.groups && input.groups.length > 0 ? [...input.groups].sort().join(",") : null;
61
- const hourAgo = new Date(now.getTime() - HOUR_MS).toISOString();
62
- const params: unknown[] = [
63
- auditId, tenantId, stage, recordKind, recordId, recordCount, now.toISOString(), actor.actorId, actor.role,
64
- actor.role === "staff" ? actor.reasonCode ?? null : null,
65
- actor.role === "staff" ? actor.ticketRef ?? null : null,
66
- action, groups,
67
- actor.role, tenantId, actor.actorId, hourAgo, STAFF_READS_PER_HOUR,
68
- ];
69
- const requireRow = input.requireRow ? ` AND EXISTS (${input.requireRow.sql})` : "";
70
- if (input.requireRow) params.push(...input.requireRow.params);
71
- return {
72
- sql: `INSERT INTO contact_access_audit
73
- (audit_id, tenant_id, stage, record_kind, record_id, record_count, at, actor_id, actor_role, reason_code, ticket_ref, action, groups, outcome)
74
- SELECT ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'admitted'
75
- WHERE (? = 'owner' OR (SELECT COUNT(*) FROM contact_access_audit
76
- WHERE tenant_id = ? AND actor_id = ? AND actor_role = 'staff' AND at > ?) < ?)${requireRow}
77
- RETURNING audit_id`,
78
- params,
79
- };
80
- }
81
-
82
- /** Run the audit insert alone: "admitted", "quota" (no row inserted) or "unavailable" (error). */
83
- export async function admitAudit(db: AuditDb, statement: AuditStatement): Promise<"admitted" | "quota" | "unavailable"> {
84
- try {
85
- const rows = await db.all(statement.sql, ...statement.params);
86
- return rows.length === 1 ? "admitted" : "quota";
87
- } catch {
88
- return "unavailable";
89
- }
90
- }
91
-
92
- /** Admitted app recipient reads per install and tenant per hour. */
93
- export const APP_CONTACT_READS_PER_HOUR = 300;
94
- export const APP_CONTACT_PURPOSE = "fulfillment-shipping";
95
-
96
- /**
97
- * The app-access audit insert (`app_contact_access_audit`): the recipient read's admission and its
98
- * only write. It inserts one row only when, at that instant, the install is active on the tenant
99
- * holding `scope`, the assignment is the install's active assignment of the order, the order still
100
- * stands at `eventVersion` (the version its releasability was computed at), a live consent covers
101
- * (install, tenant, stage, purpose), and the install has fewer than
102
- * {@link APP_CONTACT_READS_PER_HOUR} admitted rows on the tenant in the last hour.
103
- */
104
- export function appAuditStatement(input: {
105
- auditId: string;
106
- installId: string;
107
- tenantId: string;
108
- stage: VaultStage;
109
- orderId: string;
110
- assignmentId: string;
111
- eventVersion: number;
112
- scope: string;
113
- now: Date;
114
- }): AuditStatement {
115
- const { auditId, installId, tenantId, stage, orderId, assignmentId, eventVersion, scope, now } = input;
116
- const at = now.toISOString();
117
- const hourAgo = new Date(now.getTime() - HOUR_MS).toISOString();
118
- return {
119
- sql: `INSERT INTO app_contact_access_audit (audit_id, install_id, tenant_id, stage, order_id, purpose, at, outcome)
120
- SELECT ?, ?, ?, ?, ?, '${APP_CONTACT_PURPOSE}', ?, 'admitted'
121
- WHERE EXISTS (SELECT 1 FROM app_installs AS ai
122
- WHERE ai.install_id = ? AND ai.tenant_id = ? AND ai.status = 'active'
123
- AND EXISTS (SELECT 1 FROM json_each(ai.scopes) WHERE json_each.value = ?))
124
- AND EXISTS (SELECT 1 FROM fulfillment_assignments AS fa
125
- WHERE fa.assignment_id = ? AND fa.tenant_id = ? AND fa.stage = ? AND fa.order_id = ?
126
- AND fa.install_id = ? AND fa.state = 'active')
127
- AND EXISTS (SELECT 1 FROM scrappy_commerce_orders AS o
128
- WHERE o.tenant_id = ? AND o.stage = ? AND o.order_id = ? AND o.event_version = ?)
129
- AND EXISTS (SELECT 1 FROM app_contact_consents AS c
130
- WHERE c.install_id = ? AND c.tenant_id = ? AND c.stage = ? AND c.purpose = '${APP_CONTACT_PURPOSE}'
131
- AND c.revoked_at IS NULL AND c.expires_at > ?)
132
- AND (SELECT COUNT(*) FROM app_contact_access_audit AS q
133
- WHERE q.install_id = ? AND q.tenant_id = ? AND q.at > ?) < ?
134
- RETURNING audit_id`,
135
- params: [
136
- auditId, installId, tenantId, stage, orderId, at,
137
- installId, tenantId, scope,
138
- assignmentId, tenantId, stage, orderId, installId,
139
- tenantId, stage, orderId, eventVersion,
140
- installId, tenantId, stage, at,
141
- installId, tenantId, hourAgo, APP_CONTACT_READS_PER_HOUR,
142
- ],
143
- };
144
- }
145
-
146
- /** The same insert without RETURNING, for use inside a batch whose later statements check the row. */
147
- export function batchAuditStatement(statement: AuditStatement): AuditStatement {
148
- return { sql: statement.sql.replace(/\s*RETURNING audit_id$/, ""), params: statement.params };
149
- }