@tokenoftrust/storefront-runner 1.4.2-rc.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apps/storefront/astro.config.mjs +3 -3
- package/apps/storefront/dev-plugins/tenant-hot-reload.mjs +8 -3
- package/apps/storefront/env.d.ts +54 -5
- package/apps/storefront/integrations/materialize-guard.mjs +12 -14
- package/apps/storefront/migrations-apps/0004_deep_morph.sql +36 -0
- package/apps/storefront/migrations-apps/0005_common_mystique.sql +23 -0
- package/apps/storefront/migrations-apps/0006_broad_microchip.sql +16 -0
- package/apps/storefront/migrations-apps/0007_brave_outlaw_kid.sql +15 -0
- package/apps/storefront/migrations-apps/0008_blue_dazzler.sql +11 -0
- package/apps/storefront/migrations-apps/0009_bored_shinobi_shaw.sql +15 -0
- package/apps/storefront/migrations-apps/0010_ws4_verified_provider_measurement.sql +35 -0
- package/apps/storefront/migrations-apps/meta/0004_snapshot.json +1474 -0
- package/apps/storefront/migrations-apps/meta/0005_snapshot.json +1617 -0
- package/apps/storefront/migrations-apps/meta/0006_snapshot.json +1716 -0
- package/apps/storefront/migrations-apps/meta/0007_snapshot.json +1812 -0
- package/apps/storefront/migrations-apps/meta/0008_snapshot.json +1881 -0
- package/apps/storefront/migrations-apps/meta/0009_snapshot.json +1979 -0
- package/apps/storefront/migrations-apps/meta/_journal.json +42 -0
- package/apps/storefront/public/apps/tot.demo.analytics/0.1.0/entry.js +42 -0
- package/apps/storefront/public/platform/amplitude-http/v1/entry.mjs +19 -0
- package/apps/storefront/public/platform/google-measurement/v1/entry.mjs +19 -0
- package/apps/storefront/public/shared/commerce-chrome.css +20 -2
- package/apps/storefront/scripts/build-v84-clean-clone-standalone.mjs +68 -0
- package/apps/storefront/scripts/deny-v84-clean-clone-standalone-capabilities.mjs +111 -0
- package/apps/storefront/scripts/deny-v84-dogfood-capabilities.mjs +2 -0
- package/apps/storefront/scripts/deny-v84-lifecycle-capabilities.mjs +247 -0
- package/apps/storefront/scripts/dogfood-v84-nonportable-routes.ts +73 -0
- package/apps/storefront/scripts/fixed-v84-native-install-producer.ts +79 -0
- package/apps/storefront/scripts/generated/v84-clean-clone-replay.bundle.mjs +10982 -0
- package/apps/storefront/scripts/import-v84-through-ws2.ts +38 -0
- package/apps/storefront/scripts/initialize-v84-lifecycle-tooling-dependency.ts +2 -0
- package/apps/storefront/scripts/initialize-v84-lifecycle-tooling.ts +4 -0
- package/apps/storefront/scripts/install-v84-native-through-ws1.ts +185 -0
- package/apps/storefront/scripts/prove-clone-isolation.ts +506 -0
- package/apps/storefront/scripts/replay-v84-clean-clone-pass.ts +148 -0
- package/apps/storefront/scripts/replay-v84-clean-clone-standalone.ts +35 -0
- package/apps/storefront/scripts/replay-v84-clean-clone.ts +214 -0
- package/apps/storefront/scripts/run-fixed-v84-native-install-producer.mjs +18 -0
- package/apps/storefront/scripts/run-v84-clone-isolation-proof.mjs +18 -0
- package/apps/storefront/scripts/run-v84-clone-lifecycle-proof.mjs +18 -0
- package/apps/storefront/scripts/run-v84-import-through-ws2-proof.mjs +17 -0
- package/apps/storefront/scripts/run-v84-nonportable-route-dogfood.mjs +15 -0
- package/apps/storefront/scripts/sanitize-v84-proof-environment.mjs +21 -0
- package/apps/storefront/scripts/v84CleanCloneGraphPin.ts +42 -0
- package/apps/storefront/scripts/v84CleanCloneSourceGraph.ts +145 -0
- package/apps/storefront/scripts/validate-v84-clone-lifecycle.ts +18 -0
- package/apps/storefront/src/components/Img.astro +1 -1
- package/apps/storefront/src/components/admin/AdminBlogTab.astro +19 -16
- package/apps/storefront/src/components/admin/AdminIntegrationsTab.astro +105 -0
- package/apps/storefront/src/components/admin/AdminPublishTab.astro +1057 -412
- package/apps/storefront/src/components/admin/AdminSettingsTab.astro +2 -2
- package/apps/storefront/src/components/admin/orders/OrdersWorkspace.astro +5 -5
- package/apps/storefront/src/components/chrome/NavDropdown.astro +12 -0
- package/apps/storefront/src/components/chrome/SiteFooter.astro +7 -2
- package/apps/storefront/src/components/chrome/SiteHeader.astro +46 -10
- package/apps/storefront/src/components/compliance/AdultSignatureNotice.astro +1 -1
- package/apps/storefront/src/components/compliance/ComplianceNotice.astro +1 -2
- package/apps/storefront/src/components/compliance/ExciseTaxNotice.astro +1 -2
- package/apps/storefront/src/components/compliance/PactActNotice.astro +1 -1
- package/apps/storefront/src/components/compliance/Prop65Warning.astro +1 -2
- package/apps/storefront/src/components/compliance/PurchaseLimitNotice.astro +2 -3
- package/apps/storefront/src/components/compliance/ShippingRestrictionNotice.astro +2 -2
- package/apps/storefront/src/components/compliance/StateEligibilityNotice.astro +2 -3
- package/apps/storefront/src/components/content/TrustStrip.astro +4 -4
- package/apps/storefront/src/components/islands/MobileNav.tsx +26 -1
- package/apps/storefront/src/components/islands/VariantSelector.tsx +27 -2
- package/apps/storefront/src/components/islands/useCheckoutHandoffCorrelation.ts +75 -0
- package/apps/storefront/src/components/membership/IllustrativeLabel.astro +1 -2
- package/apps/storefront/src/components/membership/TierCards.astro +2 -2
- package/apps/storefront/src/components/membership/TierComparisonTable.astro +2 -2
- package/apps/storefront/src/components/subscription/SavingsExplainer.astro +2 -2
- package/apps/storefront/src/config/adminTenantLookup.ts +35 -0
- package/apps/storefront/src/config/devTenantSeed.ts +9 -9
- package/apps/storefront/src/config/resolver.ts +18 -10
- package/apps/storefront/src/layouts/Layout.astro +100 -20
- package/apps/storefront/src/lib/activity/candidateSubmitLease.ts +87 -0
- package/apps/storefront/src/lib/activity/changeActorAttribution.ts +86 -6
- package/apps/storefront/src/lib/activity/deployVersion.ts +1 -1
- package/apps/storefront/src/lib/admin/adminShell.ts +2 -0
- package/apps/storefront/src/lib/admin/envelope.ts +1 -2
- package/apps/storefront/src/lib/apps/adminService.ts +10 -0
- package/apps/storefront/src/lib/apps/adminSession.ts +1 -1
- package/apps/storefront/src/lib/apps/appVersionStore.ts +281 -0
- package/apps/storefront/src/lib/apps/consentConfigStore.ts +228 -0
- package/apps/storefront/src/lib/apps/gtmMigrationInstall.ts +447 -0
- package/apps/storefront/src/lib/apps/gtmMigrationReport.ts +367 -0
- package/apps/storefront/src/lib/apps/gtmMigrationTab.ts +315 -0
- package/apps/storefront/src/lib/apps/integrationLifecycle.ts +614 -0
- package/apps/storefront/src/lib/apps/integrationLifecycleController.ts +125 -0
- package/apps/storefront/src/lib/apps/integrationReadModel.ts +563 -0
- package/apps/storefront/src/lib/apps/integrationsTab.ts +547 -0
- package/apps/storefront/src/lib/apps/integrationsView.ts +106 -0
- package/apps/storefront/src/lib/apps/managedAnalyticsService.ts +599 -0
- package/apps/storefront/src/lib/apps/orders/orderConversionD1.ts +150 -0
- package/apps/storefront/src/lib/apps/orders/orderForwardReceiver.ts +8 -0
- package/apps/storefront/src/lib/apps/orders/ordersStore.ts +1 -1
- package/apps/storefront/src/lib/apps/orders/verifiedProviderMeasurement.ts +117 -0
- package/apps/storefront/src/lib/apps/registryService.ts +264 -10
- package/apps/storefront/src/lib/apps/tenantIntegrationMaterialization.ts +170 -0
- package/apps/storefront/src/lib/apps/v84CleanCloneReplayContext.ts +16 -0
- package/apps/storefront/src/lib/apps/v84CloneLifecycleCacheEvidence.ts +105 -0
- package/apps/storefront/src/lib/apps/v84CloneLifecycleEvidence.ts +177 -0
- package/apps/storefront/src/lib/apps/v84CloneLifecycleMaterialization.ts +251 -0
- package/apps/storefront/src/lib/apps/v84CloneLifecycleSemantics.ts +241 -0
- package/apps/storefront/src/lib/apps/v84CloneMigrationEvidence.ts +211 -0
- package/apps/storefront/src/lib/apps/v84CloneNativeInstallEvidence.ts +409 -0
- package/apps/storefront/src/lib/apps/v84NonportableCodeCoaching.ts +368 -0
- package/apps/storefront/src/lib/apps/v84NonportableRouteContract.ts +188 -0
- package/apps/storefront/src/lib/apps/v84NonportableRouteDogfood.ts +291 -0
- package/apps/storefront/src/lib/apps/ws1ManagedAnalyticsClient.ts +95 -0
- package/apps/storefront/src/lib/auth/adminApiGuard.ts +66 -0
- package/apps/storefront/src/lib/auth/adminEntry.ts +2 -2
- package/apps/storefront/src/lib/auth/adminLanding.ts +88 -0
- package/apps/storefront/src/lib/blog/collection.ts +114 -17
- package/apps/storefront/src/lib/blog/markdown.ts +1 -1
- package/apps/storefront/src/lib/blog/provider.ts +76 -9
- package/apps/storefront/src/lib/blog/types.ts +9 -9
- package/apps/storefront/src/lib/chrome/examples/tokenoftrust.chrome-assignments.example.json +6 -0
- package/apps/storefront/src/lib/chrome/examples/tokenoftrust.chrome.example.json +79 -0
- package/apps/storefront/src/lib/chrome/model.ts +48 -253
- package/apps/storefront/src/lib/chrome/navCurrent.ts +29 -0
- package/apps/storefront/src/lib/chrome/parseConfig.ts +18 -32
- package/apps/storefront/src/lib/chrome/variant.ts +39 -0
- package/apps/storefront/src/lib/commerce/checkoutHandoffCorrelation.ts +105 -0
- package/apps/storefront/src/lib/compliance/tamper-sentinel-boot.ts +152 -0
- package/apps/storefront/src/lib/compliance/tamper-sentinel.ts +327 -0
- package/apps/storefront/src/lib/content/index.ts +5 -5
- package/apps/storefront/src/lib/content-edit/applyDiff.ts +1 -1
- package/apps/storefront/src/lib/content-edit/route.ts +1 -1
- package/apps/storefront/src/lib/d1/catalog.ts +12 -0
- package/apps/storefront/src/lib/d1/schema-apps.ts +276 -0
- package/apps/storefront/src/lib/dev/cockpit/ask.ts +49 -0
- package/apps/storefront/src/lib/dev/cockpit/clickToSource.ts +71 -0
- package/apps/storefront/src/lib/dev/cockpit/copyCommand.ts +227 -0
- package/apps/storefront/src/lib/dev/cockpit/files.ts +249 -0
- package/apps/storefront/src/lib/dev/cockpit/hostedActivity.ts +500 -0
- package/apps/storefront/src/lib/dev/cockpit/infoPopover.ts +12 -0
- package/apps/storefront/src/lib/dev/cockpit/mcpCopy.ts +34 -0
- package/apps/storefront/src/lib/dev/cockpit/monitor.ts +107 -0
- package/apps/storefront/src/lib/dev/cockpit/stepper.ts +116 -0
- package/apps/storefront/src/lib/dev/cockpit/themeToggle.ts +23 -0
- package/apps/storefront/src/lib/dev/runtimeStore.ts +1 -1
- package/apps/storefront/src/lib/edgeCache.ts +18 -6
- package/apps/storefront/src/lib/email/candidateConflictEmail.ts +80 -0
- package/apps/storefront/src/lib/integration/browserEnvironment.ts +137 -0
- package/apps/storefront/src/lib/integration/managedInstallDeclarations.ts +72 -0
- package/apps/storefront/src/lib/integration/nonceStamp.ts +49 -0
- package/apps/storefront/src/lib/integration/tenantDeclarations.ts +116 -0
- package/apps/storefront/src/lib/membership/eligibility.ts +1 -1
- package/apps/storefront/src/lib/membership/model.ts +1 -2
- package/apps/storefront/src/lib/newsletter/confirmationEmail.ts +2 -2
- package/apps/storefront/src/lib/newsletter/consent.ts +2 -2
- package/apps/storefront/src/lib/newsletter/send.ts +3 -3
- package/apps/storefront/src/lib/previewReload.ts +57 -1
- package/apps/storefront/src/lib/publish/adminPublishTab.ts +1775 -669
- package/apps/storefront/src/lib/publish/buildStream.ts +269 -0
- package/apps/storefront/src/lib/publish/collapsePersistence.ts +72 -0
- package/apps/storefront/src/lib/publish/lifecycleState.ts +369 -0
- package/apps/storefront/src/lib/publish/liveReleaseSummary.ts +29 -0
- package/apps/storefront/src/lib/publish/mergeDoctorOnFailure.ts +78 -0
- package/apps/storefront/src/lib/publish/mergeHealthBanner.ts +62 -0
- package/apps/storefront/src/lib/publish/mergeRowFindings.ts +124 -0
- package/apps/storefront/src/lib/publish/mergeSupportEscalation.ts +75 -0
- package/apps/storefront/src/lib/publish/publish-guard.ts +88 -0
- package/apps/storefront/src/lib/publish/publishFormat.ts +165 -0
- package/apps/storefront/src/lib/publish/publishHero.ts +177 -0
- package/apps/storefront/src/lib/publish/reviewRelease/changeState.ts +66 -0
- package/apps/storefront/src/lib/publish/reviewRelease/copy.ts +141 -0
- package/apps/storefront/src/lib/publish/reviewRelease/index.ts +41 -0
- package/apps/storefront/src/lib/publish/reviewRelease/permissions.ts +47 -0
- package/apps/storefront/src/lib/publish/reviewRelease/releaseState.ts +42 -0
- package/apps/storefront/src/lib/publish/reviewRelease/types.ts +59 -0
- package/apps/storefront/src/lib/publish/reviewRelease/viewModel.ts +440 -0
- package/apps/storefront/src/lib/publish/reviewReleaseWorkspace/actions.ts +161 -0
- package/apps/storefront/src/lib/publish/reviewReleaseWorkspace/controller.ts +325 -0
- package/apps/storefront/src/lib/publish/reviewReleaseWorkspace/render.ts +241 -0
- package/apps/storefront/src/lib/publish/shipWorkspace.ts +22 -3
- package/apps/storefront/src/lib/publish/sseRoute.ts +119 -0
- package/apps/storefront/src/lib/publish/streamLogConsole.ts +142 -0
- package/apps/storefront/src/lib/publish/versionNumber.ts +52 -0
- package/apps/storefront/src/lib/rawChrome.ts +125 -47
- package/apps/storefront/src/lib/rawMarketingHtml.ts +74 -3
- package/apps/storefront/src/lib/seo/alternates.ts +1 -1
- package/apps/storefront/src/lib/social/notify.ts +4 -4
- package/apps/storefront/src/lib/storyblok/content-model.ts +7 -33
- package/apps/storefront/src/lib/storyblok/provider.ts +203 -69
- package/apps/storefront/src/lib/subscription/model.ts +4 -4
- package/apps/storefront/src/lib/the-build/provider.ts +9 -4
- package/apps/storefront/src/middleware/index.ts +273 -51
- package/apps/storefront/src/pages/[...slug].astro +9 -4
- package/apps/storefront/src/pages/admin/review-release.astro +265 -0
- package/apps/storefront/src/pages/admin/select.astro +96 -0
- package/apps/storefront/src/pages/admin.astro +16 -2
- package/apps/storefront/src/pages/api/activity.ts +8 -8
- package/apps/storefront/src/pages/api/admin/activity-alerts.ts +5 -20
- package/apps/storefront/src/pages/api/admin/orders/[id].ts +7 -2
- package/apps/storefront/src/pages/api/admin/orders.ts +8 -2
- package/apps/storefront/src/pages/api/apps/admin/gtm-migration-install.ts +174 -0
- package/apps/storefront/src/pages/api/apps/admin/gtm-migration.ts +96 -0
- package/apps/storefront/src/pages/api/apps/admin/integration-lifecycle.ts +118 -0
- package/apps/storefront/src/pages/api/apps/admin/integrations.ts +89 -0
- package/apps/storefront/src/pages/api/apps/admin/platform-adapters.ts +85 -0
- package/apps/storefront/src/pages/api/apps/internal/order-forward.ts +74 -2
- package/apps/storefront/src/pages/api/commerce/checkout-handoff.ts +77 -0
- package/apps/storefront/src/pages/api/compliance/tamper.ts +88 -0
- package/apps/storefront/src/pages/api/integrations/v1/[operation].ts +108 -0
- package/apps/storefront/src/pages/api/rum/vitals.ts +1 -2
- package/apps/storefront/src/pages/blog/[slug].astro +5 -5
- package/apps/storefront/src/pages/blog/author/[author].astro +3 -3
- package/apps/storefront/src/pages/blog/category/[category].astro +2 -2
- package/apps/storefront/src/pages/blog/index.astro +2 -2
- package/apps/storefront/src/pages/blog/tag/[tag].astro +2 -2
- package/apps/storefront/src/pages/cockpit.astro +61 -1362
- package/apps/storefront/src/pages/index.astro +10 -5
- package/apps/storefront/src/pages/llms.txt.ts +1 -1
- package/apps/storefront/src/pages/products/[handle].astro +7 -6
- package/apps/storefront/src/pages/sitemap.xml.ts +2 -2
- package/apps/storefront/src/pages/style-guide/[tenant]/[theme].astro +42 -31
- package/apps/storefront/src/pages/style-guide/[tenant]/chrome/[theme].astro +8 -3
- package/apps/storefront/src/pages/style-guide/[tenant]/guide/[theme].astro +6 -2
- package/apps/storefront/src/pages/style-guide/[tenant]/index.astro +6 -2
- package/apps/storefront/src/pages/style-guide/index.astro +19 -5
- package/apps/storefront/src/pages/tenants/[id]/[...path].ts +38 -2
- package/apps/storefront/src/pages/the-build/[slug].astro +4 -4
- package/apps/storefront/src/pages/the-build/index.astro +2 -2
- package/apps/storefront/src/pages/the-build/rss.xml.ts +2 -2
- package/apps/storefront/src/styles/admin.css +27 -1
- package/apps/storefront/src/themes/tenants/index.ts +19 -7
- package/apps/storefront/tsconfig.json +1 -1
- package/package.json +1 -1
- package/packages/public-runtime/package.json +2 -1
- package/packages/public-runtime/schemas/managed-analytics/v1/adapter-definition.schema.json +427 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/create-integration-install-request.schema.json +161 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/create-migration-draft-request.schema.json +157 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/delete-integration-install-request.schema.json +84 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/delete-migration-draft-request.schema.json +84 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/error-envelope.schema.json +180 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/get-adapter-definition-request.schema.json +52 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/get-integration-install-request.schema.json +52 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/get-integration-revision-request.schema.json +79 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/get-migration-draft-request.schema.json +52 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/integration-install.schema.json +167 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/integration-revision.schema.json +208 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/list-adapter-definitions-request.schema.json +53 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/list-integration-installs-request.schema.json +53 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/list-integration-revisions-request.schema.json +82 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/migration-draft.schema.json +218 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/mutation-request.schema.json +52 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/mutation-success-envelope.schema.json +49 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/read-request.schema.json +20 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/read-success-envelope.schema.json +45 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/revise-integration-install-request.schema.json +156 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/set-integration-install-status-request.schema.json +92 -0
- package/packages/public-runtime/schemas/managed-analytics/v1/update-migration-draft-request.schema.json +184 -0
- package/packages/public-runtime/scripts/generate-managed-analytics-api-v1-schemas.mjs +13 -0
- package/packages/public-runtime/src/activity/catalog.ts +41 -37
- package/packages/public-runtime/src/activity/event.ts +6 -6
- package/packages/public-runtime/src/activity/index.ts +2 -2
- package/packages/public-runtime/src/activity/redaction.ts +4 -4
- package/packages/public-runtime/src/candidate-index.ts +42 -8
- package/packages/public-runtime/src/checkout-orders.ts +2 -2
- package/packages/public-runtime/src/checkout-style-publish.ts +2 -2
- package/packages/public-runtime/src/checkout-style.ts +7 -7
- package/packages/public-runtime/src/checkout.ts +3 -3
- package/packages/public-runtime/src/chrome.ts +777 -0
- package/packages/public-runtime/src/compliance-obligations.ts +310 -0
- package/packages/public-runtime/src/csp.ts +99 -0
- package/packages/public-runtime/src/customization-runtime.ts +32 -1
- package/packages/public-runtime/src/destination-webhook/contract.ts +353 -0
- package/packages/public-runtime/src/embed-catalog.d.mts +9 -0
- package/packages/public-runtime/src/embed-catalog.mjs +40 -0
- package/packages/public-runtime/src/evidence.ts +288 -0
- package/packages/public-runtime/src/gtm-migration/bounds.ts +138 -0
- package/packages/public-runtime/src/gtm-migration/disposition-rules.ts +361 -0
- package/packages/public-runtime/src/gtm-migration/dispositions.ts +181 -0
- package/packages/public-runtime/src/gtm-migration/draft-generator.ts +400 -0
- package/packages/public-runtime/src/gtm-migration/graph.ts +468 -0
- package/packages/public-runtime/src/gtm-migration/index.ts +95 -0
- package/packages/public-runtime/src/gtm-migration/parse.ts +410 -0
- package/packages/public-runtime/src/gtm-migration/references.ts +266 -0
- package/packages/public-runtime/src/gtm-migration/types.ts +86 -0
- package/packages/public-runtime/src/index.ts +16 -1
- package/packages/public-runtime/src/integration/assurance-decision.ts +259 -0
- package/packages/public-runtime/src/integration/assurance.ts +228 -0
- package/packages/public-runtime/src/integration/candidate-evidence.ts +377 -0
- package/packages/public-runtime/src/integration/commerce-broker.ts +497 -0
- package/packages/public-runtime/src/integration/consent-broker.ts +337 -0
- package/packages/public-runtime/src/integration/consent-cmp-demand.ts +115 -0
- package/packages/public-runtime/src/integration/consent-config.ts +260 -0
- package/packages/public-runtime/src/integration/consent-preview.ts +125 -0
- package/packages/public-runtime/src/integration/correlation-token.ts +444 -0
- package/packages/public-runtime/src/integration/csp-compiler.ts +267 -0
- package/packages/public-runtime/src/integration/csp.ts +105 -0
- package/packages/public-runtime/src/integration/digest.ts +43 -0
- package/packages/public-runtime/src/integration/environment.ts +228 -0
- package/packages/public-runtime/src/integration/events-catalog.ts +186 -0
- package/packages/public-runtime/src/integration/events.ts +701 -0
- package/packages/public-runtime/src/integration/g2-action-boundary.ts +106 -0
- package/packages/public-runtime/src/integration/index.ts +90 -0
- package/packages/public-runtime/src/integration/interim-bridge.ts +138 -0
- package/packages/public-runtime/src/integration/lifecycle-boot.ts +317 -0
- package/packages/public-runtime/src/integration/lifecycle-runtime.ts +393 -0
- package/packages/public-runtime/src/integration/lifecycle.ts +94 -0
- package/packages/public-runtime/src/integration/managed-analytics-api-v1-safety.d.mts +2 -0
- package/packages/public-runtime/src/integration/managed-analytics-api-v1-safety.mjs +10 -0
- package/packages/public-runtime/src/integration/managed-analytics-api-v1.schemas.ts +382 -0
- package/packages/public-runtime/src/integration/managed-analytics-api-v1.ts +684 -0
- package/packages/public-runtime/src/integration/managed-analytics-bridge.ts +383 -0
- package/packages/public-runtime/src/integration/managed-analytics-value-safety.ts +14 -0
- package/packages/public-runtime/src/integration/managed-analytics.ts +277 -0
- package/packages/public-runtime/src/integration/manifest.ts +470 -0
- package/packages/public-runtime/src/integration/native-amplitude.ts +362 -0
- package/packages/public-runtime/src/integration/native-ga4.ts +352 -0
- package/packages/public-runtime/src/integration/observability.ts +451 -0
- package/packages/public-runtime/src/integration/order-conversion.ts +0 -0
- package/packages/public-runtime/src/integration/phases.ts +182 -0
- package/packages/public-runtime/src/integration/plan.ts +112 -0
- package/packages/public-runtime/src/integration/platform-adapter-runtime.ts +146 -0
- package/packages/public-runtime/src/integration/platform-adapters.ts +671 -0
- package/packages/public-runtime/src/integration/promotion-gate.ts +451 -0
- package/packages/public-runtime/src/integration/provider-checkout-extension.ts +425 -0
- package/packages/public-runtime/src/integration/receipt-measurement.ts +370 -0
- package/packages/public-runtime/src/integration/regulated-parent-cert.ts +311 -0
- package/packages/public-runtime/src/integration/render-phases.ts +267 -0
- package/packages/public-runtime/src/integration/resolve.ts +465 -0
- package/packages/public-runtime/src/integration/result.ts +239 -0
- package/packages/public-runtime/src/integration/secrets.ts +92 -0
- package/packages/public-runtime/src/integration/tamper-evidence.ts +205 -0
- package/packages/public-runtime/src/integration/tamper-recovery.ts +127 -0
- package/packages/public-runtime/src/integration/version.ts +92 -0
- package/packages/public-runtime/src/integration-capabilities.ts +520 -0
- package/packages/public-runtime/src/membership.ts +2 -2
- package/packages/public-runtime/src/raw-html-policy.ts +2 -4
- package/packages/public-runtime/src/regulated-commerce/broker/consent-dedupe.ts +144 -0
- package/packages/public-runtime/src/regulated-commerce/correlation/contract.ts +177 -0
- package/packages/public-runtime/src/regulated-commerce/diagnostics/local-dispatch.ts +24 -0
- package/packages/public-runtime/src/regulated-commerce/diagnostics/read-model.ts +69 -0
- package/packages/public-runtime/src/regulated-commerce/dispatch/core.ts +134 -0
- package/packages/public-runtime/src/regulated-commerce/events/contract.ts +113 -0
- package/packages/public-runtime/src/regulated-commerce/ledger/core.ts +81 -0
- package/packages/public-runtime/src/regulated-commerce/mappings/ga4-ads.ts +87 -0
- package/packages/public-runtime/src/regulated-commerce/provider-order/bridge.ts +52 -0
- package/packages/public-runtime/src/regulated-commerce/purchase-truth/contract.ts +252 -0
- package/packages/public-runtime/src/regulated-commerce/sources/accepted-browser-operation.ts +67 -0
- package/packages/public-runtime/src/regulated-commerce/testing/fake-destination.ts +93 -0
- package/packages/public-runtime/src/static-bundle.ts +5 -5
- package/packages/public-runtime/src/tenant-assets.ts +143 -4
- package/packages/public-runtime/src/tenant.ts +136 -9
- package/packages/public-runtime/tests/fixtures/integration/browser-environment.example.json +8 -0
- package/packages/public-runtime/tests/fixtures/integration/commerce-event.example.json +44 -0
- package/packages/public-runtime/tests/fixtures/integration/commerce-order-event.example.json +44 -0
- package/packages/public-runtime/tests/fixtures/integration/compliance-assurance-record.example.json +50 -0
- package/packages/public-runtime/tests/fixtures/integration/integration-manifest-v2.example.json +120 -0
- package/packages/public-runtime/tests/fixtures/integration/managed-analytics-v1/fake-adapter-catalog.json +35 -0
- package/packages/public-runtime/tests/fixtures/integration/tenant-action-registry.example.json +11 -0
- package/packages/public-runtime/tests/fixtures/integration/tenant-local-example/README.md +22 -0
- package/packages/public-runtime/tests/fixtures/integration/tenant-local-example/entry.js +30 -0
- package/packages/public-runtime/tests/fixtures/integration/tenant-local-example/manifest.json +75 -0
- package/packages/public-runtime/tests/fixtures/integration/tenant-local-example/public-config.json +3 -0
- package/packages/public-runtime/tests/fixtures/regulated-commerce/fake-destinations.ts +38 -0
- package/packages/public-runtime/tests/gtm-migration/fixtures/gtm-sample-container-v84.provenance.json +29 -0
- package/packages/public-runtime/tests/gtm-migration/fixtures/gtm-sample-container-v84.redacted.json +3397 -0
- package/scripts/build/copy-tenant-assets.mjs +12 -5
- package/scripts/dev/ai-edit.mjs +2 -1
- package/scripts/dev/file-browser.mjs +2 -2
- package/scripts/dev/file-writer.mjs +2 -2
- package/scripts/dev/integration-guardrails.mjs +498 -0
- package/scripts/dev/safe-path.mjs +2 -2
- package/scripts/dev/tenant-source-root.mjs +3 -2
- package/scripts/tot-dev.mjs +5 -4
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The integration declaration — the ONE shared browser contract for both
|
|
3
|
+
* tenant-local configuration and managed apps (ADR 0014 C1
|
|
4
|
+
* `integration-schema-shared`, A1 `integration-apps-manifest-v2`).
|
|
5
|
+
*
|
|
6
|
+
* Promotion from a tenant-local declaration to a managed app changes ownership
|
|
7
|
+
* and packaging, never the browser contract: the same `validateIntegration
|
|
8
|
+
* Manifest` validates both forms identically. `origin` is provenance metadata
|
|
9
|
+
* only and does not alter validation.
|
|
10
|
+
*
|
|
11
|
+
* Executable content (the entry asset, contribution templates) is kept separate
|
|
12
|
+
* from tenant values (public config). No field is secret-bearing; the browser
|
|
13
|
+
* block is scanned for secret material as defense-in-depth.
|
|
14
|
+
*/
|
|
15
|
+
import type { ContractResult } from "./result.js";
|
|
16
|
+
import {
|
|
17
|
+
Violations,
|
|
18
|
+
reqObject,
|
|
19
|
+
childObject,
|
|
20
|
+
reqEnum,
|
|
21
|
+
reqLiteral,
|
|
22
|
+
reqString,
|
|
23
|
+
optString,
|
|
24
|
+
reqInt,
|
|
25
|
+
reqBool,
|
|
26
|
+
reqArray,
|
|
27
|
+
reqStringArray,
|
|
28
|
+
rejectUnknownKeys,
|
|
29
|
+
} from "./result.js";
|
|
30
|
+
import {
|
|
31
|
+
INTEGRATION_MANIFEST_SCHEMA_VERSION,
|
|
32
|
+
isCompatibleWithCurrentContract,
|
|
33
|
+
BROWSER_INTEGRATION_CONTRACT_VERSION,
|
|
34
|
+
} from "./version.js";
|
|
35
|
+
import {
|
|
36
|
+
RESERVED_PHASES,
|
|
37
|
+
VENDOR_ADDRESSABLE_PHASES,
|
|
38
|
+
EXECUTION_TIERS,
|
|
39
|
+
CONTRIBUTION_KINDS,
|
|
40
|
+
ENTRY_FORMATS,
|
|
41
|
+
validateContributionDag,
|
|
42
|
+
type ReservedPhase,
|
|
43
|
+
type ExecutionTier,
|
|
44
|
+
type ContributionKind,
|
|
45
|
+
type EntryFormat,
|
|
46
|
+
type DagNode,
|
|
47
|
+
type DagEdge,
|
|
48
|
+
} from "./phases.js";
|
|
49
|
+
import { validateCspSourceSet, type CspSourceSet } from "./csp.js";
|
|
50
|
+
import { isBrowserDeliverableEventType } from "./events.js";
|
|
51
|
+
import { findForbiddenFields } from "./secrets.js";
|
|
52
|
+
|
|
53
|
+
/** Where a declaration comes from. Provenance only — does not change validation. */
|
|
54
|
+
export const INTEGRATION_ORIGINS = [
|
|
55
|
+
"platform-adapter",
|
|
56
|
+
"tenant-local",
|
|
57
|
+
"managed-app",
|
|
58
|
+
] as const;
|
|
59
|
+
export type IntegrationOrigin = (typeof INTEGRATION_ORIGINS)[number];
|
|
60
|
+
|
|
61
|
+
export const CONSENT_LOAD_WHEN = [
|
|
62
|
+
"all-declared-purposes-eligible",
|
|
63
|
+
"essential-only",
|
|
64
|
+
] as const;
|
|
65
|
+
export type ConsentLoadWhen = (typeof CONSENT_LOAD_WHEN)[number];
|
|
66
|
+
|
|
67
|
+
export const DOM_INTENTS = [
|
|
68
|
+
"none",
|
|
69
|
+
"full-parent-authority-review-metadata-only",
|
|
70
|
+
] as const;
|
|
71
|
+
export type DomIntent = (typeof DOM_INTENTS)[number];
|
|
72
|
+
|
|
73
|
+
export const ASSURANCE_CLASSIFICATIONS = ["baseline", "elevated-supported"] as const;
|
|
74
|
+
export type AssuranceClassification = (typeof ASSURANCE_CLASSIFICATIONS)[number];
|
|
75
|
+
|
|
76
|
+
export const REGULATED_TENANT_DEFAULTS = ["disabled-until-certified", "enabled"] as const;
|
|
77
|
+
export type RegulatedTenantDefault = (typeof REGULATED_TENANT_DEFAULTS)[number];
|
|
78
|
+
|
|
79
|
+
export interface IntegrationAppIdentity {
|
|
80
|
+
id: string;
|
|
81
|
+
name: string;
|
|
82
|
+
version: string;
|
|
83
|
+
digest: string;
|
|
84
|
+
publisher: string;
|
|
85
|
+
supportUrl?: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface IntegrationCompatibility {
|
|
89
|
+
storefrontBrowserContract: string;
|
|
90
|
+
configurationSchemaVersion: number;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export interface IntegrationEntry {
|
|
94
|
+
asset: string;
|
|
95
|
+
format: EntryFormat;
|
|
96
|
+
phase: ReservedPhase;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface IntegrationContribution {
|
|
100
|
+
id: string;
|
|
101
|
+
phase: ReservedPhase;
|
|
102
|
+
kind: ContributionKind;
|
|
103
|
+
template: string;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export interface IntegrationDependency {
|
|
107
|
+
contribution: string;
|
|
108
|
+
after: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface IntegrationConsent {
|
|
112
|
+
purposes: string[];
|
|
113
|
+
loadWhen: ConsentLoadWhen;
|
|
114
|
+
/** Unknown consent state always blocks — fail closed. */
|
|
115
|
+
unknownState: "block";
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export interface IntegrationCsp {
|
|
119
|
+
profiles: string[];
|
|
120
|
+
sources: CspSourceSet;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface IntegrationPermissions {
|
|
124
|
+
events: string[];
|
|
125
|
+
data: string[];
|
|
126
|
+
actions: string[];
|
|
127
|
+
domIntent: DomIntent;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export interface PerformanceBudget {
|
|
131
|
+
maxTransferredBytes: number;
|
|
132
|
+
maxAdditionalRequests: number;
|
|
133
|
+
maxMainThreadMilliseconds: number;
|
|
134
|
+
mustBeAsyncOrDeferred: boolean;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export interface IntegrationBrowser {
|
|
138
|
+
executionTier: ExecutionTier;
|
|
139
|
+
entry: IntegrationEntry;
|
|
140
|
+
contributions: IntegrationContribution[];
|
|
141
|
+
dependencies: IntegrationDependency[];
|
|
142
|
+
publicConfigSchema: Record<string, unknown>;
|
|
143
|
+
consent: IntegrationConsent;
|
|
144
|
+
csp: IntegrationCsp;
|
|
145
|
+
permissions: IntegrationPermissions;
|
|
146
|
+
performanceBudget: PerformanceBudget;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface ServerSecretRequirement {
|
|
150
|
+
/** The NAME of a secret the server needs — never a value. */
|
|
151
|
+
name: string;
|
|
152
|
+
description?: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface IntegrationServer {
|
|
156
|
+
topics: string[];
|
|
157
|
+
secretRequirements: ServerSecretRequirement[];
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export interface IntegrationAssurance {
|
|
161
|
+
requestedClassification: AssuranceClassification;
|
|
162
|
+
regulatedTenantDefault: RegulatedTenantDefault;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export interface ConfigurationMigration {
|
|
166
|
+
from: number;
|
|
167
|
+
to: number;
|
|
168
|
+
migration: string;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export interface IntegrationManifest {
|
|
172
|
+
schemaVersion: typeof INTEGRATION_MANIFEST_SCHEMA_VERSION;
|
|
173
|
+
app: IntegrationAppIdentity;
|
|
174
|
+
compatibility: IntegrationCompatibility;
|
|
175
|
+
browser: IntegrationBrowser;
|
|
176
|
+
server: IntegrationServer;
|
|
177
|
+
assurance: IntegrationAssurance;
|
|
178
|
+
configurationMigrations: ConfigurationMigration[];
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const IMPLICIT_ENTRY_NODE = "entry";
|
|
182
|
+
|
|
183
|
+
export function validateIntegrationManifest(
|
|
184
|
+
input: unknown,
|
|
185
|
+
): ContractResult<IntegrationManifest> {
|
|
186
|
+
const v = new Violations();
|
|
187
|
+
const obj = reqObject(input, v, "");
|
|
188
|
+
if (!obj) return { ok: false, violations: v.items };
|
|
189
|
+
|
|
190
|
+
rejectUnknownKeys(
|
|
191
|
+
obj,
|
|
192
|
+
[
|
|
193
|
+
"schemaVersion",
|
|
194
|
+
"app",
|
|
195
|
+
"compatibility",
|
|
196
|
+
"browser",
|
|
197
|
+
"server",
|
|
198
|
+
"assurance",
|
|
199
|
+
"configurationMigrations",
|
|
200
|
+
],
|
|
201
|
+
v,
|
|
202
|
+
"",
|
|
203
|
+
);
|
|
204
|
+
|
|
205
|
+
reqLiteral(obj, "schemaVersion", INTEGRATION_MANIFEST_SCHEMA_VERSION, v, "");
|
|
206
|
+
validateApp(obj, v);
|
|
207
|
+
validateCompatibility(obj, v);
|
|
208
|
+
validateBrowser(obj, v);
|
|
209
|
+
validateServer(obj, v);
|
|
210
|
+
validateAssurance(obj, v);
|
|
211
|
+
validateConfigurationMigrations(obj, v);
|
|
212
|
+
|
|
213
|
+
// Defense-in-depth: the browser block must carry no secret material.
|
|
214
|
+
const browser = obj["browser"];
|
|
215
|
+
if (browser !== undefined) {
|
|
216
|
+
for (const violation of findForbiddenFields(browser, "browser")) v.items.push(violation);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
if (!v.ok) return { ok: false, violations: v.items };
|
|
220
|
+
return { ok: true, value: input as IntegrationManifest };
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function validateApp(obj: Record<string, unknown>, v: Violations): void {
|
|
224
|
+
const app = childObject(obj, "app", v, "");
|
|
225
|
+
if (!app) return;
|
|
226
|
+
rejectUnknownKeys(
|
|
227
|
+
app,
|
|
228
|
+
["id", "name", "version", "digest", "publisher", "supportUrl"],
|
|
229
|
+
v,
|
|
230
|
+
"app",
|
|
231
|
+
);
|
|
232
|
+
reqString(app, "id", v, "app");
|
|
233
|
+
reqString(app, "name", v, "app");
|
|
234
|
+
reqString(app, "version", v, "app");
|
|
235
|
+
reqString(app, "digest", v, "app");
|
|
236
|
+
reqString(app, "publisher", v, "app");
|
|
237
|
+
optString(app, "supportUrl", v, "app");
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function validateCompatibility(obj: Record<string, unknown>, v: Violations): void {
|
|
241
|
+
const compat = childObject(obj, "compatibility", v, "");
|
|
242
|
+
if (!compat) return;
|
|
243
|
+
rejectUnknownKeys(
|
|
244
|
+
compat,
|
|
245
|
+
["storefrontBrowserContract", "configurationSchemaVersion"],
|
|
246
|
+
v,
|
|
247
|
+
"compatibility",
|
|
248
|
+
);
|
|
249
|
+
const range = reqString(compat, "storefrontBrowserContract", v, "compatibility");
|
|
250
|
+
reqInt(compat, "configurationSchemaVersion", v, "compatibility");
|
|
251
|
+
// Fail closed: an unparseable range and an out-of-range current contract are
|
|
252
|
+
// both rejected (`satisfiesRange` returns false for either).
|
|
253
|
+
if (range !== undefined && !isCompatibleWithCurrentContract(range)) {
|
|
254
|
+
v.add(
|
|
255
|
+
"compatibility.storefrontBrowserContract",
|
|
256
|
+
"incompatible",
|
|
257
|
+
`The current browser contract ${BROWSER_INTEGRATION_CONTRACT_VERSION} does not satisfy "${range}" (unparseable ranges also fail closed).`,
|
|
258
|
+
);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function validateBrowser(obj: Record<string, unknown>, v: Violations): void {
|
|
263
|
+
const browser = childObject(obj, "browser", v, "");
|
|
264
|
+
if (!browser) return;
|
|
265
|
+
rejectUnknownKeys(
|
|
266
|
+
browser,
|
|
267
|
+
[
|
|
268
|
+
"executionTier",
|
|
269
|
+
"entry",
|
|
270
|
+
"contributions",
|
|
271
|
+
"dependencies",
|
|
272
|
+
"publicConfigSchema",
|
|
273
|
+
"consent",
|
|
274
|
+
"csp",
|
|
275
|
+
"permissions",
|
|
276
|
+
"performanceBudget",
|
|
277
|
+
],
|
|
278
|
+
v,
|
|
279
|
+
"browser",
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
reqEnum(browser, "executionTier", EXECUTION_TIERS, v, "browser");
|
|
283
|
+
|
|
284
|
+
const dagNodes: DagNode[] = [];
|
|
285
|
+
const dagEdges: DagEdge[] = [];
|
|
286
|
+
|
|
287
|
+
const entry = childObject(browser, "entry", v, "browser");
|
|
288
|
+
if (entry) {
|
|
289
|
+
rejectUnknownKeys(entry, ["asset", "format", "phase"], v, "browser.entry");
|
|
290
|
+
reqString(entry, "asset", v, "browser.entry");
|
|
291
|
+
reqEnum(entry, "format", ENTRY_FORMATS, v, "browser.entry");
|
|
292
|
+
const phase = reqEnum(entry, "phase", VENDOR_ADDRESSABLE_PHASES, v, "browser.entry");
|
|
293
|
+
if (phase) dagNodes.push({ id: IMPLICIT_ENTRY_NODE, phase });
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
const contributions = reqArray(browser, "contributions", v, "browser");
|
|
297
|
+
if (contributions) {
|
|
298
|
+
contributions.forEach((raw, i) => {
|
|
299
|
+
const path = `browser.contributions[${i}]`;
|
|
300
|
+
const contribution = reqObject(raw, v, path);
|
|
301
|
+
if (!contribution) return;
|
|
302
|
+
rejectUnknownKeys(contribution, ["id", "phase", "kind", "template"], v, path);
|
|
303
|
+
const id = reqString(contribution, "id", v, path);
|
|
304
|
+
const phase = reqEnum(contribution, "phase", VENDOR_ADDRESSABLE_PHASES, v, path);
|
|
305
|
+
reqEnum(contribution, "kind", CONTRIBUTION_KINDS, v, path);
|
|
306
|
+
reqString(contribution, "template", v, path);
|
|
307
|
+
if (id && phase) dagNodes.push({ id, phase });
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
const dependencies = reqArray(browser, "dependencies", v, "browser");
|
|
312
|
+
if (dependencies) {
|
|
313
|
+
dependencies.forEach((raw, i) => {
|
|
314
|
+
const path = `browser.dependencies[${i}]`;
|
|
315
|
+
const dependency = reqObject(raw, v, path);
|
|
316
|
+
if (!dependency) return;
|
|
317
|
+
rejectUnknownKeys(dependency, ["contribution", "after"], v, path);
|
|
318
|
+
const contribution = reqString(dependency, "contribution", v, path);
|
|
319
|
+
const after = reqString(dependency, "after", v, path);
|
|
320
|
+
if (contribution && after) {
|
|
321
|
+
dagEdges.push({ dependent: contribution, prerequisite: after });
|
|
322
|
+
}
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
validateContributionDag(dagNodes, dagEdges, v, "browser");
|
|
327
|
+
validatePublicConfigSchema(browser["publicConfigSchema"], v, "browser.publicConfigSchema");
|
|
328
|
+
validateConsent(browser, v);
|
|
329
|
+
validateCsp(browser, v);
|
|
330
|
+
validatePermissions(browser, v);
|
|
331
|
+
validatePerformanceBudget(browser, v);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/**
|
|
335
|
+
* The public config schema must be a CLOSED object schema (`additionalProperties:
|
|
336
|
+
* false`) with only primitive-typed properties — so a tenant cannot smuggle
|
|
337
|
+
* unknown or nested executable values into browser config.
|
|
338
|
+
*/
|
|
339
|
+
function validatePublicConfigSchema(value: unknown, v: Violations, path: string): void {
|
|
340
|
+
const schema = reqObject(value, v, path);
|
|
341
|
+
if (!schema) return;
|
|
342
|
+
if (schema["type"] !== "object") {
|
|
343
|
+
v.add(`${path}.type`, "type", 'publicConfigSchema.type must be "object".');
|
|
344
|
+
}
|
|
345
|
+
if (schema["additionalProperties"] !== false) {
|
|
346
|
+
v.add(
|
|
347
|
+
`${path}.additionalProperties`,
|
|
348
|
+
"open_config",
|
|
349
|
+
"publicConfigSchema.additionalProperties must be false; tenant config is closed.",
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
if ("required" in schema) reqStringArray(schema, "required", v, path);
|
|
353
|
+
const properties = schema["properties"];
|
|
354
|
+
if (properties !== undefined) {
|
|
355
|
+
const props = reqObject(properties, v, `${path}.properties`);
|
|
356
|
+
if (props) {
|
|
357
|
+
const allowedTypes = new Set(["string", "number", "integer", "boolean"]);
|
|
358
|
+
for (const [name, propValue] of Object.entries(props)) {
|
|
359
|
+
const propPath = `${path}.properties.${name}`;
|
|
360
|
+
const prop = reqObject(propValue, v, propPath);
|
|
361
|
+
if (!prop) continue;
|
|
362
|
+
if (typeof prop["type"] !== "string" || !allowedTypes.has(prop["type"])) {
|
|
363
|
+
v.add(`${propPath}.type`, "type", "Property type must be string, number, integer, or boolean.");
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function validateConsent(browser: Record<string, unknown>, v: Violations): void {
|
|
371
|
+
const consent = childObject(browser, "consent", v, "browser");
|
|
372
|
+
if (!consent) return;
|
|
373
|
+
rejectUnknownKeys(consent, ["purposes", "loadWhen", "unknownState"], v, "browser.consent");
|
|
374
|
+
reqStringArray(consent, "purposes", v, "browser.consent");
|
|
375
|
+
reqEnum(consent, "loadWhen", CONSENT_LOAD_WHEN, v, "browser.consent");
|
|
376
|
+
// Unknown consent state must be block — fail closed by construction.
|
|
377
|
+
reqLiteral(consent, "unknownState", "block", v, "browser.consent");
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function validateCsp(browser: Record<string, unknown>, v: Violations): void {
|
|
381
|
+
const csp = childObject(browser, "csp", v, "browser");
|
|
382
|
+
if (!csp) return;
|
|
383
|
+
rejectUnknownKeys(csp, ["profiles", "sources"], v, "browser.csp");
|
|
384
|
+
reqStringArray(csp, "profiles", v, "browser.csp");
|
|
385
|
+
validateCspSourceSet(csp["sources"], v, "browser.csp.sources");
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function validatePermissions(browser: Record<string, unknown>, v: Violations): void {
|
|
389
|
+
const permissions = childObject(browser, "permissions", v, "browser");
|
|
390
|
+
if (!permissions) return;
|
|
391
|
+
rejectUnknownKeys(permissions, ["events", "data", "actions", "domIntent"], v, "browser.permissions");
|
|
392
|
+
const events = reqStringArray(permissions, "events", v, "browser.permissions");
|
|
393
|
+
// A declared event subscription is a CAPABILITY, not review-only metadata: every
|
|
394
|
+
// entry must be a released, browser-DELIVERABLE event (browser source-of-truth).
|
|
395
|
+
// An unknown name, a reserved/forward-declared type, and a verified-provider
|
|
396
|
+
// (server-authoritative) type are all rejected here — fail closed — so a typo'd or
|
|
397
|
+
// impossible subscription can never validate clean and then silently never fire.
|
|
398
|
+
// The wiring layer (lifecycle-runtime's scoped subscribe handle) can therefore
|
|
399
|
+
// trust that every declared event is one it can actually deliver.
|
|
400
|
+
if (events) {
|
|
401
|
+
events.forEach((type, i) => {
|
|
402
|
+
if (!isBrowserDeliverableEventType(type)) {
|
|
403
|
+
v.add(
|
|
404
|
+
`browser.permissions.events[${i}]`,
|
|
405
|
+
"unsubscribable_event",
|
|
406
|
+
`"${type}" is not a browser-deliverable event; declare only released browser source-of-truth events (unknown, reserved, and verified-provider types cannot be delivered to a browser subscriber).`,
|
|
407
|
+
);
|
|
408
|
+
}
|
|
409
|
+
});
|
|
410
|
+
}
|
|
411
|
+
reqStringArray(permissions, "data", v, "browser.permissions");
|
|
412
|
+
reqStringArray(permissions, "actions", v, "browser.permissions");
|
|
413
|
+
reqEnum(permissions, "domIntent", DOM_INTENTS, v, "browser.permissions");
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
function validatePerformanceBudget(browser: Record<string, unknown>, v: Violations): void {
|
|
417
|
+
const budget = childObject(browser, "performanceBudget", v, "browser");
|
|
418
|
+
if (!budget) return;
|
|
419
|
+
rejectUnknownKeys(
|
|
420
|
+
budget,
|
|
421
|
+
["maxTransferredBytes", "maxAdditionalRequests", "maxMainThreadMilliseconds", "mustBeAsyncOrDeferred"],
|
|
422
|
+
v,
|
|
423
|
+
"browser.performanceBudget",
|
|
424
|
+
);
|
|
425
|
+
reqInt(budget, "maxTransferredBytes", v, "browser.performanceBudget");
|
|
426
|
+
reqInt(budget, "maxAdditionalRequests", v, "browser.performanceBudget");
|
|
427
|
+
reqInt(budget, "maxMainThreadMilliseconds", v, "browser.performanceBudget");
|
|
428
|
+
reqBool(budget, "mustBeAsyncOrDeferred", v, "browser.performanceBudget");
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
function validateServer(obj: Record<string, unknown>, v: Violations): void {
|
|
432
|
+
const server = childObject(obj, "server", v, "");
|
|
433
|
+
if (!server) return;
|
|
434
|
+
rejectUnknownKeys(server, ["topics", "secretRequirements"], v, "server");
|
|
435
|
+
reqStringArray(server, "topics", v, "server");
|
|
436
|
+
const requirements = reqArray(server, "secretRequirements", v, "server");
|
|
437
|
+
if (requirements) {
|
|
438
|
+
requirements.forEach((raw, i) => {
|
|
439
|
+
const path = `server.secretRequirements[${i}]`;
|
|
440
|
+
const requirement = reqObject(raw, v, path);
|
|
441
|
+
if (!requirement) return;
|
|
442
|
+
// Names + descriptions only. A value-bearing key is a secret leak.
|
|
443
|
+
rejectUnknownKeys(requirement, ["name", "description"], v, path);
|
|
444
|
+
reqString(requirement, "name", v, path);
|
|
445
|
+
optString(requirement, "description", v, path);
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
function validateAssurance(obj: Record<string, unknown>, v: Violations): void {
|
|
451
|
+
const assurance = childObject(obj, "assurance", v, "");
|
|
452
|
+
if (!assurance) return;
|
|
453
|
+
rejectUnknownKeys(assurance, ["requestedClassification", "regulatedTenantDefault"], v, "assurance");
|
|
454
|
+
reqEnum(assurance, "requestedClassification", ASSURANCE_CLASSIFICATIONS, v, "assurance");
|
|
455
|
+
reqEnum(assurance, "regulatedTenantDefault", REGULATED_TENANT_DEFAULTS, v, "assurance");
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
function validateConfigurationMigrations(obj: Record<string, unknown>, v: Violations): void {
|
|
459
|
+
const migrations = reqArray(obj, "configurationMigrations", v, "");
|
|
460
|
+
if (!migrations) return;
|
|
461
|
+
migrations.forEach((raw, i) => {
|
|
462
|
+
const path = `configurationMigrations[${i}]`;
|
|
463
|
+
const migration = reqObject(raw, v, path);
|
|
464
|
+
if (!migration) return;
|
|
465
|
+
rejectUnknownKeys(migration, ["from", "to", "migration"], v, path);
|
|
466
|
+
reqInt(migration, "from", v, path);
|
|
467
|
+
reqInt(migration, "to", v, path);
|
|
468
|
+
reqString(migration, "migration", v, path);
|
|
469
|
+
});
|
|
470
|
+
}
|