@tokenoftrust/storefront-runner 7.3.2 → 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 (415) 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 +32 -8
  13. package/apps/storefront/src/lib/access/auth/brokerAssertion.ts +16 -2
  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/dashboard/staffAdmission.ts +5 -0
  17. package/apps/storefront/src/lib/access/dashboard/tenantSelection.ts +2 -0
  18. package/apps/storefront/src/lib/access/shared/capability.ts +14 -6
  19. package/apps/storefront/src/lib/access/shared/generated/capabilityCatalog.generated.ts +161 -0
  20. package/apps/storefront/src/lib/activity/activityScope.ts +36 -0
  21. package/apps/storefront/src/lib/activity/recordActivity.ts +23 -1
  22. package/apps/storefront/src/lib/activity/serverFanOut.ts +31 -0
  23. package/apps/storefront/src/lib/activity/store.ts +9 -3
  24. package/apps/storefront/src/lib/checkout/commerce/cardCartForm.ts +2 -0
  25. package/apps/storefront/src/lib/checkout/commerce/cartSession.ts +109 -12
  26. package/apps/storefront/src/lib/checkout/commerce/checkoutHandoffRoute.ts +53 -25
  27. package/apps/storefront/src/lib/checkout/commerce/finalCartAuthorization.ts +48 -6
  28. package/apps/storefront/src/lib/checkout/proposal/cartProposal.ts +388 -0
  29. package/apps/storefront/src/lib/checkout/proposal/listMatcher.ts +149 -0
  30. package/apps/storefront/src/lib/checkout/proposal/proposalRoutes.ts +447 -0
  31. package/apps/storefront/src/lib/checkout/proposal/reviewHtml.ts +100 -0
  32. package/apps/storefront/src/lib/compliance/browser/checkoutVerificationFlow.ts +26 -2
  33. package/apps/storefront/src/lib/content/shared/redirects.ts +21 -4
  34. package/apps/storefront/src/lib/publication/shared/edgeCache.ts +5 -2
  35. package/apps/storefront/src/lib/publication/shared/previewAnnotations/renderDecorator.ts +15 -8
  36. package/apps/storefront/src/lib/publication/shared/runtimeEnv.ts +1 -1
  37. package/apps/storefront/src/middleware/controlPlane.ts +15 -1
  38. package/apps/storefront/src/middleware/index.ts +7 -3
  39. package/apps/storefront/src/middleware/renderChain.ts +46 -33
  40. package/apps/storefront/src/pages/api/cart-proposal/confirm.ts +12 -0
  41. package/apps/storefront/src/pages/api/cart-proposal/review.ts +26 -0
  42. package/apps/storefront/src/pages/api/commerce/final-cart-authorization.ts +29 -6
  43. package/apps/storefront/src/pages/api/compliance/preflight.ts +25 -1
  44. package/apps/storefront/src/pages/products/[handle].astro +2 -15
  45. package/apps/storefront/tsconfig.astro.json +11 -0
  46. package/package.json +1 -1
  47. package/packages/public-runtime/src/activity/README.md +12 -0
  48. package/packages/public-runtime/src/activity/catalog.ts +7 -0
  49. package/packages/public-runtime/src/activity/event.ts +19 -0
  50. package/packages/public-runtime/src/activity/redaction.ts +31 -2
  51. package/packages/public-runtime/src/catalog-files.ts +3 -2
  52. package/packages/public-runtime/src/checkout-orders.ts +18 -19
  53. package/packages/public-runtime/src/checkout.ts +70 -0
  54. package/packages/public-runtime/src/compliance/evaluate.ts +60 -1
  55. package/packages/public-runtime/src/compliance/index.ts +1 -1
  56. package/packages/public-runtime/src/compliance/pact-report.ts +184 -3
  57. package/packages/public-runtime/src/compliance/profile.ts +268 -20
  58. package/packages/public-runtime/src/compliance/ruleset.ts +42 -0
  59. package/packages/public-runtime/src/customization-runtime.ts +1 -1
  60. package/packages/public-runtime/src/product.ts +9 -1
  61. package/packages/public-runtime/src/publication-content-redirects.ts +16 -3
  62. package/packages/public-runtime/tests/fixtures/compliance-decisions.golden.json +252 -52
  63. package/pnpm-lock.runner.yaml +0 -15
  64. package/scripts/tenant/materialize-tenant-content.mjs +3 -0
  65. package/scripts/tenant/validate.mjs +128 -0
  66. package/apps/storefront/dev-plugins/dev-publish.mjs +0 -55
  67. package/apps/storefront/drizzle.config.apps.ts +0 -13
  68. package/apps/storefront/integrations/preview-annotations-client-bundle.mjs +0 -80
  69. package/apps/storefront/migrations-apps/0000_fast_millenium_guard.sql +0 -129
  70. package/apps/storefront/migrations-apps/0001_woozy_lyja.sql +0 -22
  71. package/apps/storefront/migrations-apps/0002_good_switch.sql +0 -26
  72. package/apps/storefront/migrations-apps/0003_mute_marauders.sql +0 -12
  73. package/apps/storefront/migrations-apps/0004_deep_morph.sql +0 -36
  74. package/apps/storefront/migrations-apps/0005_common_mystique.sql +0 -23
  75. package/apps/storefront/migrations-apps/0006_broad_microchip.sql +0 -16
  76. package/apps/storefront/migrations-apps/0007_brave_outlaw_kid.sql +0 -15
  77. package/apps/storefront/migrations-apps/0008_blue_dazzler.sql +0 -11
  78. package/apps/storefront/migrations-apps/0009_bored_shinobi_shaw.sql +0 -15
  79. package/apps/storefront/migrations-apps/0010_ws4_verified_provider_measurement.sql +0 -35
  80. package/apps/storefront/migrations-apps/0011_dt_tracking_tenant_databases.sql +0 -23
  81. package/apps/storefront/migrations-apps/0012_test_destinations.sql +0 -29
  82. package/apps/storefront/migrations-apps/0013_publication_space_editorial.sql +0 -64
  83. package/apps/storefront/migrations-apps/0014_retire_candidate_ledger.sql +0 -12
  84. package/apps/storefront/migrations-apps/0015_merchant_calculation_settings.sql +0 -31
  85. package/apps/storefront/migrations-apps/0016_scrappy_commerce_contract.sql +0 -166
  86. package/apps/storefront/migrations-apps/0017_commerce_durable_projection.sql +0 -28
  87. package/apps/storefront/migrations-apps/0018_commerce_provider_cart_identity.sql +0 -13
  88. package/apps/storefront/migrations-apps/0019_commerce_source_authority.sql +0 -23
  89. package/apps/storefront/migrations-apps/0020_contact_messages.sql +0 -18
  90. package/apps/storefront/migrations-apps/0021_contact_vault.sql +0 -166
  91. package/apps/storefront/migrations-apps/0022_contact_vault_fields.sql +0 -342
  92. package/apps/storefront/migrations-apps/0023_principal_grant_contacts.sql +0 -15
  93. package/apps/storefront/migrations-apps/0024_order_contact_erasure_state.sql +0 -22
  94. package/apps/storefront/migrations-apps/0025_shipment_audit_order_lookup.sql +0 -2
  95. package/apps/storefront/migrations-apps/0026_fulfillment_assignment.sql +0 -44
  96. package/apps/storefront/migrations-apps/0027_app_contact_authority.sql +0 -70
  97. package/apps/storefront/migrations-apps/0028_app_jwk_and_candidates.sql +0 -133
  98. package/apps/storefront/migrations-apps/0029_inventory_locations_wms.sql +0 -38
  99. package/apps/storefront/migrations-apps/0030_assignment_split_shipments.sql +0 -149
  100. package/apps/storefront/migrations-apps/meta/0000_snapshot.json +0 -843
  101. package/apps/storefront/migrations-apps/meta/0001_snapshot.json +0 -990
  102. package/apps/storefront/migrations-apps/meta/0002_snapshot.json +0 -1160
  103. package/apps/storefront/migrations-apps/meta/0003_snapshot.json +0 -1235
  104. package/apps/storefront/migrations-apps/meta/0004_snapshot.json +0 -1474
  105. package/apps/storefront/migrations-apps/meta/0005_snapshot.json +0 -1617
  106. package/apps/storefront/migrations-apps/meta/0006_snapshot.json +0 -1716
  107. package/apps/storefront/migrations-apps/meta/0007_snapshot.json +0 -1812
  108. package/apps/storefront/migrations-apps/meta/0008_snapshot.json +0 -1881
  109. package/apps/storefront/migrations-apps/meta/0009_snapshot.json +0 -1979
  110. package/apps/storefront/migrations-apps/meta/_journal.json +0 -76
  111. package/apps/storefront/perf/README.md +0 -64
  112. package/apps/storefront/perf/assert-budgets.ts +0 -159
  113. package/apps/storefront/platform-reconcile-tenants.json +0 -3
  114. package/apps/storefront/playwright.config.ts +0 -23
  115. package/apps/storefront/public/js/dashboard-access-banner.js +0 -53
  116. package/apps/storefront/public/js/dashboard-apps.js +0 -183
  117. package/apps/storefront/public/js/dashboard-contact-capture.js +0 -52
  118. package/apps/storefront/public/js/dashboard-delegate.js +0 -167
  119. package/apps/storefront/public/js/dashboard-team.js +0 -356
  120. package/apps/storefront/public/js/dashboard-vendor-search.js +0 -115
  121. package/apps/storefront/src/components/content/storefront/AsyncStylesheet.astro +0 -26
  122. package/apps/storefront/src/components/integrations/storefront/WidgetFrame.astro +0 -34
  123. package/apps/storefront/src/config/adminTenantLookup.ts +0 -35
  124. package/apps/storefront/src/config/evidenceTenantRoster.ts +0 -25
  125. package/apps/storefront/src/config/staffProvisionProjection.ts +0 -24
  126. package/apps/storefront/src/config/storeName.ts +0 -34
  127. package/apps/storefront/src/lib/access/admin/README.md +0 -122
  128. package/apps/storefront/src/lib/access/admin/adminShell.ts +0 -281
  129. package/apps/storefront/src/lib/access/admin/envelope.ts +0 -9
  130. package/apps/storefront/src/lib/access/admin/viewmodels/settings.ts +0 -64
  131. package/apps/storefront/src/lib/access/auth/adminApiGuard.ts +0 -66
  132. package/apps/storefront/src/lib/access/auth/adminEntry.ts +0 -126
  133. package/apps/storefront/src/lib/access/auth/mcpClientAssertion.ts +0 -217
  134. package/apps/storefront/src/lib/access/auth/operatorSession.ts +0 -120
  135. package/apps/storefront/src/lib/access/dashboard/agentStoreEntry.ts +0 -253
  136. package/apps/storefront/src/lib/access/dashboard/delegateGate.ts +0 -130
  137. package/apps/storefront/src/lib/access/dashboard/staffStoreEntry.ts +0 -153
  138. package/apps/storefront/src/lib/access/dashboard/staffVendorAccess.ts +0 -474
  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/agentGrantAttestation.ts +0 -74
  209. package/apps/storefront/src/lib/developer-experience/dev/ai-widget-client.js +0 -308
  210. package/apps/storefront/src/lib/developer-experience/dev/apiBase.ts +0 -17
  211. package/apps/storefront/src/lib/developer-experience/dev/cliSignInCode.ts +0 -124
  212. package/apps/storefront/src/lib/developer-experience/dev/cockpit/ask.ts +0 -49
  213. package/apps/storefront/src/lib/developer-experience/dev/cockpit/clickToSource.ts +0 -71
  214. package/apps/storefront/src/lib/developer-experience/dev/cockpit/copyCommand.ts +0 -227
  215. package/apps/storefront/src/lib/developer-experience/dev/cockpit/files.ts +0 -249
  216. package/apps/storefront/src/lib/developer-experience/dev/cockpit/hostedActivity.ts +0 -500
  217. package/apps/storefront/src/lib/developer-experience/dev/cockpit/infoPopover.ts +0 -12
  218. package/apps/storefront/src/lib/developer-experience/dev/cockpit/mcpCopy.ts +0 -34
  219. package/apps/storefront/src/lib/developer-experience/dev/cockpit/monitor.ts +0 -107
  220. package/apps/storefront/src/lib/developer-experience/dev/cockpit/stepper.ts +0 -116
  221. package/apps/storefront/src/lib/developer-experience/dev/cockpit/themeToggle.ts +0 -23
  222. package/apps/storefront/src/lib/developer-experience/dev/livePreview.ts +0 -77
  223. package/apps/storefront/src/lib/developer-experience/dev/obstacleStore.ts +0 -214
  224. package/apps/storefront/src/lib/developer-experience/dev/previewStatus.ts +0 -87
  225. package/apps/storefront/src/lib/developer-experience/dev/rendezvousBroker.ts +0 -226
  226. package/apps/storefront/src/lib/developer-experience/dev/runtimeStore.ts +0 -291
  227. package/apps/storefront/src/lib/developer-experience/dev/storeStatus.ts +0 -142
  228. package/apps/storefront/src/lib/developer-experience/dev/subjectReissue.ts +0 -67
  229. package/apps/storefront/src/lib/developer-experience/fixtures/regulated-commerce-truth/index.ts +0 -540
  230. package/apps/storefront/src/lib/developer-experience/fixtures/ws3-readonly-clone-preflight/index.ts +0 -495
  231. package/apps/storefront/src/lib/engagement/contact/contactMessages.ts +0 -671
  232. package/apps/storefront/src/lib/engagement/contact/messagesTabClient.ts +0 -175
  233. package/apps/storefront/src/lib/engagement/contact/submission.ts +0 -112
  234. package/apps/storefront/src/lib/engagement/messaging/messagesClient.ts +0 -149
  235. package/apps/storefront/src/lib/engagement/newsletter/digest.ts +0 -117
  236. package/apps/storefront/src/lib/engagement/newsletter/resendClient.ts +0 -79
  237. package/apps/storefront/src/lib/engagement/newsletter/send.ts +0 -265
  238. package/apps/storefront/src/lib/engagement/social/golive.ts +0 -212
  239. package/apps/storefront/src/lib/engagement/social/notify.ts +0 -32
  240. package/apps/storefront/src/lib/engagement/social/tokenStore.ts +0 -171
  241. package/apps/storefront/src/lib/fulfillment/admin/commerceDesk.ts +0 -180
  242. package/apps/storefront/src/lib/fulfillment/admin/commerceDeskRouting.ts +0 -45
  243. package/apps/storefront/src/lib/fulfillment/admin/viewmodels/fulfillment.ts +0 -1071
  244. package/apps/storefront/src/lib/fulfillment/appShipmentEvidence.ts +0 -271
  245. package/apps/storefront/src/lib/fulfillment/carrierEvidence.ts +0 -105
  246. package/apps/storefront/src/lib/fulfillment/commerceProjection.ts +0 -157
  247. package/apps/storefront/src/lib/fulfillment/commerceReadback.ts +0 -60
  248. package/apps/storefront/src/lib/fulfillment/commerceRecovery.ts +0 -84
  249. package/apps/storefront/src/lib/fulfillment/commerceRuntime.ts +0 -41
  250. package/apps/storefront/src/lib/fulfillment/fulfillmentService.ts +0 -2842
  251. package/apps/storefront/src/lib/fulfillment/readiness.ts +0 -217
  252. package/apps/storefront/src/lib/fulfillment/splitShipments.ts +0 -388
  253. package/apps/storefront/src/lib/fulfillment/syntheticPreviewOrders.ts +0 -292
  254. package/apps/storefront/src/lib/integrations/apps/appContactAuthority.ts +0 -27
  255. package/apps/storefront/src/lib/integrations/apps/appContactConsents.ts +0 -118
  256. package/apps/storefront/src/lib/integrations/apps/appInstallEnv.ts +0 -28
  257. package/apps/storefront/src/lib/integrations/apps/gtmMigrationDraft.ts +0 -103
  258. package/apps/storefront/src/lib/integrations/apps/inventoryWrite.ts +0 -906
  259. package/apps/storefront/src/lib/integrations/apps/orders/customerHash.ts +0 -28
  260. package/apps/storefront/src/lib/integrations/apps/orders/idempotency.ts +0 -100
  261. package/apps/storefront/src/lib/integrations/apps/reports/salesVelocityReport.ts +0 -96
  262. package/apps/storefront/src/lib/integrations/apps/routeParams.ts +0 -45
  263. package/apps/storefront/src/lib/integrations/webhooks/cloudflareQueueDispatcher.ts +0 -82
  264. package/apps/storefront/src/lib/integrations/webhooks/commercePayloads.ts +0 -159
  265. package/apps/storefront/src/lib/integrations/webhooks/deliveryEngine.ts +0 -379
  266. package/apps/storefront/src/lib/integrations/webhooks/deliveryMapper.ts +0 -34
  267. package/apps/storefront/src/lib/integrations/webhooks/deliveryStore.ts +0 -903
  268. package/apps/storefront/src/lib/integrations/webhooks/dispatcher.ts +0 -168
  269. package/apps/storefront/src/lib/integrations/webhooks/emit.ts +0 -245
  270. package/apps/storefront/src/lib/integrations/webhooks/events.ts +0 -105
  271. package/apps/storefront/src/lib/integrations/webhooks/getDispatcher.ts +0 -77
  272. package/apps/storefront/src/lib/integrations/webhooks/orderFulfilledClaim.ts +0 -75
  273. package/apps/storefront/src/lib/measurement/admin/analyticsRegionPolicy.ts +0 -151
  274. package/apps/storefront/src/lib/measurement/admin/analyticsRegionsClient.ts +0 -84
  275. package/apps/storefront/src/lib/measurement/admin/consentSettingsClient.ts +0 -113
  276. package/apps/storefront/src/lib/measurement/analytics/index.ts +0 -44
  277. package/apps/storefront/src/lib/measurement/attribution/attributionService.ts +0 -206
  278. package/apps/storefront/src/lib/measurement/attribution/orderConversionD1.ts +0 -150
  279. package/apps/storefront/src/lib/measurement/attribution/verifiedProviderMeasurement.ts +0 -118
  280. package/apps/storefront/src/lib/measurement/tracking/interactionCollector.ts +0 -205
  281. package/apps/storefront/src/lib/measurement/tracking/pruneRollup.ts +0 -260
  282. package/apps/storefront/src/lib/measurement/tracking/tenantReadAccess.ts +0 -138
  283. package/apps/storefront/src/lib/measurement/tracking-writeback/rewriteTrackingIds.ts +0 -175
  284. package/apps/storefront/src/lib/measurement/tracking-writeback/writebackCandidate.ts +0 -110
  285. package/apps/storefront/src/lib/observability/diag/capture.ts +0 -162
  286. package/apps/storefront/src/lib/observability/diag/consoleLine.ts +0 -76
  287. package/apps/storefront/src/lib/observability/diag/debugConsole.ts +0 -118
  288. package/apps/storefront/src/lib/observability/diag/debugMode.ts +0 -163
  289. package/apps/storefront/src/lib/observability/diag/debugWindow.ts +0 -111
  290. package/apps/storefront/src/lib/observability/diag/redact.ts +0 -17
  291. package/apps/storefront/src/lib/observability/diag/reference.ts +0 -148
  292. package/apps/storefront/src/lib/observability/diag/referenceStore.ts +0 -113
  293. package/apps/storefront/src/lib/observability/diag/report.ts +0 -110
  294. package/apps/storefront/src/lib/observability/diag/serverResponseTime.ts +0 -91
  295. package/apps/storefront/src/lib/observability/diag/session.ts +0 -93
  296. package/apps/storefront/src/lib/observability/monitoring/manifest.ts +0 -301
  297. package/apps/storefront/src/lib/observability/performance/lighthouseReport.ts +0 -109
  298. package/apps/storefront/src/lib/observability/performance/rumAlert.ts +0 -179
  299. package/apps/storefront/src/lib/orders/admin/orderActions.ts +0 -556
  300. package/apps/storefront/src/lib/orders/admin/orderClient.ts +0 -248
  301. package/apps/storefront/src/lib/orders/admin/orderSource.ts +0 -410
  302. package/apps/storefront/src/lib/orders/admin/services/orders.ts +0 -922
  303. package/apps/storefront/src/lib/orders/admin/viewmodels/orders.ts +0 -135
  304. package/apps/storefront/src/lib/orders/data/commerceCallerConfig.ts +0 -37
  305. package/apps/storefront/src/lib/orders/data/ledgerContractOrders.ts +0 -148
  306. package/apps/storefront/src/lib/orders/data/orderForwardReceiver.ts +0 -532
  307. package/apps/storefront/src/lib/orders/data/orderMapper.ts +0 -454
  308. package/apps/storefront/src/lib/orders/data/ordersStore.ts +0 -623
  309. package/apps/storefront/src/lib/orders/data/sourceAuthorityContract.ts +0 -380
  310. package/apps/storefront/src/lib/orders/data/sourceAuthorityStore.ts +0 -830
  311. package/apps/storefront/src/lib/orders/fixtures/orders.ts +0 -186
  312. package/apps/storefront/src/lib/orders/providers/foxyOrderClient.ts +0 -207
  313. package/apps/storefront/src/lib/orders/vault/appRecipientRead.ts +0 -222
  314. package/apps/storefront/src/lib/orders/vault/contactIntake.ts +0 -63
  315. package/apps/storefront/src/lib/orders/vault/contactRoutes.ts +0 -110
  316. package/apps/storefront/src/lib/orders/vault/kmsEnv.ts +0 -11
  317. package/apps/storefront/src/lib/orders/vault/orderContact.ts +0 -96
  318. package/apps/storefront/src/lib/orders/vault/orderContactVault.ts +0 -1427
  319. package/apps/storefront/src/lib/orders/vault/vault-test-support.ts +0 -258
  320. package/apps/storefront/src/lib/publication/d1/schema-apps.ts +0 -808
  321. package/apps/storefront/src/lib/publication/notifications/candidateConflictEmail.ts +0 -80
  322. package/apps/storefront/src/lib/publication/servingMode.ts +0 -52
  323. package/apps/storefront/src/lib/publication/shared/previewAnnotations/moduleAsset.ts +0 -65
  324. package/apps/storefront/src/lib/publication/shared/routedApiParam.ts +0 -38
  325. package/apps/storefront/src/lib/reporting/admin/viewmodels/reporting.ts +0 -34
  326. package/apps/storefront/src/lib/reporting/fixtures/reporting.ts +0 -51
  327. package/apps/storefront/src/lib/subscriptions/admin/viewmodels/subscriptions.ts +0 -106
  328. package/apps/storefront/src/lib/subscriptions/fixtures/subscriptions.ts +0 -398
  329. package/apps/storefront/src/pages/api/admin/activity-alerts.ts +0 -58
  330. package/apps/storefront/src/pages/api/admin/commerce-readiness.ts +0 -172
  331. package/apps/storefront/src/pages/api/admin/fulfillment/batches.ts +0 -59
  332. package/apps/storefront/src/pages/api/admin/fulfillment/orders/[id]/address.ts +0 -66
  333. package/apps/storefront/src/pages/api/admin/fulfillment/orders/[id].ts +0 -118
  334. package/apps/storefront/src/pages/api/admin/fulfillment/orders/contact-search.ts +0 -26
  335. package/apps/storefront/src/pages/api/admin/fulfillment/orders/contacts.ts +0 -22
  336. package/apps/storefront/src/pages/api/admin/interaction-insights.ts +0 -101
  337. package/apps/storefront/src/pages/api/admin/orders/[id].ts +0 -63
  338. package/apps/storefront/src/pages/api/admin/orders.ts +0 -65
  339. package/apps/storefront/src/pages/api/contact.ts +0 -144
  340. package/apps/storefront/src/scheduled/contactVaultSweep.ts +0 -113
  341. package/apps/storefront/src/styles/admin.css +0 -1161
  342. package/apps/storefront/test/pipeline/fake-preview-services.ts +0 -288
  343. package/apps/storefront/test/pipeline/harness.ts +0 -209
  344. package/apps/storefront/test/pipeline/intake-worker.mjs +0 -14
  345. package/apps/storefront/test/pipeline/matrix-faults.ts +0 -366
  346. package/apps/storefront/test/pipeline/pipeline-host.ts +0 -418
  347. package/apps/storefront/test/pipeline/pool-config.cjs +0 -85
  348. package/apps/storefront/test/pipeline/publish-kinds.ts +0 -279
  349. package/apps/storefront/test/pipeline/synthetic-job.ts +0 -303
  350. package/apps/storefront/test/pipeline-faults/matrix-lib.ts +0 -696
  351. package/apps/storefront/vitest.config.cts +0 -44
  352. package/apps/storefront/vitest.faults.config.cts +0 -13
  353. package/apps/storefront/vitest.workers.config.cts +0 -7
  354. package/packages/feedback/fixtures/v1/expected-findings.json +0 -16
  355. package/packages/feedback/fixtures/v1/feedback-action/invalid/carries-transport-credential.json +0 -14
  356. package/packages/feedback/fixtures/v1/feedback-action/invalid/control-char-in-description.json +0 -13
  357. package/packages/feedback/fixtures/v1/feedback-action/invalid/legacy-schema-version.json +0 -13
  358. package/packages/feedback/fixtures/v1/feedback-action/invalid/page-path-with-query.json +0 -14
  359. package/packages/feedback/fixtures/v1/feedback-action/invalid/title-too-short.json +0 -13
  360. package/packages/feedback/fixtures/v1/feedback-action/valid/element-problem.json +0 -33
  361. package/packages/feedback/fixtures/v1/feedback-action/valid/page-comment.json +0 -20
  362. package/packages/feedback/fixtures/v1/feedback-action/valid/region-improvement.json +0 -24
  363. package/packages/feedback/fixtures/v1/feedback-action/valid/text-selection-feature.json +0 -30
  364. package/packages/feedback/fixtures/v1/submission-receipt/invalid/accepted-at-not-utc.json +0 -9
  365. package/packages/feedback/fixtures/v1/submission-receipt/invalid/bad-feedback-id.json +0 -9
  366. package/packages/feedback/fixtures/v1/submission-receipt/invalid/legacy-contract-version.json +0 -9
  367. package/packages/feedback/fixtures/v1/submission-receipt/invalid/missing-replayed.json +0 -8
  368. package/packages/feedback/fixtures/v1/submission-receipt/valid/accepted.json +0 -9
  369. package/packages/feedback/fixtures/v1/submission-receipt/valid/fractional-seconds.json +0 -9
  370. package/packages/feedback/fixtures/v1/submission-receipt/valid/replayed.json +0 -9
  371. package/packages/feedback/fixtures/v1/target-evidence/invalid/page-kind-claims-structure.json +0 -6
  372. package/packages/feedback/fixtures/v1/target-evidence/invalid/path-too-deep.json +0 -17
  373. package/packages/feedback/fixtures/v1/target-evidence/invalid/relative-region-out-of-range.json +0 -11
  374. package/packages/feedback/fixtures/v1/target-evidence/invalid/selector-uses-class.json +0 -7
  375. package/packages/feedback/fixtures/v1/target-evidence/invalid/source-precision-without-anchor.json +0 -6
  376. package/packages/feedback/fixtures/v1/target-evidence/valid/element-structure.json +0 -21
  377. package/packages/feedback/fixtures/v1/target-evidence/valid/host-iframe.json +0 -14
  378. package/packages/feedback/fixtures/v1/target-evidence/valid/source-anchor.json +0 -12
  379. package/packages/feedback/fixtures/v1/target-evidence/valid/text-selection.json +0 -26
  380. package/packages/feedback/package.json +0 -35
  381. package/packages/feedback/scripts/build-player.mjs +0 -28
  382. package/packages/feedback/src/index.ts +0 -1
  383. package/packages/feedback/src/primitives/composer.ts +0 -639
  384. package/packages/feedback/src/primitives/dialog.ts +0 -263
  385. package/packages/feedback/src/primitives/hostAdapter.ts +0 -116
  386. package/packages/feedback/src/primitives/index.ts +0 -10
  387. package/packages/feedback/src/primitives/launcher.ts +0 -200
  388. package/packages/feedback/src/primitives/picker.ts +0 -663
  389. package/packages/feedback/src/primitives/redaction.ts +0 -204
  390. package/packages/feedback/src/primitives/selection.ts +0 -49
  391. package/packages/feedback/src/primitives/shiftAccelerator.ts +0 -160
  392. package/packages/feedback/src/primitives/styles.ts +0 -77
  393. package/packages/feedback/src/primitives/surface.ts +0 -124
  394. package/packages/feedback/src/primitives/target.ts +0 -293
  395. package/packages/feedback/src/tour/canonical.ts +0 -27
  396. package/packages/feedback/src/tour/index.ts +0 -3
  397. package/packages/feedback/src/tour/player/browser.ts +0 -5
  398. package/packages/feedback/src/tour/player/host.ts +0 -12
  399. package/packages/feedback/src/tour/player/index.ts +0 -205
  400. package/packages/feedback/src/tour/player/manifest.ts +0 -76
  401. package/packages/feedback/src/tour/player/player.css +0 -130
  402. package/packages/feedback/src/tour/player/resolver.ts +0 -12
  403. package/packages/feedback/src/tour/player/surface.ts +0 -295
  404. package/packages/feedback/src/tour/player/types.ts +0 -8
  405. package/packages/feedback/src/tour/resolve/core.ts +0 -267
  406. package/packages/feedback/src/tour/resolve/dom.ts +0 -115
  407. package/packages/feedback/src/tour/resolve/index.ts +0 -29
  408. package/packages/feedback/src/tour/sanitize.ts +0 -76
  409. package/packages/feedback/src/tour/schema.ts +0 -362
  410. package/packages/feedback/src/v1/guards.ts +0 -335
  411. package/packages/feedback/src/v1/index.ts +0 -3
  412. package/packages/feedback/src/v1/protectedSurfaces.ts +0 -32
  413. package/packages/feedback/src/v1/types.ts +0 -177
  414. package/packages/feedback/tsconfig.json +0 -9
  415. package/packages/feedback/vitest.config.cts +0 -21
@@ -1,204 +0,0 @@
1
- /**
2
- * Local redaction of reviewer prose before it leaves the browser.
3
- *
4
- * This is the first of two passes: the host's intake runs its own canonical redactor
5
- * independently.
6
- *
7
- * Supported classes: email addresses, phone numbers in common formats, credentials (bearer/basic
8
- * tokens, JWTs, cookie/authorization header pastes, key=value secrets, provider key prefixes,
9
- * long opaque tokens), URLs, and markup. Arbitrary names, street addresses and free-form
10
- * identifiers are NOT reliably detectable by pattern; the composer shows the exact outgoing text so
11
- * the reviewer can remove them. `PII_LIMITATION_NOTICE` is the user-facing statement of that.
12
- */
13
-
14
- import type { RedactionCategory, RedactionCounts } from "../v1/types.js";
15
-
16
- export type { RedactionCategory, RedactionCounts };
17
-
18
- export const PII_LIMITATION_NOTICE =
19
- "Automatic filters remove email addresses, phone numbers, links, markup and secrets they " +
20
- "recognise. They cannot reliably find every name, address or other personal detail, so check " +
21
- "the text below before sending.";
22
-
23
- interface Rule {
24
- category: RedactionCategory;
25
- pattern: RegExp;
26
- replacement: string;
27
- /** Leave a match as written when this returns true (a shape that is prose, not a secret). */
28
- keep?(match: string): boolean;
29
- }
30
-
31
- /** A `/`-separated run with an ordinary word segment is a path the reviewer is naming. */
32
- const WORD_SEGMENT = /^[A-Z]?[a-z]{3,}$/;
33
- function isPathLike(match: string): boolean {
34
- return match.includes("/") && match.split("/").some((segment) => WORD_SEGMENT.test(segment));
35
- }
36
-
37
- /**
38
- * Longest input any rule ever sees. Every outgoing field is far shorter (the description is capped
39
- * at 4000), so this only bounds the work done on an oversized paste before it is refused.
40
- */
41
- export const REDACT_INPUT_MAX = 20_000;
42
-
43
- // Order matters: key blocks, header pastes and URLs first so their contents are not counted twice.
44
- // Every rule is linear in its input: unbounded runs are only started at a run boundary (a
45
- // lookbehind), never at every position inside the run.
46
- const RULES: Rule[] = [
47
- {
48
- // PEM / PGP armoured blocks, through their END line (or the end of the text if it was cut off).
49
- category: "credential",
50
- pattern: /-----BEGIN [A-Z0-9 ]{1,40}-----[\s\S]*?(?:-----END [A-Z0-9 ]{1,40}-----|$)/g,
51
- replacement: "[REDACTED_CREDENTIAL]",
52
- },
53
- {
54
- category: "credential",
55
- pattern: /\b(?:set-)?cookie\s*:\s*[^\n]*/gi,
56
- replacement: "[REDACTED_CREDENTIAL]",
57
- },
58
- {
59
- category: "credential",
60
- pattern: /\b(?:proxy-)?authorization\s*:\s*[^\n]*/gi,
61
- replacement: "[REDACTED_CREDENTIAL]",
62
- },
63
- {
64
- category: "credential",
65
- pattern: /\b(?:bearer|basic|token)\s+[A-Za-z0-9._~+/=-]{12,}/gi,
66
- replacement: "[REDACTED_CREDENTIAL]",
67
- },
68
- {
69
- category: "credential",
70
- pattern: /\beyJ[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{6,}\.[A-Za-z0-9_-]{0,}/g,
71
- replacement: "[REDACTED_CREDENTIAL]",
72
- },
73
- {
74
- category: "url",
75
- pattern: /\b(?:[a-z][a-z0-9+.-]{1,15}:\/\/|www\.)[^\s<>"'`]+/gi,
76
- replacement: "[REDACTED_URL]",
77
- },
78
- {
79
- category: "credential",
80
- pattern:
81
- /\b(?:api[_-]?key|access[_-]?token|refresh[_-]?token|secret|password|passwd|pwd|session(?:[_-]?id)?|sid|token|preview[_-]?token|csrf(?:[_-]?token)?|client[_-]?secret)\s*[:=]\s*["']?[^\s"'&;,]{4,}["']?/gi,
82
- replacement: "[REDACTED_CREDENTIAL]",
83
- },
84
- {
85
- category: "credential",
86
- pattern:
87
- /\b(?:sk|pk|rk|ghp|gho|ghu|ghs|github_pat|xox[abposr]|AKIA|ASIA|AIza|glpat|npm)[_-]?[A-Za-z0-9_-]{12,}/g,
88
- replacement: "[REDACTED_CREDENTIAL]",
89
- },
90
- {
91
- // Base64 secrets that contain + or / (cloud secret keys, key material): mixed case and a digit.
92
- category: "credential",
93
- pattern:
94
- /(?<![A-Za-z0-9+/=_-])(?=[A-Za-z0-9+/]*[A-Z])(?=[A-Za-z0-9+/]*[a-z])(?=[A-Za-z0-9+/]*\d)(?=[A-Za-z0-9+/]*[+/])[A-Za-z0-9+/]{32,}={0,2}(?![A-Za-z0-9+/=_-])/g,
95
- replacement: "[REDACTED_CREDENTIAL]",
96
- keep: isPathLike,
97
- },
98
- {
99
- category: "email",
100
- pattern: /(?<![A-Za-z0-9._%+-])[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g,
101
- replacement: "[REDACTED_EMAIL]",
102
- },
103
- {
104
- category: "markup",
105
- pattern: /<\/?[A-Za-z][^<>]*>|<!--[\s\S]*?-->/g,
106
- replacement: "",
107
- },
108
- {
109
- category: "phone",
110
- pattern: /(?:\+\d{1,3}[\s.-]?)?(?:\(\d{2,4}\)[\s.-]?|\d{2,4}[\s.-])\d{3,4}[\s.-]?\d{3,4}\b/g,
111
- replacement: "[REDACTED_PHONE]",
112
- },
113
- {
114
- category: "phone",
115
- pattern: /\+\d{8,15}\b/g,
116
- replacement: "[REDACTED_PHONE]",
117
- },
118
- {
119
- // Long opaque tokens (hex / base64url runs) that look like secrets or identifiers.
120
- category: "credential",
121
- pattern: /(?<![A-Za-z0-9_-])(?=[A-Za-z0-9_-]*\d)(?=[A-Za-z0-9_-]*[A-Za-z])[A-Za-z0-9_-]{32,}(?![A-Za-z0-9_-])/g,
122
- replacement: "[REDACTED_CREDENTIAL]",
123
- },
124
- ];
125
-
126
- // Control characters other than tab/newline; bidi marks, overrides and isolates that can disguise
127
- // text; and invisible format characters (soft hyphen, zero-width space/joiners, word joiner, BOM)
128
- // that would otherwise split an address or key so no rule recognises it.
129
- const CONTROL =
130
- /[\u0000-\u0008\u000B\u000C\u000E-\u001F\u007F-\u009F\u00AD\u061C\u180E\u200B\u200E\u200F\u2028-\u202E\u2060-\u2064\u2066-\u206F\uFEFF]/g;
131
-
132
- // Zero-width non-joiner / joiner are real text in Persian, Indic scripts and emoji sequences; strip
133
- // them only between printable ASCII characters, where they can only split an address or key.
134
- const ASCII_JOINER = /(?<=[\x21-\x7E])[\u200C\u200D]+(?=[\x21-\x7E])/g;
135
-
136
- export interface RedactionResult {
137
- text: string;
138
- counts: RedactionCounts;
139
- }
140
-
141
- /** Redact one string. Pure and deterministic. */
142
- export function redactText(input: string): RedactionResult {
143
- const counts: RedactionCounts = {};
144
- let text = String(input ?? "").slice(0, REDACT_INPUT_MAX).normalize("NFC");
145
- const controlMatches = text.match(CONTROL);
146
- if (controlMatches) {
147
- counts.other = (counts.other ?? 0) + controlMatches.length;
148
- text = text.replace(CONTROL, "");
149
- }
150
- const joiners = text.match(ASCII_JOINER);
151
- if (joiners) {
152
- counts.other = (counts.other ?? 0) + joiners.reduce((n, m) => n + m.length, 0);
153
- text = text.replace(ASCII_JOINER, "");
154
- }
155
- for (const rule of RULES) {
156
- text = text.replace(rule.pattern, (match) => {
157
- if (rule.keep?.(match)) return match;
158
- counts[rule.category] = (counts[rule.category] ?? 0) + 1;
159
- return rule.replacement;
160
- });
161
- }
162
- // Any stray angle brackets left after markup removal cannot form a tag, but keep the outgoing
163
- // text plain: render-side escaping still applies everywhere it is displayed.
164
- text = text.replace(/[ \t]+\n/g, "\n").replace(/\n{3,}/g, "\n\n").trim();
165
- return { text, counts };
166
- }
167
-
168
- /** Merge several count maps. */
169
- export function mergeCounts(...maps: RedactionCounts[]): RedactionCounts {
170
- const out: RedactionCounts = {};
171
- for (const map of maps) {
172
- for (const [key, value] of Object.entries(map) as [RedactionCategory, number][]) {
173
- if (value > 0) out[key] = Math.min(10000, (out[key] ?? 0) + value);
174
- }
175
- }
176
- return out;
177
- }
178
-
179
- export function totalRedactions(counts: RedactionCounts): number {
180
- return Object.values(counts).reduce((sum, n) => sum + (n ?? 0), 0);
181
- }
182
-
183
- const LABELS: Record<RedactionCategory, [string, string]> = {
184
- email: ["email address", "email addresses"],
185
- phone: ["phone number", "phone numbers"],
186
- credential: ["secret", "secrets"],
187
- url: ["link", "links"],
188
- markup: ["markup tag", "markup tags"],
189
- other: ["hidden character", "hidden characters"],
190
- };
191
-
192
- /** "Removed 2 email addresses and 1 link." — or null when nothing was removed. */
193
- export function describeRedactions(counts: RedactionCounts): string | null {
194
- const parts = (Object.keys(LABELS) as RedactionCategory[])
195
- .filter((key) => (counts[key] ?? 0) > 0)
196
- .map((key) => {
197
- const n = counts[key] as number;
198
- return `${n} ${LABELS[key][n === 1 ? 0 : 1]}`;
199
- });
200
- if (parts.length === 0) return null;
201
- const list =
202
- parts.length === 1 ? parts[0] : `${parts.slice(0, -1).join(", ")} and ${parts[parts.length - 1]}`;
203
- return `Removed ${list}.`;
204
- }
@@ -1,49 +0,0 @@
1
- /**
2
- * Text-selection picking. The reviewer's own selected words are the one page text the primitives
3
- * read, and only an excerpt that has passed local redaction ever leaves this module.
4
- */
5
- import type { TextSelection } from "../v1/types.js";
6
- import { mergeCounts, redactText } from "./redaction.js";
7
- import { safeRect } from "./target.js";
8
-
9
- export const EXCERPT_MAX = 500;
10
- const CHAR_COUNT_MAX = 100_000;
11
-
12
- export interface TextPick {
13
- selection: TextSelection;
14
- /** Closest element containing the whole selection; for structural evidence. */
15
- container: Element | null;
16
- }
17
-
18
- /**
19
- * Read the current window selection. Returns null when nothing is selected, or when the selection
20
- * lies inside the feedback UI itself (`ownHost`).
21
- */
22
- export function readTextSelection(win: Window, ownHost?: Element | null): TextPick | null {
23
- const sel = typeof win.getSelection === "function" ? win.getSelection() : null;
24
- if (!sel || sel.rangeCount === 0 || sel.isCollapsed) return null;
25
- const range = sel.getRangeAt(0);
26
- const common = range.commonAncestorContainer;
27
- const container = common.nodeType === 1 ? (common as Element) : common.parentElement;
28
- if (ownHost && (ownHost === container || (container && ownHost.contains(container)))) return null;
29
- const raw = sel.toString();
30
- if (raw.trim().length === 0) return null;
31
-
32
- const selection: TextSelection = { kind: "text", charCount: Math.min(CHAR_COUNT_MAX, raw.length) };
33
- const r = range.getBoundingClientRect();
34
- if (r && (r.width > 0 || r.height > 0)) selection.bounds = safeRect(r);
35
-
36
- // Redact before truncating so a secret straddling the cut is still caught; bound the work first.
37
- const redacted = redactText(raw.slice(0, 4000));
38
- const flat = redacted.text.replace(/\s+/g, " ").trim();
39
- if (flat.length > 0) {
40
- const truncated = flat.length > EXCERPT_MAX;
41
- const counts = mergeCounts(redacted.counts);
42
- selection.excerpt = {
43
- text: truncated ? `${flat.slice(0, EXCERPT_MAX - 1)}…` : flat,
44
- truncated: truncated || raw.length > 4000,
45
- ...(Object.keys(counts).length > 0 ? { redactionCounts: counts } : {}),
46
- };
47
- }
48
- return { selection, container };
49
- }
@@ -1,160 +0,0 @@
1
- /**
2
- * Double-Shift accelerator: two complete, unmodified Shift down/up taps within 450 ms.
3
- *
4
- * Ignored: key repeats, IME composition, events from editable controls, Shift held with another
5
- * modifier, any intervening key, a pointer action, focus loss, and taps during the post-activation
6
- * cooldown. It never calls preventDefault, so ordinary shortcuts are untouched.
7
- */
8
-
9
- export const DOUBLE_SHIFT_WINDOW_MS = 450;
10
- export const DOUBLE_SHIFT_COOLDOWN_MS = 800;
11
- /** A Shift held longer than this is not a tap. */
12
- const MAX_TAP_MS = 300;
13
-
14
- export interface KeyLike {
15
- type: "keydown" | "keyup";
16
- key: string;
17
- repeat?: boolean;
18
- isComposing?: boolean;
19
- altKey?: boolean;
20
- ctrlKey?: boolean;
21
- metaKey?: boolean;
22
- /** True when the event target is an editable control (input, textarea, select, contenteditable). */
23
- editable?: boolean;
24
- timeStamp: number;
25
- }
26
-
27
- export class DoubleShiftDetector {
28
- private downAt: number | null = null;
29
- private taps: number[] = [];
30
- private cooldownUntil = 0;
31
-
32
- constructor(
33
- private readonly windowMs = DOUBLE_SHIFT_WINDOW_MS,
34
- private readonly cooldownMs = DOUBLE_SHIFT_COOLDOWN_MS,
35
- ) {}
36
-
37
- /** Clear any partial sequence (pointer action, blur, visibility change, intervening key). */
38
- reset(): void {
39
- this.downAt = null;
40
- this.taps = [];
41
- }
42
-
43
- /** Feed a key event. Returns true exactly when the accelerator fires. */
44
- feed(e: KeyLike): boolean {
45
- const isShift = e.key === "Shift";
46
- if (!isShift || e.repeat || e.isComposing || e.editable || e.altKey || e.ctrlKey || e.metaKey) {
47
- // Holding Shift through a repeat is not a tap; any other key breaks the sequence.
48
- this.reset();
49
- return false;
50
- }
51
- if (e.timeStamp < this.cooldownUntil) {
52
- this.reset();
53
- return false;
54
- }
55
- if (e.type === "keydown") {
56
- if (this.downAt !== null) {
57
- this.reset();
58
- return false;
59
- }
60
- this.downAt = e.timeStamp;
61
- return false;
62
- }
63
- // keyup
64
- if (this.downAt === null || e.timeStamp - this.downAt > MAX_TAP_MS) {
65
- this.reset();
66
- return false;
67
- }
68
- this.downAt = null;
69
- this.taps = this.taps.filter((t) => e.timeStamp - t <= this.windowMs);
70
- this.taps.push(e.timeStamp);
71
- if (this.taps.length >= 2) {
72
- this.reset();
73
- this.cooldownUntil = e.timeStamp + this.cooldownMs;
74
- return true;
75
- }
76
- return false;
77
- }
78
- }
79
-
80
- export interface DoubleShiftOptions {
81
- /** Called exactly when the guarded double-Shift fires. */
82
- onActivate(): void;
83
- /** True while activation must be ignored (for example, a dialog is already open). */
84
- isSuppressed?(): boolean;
85
- /** True when the event came from the feedback UI itself; such events are treated as editable. */
86
- isOwnEvent?(event: Event): boolean;
87
- windowMs?: number;
88
- cooldownMs?: number;
89
- }
90
-
91
- export interface DoubleShiftBinding {
92
- detach(): void;
93
- /** Clear any partial Shift sequence. */
94
- reset(): void;
95
- }
96
-
97
- /**
98
- * Listen on `win` (capture phase, passive: never calls preventDefault) for the guarded double-Shift.
99
- * Pointer actions and window blur reset a partial sequence. Safe to detach more than once.
100
- */
101
- export function attachDoubleShift(win: Window, options: DoubleShiftOptions): DoubleShiftBinding {
102
- const detector = new DoubleShiftDetector(options.windowMs, options.cooldownMs);
103
- let attached = true;
104
- const onKey = (e: Event) => {
105
- const ke = e as KeyboardEvent;
106
- const suppressed = options.isSuppressed?.() ?? false;
107
- const fired = detector.feed({
108
- type: ke.type as "keydown" | "keyup",
109
- key: ke.key,
110
- repeat: ke.repeat,
111
- isComposing: ke.isComposing,
112
- altKey: ke.altKey,
113
- ctrlKey: ke.ctrlKey,
114
- metaKey: ke.metaKey,
115
- editable: (options.isOwnEvent?.(ke) ?? false) || isEditableTarget(ke),
116
- timeStamp: ke.timeStamp,
117
- });
118
- if (suppressed) {
119
- detector.reset();
120
- return;
121
- }
122
- if (fired) options.onActivate();
123
- };
124
- const reset = () => detector.reset();
125
- win.addEventListener("keydown", onKey, { capture: true, passive: true });
126
- win.addEventListener("keyup", onKey, { capture: true, passive: true });
127
- win.addEventListener("pointerdown", reset, { capture: true, passive: true });
128
- win.addEventListener("blur", reset);
129
- return {
130
- reset,
131
- detach() {
132
- if (!attached) return;
133
- attached = false;
134
- win.removeEventListener("keydown", onKey, { capture: true });
135
- win.removeEventListener("keyup", onKey, { capture: true });
136
- win.removeEventListener("pointerdown", reset, { capture: true });
137
- win.removeEventListener("blur", reset);
138
- detector.reset();
139
- },
140
- };
141
- }
142
-
143
- /** True when an event target is an editable control. Composed path aware (shadow DOM inputs). */
144
- export function isEditableTarget(event: Event): boolean {
145
- const path = typeof event.composedPath === "function" ? event.composedPath() : [event.target];
146
- for (const node of path) {
147
- if (!node || typeof (node as Element).tagName !== "string") continue;
148
- const el = node as HTMLElement;
149
- const tag = el.tagName.toLowerCase();
150
- if (tag === "textarea" || tag === "select") return true;
151
- if (tag === "input") {
152
- const type = ((el as HTMLInputElement).type || "text").toLowerCase();
153
- if (!["button", "submit", "reset", "checkbox", "radio", "range", "color", "file", "image"].includes(type)) return true;
154
- }
155
- if (el.isContentEditable || el.getAttribute?.("contenteditable") === "true") return true;
156
- const role = el.getAttribute?.("role");
157
- if (role === "textbox" || role === "combobox" || role === "searchbox") return true;
158
- }
159
- return false;
160
- }
@@ -1,77 +0,0 @@
1
- /**
2
- * Isolated styles for the primitives' shadow roots. Colors, font and launcher stacking come from
3
- * `--fb-*` custom properties, which a host overrides through `HostAdapter.theme.tokens`.
4
- */
5
- export const PRIMITIVE_CSS = `
6
- :host { all: initial; }
7
- * { box-sizing: border-box; }
8
- [hidden] { display: none !important; }
9
- .root { --fb-acc: #4f46e5; --fb-acc-ink: #fff; --fb-ink: #111827; --fb-muted: #4b5563; --fb-bg: #fff; --fb-line: #d1d5db;
10
- --fb-err: #b91c1c; --fb-ok: #047857; --fb-font: system-ui, -apple-system, "Segoe UI", sans-serif; --fb-z: 2147483646;
11
- font: 14px/1.45 var(--fb-font); color: var(--fb-ink); }
12
- button, input, select, textarea { font: inherit; color: inherit; }
13
- button { cursor: pointer; border: 1px solid var(--fb-line); background: var(--fb-bg); border-radius: 6px; padding: 6px 10px; min-height: 32px; }
14
- button.primary { background: var(--fb-acc); border-color: var(--fb-acc); color: var(--fb-acc-ink); }
15
- button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
16
- outline: 3px solid var(--fb-acc); outline-offset: 2px; }
17
- button[disabled] { opacity: .55; cursor: not-allowed; }
18
- .cue { position: fixed; right: 12px; bottom: 0; z-index: var(--fb-z); pointer-events: auto; display: flex; align-items: flex-end; }
19
- .fab { background: #f3f4f6; color: #4b5563; border: 1px solid #d1d5db; border-bottom: 0; border-radius: 8px 8px 0 0; padding: 0 10px;
20
- min-height: 22px; height: 22px; font-size: 11px; line-height: 20px; font-weight: 500; opacity: .6; box-shadow: none; position: relative;
21
- transition: opacity .15s; }
22
- .fab:hover, .fab:focus-visible { opacity: 1; color: #111827; }
23
- .fab .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #d97706; margin-left: 6px; vertical-align: middle; }
24
- .cue[data-nub="true"] .fab { padding: 0; width: 28px; min-height: 8px; height: 8px; border-radius: 6px 6px 0 0; }
25
- .cue[data-nub="true"] .fab .dot { position: absolute; top: -3px; right: -3px; margin: 0; }
26
- .strip { display: flex; align-items: center; gap: 4px 8px; background: #111827; color: #f9fafb; border-radius: 10px 10px 0 0; padding: 4px 10px;
27
- font-size: 13px; line-height: 20px; max-width: calc(100vw - 24px); }
28
- .strip button { min-height: 28px; padding: 2px 10px; font-size: 13px; border-radius: 6px; }
29
- .strip .strip-act { background: #4f46e5; border-color: #4f46e5; color: #fff; font-weight: 600; }
30
- .strip .strip-hide { background: transparent; border-color: #6b7280; color: #e5e7eb; }
31
- .strip button:focus-visible { outline: 3px solid #fbbf24; outline-offset: 2px; }
32
- .fab:focus-visible { outline-offset: 0; }
33
- .dialog { position: fixed; right: 16px; top: 16px; z-index: calc(var(--fb-z) + 1); pointer-events: auto; width: 360px;
34
- max-width: calc(100vw - 16px); max-height: calc(100vh - 16px); overflow: auto; background: var(--fb-bg);
35
- border: 1px solid var(--fb-line); border-radius: 12px; box-shadow: 0 16px 40px rgba(17,24,39,.28); }
36
- @media (max-width: 600px) {
37
- .strip { flex-wrap: wrap; }
38
- .strip-title { flex-basis: 100%; font-size: 12px; line-height: 16px; }
39
- .dialog { left: 0; right: 0; top: auto; bottom: 0; width: 100%; max-width: 100%; max-height: 85vh; border-radius: 14px 14px 0 0; }
40
- }
41
- .titlebar { display: flex; align-items: center; gap: 4px; padding: 8px 10px; border-bottom: 1px solid var(--fb-line); }
42
- .titlebar h2 { font-size: 15px; margin: 0; flex: 1; }
43
- .titlebar button { padding: 2px 6px; min-height: 28px; font-size: 12px; }
44
- .body { padding: 10px 12px 12px; display: grid; gap: 10px; }
45
- .shield { position: fixed; inset: 0; z-index: calc(var(--fb-z) - 2); pointer-events: auto; cursor: crosshair; background: transparent;
46
- touch-action: none; }
47
- .highlight { position: fixed; z-index: calc(var(--fb-z) - 1); pointer-events: none; border: 2px solid var(--fb-acc); border-radius: 3px;
48
- box-shadow: 0 0 0 4px rgba(79,70,229,.25), 0 0 18px 4px rgba(79,70,229,.35); }
49
- .highlight .tag { position: absolute; left: -2px; top: -24px; background: var(--fb-acc); color: var(--fb-acc-ink); font-size: 12px;
50
- padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
51
- .region { position: fixed; z-index: calc(var(--fb-z) - 1); pointer-events: none; border: 2px dashed var(--fb-acc); background: rgba(79,70,229,.10); }
52
- .toolbar { position: fixed; left: 50%; top: 12px; transform: translateX(-50%); z-index: calc(var(--fb-z) + 2); pointer-events: auto;
53
- background: var(--fb-bg); border: 1px solid var(--fb-line); border-radius: 10px; padding: 8px; box-shadow: 0 8px 28px rgba(17,24,39,.22);
54
- display: flex; flex-wrap: wrap; gap: 6px; align-items: center; max-width: calc(100vw - 24px); }
55
- .toolbar.bottom { top: auto; bottom: 12px; }
56
- .toolbar .instr { flex-basis: 100%; color: var(--fb-muted); font-size: 13px; }
57
- .toolbar [aria-pressed="true"] { background: var(--fb-acc); color: var(--fb-acc-ink); border-color: var(--fb-acc); }
58
- .composer label, .composer legend { font-weight: 600; font-size: 13px; }
59
- .composer input[type=text], .composer textarea, .composer select { width: 100%; border: 1px solid var(--fb-line); border-radius: 6px; padding: 6px 8px; background: #fff; }
60
- .composer textarea { min-height: 64px; resize: vertical; }
61
- .composer fieldset { border: 0; padding: 0; margin: 0; display: grid; gap: 4px; }
62
- .intents { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
63
- .intents label { font-weight: 400; display: flex; gap: 6px; align-items: center; border: 1px solid var(--fb-line); border-radius: 6px; padding: 4px 6px; }
64
- .muted { color: var(--fb-muted); font-size: 12px; }
65
- .error { color: var(--fb-err); font-size: 13px; }
66
- .ok { color: var(--fb-ok); }
67
- .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
68
- .target { display: flex; gap: 8px; align-items: center; justify-content: space-between; background: #f3f4f6; border-radius: 6px; padding: 6px 8px; }
69
- .review dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 2px 8px; font-size: 13px; }
70
- .review dt { color: var(--fb-muted); }
71
- .review dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
72
- .composer pre { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; background: #f9fafb; padding: 6px; border-radius: 6px; max-height: 200px; overflow: auto; }
73
- .notice { background: #fffbeb; border: 1px solid #fcd34d; border-radius: 6px; padding: 6px 8px; font-size: 13px; }
74
- .copybox { width: 100%; min-height: 80px; font-size: 12px; }
75
- .sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
76
- @media (prefers-reduced-motion: reduce) { .fab, .dialog, .highlight { transition: none !important; animation: none !important; } }
77
- `;
@@ -1,124 +0,0 @@
1
- /**
2
- * One isolated surface: a host element carrying a shadow root, themed and styled, attached to the
3
- * page through the host adapter. Every primitive owns exactly one. All dynamic text is written with
4
- * `textContent`; the shadow root gives style isolation only, never confidentiality.
5
- */
6
- import { applyTheme, type HostAdapter } from "./hostAdapter.js";
7
- import { PRIMITIVE_CSS } from "./styles.js";
8
-
9
- type Child = Node | string | null | undefined | false;
10
-
11
- /** Create an element with attributes (`text` sets textContent) and children. */
12
- export function h<K extends keyof HTMLElementTagNameMap>(
13
- doc: Document,
14
- tag: K,
15
- attrs: Record<string, string | boolean | undefined> = {},
16
- ...children: Child[]
17
- ): HTMLElementTagNameMap[K] {
18
- const el = doc.createElement(tag);
19
- for (const [k, v] of Object.entries(attrs)) {
20
- if (v === undefined || v === false) continue;
21
- if (k === "text") el.textContent = String(v);
22
- else el.setAttribute(k, v === true ? "" : v);
23
- }
24
- for (const c of children) {
25
- if (c === null || c === undefined || c === false) continue;
26
- el.append(typeof c === "string" ? doc.createTextNode(c) : c);
27
- }
28
- return el;
29
- }
30
-
31
- export interface Surface {
32
- /** The element placed in the page. */
33
- readonly host: HTMLElement;
34
- readonly shadow: ShadowRoot;
35
- /** Container inside the shadow root; primitives append their UI here. */
36
- readonly root: HTMLElement;
37
- readonly isAttached: boolean;
38
- /** Idempotent. */
39
- attach(): void;
40
- /** Idempotent. Runs the adapter's mount cleanup, then removes the host element. */
41
- detach(): void;
42
- }
43
-
44
- export interface SurfaceOptions {
45
- win: Window;
46
- doc: Document;
47
- adapter: HostAdapter | undefined;
48
- /** Custom element name for the host; must contain a hyphen. */
49
- tag: string;
50
- shadowMode?: "open" | "closed";
51
- }
52
-
53
- export function createSurface(options: SurfaceOptions): Surface {
54
- const { win, doc, adapter, tag } = options;
55
- const host = doc.createElement(tag);
56
- host.setAttribute("data-feedback-surface", "");
57
- for (const [k, v] of [
58
- ["all", "initial"],
59
- ["position", "fixed"],
60
- ["top", "0"],
61
- ["left", "0"],
62
- ["width", "0"],
63
- ["height", "0"],
64
- ] as const) {
65
- host.style.setProperty(k, v);
66
- }
67
- const shadow = host.attachShadow({ mode: options.shadowMode ?? "closed" });
68
- let adopted = false;
69
- const SheetCtor = (win as Window & { CSSStyleSheet?: typeof CSSStyleSheet }).CSSStyleSheet;
70
- try {
71
- if (SheetCtor && "adoptedStyleSheets" in shadow) {
72
- const sheet = new SheetCtor();
73
- sheet.replaceSync(PRIMITIVE_CSS);
74
- (shadow as ShadowRoot & { adoptedStyleSheets: CSSStyleSheet[] }).adoptedStyleSheets = [sheet];
75
- adopted = true;
76
- }
77
- } catch {
78
- adopted = false;
79
- }
80
- if (!adopted) {
81
- const style = doc.createElement("style");
82
- const nonce = adapter?.theme?.nonce;
83
- if (nonce) style.setAttribute("nonce", nonce);
84
- style.textContent = PRIMITIVE_CSS;
85
- shadow.append(style);
86
- }
87
- const root = h(doc, "div", { class: "root" });
88
- applyTheme(root, adapter?.theme);
89
- shadow.append(root);
90
-
91
- let attached = false;
92
- let cleanup: void | (() => void);
93
- return {
94
- host,
95
- shadow,
96
- root,
97
- get isAttached() {
98
- return attached;
99
- },
100
- attach() {
101
- if (attached) return;
102
- attached = true;
103
- if (adapter?.mount) cleanup = adapter.mount(host);
104
- else (doc.documentElement || doc.body).append(host);
105
- },
106
- detach() {
107
- if (!attached) return;
108
- attached = false;
109
- const run = cleanup;
110
- cleanup = undefined;
111
- try {
112
- if (typeof run === "function") run();
113
- } finally {
114
- host.remove();
115
- }
116
- },
117
- };
118
- }
119
-
120
- /** True when `event` was dispatched from inside (or on) the given host element. */
121
- export function eventFromHost(event: Event, host: Element): boolean {
122
- const path = typeof event.composedPath === "function" ? event.composedPath() : [];
123
- return path.includes(host);
124
- }