@aglyn/aglyn 1.0.0-beta.217 → 1.0.0-beta.219
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/package.json +14 -14
- package/src/lib/app-utils/actions.d.ts +25 -374
- package/src/lib/app-utils/actions.js +101 -561
- package/src/lib/app-utils/actions.js.map +1 -1
- package/src/lib/app-utils/activity-presenter.d.ts +3 -3
- package/src/lib/app-utils/activity-presenter.js +36 -52
- package/src/lib/app-utils/activity-presenter.js.map +1 -1
- package/src/lib/app-utils/admin-audit-index.js +2 -2
- package/src/lib/app-utils/admin-audit-index.js.map +1 -1
- package/src/lib/app-utils/analytics-events.d.ts +11 -2
- package/src/lib/app-utils/analytics-events.js +11 -2
- package/src/lib/app-utils/analytics-events.js.map +1 -1
- package/src/lib/app-utils/analytics-provider.d.ts +182 -0
- package/src/lib/app-utils/analytics-provider.js +133 -0
- package/src/lib/app-utils/analytics-provider.js.map +1 -0
- package/src/lib/app-utils/api-plugins.d.ts +46 -0
- package/src/lib/app-utils/api-plugins.js +19 -0
- package/src/lib/app-utils/api-plugins.js.map +1 -1
- package/src/lib/app-utils/{marketplace-overrides.d.ts → artifact-overrides.d.ts} +9 -6
- package/src/lib/app-utils/{marketplace-overrides.js → artifact-overrides.js} +10 -7
- package/src/lib/app-utils/artifact-overrides.js.map +1 -0
- package/src/lib/app-utils/{marketplace-provenance.d.ts → artifact-provenance.d.ts} +12 -10
- package/src/lib/app-utils/{marketplace-provenance.js → artifact-provenance.js} +9 -7
- package/src/lib/app-utils/artifact-provenance.js.map +1 -0
- package/src/lib/app-utils/assist-credits.js +2 -1
- package/src/lib/app-utils/assist-credits.js.map +1 -1
- package/src/lib/app-utils/binding-token-catalog.d.ts +5 -13
- package/src/lib/app-utils/binding-token-catalog.js +17 -41
- package/src/lib/app-utils/binding-token-catalog.js.map +1 -1
- package/src/lib/app-utils/binding-tokens.js +1 -1
- package/src/lib/app-utils/binding-tokens.js.map +1 -1
- package/src/lib/app-utils/brand-support-line.d.ts +36 -0
- package/src/lib/app-utils/brand-support-line.js +38 -0
- package/src/lib/app-utils/brand-support-line.js.map +1 -0
- package/src/lib/app-utils/campaign-touch.d.ts +5 -5
- package/src/lib/app-utils/campaign-touch.js +8 -8
- package/src/lib/app-utils/campaign-touch.js.map +1 -1
- package/src/lib/app-utils/collection-entries.d.ts +2 -2
- package/src/lib/app-utils/collection-entries.js.map +1 -1
- package/src/lib/app-utils/consent-group-change.d.ts +4 -0
- package/src/lib/app-utils/consent-group-change.js.map +1 -1
- package/src/lib/app-utils/console-record-links.d.ts +10 -89
- package/src/lib/app-utils/console-record-links.js +3 -107
- package/src/lib/app-utils/console-record-links.js.map +1 -1
- package/src/lib/app-utils/console-routes.d.ts +16 -7
- package/src/lib/app-utils/console-routes.js +9 -3
- package/src/lib/app-utils/console-routes.js.map +1 -1
- package/src/lib/app-utils/contacts.d.ts +23 -1
- package/src/lib/app-utils/contacts.js +21 -5
- package/src/lib/app-utils/contacts.js.map +1 -1
- package/src/lib/app-utils/cross-pool-desync.d.ts +39 -0
- package/src/lib/app-utils/cross-pool-desync.js +47 -0
- package/src/lib/app-utils/cross-pool-desync.js.map +1 -0
- package/src/lib/app-utils/csv-upload.d.ts +29 -0
- package/src/lib/app-utils/csv-upload.js +29 -0
- package/src/lib/app-utils/csv-upload.js.map +1 -0
- package/src/lib/app-utils/dataset-models.d.ts +5 -5
- package/src/lib/app-utils/dataset-models.js +19 -2
- package/src/lib/app-utils/dataset-models.js.map +1 -1
- package/src/lib/app-utils/datasets.d.ts +65 -11
- package/src/lib/app-utils/datasets.js +74 -11
- package/src/lib/app-utils/datasets.js.map +1 -1
- package/src/lib/app-utils/docs-deflection.d.ts +6 -6
- package/src/lib/app-utils/docs-deflection.js.map +1 -1
- package/src/lib/app-utils/docs-help.generated.d.ts +12 -6
- package/src/lib/app-utils/docs-help.generated.js +21 -6
- package/src/lib/app-utils/docs-help.generated.js.map +1 -1
- package/src/lib/app-utils/docs-index.generated.d.ts +2 -2
- package/src/lib/app-utils/docs-index.generated.js +514 -318
- package/src/lib/app-utils/docs-index.generated.js.map +1 -1
- package/src/lib/app-utils/docs-retrieval.d.ts +3 -3
- package/src/lib/app-utils/docs-retrieval.js +14 -10
- package/src/lib/app-utils/docs-retrieval.js.map +1 -1
- package/src/lib/app-utils/duplicate-resource.d.ts +4 -1
- package/src/lib/app-utils/duplicate-resource.js +7 -4
- package/src/lib/app-utils/duplicate-resource.js.map +1 -1
- package/src/lib/app-utils/dynamic-list-rule.d.ts +1 -1
- package/src/lib/app-utils/dynamic-list-rule.js.map +1 -1
- package/src/lib/app-utils/element-ui.d.ts +1 -1
- package/src/lib/app-utils/element-ui.js +1 -1
- package/src/lib/app-utils/element-ui.js.map +1 -1
- package/src/lib/app-utils/email-starter-policy.js +3 -3
- package/src/lib/app-utils/email-starter-policy.js.map +1 -1
- package/src/lib/app-utils/entity-picker-context.d.ts +10 -5
- package/src/lib/app-utils/entity-picker-context.js.map +1 -1
- package/src/lib/app-utils/error-beacon.d.ts +75 -6
- package/src/lib/app-utils/error-beacon.js +160 -21
- package/src/lib/app-utils/error-beacon.js.map +1 -1
- package/src/lib/app-utils/expand-repeatables.d.ts +10 -10
- package/src/lib/app-utils/expand-repeatables.js +10 -10
- package/src/lib/app-utils/expand-repeatables.js.map +1 -1
- package/src/lib/app-utils/host-events.d.ts +82 -0
- package/src/lib/app-utils/host-events.js +62 -0
- package/src/lib/app-utils/host-events.js.map +1 -0
- package/src/lib/app-utils/lockdown.d.ts +33 -1
- package/src/lib/app-utils/lockdown.js +45 -4
- package/src/lib/app-utils/lockdown.js.map +1 -1
- package/src/lib/app-utils/margin-utilization.d.ts +4 -69
- package/src/lib/app-utils/margin-utilization.js +82 -69
- package/src/lib/app-utils/margin-utilization.js.map +1 -1
- package/src/lib/app-utils/node-definition-sanitizer.d.ts +16 -16
- package/src/lib/app-utils/node-definition-sanitizer.js +24 -20
- package/src/lib/app-utils/node-definition-sanitizer.js.map +1 -1
- package/src/lib/app-utils/node-interactions.d.ts +7 -7
- package/src/lib/app-utils/node-interactions.js.map +1 -1
- package/src/lib/app-utils/notifications.d.ts +78 -47
- package/src/lib/app-utils/notifications.js +63 -44
- package/src/lib/app-utils/notifications.js.map +1 -1
- package/src/lib/app-utils/payments-configured.d.ts +8 -21
- package/src/lib/app-utils/payments-configured.js +8 -23
- package/src/lib/app-utils/payments-configured.js.map +1 -1
- package/src/lib/app-utils/plan-entitlements.d.ts +43 -128
- package/src/lib/app-utils/plan-entitlements.js +145 -304
- package/src/lib/app-utils/plan-entitlements.js.map +1 -1
- package/src/lib/app-utils/platform-brand.d.ts +10 -0
- package/src/lib/app-utils/platform-brand.js +14 -3
- package/src/lib/app-utils/platform-brand.js.map +1 -1
- package/src/lib/app-utils/plugin-api-rate-limit.d.ts +7 -1
- package/src/lib/app-utils/plugin-api-rate-limit.js +11 -3
- package/src/lib/app-utils/plugin-api-rate-limit.js.map +1 -1
- package/src/lib/app-utils/plugin-bundle-checks.js +2 -2
- package/src/lib/app-utils/plugin-bundle-checks.js.map +1 -1
- package/src/lib/app-utils/plugin-host-events.generated.d.ts +12 -0
- package/src/lib/app-utils/plugin-host-events.generated.js +169 -0
- package/src/lib/app-utils/plugin-host-events.generated.js.map +1 -0
- package/src/lib/app-utils/plugin-release-flags.generated.d.ts +12 -0
- package/src/lib/app-utils/plugin-release-flags.generated.js +106 -0
- package/src/lib/app-utils/plugin-release-flags.generated.js.map +1 -0
- package/src/lib/app-utils/realm-host-surface.generated.js +2 -0
- package/src/lib/app-utils/realm-host-surface.generated.js.map +1 -1
- package/src/lib/app-utils/release-flags.d.ts +14 -5
- package/src/lib/app-utils/release-flags.js +21 -125
- package/src/lib/app-utils/release-flags.js.map +1 -1
- package/src/lib/app-utils/repeat-sources.d.ts +9 -0
- package/src/lib/app-utils/repeat-sources.js.map +1 -1
- package/src/lib/app-utils/retained-refusals.d.ts +73 -0
- package/src/lib/app-utils/retained-refusals.js +186 -0
- package/src/lib/app-utils/retained-refusals.js.map +1 -0
- package/src/lib/app-utils/scope-tokens.d.ts +27 -0
- package/src/lib/app-utils/scope-tokens.js +61 -0
- package/src/lib/app-utils/scope-tokens.js.map +1 -1
- package/src/lib/app-utils/screen-link-context.js +3 -3
- package/src/lib/app-utils/screen-link-context.js.map +1 -1
- package/src/lib/app-utils/screen-route.d.ts +15 -0
- package/src/lib/app-utils/screen-route.js +21 -1
- package/src/lib/app-utils/screen-route.js.map +1 -1
- package/src/lib/app-utils/seo-audit.d.ts +132 -0
- package/src/lib/app-utils/seo-audit.js +246 -0
- package/src/lib/app-utils/seo-audit.js.map +1 -0
- package/src/lib/app-utils/seo-keywords.d.ts +48 -0
- package/src/lib/app-utils/seo-keywords.js +60 -0
- package/src/lib/app-utils/seo-keywords.js.map +1 -0
- package/src/lib/app-utils/seo-page-facts.d.ts +66 -0
- package/src/lib/app-utils/seo-page-facts.js +155 -0
- package/src/lib/app-utils/seo-page-facts.js.map +1 -0
- package/src/lib/app-utils/seo-site-scan.d.ts +126 -0
- package/src/lib/app-utils/seo-site-scan.js +162 -0
- package/src/lib/app-utils/seo-site-scan.js.map +1 -0
- package/src/lib/app-utils/seo-title-variables.js +1 -1
- package/src/lib/app-utils/seo-title-variables.js.map +1 -1
- package/src/lib/app-utils/server.d.ts +6 -9
- package/src/lib/app-utils/server.js +17 -27
- package/src/lib/app-utils/server.js.map +1 -1
- package/src/lib/app-utils/site-interactions.d.ts +501 -0
- package/src/lib/app-utils/site-interactions.js +554 -0
- package/src/lib/app-utils/site-interactions.js.map +1 -0
- package/src/lib/app-utils/{marketplace-theme.d.ts → site-theme.d.ts} +13 -2
- package/src/lib/app-utils/{marketplace-theme.js → site-theme.js} +5 -2
- package/src/lib/app-utils/site-theme.js.map +1 -0
- package/src/lib/app-utils/sitemap.d.ts +4 -3
- package/src/lib/app-utils/sitemap.js +9 -7
- package/src/lib/app-utils/sitemap.js.map +1 -1
- package/src/lib/app-utils/stale-build-error.d.ts +51 -0
- package/src/lib/app-utils/stale-build-error.js +100 -1
- package/src/lib/app-utils/stale-build-error.js.map +1 -1
- package/src/lib/app-utils/starter-templates.d.ts +20 -0
- package/src/lib/app-utils/starter-templates.js +49 -0
- package/src/lib/app-utils/starter-templates.js.map +1 -1
- package/src/lib/app-utils/tax-jurisdiction-figures.d.ts +118 -0
- package/src/lib/app-utils/tax-jurisdiction-figures.js +123 -0
- package/src/lib/app-utils/tax-jurisdiction-figures.js.map +1 -0
- package/src/lib/app-utils/theme-library.d.ts +10 -3
- package/src/lib/app-utils/theme-library.js +13 -4
- package/src/lib/app-utils/theme-library.js.map +1 -1
- package/src/lib/app-utils/{campaign-attribution.d.ts → utm-attribution.d.ts} +11 -6
- package/src/lib/app-utils/{campaign-attribution.js → utm-attribution.js} +13 -8
- package/src/lib/app-utils/utm-attribution.js.map +1 -0
- package/src/lib/app-utils/{campaign-forwarding.d.ts → utm-forwarding.d.ts} +14 -14
- package/src/lib/app-utils/{campaign-forwarding.js → utm-forwarding.js} +26 -26
- package/src/lib/app-utils/utm-forwarding.js.map +1 -0
- package/src/lib/app-utils/video-object.js +6 -5
- package/src/lib/app-utils/video-object.js.map +1 -1
- package/src/lib/app-utils/visitor-consent.d.ts +41 -164
- package/src/lib/app-utils/visitor-consent.js +66 -277
- package/src/lib/app-utils/visitor-consent.js.map +1 -1
- package/src/lib/app-utils/web-vitals-rum.d.ts +7 -7
- package/src/lib/app-utils/web-vitals-rum.js +31 -63
- package/src/lib/app-utils/web-vitals-rum.js.map +1 -1
- package/src/lib/app-utils/where-used.d.ts +11 -6
- package/src/lib/app-utils/where-used.js +3 -8
- package/src/lib/app-utils/where-used.js.map +1 -1
- package/src/lib/canvas-manager/canvas-manager.js +3 -3
- package/src/lib/canvas-manager/canvas-manager.js.map +1 -1
- package/src/lib/foundation/definitions/components.types.d.ts +1 -1
- package/src/lib/foundation/definitions/components.types.js +1 -1
- package/src/lib/foundation/definitions/components.types.js.map +1 -1
- package/src/lib/foundation/definitions/org-billing.types.d.ts +18 -135
- package/src/lib/foundation/definitions/org-billing.types.js.map +1 -1
- package/src/lib/foundation/definitions/organization.types.d.ts +6 -3
- package/src/lib/foundation/definitions/organization.types.js.map +1 -1
- package/src/lib/foundation/definitions/platform.types.d.ts +27 -5
- package/src/lib/foundation/definitions/platform.types.js.map +1 -1
- package/src/lib/foundation/definitions/write-deny-coverage.util.d.ts +16 -0
- package/src/lib/foundation/definitions/write-deny-coverage.util.js +20 -0
- package/src/lib/foundation/definitions/write-deny-coverage.util.js.map +1 -1
- package/src/lib/foundation/index.d.ts +1 -1
- package/src/lib/foundation/index.js.map +1 -1
- package/src/lib/plugin-manager/besigner-documents.d.ts +96 -0
- package/src/lib/plugin-manager/besigner-documents.js +61 -0
- package/src/lib/plugin-manager/besigner-documents.js.map +1 -0
- package/src/lib/plugin-manager/computed-variables.d.ts +71 -0
- package/src/lib/plugin-manager/computed-variables.js +74 -0
- package/src/lib/plugin-manager/computed-variables.js.map +1 -0
- package/src/lib/plugin-manager/custom-fields.d.ts +29 -2
- package/src/lib/plugin-manager/custom-fields.js +47 -1
- package/src/lib/plugin-manager/custom-fields.js.map +1 -1
- package/src/lib/plugin-manager/feature-plugins.d.ts +292 -20
- package/src/lib/plugin-manager/feature-plugins.js +105 -17
- package/src/lib/plugin-manager/feature-plugins.js.map +1 -1
- package/src/lib/plugin-manager/first-party-plugins.generated.d.ts +123 -0
- package/src/lib/plugin-manager/first-party-plugins.generated.js +785 -14
- package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
- package/src/lib/plugin-manager/plugin-activity-actions.d.ts +12 -0
- package/src/lib/plugin-manager/plugin-activity-actions.js +25 -0
- package/src/lib/plugin-manager/plugin-activity-actions.js.map +1 -1
- package/src/lib/plugin-manager/plugin-contributions.d.ts +1 -1
- package/src/lib/plugin-manager/plugin-contributions.js.map +1 -1
- package/src/lib/plugin-manager/plugin-declarations-repair.d.ts +36 -0
- package/src/lib/plugin-manager/plugin-declarations-repair.js +64 -0
- package/src/lib/plugin-manager/plugin-declarations-repair.js.map +1 -0
- package/src/lib/plugin-manager/plugin-dependents.d.ts +101 -0
- package/src/lib/plugin-manager/plugin-dependents.js +75 -0
- package/src/lib/plugin-manager/plugin-dependents.js.map +1 -0
- package/src/lib/plugin-manager/plugin-distribution.d.ts +55 -0
- package/src/lib/plugin-manager/plugin-distribution.js +45 -0
- package/src/lib/plugin-manager/plugin-distribution.js.map +1 -0
- package/src/lib/plugin-manager/plugin-host-collections.d.ts +17 -0
- package/src/lib/plugin-manager/plugin-host-collections.js +6 -0
- package/src/lib/plugin-manager/plugin-host-collections.js.map +1 -1
- package/src/lib/plugin-manager/plugin-host-resources.d.ts +133 -0
- package/src/lib/plugin-manager/plugin-host-resources.js +52 -0
- package/src/lib/plugin-manager/plugin-host-resources.js.map +1 -0
- package/src/lib/plugin-manager/plugin-org-erasure.d.ts +28 -2
- package/src/lib/plugin-manager/plugin-org-erasure.js +61 -2
- package/src/lib/plugin-manager/plugin-org-erasure.js.map +1 -1
- package/src/lib/plugin-manager/plugin-plan-entitlements.d.ts +123 -0
- package/src/lib/plugin-manager/plugin-plan-entitlements.js +101 -0
- package/src/lib/plugin-manager/plugin-plan-entitlements.js.map +1 -0
- package/src/lib/plugin-manager/plugin-record-index.d.ts +95 -0
- package/src/lib/plugin-manager/plugin-record-index.js +51 -0
- package/src/lib/plugin-manager/plugin-record-index.js.map +1 -0
- package/src/lib/plugin-manager/plugin-record-written.d.ts +58 -0
- package/src/lib/plugin-manager/plugin-record-written.js +42 -0
- package/src/lib/plugin-manager/plugin-record-written.js.map +1 -0
- package/src/lib/plugin-manager/plugin-revenue-sources.d.ts +213 -0
- package/src/lib/plugin-manager/plugin-revenue-sources.js +194 -0
- package/src/lib/plugin-manager/plugin-revenue-sources.js.map +1 -0
- package/src/lib/plugin-manager/plugin-site-bundle.d.ts +145 -0
- package/src/lib/plugin-manager/plugin-site-bundle.js +78 -0
- package/src/lib/plugin-manager/plugin-site-bundle.js.map +1 -0
- package/src/lib/plugin-manager/plugin-site-cache.d.ts +12 -0
- package/src/lib/plugin-manager/plugin-site-cache.js.map +1 -1
- package/src/lib/plugin-manager/plugin-site-export.d.ts +81 -0
- package/src/lib/plugin-manager/plugin-site-export.js +40 -0
- package/src/lib/plugin-manager/plugin-site-export.js.map +1 -0
- package/src/lib/plugin-manager/plugin-sitemap-sections.d.ts +88 -0
- package/src/lib/plugin-manager/plugin-sitemap-sections.js +29 -0
- package/src/lib/plugin-manager/plugin-sitemap-sections.js.map +1 -0
- package/src/lib/plugin-manager/plugin-tax-profile.d.ts +20 -4
- package/src/lib/plugin-manager/plugin-tax-profile.js.map +1 -1
- package/src/lib/plugin-manager/plugin-tax-return-sources.d.ts +255 -0
- package/src/lib/plugin-manager/plugin-tax-return-sources.js +191 -0
- package/src/lib/plugin-manager/plugin-tax-return-sources.js.map +1 -0
- package/src/lib/plugin-manager/plugin-template-sources.d.ts +75 -0
- package/src/lib/plugin-manager/plugin-template-sources.js +37 -0
- package/src/lib/plugin-manager/plugin-template-sources.js.map +1 -0
- package/src/lib/plugin-manager/plugin-usage-axes.d.ts +107 -0
- package/src/lib/plugin-manager/plugin-usage-axes.js +107 -0
- package/src/lib/plugin-manager/plugin-usage-axes.js.map +1 -0
- package/src/lib/plugin-manager/plugin-zones.d.ts +4 -5
- package/src/lib/plugin-manager/plugin-zones.js.map +1 -1
- package/src/lib/plugin-manager/realm-host-aglyn.generated.js +2 -0
- package/src/lib/plugin-manager/realm-host-aglyn.generated.js.map +1 -1
- package/src/lib/plugin-manager/record-captured-contact.d.ts +1 -14
- package/src/lib/plugin-manager/record-captured-contact.js +10 -32
- package/src/lib/plugin-manager/record-captured-contact.js.map +1 -1
- package/src/lib/plugin-manager/repeat-rows.d.ts +124 -0
- package/src/lib/plugin-manager/repeat-rows.js +108 -0
- package/src/lib/plugin-manager/repeat-rows.js.map +1 -0
- package/src/lib/plugin-manager/submission-record-target.d.ts +144 -0
- package/src/lib/plugin-manager/submission-record-target.js +125 -0
- package/src/lib/plugin-manager/submission-record-target.js.map +1 -0
- package/src/lib/plugin-manager/video-embed-provider.d.ts +108 -0
- package/src/lib/plugin-manager/video-embed-provider.js +165 -0
- package/src/lib/plugin-manager/video-embed-provider.js.map +1 -0
- package/src/lib/types/nodes.d.ts +2 -2
- package/src/lib/types/nodes.js.map +1 -1
- package/src/lib/app-utils/campaign-attribution.js.map +0 -1
- package/src/lib/app-utils/campaign-forwarding.js.map +0 -1
- package/src/lib/app-utils/contact-holder.d.ts +0 -68
- package/src/lib/app-utils/contact-holder.js +0 -129
- package/src/lib/app-utils/contact-holder.js.map +0 -1
- package/src/lib/app-utils/contact-merge.d.ts +0 -136
- package/src/lib/app-utils/contact-merge.js +0 -412
- package/src/lib/app-utils/contact-merge.js.map +0 -1
- package/src/lib/app-utils/crm-csv.d.ts +0 -239
- package/src/lib/app-utils/crm-csv.js +0 -467
- package/src/lib/app-utils/crm-csv.js.map +0 -1
- package/src/lib/app-utils/crm-digest.d.ts +0 -185
- package/src/lib/app-utils/crm-digest.js +0 -272
- package/src/lib/app-utils/crm-digest.js.map +0 -1
- package/src/lib/app-utils/form-dataset-binding.d.ts +0 -50
- package/src/lib/app-utils/form-dataset-binding.js +0 -74
- package/src/lib/app-utils/form-dataset-binding.js.map +0 -1
- package/src/lib/app-utils/list-import.d.ts +0 -158
- package/src/lib/app-utils/list-import.js +0 -332
- package/src/lib/app-utils/list-import.js.map +0 -1
- package/src/lib/app-utils/marketplace-listing-visibility.d.ts +0 -122
- package/src/lib/app-utils/marketplace-listing-visibility.js +0 -147
- package/src/lib/app-utils/marketplace-listing-visibility.js.map +0 -1
- package/src/lib/app-utils/marketplace-overrides.js.map +0 -1
- package/src/lib/app-utils/marketplace-provenance.js.map +0 -1
- package/src/lib/app-utils/marketplace-theme.js.map +0 -1
- package/src/lib/app-utils/marketplace-update-state.d.ts +0 -119
- package/src/lib/app-utils/marketplace-update-state.js +0 -132
- package/src/lib/app-utils/marketplace-update-state.js.map +0 -1
- package/src/lib/app-utils/publisher-agreement.d.ts +0 -289
- package/src/lib/app-utils/publisher-agreement.js +0 -321
- package/src/lib/app-utils/publisher-agreement.js.map +0 -1
- package/src/lib/app-utils/wistia-embed.d.ts +0 -104
- package/src/lib/app-utils/wistia-embed.js +0 -138
- package/src/lib/app-utils/wistia-embed.js.map +0 -1
- package/src/lib/app-utils/workflows.d.ts +0 -136
- package/src/lib/app-utils/workflows.js +0 -346
- package/src/lib/app-utils/workflows.js.map +0 -1
- package/src/lib/plugin-manager/commerce-zone-props.d.ts +0 -172
- package/src/lib/plugin-manager/commerce-zone-props.js +0 -31
- package/src/lib/plugin-manager/commerce-zone-props.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/plugin-bundle-checks.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Static plugin-bundle checks (AGL-426) — Strapi `strapi-plugin verify`\n * parity, but ALSO enforced server-side: the publish API runs the same\n * checks, so a bundle that fails locally fails there identically.\n *\n * The bundle is PARSED and the tree analysed (AGL-964). The checks used to\n * match source text with regexes, which meant they could not see computed\n * member access, could not follow a value into a call, and could not tell\n * code from a comment — `g['ev'+'al'](…)` passed while the words `eval(`\n * inside a comment failed. On a minified bundle, which every published\n * artifact is, that is close to no signal at all.\n *\n * These are still cheap heuristics, NOT a sandbox: they catch honest build\n * mistakes (leftover imports, missing entry exports, oversized bundles),\n * flag the APIs the platform never wants in marketplace code, and surface\n * the questions a reviewer should ask. A determined author can still hide\n * intent from any static pass. The real security boundary stays the trust\n * chain (sandbox iframe + per-manifest CSP / staff review + realm signing /\n * sha pinning / the kill switch).\n */\n\nimport { parse, type Node, type Options } from 'acorn'\n// The leaf, not the barrel: the phishing screen's own reading of an input's\n// type, autocomplete token and raw HTML (AGL-3362).\nimport {\n credentialForInputAttribute,\n credentialInHtml,\n} from '@aglyn/shared-util-email/hosted-page-screen'\nimport { lookalikeBrandForHost } from '@aglyn/shared-util-email/outbound-phishing-screen'\nimport type { PluginContributions } from '../plugin-manager/plugin-contributions'\nimport {\n PLUGIN_HOST_ABI_KEYS,\n PLUGIN_HOST_GLOBAL,\n PLUGIN_HOST_MODULE_KEYS,\n} from './plugin-host-abi'\nimport { REALM_HOST_SURFACE_NAMES } from './realm-host-surface.generated'\n\n/** The areas the verifier reports on, in the order a reviewer reads them. */\nexport type BundleCheckId =\n | 'parse'\n | 'entry'\n | 'self-contained'\n | 'host-abi'\n | 'size'\n | 'code-execution'\n | 'globals'\n | 'storage'\n | 'dynamic-import'\n | 'network'\n | 'obfuscation'\n | 'contributions'\n | 'credentials'\n\nexport interface BundleCheckProblem {\n level: 'error' | 'warning'\n message: string\n /**\n * Which check produced this. Optional so a verdict stored by an older\n * checker still reads — those findings render on their own rather than\n * under a check row.\n */\n check?: BundleCheckId\n}\n\n/**\n * `unknown` is the one that earns its keep (AGL-1087). A check that could\n * not run — the network diff with no manifest supplied, everything at all\n * when the parse failed — must not render as green, or the page tells a\n * reviewer something was verified when nothing looked at it.\n */\nexport type BundleCheckStatus = 'pass' | 'fail' | 'question' | 'unknown'\n\nexport interface BundleCheckSummary {\n id: BundleCheckId\n /** Reviewer-facing name of the area. */\n label: string\n status: BundleCheckStatus\n /** What the check actually saw, when that is worth stating on its own. */\n detail?: string\n}\n\nexport interface BundleCheckResult {\n ok: boolean\n problems: BundleCheckProblem[]\n /** Every area, including the ones that found nothing (AGL-1087). */\n checks: BundleCheckSummary[]\n /** Which entry exports the source declares. */\n exports: { register: boolean; registerApi: boolean }\n /** What `register()` visibly registers (AGL-3116). */\n contributions: DetectedContributions\n}\n\n/**\n * What a bundle's `register()` visibly registers (AGL-3116): the declaration\n * its registration calls imply, read from the tree.\n */\nexport interface DetectedContributions {\n contributes: PluginContributions\n /**\n * Registrations the checker saw and could not read — an argument built at\n * runtime. What they contribute is unknown, so a declaration cannot be\n * checked against them and a reviewer has to read them.\n */\n unresolved: string[]\n}\n\nconst CHECK_LABELS: Record<BundleCheckId, string> = {\n parse: 'Parses as an ES module',\n entry: 'Exports an entry point',\n 'self-contained': 'Self-contained (no static imports)',\n 'host-abi': 'Reads only what the host provides',\n size: 'Within the size limit',\n 'code-execution': 'No eval / Function constructor',\n globals: 'No computed access on a global',\n storage: 'No direct storage or cookie access',\n 'dynamic-import': 'No dynamic import of unknown code',\n network: 'Network calls match the manifest',\n obfuscation: 'No obfuscation shapes',\n contributions: 'Registrations match the declared contributions',\n credentials: 'No password, card or one-time-code inputs',\n}\n\n/** Check order as displayed — findings first would reorder on every bundle. */\nconst CHECK_ORDER: BundleCheckId[] = [\n 'parse',\n 'entry',\n 'self-contained',\n 'host-abi',\n 'size',\n 'code-execution',\n 'globals',\n 'storage',\n 'dynamic-import',\n 'network',\n 'obfuscation',\n 'contributions',\n 'credentials',\n]\n\nexport const MAX_PLUGIN_BUNDLE_BYTES = 1_000_000\n\n/**\n * Stamped onto a cached verdict (AGL-962) so a stored result outlives only\n * the checker that produced it.\n *\n * `checkPluginBundle` is pure over immutable, content-addressed bytes, so a\n * verdict for a given sha256 never changes — but the CHECKS do. **Bump this\n * whenever a rule is added, removed or loosened**, and every stored verdict\n * from the old checker is ignored and recomputed on next read. Forgetting to\n * bump means a reviewer sees a verdict from a checker that no longer exists,\n * which is the failure mode re-running the verifier was meant to prevent.\n *\n * 2 — AST analysis replaces the regex scan (AGL-964).\n * 3 — per-check summary added to the verdict (AGL-1087).\n * 4 — calls through an alias are resolved (AGL-1090).\n * 5 — URLs held in a constant are resolved (AGL-1093).\n * 6 — registrations are compared with the declared contributions (AGL-3116).\n * 7 — inputs that collect a password, card or one-time code (AGL-3362).\n * 8 — declared network origins that are a brand's lookalike (AGL-3365).\n * 9 — lookups on the host ABI name only keys a host provides (AGL-3392).\n */\nexport const PLUGIN_VERIFIER_VERSION = 10\n\n/** A verdict as stored on a `pluginVersions` doc (AGL-962). */\nexport interface StoredBundleVerdict {\n ok?: boolean\n problems?: BundleCheckProblem[]\n /** Present from verifier 3 on (AGL-1087). */\n checks?: BundleCheckSummary[]\n sha256?: string\n verifierVersion?: number\n}\n\n/**\n * Whether a stored verdict may be served instead of re-running the checks.\n *\n * Fails closed on every mismatch: no verdict, a verdict for different bytes\n * (a republished version keeps its version string but changes sha), or a\n * verdict from a checker that has since changed. Any of those means\n * download-and-recompute, which costs one page view rather than showing a\n * reviewer a verdict that was never true of the bundle in front of them.\n */\nexport function isStoredVerdictCurrent(\n stored: StoredBundleVerdict | null | undefined,\n sha256: string,\n): boolean {\n if (!stored || !sha256) return false\n return (\n stored.sha256 === sha256 &&\n Number(stored.verifierVersion) === PLUGIN_VERIFIER_VERSION\n )\n}\n\n/**\n * Globals whose properties are the platform's business. Computed access on\n * one of these is flagged as computed access rather than by trying to\n * enumerate the property names an author might reach — `g[k]` hides its\n * property from any static pass, so the ACCESS is the finding.\n */\nconst GLOBAL_ROOTS = new Set([\n 'globalThis',\n 'window',\n 'self',\n 'top',\n 'parent',\n 'frames',\n 'document',\n])\n\n/** Storage the platform never wants reached directly (use host-mediated data). */\nconst STORAGE_NAMES = new Set(['localStorage', 'sessionStorage', 'indexedDB'])\n\n/** Network entry points, by the name they are called/constructed under. */\nconst NETWORK_CALLS = new Set(['fetch', 'sendBeacon'])\nconst NETWORK_CONSTRUCTORS = new Set([\n 'XMLHttpRequest',\n 'WebSocket',\n 'EventSource',\n])\n\n/**\n * Names worth following through an alias (AGL-1090).\n *\n * `const f = fetch; f(url)` used to pass every check, and the network row\n * rendered a green \"no network calls\" rather than going quiet — a two-line\n * indirection defeating the signal this whole verifier exists to produce.\n * Aliasing a VALUE was the exact gap the project was created to close, and\n * resolving global objects (`const g = globalThis`) never covered it.\n *\n * Reassignment, `arr[0]`, an object property and passing the function as an\n * argument all stay out of reach. The bar is that the cheap form is not free.\n */\nconst ALIASABLE_CALLABLES = new Set([\n 'eval',\n 'Function',\n 'fetch',\n 'sendBeacon',\n 'XMLHttpRequest',\n 'WebSocket',\n 'EventSource',\n])\n\n/**\n * Callees that legitimately take an absolute URL and reach nothing — so a URL\n * literal passed to them is not a call the network check failed to follow.\n * `createElementNS` matters most: an SVG namespace argument appears in a large\n * share of real bundles.\n */\nconst URL_TAKING_NON_CALLS = new Set([\n 'URL',\n 'URLSearchParams',\n 'createElementNS',\n 'createDocument',\n])\n\n/** Beyond this, a single line is not source a reviewer can read. */\nconst MAX_READABLE_LINE = 100_000\n/** A base64 blob at least this long is worth decoding before approving. */\nconst MIN_SUSPICIOUS_BASE64 = 1024\n/** How many `_0x…` names before the bundle counts as machine-obfuscated. */\nconst MIN_OBFUSCATED_NAMES = 5\n/** Verdicts are stored on a version doc; keep them bounded. */\nconst MAX_PROBLEMS = 40\n\nconst OBFUSCATED_NAME = /^_0x[0-9a-f]{4,}$/i\nconst BASE64_BLOB = /^[A-Za-z0-9+/\\r\\n]+={0,2}$/\n\ntype AnyNode = Node & Record<string, unknown>\n\n/**\n * Child keys that are NOT expressions in the surrounding scope — a\n * non-computed `.property`, an object literal key, a label. Walking into\n * them would read `x.localStorage` on an unrelated object as a global\n * storage access.\n */\nconst skippedChild = (node: AnyNode, key: string): boolean => {\n switch (node.type) {\n case 'MemberExpression':\n return key === 'property' && !node['computed']\n case 'Property':\n case 'PropertyDefinition':\n case 'MethodDefinition':\n return key === 'key' && !node['computed']\n case 'LabeledStatement':\n case 'BreakStatement':\n case 'ContinueStatement':\n return key === 'label'\n case 'ImportSpecifier':\n case 'ExportSpecifier':\n return true\n default:\n return false\n }\n}\n\n/** Depth-first walk over every expression-position node in the tree. */\nfunction walk(root: AnyNode, visit: (node: AnyNode) => void): void {\n const stack: AnyNode[] = [root]\n while (stack.length) {\n const node = stack.pop()\n if (!node) continue\n visit(node)\n for (const key of Object.keys(node)) {\n if (key === 'type' || key === 'start' || key === 'end') continue\n if (skippedChild(node, key)) continue\n const value = node[key]\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item && typeof item === 'object' && typeof item.type === 'string')\n stack.push(item as AnyNode)\n }\n } else if (\n value &&\n typeof value === 'object' &&\n typeof (value as AnyNode).type === 'string'\n ) {\n stack.push(value as AnyNode)\n }\n }\n }\n}\n\n/**\n * The string a node evaluates to, when that is knowable without running it.\n * Covers the shapes used to hide a property name from a text scan: a\n * string literal, a template with no interpolation, and literals added\n * together (`'ev' + 'al'`).\n */\nfunction staticString(\n node: AnyNode | null | undefined,\n constants?: ReadonlyMap<string, string>,\n): string | null {\n if (!node) return null\n if (node.type === 'Literal')\n return typeof node['value'] === 'string' ? (node['value'] as string) : null\n // A name bound once to a constant string (AGL-1093). `const ENDPOINT =\n // 'https://…'; fetch(ENDPOINT)` is the idiomatic way to write a request,\n // and refusing to read it meant the network diff quietly did not run for\n // the bundles most likely to be honest.\n if (node.type === 'Identifier' && constants)\n return constants.get(node['name'] as string) ?? null\n if (node.type === 'TemplateLiteral') {\n const expressions = (node['expressions'] ?? []) as AnyNode[]\n const quasis = (node['quasis'] ?? []) as Array<{\n value: { cooked?: string }\n }>\n if (!expressions.length) {\n return quasis.length === 1 ? quasis[0]?.value?.cooked ?? null : null\n }\n // `${BASE}/zen` — resolvable exactly when every hole is.\n let out = ''\n for (let index = 0; index < quasis.length; index += 1) {\n out += quasis[index]?.value?.cooked ?? ''\n if (index < expressions.length) {\n const filled = staticString(expressions[index], constants)\n if (filled === null) return null\n out += filled\n }\n }\n return out\n }\n if (node.type === 'BinaryExpression' && node['operator'] === '+') {\n const left = staticString(node['left'] as AnyNode, constants)\n const right = staticString(node['right'] as AnyNode, constants)\n return left !== null && right !== null ? left + right : null\n }\n return null\n}\n\n/** The property name a member expression reads, computed or not. */\nfunction propertyName(\n node: AnyNode,\n constants?: ReadonlyMap<string, string>,\n): string | null {\n const property = node['property'] as AnyNode\n if (!node['computed'])\n return property?.type === 'Identifier'\n ? (property['name'] as string)\n : null\n return staticString(property, constants)\n}\n\n/**\n * The origin of a URL argument, when it is a knowable http(s) URL.\n *\n * Scheme-checked HERE, once (AGL-1094). An opaque origin — every `data:`,\n * `blob:` and `javascript:` URL — makes `new URL(x).origin` the STRING\n * `\"null\"`, and a caller that then re-parsed that string threw `Invalid URL`\n * and took the whole checker down with it. Nothing downstream should have to\n * know that, so nothing downstream gets the chance.\n */\nfunction literalOrigin(\n node: AnyNode | undefined,\n constants?: ReadonlyMap<string, string>,\n): string | null {\n const value = staticString(node, constants)\n if (!value) return null\n try {\n const url = new URL(value)\n return /^https?:$/.test(url.protocol) ? url.origin : null\n } catch {\n return null\n }\n}\n\ninterface CheckOptions {\n maxBytes?: number\n /**\n * The origins the manifest declares under `capabilities.network`. A\n * network call the manifest does not account for is the single most\n * useful signal the tree makes available — and the per-manifest CSP\n * would block it at runtime anyway, so the bundle and its manifest\n * disagreeing is a bug the publisher wants to hear about at publish\n * time, not a mystery in production. Undefined = \"not supplied\", which\n * downgrades those findings to warnings, because a checker that was\n * never told what was declared cannot claim anything was undeclared.\n */\n declaredNetwork?: string[]\n /**\n * The manifest's `contributes` block (AGL-3116): `null` when the manifest\n * declares none, `undefined` when no manifest was supplied — which leaves\n * the comparison `unknown`, as the network diff is without its manifest.\n */\n declaredContributions?: PluginContributions | null\n /**\n * Refuse a bundle that registers something while its manifest declares no\n * contributions at all. Set where a NEW version is judged — the publish\n * pipeline and the local verifier that mirrors it. The review page and the\n * re-verification sweep judge versions published before the contract,\n * which load under its default, and a rule they were never held to must\n * not turn them red after the fact.\n */\n requireContributions?: boolean\n}\n\n/** The detection result of a bundle no pass could read. */\nconst NOTHING_DETECTED: DetectedContributions = { contributes: {}, unresolved: [] }\n\n/**\n * Registration calls whose argument says what a bundle contributes, by the\n * name they are reached through: `h.aglyn.registerConsoleExtension(...)`,\n * `registerConsoleExtension(...)` after the realm template's host mapping,\n * `aglyn.components.registerComponent(...)`.\n */\nconst REGISTRATION_CALLS = new Set([\n 'registerConsoleExtension',\n 'registerSiteRuntime',\n 'registerComponent',\n 'addDependency',\n 'defineUiFeatureBundle',\n])\n\n/**\n * Console extension fields the shell draws on every screen of a workspace:\n * nav tabs, organization tabs, providers, staff pages and the dashboard and\n * settings entries. A plugin registering any of them loads with the shell.\n */\nconst SHELL_EXTENSION_FIELDS = [\n 'navItems',\n 'orgNavItems',\n 'providers',\n 'staffPages',\n 'dashboardCards',\n 'settingsSections',\n]\n\n/**\n * What `register()` visibly registers (AGL-3116), read from the tree.\n *\n * A heuristic like every check here: it reads registration calls whose\n * arguments are written out — an object literal, a string or a named slot —\n * and reports every call it cannot read as `unresolved` rather than guessing.\n * The declaration stays the contract; this is how a publisher learns theirs\n * is incomplete before a published page fails to load the plugin.\n */\nfunction detectRegistrations(\n program: AnyNode,\n constants: ReadonlyMap<string, string>,\n): DetectedContributions {\n const slots = new Set<string>()\n const routes = new Set<string>()\n const orgRoutes = new Set<string>()\n const components = new Set<string>()\n const features = new Set<string>()\n const unresolved = new Set<string>()\n let shell = false\n\n const objectProperty = (\n object: AnyNode | undefined,\n name: string,\n ): AnyNode | undefined => {\n if (object?.type !== 'ObjectExpression') return undefined\n for (const property of (object['properties'] ?? []) as AnyNode[]) {\n if (property.type !== 'Property') continue\n const key = property['key'] as AnyNode\n const keyName =\n !property['computed'] && key?.type === 'Identifier'\n ? (key['name'] as string)\n : staticString(key, constants)\n if (keyName === name) return property['value'] as AnyNode\n }\n return undefined\n }\n const listOf = (node: AnyNode | undefined): AnyNode[] | null =>\n node?.type === 'ArrayExpression' ? ((node['elements'] ?? []) as AnyNode[]) : null\n // A slot as a widget names it: a string, or a catalog entry\n // (`CONSOLE_WIDGET_SLOTS.hostActivity`), whose property IS the slot id.\n const slotName = (node: AnyNode | undefined): string | null => {\n const literal = staticString(node, constants)\n if (literal !== null) return literal\n return node?.type === 'MemberExpression' ? propertyName(node, constants) : null\n }\n\n walk(program, (node) => {\n if (node.type !== 'CallExpression') return\n const callee = node['callee'] as AnyNode\n const name =\n callee?.type === 'Identifier'\n ? (callee['name'] as string)\n : callee?.type === 'MemberExpression'\n ? propertyName(callee, constants)\n : null\n if (!name || !REGISTRATION_CALLS.has(name)) return\n const args = (node['arguments'] ?? []) as AnyNode[]\n if (name === 'registerConsoleExtension') {\n const extension = args[0]\n if (extension?.type !== 'ObjectExpression') {\n unresolved.add('a console extension built at runtime')\n return\n }\n const widgets = objectProperty(extension, 'widgets')\n if (widgets) {\n const list = listOf(widgets)\n if (!list) unresolved.add('a console widget list built at runtime')\n for (const widget of list ?? []) {\n const slot = slotName(objectProperty(widget, 'slot'))\n if (slot) slots.add(slot)\n else unresolved.add('a console widget whose slot is built at runtime')\n }\n }\n for (const field of SHELL_EXTENSION_FIELDS) {\n const value = objectProperty(extension, field)\n if (!value) continue\n shell = true\n if (field !== 'navItems' && field !== 'orgNavItems') continue\n const into = field === 'navItems' ? routes : orgRoutes\n const list = listOf(value)\n if (!list) unresolved.add(`console ${field} built at runtime`)\n for (const item of list ?? []) {\n const href = staticString(objectProperty(item, 'href'), constants)\n if (href) into.add(href)\n else unresolved.add(`a console ${field} entry whose href is built at runtime`)\n }\n }\n return\n }\n if (name === 'registerSiteRuntime') {\n const id = staticString(objectProperty(args[0], 'runtimeId'), constants)\n if (id) features.add(id)\n else unresolved.add('a site runtime whose runtimeId is built at runtime')\n return\n }\n if (name === 'registerComponent') {\n const id = staticString(objectProperty(args[1], '$id'), constants)\n if (id) components.add(id)\n else unresolved.add('a canvas component whose $id is built at runtime')\n return\n }\n // `addDependency` / `defineUiFeatureBundle`: a component bundle whose\n // entries register later, from a list this pass does not follow.\n unresolved.add('a canvas component bundle')\n })\n\n const contributes: PluginContributions = {}\n if (components.size || features.size) {\n contributes.site = {\n ...(components.size ? { components: [...components].sort() } : {}),\n ...(features.size ? { features: [...features].sort() } : {}),\n }\n }\n if (slots.size || routes.size || orgRoutes.size || shell) {\n contributes.console = {\n ...(slots.size ? { slots: [...slots].sort() } : {}),\n ...(routes.size ? { routes: [...routes].sort() } : {}),\n ...(orgRoutes.size ? { orgRoutes: [...orgRoutes].sort() } : {}),\n ...(shell ? { shell: true } : {}),\n }\n }\n return { contributes, unresolved: [...unresolved].sort() }\n}\n\n/** A declaration in the words a reviewer reads: `console slots hostActivity`. */\nfunction describeContributions(contributes: PluginContributions): string {\n const parts: string[] = []\n const site = contributes.site ?? {}\n const shell = contributes.console ?? {}\n if (site.components?.length) parts.push(`site components ${site.components.join(', ')}`)\n if (site.features?.length) parts.push(`site features ${site.features.join(', ')}`)\n if (shell.slots?.length) parts.push(`console slots ${shell.slots.join(', ')}`)\n if (shell.routes?.length) parts.push(`console routes ${shell.routes.join(', ')}`)\n if (shell.orgRoutes?.length) {\n parts.push(`console organization routes ${shell.orgRoutes.join(', ')}`)\n }\n if (shell.shell) parts.push('the console shell')\n return parts.join(' · ') || 'nothing'\n}\n\n/**\n * The `contributions` area (AGL-3116): what the bundle registers against what\n * its manifest declares.\n *\n * Every registration the tree shows must be declared, because the loaders\n * read ONLY the declaration: a slot the manifest omits is a slot whose\n * screens never load the plugin, and a component it omits is an element that\n * renders empty on every published page that places it. A declared entry the\n * bundle never registers is a warning — the plugin loads there for nothing.\n */\nfunction compareContributions(\n detected: DetectedContributions,\n options: CheckOptions | undefined,\n add: (\n level: BundleCheckProblem['level'],\n check: BundleCheckId,\n message: string,\n ) => void,\n details: Map<BundleCheckId, string>,\n markUnknown: (check: BundleCheckId) => void,\n): void {\n const found = detected.contributes\n const registers = describeContributions(found)\n const registersSomething =\n Boolean(found.site || found.console) || detected.unresolved.length > 0\n const unreadable = detected.unresolved.length\n ? ` It also makes registrations the checker could not read: ${detected.unresolved.join('; ')}.`\n : ''\n const declared = options?.declaredContributions\n if (declared === undefined) {\n // Nothing to compare against is `unknown`, never a pass — the same\n // reading the network row gives a bundle checked without its manifest.\n if (!registersSomething) {\n details.set('contributions', 'registers nothing')\n return\n }\n markUnknown('contributions')\n details.set(\n 'contributions',\n `registers ${registers} — no manifest was supplied, so nothing was compared`,\n )\n return\n }\n if (declared === null) {\n details.set(\n 'contributions',\n registersSomething ? `undeclared · registers ${registers}` : 'declares and registers nothing',\n )\n if (!registersSomething) return\n add(\n options?.requireContributions ? 'error' : 'warning',\n 'contributions',\n `the manifest declares no \"contributes\", and register() registers ` +\n `${registers}.${unreadable} Declare it — ` +\n `\"contributes\": ${JSON.stringify(found)} — because the loaders place ` +\n 'a plugin by its declaration alone. Undeclared, a published page ' +\n 'loads it only where its element is placed and the console loads it ' +\n 'with the shell.',\n )\n return\n }\n\n details.set('contributions', `declares ${describeContributions(declared)}`)\n const missing = (\n label: string,\n registered: readonly string[] | undefined,\n listed: readonly string[] | undefined,\n consequence: string,\n ) => {\n for (const id of registered ?? []) {\n if ((listed ?? []).includes(id)) continue\n add(\n 'error',\n 'contributions',\n `register() registers ${label} \"${id}\", which the manifest does not ` +\n `declare — ${consequence}`,\n )\n }\n }\n missing(\n 'the site component',\n found.site?.components,\n declared.site?.components,\n 'a published page that places it would never load the plugin',\n )\n missing(\n 'the site feature',\n found.site?.features,\n declared.site?.features,\n 'no published page would ever load the plugin to run it',\n )\n missing(\n 'a widget in the console slot',\n found.console?.slots,\n declared.console?.slots,\n 'a screen that renders the slot would never load the plugin',\n )\n missing(\n 'the console route',\n found.console?.routes,\n declared.console?.routes,\n 'the route would not find the plugin that serves it',\n )\n missing(\n 'the console organization route',\n found.console?.orgRoutes,\n declared.console?.orgRoutes,\n 'the route would not find the plugin that serves it',\n )\n if (found.console?.shell && !declared.console?.shell) {\n add(\n 'error',\n 'contributions',\n 'register() adds a nav tab, a provider or another entry the console ' +\n 'shell draws on every screen, and the manifest does not declare ' +\n '\"console\": { \"shell\": true } — the shell would draw it only on ' +\n 'screens that happened to load the plugin for something else',\n )\n }\n if (detected.unresolved.length) {\n add(\n 'warning',\n 'contributions',\n `the checker could not read ${detected.unresolved.join('; ')} — ` +\n 'confirm the declaration covers what it registers',\n )\n }\n const unused = (\n label: string,\n listed: readonly string[] | undefined,\n registered: readonly string[] | undefined,\n ) => {\n // Only when every registration of that kind was readable: an unreadable\n // one may be exactly the entry that is declared.\n if (detected.unresolved.length) return\n for (const id of listed ?? []) {\n if ((registered ?? []).includes(id)) continue\n add(\n 'warning',\n 'contributions',\n `the manifest declares ${label} \"${id}\", and register() never ` +\n 'registers it — the plugin would load there for nothing',\n )\n }\n }\n unused('the site component', declared.site?.components, found.site?.components)\n unused('the site feature', declared.site?.features, found.site?.features)\n unused('the console slot', declared.console?.slots, found.console?.slots)\n}\n\n/**\n * Inputs a bundle builds that collect a password, a card number or a\n * one-time code (AGL-3362) — a reviewer's QUESTION, never a failure.\n *\n * The phishing screen holds a published page whose author defined such a\n * field, but a plugin renders its own inputs from code the page screen never\n * reads. So the same reading is applied here, to the bundle, at review: an\n * input's `type` or `autocomplete` in an object literal (`createElement`\n * props, a JSX runtime call, a DOM `Object.assign`), in `setAttribute`, and\n * in any HTML string. A warning rather than an error because a legitimate\n * plugin can own a sign-in (a members-only area, a booking account); what the\n * reviewer asks is whether its credentials go anywhere but its declared\n * origins. The sandbox tier cannot post a native form at all — its frame\n * has no `allow-forms` and its CSP says `form-action 'none'` — so the\n * question is about `connect-src`, which the network check already lists.\n */\nfunction credentialInputsIn(\n program: AnyNode,\n constants: ReadonlyMap<string, string>,\n): string[] {\n const found = new Set<'password' | 'card' | 'otp'>()\n const keyOf = (node: AnyNode): string | null => {\n const key = node['key'] as AnyNode\n if (!key) return null\n if (!node['computed'] && key.type === 'Identifier') return key['name'] as string\n return staticString(key, constants)\n }\n walk(program, (node) => {\n if (node.type === 'Property') {\n const key = keyOf(node)\n const value = staticString(node['value'] as AnyNode, constants)\n const field = key && value !== null ? credentialForInputAttribute(key, value) : null\n if (field) found.add(field)\n } else if (node.type === 'CallExpression') {\n const callee = node['callee'] as AnyNode\n const args = (node['arguments'] ?? []) as AnyNode[]\n if (callee?.type === 'MemberExpression' && propertyName(callee, constants) === 'setAttribute') {\n const name = staticString(args[0], constants)\n const value = staticString(args[1], constants)\n const field = name !== null && value !== null ? credentialForInputAttribute(name, value) : null\n if (field) found.add(field)\n }\n } else if (node.type === 'Literal' && typeof node['value'] === 'string') {\n const field = credentialInHtml(node['value'] as string)\n if (field) found.add(field)\n } else if (node.type === 'TemplateLiteral') {\n const text = ((node['quasis'] ?? []) as AnyNode[])\n .map((quasi) => String((quasi['value'] as { cooked?: string } | undefined)?.cooked ?? ''))\n .join('')\n const field = credentialInHtml(text)\n if (field) found.add(field)\n }\n })\n const words = { password: 'a password', card: 'a card number or security code', otp: 'a one-time code' }\n return [...found].map(\n (field) =>\n `builds an input that collects ${words[field]} — confirm what it is for, and that ` +\n 'it is sent only to the origins the manifest declares',\n )\n}\n\n/**\n * Declared network origins that wear a brand without being the brand's\n * (AGL-3365) — a reviewer's QUESTION, read with the phishing screen's own\n * lookalike rule (`lookalikeBrandForHost`), the one that holds a link in an\n * email or on a page.\n *\n * The manifest's origins are what the loader stamps into the plugin frame's\n * `connect-src`, so they are exactly where a plugin's data and a visitor's\n * input can go. A plugin that integrates with PayPal declares\n * `https://api-m.paypal.com`, which is PayPal's own domain and passes; one that\n * declares `https://paypal-verify.net` or `https://aglyn-billing.com` is\n * sending somewhere dressed as somebody else. A warning rather than an error\n * because every plugin version is reviewed before it installs, and the\n * reviewer is the one who can ask whose domain it is.\n */\nfunction lookalikeDeclaredOrigins(declared: readonly string[]): string[] {\n const messages: string[] = []\n for (const origin of declared) {\n let host: string\n try {\n host = new URL(origin).hostname\n } catch {\n continue\n }\n const brand = lookalikeBrandForHost(host)\n if (brand) {\n messages.push(\n `the manifest declares ${origin}, which wears the ${brand.label} name ` +\n `but is not ${brand.label}'s domain — confirm whose it is before approving`,\n )\n }\n }\n return messages\n}\n\n/**\n * Walks every expression-position node with its parent, by the same rules as\n * {@link walk}.\n */\nfunction walkWithParents(\n root: AnyNode,\n visit: (node: AnyNode, parent: AnyNode | null) => void,\n): void {\n const stack: Array<[AnyNode, AnyNode | null]> = [[root, null]]\n while (stack.length) {\n const entry = stack.pop()\n if (!entry) continue\n const [node, parent] = entry\n visit(node, parent)\n for (const key of Object.keys(node)) {\n if (key === 'type' || key === 'start' || key === 'end') continue\n if (skippedChild(node, key)) continue\n const value = node[key]\n const children = Array.isArray(value) ? value : [value]\n for (const child of children) {\n if (\n child &&\n typeof child === 'object' &&\n typeof (child as AnyNode).type === 'string'\n ) {\n stack.push([child as AnyNode, node])\n }\n }\n }\n }\n}\n\nconst FUNCTION_TYPES = new Set([\n 'FunctionDeclaration',\n 'FunctionExpression',\n 'ArrowFunctionExpression',\n])\n\n/** Nodes that open a scope a name can be declared in. */\nconst SCOPE_TYPES = new Set([\n 'Program',\n ...FUNCTION_TYPES,\n 'BlockStatement',\n 'StaticBlock',\n 'SwitchStatement',\n 'CatchClause',\n 'ForStatement',\n 'ForInStatement',\n 'ForOfStatement',\n 'ClassExpression',\n])\n\n/** The names a binding pattern declares: `a`, `{ a, b: c }`, `[a, ...b]`, `a = 1`. */\nfunction patternNames(pattern: AnyNode | null | undefined, into: Set<string>): void {\n if (!pattern) return\n switch (pattern.type) {\n case 'Identifier':\n into.add(pattern['name'] as string)\n return\n case 'AssignmentPattern':\n return patternNames(pattern['left'] as AnyNode, into)\n case 'RestElement':\n return patternNames(pattern['argument'] as AnyNode, into)\n case 'ArrayPattern':\n for (const element of (pattern['elements'] ?? []) as AnyNode[]) patternNames(element, into)\n return\n case 'ObjectPattern':\n for (const property of (pattern['properties'] ?? []) as AnyNode[]) {\n patternNames(\n (property.type === 'RestElement' ? property : property['value']) as AnyNode,\n into,\n )\n }\n return\n }\n}\n\n/** The declarations a statement list makes itself: `let`/`const`/`class`/`function`. */\nfunction lexicalNames(statements: readonly AnyNode[], into: Set<string>): void {\n for (const statement of statements) {\n if (statement?.type === 'VariableDeclaration' && statement['kind'] !== 'var') {\n for (const declarator of (statement['declarations'] ?? []) as AnyNode[]) {\n patternNames(declarator['id'] as AnyNode, into)\n }\n }\n if (\n (statement?.type === 'FunctionDeclaration' || statement?.type === 'ClassDeclaration') &&\n statement['id']\n ) {\n into.add((statement['id'] as AnyNode)['name'] as string)\n }\n }\n}\n\n/** Every `var` a function body declares, however deep, short of a nested function. */\nfunction varNames(node: AnyNode | null | undefined, into: Set<string>): void {\n if (!node || typeof node !== 'object') return\n if (FUNCTION_TYPES.has(node.type)) return\n if (node.type === 'VariableDeclaration' && node['kind'] === 'var') {\n for (const declarator of (node['declarations'] ?? []) as AnyNode[]) {\n patternNames(declarator['id'] as AnyNode, into)\n }\n }\n for (const [field, value] of Object.entries(node)) {\n if (field === 'type' || !value || typeof value !== 'object') continue\n if (Array.isArray(value)) for (const child of value) varNames(child as AnyNode, into)\n else if ('type' in (value as object)) varNames(value as AnyNode, into)\n }\n}\n\n/** The names a scope node declares for its own body. */\nfunction declaredNames(scope: AnyNode): Set<string> {\n const names = new Set<string>()\n if (FUNCTION_TYPES.has(scope.type)) {\n for (const param of (scope['params'] ?? []) as AnyNode[]) patternNames(param, names)\n if (scope.type === 'FunctionExpression' && scope['id']) {\n names.add((scope['id'] as AnyNode)['name'] as string)\n }\n const body = scope['body'] as AnyNode\n if (body?.type === 'BlockStatement') {\n for (const statement of (body['body'] ?? []) as AnyNode[]) varNames(statement, names)\n lexicalNames((body['body'] ?? []) as AnyNode[], names)\n }\n return names\n }\n switch (scope.type) {\n case 'Program':\n case 'BlockStatement':\n case 'StaticBlock':\n lexicalNames((scope['body'] ?? []) as AnyNode[], names)\n break\n case 'SwitchStatement':\n for (const branch of (scope['cases'] ?? []) as AnyNode[]) {\n lexicalNames((branch['consequent'] ?? []) as AnyNode[], names)\n }\n break\n case 'CatchClause':\n patternNames(scope['param'] as AnyNode, names)\n break\n case 'ForStatement':\n case 'ForInStatement':\n case 'ForOfStatement': {\n const head = (scope['init'] ?? scope['left']) as AnyNode | null\n if (head?.type === 'VariableDeclaration' && head['kind'] !== 'var') lexicalNames([head], names)\n break\n }\n case 'ClassExpression':\n if (scope['id']) names.add((scope['id'] as AnyNode)['name'] as string)\n break\n }\n return names\n}\n\n/**\n * Whether an identifier refers to a variable, rather than naming a property,\n * a key or a label.\n */\nfunction isReference(node: AnyNode, parent: AnyNode | null | undefined): boolean {\n if (!parent) return true\n switch (parent.type) {\n case 'MemberExpression':\n return parent['object'] === node || parent['computed'] === true\n case 'Property':\n if (parent['key'] === node && parent['computed'] !== true) {\n return parent['shorthand'] === true && parent['value'] === node\n }\n return true\n case 'MethodDefinition':\n case 'PropertyDefinition':\n return parent['key'] !== node || parent['computed'] === true\n case 'LabeledStatement':\n case 'BreakStatement':\n case 'ContinueStatement':\n return false\n case 'ExportSpecifier':\n return parent['local'] === node\n case 'ImportSpecifier':\n case 'ImportDefaultSpecifier':\n case 'ImportNamespaceSpecifier':\n return false\n default:\n return true\n }\n}\n\n/**\n * What a bundle reads from the host ABI (AGL-3392), read off the bytes.\n *\n * The realm Rollup configs compile each host import into\n * `const host = globalThis.__AGLYN_PLUGIN_HOST__; … host[\"mui\"]`, and each use\n * of an import into a member read on that: `_aglynHost_mui.Button`. So:\n *\n * - `read` / `unknown` / `computed` are the KEYS a bundle reads off the host\n * object. A key outside `PLUGIN_HOST_ABI_KEYS` is undefined on every host\n * and the bundle fails where it is used; a key chosen at runtime cannot be\n * reviewed at all.\n * - `imports` is what it reads from each host MODULE, by name, so each name\n * can be checked against what the host holds. A module handed around as a\n * value (`import * as M`, a spread, a computed read) cannot be narrowed and\n * records `'*'`.\n *\n * The host is reached through `globalThis.__AGLYN_PLUGIN_HOST__`, a name bound\n * to it, or the parameter of the exported `register(host)` — the last only\n * inside `register` itself, since the same name elsewhere is another variable.\n * A bad key on that parameter is a warning rather than a refusal: bundles\n * written before this check read it freely, and refusing them would report a\n * regression on bytes that are already installed.\n */\nfunction hostAbiReads(\n program: AnyNode,\n constants: ReadonlyMap<string, string>,\n isGlobalRef: (node: AnyNode | null | undefined) => boolean,\n): {\n read: Set<string>\n unknown: Set<string>\n /** Read off `register`'s parameter, which could be a bundle's own mistake. */\n unknownOnParam: Set<string>\n computed: number\n computedOnParam: number\n imports: Partial<Record<string, readonly string[] | '*'>>\n} {\n const parents = new Map<AnyNode, AnyNode | null>()\n const identifiers = new Map<string, AnyNode[]>()\n walkWithParents(program, (node, parent) => {\n parents.set(node, parent)\n if (node.type === 'Identifier') {\n const name = node['name'] as string\n const list = identifiers.get(name)\n if (list) list.push(node)\n else identifiers.set(name, [node])\n }\n })\n // Scope (AGL-3394). A minifier names the host alias `e`, and names every\n // other function's first parameter `e` too, so a name only resolves to the\n // host where no nearer scope declares it again.\n const scopeNames = new Map<AnyNode, Set<string>>()\n const namesOf = (scope: AnyNode): Set<string> => {\n let found = scopeNames.get(scope)\n if (!found) {\n found = declaredNames(scope)\n scopeNames.set(scope, found)\n }\n return found\n }\n /** The scope a declarator's name belongs to: its function for `var`, else its block. */\n const bindingScope = (declarator: AnyNode): AnyNode | null => {\n const declaration = parents.get(declarator)\n const functionScoped = declaration?.['kind'] === 'var'\n for (let at = parents.get(declaration as AnyNode); at; at = parents.get(at)) {\n if (functionScoped ? FUNCTION_TYPES.has(at.type) || at.type === 'Program' : SCOPE_TYPES.has(at.type)) {\n return at\n }\n }\n return null\n }\n /** Whether `ref` means the binding `name` declared in `scope`. */\n const resolvesTo = (ref: AnyNode, name: string, scope: AnyNode | null): boolean => {\n if (!isReference(ref, parents.get(ref))) return false\n for (let at = parents.get(ref); at; at = parents.get(at)) {\n if (at === scope) return true\n if (SCOPE_TYPES.has(at.type) && namesOf(at).has(name)) return false\n }\n return scope === null\n }\n\n const isHostGlobal = (node: AnyNode | null | undefined): boolean =>\n (node?.type === 'Identifier' && node['name'] === PLUGIN_HOST_GLOBAL) ||\n (node?.type === 'MemberExpression' &&\n isGlobalRef(node['object'] as AnyNode) &&\n propertyName(node) === PLUGIN_HOST_GLOBAL)\n\n // Names bound to the host object, each with the scope it is declared in:\n // a declarator's block or function, or the `register(host)` function for its\n // parameter.\n const hostNames = new Map<string, { scope: AnyNode | null; param: boolean }>()\n walk(program, (node) => {\n if (node.type === 'VariableDeclarator') {\n const id = node['id'] as AnyNode\n const init = node['init'] as AnyNode | null\n const roots =\n init?.type === 'LogicalExpression'\n ? [init['left'] as AnyNode, init['right'] as AnyNode]\n : [init]\n if (id?.type === 'Identifier' && roots.some(isHostGlobal)) {\n hostNames.set(id['name'] as string, { scope: bindingScope(node), param: false })\n }\n }\n if (\n node.type === 'FunctionDeclaration' &&\n (node['id'] as AnyNode | null)?.['name'] === 'register'\n ) {\n const param = ((node['params'] ?? []) as AnyNode[])[0]\n if (param?.type === 'Identifier' && !hostNames.has(param['name'] as string)) {\n hostNames.set(param['name'] as string, { scope: node, param: true })\n }\n }\n })\n /** `'global'` for the host reached by name, `'param'` for `register(host)`. */\n const hostRef = (\n node: AnyNode | null | undefined,\n ): 'global' | 'param' | null => {\n if (isHostGlobal(node)) return 'global'\n if (node?.type !== 'Identifier') return null\n const name = node['name'] as string\n const binding = hostNames.get(name)\n if (!binding || !resolvesTo(node, name, binding.scope)) return null\n return binding.param ? 'param' : 'global'\n }\n\n const modules = new Set<string>(PLUGIN_HOST_MODULE_KEYS)\n const allowed = new Set<string>(PLUGIN_HOST_ABI_KEYS)\n const read = new Set<string>()\n const unknown = new Set<string>()\n const unknownOnParam = new Set<string>()\n let computed = 0\n let computedOnParam = 0\n const names = new Map<string, Set<string> | '*'>()\n const whole = (key: string): void => {\n names.set(key, '*')\n }\n const note = (key: string, name: string | null): void => {\n if (name === null) return whole(key)\n const current = names.get(key)\n if (current === '*') return\n if (current) current.add(name)\n else names.set(key, new Set([name]))\n }\n const seenAliases = new Set<AnyNode>()\n\n /** Records how one reference to a lazy key's module is used. */\n const useOf = (key: string, ref: AnyNode): void => {\n const parent = parents.get(ref)\n // A presence check reads no name from the module: `if (!h.aglyn) return`\n // is how a bundle stays inert on a host without the key, and every\n // example plugin does it.\n if (\n (parent?.type === 'UnaryExpression' &&\n (parent['operator'] === '!' || parent['operator'] === 'typeof')) ||\n ((parent?.type === 'IfStatement' || parent?.type === 'ConditionalExpression') &&\n parent['test'] === ref)\n ) {\n return\n }\n if (parent?.type === 'MemberExpression' && parent['object'] === ref) {\n return note(key, propertyName(parent, constants))\n }\n if (parent?.type === 'VariableDeclarator' && parent['init'] === ref) {\n const id = parent['id'] as AnyNode\n if (id?.type === 'Identifier') {\n const alias = id['name'] as string\n if (seenAliases.has(parent)) return\n seenAliases.add(parent)\n const scope = bindingScope(parent)\n for (const use of identifiers.get(alias) ?? []) {\n if (use !== id && resolvesTo(use, alias, scope)) useOf(key, use)\n }\n return\n }\n if (id?.type === 'ObjectPattern') {\n for (const property of (id['properties'] ?? []) as AnyNode[]) {\n if (property.type !== 'Property' || property['computed']) {\n return whole(key)\n }\n const propertyKey = property['key'] as AnyNode\n const name =\n propertyKey?.type === 'Identifier'\n ? (propertyKey['name'] as string)\n : staticString(propertyKey)\n note(key, name)\n }\n return\n }\n }\n whole(key)\n }\n\n walk(program, (node) => {\n if (node.type !== 'MemberExpression') return\n const via = hostRef(node['object'] as AnyNode)\n if (!via) return\n const key = propertyName(node, constants)\n if (key === null) {\n if (via === 'param') computedOnParam += 1\n else computed += 1\n } else if (!allowed.has(key)) {\n ;(via === 'param' ? unknownOnParam : unknown).add(key)\n } else {\n read.add(key)\n if (modules.has(key)) useOf(key, node)\n }\n })\n\n const imports: Record<string, readonly string[] | '*'> = {}\n for (const [key, value] of names) {\n imports[key] = value === '*' ? '*' : [...value].sort()\n }\n return {\n read,\n unknown,\n unknownOnParam,\n computed,\n computedOnParam,\n imports,\n }\n}\n\nfunction analyseBundle(\n source: string,\n options?: CheckOptions,\n): BundleCheckResult {\n const problems: BundleCheckProblem[] = []\n const seen = new Set<string>()\n // Every area starts as \"ran, found nothing\" and is downgraded by its own\n // findings, so the summary cannot drift from the problem list (AGL-1087).\n const status = new Map<BundleCheckId, BundleCheckStatus>(\n CHECK_ORDER.map((id) => [id, 'pass']),\n )\n const details = new Map<BundleCheckId, string>()\n const add = (\n level: BundleCheckProblem['level'],\n check: BundleCheckId,\n message: string,\n ) => {\n if (level === 'error') status.set(check, 'fail')\n else if (status.get(check) === 'pass') status.set(check, 'question')\n if (seen.has(message) || seen.size >= MAX_PROBLEMS) return\n seen.add(message)\n problems.push({ level, message, check })\n }\n /** Mark the areas that never ran, so they cannot read as clean. */\n const unknownFrom = (...ids: BundleCheckId[]) => {\n for (const id of ids) status.set(id, 'unknown')\n }\n const summarise = (): BundleCheckSummary[] =>\n CHECK_ORDER.map((id) => ({\n id,\n label: CHECK_LABELS[id],\n status: status.get(id) ?? 'unknown',\n ...(details.has(id) ? { detail: details.get(id) } : {}),\n }))\n\n const maxBytes = options?.maxBytes ?? MAX_PLUGIN_BUNDLE_BYTES\n const bytes = new TextEncoder().encode(source).byteLength\n details.set('size', `${bytes.toLocaleString('en-US')} bytes of ${maxBytes.toLocaleString('en-US')}`)\n if (bytes === 0) {\n add('error', 'size', 'bundle is empty')\n unknownFrom(\n 'parse',\n 'entry',\n 'self-contained',\n 'host-abi',\n 'code-execution',\n 'globals',\n 'storage',\n 'dynamic-import',\n 'network',\n 'obfuscation',\n 'contributions',\n 'credentials',\n )\n return {\n ok: false,\n problems,\n checks: summarise(),\n exports: { register: false, registerApi: false },\n contributions: NOTHING_DETECTED,\n }\n }\n if (bytes > maxBytes) {\n add('error', 'size', `bundle is ${bytes} bytes (limit ${maxBytes})`)\n }\n\n const parseOptions: Options = {\n ecmaVersion: 'latest',\n sourceType: 'module',\n allowHashBang: true,\n allowAwaitOutsideFunction: true,\n }\n let program: AnyNode\n try {\n program = parse(source, parseOptions) as unknown as AnyNode\n } catch (error) {\n // Unparseable means unanalysable, and the loader would fail on it too.\n // Nothing else ran, and saying so is the whole point of `unknown`: a\n // bundle nobody could read must not show nine green rows.\n add(\n 'error',\n 'parse',\n `bundle does not parse as an ES module: ${\n error instanceof Error ? error.message : String(error)\n }`,\n )\n unknownFrom(\n 'entry',\n 'self-contained',\n 'host-abi',\n 'code-execution',\n 'globals',\n 'storage',\n 'dynamic-import',\n 'network',\n 'obfuscation',\n 'contributions',\n 'credentials',\n )\n return {\n ok: false,\n problems,\n checks: summarise(),\n exports: { register: false, registerApi: false },\n contributions: NOTHING_DETECTED,\n }\n }\n\n // Names bound to a global, so `const g = globalThis; g['ev'+'al']` reads\n // as access on a global rather than on some object we know nothing about.\n const aliases = new Set<string>()\n const noteAlias = (name: unknown, init: AnyNode | null | undefined) => {\n if (typeof name !== 'string' || !init) return\n const roots: AnyNode[] =\n init.type === 'LogicalExpression'\n ? [init['left'] as AnyNode, init['right'] as AnyNode]\n : [init]\n for (const root of roots) {\n if (\n root?.type === 'Identifier' &&\n GLOBAL_ROOTS.has(root['name'] as string)\n ) {\n aliases.add(name)\n }\n }\n }\n // Local name -> the constant string it holds (AGL-1093).\n //\n // A binding is only usable when the whole tree agrees on it: declared once,\n // never assigned again, and never a parameter or another binder anywhere.\n // Any of those means the value at a given call site is a GUESS, and a guess\n // is how a checker starts making claims about code it did not read.\n const constants = new Map<string, string>()\n {\n const bound = new Map<string, AnyNode>()\n const poisoned = new Set<string>()\n const declared = new Set<string>()\n const poison = (name: unknown) => {\n if (typeof name === 'string') poisoned.add(name)\n }\n /** Every name a pattern binds — a parameter shadowing a constant is a\n * different variable, and resolving it to the outer value would be a\n * fabrication. */\n const poisonPattern = (node: AnyNode | null | undefined) => {\n if (!node) return\n if (node.type === 'Identifier') return poison(node['name'])\n for (const key of [\n 'left',\n 'argument',\n 'properties',\n 'elements',\n 'value',\n ]) {\n const value = node[key]\n if (Array.isArray(value))\n value.forEach((item) => poisonPattern(item as AnyNode))\n else if (value) poisonPattern(value as AnyNode)\n }\n }\n walk(program, (node) => {\n if (node.type === 'VariableDeclarator') {\n const id = node['id'] as AnyNode\n if (id?.type === 'Identifier') {\n const name = id['name'] as string\n if (declared.has(name)) poison(name)\n declared.add(name)\n bound.set(name, node['init'] as AnyNode)\n } else {\n poisonPattern(id)\n }\n } else if (node.type === 'AssignmentExpression') {\n poisonPattern(node['left'] as AnyNode)\n } else if (node.type === 'UpdateExpression') {\n poisonPattern(node['argument'] as AnyNode)\n } else if (\n node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression' ||\n node.type === 'ArrowFunctionExpression'\n ) {\n ;((node['params'] ?? []) as AnyNode[]).forEach(poisonPattern)\n if ((node['id'] as AnyNode)?.type === 'Identifier')\n poison((node['id'] as AnyNode)['name'])\n } else if (node.type === 'CatchClause') {\n poisonPattern(node['param'] as AnyNode)\n } else if (\n node.type === 'ClassDeclaration' ||\n node.type === 'ClassExpression'\n ) {\n if ((node['id'] as AnyNode)?.type === 'Identifier')\n poison((node['id'] as AnyNode)['name'])\n }\n })\n // Two passes, so `const BASE = 'https://x'` then `BASE + '/y'` resolves.\n // A third buys almost nothing and each is a full re-read of the bindings.\n for (let pass = 0; pass < 2; pass += 1) {\n for (const [name, init] of bound) {\n if (poisoned.has(name) || constants.has(name)) continue\n const value = staticString(init, constants)\n if (value !== null) constants.set(name, value)\n }\n }\n }\n\n // Local name -> the callable it stands for (AGL-1090). `const f = fetch`,\n // `const d = globalThis.fetch`, `const {fetch: h} = globalThis`.\n const callableAliases = new Map<string, string>()\n /** The aliasable callable an initializer denotes, if any. */\n const callableFrom = (init: AnyNode | null | undefined): string | null => {\n if (!init) return null\n if (\n init.type === 'Identifier' &&\n ALIASABLE_CALLABLES.has(init['name'] as string)\n ) {\n return init['name'] as string\n }\n // `globalThis.fetch` / `window['fe' + 'tch']` — the property is what the\n // name will stand for, and only when the object is a global (an unknown\n // object's `.fetch` is somebody else's method).\n if (init.type === 'MemberExpression') {\n const property = propertyName(init)\n const object = init['object'] as AnyNode\n if (\n property &&\n ALIASABLE_CALLABLES.has(property) &&\n object?.type === 'Identifier' &&\n (GLOBAL_ROOTS.has(object['name'] as string) ||\n aliases.has(object['name'] as string))\n ) {\n return property\n }\n }\n return null\n }\n const noteCallableAlias = (\n id: AnyNode | null | undefined,\n init: AnyNode | null | undefined,\n ) => {\n if (!id) return\n if (id.type === 'Identifier') {\n const callable = callableFrom(init)\n if (callable) callableAliases.set(id['name'] as string, callable)\n return\n }\n // `const { fetch } = globalThis` and `const { fetch: h } = globalThis`.\n if (id.type === 'ObjectPattern' && init) {\n const fromGlobal =\n init.type === 'Identifier' &&\n (GLOBAL_ROOTS.has(init['name'] as string) ||\n aliases.has(init['name'] as string))\n if (!fromGlobal) return\n for (const property of (id['properties'] ?? []) as AnyNode[]) {\n const key = property['key'] as AnyNode\n const value = property['value'] as AnyNode\n const name =\n key?.type === 'Identifier' ? (key['name'] as string) : staticString(key)\n if (\n name &&\n ALIASABLE_CALLABLES.has(name) &&\n value?.type === 'Identifier'\n ) {\n callableAliases.set(value['name'] as string, name)\n }\n }\n }\n }\n\n // Global-object aliases first, as a complete pass: the callable pass below\n // resolves `g.fetch` against them, and walk order is not source order.\n walk(program, (node) => {\n if (node.type === 'VariableDeclarator') {\n const id = node['id'] as AnyNode\n if (id?.type === 'Identifier')\n noteAlias(id['name'], node['init'] as AnyNode)\n } else if (\n node.type === 'AssignmentExpression' &&\n node['operator'] === '='\n ) {\n const left = node['left'] as AnyNode\n if (left?.type === 'Identifier')\n noteAlias(left['name'], node['right'] as AnyNode)\n }\n })\n walk(program, (node) => {\n if (node.type === 'VariableDeclarator') {\n noteCallableAlias(node['id'] as AnyNode, node['init'] as AnyNode)\n } else if (\n node.type === 'AssignmentExpression' &&\n node['operator'] === '='\n ) {\n noteCallableAlias(node['left'] as AnyNode, node['right'] as AnyNode)\n }\n })\n\n const isGlobalRef = (node: AnyNode | null | undefined): boolean =>\n !!node &&\n node.type === 'Identifier' &&\n (GLOBAL_ROOTS.has(node['name'] as string) ||\n aliases.has(node['name'] as string))\n\n const declared = options?.declaredNetwork\n const allowlist = new Set(\n (declared ?? []).map((origin) => {\n try {\n return new URL(origin).origin\n } catch {\n return origin\n }\n }),\n )\n for (const message of lookalikeDeclaredOrigins(declared ?? [])) {\n add('warning', 'network', message)\n }\n /** Level for a network finding: a claim only when we know what was declared. */\n const networkLevel: BundleCheckProblem['level'] = declared\n ? 'error'\n : 'warning'\n // What the bundle reaches for, so the summary row can SAY it (AGL-1087) —\n // \"calls https://api.stripe.com, declared\" is the line a reviewer would\n // otherwise open the bundle to get.\n const networkApis = new Set<string>()\n const networkOrigins = new Set<string>()\n let runtimeUrls = 0\n /** Origins handed to a callee the checker could not resolve (AGL-1090). */\n const unresolvedOrigins = new Set<string>()\n const noteNetwork = (api: string, urlArg: AnyNode | undefined) => {\n const origin = literalOrigin(urlArg, constants)\n networkApis.add(api)\n if (origin) networkOrigins.add(origin)\n else runtimeUrls += 1\n if (!declared) {\n add(\n 'warning',\n 'network',\n `bundle makes network calls (${api}) — check them against the ` +\n \"manifest's declared network capability\",\n )\n return\n }\n if (!allowlist.size) {\n add(\n networkLevel,\n 'network',\n `bundle calls ${api} but the manifest declares no network ` +\n 'capability — declare every origin under capabilities.network ' +\n '(the CSP blocks the rest at runtime)',\n )\n return\n }\n if (!origin) {\n add(\n 'warning',\n 'network',\n `${api} is called with a URL that is only known at runtime — it ` +\n 'cannot be checked against the declared origins',\n )\n return\n }\n if (!allowlist.has(origin)) {\n add(\n networkLevel,\n 'network',\n `${api} calls ${origin}, which the manifest does not declare ` +\n `(declared: ${[...allowlist].join(', ')})`,\n )\n }\n }\n\n /**\n * A call the checker could not resolve, given an absolute URL.\n *\n * Reported as a QUESTION, never a refusal: most of these are helpers, and\n * refusing every unrecognised call that mentions a URL would make the\n * verifier useless. But leaving them silent is what let the network row\n * claim \"no network calls\" over a bundle whose calls it simply could not\n * follow — and a URL to an origin the manifest never declared is exactly\n * what a reviewer should be pointed at.\n */\n const noteUnresolvedUrl = (\n name: string | null,\n urlArg: AnyNode | undefined,\n ) => {\n if (name && URL_TAKING_NON_CALLS.has(name)) return\n const origin = literalOrigin(urlArg, constants)\n if (!origin) return\n // A declared origin is consistent with the manifest and permitted by the\n // CSP, so there is no question to raise about it.\n if (allowlist.has(origin)) return\n unresolvedOrigins.add(origin)\n add(\n 'warning',\n 'network',\n `${name ? `${name}()` : 'a call'} is passed ${origin}, which the ` +\n 'manifest does not declare — the checker could not tell whether it ' +\n 'reaches the network, so read this call',\n )\n }\n\n let exportsRegister = false\n let exportsRegisterApi = false\n const noteExport = (name: unknown) => {\n if (name === 'register') exportsRegister = true\n else if (name === 'registerApi') exportsRegisterApi = true\n }\n\n let obfuscatedNames = 0\n\n walk(program, (node) => {\n switch (node.type) {\n // ---- entry exports + self-containment ----\n case 'ImportDeclaration':\n add(\n 'error',\n 'self-contained',\n 'bundle has static imports — realm bundles must be self-contained ' +\n '(react/@aglyn/aglyn come from the host ABI; see the realm rollup ' +\n 'template)',\n )\n break\n case 'ExportAllDeclaration':\n case 'ExportNamedDeclaration': {\n if (node['source']) {\n add(\n 'error',\n 'self-contained',\n 'bundle re-exports from another module — realm bundles must be ' +\n 'self-contained (see the realm rollup template)',\n )\n }\n const declaration = node['declaration'] as AnyNode | null\n if (declaration) {\n if (declaration['id'])\n noteExport((declaration['id'] as AnyNode)['name'])\n for (const declarator of (declaration['declarations'] ??\n []) as AnyNode[]) {\n const id = declarator['id'] as AnyNode\n if (id?.type === 'Identifier') noteExport(id['name'])\n }\n }\n for (const specifier of (node['specifiers'] ?? []) as AnyNode[]) {\n const exported = specifier['exported'] as AnyNode\n noteExport(\n exported?.type === 'Identifier'\n ? exported['name']\n : staticString(exported),\n )\n }\n break\n }\n\n // ---- dynamic import ----\n case 'ImportExpression': {\n const specifier = staticString(node['source'] as AnyNode, constants)\n if (specifier === null) {\n add(\n 'error',\n 'dynamic-import',\n 'dynamic import with a specifier computed at runtime is not ' +\n 'allowed — the loader cannot know what would be fetched',\n )\n } else if (/^https?:/i.test(specifier)) {\n add(\n 'error',\n 'dynamic-import',\n 'dynamic import of remote URLs is not allowed',\n )\n }\n break\n }\n\n // ---- calls ----\n case 'CallExpression':\n case 'NewExpression': {\n const callee = node['callee'] as AnyNode\n const args = (node['arguments'] ?? []) as AnyNode[]\n const written =\n callee?.type === 'Identifier'\n ? (callee['name'] as string)\n : callee?.type === 'MemberExpression'\n ? propertyName(callee, constants)\n : null\n // An alias resolves to what it stands for (AGL-1090), so `f(url)`\n // after `const f = fetch` is a fetch call.\n const name =\n (written && callableAliases.get(written)) ?? written ?? null\n\n if (name === 'eval')\n add('error', 'code-execution', 'eval() is not allowed')\n if (name === 'Function')\n add(\n 'error',\n 'code-execution',\n 'the Function constructor is not allowed',\n )\n // `(()=>{}).constructor('return 1')()` — the Function constructor\n // reached through any function value, which is why the CALL is the\n // finding rather than the name `Function`.\n if (name === 'constructor' && callee?.type === 'MemberExpression')\n add(\n 'error',\n 'code-execution',\n 'calling .constructor() is not allowed — it reaches the ' +\n 'Function constructor from any function value',\n )\n if (name && NETWORK_CALLS.has(name)) noteNetwork(name, args[0])\n else if (name && NETWORK_CONSTRUCTORS.has(name))\n noteNetwork(name, node.type === 'NewExpression' ? args[0] : args[1])\n // Something we could not follow, handed an absolute URL (AGL-1090).\n // Not a refusal — it may be a helper, a logger, or a link — but the\n // network row must stop rendering \"no network calls\" over it.\n else noteUnresolvedUrl(name, args[0])\n break\n }\n\n // ---- member access ----\n case 'MemberExpression': {\n const object = node['object'] as AnyNode\n const name = propertyName(node, constants)\n if (isGlobalRef(object) && name === null) {\n add(\n 'error',\n 'globals',\n `computed property access on ${\n (object['name'] as string) || 'a global'\n } is not allowed — a property chosen at runtime cannot be ` +\n 'reviewed',\n )\n break\n }\n // Property names only mean anything on a global: `response.cookie`\n // and `state.localStorage` are somebody else's object.\n if (name === 'cookie' && isGlobalRef(object))\n add('error', 'storage', 'document.cookie access is not allowed')\n if (name && STORAGE_NAMES.has(name) && isGlobalRef(object))\n add(\n 'error',\n 'storage',\n 'browser storage access is not allowed (use host-mediated data)',\n )\n if (name === 'eval' && isGlobalRef(object))\n add('error', 'code-execution', 'eval() is not allowed')\n break\n }\n\n // ---- bare references ----\n case 'Identifier': {\n const name = node['name'] as string\n if (STORAGE_NAMES.has(name))\n add(\n 'error',\n 'storage',\n 'browser storage access is not allowed (use host-mediated data)',\n )\n if (OBFUSCATED_NAME.test(name)) obfuscatedNames += 1\n break\n }\n\n // ---- obfuscation ----\n case 'Literal': {\n const value = node['value']\n if (\n typeof value === 'string' &&\n value.length >= MIN_SUSPICIOUS_BASE64 &&\n BASE64_BLOB.test(value)\n ) {\n add(\n 'warning',\n 'obfuscation',\n `bundle embeds a ${value.length}-character base64 literal — ` +\n 'decode it before approving',\n )\n }\n break\n }\n default:\n break\n }\n })\n\n if (!exportsRegister && !exportsRegisterApi) {\n add(\n 'error',\n 'entry',\n 'bundle exports neither register(host) nor registerApi() — ' +\n 'nothing for the loader to call',\n )\n }\n\n if (obfuscatedNames >= MIN_OBFUSCATED_NAMES) {\n add(\n 'warning',\n 'obfuscation',\n `bundle uses ${obfuscatedNames} machine-obfuscated identifiers ` +\n '(_0x… naming) — minifiers do not produce these',\n )\n }\n const longestLine = source\n .split('\\n')\n .reduce((longest, line) => Math.max(longest, line.length), 0)\n if (longestLine > MAX_READABLE_LINE) {\n add(\n 'warning',\n 'obfuscation',\n `bundle has a single ${longestLine}-character line — nothing on it ` +\n 'can be read in review; ask for a readable build or a source map',\n )\n }\n\n details.set(\n 'entry',\n [\n exportsRegister ? 'register(host)' : null,\n exportsRegisterApi ? 'registerApi()' : null,\n ]\n .filter(Boolean)\n .join(', ') || 'none',\n )\n\n // What the network check actually saw. Without the manifest it saw the\n // calls but could not judge them, and that is `unknown`, not a pass — the\n // row a reviewer must not read as \"checked and fine\".\n if (!declared) {\n if (networkApis.size) {\n status.set('network', 'unknown')\n details.set(\n 'network',\n `calls ${[...networkApis].join(', ')} — no declared origins were ` +\n 'supplied, so nothing was compared',\n )\n } else {\n details.set('network', 'no network calls')\n }\n } else if (!networkApis.size) {\n details.set(\n 'network',\n unresolvedOrigins.size\n ? `no resolved network calls, but ${[...unresolvedOrigins].join(', ')} ` +\n 'is passed to a call the checker could not follow'\n : 'no network calls',\n )\n } else {\n const origins = networkOrigins.size\n ? [...networkOrigins]\n .map((origin) =>\n allowlist.has(origin) ? `${origin} (declared)` : `${origin} (NOT declared)`,\n )\n .join(', ')\n : ''\n details.set(\n 'network',\n [\n `calls ${[...networkApis].join(', ')}`,\n origins,\n runtimeUrls\n ? `${runtimeUrls} call(s) with a URL only known at runtime`\n : '',\n ]\n .filter(Boolean)\n .join(' · '),\n )\n }\n\n const abi = hostAbiReads(program, constants, isGlobalRef)\n for (const key of abi.unknown) {\n add(\n 'error',\n 'host-abi',\n `bundle reads \"${key}\" from the host, which provides only ` +\n `${PLUGIN_HOST_ABI_KEYS.join(', ')} — it would be undefined on every site`,\n )\n }\n for (const key of abi.unknownOnParam) {\n add(\n 'warning',\n 'host-abi',\n `register() reads \"${key}\" from its host argument, which provides only ` +\n `${PLUGIN_HOST_ABI_KEYS.join(', ')} — it will be undefined`,\n )\n }\n if (abi.computedOnParam) {\n add(\n 'warning',\n 'host-abi',\n `register() reads its host argument by a key chosen at runtime ` +\n `(${abi.computedOnParam}×)`,\n )\n }\n if (abi.computed) {\n add(\n 'error',\n 'host-abi',\n `bundle reads the host by a key chosen at runtime (${abi.computed}×) — ` +\n 'a lookup that cannot be named cannot be reviewed',\n )\n }\n // Each name the bundle reads from a host module must be one the host holds\n // (AGL-3392): core's realm plugin surface, or the whole of the others.\n for (const key of PLUGIN_HOST_MODULE_KEYS) {\n const read = abi.imports[key]\n if (!read) continue\n const holds = REALM_HOST_SURFACE_NAMES[key]\n if (read === '*') {\n if (key === 'aglyn') {\n add(\n 'warning',\n 'host-abi',\n 'uses @aglyn/aglyn as a namespace value — only the realm plugin ' +\n 'surface is on the host, so any other name read through it is ' +\n 'undefined; import what you use by name',\n )\n }\n continue\n }\n const missing = read.filter((name) => !holds.has(name))\n if (missing.length) {\n add(\n 'error',\n 'host-abi',\n `reads ${missing.join(', ')} from the host's ${key}, which does not ` +\n `hold ${missing.length === 1 ? 'it' : 'them'}` +\n (key === 'aglyn'\n ? ' — only the realm plugin surface of @aglyn/aglyn is on the host'\n : ''),\n )\n }\n }\n details.set(\n 'host-abi',\n abi.read.size ? `reads ${[...abi.read].sort().join(', ')}` : 'reads nothing by name',\n )\n\n const detected = detectRegistrations(program, constants)\n for (const message of credentialInputsIn(program, constants)) {\n add('warning', 'credentials', message)\n }\n compareContributions(detected, options, add, details, (check) =>\n status.set(check, 'unknown'),\n )\n\n return {\n ok: !problems.some((problem) => problem.level === 'error'),\n problems,\n checks: summarise(),\n exports: { register: exportsRegister, registerApi: exportsRegisterApi },\n contributions: detected,\n }\n}\n\n/**\n * Run the checks over a bundle. NEVER throws (AGL-1094).\n *\n * The publish route calls this directly, so an unexpected failure in here\n * used to mean a 500 and no explanation for the publisher — and in the review\n * sweep it looked exactly like a missing artifact, which sent the\n * investigation to the storage bucket instead of to this file. A checker that\n * cannot analyse a bundle has an answer: say so, in the verdict, as an error.\n */\nexport function checkPluginBundle(\n source: string,\n options?: CheckOptions,\n): BundleCheckResult {\n try {\n return analyseBundle(source, options)\n } catch (error) {\n return {\n ok: false,\n problems: [\n {\n level: 'error',\n check: 'parse',\n message:\n 'the verifier failed on this bundle — treat it as unchecked and ' +\n `report it: ${\n error instanceof Error ? error.message : String(error)\n }`,\n },\n ],\n checks: CHECK_ORDER.map((id) => ({\n id,\n label: CHECK_LABELS[id],\n status: id === 'parse' ? 'fail' : 'unknown',\n })),\n exports: { register: false, registerApi: false },\n contributions: NOTHING_DETECTED,\n }\n }\n}\n"],"names":["parse","credentialForInputAttribute","credentialInHtml","lookalikeBrandForHost","PLUGIN_HOST_ABI_KEYS","PLUGIN_HOST_GLOBAL","PLUGIN_HOST_MODULE_KEYS","REALM_HOST_SURFACE_NAMES","CHECK_LABELS","entry","size","globals","storage","network","obfuscation","contributions","credentials","CHECK_ORDER","MAX_PLUGIN_BUNDLE_BYTES","PLUGIN_VERIFIER_VERSION","isStoredVerdictCurrent","stored","sha256","Number","verifierVersion","GLOBAL_ROOTS","Set","STORAGE_NAMES","NETWORK_CALLS","NETWORK_CONSTRUCTORS","ALIASABLE_CALLABLES","URL_TAKING_NON_CALLS","MAX_READABLE_LINE","MIN_SUSPICIOUS_BASE64","MIN_OBFUSCATED_NAMES","MAX_PROBLEMS","OBFUSCATED_NAME","BASE64_BLOB","skippedChild","node","key","type","walk","root","visit","stack","length","pop","Object","keys","value","Array","isArray","item","push","staticString","constants","get","expressions","quasis","cooked","out","index","filled","left","right","propertyName","property","literalOrigin","url","URL","test","protocol","origin","NOTHING_DETECTED","contributes","unresolved","REGISTRATION_CALLS","SHELL_EXTENSION_FIELDS","detectRegistrations","program","slots","routes","orgRoutes","components","features","shell","objectProperty","object","name","undefined","keyName","listOf","slotName","literal","callee","has","args","extension","add","widgets","list","widget","slot","field","into","href","id","site","sort","console","describeContributions","parts","join","compareContributions","detected","options","details","markUnknown","found","declared","registers","registersSomething","Boolean","unreadable","declaredContributions","set","requireContributions","JSON","stringify","missing","label","registered","listed","consequence","includes","unused","credentialInputsIn","keyOf","text","map","quasi","String","words","password","card","otp","lookalikeDeclaredOrigins","messages","host","hostname","brand","walkWithParents","parent","children","child","FUNCTION_TYPES","SCOPE_TYPES","patternNames","pattern","element","lexicalNames","statements","statement","declarator","varNames","entries","declaredNames","scope","names","param","body","branch","head","isReference","hostAbiReads","isGlobalRef","parents","Map","identifiers","scopeNames","namesOf","bindingScope","declaration","functionScoped","at","resolvesTo","ref","isHostGlobal","hostNames","init","roots","some","hostRef","binding","modules","allowed","read","unknown","unknownOnParam","computed","computedOnParam","whole","note","current","seenAliases","useOf","alias","use","propertyKey","via","imports","analyseBundle","source","problems","seen","status","level","check","message","unknownFrom","ids","summarise","detail","maxBytes","bytes","TextEncoder","encode","byteLength","toLocaleString","ok","checks","exports","register","registerApi","parseOptions","ecmaVersion","sourceType","allowHashBang","allowAwaitOutsideFunction","error","Error","aliases","noteAlias","bound","poisoned","poison","poisonPattern","forEach","pass","callableAliases","callableFrom","noteCallableAlias","callable","fromGlobal","declaredNetwork","allowlist","networkLevel","networkApis","networkOrigins","runtimeUrls","unresolvedOrigins","noteNetwork","api","urlArg","noteUnresolvedUrl","exportsRegister","exportsRegisterApi","noteExport","obfuscatedNames","specifier","exported","written","longestLine","split","reduce","longest","line","Math","max","filter","origins","abi","holds","problem","checkPluginBundle"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;CAmBC,GAED,SAASA,KAAK,QAAiC,QAAO;AACtD,4EAA4E;AAC5E,oDAAoD;AACpD,SACEC,2BAA2B,EAC3BC,gBAAgB,QACX,8CAA6C;AACpD,SAASC,qBAAqB,QAAQ,oDAAmD;AAEzF,SACEC,oBAAoB,EACpBC,kBAAkB,EAClBC,uBAAuB,QAClB,uBAAmB;AAC1B,SAASC,wBAAwB,QAAQ,oCAAgC;AAuEzE,MAAMC,eAA8C;IAClDR,OAAO;IACPS,OAAO;IACP,kBAAkB;IAClB,YAAY;IACZC,MAAM;IACN,kBAAkB;IAClBC,SAAS;IACTC,SAAS;IACT,kBAAkB;IAClBC,SAAS;IACTC,aAAa;IACbC,eAAe;IACfC,aAAa;AACf;AAEA,6EAA6E,GAC7E,MAAMC,cAA+B;IACnC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,OAAO,MAAMC,0BAA0B,QAAS;AAEhD;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,MAAMC,0BAA0B,GAAE;AAYzC;;;;;;;;CAQC,GACD,OAAO,SAASC,uBACdC,MAA8C,EAC9CC,MAAc;IAEd,IAAI,CAACD,UAAU,CAACC,QAAQ,OAAO;IAC/B,OACED,OAAOC,MAAM,KAAKA,UAClBC,OAAOF,OAAOG,eAAe,MAAML;AAEvC;AAEA;;;;;CAKC,GACD,MAAMM,eAAe,IAAIC,IAAI;IAC3B;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,gFAAgF,GAChF,MAAMC,gB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;;;;;;CAQC,GACD,OAAO,SAAS0K,kBACdxE,MAAc,EACdjG,OAAsB;IAEtB,IAAI;QACF,OAAOgG,cAAcC,QAAQjG;IAC/B,EAAE,OAAO4H,OAAO;QACd,OAAO;YACLV,IAAI;YACJhB,UAAU;gBACR;oBACEG,OAAO;oBACPC,OAAO;oBACPC,SACE,oEACA,CAAC,WAAW,EACVqB,iBAAiBC,QAAQD,MAAMrB,OAAO,GAAG7E,OAAOkG,QAChD;gBACN;aACD;YACDT,QAAQtN,YAAY2H,GAAG,CAAC,CAACjC,KAAQ,CAAA;oBAC/BA;oBACAwB,OAAO3H,YAAY,CAACmG,GAAG;oBACvB6G,QAAQ7G,OAAO,UAAU,SAAS;gBACpC,CAAA;YACA6H,SAAS;gBAAEC,UAAU;gBAAOC,aAAa;YAAM;YAC/C3N,eAAe2D;QACjB;IACF;AACF"}
|
|
1
|
+
{"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/plugin-bundle-checks.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\n/**\n * Static plugin-bundle checks (AGL-426) — Strapi `strapi-plugin verify`\n * parity, but ALSO enforced server-side: the publish API runs the same\n * checks, so a bundle that fails locally fails there identically.\n *\n * The bundle is PARSED and the tree analysed (AGL-964). The checks used to\n * match source text with regexes, which meant they could not see computed\n * member access, could not follow a value into a call, and could not tell\n * code from a comment — `g['ev'+'al'](…)` passed while the words `eval(`\n * inside a comment failed. On a minified bundle, which every published\n * artifact is, that is close to no signal at all.\n *\n * These are still cheap heuristics, NOT a sandbox: they catch honest build\n * mistakes (leftover imports, missing entry exports, oversized bundles),\n * flag the APIs the platform never wants in marketplace code, and surface\n * the questions a reviewer should ask. A determined author can still hide\n * intent from any static pass. The real security boundary stays the trust\n * chain (sandbox iframe + per-manifest CSP / staff review + realm signing /\n * sha pinning / the kill switch).\n */\n\nimport { parse, type Node, type Options } from 'acorn'\n// The leaf, not the barrel: the phishing screen's own reading of an input's\n// type, autocomplete token and raw HTML (AGL-3362).\nimport {\n credentialForInputAttribute,\n credentialInHtml,\n} from '@aglyn/shared-util-email/hosted-page-screen'\nimport { lookalikeBrandForHost } from '@aglyn/shared-util-email/outbound-phishing-screen'\nimport type { PluginContributions } from '../plugin-manager/plugin-contributions'\nimport {\n PLUGIN_HOST_ABI_KEYS,\n PLUGIN_HOST_GLOBAL,\n PLUGIN_HOST_MODULE_KEYS,\n} from './plugin-host-abi'\nimport { REALM_HOST_SURFACE_NAMES } from './realm-host-surface.generated'\n\n/** The areas the verifier reports on, in the order a reviewer reads them. */\nexport type BundleCheckId =\n | 'parse'\n | 'entry'\n | 'self-contained'\n | 'host-abi'\n | 'size'\n | 'code-execution'\n | 'globals'\n | 'storage'\n | 'dynamic-import'\n | 'network'\n | 'obfuscation'\n | 'contributions'\n | 'credentials'\n\nexport interface BundleCheckProblem {\n level: 'error' | 'warning'\n message: string\n /**\n * Which check produced this. Optional so a verdict stored by an older\n * checker still reads — those findings render on their own rather than\n * under a check row.\n */\n check?: BundleCheckId\n}\n\n/**\n * `unknown` is the one that earns its keep (AGL-1087). A check that could\n * not run — the network diff with no manifest supplied, everything at all\n * when the parse failed — must not render as green, or the page tells a\n * reviewer something was verified when nothing looked at it.\n */\nexport type BundleCheckStatus = 'pass' | 'fail' | 'question' | 'unknown'\n\nexport interface BundleCheckSummary {\n id: BundleCheckId\n /** Reviewer-facing name of the area. */\n label: string\n status: BundleCheckStatus\n /** What the check actually saw, when that is worth stating on its own. */\n detail?: string\n}\n\nexport interface BundleCheckResult {\n ok: boolean\n problems: BundleCheckProblem[]\n /** Every area, including the ones that found nothing (AGL-1087). */\n checks: BundleCheckSummary[]\n /** Which entry exports the source declares. */\n exports: { register: boolean; registerApi: boolean }\n /** What `register()` visibly registers (AGL-3116). */\n contributions: DetectedContributions\n}\n\n/**\n * What a bundle's `register()` visibly registers (AGL-3116): the declaration\n * its registration calls imply, read from the tree.\n */\nexport interface DetectedContributions {\n contributes: PluginContributions\n /**\n * Registrations the checker saw and could not read — an argument built at\n * runtime. What they contribute is unknown, so a declaration cannot be\n * checked against them and a reviewer has to read them.\n */\n unresolved: string[]\n}\n\nconst CHECK_LABELS: Record<BundleCheckId, string> = {\n parse: 'Parses as an ES module',\n entry: 'Exports an entry point',\n 'self-contained': 'Self-contained (no static imports)',\n 'host-abi': 'Reads only what the host provides',\n size: 'Within the size limit',\n 'code-execution': 'No eval / Function constructor',\n globals: 'No computed access on a global',\n storage: 'No direct storage or cookie access',\n 'dynamic-import': 'No dynamic import of unknown code',\n network: 'Network calls match the manifest',\n obfuscation: 'No obfuscation shapes',\n contributions: 'Registrations match the declared contributions',\n credentials: 'No password, card or one-time-code inputs',\n}\n\n/** Check order as displayed — findings first would reorder on every bundle. */\nconst CHECK_ORDER: BundleCheckId[] = [\n 'parse',\n 'entry',\n 'self-contained',\n 'host-abi',\n 'size',\n 'code-execution',\n 'globals',\n 'storage',\n 'dynamic-import',\n 'network',\n 'obfuscation',\n 'contributions',\n 'credentials',\n]\n\nexport const MAX_PLUGIN_BUNDLE_BYTES = 1_000_000\n\n/**\n * Stamped onto a cached verdict (AGL-962) so a stored result outlives only\n * the checker that produced it.\n *\n * `checkPluginBundle` is pure over immutable, content-addressed bytes, so a\n * verdict for a given sha256 never changes — but the CHECKS do. **Bump this\n * whenever a rule is added, removed or loosened**, and every stored verdict\n * from the old checker is ignored and recomputed on next read. Forgetting to\n * bump means a reviewer sees a verdict from a checker that no longer exists,\n * which is the failure mode re-running the verifier was meant to prevent.\n *\n * 2 — AST analysis replaces the regex scan (AGL-964).\n * 3 — per-check summary added to the verdict (AGL-1087).\n * 4 — calls through an alias are resolved (AGL-1090).\n * 5 — URLs held in a constant are resolved (AGL-1093).\n * 6 — registrations are compared with the declared contributions (AGL-3116).\n * 7 — inputs that collect a password, card or one-time code (AGL-3362).\n * 8 — declared network origins that are a brand's lookalike (AGL-3365).\n * 9 — lookups on the host ABI name only keys a host provides (AGL-3392).\n */\nexport const PLUGIN_VERIFIER_VERSION = 10\n\n/** A verdict as stored on a `pluginVersions` doc (AGL-962). */\nexport interface StoredBundleVerdict {\n ok?: boolean\n problems?: BundleCheckProblem[]\n /** Present from verifier 3 on (AGL-1087). */\n checks?: BundleCheckSummary[]\n sha256?: string\n verifierVersion?: number\n}\n\n/**\n * Whether a stored verdict may be served instead of re-running the checks.\n *\n * Fails closed on every mismatch: no verdict, a verdict for different bytes\n * (a republished version keeps its version string but changes sha), or a\n * verdict from a checker that has since changed. Any of those means\n * download-and-recompute, which costs one page view rather than showing a\n * reviewer a verdict that was never true of the bundle in front of them.\n */\nexport function isStoredVerdictCurrent(\n stored: StoredBundleVerdict | null | undefined,\n sha256: string,\n): boolean {\n if (!stored || !sha256) return false\n return (\n stored.sha256 === sha256 &&\n Number(stored.verifierVersion) === PLUGIN_VERIFIER_VERSION\n )\n}\n\n/**\n * Globals whose properties are the platform's business. Computed access on\n * one of these is flagged as computed access rather than by trying to\n * enumerate the property names an author might reach — `g[k]` hides its\n * property from any static pass, so the ACCESS is the finding.\n */\nconst GLOBAL_ROOTS = new Set([\n 'globalThis',\n 'window',\n 'self',\n 'top',\n 'parent',\n 'frames',\n 'document',\n])\n\n/** Storage the platform never wants reached directly (use host-mediated data). */\nconst STORAGE_NAMES = new Set(['localStorage', 'sessionStorage', 'indexedDB'])\n\n/** Network entry points, by the name they are called/constructed under. */\nconst NETWORK_CALLS = new Set(['fetch', 'sendBeacon'])\nconst NETWORK_CONSTRUCTORS = new Set([\n 'XMLHttpRequest',\n 'WebSocket',\n 'EventSource',\n])\n\n/**\n * Names worth following through an alias (AGL-1090).\n *\n * `const f = fetch; f(url)` used to pass every check, and the network row\n * rendered a green \"no network calls\" rather than going quiet — a two-line\n * indirection defeating the signal this whole verifier exists to produce.\n * Aliasing a VALUE was the exact gap the project was created to close, and\n * resolving global objects (`const g = globalThis`) never covered it.\n *\n * Reassignment, `arr[0]`, an object property and passing the function as an\n * argument all stay out of reach. The bar is that the cheap form is not free.\n */\nconst ALIASABLE_CALLABLES = new Set([\n 'eval',\n 'Function',\n 'fetch',\n 'sendBeacon',\n 'XMLHttpRequest',\n 'WebSocket',\n 'EventSource',\n])\n\n/**\n * Callees that legitimately take an absolute URL and reach nothing — so a URL\n * literal passed to them is not a call the network check failed to follow.\n * `createElementNS` matters most: an SVG namespace argument appears in a large\n * share of real bundles.\n */\nconst URL_TAKING_NON_CALLS = new Set([\n 'URL',\n 'URLSearchParams',\n 'createElementNS',\n 'createDocument',\n])\n\n/** Beyond this, a single line is not source a reviewer can read. */\nconst MAX_READABLE_LINE = 100_000\n/** A base64 blob at least this long is worth decoding before approving. */\nconst MIN_SUSPICIOUS_BASE64 = 1024\n/** How many `_0x…` names before the bundle counts as machine-obfuscated. */\nconst MIN_OBFUSCATED_NAMES = 5\n/** Verdicts are stored on a version doc; keep them bounded. */\nconst MAX_PROBLEMS = 40\n\nconst OBFUSCATED_NAME = /^_0x[0-9a-f]{4,}$/i\nconst BASE64_BLOB = /^[A-Za-z0-9+/\\r\\n]+={0,2}$/\n\ntype AnyNode = Node & Record<string, unknown>\n\n/**\n * Child keys that are NOT expressions in the surrounding scope — a\n * non-computed `.property`, an object literal key, a label. Walking into\n * them would read `x.localStorage` on an unrelated object as a global\n * storage access.\n */\nconst skippedChild = (node: AnyNode, key: string): boolean => {\n switch (node.type) {\n case 'MemberExpression':\n return key === 'property' && !node['computed']\n case 'Property':\n case 'PropertyDefinition':\n case 'MethodDefinition':\n return key === 'key' && !node['computed']\n case 'LabeledStatement':\n case 'BreakStatement':\n case 'ContinueStatement':\n return key === 'label'\n case 'ImportSpecifier':\n case 'ExportSpecifier':\n return true\n default:\n return false\n }\n}\n\n/** Depth-first walk over every expression-position node in the tree. */\nfunction walk(root: AnyNode, visit: (node: AnyNode) => void): void {\n const stack: AnyNode[] = [root]\n while (stack.length) {\n const node = stack.pop()\n if (!node) continue\n visit(node)\n for (const key of Object.keys(node)) {\n if (key === 'type' || key === 'start' || key === 'end') continue\n if (skippedChild(node, key)) continue\n const value = node[key]\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item && typeof item === 'object' && typeof item.type === 'string')\n stack.push(item as AnyNode)\n }\n } else if (\n value &&\n typeof value === 'object' &&\n typeof (value as AnyNode).type === 'string'\n ) {\n stack.push(value as AnyNode)\n }\n }\n }\n}\n\n/**\n * The string a node evaluates to, when that is knowable without running it.\n * Covers the shapes used to hide a property name from a text scan: a\n * string literal, a template with no interpolation, and literals added\n * together (`'ev' + 'al'`).\n */\nfunction staticString(\n node: AnyNode | null | undefined,\n constants?: ReadonlyMap<string, string>,\n): string | null {\n if (!node) return null\n if (node.type === 'Literal')\n return typeof node['value'] === 'string' ? (node['value'] as string) : null\n // A name bound once to a constant string (AGL-1093). `const ENDPOINT =\n // 'https://…'; fetch(ENDPOINT)` is the idiomatic way to write a request,\n // and refusing to read it meant the network diff quietly did not run for\n // the bundles most likely to be honest.\n if (node.type === 'Identifier' && constants)\n return constants.get(node['name'] as string) ?? null\n if (node.type === 'TemplateLiteral') {\n const expressions = (node['expressions'] ?? []) as AnyNode[]\n const quasis = (node['quasis'] ?? []) as Array<{\n value: { cooked?: string }\n }>\n if (!expressions.length) {\n return quasis.length === 1 ? quasis[0]?.value?.cooked ?? null : null\n }\n // `${BASE}/zen` — resolvable exactly when every hole is.\n let out = ''\n for (let index = 0; index < quasis.length; index += 1) {\n out += quasis[index]?.value?.cooked ?? ''\n if (index < expressions.length) {\n const filled = staticString(expressions[index], constants)\n if (filled === null) return null\n out += filled\n }\n }\n return out\n }\n if (node.type === 'BinaryExpression' && node['operator'] === '+') {\n const left = staticString(node['left'] as AnyNode, constants)\n const right = staticString(node['right'] as AnyNode, constants)\n return left !== null && right !== null ? left + right : null\n }\n return null\n}\n\n/** The property name a member expression reads, computed or not. */\nfunction propertyName(\n node: AnyNode,\n constants?: ReadonlyMap<string, string>,\n): string | null {\n const property = node['property'] as AnyNode\n if (!node['computed'])\n return property?.type === 'Identifier'\n ? (property['name'] as string)\n : null\n return staticString(property, constants)\n}\n\n/**\n * The origin of a URL argument, when it is a knowable http(s) URL.\n *\n * Scheme-checked HERE, once (AGL-1094). An opaque origin — every `data:`,\n * `blob:` and `javascript:` URL — makes `new URL(x).origin` the STRING\n * `\"null\"`, and a caller that then re-parsed that string threw `Invalid URL`\n * and took the whole checker down with it. Nothing downstream should have to\n * know that, so nothing downstream gets the chance.\n */\nfunction literalOrigin(\n node: AnyNode | undefined,\n constants?: ReadonlyMap<string, string>,\n): string | null {\n const value = staticString(node, constants)\n if (!value) return null\n try {\n const url = new URL(value)\n return /^https?:$/.test(url.protocol) ? url.origin : null\n } catch {\n return null\n }\n}\n\ninterface CheckOptions {\n maxBytes?: number\n /**\n * The origins the manifest declares under `capabilities.network`. A\n * network call the manifest does not account for is the single most\n * useful signal the tree makes available — and the per-manifest CSP\n * would block it at runtime anyway, so the bundle and its manifest\n * disagreeing is a bug the publisher wants to hear about at publish\n * time, not a mystery in production. Undefined = \"not supplied\", which\n * downgrades those findings to warnings, because a checker that was\n * never told what was declared cannot claim anything was undeclared.\n */\n declaredNetwork?: string[]\n /**\n * The manifest's `contributes` block (AGL-3116): `null` when the manifest\n * declares none, `undefined` when no manifest was supplied — which leaves\n * the comparison `unknown`, as the network diff is without its manifest.\n */\n declaredContributions?: PluginContributions | null\n /**\n * Refuse a bundle that registers something while its manifest declares no\n * contributions at all. Set where a NEW version is judged — the publish\n * pipeline and the local verifier that mirrors it. The review page and the\n * re-verification sweep judge versions published before the contract,\n * which load under its default, and a rule they were never held to must\n * not turn them red after the fact.\n */\n requireContributions?: boolean\n}\n\n/** The detection result of a bundle no pass could read. */\nconst NOTHING_DETECTED: DetectedContributions = { contributes: {}, unresolved: [] }\n\n/**\n * Registration calls whose argument says what a bundle contributes, by the\n * name they are reached through: `h.aglyn.registerConsoleExtension(...)`,\n * `registerConsoleExtension(...)` after the realm template's host mapping,\n * `aglyn.components.registerComponent(...)`.\n */\nconst REGISTRATION_CALLS = new Set([\n 'registerConsoleExtension',\n 'registerSiteRuntime',\n 'registerComponent',\n 'addDependency',\n 'defineUiFeatureBundle',\n])\n\n/**\n * Console extension fields the shell draws on every screen of a workspace:\n * nav tabs, organization tabs, providers, staff pages and the dashboard and\n * settings entries. A plugin registering any of them loads with the shell.\n */\nconst SHELL_EXTENSION_FIELDS = [\n 'navItems',\n 'orgNavItems',\n 'providers',\n 'staffPages',\n 'dashboardCards',\n 'settingsSections',\n]\n\n/**\n * What `register()` visibly registers (AGL-3116), read from the tree.\n *\n * A heuristic like every check here: it reads registration calls whose\n * arguments are written out — an object literal, a string or a named slot —\n * and reports every call it cannot read as `unresolved` rather than guessing.\n * The declaration stays the contract; this is how a publisher learns theirs\n * is incomplete before a published page fails to load the plugin.\n */\nfunction detectRegistrations(\n program: AnyNode,\n constants: ReadonlyMap<string, string>,\n): DetectedContributions {\n const slots = new Set<string>()\n const routes = new Set<string>()\n const orgRoutes = new Set<string>()\n const components = new Set<string>()\n const features = new Set<string>()\n const unresolved = new Set<string>()\n let shell = false\n\n const objectProperty = (\n object: AnyNode | undefined,\n name: string,\n ): AnyNode | undefined => {\n if (object?.type !== 'ObjectExpression') return undefined\n for (const property of (object['properties'] ?? []) as AnyNode[]) {\n if (property.type !== 'Property') continue\n const key = property['key'] as AnyNode\n const keyName =\n !property['computed'] && key?.type === 'Identifier'\n ? (key['name'] as string)\n : staticString(key, constants)\n if (keyName === name) return property['value'] as AnyNode\n }\n return undefined\n }\n const listOf = (node: AnyNode | undefined): AnyNode[] | null =>\n node?.type === 'ArrayExpression' ? ((node['elements'] ?? []) as AnyNode[]) : null\n // A slot as a widget names it: a string, or a catalog entry\n // (`CONSOLE_WIDGET_SLOTS.hostActivity`), whose property IS the slot id.\n const slotName = (node: AnyNode | undefined): string | null => {\n const literal = staticString(node, constants)\n if (literal !== null) return literal\n return node?.type === 'MemberExpression' ? propertyName(node, constants) : null\n }\n\n walk(program, (node) => {\n if (node.type !== 'CallExpression') return\n const callee = node['callee'] as AnyNode\n const name =\n callee?.type === 'Identifier'\n ? (callee['name'] as string)\n : callee?.type === 'MemberExpression'\n ? propertyName(callee, constants)\n : null\n if (!name || !REGISTRATION_CALLS.has(name)) return\n const args = (node['arguments'] ?? []) as AnyNode[]\n if (name === 'registerConsoleExtension') {\n const extension = args[0]\n if (extension?.type !== 'ObjectExpression') {\n unresolved.add('a console extension built at runtime')\n return\n }\n const widgets = objectProperty(extension, 'widgets')\n if (widgets) {\n const list = listOf(widgets)\n if (!list) unresolved.add('a console widget list built at runtime')\n for (const widget of list ?? []) {\n const slot = slotName(objectProperty(widget, 'slot'))\n if (slot) slots.add(slot)\n else unresolved.add('a console widget whose slot is built at runtime')\n }\n }\n for (const field of SHELL_EXTENSION_FIELDS) {\n const value = objectProperty(extension, field)\n if (!value) continue\n shell = true\n if (field !== 'navItems' && field !== 'orgNavItems') continue\n const into = field === 'navItems' ? routes : orgRoutes\n const list = listOf(value)\n if (!list) unresolved.add(`console ${field} built at runtime`)\n for (const item of list ?? []) {\n const href = staticString(objectProperty(item, 'href'), constants)\n if (href) into.add(href)\n else unresolved.add(`a console ${field} entry whose href is built at runtime`)\n }\n }\n return\n }\n if (name === 'registerSiteRuntime') {\n const id = staticString(objectProperty(args[0], 'runtimeId'), constants)\n if (id) features.add(id)\n else unresolved.add('a site runtime whose runtimeId is built at runtime')\n return\n }\n if (name === 'registerComponent') {\n const id = staticString(objectProperty(args[1], '$id'), constants)\n if (id) components.add(id)\n else unresolved.add('a canvas component whose $id is built at runtime')\n return\n }\n // `addDependency` / `defineUiFeatureBundle`: a component bundle whose\n // entries register later, from a list this pass does not follow.\n unresolved.add('a canvas component bundle')\n })\n\n const contributes: PluginContributions = {}\n if (components.size || features.size) {\n contributes.site = {\n ...(components.size ? { components: [...components].sort() } : {}),\n ...(features.size ? { features: [...features].sort() } : {}),\n }\n }\n if (slots.size || routes.size || orgRoutes.size || shell) {\n contributes.console = {\n ...(slots.size ? { slots: [...slots].sort() } : {}),\n ...(routes.size ? { routes: [...routes].sort() } : {}),\n ...(orgRoutes.size ? { orgRoutes: [...orgRoutes].sort() } : {}),\n ...(shell ? { shell: true } : {}),\n }\n }\n return { contributes, unresolved: [...unresolved].sort() }\n}\n\n/** A declaration in the words a reviewer reads: `console slots hostActivity`. */\nfunction describeContributions(contributes: PluginContributions): string {\n const parts: string[] = []\n const site = contributes.site ?? {}\n const shell = contributes.console ?? {}\n if (site.components?.length) parts.push(`site components ${site.components.join(', ')}`)\n if (site.features?.length) parts.push(`site features ${site.features.join(', ')}`)\n if (shell.slots?.length) parts.push(`console slots ${shell.slots.join(', ')}`)\n if (shell.routes?.length) parts.push(`console routes ${shell.routes.join(', ')}`)\n if (shell.orgRoutes?.length) {\n parts.push(`console organization routes ${shell.orgRoutes.join(', ')}`)\n }\n if (shell.shell) parts.push('the console shell')\n return parts.join(' · ') || 'nothing'\n}\n\n/**\n * The `contributions` area (AGL-3116): what the bundle registers against what\n * its manifest declares.\n *\n * Every registration the tree shows must be declared, because the loaders\n * read ONLY the declaration: a slot the manifest omits is a slot whose\n * screens never load the plugin, and a component it omits is an element that\n * renders empty on every published page that places it. A declared entry the\n * bundle never registers is a warning — the plugin loads there for nothing.\n */\nfunction compareContributions(\n detected: DetectedContributions,\n options: CheckOptions | undefined,\n add: (\n level: BundleCheckProblem['level'],\n check: BundleCheckId,\n message: string,\n ) => void,\n details: Map<BundleCheckId, string>,\n markUnknown: (check: BundleCheckId) => void,\n): void {\n const found = detected.contributes\n const registers = describeContributions(found)\n const registersSomething =\n Boolean(found.site || found.console) || detected.unresolved.length > 0\n const unreadable = detected.unresolved.length\n ? ` It also makes registrations the checker could not read: ${detected.unresolved.join('; ')}.`\n : ''\n const declared = options?.declaredContributions\n if (declared === undefined) {\n // Nothing to compare against is `unknown`, never a pass — the same\n // reading the network row gives a bundle checked without its manifest.\n if (!registersSomething) {\n details.set('contributions', 'registers nothing')\n return\n }\n markUnknown('contributions')\n details.set(\n 'contributions',\n `registers ${registers} — no manifest was supplied, so nothing was compared`,\n )\n return\n }\n if (declared === null) {\n details.set(\n 'contributions',\n registersSomething ? `undeclared · registers ${registers}` : 'declares and registers nothing',\n )\n if (!registersSomething) return\n add(\n options?.requireContributions ? 'error' : 'warning',\n 'contributions',\n `the manifest declares no \"contributes\", and register() registers ` +\n `${registers}.${unreadable} Declare it — ` +\n `\"contributes\": ${JSON.stringify(found)} — because the loaders place ` +\n 'a plugin by its declaration alone. Undeclared, a published page ' +\n 'loads it only where its element is placed and the console loads it ' +\n 'with the shell.',\n )\n return\n }\n\n details.set('contributions', `declares ${describeContributions(declared)}`)\n const missing = (\n label: string,\n registered: readonly string[] | undefined,\n listed: readonly string[] | undefined,\n consequence: string,\n ) => {\n for (const id of registered ?? []) {\n if ((listed ?? []).includes(id)) continue\n add(\n 'error',\n 'contributions',\n `register() registers ${label} \"${id}\", which the manifest does not ` +\n `declare — ${consequence}`,\n )\n }\n }\n missing(\n 'the site component',\n found.site?.components,\n declared.site?.components,\n 'a published page that places it would never load the plugin',\n )\n missing(\n 'the site feature',\n found.site?.features,\n declared.site?.features,\n 'no published page would ever load the plugin to run it',\n )\n missing(\n 'a widget in the console slot',\n found.console?.slots,\n declared.console?.slots,\n 'a console page that renders the slot would never load the plugin',\n )\n missing(\n 'the console route',\n found.console?.routes,\n declared.console?.routes,\n 'the route would not find the plugin that serves it',\n )\n missing(\n 'the console organization route',\n found.console?.orgRoutes,\n declared.console?.orgRoutes,\n 'the route would not find the plugin that serves it',\n )\n if (found.console?.shell && !declared.console?.shell) {\n add(\n 'error',\n 'contributions',\n 'register() adds a nav tab, a provider or another entry the console ' +\n 'shell draws on every page, and the manifest does not declare ' +\n '\"console\": { \"shell\": true } — the shell would draw it only on ' +\n 'pages that happened to load the plugin for something else',\n )\n }\n if (detected.unresolved.length) {\n add(\n 'warning',\n 'contributions',\n `the checker could not read ${detected.unresolved.join('; ')} — ` +\n 'confirm the declaration covers what it registers',\n )\n }\n const unused = (\n label: string,\n listed: readonly string[] | undefined,\n registered: readonly string[] | undefined,\n ) => {\n // Only when every registration of that kind was readable: an unreadable\n // one may be exactly the entry that is declared.\n if (detected.unresolved.length) return\n for (const id of listed ?? []) {\n if ((registered ?? []).includes(id)) continue\n add(\n 'warning',\n 'contributions',\n `the manifest declares ${label} \"${id}\", and register() never ` +\n 'registers it — the plugin would load there for nothing',\n )\n }\n }\n unused('the site component', declared.site?.components, found.site?.components)\n unused('the site feature', declared.site?.features, found.site?.features)\n unused('the console slot', declared.console?.slots, found.console?.slots)\n}\n\n/**\n * Inputs a bundle builds that collect a password, a card number or a\n * one-time code (AGL-3362) — a reviewer's QUESTION, never a failure.\n *\n * The phishing screen holds a published page whose author defined such a\n * field, but a plugin renders its own inputs from code the page screen never\n * reads. So the same reading is applied here, to the bundle, at review: an\n * input's `type` or `autocomplete` in an object literal (`createElement`\n * props, a JSX runtime call, a DOM `Object.assign`), in `setAttribute`, and\n * in any HTML string. A warning rather than an error because a legitimate\n * plugin can own a sign-in (a members-only area, a booking account); what the\n * reviewer asks is whether its credentials go anywhere but its declared\n * origins. The sandbox tier cannot post a native form at all — its frame\n * has no `allow-forms` and its CSP says `form-action 'none'` — so the\n * question is about `connect-src`, which the network check already lists.\n */\nfunction credentialInputsIn(\n program: AnyNode,\n constants: ReadonlyMap<string, string>,\n): string[] {\n const found = new Set<'password' | 'card' | 'otp'>()\n const keyOf = (node: AnyNode): string | null => {\n const key = node['key'] as AnyNode\n if (!key) return null\n if (!node['computed'] && key.type === 'Identifier') return key['name'] as string\n return staticString(key, constants)\n }\n walk(program, (node) => {\n if (node.type === 'Property') {\n const key = keyOf(node)\n const value = staticString(node['value'] as AnyNode, constants)\n const field = key && value !== null ? credentialForInputAttribute(key, value) : null\n if (field) found.add(field)\n } else if (node.type === 'CallExpression') {\n const callee = node['callee'] as AnyNode\n const args = (node['arguments'] ?? []) as AnyNode[]\n if (callee?.type === 'MemberExpression' && propertyName(callee, constants) === 'setAttribute') {\n const name = staticString(args[0], constants)\n const value = staticString(args[1], constants)\n const field = name !== null && value !== null ? credentialForInputAttribute(name, value) : null\n if (field) found.add(field)\n }\n } else if (node.type === 'Literal' && typeof node['value'] === 'string') {\n const field = credentialInHtml(node['value'] as string)\n if (field) found.add(field)\n } else if (node.type === 'TemplateLiteral') {\n const text = ((node['quasis'] ?? []) as AnyNode[])\n .map((quasi) => String((quasi['value'] as { cooked?: string } | undefined)?.cooked ?? ''))\n .join('')\n const field = credentialInHtml(text)\n if (field) found.add(field)\n }\n })\n const words = { password: 'a password', card: 'a card number or security code', otp: 'a one-time code' }\n return [...found].map(\n (field) =>\n `builds an input that collects ${words[field]} — confirm what it is for, and that ` +\n 'it is sent only to the origins the manifest declares',\n )\n}\n\n/**\n * Declared network origins that wear a brand without being the brand's\n * (AGL-3365) — a reviewer's QUESTION, read with the phishing screen's own\n * lookalike rule (`lookalikeBrandForHost`), the one that holds a link in an\n * email or on a page.\n *\n * The manifest's origins are what the loader stamps into the plugin frame's\n * `connect-src`, so they are exactly where a plugin's data and a visitor's\n * input can go. A plugin that integrates with PayPal declares\n * `https://api-m.paypal.com`, which is PayPal's own domain and passes; one that\n * declares `https://paypal-verify.net` or `https://aglyn-billing.com` is\n * sending somewhere dressed as somebody else. A warning rather than an error\n * because every plugin version is reviewed before it installs, and the\n * reviewer is the one who can ask whose domain it is.\n */\nfunction lookalikeDeclaredOrigins(declared: readonly string[]): string[] {\n const messages: string[] = []\n for (const origin of declared) {\n let host: string\n try {\n host = new URL(origin).hostname\n } catch {\n continue\n }\n const brand = lookalikeBrandForHost(host)\n if (brand) {\n messages.push(\n `the manifest declares ${origin}, which wears the ${brand.label} name ` +\n `but is not ${brand.label}'s domain — confirm whose it is before approving`,\n )\n }\n }\n return messages\n}\n\n/**\n * Walks every expression-position node with its parent, by the same rules as\n * {@link walk}.\n */\nfunction walkWithParents(\n root: AnyNode,\n visit: (node: AnyNode, parent: AnyNode | null) => void,\n): void {\n const stack: Array<[AnyNode, AnyNode | null]> = [[root, null]]\n while (stack.length) {\n const entry = stack.pop()\n if (!entry) continue\n const [node, parent] = entry\n visit(node, parent)\n for (const key of Object.keys(node)) {\n if (key === 'type' || key === 'start' || key === 'end') continue\n if (skippedChild(node, key)) continue\n const value = node[key]\n const children = Array.isArray(value) ? value : [value]\n for (const child of children) {\n if (\n child &&\n typeof child === 'object' &&\n typeof (child as AnyNode).type === 'string'\n ) {\n stack.push([child as AnyNode, node])\n }\n }\n }\n }\n}\n\nconst FUNCTION_TYPES = new Set([\n 'FunctionDeclaration',\n 'FunctionExpression',\n 'ArrowFunctionExpression',\n])\n\n/** Nodes that open a scope a name can be declared in. */\nconst SCOPE_TYPES = new Set([\n 'Program',\n ...FUNCTION_TYPES,\n 'BlockStatement',\n 'StaticBlock',\n 'SwitchStatement',\n 'CatchClause',\n 'ForStatement',\n 'ForInStatement',\n 'ForOfStatement',\n 'ClassExpression',\n])\n\n/** The names a binding pattern declares: `a`, `{ a, b: c }`, `[a, ...b]`, `a = 1`. */\nfunction patternNames(pattern: AnyNode | null | undefined, into: Set<string>): void {\n if (!pattern) return\n switch (pattern.type) {\n case 'Identifier':\n into.add(pattern['name'] as string)\n return\n case 'AssignmentPattern':\n return patternNames(pattern['left'] as AnyNode, into)\n case 'RestElement':\n return patternNames(pattern['argument'] as AnyNode, into)\n case 'ArrayPattern':\n for (const element of (pattern['elements'] ?? []) as AnyNode[]) patternNames(element, into)\n return\n case 'ObjectPattern':\n for (const property of (pattern['properties'] ?? []) as AnyNode[]) {\n patternNames(\n (property.type === 'RestElement' ? property : property['value']) as AnyNode,\n into,\n )\n }\n return\n }\n}\n\n/** The declarations a statement list makes itself: `let`/`const`/`class`/`function`. */\nfunction lexicalNames(statements: readonly AnyNode[], into: Set<string>): void {\n for (const statement of statements) {\n if (statement?.type === 'VariableDeclaration' && statement['kind'] !== 'var') {\n for (const declarator of (statement['declarations'] ?? []) as AnyNode[]) {\n patternNames(declarator['id'] as AnyNode, into)\n }\n }\n if (\n (statement?.type === 'FunctionDeclaration' || statement?.type === 'ClassDeclaration') &&\n statement['id']\n ) {\n into.add((statement['id'] as AnyNode)['name'] as string)\n }\n }\n}\n\n/** Every `var` a function body declares, however deep, short of a nested function. */\nfunction varNames(node: AnyNode | null | undefined, into: Set<string>): void {\n if (!node || typeof node !== 'object') return\n if (FUNCTION_TYPES.has(node.type)) return\n if (node.type === 'VariableDeclaration' && node['kind'] === 'var') {\n for (const declarator of (node['declarations'] ?? []) as AnyNode[]) {\n patternNames(declarator['id'] as AnyNode, into)\n }\n }\n for (const [field, value] of Object.entries(node)) {\n if (field === 'type' || !value || typeof value !== 'object') continue\n if (Array.isArray(value)) for (const child of value) varNames(child as AnyNode, into)\n else if ('type' in (value as object)) varNames(value as AnyNode, into)\n }\n}\n\n/** The names a scope node declares for its own body. */\nfunction declaredNames(scope: AnyNode): Set<string> {\n const names = new Set<string>()\n if (FUNCTION_TYPES.has(scope.type)) {\n for (const param of (scope['params'] ?? []) as AnyNode[]) patternNames(param, names)\n if (scope.type === 'FunctionExpression' && scope['id']) {\n names.add((scope['id'] as AnyNode)['name'] as string)\n }\n const body = scope['body'] as AnyNode\n if (body?.type === 'BlockStatement') {\n for (const statement of (body['body'] ?? []) as AnyNode[]) varNames(statement, names)\n lexicalNames((body['body'] ?? []) as AnyNode[], names)\n }\n return names\n }\n switch (scope.type) {\n case 'Program':\n case 'BlockStatement':\n case 'StaticBlock':\n lexicalNames((scope['body'] ?? []) as AnyNode[], names)\n break\n case 'SwitchStatement':\n for (const branch of (scope['cases'] ?? []) as AnyNode[]) {\n lexicalNames((branch['consequent'] ?? []) as AnyNode[], names)\n }\n break\n case 'CatchClause':\n patternNames(scope['param'] as AnyNode, names)\n break\n case 'ForStatement':\n case 'ForInStatement':\n case 'ForOfStatement': {\n const head = (scope['init'] ?? scope['left']) as AnyNode | null\n if (head?.type === 'VariableDeclaration' && head['kind'] !== 'var') lexicalNames([head], names)\n break\n }\n case 'ClassExpression':\n if (scope['id']) names.add((scope['id'] as AnyNode)['name'] as string)\n break\n }\n return names\n}\n\n/**\n * Whether an identifier refers to a variable, rather than naming a property,\n * a key or a label.\n */\nfunction isReference(node: AnyNode, parent: AnyNode | null | undefined): boolean {\n if (!parent) return true\n switch (parent.type) {\n case 'MemberExpression':\n return parent['object'] === node || parent['computed'] === true\n case 'Property':\n if (parent['key'] === node && parent['computed'] !== true) {\n return parent['shorthand'] === true && parent['value'] === node\n }\n return true\n case 'MethodDefinition':\n case 'PropertyDefinition':\n return parent['key'] !== node || parent['computed'] === true\n case 'LabeledStatement':\n case 'BreakStatement':\n case 'ContinueStatement':\n return false\n case 'ExportSpecifier':\n return parent['local'] === node\n case 'ImportSpecifier':\n case 'ImportDefaultSpecifier':\n case 'ImportNamespaceSpecifier':\n return false\n default:\n return true\n }\n}\n\n/**\n * What a bundle reads from the host ABI (AGL-3392), read off the bytes.\n *\n * The realm Rollup configs compile each host import into\n * `const host = globalThis.__AGLYN_PLUGIN_HOST__; … host[\"mui\"]`, and each use\n * of an import into a member read on that: `_aglynHost_mui.Button`. So:\n *\n * - `read` / `unknown` / `computed` are the KEYS a bundle reads off the host\n * object. A key outside `PLUGIN_HOST_ABI_KEYS` is undefined on every host\n * and the bundle fails where it is used; a key chosen at runtime cannot be\n * reviewed at all.\n * - `imports` is what it reads from each host MODULE, by name, so each name\n * can be checked against what the host holds. A module handed around as a\n * value (`import * as M`, a spread, a computed read) cannot be narrowed and\n * records `'*'`.\n *\n * The host is reached through `globalThis.__AGLYN_PLUGIN_HOST__`, a name bound\n * to it, or the parameter of the exported `register(host)` — the last only\n * inside `register` itself, since the same name elsewhere is another variable.\n * A bad key on that parameter is a warning rather than a refusal: bundles\n * written before this check read it freely, and refusing them would report a\n * regression on bytes that are already installed.\n */\nfunction hostAbiReads(\n program: AnyNode,\n constants: ReadonlyMap<string, string>,\n isGlobalRef: (node: AnyNode | null | undefined) => boolean,\n): {\n read: Set<string>\n unknown: Set<string>\n /** Read off `register`'s parameter, which could be a bundle's own mistake. */\n unknownOnParam: Set<string>\n computed: number\n computedOnParam: number\n imports: Partial<Record<string, readonly string[] | '*'>>\n} {\n const parents = new Map<AnyNode, AnyNode | null>()\n const identifiers = new Map<string, AnyNode[]>()\n walkWithParents(program, (node, parent) => {\n parents.set(node, parent)\n if (node.type === 'Identifier') {\n const name = node['name'] as string\n const list = identifiers.get(name)\n if (list) list.push(node)\n else identifiers.set(name, [node])\n }\n })\n // Scope (AGL-3394). A minifier names the host alias `e`, and names every\n // other function's first parameter `e` too, so a name only resolves to the\n // host where no nearer scope declares it again.\n const scopeNames = new Map<AnyNode, Set<string>>()\n const namesOf = (scope: AnyNode): Set<string> => {\n let found = scopeNames.get(scope)\n if (!found) {\n found = declaredNames(scope)\n scopeNames.set(scope, found)\n }\n return found\n }\n /** The scope a declarator's name belongs to: its function for `var`, else its block. */\n const bindingScope = (declarator: AnyNode): AnyNode | null => {\n const declaration = parents.get(declarator)\n const functionScoped = declaration?.['kind'] === 'var'\n for (let at = parents.get(declaration as AnyNode); at; at = parents.get(at)) {\n if (functionScoped ? FUNCTION_TYPES.has(at.type) || at.type === 'Program' : SCOPE_TYPES.has(at.type)) {\n return at\n }\n }\n return null\n }\n /** Whether `ref` means the binding `name` declared in `scope`. */\n const resolvesTo = (ref: AnyNode, name: string, scope: AnyNode | null): boolean => {\n if (!isReference(ref, parents.get(ref))) return false\n for (let at = parents.get(ref); at; at = parents.get(at)) {\n if (at === scope) return true\n if (SCOPE_TYPES.has(at.type) && namesOf(at).has(name)) return false\n }\n return scope === null\n }\n\n const isHostGlobal = (node: AnyNode | null | undefined): boolean =>\n (node?.type === 'Identifier' && node['name'] === PLUGIN_HOST_GLOBAL) ||\n (node?.type === 'MemberExpression' &&\n isGlobalRef(node['object'] as AnyNode) &&\n propertyName(node) === PLUGIN_HOST_GLOBAL)\n\n // Names bound to the host object, each with the scope it is declared in:\n // a declarator's block or function, or the `register(host)` function for its\n // parameter.\n const hostNames = new Map<string, { scope: AnyNode | null; param: boolean }>()\n walk(program, (node) => {\n if (node.type === 'VariableDeclarator') {\n const id = node['id'] as AnyNode\n const init = node['init'] as AnyNode | null\n const roots =\n init?.type === 'LogicalExpression'\n ? [init['left'] as AnyNode, init['right'] as AnyNode]\n : [init]\n if (id?.type === 'Identifier' && roots.some(isHostGlobal)) {\n hostNames.set(id['name'] as string, { scope: bindingScope(node), param: false })\n }\n }\n if (\n node.type === 'FunctionDeclaration' &&\n (node['id'] as AnyNode | null)?.['name'] === 'register'\n ) {\n const param = ((node['params'] ?? []) as AnyNode[])[0]\n if (param?.type === 'Identifier' && !hostNames.has(param['name'] as string)) {\n hostNames.set(param['name'] as string, { scope: node, param: true })\n }\n }\n })\n /** `'global'` for the host reached by name, `'param'` for `register(host)`. */\n const hostRef = (\n node: AnyNode | null | undefined,\n ): 'global' | 'param' | null => {\n if (isHostGlobal(node)) return 'global'\n if (node?.type !== 'Identifier') return null\n const name = node['name'] as string\n const binding = hostNames.get(name)\n if (!binding || !resolvesTo(node, name, binding.scope)) return null\n return binding.param ? 'param' : 'global'\n }\n\n const modules = new Set<string>(PLUGIN_HOST_MODULE_KEYS)\n const allowed = new Set<string>(PLUGIN_HOST_ABI_KEYS)\n const read = new Set<string>()\n const unknown = new Set<string>()\n const unknownOnParam = new Set<string>()\n let computed = 0\n let computedOnParam = 0\n const names = new Map<string, Set<string> | '*'>()\n const whole = (key: string): void => {\n names.set(key, '*')\n }\n const note = (key: string, name: string | null): void => {\n if (name === null) return whole(key)\n const current = names.get(key)\n if (current === '*') return\n if (current) current.add(name)\n else names.set(key, new Set([name]))\n }\n const seenAliases = new Set<AnyNode>()\n\n /** Records how one reference to a lazy key's module is used. */\n const useOf = (key: string, ref: AnyNode): void => {\n const parent = parents.get(ref)\n // A presence check reads no name from the module: `if (!h.aglyn) return`\n // is how a bundle stays inert on a host without the key, and every\n // example plugin does it.\n if (\n (parent?.type === 'UnaryExpression' &&\n (parent['operator'] === '!' || parent['operator'] === 'typeof')) ||\n ((parent?.type === 'IfStatement' || parent?.type === 'ConditionalExpression') &&\n parent['test'] === ref)\n ) {\n return\n }\n if (parent?.type === 'MemberExpression' && parent['object'] === ref) {\n return note(key, propertyName(parent, constants))\n }\n if (parent?.type === 'VariableDeclarator' && parent['init'] === ref) {\n const id = parent['id'] as AnyNode\n if (id?.type === 'Identifier') {\n const alias = id['name'] as string\n if (seenAliases.has(parent)) return\n seenAliases.add(parent)\n const scope = bindingScope(parent)\n for (const use of identifiers.get(alias) ?? []) {\n if (use !== id && resolvesTo(use, alias, scope)) useOf(key, use)\n }\n return\n }\n if (id?.type === 'ObjectPattern') {\n for (const property of (id['properties'] ?? []) as AnyNode[]) {\n if (property.type !== 'Property' || property['computed']) {\n return whole(key)\n }\n const propertyKey = property['key'] as AnyNode\n const name =\n propertyKey?.type === 'Identifier'\n ? (propertyKey['name'] as string)\n : staticString(propertyKey)\n note(key, name)\n }\n return\n }\n }\n whole(key)\n }\n\n walk(program, (node) => {\n if (node.type !== 'MemberExpression') return\n const via = hostRef(node['object'] as AnyNode)\n if (!via) return\n const key = propertyName(node, constants)\n if (key === null) {\n if (via === 'param') computedOnParam += 1\n else computed += 1\n } else if (!allowed.has(key)) {\n ;(via === 'param' ? unknownOnParam : unknown).add(key)\n } else {\n read.add(key)\n if (modules.has(key)) useOf(key, node)\n }\n })\n\n const imports: Record<string, readonly string[] | '*'> = {}\n for (const [key, value] of names) {\n imports[key] = value === '*' ? '*' : [...value].sort()\n }\n return {\n read,\n unknown,\n unknownOnParam,\n computed,\n computedOnParam,\n imports,\n }\n}\n\nfunction analyseBundle(\n source: string,\n options?: CheckOptions,\n): BundleCheckResult {\n const problems: BundleCheckProblem[] = []\n const seen = new Set<string>()\n // Every area starts as \"ran, found nothing\" and is downgraded by its own\n // findings, so the summary cannot drift from the problem list (AGL-1087).\n const status = new Map<BundleCheckId, BundleCheckStatus>(\n CHECK_ORDER.map((id) => [id, 'pass']),\n )\n const details = new Map<BundleCheckId, string>()\n const add = (\n level: BundleCheckProblem['level'],\n check: BundleCheckId,\n message: string,\n ) => {\n if (level === 'error') status.set(check, 'fail')\n else if (status.get(check) === 'pass') status.set(check, 'question')\n if (seen.has(message) || seen.size >= MAX_PROBLEMS) return\n seen.add(message)\n problems.push({ level, message, check })\n }\n /** Mark the areas that never ran, so they cannot read as clean. */\n const unknownFrom = (...ids: BundleCheckId[]) => {\n for (const id of ids) status.set(id, 'unknown')\n }\n const summarise = (): BundleCheckSummary[] =>\n CHECK_ORDER.map((id) => ({\n id,\n label: CHECK_LABELS[id],\n status: status.get(id) ?? 'unknown',\n ...(details.has(id) ? { detail: details.get(id) } : {}),\n }))\n\n const maxBytes = options?.maxBytes ?? MAX_PLUGIN_BUNDLE_BYTES\n const bytes = new TextEncoder().encode(source).byteLength\n details.set('size', `${bytes.toLocaleString('en-US')} bytes of ${maxBytes.toLocaleString('en-US')}`)\n if (bytes === 0) {\n add('error', 'size', 'bundle is empty')\n unknownFrom(\n 'parse',\n 'entry',\n 'self-contained',\n 'host-abi',\n 'code-execution',\n 'globals',\n 'storage',\n 'dynamic-import',\n 'network',\n 'obfuscation',\n 'contributions',\n 'credentials',\n )\n return {\n ok: false,\n problems,\n checks: summarise(),\n exports: { register: false, registerApi: false },\n contributions: NOTHING_DETECTED,\n }\n }\n if (bytes > maxBytes) {\n add('error', 'size', `bundle is ${bytes} bytes (limit ${maxBytes})`)\n }\n\n const parseOptions: Options = {\n ecmaVersion: 'latest',\n sourceType: 'module',\n allowHashBang: true,\n allowAwaitOutsideFunction: true,\n }\n let program: AnyNode\n try {\n program = parse(source, parseOptions) as unknown as AnyNode\n } catch (error) {\n // Unparseable means unanalysable, and the loader would fail on it too.\n // Nothing else ran, and saying so is the whole point of `unknown`: a\n // bundle nobody could read must not show nine green rows.\n add(\n 'error',\n 'parse',\n `bundle does not parse as an ES module: ${\n error instanceof Error ? error.message : String(error)\n }`,\n )\n unknownFrom(\n 'entry',\n 'self-contained',\n 'host-abi',\n 'code-execution',\n 'globals',\n 'storage',\n 'dynamic-import',\n 'network',\n 'obfuscation',\n 'contributions',\n 'credentials',\n )\n return {\n ok: false,\n problems,\n checks: summarise(),\n exports: { register: false, registerApi: false },\n contributions: NOTHING_DETECTED,\n }\n }\n\n // Names bound to a global, so `const g = globalThis; g['ev'+'al']` reads\n // as access on a global rather than on some object we know nothing about.\n const aliases = new Set<string>()\n const noteAlias = (name: unknown, init: AnyNode | null | undefined) => {\n if (typeof name !== 'string' || !init) return\n const roots: AnyNode[] =\n init.type === 'LogicalExpression'\n ? [init['left'] as AnyNode, init['right'] as AnyNode]\n : [init]\n for (const root of roots) {\n if (\n root?.type === 'Identifier' &&\n GLOBAL_ROOTS.has(root['name'] as string)\n ) {\n aliases.add(name)\n }\n }\n }\n // Local name -> the constant string it holds (AGL-1093).\n //\n // A binding is only usable when the whole tree agrees on it: declared once,\n // never assigned again, and never a parameter or another binder anywhere.\n // Any of those means the value at a given call site is a GUESS, and a guess\n // is how a checker starts making claims about code it did not read.\n const constants = new Map<string, string>()\n {\n const bound = new Map<string, AnyNode>()\n const poisoned = new Set<string>()\n const declared = new Set<string>()\n const poison = (name: unknown) => {\n if (typeof name === 'string') poisoned.add(name)\n }\n /** Every name a pattern binds — a parameter shadowing a constant is a\n * different variable, and resolving it to the outer value would be a\n * fabrication. */\n const poisonPattern = (node: AnyNode | null | undefined) => {\n if (!node) return\n if (node.type === 'Identifier') return poison(node['name'])\n for (const key of [\n 'left',\n 'argument',\n 'properties',\n 'elements',\n 'value',\n ]) {\n const value = node[key]\n if (Array.isArray(value))\n value.forEach((item) => poisonPattern(item as AnyNode))\n else if (value) poisonPattern(value as AnyNode)\n }\n }\n walk(program, (node) => {\n if (node.type === 'VariableDeclarator') {\n const id = node['id'] as AnyNode\n if (id?.type === 'Identifier') {\n const name = id['name'] as string\n if (declared.has(name)) poison(name)\n declared.add(name)\n bound.set(name, node['init'] as AnyNode)\n } else {\n poisonPattern(id)\n }\n } else if (node.type === 'AssignmentExpression') {\n poisonPattern(node['left'] as AnyNode)\n } else if (node.type === 'UpdateExpression') {\n poisonPattern(node['argument'] as AnyNode)\n } else if (\n node.type === 'FunctionDeclaration' ||\n node.type === 'FunctionExpression' ||\n node.type === 'ArrowFunctionExpression'\n ) {\n ;((node['params'] ?? []) as AnyNode[]).forEach(poisonPattern)\n if ((node['id'] as AnyNode)?.type === 'Identifier')\n poison((node['id'] as AnyNode)['name'])\n } else if (node.type === 'CatchClause') {\n poisonPattern(node['param'] as AnyNode)\n } else if (\n node.type === 'ClassDeclaration' ||\n node.type === 'ClassExpression'\n ) {\n if ((node['id'] as AnyNode)?.type === 'Identifier')\n poison((node['id'] as AnyNode)['name'])\n }\n })\n // Two passes, so `const BASE = 'https://x'` then `BASE + '/y'` resolves.\n // A third buys almost nothing and each is a full re-read of the bindings.\n for (let pass = 0; pass < 2; pass += 1) {\n for (const [name, init] of bound) {\n if (poisoned.has(name) || constants.has(name)) continue\n const value = staticString(init, constants)\n if (value !== null) constants.set(name, value)\n }\n }\n }\n\n // Local name -> the callable it stands for (AGL-1090). `const f = fetch`,\n // `const d = globalThis.fetch`, `const {fetch: h} = globalThis`.\n const callableAliases = new Map<string, string>()\n /** The aliasable callable an initializer denotes, if any. */\n const callableFrom = (init: AnyNode | null | undefined): string | null => {\n if (!init) return null\n if (\n init.type === 'Identifier' &&\n ALIASABLE_CALLABLES.has(init['name'] as string)\n ) {\n return init['name'] as string\n }\n // `globalThis.fetch` / `window['fe' + 'tch']` — the property is what the\n // name will stand for, and only when the object is a global (an unknown\n // object's `.fetch` is somebody else's method).\n if (init.type === 'MemberExpression') {\n const property = propertyName(init)\n const object = init['object'] as AnyNode\n if (\n property &&\n ALIASABLE_CALLABLES.has(property) &&\n object?.type === 'Identifier' &&\n (GLOBAL_ROOTS.has(object['name'] as string) ||\n aliases.has(object['name'] as string))\n ) {\n return property\n }\n }\n return null\n }\n const noteCallableAlias = (\n id: AnyNode | null | undefined,\n init: AnyNode | null | undefined,\n ) => {\n if (!id) return\n if (id.type === 'Identifier') {\n const callable = callableFrom(init)\n if (callable) callableAliases.set(id['name'] as string, callable)\n return\n }\n // `const { fetch } = globalThis` and `const { fetch: h } = globalThis`.\n if (id.type === 'ObjectPattern' && init) {\n const fromGlobal =\n init.type === 'Identifier' &&\n (GLOBAL_ROOTS.has(init['name'] as string) ||\n aliases.has(init['name'] as string))\n if (!fromGlobal) return\n for (const property of (id['properties'] ?? []) as AnyNode[]) {\n const key = property['key'] as AnyNode\n const value = property['value'] as AnyNode\n const name =\n key?.type === 'Identifier' ? (key['name'] as string) : staticString(key)\n if (\n name &&\n ALIASABLE_CALLABLES.has(name) &&\n value?.type === 'Identifier'\n ) {\n callableAliases.set(value['name'] as string, name)\n }\n }\n }\n }\n\n // Global-object aliases first, as a complete pass: the callable pass below\n // resolves `g.fetch` against them, and walk order is not source order.\n walk(program, (node) => {\n if (node.type === 'VariableDeclarator') {\n const id = node['id'] as AnyNode\n if (id?.type === 'Identifier')\n noteAlias(id['name'], node['init'] as AnyNode)\n } else if (\n node.type === 'AssignmentExpression' &&\n node['operator'] === '='\n ) {\n const left = node['left'] as AnyNode\n if (left?.type === 'Identifier')\n noteAlias(left['name'], node['right'] as AnyNode)\n }\n })\n walk(program, (node) => {\n if (node.type === 'VariableDeclarator') {\n noteCallableAlias(node['id'] as AnyNode, node['init'] as AnyNode)\n } else if (\n node.type === 'AssignmentExpression' &&\n node['operator'] === '='\n ) {\n noteCallableAlias(node['left'] as AnyNode, node['right'] as AnyNode)\n }\n })\n\n const isGlobalRef = (node: AnyNode | null | undefined): boolean =>\n !!node &&\n node.type === 'Identifier' &&\n (GLOBAL_ROOTS.has(node['name'] as string) ||\n aliases.has(node['name'] as string))\n\n const declared = options?.declaredNetwork\n const allowlist = new Set(\n (declared ?? []).map((origin) => {\n try {\n return new URL(origin).origin\n } catch {\n return origin\n }\n }),\n )\n for (const message of lookalikeDeclaredOrigins(declared ?? [])) {\n add('warning', 'network', message)\n }\n /** Level for a network finding: a claim only when we know what was declared. */\n const networkLevel: BundleCheckProblem['level'] = declared\n ? 'error'\n : 'warning'\n // What the bundle reaches for, so the summary row can SAY it (AGL-1087) —\n // \"calls https://api.stripe.com, declared\" is the line a reviewer would\n // otherwise open the bundle to get.\n const networkApis = new Set<string>()\n const networkOrigins = new Set<string>()\n let runtimeUrls = 0\n /** Origins handed to a callee the checker could not resolve (AGL-1090). */\n const unresolvedOrigins = new Set<string>()\n const noteNetwork = (api: string, urlArg: AnyNode | undefined) => {\n const origin = literalOrigin(urlArg, constants)\n networkApis.add(api)\n if (origin) networkOrigins.add(origin)\n else runtimeUrls += 1\n if (!declared) {\n add(\n 'warning',\n 'network',\n `bundle makes network calls (${api}) — check them against the ` +\n \"manifest's declared network capability\",\n )\n return\n }\n if (!allowlist.size) {\n add(\n networkLevel,\n 'network',\n `bundle calls ${api} but the manifest declares no network ` +\n 'capability — declare every origin under capabilities.network ' +\n '(the CSP blocks the rest at runtime)',\n )\n return\n }\n if (!origin) {\n add(\n 'warning',\n 'network',\n `${api} is called with a URL that is only known at runtime — it ` +\n 'cannot be checked against the declared origins',\n )\n return\n }\n if (!allowlist.has(origin)) {\n add(\n networkLevel,\n 'network',\n `${api} calls ${origin}, which the manifest does not declare ` +\n `(declared: ${[...allowlist].join(', ')})`,\n )\n }\n }\n\n /**\n * A call the checker could not resolve, given an absolute URL.\n *\n * Reported as a QUESTION, never a refusal: most of these are helpers, and\n * refusing every unrecognised call that mentions a URL would make the\n * verifier useless. But leaving them silent is what let the network row\n * claim \"no network calls\" over a bundle whose calls it simply could not\n * follow — and a URL to an origin the manifest never declared is exactly\n * what a reviewer should be pointed at.\n */\n const noteUnresolvedUrl = (\n name: string | null,\n urlArg: AnyNode | undefined,\n ) => {\n if (name && URL_TAKING_NON_CALLS.has(name)) return\n const origin = literalOrigin(urlArg, constants)\n if (!origin) return\n // A declared origin is consistent with the manifest and permitted by the\n // CSP, so there is no question to raise about it.\n if (allowlist.has(origin)) return\n unresolvedOrigins.add(origin)\n add(\n 'warning',\n 'network',\n `${name ? `${name}()` : 'a call'} is passed ${origin}, which the ` +\n 'manifest does not declare — the checker could not tell whether it ' +\n 'reaches the network, so read this call',\n )\n }\n\n let exportsRegister = false\n let exportsRegisterApi = false\n const noteExport = (name: unknown) => {\n if (name === 'register') exportsRegister = true\n else if (name === 'registerApi') exportsRegisterApi = true\n }\n\n let obfuscatedNames = 0\n\n walk(program, (node) => {\n switch (node.type) {\n // ---- entry exports + self-containment ----\n case 'ImportDeclaration':\n add(\n 'error',\n 'self-contained',\n 'bundle has static imports — realm bundles must be self-contained ' +\n '(react/@aglyn/aglyn come from the host ABI; see the realm rollup ' +\n 'template)',\n )\n break\n case 'ExportAllDeclaration':\n case 'ExportNamedDeclaration': {\n if (node['source']) {\n add(\n 'error',\n 'self-contained',\n 'bundle re-exports from another module — realm bundles must be ' +\n 'self-contained (see the realm rollup template)',\n )\n }\n const declaration = node['declaration'] as AnyNode | null\n if (declaration) {\n if (declaration['id'])\n noteExport((declaration['id'] as AnyNode)['name'])\n for (const declarator of (declaration['declarations'] ??\n []) as AnyNode[]) {\n const id = declarator['id'] as AnyNode\n if (id?.type === 'Identifier') noteExport(id['name'])\n }\n }\n for (const specifier of (node['specifiers'] ?? []) as AnyNode[]) {\n const exported = specifier['exported'] as AnyNode\n noteExport(\n exported?.type === 'Identifier'\n ? exported['name']\n : staticString(exported),\n )\n }\n break\n }\n\n // ---- dynamic import ----\n case 'ImportExpression': {\n const specifier = staticString(node['source'] as AnyNode, constants)\n if (specifier === null) {\n add(\n 'error',\n 'dynamic-import',\n 'dynamic import with a specifier computed at runtime is not ' +\n 'allowed — the loader cannot know what would be fetched',\n )\n } else if (/^https?:/i.test(specifier)) {\n add(\n 'error',\n 'dynamic-import',\n 'dynamic import of remote URLs is not allowed',\n )\n }\n break\n }\n\n // ---- calls ----\n case 'CallExpression':\n case 'NewExpression': {\n const callee = node['callee'] as AnyNode\n const args = (node['arguments'] ?? []) as AnyNode[]\n const written =\n callee?.type === 'Identifier'\n ? (callee['name'] as string)\n : callee?.type === 'MemberExpression'\n ? propertyName(callee, constants)\n : null\n // An alias resolves to what it stands for (AGL-1090), so `f(url)`\n // after `const f = fetch` is a fetch call.\n const name =\n (written && callableAliases.get(written)) ?? written ?? null\n\n if (name === 'eval')\n add('error', 'code-execution', 'eval() is not allowed')\n if (name === 'Function')\n add(\n 'error',\n 'code-execution',\n 'the Function constructor is not allowed',\n )\n // `(()=>{}).constructor('return 1')()` — the Function constructor\n // reached through any function value, which is why the CALL is the\n // finding rather than the name `Function`.\n if (name === 'constructor' && callee?.type === 'MemberExpression')\n add(\n 'error',\n 'code-execution',\n 'calling .constructor() is not allowed — it reaches the ' +\n 'Function constructor from any function value',\n )\n if (name && NETWORK_CALLS.has(name)) noteNetwork(name, args[0])\n else if (name && NETWORK_CONSTRUCTORS.has(name))\n noteNetwork(name, node.type === 'NewExpression' ? args[0] : args[1])\n // Something we could not follow, handed an absolute URL (AGL-1090).\n // Not a refusal — it may be a helper, a logger, or a link — but the\n // network row must stop rendering \"no network calls\" over it.\n else noteUnresolvedUrl(name, args[0])\n break\n }\n\n // ---- member access ----\n case 'MemberExpression': {\n const object = node['object'] as AnyNode\n const name = propertyName(node, constants)\n if (isGlobalRef(object) && name === null) {\n add(\n 'error',\n 'globals',\n `computed property access on ${\n (object['name'] as string) || 'a global'\n } is not allowed — a property chosen at runtime cannot be ` +\n 'reviewed',\n )\n break\n }\n // Property names only mean anything on a global: `response.cookie`\n // and `state.localStorage` are somebody else's object.\n if (name === 'cookie' && isGlobalRef(object))\n add('error', 'storage', 'document.cookie access is not allowed')\n if (name && STORAGE_NAMES.has(name) && isGlobalRef(object))\n add(\n 'error',\n 'storage',\n 'browser storage access is not allowed (use host-mediated data)',\n )\n if (name === 'eval' && isGlobalRef(object))\n add('error', 'code-execution', 'eval() is not allowed')\n break\n }\n\n // ---- bare references ----\n case 'Identifier': {\n const name = node['name'] as string\n if (STORAGE_NAMES.has(name))\n add(\n 'error',\n 'storage',\n 'browser storage access is not allowed (use host-mediated data)',\n )\n if (OBFUSCATED_NAME.test(name)) obfuscatedNames += 1\n break\n }\n\n // ---- obfuscation ----\n case 'Literal': {\n const value = node['value']\n if (\n typeof value === 'string' &&\n value.length >= MIN_SUSPICIOUS_BASE64 &&\n BASE64_BLOB.test(value)\n ) {\n add(\n 'warning',\n 'obfuscation',\n `bundle embeds a ${value.length}-character base64 literal — ` +\n 'decode it before approving',\n )\n }\n break\n }\n default:\n break\n }\n })\n\n if (!exportsRegister && !exportsRegisterApi) {\n add(\n 'error',\n 'entry',\n 'bundle exports neither register(host) nor registerApi() — ' +\n 'nothing for the loader to call',\n )\n }\n\n if (obfuscatedNames >= MIN_OBFUSCATED_NAMES) {\n add(\n 'warning',\n 'obfuscation',\n `bundle uses ${obfuscatedNames} machine-obfuscated identifiers ` +\n '(_0x… naming) — minifiers do not produce these',\n )\n }\n const longestLine = source\n .split('\\n')\n .reduce((longest, line) => Math.max(longest, line.length), 0)\n if (longestLine > MAX_READABLE_LINE) {\n add(\n 'warning',\n 'obfuscation',\n `bundle has a single ${longestLine}-character line — nothing on it ` +\n 'can be read in review; ask for a readable build or a source map',\n )\n }\n\n details.set(\n 'entry',\n [\n exportsRegister ? 'register(host)' : null,\n exportsRegisterApi ? 'registerApi()' : null,\n ]\n .filter(Boolean)\n .join(', ') || 'none',\n )\n\n // What the network check actually saw. Without the manifest it saw the\n // calls but could not judge them, and that is `unknown`, not a pass — the\n // row a reviewer must not read as \"checked and fine\".\n if (!declared) {\n if (networkApis.size) {\n status.set('network', 'unknown')\n details.set(\n 'network',\n `calls ${[...networkApis].join(', ')} — no declared origins were ` +\n 'supplied, so nothing was compared',\n )\n } else {\n details.set('network', 'no network calls')\n }\n } else if (!networkApis.size) {\n details.set(\n 'network',\n unresolvedOrigins.size\n ? `no resolved network calls, but ${[...unresolvedOrigins].join(', ')} ` +\n 'is passed to a call the checker could not follow'\n : 'no network calls',\n )\n } else {\n const origins = networkOrigins.size\n ? [...networkOrigins]\n .map((origin) =>\n allowlist.has(origin) ? `${origin} (declared)` : `${origin} (NOT declared)`,\n )\n .join(', ')\n : ''\n details.set(\n 'network',\n [\n `calls ${[...networkApis].join(', ')}`,\n origins,\n runtimeUrls\n ? `${runtimeUrls} call(s) with a URL only known at runtime`\n : '',\n ]\n .filter(Boolean)\n .join(' · '),\n )\n }\n\n const abi = hostAbiReads(program, constants, isGlobalRef)\n for (const key of abi.unknown) {\n add(\n 'error',\n 'host-abi',\n `bundle reads \"${key}\" from the host, which provides only ` +\n `${PLUGIN_HOST_ABI_KEYS.join(', ')} — it would be undefined on every site`,\n )\n }\n for (const key of abi.unknownOnParam) {\n add(\n 'warning',\n 'host-abi',\n `register() reads \"${key}\" from its host argument, which provides only ` +\n `${PLUGIN_HOST_ABI_KEYS.join(', ')} — it will be undefined`,\n )\n }\n if (abi.computedOnParam) {\n add(\n 'warning',\n 'host-abi',\n `register() reads its host argument by a key chosen at runtime ` +\n `(${abi.computedOnParam}×)`,\n )\n }\n if (abi.computed) {\n add(\n 'error',\n 'host-abi',\n `bundle reads the host by a key chosen at runtime (${abi.computed}×) — ` +\n 'a lookup that cannot be named cannot be reviewed',\n )\n }\n // Each name the bundle reads from a host module must be one the host holds\n // (AGL-3392): core's realm plugin surface, or the whole of the others.\n for (const key of PLUGIN_HOST_MODULE_KEYS) {\n const read = abi.imports[key]\n if (!read) continue\n const holds = REALM_HOST_SURFACE_NAMES[key]\n if (read === '*') {\n if (key === 'aglyn') {\n add(\n 'warning',\n 'host-abi',\n 'uses @aglyn/aglyn as a namespace value — only the realm plugin ' +\n 'surface is on the host, so any other name read through it is ' +\n 'undefined; import what you use by name',\n )\n }\n continue\n }\n const missing = read.filter((name) => !holds.has(name))\n if (missing.length) {\n add(\n 'error',\n 'host-abi',\n `reads ${missing.join(', ')} from the host's ${key}, which does not ` +\n `hold ${missing.length === 1 ? 'it' : 'them'}` +\n (key === 'aglyn'\n ? ' — only the realm plugin surface of @aglyn/aglyn is on the host'\n : ''),\n )\n }\n }\n details.set(\n 'host-abi',\n abi.read.size ? `reads ${[...abi.read].sort().join(', ')}` : 'reads nothing by name',\n )\n\n const detected = detectRegistrations(program, constants)\n for (const message of credentialInputsIn(program, constants)) {\n add('warning', 'credentials', message)\n }\n compareContributions(detected, options, add, details, (check) =>\n status.set(check, 'unknown'),\n )\n\n return {\n ok: !problems.some((problem) => problem.level === 'error'),\n problems,\n checks: summarise(),\n exports: { register: exportsRegister, registerApi: exportsRegisterApi },\n contributions: detected,\n }\n}\n\n/**\n * Run the checks over a bundle. NEVER throws (AGL-1094).\n *\n * The publish route calls this directly, so an unexpected failure in here\n * used to mean a 500 and no explanation for the publisher — and in the review\n * sweep it looked exactly like a missing artifact, which sent the\n * investigation to the storage bucket instead of to this file. A checker that\n * cannot analyse a bundle has an answer: say so, in the verdict, as an error.\n */\nexport function checkPluginBundle(\n source: string,\n options?: CheckOptions,\n): BundleCheckResult {\n try {\n return analyseBundle(source, options)\n } catch (error) {\n return {\n ok: false,\n problems: [\n {\n level: 'error',\n check: 'parse',\n message:\n 'the verifier failed on this bundle — treat it as unchecked and ' +\n `report it: ${\n error instanceof Error ? error.message : String(error)\n }`,\n },\n ],\n checks: CHECK_ORDER.map((id) => ({\n id,\n label: CHECK_LABELS[id],\n status: id === 'parse' ? 'fail' : 'unknown',\n })),\n exports: { register: false, registerApi: false },\n contributions: NOTHING_DETECTED,\n }\n }\n}\n"],"names":["parse","credentialForInputAttribute","credentialInHtml","lookalikeBrandForHost","PLUGIN_HOST_ABI_KEYS","PLUGIN_HOST_GLOBAL","PLUGIN_HOST_MODULE_KEYS","REALM_HOST_SURFACE_NAMES","CHECK_LABELS","entry","size","globals","storage","network","obfuscation","contributions","credentials","CHECK_ORDER","MAX_PLUGIN_BUNDLE_BYTES","PLUGIN_VERIFIER_VERSION","isStoredVerdictCurrent","stored","sha256","Number","verifierVersion","GLOBAL_ROOTS","Set","STORAGE_NAMES","NETWORK_CALLS","NETWORK_CONSTRUCTORS","ALIASABLE_CALLABLES","URL_TAKING_NON_CALLS","MAX_READABLE_LINE","MIN_SUSPICIOUS_BASE64","MIN_OBFUSCATED_NAMES","MAX_PROBLEMS","OBFUSCATED_NAME","BASE64_BLOB","skippedChild","node","key","type","walk","root","visit","stack","length","pop","Object","keys","value","Array","isArray","item","push","staticString","constants","get","expressions","quasis","cooked","out","index","filled","left","right","propertyName","property","literalOrigin","url","URL","test","protocol","origin","NOTHING_DETECTED","contributes","unresolved","REGISTRATION_CALLS","SHELL_EXTENSION_FIELDS","detectRegistrations","program","slots","routes","orgRoutes","components","features","shell","objectProperty","object","name","undefined","keyName","listOf","slotName","literal","callee","has","args","extension","add","widgets","list","widget","slot","field","into","href","id","site","sort","console","describeContributions","parts","join","compareContributions","detected","options","details","markUnknown","found","declared","registers","registersSomething","Boolean","unreadable","declaredContributions","set","requireContributions","JSON","stringify","missing","label","registered","listed","consequence","includes","unused","credentialInputsIn","keyOf","text","map","quasi","String","words","password","card","otp","lookalikeDeclaredOrigins","messages","host","hostname","brand","walkWithParents","parent","children","child","FUNCTION_TYPES","SCOPE_TYPES","patternNames","pattern","element","lexicalNames","statements","statement","declarator","varNames","entries","declaredNames","scope","names","param","body","branch","head","isReference","hostAbiReads","isGlobalRef","parents","Map","identifiers","scopeNames","namesOf","bindingScope","declaration","functionScoped","at","resolvesTo","ref","isHostGlobal","hostNames","init","roots","some","hostRef","binding","modules","allowed","read","unknown","unknownOnParam","computed","computedOnParam","whole","note","current","seenAliases","useOf","alias","use","propertyKey","via","imports","analyseBundle","source","problems","seen","status","level","check","message","unknownFrom","ids","summarise","detail","maxBytes","bytes","TextEncoder","encode","byteLength","toLocaleString","ok","checks","exports","register","registerApi","parseOptions","ecmaVersion","sourceType","allowHashBang","allowAwaitOutsideFunction","error","Error","aliases","noteAlias","bound","poisoned","poison","poisonPattern","forEach","pass","callableAliases","callableFrom","noteCallableAlias","callable","fromGlobal","declaredNetwork","allowlist","networkLevel","networkApis","networkOrigins","runtimeUrls","unresolvedOrigins","noteNetwork","api","urlArg","noteUnresolvedUrl","exportsRegister","exportsRegisterApi","noteExport","obfuscatedNames","specifier","exported","written","longestLine","split","reduce","longest","line","Math","max","filter","origins","abi","holds","problem","checkPluginBundle"],"mappings":";AAAA;;;;;;;;;;;;;;;CAeC,GAED;;;;;;;;;;;;;;;;;;;CAmBC,GAED,SAASA,KAAK,QAAiC,QAAO;AACtD,4EAA4E;AAC5E,oDAAoD;AACpD,SACEC,2BAA2B,EAC3BC,gBAAgB,QACX,8CAA6C;AACpD,SAASC,qBAAqB,QAAQ,oDAAmD;AAEzF,SACEC,oBAAoB,EACpBC,kBAAkB,EAClBC,uBAAuB,QAClB,uBAAmB;AAC1B,SAASC,wBAAwB,QAAQ,oCAAgC;AAuEzE,MAAMC,eAA8C;IAClDR,OAAO;IACPS,OAAO;IACP,kBAAkB;IAClB,YAAY;IACZC,MAAM;IACN,kBAAkB;IAClBC,SAAS;IACTC,SAAS;IACT,kBAAkB;IAClBC,SAAS;IACTC,aAAa;IACbC,eAAe;IACfC,aAAa;AACf;AAEA,6EAA6E,GAC7E,MAAMC,cAA+B;IACnC;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AAED,OAAO,MAAMC,0BAA0B,QAAS;AAEhD;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,MAAMC,0BAA0B,GAAE;AAYzC;;;;;;;;CAQC,GACD,OAAO,SAASC,uBACdC,MAA8C,EAC9CC,MAAc;IAEd,IAAI,CAACD,UAAU,CAACC,QAAQ,OAAO;IAC/B,OACED,OAAOC,MAAM,KAAKA,UAClBC,OAAOF,OAAOG,eAAe,MAAML;AAEvC;AAEA;;;;;CAKC,G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