@aglyn/aglyn 1.15.0 → 1.15.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/package.json +11 -11
  2. package/src/lib/app-utils/buy-now-pay-later.d.ts +45 -0
  3. package/src/lib/app-utils/buy-now-pay-later.js +68 -0
  4. package/src/lib/app-utils/buy-now-pay-later.js.map +1 -0
  5. package/src/lib/app-utils/contexts.d.ts +1 -0
  6. package/src/lib/app-utils/contexts.js +1 -0
  7. package/src/lib/app-utils/contexts.js.map +1 -1
  8. package/src/lib/app-utils/docs-help-sections.generated.js +2 -0
  9. package/src/lib/app-utils/docs-help-sections.generated.js.map +1 -1
  10. package/src/lib/app-utils/docs-help.generated.d.ts +3 -3
  11. package/src/lib/app-utils/docs-help.generated.js +9 -0
  12. package/src/lib/app-utils/docs-help.generated.js.map +1 -1
  13. package/src/lib/app-utils/docs-index.generated.js +4 -4
  14. package/src/lib/app-utils/docs-index.generated.js.map +1 -1
  15. package/src/lib/app-utils/plan-entitlements.d.ts +127 -75
  16. package/src/lib/app-utils/plan-entitlements.js +120 -77
  17. package/src/lib/app-utils/plan-entitlements.js.map +1 -1
  18. package/src/lib/app-utils/plugin-bundle-checks.d.ts +14 -2
  19. package/src/lib/app-utils/plugin-bundle-checks.js +82 -7
  20. package/src/lib/app-utils/plugin-bundle-checks.js.map +1 -1
  21. package/src/lib/app-utils/plugin-connection-editor.d.ts +48 -0
  22. package/src/lib/app-utils/plugin-connection-editor.js +46 -0
  23. package/src/lib/app-utils/plugin-connection-editor.js.map +1 -0
  24. package/src/lib/app-utils/plugin-connection-record.d.ts +42 -0
  25. package/src/lib/app-utils/plugin-connection-record.js +48 -0
  26. package/src/lib/app-utils/plugin-connection-record.js.map +1 -0
  27. package/src/lib/app-utils/plugin-connection-records-context.d.ts +23 -0
  28. package/src/lib/app-utils/plugin-connection-records-context.js +29 -0
  29. package/src/lib/app-utils/plugin-connection-records-context.js.map +1 -0
  30. package/src/lib/app-utils/plugin-connection-records.d.ts +42 -0
  31. package/src/lib/app-utils/plugin-connection-records.js +56 -0
  32. package/src/lib/app-utils/plugin-connection-records.js.map +1 -0
  33. package/src/lib/app-utils/plugin-connections.d.ts +320 -0
  34. package/src/lib/app-utils/plugin-connections.js +895 -0
  35. package/src/lib/app-utils/plugin-connections.js.map +1 -0
  36. package/src/lib/app-utils/plugin-elements.d.ts +104 -0
  37. package/src/lib/app-utils/plugin-elements.js +128 -0
  38. package/src/lib/app-utils/plugin-elements.js.map +1 -0
  39. package/src/lib/app-utils/plugin-manifest.d.ts +20 -75
  40. package/src/lib/app-utils/plugin-manifest.js +65 -100
  41. package/src/lib/app-utils/plugin-manifest.js.map +1 -1
  42. package/src/lib/app-utils/realm-elements-context.d.ts +16 -0
  43. package/src/lib/app-utils/realm-elements-context.js +16 -0
  44. package/src/lib/app-utils/realm-elements-context.js.map +1 -1
  45. package/src/lib/app-utils/realm-host-surface.generated.js +1 -0
  46. package/src/lib/app-utils/realm-host-surface.generated.js.map +1 -1
  47. package/src/lib/app-utils/release-flags.d.ts +1 -1
  48. package/src/lib/app-utils/release-flags.js +11 -0
  49. package/src/lib/app-utils/release-flags.js.map +1 -1
  50. package/src/lib/app-utils/server.d.ts +1 -0
  51. package/src/lib/app-utils/server.js +2 -0
  52. package/src/lib/app-utils/server.js.map +1 -1
  53. package/src/lib/plugin-manager/feature-plugins.d.ts +25 -0
  54. package/src/lib/plugin-manager/feature-plugins.js +10 -0
  55. package/src/lib/plugin-manager/feature-plugins.js.map +1 -1
  56. package/src/lib/plugin-manager/first-party-plugins.generated.js +11 -0
  57. package/src/lib/plugin-manager/first-party-plugins.generated.js.map +1 -1
  58. package/src/lib/plugin-manager/index.d.ts +1 -0
  59. package/src/lib/plugin-manager/index.js +1 -0
  60. package/src/lib/plugin-manager/index.js.map +1 -1
  61. package/src/lib/plugin-manager/plugin-artifact-inventory.d.ts +5 -0
  62. package/src/lib/plugin-manager/plugin-artifact-inventory.js.map +1 -1
  63. package/src/lib/plugin-manager/plugin-site-csp.d.ts +36 -0
  64. package/src/lib/plugin-manager/plugin-site-csp.js +50 -1
  65. package/src/lib/plugin-manager/plugin-site-csp.js.map +1 -1
  66. package/src/lib/plugin-manager/realm-host-aglyn.generated.js +61 -59
  67. package/src/lib/plugin-manager/realm-host-aglyn.generated.js.map +1 -1
  68. package/src/lib/plugin-manager/site-page-enricher-services.d.ts +35 -0
  69. package/src/lib/plugin-manager/site-page-enricher-services.js +35 -0
  70. package/src/lib/plugin-manager/site-page-enricher-services.js.map +1 -0
  71. package/src/lib/plugin-manager/site-page-hooks.js +16 -3
  72. package/src/lib/plugin-manager/site-page-hooks.js.map +1 -1
@@ -1,3 +1,5 @@
1
+ import { _ as _extends } from "@swc/helpers/_/_extends";
2
+ import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
1
3
  /**
2
4
  * @license
3
5
  * Copyright 2026 Aglyn LLC
@@ -13,9 +15,10 @@
13
15
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
16
  * See the License for the specific language governing permissions and
15
17
  * limitations under the License.
16
- */ import { _ as _extends } from "@swc/helpers/_/_extends";
17
- import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
18
+ */ import { pluginConfigSchemaFromManifest } from "../plugin-manager/plugin-config.js";
18
19
  import { sanitizePluginContributions } from "../plugin-manager/plugin-contributions.js";
20
+ import { validatePluginConnections, validatePluginImageHosts } from "./plugin-connections.js";
21
+ import { PLUGIN_COMPONENT_ID } from "./plugin-elements.js";
19
22
  /**
20
23
  * Categories a third-party element may declare.
21
24
  *
@@ -230,6 +233,13 @@ export function validatePluginManifest(input) {
230
233
  const propSchema = sanitizePropSchemaList(propSchemaInput, new Set((_capabilities_props = capabilities.props) != null ? _capabilities_props : []));
231
234
  if (propSchema.length) capabilities.propSchema = propSchema;
232
235
  }
236
+ // Image hosts (AGL-4193): validation only here, the tenant's CSP reads it.
237
+ const imageHosts = validatePluginImageHosts(capabilitiesInput['imageHosts']);
238
+ if (imageHosts.ok === false) return {
239
+ ok: false,
240
+ error: imageHosts.error
241
+ };
242
+ if (imageHosts.value.length) capabilities.imageHosts = imageHosts.value;
233
243
  const size = capabilitiesInput['size'];
234
244
  if (size) {
235
245
  var _size_width, _size_height;
@@ -333,6 +343,49 @@ export function validatePluginManifest(input) {
333
343
  };
334
344
  contributes = verdict.contributions;
335
345
  }
346
+ /**
347
+ * Declared connections (AGL-4193). Refused whole when malformed, like
348
+ * `contributes`: a connection trimmed on the way in is an OAuth flow and a
349
+ * sync that silently do not exist.
350
+ */ const connectionsVerdict = validatePluginConnections(raw['connections']);
351
+ if (connectionsVerdict.ok === false) {
352
+ return {
353
+ ok: false,
354
+ error: connectionsVerdict.error
355
+ };
356
+ }
357
+ const connections = connectionsVerdict.value;
358
+ /**
359
+ * Declared settings (AGL-428). This validator rebuilds the manifest from
360
+ * the fields it knows, and `config` was never one of them, so a publisher's
361
+ * settings were dropped at publish and the console never drew the form the
362
+ * docs promise. Kept now, through the SAME sanitizer the console reads the
363
+ * pinned manifest with (`pluginConfigSchemaFromManifest`): unknown field
364
+ * types, duplicate keys and empty selects are dropped, at most 50 fields
365
+ * are kept, and every default is coerced to its field's type. A `config`
366
+ * that is not an object with a `fields` list is refused, a build error the
367
+ * publisher can see; one whose fields all drop out is left off.
368
+ */ let config;
369
+ if (raw['config'] !== undefined) {
370
+ const declaredConfig = raw['config'];
371
+ if (!declaredConfig || typeof declaredConfig !== 'object' || !Array.isArray(declaredConfig.fields)) {
372
+ return {
373
+ ok: false,
374
+ error: 'config must be an object with a fields list'
375
+ };
376
+ }
377
+ const schema = pluginConfigSchemaFromManifest(id, {
378
+ config: declaredConfig
379
+ });
380
+ // No `undefined` member survives: the manifest is written to Firestore
381
+ // as is, and the Admin SDK refuses an undefined value.
382
+ if (schema) {
383
+ config = {
384
+ fields: schema.fields.map((field)=>Object.fromEntries(Object.entries(field).filter(([, value])=>value !== undefined))),
385
+ defaults: schema.defaults
386
+ };
387
+ }
388
+ }
336
389
  return {
337
390
  ok: true,
338
391
  manifest: _extends({
@@ -344,6 +397,10 @@ export function validatePluginManifest(input) {
344
397
  hostAbi
345
398
  } : {}, contributes ? {
346
399
  contributes
400
+ } : {}, connections.length ? {
401
+ connections
402
+ } : {}, config ? {
403
+ config
347
404
  } : {}, Object.keys(capabilities).length ? {
348
405
  capabilities
349
406
  } : {}, elements.length ? {
@@ -559,7 +616,9 @@ export function validatePluginManifest(input) {
559
616
  return false;
560
617
  }
561
618
  }
562
- /** Component id of the sandboxed plugin canvas element (plugins-mui). */ export const PLUGIN_COMPONENT_ID = 'marketplacePlugin';
619
+ // The sandboxed plugin element's id lives in `plugin-elements.ts` (AGL-4201),
620
+ // so the mui site module can read it without loading this module.
621
+ export { PLUGIN_COMPONENT_ID };
563
622
  /**
564
623
  * Compose-time injection (AGL-45), mirroring `attachFunctionDefinitions`:
565
624
  * a `marketplacePlugin` node carries only a `listingId` in the saved screen;
@@ -586,102 +645,8 @@ export function validatePluginManifest(input) {
586
645
  }
587
646
  return next;
588
647
  }
589
- /**
590
- * The settings an author may edit on a placed plugin (AGL-1049).
591
- *
592
- * Driven by `capabilities.props` — THE allowlist — and decorated by
593
- * `propSchema` where the publisher supplied one. That order is the whole
594
- * security property: the list of editable settings can never be longer than
595
- * the list of props that cross the bridge, whatever the schema says, so a
596
- * publisher cannot describe their way into a prop they did not declare.
597
- *
598
- * A plugin published before `propSchema` existed still gets a field per
599
- * declared prop, as plain text. That is the difference between guessing key
600
- * names in a JSON textarea and being shown them, and it needs no manifest
601
- * change to work — which matters, because every plugin installed today
602
- * predates this.
603
- */ export function resolvePluginPropFields(manifest) {
604
- var _ref, _ref1;
605
- var _manifest_capabilities, _manifest_capabilities1;
606
- const props = (_ref = manifest == null ? void 0 : (_manifest_capabilities = manifest.capabilities) == null ? void 0 : _manifest_capabilities.props) != null ? _ref : [];
607
- const schema = new Map(((_ref1 = manifest == null ? void 0 : (_manifest_capabilities1 = manifest.capabilities) == null ? void 0 : _manifest_capabilities1.propSchema) != null ? _ref1 : []).map((entry)=>[
608
- entry.name,
609
- entry
610
- ]));
611
- return props.map((name)=>{
612
- var _ref, _ref1;
613
- const declared = schema.get(name);
614
- return _extends({
615
- name,
616
- type: (_ref = declared == null ? void 0 : declared.type) != null ? _ref : 'string',
617
- label: (_ref1 = declared == null ? void 0 : declared.label) != null ? _ref1 : name
618
- }, (declared == null ? void 0 : declared.description) ? {
619
- description: declared.description
620
- } : {}, (declared == null ? void 0 : declared.default) !== undefined ? {
621
- default: declared.default
622
- } : {}, (declared == null ? void 0 : declared.options) ? {
623
- options: declared.options
624
- } : {});
625
- });
626
- }
627
- /**
628
- * Keys an author has set that the plugin will silently ignore.
629
- *
630
- * The failure this exists to surface: `filterPluginProps` drops anything not
631
- * in the allowlist, so a typo does not fail — it just quietly does nothing,
632
- * which is the worst of the options. Naming the key is the whole fix.
633
- */ export function unknownPluginPropKeys(manifest, values) {
634
- var _ref;
635
- var _manifest_capabilities;
636
- if (!values) return [];
637
- const allowed = new Set((_ref = manifest == null ? void 0 : (_manifest_capabilities = manifest.capabilities) == null ? void 0 : _manifest_capabilities.props) != null ? _ref : []);
638
- return Object.keys(values).filter((key)=>!allowed.has(key));
639
- }
640
- /**
641
- * The palette entries an installed plugin contributes (AGL-1031).
642
- *
643
- * Resolved from the PINNED install, which is what makes the two guarantees in
644
- * the issue hold without extra machinery: an element only appears where the
645
- * plugin is installed, and a revoked or downgraded version's elements vanish
646
- * with it, because the palette is rebuilt from whatever the pin now points at.
647
- *
648
- * Attributes come back through `resolvePluginPropFields`, so an element's
649
- * editable fields are bounded by `capabilities.props` exactly like the generic
650
- * plugin element's are. A declared element cannot widen what crosses the
651
- * bridge; it only gives the same props a better name and a better editor.
652
- */ export function resolvePluginElements(install) {
653
- var _ref, _ref1;
654
- var _install_manifest;
655
- const listingId = install == null ? void 0 : install.listingId;
656
- if (!listingId) return [];
657
- const declared = (_ref = (_ref1 = install == null ? void 0 : install.elements) != null ? _ref1 : install == null ? void 0 : (_install_manifest = install.manifest) == null ? void 0 : _install_manifest.elements) != null ? _ref : [];
658
- const capabilities = install == null ? void 0 : install.capabilities;
659
- return declared.map((element)=>{
660
- var _element_category;
661
- var _element_attributes;
662
- return _extends({
663
- listingId,
664
- elementId: element.id,
665
- displayName: element.displayName
666
- }, element.description ? {
667
- description: element.description
668
- } : {}, {
669
- category: (_element_category = element.category) != null ? _element_category : 'Data Display'
670
- }, element.icon ? {
671
- icon: element.icon
672
- } : {}, {
673
- // Per-element attributes when declared; otherwise the plugin's whole
674
- // declared prop set, which is still better than a JSON box.
675
- fields: ((_element_attributes = element.attributes) == null ? void 0 : _element_attributes.length) ? resolvePluginPropFields({
676
- capabilities: {
677
- props: element.attributes.map((attribute)=>attribute.name),
678
- propSchema: element.attributes
679
- }
680
- }) : resolvePluginPropFields({
681
- capabilities
682
- })
683
- });
684
- });
685
- }
648
+ // The editor-facing resolvers live in `plugin-elements.ts` (AGL-4201), so the
649
+ // published page that calls them does not load this module's validators.
650
+ export { resolvePluginElements, resolvePluginPropFields, unknownPluginPropKeys } from "./plugin-elements.js";
686
651
 
687
652
  //# sourceMappingURL=plugin-manifest.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/plugin-manifest.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\nimport type { PluginConfigField } from '../plugin-manager/plugin-config'\nimport {\n sanitizePluginContributions,\n type PluginContributions,\n} from '../plugin-manager/plugin-contributions'\n\n/**\n * Executable-plugin manifest, artifact-path, CSP, and revocation helpers\n * (AGL-45), per the accepted AGL-43 design. Plugins — unlike declarative\n * components (see `marketplace.ts`) — are code, so they never run in the\n * console/tenant origin: they load in a sandboxed iframe on a dedicated\n * plugin origin, and this manifest is the contract the install screen\n * shows verbatim and the serving layer turns into CSP. Pure module — safe\n * to import from API routes, the loader, and the host runtime alike.\n */\n\n/** Capabilities a plugin declares; shown verbatim at install. */\n/**\n * How a declared prop should be EDITED. Authoring metadata only (AGL-1049).\n *\n * Deliberately separate from `props`, which stays the security allowlist. A\n * schema entry for a name that is not in `props` widens nothing — it is\n * dropped, because the filter and the author disagreeing must resolve in the\n * filter's favour. The point of this is to make them agree, never to let a\n * publisher grant themselves a prop by describing it.\n */\nexport interface PluginPropSchema {\n /** Must also appear in `capabilities.props`, or this entry is ignored. */\n name: string\n /**\n * Which editor to render. Unknown values degrade to `string` rather than\n * being rejected: this is publisher-authored data, and a manifest from a\n * newer platform version must not make an older host refuse the plugin.\n */\n type?: 'string' | 'number' | 'boolean' | 'color' | 'date' | 'url' | 'select'\n label?: string\n description?: string\n /** Shown as the field's initial value, so \"leave it alone\" is visible. */\n default?: string | number | boolean\n /** `select` only. */\n options?: Array<{ value: string; label?: string }>\n}\n\n/**\n * A canvas element a plugin version contributes (AGL-1031).\n *\n * A first-party plugin that extends the besigner declares a `ComponentSchema`\n * and gets a first-class palette entry. A marketplace plugin doing the same\n * work got a generic \"Plugin\" wrapper and a JSON textarea. Where an element\n * came from is a fact about its provenance, not a different kind of thing.\n *\n * The line this must not cross: **declared schema drives AUTHORING; the\n * sandbox still owns runtime.** This is publisher-authored DATA. It never\n * becomes a React component in the host bundle — the palette entry, the label\n * and the attribute fields are host-rendered from the declaration, and the\n * saved node still resolves to a sandboxed `PluginFrame` integrity-checked\n * against the pinned sha256. Nothing here changes what executes or where.\n */\nexport interface PluginElementDeclaration {\n /**\n * Stable id, unique within the plugin. Saved on the node beside the listing\n * id, so renaming the display name never orphans a placed element.\n */\n id: string\n displayName: string\n description?: string\n /**\n * Drawer category. Constrained to a subset — see\n * {@link PLUGIN_ELEMENT_CATEGORIES}.\n */\n category?: string\n /**\n * An mdi icon NAME (`mdiTimerOutline`), never markup and never a path.\n *\n * A path would be arbitrary SVG from a publisher rendered into console\n * chrome; a name is looked up in the icon set the host already ships, so the\n * worst a bad value can do is render nothing.\n */\n icon?: string\n /**\n * The element's editable attributes. Intersected with `capabilities.props`\n * exactly as {@link PluginPropSchema} is — an attribute the plugin cannot\n * receive is not an attribute.\n */\n attributes?: PluginPropSchema[]\n}\n\n/**\n * Categories a third-party element may declare.\n *\n * Deliberately not the whole enum. `LAYOUT` and `NAVIGATION` are structural —\n * a third-party element appearing among the containers a page is built out of\n * invites placements the sandbox cannot honour, and taking a category away\n * later breaks every site that used it. Cheaper to decide now, as the issue\n * says; widening later is easy and narrowing is not.\n */\nexport const PLUGIN_ELEMENT_CATEGORIES: readonly string[] = [\n 'Data Display',\n 'Media',\n 'Commerce',\n 'Forms',\n 'Input',\n 'Text',\n 'Sections & Blocks',\n]\n\n/** Bound on how many elements one plugin may contribute to the palette. */\nexport const PLUGIN_MAX_ELEMENTS = 12\n\nexport interface PluginCapabilities {\n /**\n * Outbound origins the plugin may call (`connect-src`), each an exact\n * https origin (`https://api.example.com`). Empty = no network.\n */\n network?: string[]\n /** Prop names the host passes IN through the bridge. THE allowlist. */\n props?: string[]\n /**\n * Optional editing metadata for the props above (AGL-1049). Absent on every\n * plugin published before this existed, which is why the authoring surface\n * falls back to a plain text field per declared name rather than requiring\n * it.\n */\n propSchema?: PluginPropSchema[]\n /** Event names the plugin may emit OUT through the bridge. */\n events?: string[]\n /** Rendered iframe region size (host reserves this box). */\n size?: { width?: number; height?: number }\n}\n\nexport interface PluginManifest {\n /** Stable plugin id (matches the listing); persisted, never renamed. */\n id: string\n /** Human name shown in the drawer + install screen. */\n name: string\n /** Semver-ish version string (`1.2.0`); must match the artifact version. */\n version: string\n /** Bundle entry the loader imports on the plugin origin. */\n entry: string\n /**\n * Host ABI generation the bundle was built against (AGL-429). Realm and\n * remote-server loaders refuse a bundle whose declared ABI differs from\n * the running host's PLUGIN_HOST_ABI_VERSION; absent = pre-compat\n * bundle, loaded with a warning. Bumping the ABI is a breaking change.\n */\n hostAbi?: number\n capabilities?: PluginCapabilities\n /**\n * Canvas elements this version contributes to the palette (AGL-1031).\n *\n * Part of the reviewed bytes: a new element is a new version through review,\n * and a revoked version's elements vanish from the palette with it, because\n * the palette is built from the pinned install.\n */\n elements?: PluginElementDeclaration[]\n /** Besigner lineal rules the registered component honors (AGL-45 §4). */\n restrictParent?: string[]\n restrictChildren?: string[]\n description?: string\n /**\n * Settings this plugin takes, declared in the manifest (AGL-428).\n *\n * First-party plugins call `registerPluginConfigSchema` at module scope,\n * which a sandboxed third-party bundle cannot do: it does not run in the\n * console process at all, so nothing it executes can reach the registry the\n * settings form reads. The manifest is the one declaration of a marketplace\n * plugin that IS present in the console — denormalized onto every install\n * pin, and part of the reviewed bytes — so it is where a publisher's fields\n * come from.\n *\n * Read through `pluginConfigSchemaFromManifest`, never directly: this is\n * publisher-authored data on a document the console renders a form from, so\n * every field is re-validated on the way in rather than trusted for having\n * been reviewed once.\n */\n config?: {\n fields: PluginConfigField[]\n defaults?: Record<string, unknown>\n }\n /**\n * What `register(host)` contributes, and where (AGL-3116): the elements and\n * features a published page loads the plugin for, and the console slots,\n * routes and shell entries a console screen loads it for. See\n * `plugin-contributions.ts`.\n *\n * Absent on every version published before the contract, and those load\n * under its documented default. A version that declares it is held to it:\n * the verifier compares it with what the bundle registers, and a published\n * page never loads the plugin anywhere the declaration does not place it.\n */\n contributes?: PluginContributions\n}\n\n/** A published, content-addressed version of a plugin listing. */\nexport interface PluginListingVersion {\n version: string\n /** Content hash of the artifact bundle (integrity check at load). */\n sha256: string\n /**\n * Trust tier (AGL-420): 'realm' = staff-reviewed + platform-signed,\n * may load into the app realm; anything else stays in the sandboxed\n * PluginFrame. Staff-writable only.\n */\n trust?: string\n /** Ed25519 signature (base64) over the sha256 hex (AGL-420). */\n signature?: string\n changelog?: string\n createdAtMs?: number\n manifest: PluginManifest\n}\n\n/** `hosts/{hostId}/installs/{listingId}` — a pinned plugin install. */\nexport interface PluginInstall {\n listingId: string\n version: string\n sha256: string\n /** Mirrored trust tier + signature at install time (AGL-420). */\n trust?: string\n signature?: string\n installedAtMs?: number\n updatedAtMs?: number\n entitlementRef?: string\n}\n\n/** `revocations/{listingId}` — platform kill switch checked at load. */\nexport interface PluginRevocation {\n /**\n * Specific versions revoked, or `'all'` to kill the whole listing. The\n * field every INSTALLABILITY reader consults, via `isPluginRevoked`.\n *\n * It used to say this was the only field any reader consulted, and that\n * was the defect rather than a description of one: staff are required to\n * type a reason, it was written here, and nothing rendered it — so the\n * customer whose site broke and the publisher whose version was pulled\n * both got a bare chip (AGL-2328). `reason` and the timestamp are now\n * read by `host-plugins-card` and by the publisher branch of\n * `listing-versions`. Do not restore the old claim.\n */\n versions: string[] | 'all'\n /** Typed by staff, REQUIRED to revoke. Rendered to both audiences. */\n reason?: string\n /**\n * ⚠️ DECLARED HERE AND WRITTEN BY NOTHING. Every writer in\n * `apps/console/app/api/admin/plugin-reviews/route.ts` stores\n * `revokedAt` instead. A reader that trusts this field alone shows no\n * date for every revocation that actually exists — read both, the way\n * `revocationTimeMs` in `listing-versions.ts` does.\n */\n atMs?: number\n /**\n * What the writers actually store — a Firestore server timestamp, so its\n * shape depends on which SDK read it back (`toMillis()` on admin, a\n * `seconds` field through a client). Deliberately `unknown` rather than a\n * lie about which one a given reader will see.\n */\n revokedAt?: unknown\n /**\n * The staff uid that pulled it. Recorded, and deliberately NEVER returned\n * to a customer or a publisher: who acted belongs in the audit log, not\n * on the screen of the person it was done to (AGL-2328).\n */\n revokedBy?: string\n /**\n * `'takedown'` when the listing-level hide wrote it (AGL-948). Un-hiding\n * clears a takedown-owned entry, so it must not be the only record.\n */\n source?: string\n /**\n * Versions revoked by a REVIEW decision (AGL-1085), kept separately from\n * `versions` because a takedown flattens that to `'all'`. Without this,\n * un-hiding a listing would silently un-revoke versions a reviewer stopped\n * for an unrelated reason.\n */\n reviewVersions?: string[]\n}\n\nexport * from './plugin-artifact-path'\n\nexport const PLUGIN_ID_PATTERN = /^[a-z][a-z0-9-]{1,63}$/\nexport const PLUGIN_VERSION_PATTERN = /^\\d+\\.\\d+\\.\\d+$/\nexport const PLUGIN_MAX_NETWORK_ORIGINS = 10\nexport const PLUGIN_MAX_PROPS = 32\n/** Label/description/default text is publisher-authored; keep it bounded. */\nconst PLUGIN_PROP_TEXT_MAX = 200\n/**\n * `mdiTimerOutline` — an icon NAME from the set the host already ships.\n *\n * Never a path: a path is arbitrary SVG from a publisher rendered into console\n * chrome. A name is a lookup, so the worst an unknown one does is render\n * nothing.\n */\nconst MDI_ICON_NAME_PATTERN = /^mdi[A-Za-z0-9]{1,48}$/\nconst PROP_SCHEMA_TYPES = new Set([\n 'string',\n 'number',\n 'boolean',\n 'color',\n 'date',\n 'url',\n 'select',\n])\nexport const PLUGIN_MAX_EVENTS = 32\nexport const PLUGIN_MAX_SIZE_PX = 4096\nconst HTTPS_ORIGIN_PATTERN = /^https:\\/\\/[a-z0-9.-]+(:\\d+)?$/i\nconst IDENTIFIER_PATTERN = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/\n\n/**\n * Validates a manifest at publish time. Returns the normalized manifest or\n * a human-readable error — the publish Cloud Function refuses to store a\n * bundle whose manifest doesn't pass, so bad capabilities never reach a\n * consumer's install screen.\n */\n/**\n * Sanitizes a publisher-authored prop schema against a set of declared props.\n *\n * Shared by `capabilities.propSchema` and each element's `attributes`, so a\n * declared element cannot describe its way past the allowlist any more than a\n * top-level schema can. One implementation, one rule.\n */\nfunction sanitizePropSchemaList(\n input: unknown,\n declared: ReadonlySet<string>,\n): PluginPropSchema[] {\n if (!Array.isArray(input)) return []\n const out: PluginPropSchema[] = []\n const seen = new Set<string>()\n for (const raw of input.slice(0, PLUGIN_MAX_PROPS)) {\n if (!raw || typeof raw !== 'object') continue\n const entry = raw as Record<string, unknown>\n const name = entry['name']\n if (typeof name !== 'string' || !IDENTIFIER_PATTERN.test(name)) continue\n if (!declared.has(name) || seen.has(name)) continue\n seen.add(name)\n const type = PROP_SCHEMA_TYPES.has(String(entry['type']))\n ? (entry['type'] as PluginPropSchema['type'])\n : 'string'\n const next: PluginPropSchema = { name, type }\n for (const key of ['label', 'description'] as const) {\n const value = entry[key]\n if (typeof value === 'string' && value.trim()) {\n next[key] = value.trim().slice(0, PLUGIN_PROP_TEXT_MAX)\n }\n }\n const fallback = entry['default']\n if (\n typeof fallback === 'string' ||\n typeof fallback === 'number' ||\n typeof fallback === 'boolean'\n ) {\n next.default =\n typeof fallback === 'string'\n ? fallback.slice(0, PLUGIN_PROP_TEXT_MAX)\n : fallback\n }\n if (type === 'select' && Array.isArray(entry['options'])) {\n const options = (entry['options'] as unknown[])\n .map((option) => {\n const record = (option ?? {}) as Record<string, unknown>\n const value = record['value']\n if (typeof value !== 'string' || !value) return null\n const label = record['label']\n return {\n value: value.slice(0, PLUGIN_PROP_TEXT_MAX),\n ...(typeof label === 'string' && label.trim()\n ? { label: label.trim().slice(0, PLUGIN_PROP_TEXT_MAX) }\n : {}),\n }\n })\n .filter(Boolean) as Array<{ value: string; label?: string }>\n if (options.length) next.options = options.slice(0, PLUGIN_MAX_PROPS)\n }\n out.push(next)\n }\n return out\n}\n\nexport function validatePluginManifest(\n input: unknown,\n): { ok: true; manifest: PluginManifest } | { ok: false; error: string } {\n if (!input || typeof input !== 'object') {\n return { ok: false, error: 'Manifest must be an object' }\n }\n const raw = input as Record<string, unknown>\n const id = String(raw['id'] ?? '')\n if (!PLUGIN_ID_PATTERN.test(id)) {\n return { ok: false, error: 'Invalid plugin id' }\n }\n const version = String(raw['version'] ?? '')\n if (!PLUGIN_VERSION_PATTERN.test(version)) {\n return { ok: false, error: 'Version must be semver (e.g. 1.0.0)' }\n }\n const name = String(raw['name'] ?? '').trim()\n if (!name || name.length > 80) {\n return { ok: false, error: 'Name is required (max 80 chars)' }\n }\n const entry = String(raw['entry'] ?? '').trim()\n // Entry is a relative bundle path — absolute URLs would let a plugin\n // point the loader at an off-origin script.\n if (!entry || /^[a-z][a-z0-9+.-]*:/i.test(entry) || entry.startsWith('//')) {\n return { ok: false, error: 'Entry must be a relative bundle path' }\n }\n\n const capabilitiesInput = (raw['capabilities'] ?? {}) as Record<\n string,\n unknown\n >\n const capabilities: PluginCapabilities = {}\n\n const network = capabilitiesInput['network']\n if (network !== undefined) {\n if (!Array.isArray(network) || network.length > PLUGIN_MAX_NETWORK_ORIGINS) {\n return { ok: false, error: 'Too many network origins declared' }\n }\n for (const origin of network) {\n if (typeof origin !== 'string' || !HTTPS_ORIGIN_PATTERN.test(origin)) {\n return {\n ok: false,\n error: `Network origin \"${origin}\" must be an https origin`,\n }\n }\n }\n if (network.length) capabilities.network = [...new Set(network as string[])]\n }\n\n for (const key of ['props', 'events'] as const) {\n const list = capabilitiesInput[key]\n if (list === undefined) continue\n const max = key === 'props' ? PLUGIN_MAX_PROPS : PLUGIN_MAX_EVENTS\n if (!Array.isArray(list) || list.length > max) {\n return { ok: false, error: `Too many ${key} declared` }\n }\n for (const name of list) {\n if (typeof name !== 'string' || !IDENTIFIER_PATTERN.test(name)) {\n return { ok: false, error: `Invalid ${key} name \"${name}\"` }\n }\n }\n if (list.length) capabilities[key] = [...new Set(list as string[])]\n }\n\n /**\n * Editing metadata (AGL-1049). Sanitized, never trusted, and INTERSECTED\n * with the allowlist above — an entry naming a prop that is not declared in\n * `props` is dropped rather than rejected.\n *\n * Dropped and not rejected on purpose: a publisher who describes a prop they\n * forgot to declare has made an authoring mistake, not an attack, and\n * refusing the whole manifest for it would fail the publish over a label.\n * The prop still does not cross the bridge, because `filterPluginProps`\n * reads `props` and never this.\n *\n * An unknown `type` degrades to a text field rather than failing: a manifest\n * written against a newer platform must not make an older host refuse a\n * plugin that is otherwise fine.\n */\n const propSchemaInput = capabilitiesInput['propSchema']\n if (propSchemaInput !== undefined) {\n if (\n !Array.isArray(propSchemaInput) ||\n propSchemaInput.length > PLUGIN_MAX_PROPS\n ) {\n return { ok: false, error: 'Too many prop schemas declared' }\n }\n const propSchema = sanitizePropSchemaList(\n propSchemaInput,\n new Set(capabilities.props ?? []),\n )\n if (propSchema.length) capabilities.propSchema = propSchema\n }\n\n const size = capabilitiesInput['size'] as\n | { width?: unknown; height?: unknown }\n | undefined\n if (size) {\n const width = Number(size.width ?? 0)\n const height = Number(size.height ?? 0)\n if (\n (size.width !== undefined &&\n (!Number.isFinite(width) || width < 0 || width > PLUGIN_MAX_SIZE_PX)) ||\n (size.height !== undefined &&\n (!Number.isFinite(height) ||\n height < 0 ||\n height > PLUGIN_MAX_SIZE_PX))\n ) {\n return { ok: false, error: 'Declared size is out of range' }\n }\n capabilities.size = {\n ...(size.width !== undefined ? { width } : {}),\n ...(size.height !== undefined ? { height } : {}),\n }\n }\n\n const restrict = (value: unknown): string[] | undefined => {\n if (!Array.isArray(value)) return undefined\n const ids = value.filter(\n (entry): entry is string => typeof entry === 'string' && entry.length > 0,\n )\n return ids.length ? [...new Set(ids)] : undefined\n }\n\n const hostAbiRaw = raw['hostAbi']\n let hostAbi: number | undefined\n if (hostAbiRaw !== undefined) {\n hostAbi = Number(hostAbiRaw)\n if (!Number.isInteger(hostAbi) || hostAbi < 1 || hostAbi > 99) {\n return { ok: false, error: 'hostAbi must be a small positive integer' }\n }\n }\n\n /**\n * Declared canvas elements (AGL-1031). Sanitized hard, because every field\n * here is publisher-authored data the HOST renders into its own chrome.\n *\n * A malformed `elements` array is refused — that is a build error a\n * publisher can see and fix. A single bad ENTRY is dropped instead, so one\n * typo cannot fail a whole release.\n */\n const elementsInput = raw['elements']\n const elements: PluginElementDeclaration[] = []\n if (elementsInput !== undefined) {\n if (\n !Array.isArray(elementsInput) ||\n elementsInput.length > PLUGIN_MAX_ELEMENTS\n ) {\n return { ok: false, error: 'Too many elements declared' }\n }\n const declaredProps = new Set(capabilities.props ?? [])\n const seenIds = new Set<string>()\n for (const rawElement of elementsInput) {\n if (!rawElement || typeof rawElement !== 'object') continue\n const entryRecord = rawElement as Record<string, unknown>\n const elementId = entryRecord['id']\n const elementName = entryRecord['displayName']\n if (typeof elementId !== 'string' || !IDENTIFIER_PATTERN.test(elementId)) {\n continue\n }\n if (seenIds.has(elementId)) continue\n if (typeof elementName !== 'string' || !elementName.trim()) continue\n seenIds.add(elementId)\n const element: PluginElementDeclaration = {\n id: elementId,\n displayName: elementName.trim().slice(0, PLUGIN_PROP_TEXT_MAX),\n }\n const elementDescription = entryRecord['description']\n if (typeof elementDescription === 'string' && elementDescription.trim()) {\n element.description = elementDescription\n .trim()\n .slice(0, PLUGIN_PROP_TEXT_MAX)\n }\n // A category outside the permitted subset is DROPPED, not refused: the\n // structural ones are withheld deliberately (see\n // PLUGIN_ELEMENT_CATEGORIES), and a publisher aiming at one should still\n // get a usable element rather than a failed publish.\n const elementCategory = entryRecord['category']\n if (\n typeof elementCategory === 'string' &&\n PLUGIN_ELEMENT_CATEGORIES.includes(elementCategory)\n ) {\n element.category = elementCategory\n }\n const elementIcon = entryRecord['icon']\n if (\n typeof elementIcon === 'string' &&\n MDI_ICON_NAME_PATTERN.test(elementIcon)\n ) {\n element.icon = elementIcon\n }\n const elementAttributes = sanitizePropSchemaList(\n entryRecord['attributes'],\n declaredProps,\n )\n if (elementAttributes.length) element.attributes = elementAttributes\n elements.push(element)\n }\n }\n\n /**\n * Declared contributions (AGL-3116). Refused whole when malformed rather\n * than trimmed: a loader places the plugin by this block, and an entry\n * dropped on the way in would stop it loading where it is used.\n */\n let contributes: PluginContributions | undefined\n if (raw['contributes'] !== undefined) {\n const verdict = sanitizePluginContributions(raw['contributes'])\n if (verdict.ok === false) return { ok: false, error: verdict.error }\n contributes = verdict.contributions\n }\n\n return {\n ok: true,\n manifest: {\n id,\n name,\n version,\n entry,\n ...(hostAbi !== undefined ? { hostAbi } : {}),\n ...(contributes ? { contributes } : {}),\n ...(Object.keys(capabilities).length ? { capabilities } : {}),\n ...(elements.length ? { elements } : {}),\n ...(restrict(raw['restrictParent'])\n ? { restrictParent: restrict(raw['restrictParent']) }\n : {}),\n ...(restrict(raw['restrictChildren'])\n ? { restrictChildren: restrict(raw['restrictChildren']) }\n : {}),\n ...(typeof raw['description'] === 'string'\n ? { description: String(raw['description']).slice(0, 500) }\n : {}),\n },\n }\n}\n\n\n/**\n * The sandbox CSP is NOT built here (AGL-1092).\n *\n * A `pluginContentSecurityPolicy` used to live at this spot: exported,\n * unit-tested, and called by nothing. The policy that actually reaches a\n * browser is `csp()` in `tools/plugin-loader/origin/api/load.mjs`, on the\n * plugin-origin deployment, and the two disagreed — this one emitted\n * `connect-src 'none'` for a manifest with no network, which would have\n * broken every sandboxed load, since the frame fetches its own bundle from\n * its own origin. Deleted rather than reconciled: a tested policy nobody\n * serves is worse than none, because it answers a reader's question wrongly.\n * `capabilities.network` still decides the allowlist — the loader reads it\n * from the public listing-versions endpoint and appends it to `connect-src`,\n * with tests beside it (`npm run test:plugin-loader`).\n */\n\n/**\n * True when a pinned version is killed — the whole listing (`'all'`) or the\n * specific version. Loaders check this before executing and render a safe\n * placeholder when true (AGL-45 §3.5 kill switch).\n */\nexport function isPluginRevoked(\n revocation: PluginRevocation | null | undefined,\n version: string,\n): boolean {\n if (!revocation) return false\n if (isListingWideRevocation(revocation)) return true\n return (\n Array.isArray(revocation.versions) && revocation.versions.includes(version)\n )\n}\n\n/**\n * True when the kill switch is thrown on the WHOLE listing, not one build.\n *\n * Split out for the one caller that has no version to ask about: marketplace\n * checkout (AGL-2288) must refuse to SELL a listing the platform has switched\n * off, and it decides that before any version is chosen. Written here rather\n * than as `revocation?.versions === 'all'` at that call site for the reason\n * the doc comment on `nextRevocationState` gives — what `'all'` means is a\n * property of this document's shape, and a second reader that spelled it out\n * itself is how a kill switch silently stops killing.\n *\n * A per-version revocation is deliberately NOT listing-wide: it stops one\n * build while the rest stay installable.\n */\nexport function isListingWideRevocation(\n revocation: PluginRevocation | null | undefined,\n): boolean {\n return revocation?.versions === 'all'\n}\n\n/**\n * What a listing OFFERS a client right now (AGL-2368).\n *\n * `newestInstallableVersion` is the derivation, and it needs the version set —\n * which is server-only (`pluginVersions`). A client has the listing's\n * `latestApprovedVersion` mirror instead, and since AGL-2306 every writer of\n * that mirror computes it with `newestInstallableVersion`. So on a client the\n * mirror IS the answer, with one gap: the revocation document and the listing\n * document are two non-transactional writes, and a live listener sees them\n * land at different times. In that window the mirror names a version the kill\n * switch has already stopped, which is the whole shape of this bug.\n *\n * So a client that holds the revocation checks it against the mirror and, when\n * they disagree, offers NOTHING rather than the next-best guess. It cannot\n * compute the next-best guess — it has no version list — and \"no update to\n * offer\" is the safe reading of a mirror it has caught mid-repair. The repair\n * lands moments later and the real answer appears.\n *\n * A client with no revocation in hand passes `undefined` and gets the mirror,\n * which is what it had before. That is a real fallback, not a silent one: the\n * gap it leaves is bounded by the repair, and the install route derives live\n * and refuses regardless.\n */\nexport function offeredPluginVersion(\n listing: { latestApprovedVersion?: unknown } | null | undefined,\n revocation: PluginRevocation | null | undefined,\n): string | null {\n const offered = String(listing?.latestApprovedVersion ?? '')\n if (!offered) return null\n return isPluginRevoked(revocation, offered) ? null : offered\n}\n\n/**\n * The newest version a buyer could actually install right now (AGL-2306).\n *\n * Two things have to be true of an offer, and the listing's\n * `latestApprovedVersion` mirror only ever tracked one of them: the version\n * must be APPROVED (AGL-966 — review lives on the version) and it must not be\n * REVOKED (AGL-1085 — `install-plugin` answers 409 to a revoked pin).\n *\n * Written here rather than in the console route that repairs the mirror, and\n * rather than reusing `newestApprovedVersion` in the marketplace plugin's\n * model, because the console is `scope:app` and may not depend on\n * `aglyn:addons`. Both may import core, and \"what is on offer\" is one\n * question that must have one answer.\n *\n * `compare` is injected rather than imported so this module stays free of the\n * artifact-version comparator's own dependencies; every caller already has it.\n * A `null` comparison (an unparseable version string) sorts as \"not newer\",\n * which keeps a malformed version out of an offer rather than into one.\n *\n * Returns `null` when nothing qualifies — an ABSENT mirror reads as \"no update\n * to offer\", while a stale string reads as an update that does not exist.\n */\nexport function newestInstallableVersion(\n versions: readonly { version: string; reviewState?: unknown }[],\n revocation: PluginRevocation | null | undefined,\n compare: (a: string, b: string) => number | null,\n): string | null {\n let newest: string | null = null\n for (const entry of versions) {\n if (!entry?.version) continue\n if (entry.reviewState !== 'approved') continue\n if (isPluginRevoked(revocation, entry.version)) continue\n if (newest == null || (compare(newest, entry.version) ?? 0) < 0) {\n newest = entry.version\n }\n }\n return newest\n}\n\n/**\n * The next `revocations/{listingId}` state after one write (AGL-1085).\n *\n * Two writers share this doc and neither may erase the other:\n *\n * * a **takedown** kills the listing, flattening `versions` to `'all'`, and\n * un-hiding removes what it wrote (AGL-948);\n * * a **review** decision stops one version's bytes — the reviewer's only\n * alternative used to be a full takedown, which also revokes the version\n * customers are happily running.\n *\n * `versions` stays the single field every reader consults, so `isPluginRevoked`\n * and the loaders are untouched. `reviewVersions` is the durable record of the\n * review-owned half, which is what lets un-hiding restore rather than clear it.\n * Returns `null` when nothing is revoked any more and the doc should be\n * deleted — an empty `versions: []` would read as \"revoked nothing\" but keep a\n * doc around that a later reader has to interpret.\n *\n * Pure so both transitions are testable without Firestore, and colocated with\n * `isPluginRevoked` on purpose: a writer that disagreed with the reader about\n * this doc's shape is exactly how a kill switch silently stops killing.\n */\nexport function nextRevocationState(\n current: PluginRevocation | null | undefined,\n change:\n | { type: 'revoke-version'; version: string }\n | { type: 'unrevoke-version'; version: string }\n | { type: 'takedown' }\n | { type: 'restore' },\n): PluginRevocation | null {\n const takenDown = current?.source === 'takedown'\n // A document written before AGL-1085 — or by hand, which the rules permit\n // any staff client to do — has `versions` and NO `reviewVersions`\n // (AGL-2305). `withReview` REPLACES `versions` wholesale from this seed, so\n // reading it as an empty list silently rebuilt the document: revoking a\n // second version un-revoked the first, and un-revoking any version returned\n // `null`, which the caller turns into a DELETE of the whole kill switch.\n //\n // A legacy `versions` array is adopted as the review-owned half, which is\n // what it actually was: before AGL-1085 the only writer that produced an\n // array here was a reviewer, and `'all'` (the takedown form) is excluded\n // because that half is owned by `source` and restored by `restore`.\n const reviewVersions = [\n ...(current?.reviewVersions ??\n (Array.isArray(current?.versions) ? current.versions : [])),\n ]\n const withReview = (versions: string[], stillTakenDown: boolean) => {\n if (stillTakenDown) {\n return { ...current, versions: 'all' as const, reviewVersions: versions }\n }\n if (!versions.length) return null\n const { source: _source, ...rest } = current ?? {}\n return { ...rest, versions, reviewVersions: versions }\n }\n switch (change.type) {\n case 'revoke-version': {\n const next = reviewVersions.includes(change.version)\n ? reviewVersions\n : [...reviewVersions, change.version]\n return withReview(next, takenDown)\n }\n case 'unrevoke-version': {\n return withReview(\n reviewVersions.filter((entry) => entry !== change.version),\n takenDown,\n )\n }\n case 'takedown':\n return { ...current, versions: 'all', source: 'takedown', reviewVersions }\n case 'restore':\n // Only the takedown's own contribution goes away. A version a reviewer\n // stopped stays stopped — un-hiding is not a review decision.\n return withReview(reviewVersions, false)\n }\n}\n\n/** Methods a host-mediated plugin fetch may use (AGL-191). */\nexport const PLUGIN_FETCH_METHODS = ['GET', 'POST'] as const\nexport type PluginFetchMethod = (typeof PLUGIN_FETCH_METHODS)[number]\n/** Request/response body cap for host-mediated fetch (bytes). */\nexport const PLUGIN_FETCH_MAX_BODY_BYTES = 256 * 1024\n\n/**\n * True when `url`'s origin is an exact match against the manifest's\n * declared `network` allowlist (AGL-191). The host re-checks this before\n * proxying a plugin's `fetch-request`, so a plugin can only reach origins\n * it declared at install (and the install screen surfaced). No allowlist =\n * no host-mediated network; https-only.\n */\nexport function isPluginNetworkAllowed(\n url: string,\n capabilities: PluginCapabilities | undefined,\n): boolean {\n const allow = capabilities?.network\n if (!allow?.length) return false\n try {\n const parsed = new URL(url)\n if (parsed.protocol !== 'https:') return false\n return allow.includes(parsed.origin)\n } catch {\n return false\n }\n}\n\n/** Component id of the sandboxed plugin canvas element (plugins-mui). */\nexport const PLUGIN_COMPONENT_ID = 'marketplacePlugin'\n\n/** Resolved install data injected into a plugin node's props at compose. */\nexport interface ResolvedPluginInstall {\n listingId: string\n version: string\n sha256: string\n capabilities?: PluginCapabilities\n revoked?: boolean\n}\n\n/**\n * Compose-time injection (AGL-45), mirroring `attachFunctionDefinitions`:\n * a `marketplacePlugin` node carries only a `listingId` in the saved screen;\n * the tenant compose pass resolves that to the host's pinned install\n * (version/sha256/capabilities) and the kill-switch state, and stamps them\n * onto the node's props so `PluginFrame` renders without a client read.\n * Unknown/uninstalled listings leave the node untouched (it shows a safe\n * \"not installed\" placeholder rather than taking the screen down).\n */\nexport function attachPluginInstalls<T extends Record<string, any>>(\n nodes: T,\n installsByListingId: Record<string, ResolvedPluginInstall | undefined>,\n): T {\n if (!Object.keys(installsByListingId).length) return nodes\n const next: Record<string, any> = {}\n for (const [id, node] of Object.entries(nodes)) {\n const listingId =\n node?.componentId === PLUGIN_COMPONENT_ID\n ? node?.props?.listingId\n : undefined\n const install = listingId\n ? installsByListingId[String(listingId)]\n : undefined\n next[id] = install\n ? {\n ...node,\n props: {\n ...node.props,\n version: install.version,\n sha256: install.sha256,\n capabilities: install.capabilities,\n revoked: Boolean(install.revoked),\n },\n }\n : node\n }\n return next as T\n}\n\n/** One editable setting on a placed plugin, resolved for the attributes panel. */\nexport interface PluginPropField {\n name: string\n type: NonNullable<PluginPropSchema['type']>\n label: string\n description?: string\n default?: string | number | boolean\n options?: Array<{ value: string; label?: string }>\n}\n\n/**\n * The settings an author may edit on a placed plugin (AGL-1049).\n *\n * Driven by `capabilities.props` — THE allowlist — and decorated by\n * `propSchema` where the publisher supplied one. That order is the whole\n * security property: the list of editable settings can never be longer than\n * the list of props that cross the bridge, whatever the schema says, so a\n * publisher cannot describe their way into a prop they did not declare.\n *\n * A plugin published before `propSchema` existed still gets a field per\n * declared prop, as plain text. That is the difference between guessing key\n * names in a JSON textarea and being shown them, and it needs no manifest\n * change to work — which matters, because every plugin installed today\n * predates this.\n */\nexport function resolvePluginPropFields(\n manifest: { capabilities?: PluginCapabilities } | null | undefined,\n): PluginPropField[] {\n const props = manifest?.capabilities?.props ?? []\n const schema = new Map(\n (manifest?.capabilities?.propSchema ?? []).map((entry) => [\n entry.name,\n entry,\n ]),\n )\n return props.map((name) => {\n const declared = schema.get(name)\n return {\n name,\n type: declared?.type ?? 'string',\n label: declared?.label ?? name,\n ...(declared?.description ? { description: declared.description } : {}),\n ...(declared?.default !== undefined ? { default: declared.default } : {}),\n ...(declared?.options ? { options: declared.options } : {}),\n }\n })\n}\n\n/**\n * Keys an author has set that the plugin will silently ignore.\n *\n * The failure this exists to surface: `filterPluginProps` drops anything not\n * in the allowlist, so a typo does not fail — it just quietly does nothing,\n * which is the worst of the options. Naming the key is the whole fix.\n */\nexport function unknownPluginPropKeys(\n manifest: { capabilities?: PluginCapabilities } | null | undefined,\n values: Record<string, unknown> | null | undefined,\n): string[] {\n if (!values) return []\n const allowed = new Set(manifest?.capabilities?.props ?? [])\n return Object.keys(values).filter((key) => !allowed.has(key))\n}\n\n/** A declared element, resolved for the palette. */\nexport interface PluginPaletteElement {\n listingId: string\n elementId: string\n displayName: string\n description?: string\n category: string\n /** mdi icon NAME; the surface looks it up, never renders it as markup. */\n icon?: string\n fields: PluginPropField[]\n}\n\n/**\n * The palette entries an installed plugin contributes (AGL-1031).\n *\n * Resolved from the PINNED install, which is what makes the two guarantees in\n * the issue hold without extra machinery: an element only appears where the\n * plugin is installed, and a revoked or downgraded version's elements vanish\n * with it, because the palette is rebuilt from whatever the pin now points at.\n *\n * Attributes come back through `resolvePluginPropFields`, so an element's\n * editable fields are bounded by `capabilities.props` exactly like the generic\n * plugin element's are. A declared element cannot widen what crosses the\n * bridge; it only gives the same props a better name and a better editor.\n */\nexport function resolvePluginElements(\n install:\n | {\n listingId?: string\n capabilities?: PluginCapabilities\n manifest?: { elements?: PluginElementDeclaration[] }\n elements?: PluginElementDeclaration[]\n }\n | null\n | undefined,\n): PluginPaletteElement[] {\n const listingId = install?.listingId\n if (!listingId) return []\n const declared = install?.elements ?? install?.manifest?.elements ?? []\n const capabilities = install?.capabilities\n return declared.map((element) => ({\n listingId,\n elementId: element.id,\n displayName: element.displayName,\n ...(element.description ? { description: element.description } : {}),\n category: element.category ?? 'Data Display',\n ...(element.icon ? { icon: element.icon } : {}),\n // Per-element attributes when declared; otherwise the plugin's whole\n // declared prop set, which is still better than a JSON box.\n fields: element.attributes?.length\n ? resolvePluginPropFields({\n capabilities: {\n props: element.attributes.map((attribute) => attribute.name),\n propSchema: element.attributes,\n },\n })\n : resolvePluginPropFields({ capabilities }),\n }))\n}\n"],"names":["sanitizePluginContributions","PLUGIN_ELEMENT_CATEGORIES","PLUGIN_MAX_ELEMENTS","PLUGIN_ID_PATTERN","PLUGIN_VERSION_PATTERN","PLUGIN_MAX_NETWORK_ORIGINS","PLUGIN_MAX_PROPS","PLUGIN_PROP_TEXT_MAX","MDI_ICON_NAME_PATTERN","PROP_SCHEMA_TYPES","Set","PLUGIN_MAX_EVENTS","PLUGIN_MAX_SIZE_PX","HTTPS_ORIGIN_PATTERN","IDENTIFIER_PATTERN","sanitizePropSchemaList","input","declared","Array","isArray","out","seen","raw","slice","entry","name","test","has","add","type","String","next","key","value","trim","fallback","default","options","map","option","record","label","filter","Boolean","length","push","validatePluginManifest","ok","error","id","version","startsWith","capabilitiesInput","capabilities","network","undefined","origin","list","max","propSchemaInput","propSchema","props","size","width","Number","height","isFinite","restrict","ids","hostAbiRaw","hostAbi","isInteger","elementsInput","elements","declaredProps","seenIds","rawElement","entryRecord","elementId","elementName","element","displayName","elementDescription","description","elementCategory","includes","category","elementIcon","icon","elementAttributes","attributes","contributes","verdict","contributions","manifest","Object","keys","restrictParent","restrictChildren","isPluginRevoked","revocation","isListingWideRevocation","versions","offeredPluginVersion","listing","offered","latestApprovedVersion","newestInstallableVersion","compare","newest","reviewState","nextRevocationState","current","change","takenDown","source","reviewVersions","withReview","stillTakenDown","_source","rest","PLUGIN_FETCH_METHODS","PLUGIN_FETCH_MAX_BODY_BYTES","isPluginNetworkAllowed","url","allow","parsed","URL","protocol","PLUGIN_COMPONENT_ID","attachPluginInstalls","nodes","installsByListingId","node","entries","listingId","componentId","install","sha256","revoked","resolvePluginPropFields","schema","Map","get","unknownPluginPropKeys","values","allowed","resolvePluginElements","fields","attribute"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;;AAGD,SACEA,2BAA2B,QAEtB,4CAAwC;AAmF/C;;;;;;;;CAQC,GACD,OAAO,MAAMC,4BAA+C;IAC1D;IACA;IACA;IACA;IACA;IACA;IACA;CACD,CAAA;AAED,yEAAyE,GACzE,OAAO,MAAMC,sBAAsB,GAAE;AAyKrC,cAAc,4BAAwB;AAEtC,OAAO,MAAMC,oBAAoB,yBAAwB;AACzD,OAAO,MAAMC,yBAAyB,kBAAiB;AACvD,OAAO,MAAMC,6BAA6B,GAAE;AAC5C,OAAO,MAAMC,mBAAmB,GAAE;AAClC,2EAA2E,GAC3E,MAAMC,uBAAuB;AAC7B;;;;;;CAMC,GACD,MAAMC,wBAAwB;AAC9B,MAAMC,oBAAoB,IAAIC,IAAI;IAChC;IACA;IACA;IACA;IACA;IACA;IACA;CACD;AACD,OAAO,MAAMC,oBAAoB,GAAE;AACnC,OAAO,MAAMC,qBAAqB,KAAI;AACtC,MAAMC,uBAAuB;AAC7B,MAAMC,qBAAqB;AAE3B;;;;;CAKC,GACD;;;;;;CAMC,GACD,SAASC,uBACPC,KAAc,EACdC,QAA6B;IAE7B,IAAI,CAACC,MAAMC,OAAO,CAACH,QAAQ,OAAO,EAAE;IACpC,MAAMI,MAA0B,EAAE;IAClC,MAAMC,OAAO,IAAIX;IACjB,KAAK,MAAMY,OAAON,MAAMO,KAAK,CAAC,GAAGjB,kBAAmB;QAClD,IAAI,CAACgB,OAAO,OAAOA,QAAQ,UAAU;QACrC,MAAME,QAAQF;QACd,MAAMG,OAAOD,KAAK,CAAC,OAAO;QAC1B,IAAI,OAAOC,SAAS,YAAY,CAACX,mBAAmBY,IAAI,C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gE,4BAAAA,oBAAAA,QAAS3C,QAAQ,qBAAjB2C,kBAAmBhE,QAAQ,YAAhDgE,OAAoD,EAAE;IACvE,MAAMpF,eAAeoF,2BAAAA,QAASpF,YAAY;IAC1C,OAAOpC,SAASqB,GAAG,CAAC,CAAC0C;YAKTA;YAIFA;eATwB;YAChCuD;YACAzD,WAAWE,QAAQ/B,EAAE;YACrBgC,aAAaD,QAAQC,WAAW;WAC5BD,QAAQG,WAAW,GAAG;YAAEA,aAAaH,QAAQG,WAAW;QAAC,IAAI,CAAC;YAClEG,QAAQ,GAAEN,oBAAAA,QAAQM,QAAQ,YAAhBN,oBAAoB;WAC1BA,QAAQQ,IAAI,GAAG;YAAEA,MAAMR,QAAQQ,IAAI;QAAC,IAAI,CAAC;YAC7C,qEAAqE;YACrE,4DAA4D;YAC5D4D,QAAQpE,EAAAA,sBAAAA,QAAQU,UAAU,qBAAlBV,oBAAoBpC,MAAM,IAC9BgG,wBAAwB;gBACtBvF,cAAc;oBACZQ,OAAOmB,QAAQU,UAAU,CAACpD,GAAG,CAAC,CAAC+G,YAAcA,UAAU5H,IAAI;oBAC3DmC,YAAYoB,QAAQU,UAAU;gBAChC;YACF,KACAkD,wBAAwB;gBAAEvF;YAAa;;;AAE/C"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/plugin-manifest.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\nimport {\n pluginConfigSchemaFromManifest,\n type PluginConfigField,\n} from '../plugin-manager/plugin-config'\nimport {\n sanitizePluginContributions,\n type PluginContributions,\n} from '../plugin-manager/plugin-contributions'\nimport {\n validatePluginConnections,\n validatePluginImageHosts,\n type PluginConnectionDeclaration,\n} from './plugin-connections'\nimport { PLUGIN_COMPONENT_ID } from './plugin-elements'\n\n/**\n * Executable-plugin manifest, artifact-path, CSP, and revocation helpers\n * (AGL-45), per the accepted AGL-43 design. Plugins — unlike declarative\n * components (see `marketplace.ts`) — are code, so they never run in the\n * console/tenant origin: they load in a sandboxed iframe on a dedicated\n * plugin origin, and this manifest is the contract the install screen\n * shows verbatim and the serving layer turns into CSP. Pure module — safe\n * to import from API routes, the loader, and the host runtime alike.\n */\n\n/** Capabilities a plugin declares; shown verbatim at install. */\n/**\n * How a declared prop should be EDITED. Authoring metadata only (AGL-1049).\n *\n * Deliberately separate from `props`, which stays the security allowlist. A\n * schema entry for a name that is not in `props` widens nothing — it is\n * dropped, because the filter and the author disagreeing must resolve in the\n * filter's favour. The point of this is to make them agree, never to let a\n * publisher grant themselves a prop by describing it.\n */\nexport interface PluginPropSchema {\n /** Must also appear in `capabilities.props`, or this entry is ignored. */\n name: string\n /**\n * Which editor to render. Unknown values degrade to `string` rather than\n * being rejected: this is publisher-authored data, and a manifest from a\n * newer platform version must not make an older host refuse the plugin.\n */\n type?: 'string' | 'number' | 'boolean' | 'color' | 'date' | 'url' | 'select'\n label?: string\n description?: string\n /** Shown as the field's initial value, so \"leave it alone\" is visible. */\n default?: string | number | boolean\n /** `select` only. */\n options?: Array<{ value: string; label?: string }>\n}\n\n/**\n * A canvas element a plugin version contributes (AGL-1031).\n *\n * A first-party plugin that extends the besigner declares a `ComponentSchema`\n * and gets a first-class palette entry. A marketplace plugin doing the same\n * work got a generic \"Plugin\" wrapper and a JSON textarea. Where an element\n * came from is a fact about its provenance, not a different kind of thing.\n *\n * The line this must not cross: **declared schema drives AUTHORING; the\n * sandbox still owns runtime.** This is publisher-authored DATA. It never\n * becomes a React component in the host bundle — the palette entry, the label\n * and the attribute fields are host-rendered from the declaration, and the\n * saved node still resolves to a sandboxed `PluginFrame` integrity-checked\n * against the pinned sha256. Nothing here changes what executes or where.\n */\nexport interface PluginElementDeclaration {\n /**\n * Stable id, unique within the plugin. Saved on the node beside the listing\n * id, so renaming the display name never orphans a placed element.\n */\n id: string\n displayName: string\n description?: string\n /**\n * Drawer category. Constrained to a subset — see\n * {@link PLUGIN_ELEMENT_CATEGORIES}.\n */\n category?: string\n /**\n * An mdi icon NAME (`mdiTimerOutline`), never markup and never a path.\n *\n * A path would be arbitrary SVG from a publisher rendered into console\n * chrome; a name is looked up in the icon set the host already ships, so the\n * worst a bad value can do is render nothing.\n */\n icon?: string\n /**\n * The element's editable attributes. Intersected with `capabilities.props`\n * exactly as {@link PluginPropSchema} is — an attribute the plugin cannot\n * receive is not an attribute.\n */\n attributes?: PluginPropSchema[]\n}\n\n/**\n * Categories a third-party element may declare.\n *\n * Deliberately not the whole enum. `LAYOUT` and `NAVIGATION` are structural —\n * a third-party element appearing among the containers a page is built out of\n * invites placements the sandbox cannot honour, and taking a category away\n * later breaks every site that used it. Cheaper to decide now, as the issue\n * says; widening later is easy and narrowing is not.\n */\nexport const PLUGIN_ELEMENT_CATEGORIES: readonly string[] = [\n 'Data Display',\n 'Media',\n 'Commerce',\n 'Forms',\n 'Input',\n 'Text',\n 'Sections & Blocks',\n]\n\n/** Bound on how many elements one plugin may contribute to the palette. */\nexport const PLUGIN_MAX_ELEMENTS = 12\n\nexport interface PluginCapabilities {\n /**\n * Outbound origins the plugin may call (`connect-src`), each an exact\n * https origin (`https://api.example.com`). Empty = no network.\n */\n network?: string[]\n /** Prop names the host passes IN through the bridge. THE allowlist. */\n props?: string[]\n /**\n * Optional editing metadata for the props above (AGL-1049). Absent on every\n * plugin published before this existed, which is why the authoring surface\n * falls back to a plain text field per declared name rather than requiring\n * it.\n */\n propSchema?: PluginPropSchema[]\n /** Event names the plugin may emit OUT through the bridge. */\n events?: string[]\n /** Rendered iframe region size (host reserves this box). */\n size?: { width?: number; height?: number }\n /**\n * Hosts the plugin's elements may show images from on a published site\n * (AGL-4193): an exact public hostname or `*.<domain>` with one wildcard\n * label. Validated here; the tenant's `img-src` reads it for a site that\n * runs the plugin.\n */\n imageHosts?: string[]\n}\n\nexport interface PluginManifest {\n /** Stable plugin id (matches the listing); persisted, never renamed. */\n id: string\n /** Human name shown in the drawer + install screen. */\n name: string\n /** Semver-ish version string (`1.2.0`); must match the artifact version. */\n version: string\n /** Bundle entry the loader imports on the plugin origin. */\n entry: string\n /**\n * Host ABI generation the bundle was built against (AGL-429). Realm and\n * remote-server loaders refuse a bundle whose declared ABI differs from\n * the running host's PLUGIN_HOST_ABI_VERSION; absent = pre-compat\n * bundle, loaded with a warning. Bumping the ABI is a breaking change.\n */\n hostAbi?: number\n capabilities?: PluginCapabilities\n /**\n * Canvas elements this version contributes to the palette (AGL-1031).\n *\n * Part of the reviewed bytes: a new element is a new version through review,\n * and a revoked version's elements vanish from the palette with it, because\n * the palette is built from the pinned install.\n */\n elements?: PluginElementDeclaration[]\n /** Besigner lineal rules the registered component honors (AGL-45 §4). */\n restrictParent?: string[]\n restrictChildren?: string[]\n description?: string\n /**\n * Settings this plugin takes, declared in the manifest (AGL-428).\n *\n * First-party plugins call `registerPluginConfigSchema` at module scope,\n * which a sandboxed third-party bundle cannot do: it does not run in the\n * console process at all, so nothing it executes can reach the registry the\n * settings form reads. The manifest is the one declaration of a marketplace\n * plugin that IS present in the console — denormalized onto every install\n * pin, and part of the reviewed bytes — so it is where a publisher's fields\n * come from.\n *\n * Read through `pluginConfigSchemaFromManifest`, never directly: this is\n * publisher-authored data on a document the console renders a form from, so\n * every field is re-validated on the way in rather than trusted for having\n * been reviewed once.\n */\n config?: {\n fields: PluginConfigField[]\n defaults?: Record<string, unknown>\n }\n /**\n * What `register(host)` contributes, and where (AGL-3116): the elements and\n * features a published page loads the plugin for, and the console slots,\n * routes and shell entries a console screen loads it for. See\n * `plugin-contributions.ts`.\n *\n * Absent on every version published before the contract, and those load\n * under its documented default. A version that declares it is held to it:\n * the verifier compares it with what the bundle registers, and a published\n * page never loads the plugin anywhere the declaration does not place it.\n */\n contributes?: PluginContributions\n /**\n * Declared connections (AGL-4193): OAuth providers the PLATFORM connects a\n * site to on the plugin's behalf, the hosts it may call with the grant, the\n * picker that chooses what to connect, and the scheduled fetch that maps the\n * provider's answer into the site's public record. The plugin's own code\n * never sees a token. See `plugin-connections.ts`.\n */\n connections?: PluginConnectionDeclaration[]\n}\n\n/** A published, content-addressed version of a plugin listing. */\nexport interface PluginListingVersion {\n version: string\n /** Content hash of the artifact bundle (integrity check at load). */\n sha256: string\n /**\n * Trust tier (AGL-420): 'realm' = staff-reviewed + platform-signed,\n * may load into the app realm; anything else stays in the sandboxed\n * PluginFrame. Staff-writable only.\n */\n trust?: string\n /** Ed25519 signature (base64) over the sha256 hex (AGL-420). */\n signature?: string\n changelog?: string\n createdAtMs?: number\n manifest: PluginManifest\n}\n\n/** `hosts/{hostId}/installs/{listingId}` — a pinned plugin install. */\nexport interface PluginInstall {\n listingId: string\n version: string\n sha256: string\n /** Mirrored trust tier + signature at install time (AGL-420). */\n trust?: string\n signature?: string\n installedAtMs?: number\n updatedAtMs?: number\n entitlementRef?: string\n}\n\n/** `revocations/{listingId}` — platform kill switch checked at load. */\nexport interface PluginRevocation {\n /**\n * Specific versions revoked, or `'all'` to kill the whole listing. The\n * field every INSTALLABILITY reader consults, via `isPluginRevoked`.\n *\n * It used to say this was the only field any reader consulted, and that\n * was the defect rather than a description of one: staff are required to\n * type a reason, it was written here, and nothing rendered it — so the\n * customer whose site broke and the publisher whose version was pulled\n * both got a bare chip (AGL-2328). `reason` and the timestamp are now\n * read by `host-plugins-card` and by the publisher branch of\n * `listing-versions`. Do not restore the old claim.\n */\n versions: string[] | 'all'\n /** Typed by staff, REQUIRED to revoke. Rendered to both audiences. */\n reason?: string\n /**\n * ⚠️ DECLARED HERE AND WRITTEN BY NOTHING. Every writer in\n * `apps/console/app/api/admin/plugin-reviews/route.ts` stores\n * `revokedAt` instead. A reader that trusts this field alone shows no\n * date for every revocation that actually exists — read both, the way\n * `revocationTimeMs` in `listing-versions.ts` does.\n */\n atMs?: number\n /**\n * What the writers actually store — a Firestore server timestamp, so its\n * shape depends on which SDK read it back (`toMillis()` on admin, a\n * `seconds` field through a client). Deliberately `unknown` rather than a\n * lie about which one a given reader will see.\n */\n revokedAt?: unknown\n /**\n * The staff uid that pulled it. Recorded, and deliberately NEVER returned\n * to a customer or a publisher: who acted belongs in the audit log, not\n * on the screen of the person it was done to (AGL-2328).\n */\n revokedBy?: string\n /**\n * `'takedown'` when the listing-level hide wrote it (AGL-948). Un-hiding\n * clears a takedown-owned entry, so it must not be the only record.\n */\n source?: string\n /**\n * Versions revoked by a REVIEW decision (AGL-1085), kept separately from\n * `versions` because a takedown flattens that to `'all'`. Without this,\n * un-hiding a listing would silently un-revoke versions a reviewer stopped\n * for an unrelated reason.\n */\n reviewVersions?: string[]\n}\n\nexport * from './plugin-artifact-path'\n\nexport const PLUGIN_ID_PATTERN = /^[a-z][a-z0-9-]{1,63}$/\nexport const PLUGIN_VERSION_PATTERN = /^\\d+\\.\\d+\\.\\d+$/\nexport const PLUGIN_MAX_NETWORK_ORIGINS = 10\nexport const PLUGIN_MAX_PROPS = 32\n/** Label/description/default text is publisher-authored; keep it bounded. */\nconst PLUGIN_PROP_TEXT_MAX = 200\n/**\n * `mdiTimerOutline` — an icon NAME from the set the host already ships.\n *\n * Never a path: a path is arbitrary SVG from a publisher rendered into console\n * chrome. A name is a lookup, so the worst an unknown one does is render\n * nothing.\n */\nconst MDI_ICON_NAME_PATTERN = /^mdi[A-Za-z0-9]{1,48}$/\nconst PROP_SCHEMA_TYPES = new Set([\n 'string',\n 'number',\n 'boolean',\n 'color',\n 'date',\n 'url',\n 'select',\n])\nexport const PLUGIN_MAX_EVENTS = 32\nexport const PLUGIN_MAX_SIZE_PX = 4096\nconst HTTPS_ORIGIN_PATTERN = /^https:\\/\\/[a-z0-9.-]+(:\\d+)?$/i\nconst IDENTIFIER_PATTERN = /^[A-Za-z_][A-Za-z0-9_]{0,63}$/\n\n/**\n * Validates a manifest at publish time. Returns the normalized manifest or\n * a human-readable error — the publish Cloud Function refuses to store a\n * bundle whose manifest doesn't pass, so bad capabilities never reach a\n * consumer's install screen.\n */\n/**\n * Sanitizes a publisher-authored prop schema against a set of declared props.\n *\n * Shared by `capabilities.propSchema` and each element's `attributes`, so a\n * declared element cannot describe its way past the allowlist any more than a\n * top-level schema can. One implementation, one rule.\n */\nfunction sanitizePropSchemaList(\n input: unknown,\n declared: ReadonlySet<string>,\n): PluginPropSchema[] {\n if (!Array.isArray(input)) return []\n const out: PluginPropSchema[] = []\n const seen = new Set<string>()\n for (const raw of input.slice(0, PLUGIN_MAX_PROPS)) {\n if (!raw || typeof raw !== 'object') continue\n const entry = raw as Record<string, unknown>\n const name = entry['name']\n if (typeof name !== 'string' || !IDENTIFIER_PATTERN.test(name)) continue\n if (!declared.has(name) || seen.has(name)) continue\n seen.add(name)\n const type = PROP_SCHEMA_TYPES.has(String(entry['type']))\n ? (entry['type'] as PluginPropSchema['type'])\n : 'string'\n const next: PluginPropSchema = { name, type }\n for (const key of ['label', 'description'] as const) {\n const value = entry[key]\n if (typeof value === 'string' && value.trim()) {\n next[key] = value.trim().slice(0, PLUGIN_PROP_TEXT_MAX)\n }\n }\n const fallback = entry['default']\n if (\n typeof fallback === 'string' ||\n typeof fallback === 'number' ||\n typeof fallback === 'boolean'\n ) {\n next.default =\n typeof fallback === 'string'\n ? fallback.slice(0, PLUGIN_PROP_TEXT_MAX)\n : fallback\n }\n if (type === 'select' && Array.isArray(entry['options'])) {\n const options = (entry['options'] as unknown[])\n .map((option) => {\n const record = (option ?? {}) as Record<string, unknown>\n const value = record['value']\n if (typeof value !== 'string' || !value) return null\n const label = record['label']\n return {\n value: value.slice(0, PLUGIN_PROP_TEXT_MAX),\n ...(typeof label === 'string' && label.trim()\n ? { label: label.trim().slice(0, PLUGIN_PROP_TEXT_MAX) }\n : {}),\n }\n })\n .filter(Boolean) as Array<{ value: string; label?: string }>\n if (options.length) next.options = options.slice(0, PLUGIN_MAX_PROPS)\n }\n out.push(next)\n }\n return out\n}\n\nexport function validatePluginManifest(\n input: unknown,\n): { ok: true; manifest: PluginManifest } | { ok: false; error: string } {\n if (!input || typeof input !== 'object') {\n return { ok: false, error: 'Manifest must be an object' }\n }\n const raw = input as Record<string, unknown>\n const id = String(raw['id'] ?? '')\n if (!PLUGIN_ID_PATTERN.test(id)) {\n return { ok: false, error: 'Invalid plugin id' }\n }\n const version = String(raw['version'] ?? '')\n if (!PLUGIN_VERSION_PATTERN.test(version)) {\n return { ok: false, error: 'Version must be semver (e.g. 1.0.0)' }\n }\n const name = String(raw['name'] ?? '').trim()\n if (!name || name.length > 80) {\n return { ok: false, error: 'Name is required (max 80 chars)' }\n }\n const entry = String(raw['entry'] ?? '').trim()\n // Entry is a relative bundle path — absolute URLs would let a plugin\n // point the loader at an off-origin script.\n if (!entry || /^[a-z][a-z0-9+.-]*:/i.test(entry) || entry.startsWith('//')) {\n return { ok: false, error: 'Entry must be a relative bundle path' }\n }\n\n const capabilitiesInput = (raw['capabilities'] ?? {}) as Record<\n string,\n unknown\n >\n const capabilities: PluginCapabilities = {}\n\n const network = capabilitiesInput['network']\n if (network !== undefined) {\n if (!Array.isArray(network) || network.length > PLUGIN_MAX_NETWORK_ORIGINS) {\n return { ok: false, error: 'Too many network origins declared' }\n }\n for (const origin of network) {\n if (typeof origin !== 'string' || !HTTPS_ORIGIN_PATTERN.test(origin)) {\n return {\n ok: false,\n error: `Network origin \"${origin}\" must be an https origin`,\n }\n }\n }\n if (network.length) capabilities.network = [...new Set(network as string[])]\n }\n\n for (const key of ['props', 'events'] as const) {\n const list = capabilitiesInput[key]\n if (list === undefined) continue\n const max = key === 'props' ? PLUGIN_MAX_PROPS : PLUGIN_MAX_EVENTS\n if (!Array.isArray(list) || list.length > max) {\n return { ok: false, error: `Too many ${key} declared` }\n }\n for (const name of list) {\n if (typeof name !== 'string' || !IDENTIFIER_PATTERN.test(name)) {\n return { ok: false, error: `Invalid ${key} name \"${name}\"` }\n }\n }\n if (list.length) capabilities[key] = [...new Set(list as string[])]\n }\n\n /**\n * Editing metadata (AGL-1049). Sanitized, never trusted, and INTERSECTED\n * with the allowlist above — an entry naming a prop that is not declared in\n * `props` is dropped rather than rejected.\n *\n * Dropped and not rejected on purpose: a publisher who describes a prop they\n * forgot to declare has made an authoring mistake, not an attack, and\n * refusing the whole manifest for it would fail the publish over a label.\n * The prop still does not cross the bridge, because `filterPluginProps`\n * reads `props` and never this.\n *\n * An unknown `type` degrades to a text field rather than failing: a manifest\n * written against a newer platform must not make an older host refuse a\n * plugin that is otherwise fine.\n */\n const propSchemaInput = capabilitiesInput['propSchema']\n if (propSchemaInput !== undefined) {\n if (\n !Array.isArray(propSchemaInput) ||\n propSchemaInput.length > PLUGIN_MAX_PROPS\n ) {\n return { ok: false, error: 'Too many prop schemas declared' }\n }\n const propSchema = sanitizePropSchemaList(\n propSchemaInput,\n new Set(capabilities.props ?? []),\n )\n if (propSchema.length) capabilities.propSchema = propSchema\n }\n\n // Image hosts (AGL-4193): validation only here, the tenant's CSP reads it.\n const imageHosts = validatePluginImageHosts(capabilitiesInput['imageHosts'])\n if (imageHosts.ok === false) return { ok: false, error: imageHosts.error }\n if (imageHosts.value.length) capabilities.imageHosts = imageHosts.value\n\n const size = capabilitiesInput['size'] as\n | { width?: unknown; height?: unknown }\n | undefined\n if (size) {\n const width = Number(size.width ?? 0)\n const height = Number(size.height ?? 0)\n if (\n (size.width !== undefined &&\n (!Number.isFinite(width) || width < 0 || width > PLUGIN_MAX_SIZE_PX)) ||\n (size.height !== undefined &&\n (!Number.isFinite(height) ||\n height < 0 ||\n height > PLUGIN_MAX_SIZE_PX))\n ) {\n return { ok: false, error: 'Declared size is out of range' }\n }\n capabilities.size = {\n ...(size.width !== undefined ? { width } : {}),\n ...(size.height !== undefined ? { height } : {}),\n }\n }\n\n const restrict = (value: unknown): string[] | undefined => {\n if (!Array.isArray(value)) return undefined\n const ids = value.filter(\n (entry): entry is string => typeof entry === 'string' && entry.length > 0,\n )\n return ids.length ? [...new Set(ids)] : undefined\n }\n\n const hostAbiRaw = raw['hostAbi']\n let hostAbi: number | undefined\n if (hostAbiRaw !== undefined) {\n hostAbi = Number(hostAbiRaw)\n if (!Number.isInteger(hostAbi) || hostAbi < 1 || hostAbi > 99) {\n return { ok: false, error: 'hostAbi must be a small positive integer' }\n }\n }\n\n /**\n * Declared canvas elements (AGL-1031). Sanitized hard, because every field\n * here is publisher-authored data the HOST renders into its own chrome.\n *\n * A malformed `elements` array is refused — that is a build error a\n * publisher can see and fix. A single bad ENTRY is dropped instead, so one\n * typo cannot fail a whole release.\n */\n const elementsInput = raw['elements']\n const elements: PluginElementDeclaration[] = []\n if (elementsInput !== undefined) {\n if (\n !Array.isArray(elementsInput) ||\n elementsInput.length > PLUGIN_MAX_ELEMENTS\n ) {\n return { ok: false, error: 'Too many elements declared' }\n }\n const declaredProps = new Set(capabilities.props ?? [])\n const seenIds = new Set<string>()\n for (const rawElement of elementsInput) {\n if (!rawElement || typeof rawElement !== 'object') continue\n const entryRecord = rawElement as Record<string, unknown>\n const elementId = entryRecord['id']\n const elementName = entryRecord['displayName']\n if (typeof elementId !== 'string' || !IDENTIFIER_PATTERN.test(elementId)) {\n continue\n }\n if (seenIds.has(elementId)) continue\n if (typeof elementName !== 'string' || !elementName.trim()) continue\n seenIds.add(elementId)\n const element: PluginElementDeclaration = {\n id: elementId,\n displayName: elementName.trim().slice(0, PLUGIN_PROP_TEXT_MAX),\n }\n const elementDescription = entryRecord['description']\n if (typeof elementDescription === 'string' && elementDescription.trim()) {\n element.description = elementDescription\n .trim()\n .slice(0, PLUGIN_PROP_TEXT_MAX)\n }\n // A category outside the permitted subset is DROPPED, not refused: the\n // structural ones are withheld deliberately (see\n // PLUGIN_ELEMENT_CATEGORIES), and a publisher aiming at one should still\n // get a usable element rather than a failed publish.\n const elementCategory = entryRecord['category']\n if (\n typeof elementCategory === 'string' &&\n PLUGIN_ELEMENT_CATEGORIES.includes(elementCategory)\n ) {\n element.category = elementCategory\n }\n const elementIcon = entryRecord['icon']\n if (\n typeof elementIcon === 'string' &&\n MDI_ICON_NAME_PATTERN.test(elementIcon)\n ) {\n element.icon = elementIcon\n }\n const elementAttributes = sanitizePropSchemaList(\n entryRecord['attributes'],\n declaredProps,\n )\n if (elementAttributes.length) element.attributes = elementAttributes\n elements.push(element)\n }\n }\n\n /**\n * Declared contributions (AGL-3116). Refused whole when malformed rather\n * than trimmed: a loader places the plugin by this block, and an entry\n * dropped on the way in would stop it loading where it is used.\n */\n let contributes: PluginContributions | undefined\n if (raw['contributes'] !== undefined) {\n const verdict = sanitizePluginContributions(raw['contributes'])\n if (verdict.ok === false) return { ok: false, error: verdict.error }\n contributes = verdict.contributions\n }\n\n /**\n * Declared connections (AGL-4193). Refused whole when malformed, like\n * `contributes`: a connection trimmed on the way in is an OAuth flow and a\n * sync that silently do not exist.\n */\n const connectionsVerdict = validatePluginConnections(raw['connections'])\n if (connectionsVerdict.ok === false) {\n return { ok: false, error: connectionsVerdict.error }\n }\n const connections = connectionsVerdict.value\n\n /**\n * Declared settings (AGL-428). This validator rebuilds the manifest from\n * the fields it knows, and `config` was never one of them, so a publisher's\n * settings were dropped at publish and the console never drew the form the\n * docs promise. Kept now, through the SAME sanitizer the console reads the\n * pinned manifest with (`pluginConfigSchemaFromManifest`): unknown field\n * types, duplicate keys and empty selects are dropped, at most 50 fields\n * are kept, and every default is coerced to its field's type. A `config`\n * that is not an object with a `fields` list is refused, a build error the\n * publisher can see; one whose fields all drop out is left off.\n */\n let config: PluginManifest['config'] | undefined\n if (raw['config'] !== undefined) {\n const declaredConfig = raw['config'] as { fields?: unknown } | null\n if (!declaredConfig || typeof declaredConfig !== 'object' || !Array.isArray(declaredConfig.fields)) {\n return { ok: false, error: 'config must be an object with a fields list' }\n }\n const schema = pluginConfigSchemaFromManifest(id, { config: declaredConfig })\n // No `undefined` member survives: the manifest is written to Firestore\n // as is, and the Admin SDK refuses an undefined value.\n if (schema) {\n config = {\n fields: schema.fields.map(\n (field) =>\n Object.fromEntries(\n Object.entries(field).filter(([, value]) => value !== undefined),\n ) as PluginConfigField,\n ),\n defaults: schema.defaults,\n }\n }\n }\n\n return {\n ok: true,\n manifest: {\n id,\n name,\n version,\n entry,\n ...(hostAbi !== undefined ? { hostAbi } : {}),\n ...(contributes ? { contributes } : {}),\n ...(connections.length ? { connections } : {}),\n ...(config ? { config } : {}),\n ...(Object.keys(capabilities).length ? { capabilities } : {}),\n ...(elements.length ? { elements } : {}),\n ...(restrict(raw['restrictParent'])\n ? { restrictParent: restrict(raw['restrictParent']) }\n : {}),\n ...(restrict(raw['restrictChildren'])\n ? { restrictChildren: restrict(raw['restrictChildren']) }\n : {}),\n ...(typeof raw['description'] === 'string'\n ? { description: String(raw['description']).slice(0, 500) }\n : {}),\n },\n }\n}\n\n\n/**\n * The sandbox CSP is NOT built here (AGL-1092).\n *\n * A `pluginContentSecurityPolicy` used to live at this spot: exported,\n * unit-tested, and called by nothing. The policy that actually reaches a\n * browser is `csp()` in `tools/plugin-loader/origin/api/load.mjs`, on the\n * plugin-origin deployment, and the two disagreed — this one emitted\n * `connect-src 'none'` for a manifest with no network, which would have\n * broken every sandboxed load, since the frame fetches its own bundle from\n * its own origin. Deleted rather than reconciled: a tested policy nobody\n * serves is worse than none, because it answers a reader's question wrongly.\n * `capabilities.network` still decides the allowlist — the loader reads it\n * from the public listing-versions endpoint and appends it to `connect-src`,\n * with tests beside it (`npm run test:plugin-loader`).\n */\n\n/**\n * True when a pinned version is killed — the whole listing (`'all'`) or the\n * specific version. Loaders check this before executing and render a safe\n * placeholder when true (AGL-45 §3.5 kill switch).\n */\nexport function isPluginRevoked(\n revocation: PluginRevocation | null | undefined,\n version: string,\n): boolean {\n if (!revocation) return false\n if (isListingWideRevocation(revocation)) return true\n return (\n Array.isArray(revocation.versions) && revocation.versions.includes(version)\n )\n}\n\n/**\n * True when the kill switch is thrown on the WHOLE listing, not one build.\n *\n * Split out for the one caller that has no version to ask about: marketplace\n * checkout (AGL-2288) must refuse to SELL a listing the platform has switched\n * off, and it decides that before any version is chosen. Written here rather\n * than as `revocation?.versions === 'all'` at that call site for the reason\n * the doc comment on `nextRevocationState` gives — what `'all'` means is a\n * property of this document's shape, and a second reader that spelled it out\n * itself is how a kill switch silently stops killing.\n *\n * A per-version revocation is deliberately NOT listing-wide: it stops one\n * build while the rest stay installable.\n */\nexport function isListingWideRevocation(\n revocation: PluginRevocation | null | undefined,\n): boolean {\n return revocation?.versions === 'all'\n}\n\n/**\n * What a listing OFFERS a client right now (AGL-2368).\n *\n * `newestInstallableVersion` is the derivation, and it needs the version set —\n * which is server-only (`pluginVersions`). A client has the listing's\n * `latestApprovedVersion` mirror instead, and since AGL-2306 every writer of\n * that mirror computes it with `newestInstallableVersion`. So on a client the\n * mirror IS the answer, with one gap: the revocation document and the listing\n * document are two non-transactional writes, and a live listener sees them\n * land at different times. In that window the mirror names a version the kill\n * switch has already stopped, which is the whole shape of this bug.\n *\n * So a client that holds the revocation checks it against the mirror and, when\n * they disagree, offers NOTHING rather than the next-best guess. It cannot\n * compute the next-best guess — it has no version list — and \"no update to\n * offer\" is the safe reading of a mirror it has caught mid-repair. The repair\n * lands moments later and the real answer appears.\n *\n * A client with no revocation in hand passes `undefined` and gets the mirror,\n * which is what it had before. That is a real fallback, not a silent one: the\n * gap it leaves is bounded by the repair, and the install route derives live\n * and refuses regardless.\n */\nexport function offeredPluginVersion(\n listing: { latestApprovedVersion?: unknown } | null | undefined,\n revocation: PluginRevocation | null | undefined,\n): string | null {\n const offered = String(listing?.latestApprovedVersion ?? '')\n if (!offered) return null\n return isPluginRevoked(revocation, offered) ? null : offered\n}\n\n/**\n * The newest version a buyer could actually install right now (AGL-2306).\n *\n * Two things have to be true of an offer, and the listing's\n * `latestApprovedVersion` mirror only ever tracked one of them: the version\n * must be APPROVED (AGL-966 — review lives on the version) and it must not be\n * REVOKED (AGL-1085 — `install-plugin` answers 409 to a revoked pin).\n *\n * Written here rather than in the console route that repairs the mirror, and\n * rather than reusing `newestApprovedVersion` in the marketplace plugin's\n * model, because the console is `scope:app` and may not depend on\n * `aglyn:addons`. Both may import core, and \"what is on offer\" is one\n * question that must have one answer.\n *\n * `compare` is injected rather than imported so this module stays free of the\n * artifact-version comparator's own dependencies; every caller already has it.\n * A `null` comparison (an unparseable version string) sorts as \"not newer\",\n * which keeps a malformed version out of an offer rather than into one.\n *\n * Returns `null` when nothing qualifies — an ABSENT mirror reads as \"no update\n * to offer\", while a stale string reads as an update that does not exist.\n */\nexport function newestInstallableVersion(\n versions: readonly { version: string; reviewState?: unknown }[],\n revocation: PluginRevocation | null | undefined,\n compare: (a: string, b: string) => number | null,\n): string | null {\n let newest: string | null = null\n for (const entry of versions) {\n if (!entry?.version) continue\n if (entry.reviewState !== 'approved') continue\n if (isPluginRevoked(revocation, entry.version)) continue\n if (newest == null || (compare(newest, entry.version) ?? 0) < 0) {\n newest = entry.version\n }\n }\n return newest\n}\n\n/**\n * The next `revocations/{listingId}` state after one write (AGL-1085).\n *\n * Two writers share this doc and neither may erase the other:\n *\n * * a **takedown** kills the listing, flattening `versions` to `'all'`, and\n * un-hiding removes what it wrote (AGL-948);\n * * a **review** decision stops one version's bytes — the reviewer's only\n * alternative used to be a full takedown, which also revokes the version\n * customers are happily running.\n *\n * `versions` stays the single field every reader consults, so `isPluginRevoked`\n * and the loaders are untouched. `reviewVersions` is the durable record of the\n * review-owned half, which is what lets un-hiding restore rather than clear it.\n * Returns `null` when nothing is revoked any more and the doc should be\n * deleted — an empty `versions: []` would read as \"revoked nothing\" but keep a\n * doc around that a later reader has to interpret.\n *\n * Pure so both transitions are testable without Firestore, and colocated with\n * `isPluginRevoked` on purpose: a writer that disagreed with the reader about\n * this doc's shape is exactly how a kill switch silently stops killing.\n */\nexport function nextRevocationState(\n current: PluginRevocation | null | undefined,\n change:\n | { type: 'revoke-version'; version: string }\n | { type: 'unrevoke-version'; version: string }\n | { type: 'takedown' }\n | { type: 'restore' },\n): PluginRevocation | null {\n const takenDown = current?.source === 'takedown'\n // A document written before AGL-1085 — or by hand, which the rules permit\n // any staff client to do — has `versions` and NO `reviewVersions`\n // (AGL-2305). `withReview` REPLACES `versions` wholesale from this seed, so\n // reading it as an empty list silently rebuilt the document: revoking a\n // second version un-revoked the first, and un-revoking any version returned\n // `null`, which the caller turns into a DELETE of the whole kill switch.\n //\n // A legacy `versions` array is adopted as the review-owned half, which is\n // what it actually was: before AGL-1085 the only writer that produced an\n // array here was a reviewer, and `'all'` (the takedown form) is excluded\n // because that half is owned by `source` and restored by `restore`.\n const reviewVersions = [\n ...(current?.reviewVersions ??\n (Array.isArray(current?.versions) ? current.versions : [])),\n ]\n const withReview = (versions: string[], stillTakenDown: boolean) => {\n if (stillTakenDown) {\n return { ...current, versions: 'all' as const, reviewVersions: versions }\n }\n if (!versions.length) return null\n const { source: _source, ...rest } = current ?? {}\n return { ...rest, versions, reviewVersions: versions }\n }\n switch (change.type) {\n case 'revoke-version': {\n const next = reviewVersions.includes(change.version)\n ? reviewVersions\n : [...reviewVersions, change.version]\n return withReview(next, takenDown)\n }\n case 'unrevoke-version': {\n return withReview(\n reviewVersions.filter((entry) => entry !== change.version),\n takenDown,\n )\n }\n case 'takedown':\n return { ...current, versions: 'all', source: 'takedown', reviewVersions }\n case 'restore':\n // Only the takedown's own contribution goes away. A version a reviewer\n // stopped stays stopped — un-hiding is not a review decision.\n return withReview(reviewVersions, false)\n }\n}\n\n/** Methods a host-mediated plugin fetch may use (AGL-191). */\nexport const PLUGIN_FETCH_METHODS = ['GET', 'POST'] as const\nexport type PluginFetchMethod = (typeof PLUGIN_FETCH_METHODS)[number]\n/** Request/response body cap for host-mediated fetch (bytes). */\nexport const PLUGIN_FETCH_MAX_BODY_BYTES = 256 * 1024\n\n/**\n * True when `url`'s origin is an exact match against the manifest's\n * declared `network` allowlist (AGL-191). The host re-checks this before\n * proxying a plugin's `fetch-request`, so a plugin can only reach origins\n * it declared at install (and the install screen surfaced). No allowlist =\n * no host-mediated network; https-only.\n */\nexport function isPluginNetworkAllowed(\n url: string,\n capabilities: PluginCapabilities | undefined,\n): boolean {\n const allow = capabilities?.network\n if (!allow?.length) return false\n try {\n const parsed = new URL(url)\n if (parsed.protocol !== 'https:') return false\n return allow.includes(parsed.origin)\n } catch {\n return false\n }\n}\n\n// The sandboxed plugin element's id lives in `plugin-elements.ts` (AGL-4201),\n// so the mui site module can read it without loading this module.\nexport { PLUGIN_COMPONENT_ID }\n\n/** Resolved install data injected into a plugin node's props at compose. */\nexport interface ResolvedPluginInstall {\n listingId: string\n version: string\n sha256: string\n capabilities?: PluginCapabilities\n revoked?: boolean\n}\n\n/**\n * Compose-time injection (AGL-45), mirroring `attachFunctionDefinitions`:\n * a `marketplacePlugin` node carries only a `listingId` in the saved screen;\n * the tenant compose pass resolves that to the host's pinned install\n * (version/sha256/capabilities) and the kill-switch state, and stamps them\n * onto the node's props so `PluginFrame` renders without a client read.\n * Unknown/uninstalled listings leave the node untouched (it shows a safe\n * \"not installed\" placeholder rather than taking the screen down).\n */\nexport function attachPluginInstalls<T extends Record<string, any>>(\n nodes: T,\n installsByListingId: Record<string, ResolvedPluginInstall | undefined>,\n): T {\n if (!Object.keys(installsByListingId).length) return nodes\n const next: Record<string, any> = {}\n for (const [id, node] of Object.entries(nodes)) {\n const listingId =\n node?.componentId === PLUGIN_COMPONENT_ID\n ? node?.props?.listingId\n : undefined\n const install = listingId\n ? installsByListingId[String(listingId)]\n : undefined\n next[id] = install\n ? {\n ...node,\n props: {\n ...node.props,\n version: install.version,\n sha256: install.sha256,\n capabilities: install.capabilities,\n revoked: Boolean(install.revoked),\n },\n }\n : node\n }\n return next as T\n}\n\n// The editor-facing resolvers live in `plugin-elements.ts` (AGL-4201), so the\n// published page that calls them does not load this module's validators.\nexport {\n resolvePluginElements,\n resolvePluginPropFields,\n unknownPluginPropKeys,\n type PluginPaletteElement,\n type PluginPropField,\n} from './plugin-elements'\n"],"names":["pluginConfigSchemaFromManifest","sanitizePluginContributions","validatePluginConnections","validatePluginImageHosts","PLUGIN_COMPONENT_ID","PLUGIN_ELEMENT_CATEGORIES","PLUGIN_MAX_ELEMENTS","PLUGIN_ID_PATTERN","PLUGIN_VERSION_PATTERN","PLUGIN_MAX_NETWORK_ORIGINS","PLUGIN_MAX_PROPS","PLUGIN_PROP_TEXT_MAX","MDI_ICON_NAME_PATTERN","PROP_SCHEMA_TYPES","Set","PLUGIN_MAX_EVENTS","PLUGIN_MAX_SIZE_PX","HTTPS_ORIGIN_PATTERN","IDENTIFIER_PATTERN","sanitizePropSchemaList","input","declared","Array","isArray","out","seen","raw","slice","entry","name","test","has","add","type","String","next","key","value","trim","fallback","default","options","map","option","record","label","filter","Boolean","length","push","validatePluginManifest","ok","error","id","version","startsWith","capabilitiesInput","capabilities","network","undefined","origin","list","max","propSchemaInput","propSchema","props","imageHosts","size","width","Number","height","isFinite","restrict","ids","hostAbiRaw","hostAbi","isInteger","elementsInput","elements","declaredProps","seenIds","rawElement","entryRecord","elementId","elementName","element","displayName","elementDescription","description","elementCategory","includes","category","elementIcon","icon","elementAttributes","attributes","contributes","verdict","contributions","connectionsVerdict","connections","config","declaredConfig","fields","schema","field","Object","fromEntries","entries","defaults","manifest","keys","restrictParent","restrictChildren","isPluginRevoked","revocation","isListingWideRevocation","versions","offeredPluginVersion","listing","offered","latestApprovedVersion","newestInstallableVersion","compare","newest","reviewState","nextRevocationState","current","change","takenDown","source","reviewVersions","withReview","stillTakenDown","_source","rest","PLUGIN_FETCH_METHODS","PLUGIN_FETCH_MAX_BODY_BYTES","isPluginNetworkAllowed","url","allow","parsed","URL","protocol","attachPluginInstalls","nodes","installsByListingId","node","listingId","componentId","install","sha256","revoked","resolvePluginElements","resolvePluginPropFields","unknownPluginPropKeys"],"mappings":";;AAAA;;;;;;;;;;;;;;;CAeC,GAED,SACEA,8BAA8B,QAEzB,qCAAiC;AACxC,SACEC,2BAA2B,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E,QAAQ,KAAK,UAAU,OAAO;QACzC,OAAOH,MAAMlD,QAAQ,CAACmD,OAAOjF,MAAM;IACrC,EAAE,eAAM;QACN,OAAO;IACT;AACF;AAEA,8EAA8E;AAC9E,kEAAkE;AAClE,SAASxD,mBAAmB,GAAE;AAW9B;;;;;;;;CAQC,GACD,OAAO,SAAS4I,qBACdC,KAAQ,EACRC,mBAAsE;IAEtE,IAAI,CAACxC,OAAOK,IAAI,CAACmC,qBAAqBlG,MAAM,EAAE,OAAOiG;IACrD,MAAM9G,OAA4B,CAAC;IACnC,KAAK,MAAM,CAACkB,IAAI8F,KAAK,IAAIzC,OAAOE,OAAO,CAACqC,OAAQ;YAGxCE;QAFN,MAAMC,YACJD,CAAAA,wBAAAA,KAAME,WAAW,MAAKjJ,sBAClB+I,yBAAAA,cAAAA,KAAMlF,KAAK,qBAAXkF,YAAaC,SAAS,GACtBzF;QACN,MAAM2F,UAAUF,YACZF,mBAAmB,CAAChH,OAAOkH,WAAW,GACtCzF;QACJxB,IAAI,CAACkB,GAAG,GAAGiG,UACP,aACKH;YACHlF,OAAO,aACFkF,KAAKlF,KAAK;gBACbX,SAASgG,QAAQhG,OAAO;gBACxBiG,QAAQD,QAAQC,MAAM;gBACtB9F,cAAc6F,QAAQ7F,YAAY;gBAClC+F,SAASzG,QAAQuG,QAAQE,OAAO;;aAGpCL;IACN;IACA,OAAOhH;AACT;AAEA,8EAA8E;AAC9E,yEAAyE;AACzE,SACEsH,qBAAqB,EACrBC,uBAAuB,EACvBC,qBAAqB,QAGhB,uBAAmB"}
@@ -15,3 +15,19 @@
15
15
  * element waits.
16
16
  */
17
17
  export declare const RealmElementsContext: import("react").Context<(componentId: string) => Promise<void> | undefined>;
18
+ /**
19
+ * The node id of the signed marketplace element a leaf renders inside
20
+ * (AGL-3390, AGL-4195).
21
+ *
22
+ * The renderer gives each namespaced element a Suspense boundary of its own
23
+ * and provides its node id here around the element and everything it draws;
24
+ * an element nested inside another provides its own. The renderer reads it to
25
+ * know the inner render from the boundary's, and the connection record hook
26
+ * (`plugin-connection-record.ts`) reads it to know WHICH element is asking,
27
+ * so an element can only ever be handed its own plugin's record.
28
+ *
29
+ * Deliberately NOT on the realm host surface: a bundle that could provide it
30
+ * could claim to be another element. `NodeIdentityContext`, which is, says
31
+ * which node a component renders as and proves nothing about who asked.
32
+ */
33
+ export declare const RealmElementNodeContext: import("react").Context<string>;
@@ -31,5 +31,21 @@
31
31
  * element waits.
32
32
  */ export const RealmElementsContext = createContext(undefined);
33
33
  RealmElementsContext.displayName = 'RealmElementsContext';
34
+ /**
35
+ * The node id of the signed marketplace element a leaf renders inside
36
+ * (AGL-3390, AGL-4195).
37
+ *
38
+ * The renderer gives each namespaced element a Suspense boundary of its own
39
+ * and provides its node id here around the element and everything it draws;
40
+ * an element nested inside another provides its own. The renderer reads it to
41
+ * know the inner render from the boundary's, and the connection record hook
42
+ * (`plugin-connection-record.ts`) reads it to know WHICH element is asking,
43
+ * so an element can only ever be handed its own plugin's record.
44
+ *
45
+ * Deliberately NOT on the realm host surface: a bundle that could provide it
46
+ * could claim to be another element. `NodeIdentityContext`, which is, says
47
+ * which node a component renders as and proves nothing about who asked.
48
+ */ export const RealmElementNodeContext = createContext(undefined);
49
+ RealmElementNodeContext.displayName = 'RealmBoundaryContext';
34
50
 
35
51
  //# sourceMappingURL=realm-elements-context.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/realm-elements-context.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 */\nimport { createContext } from 'react'\n\n/**\n * How a namespaced element waits for the realm bundle that registers it\n * (AGL-3390).\n *\n * A signed marketplace plugin's elements render on the server, and the\n * browser has to register the same component before it can hydrate that\n * HTML. The host app answers, for a component id, the load that registers\n * it, or `undefined` when no load on this page will. The renderer suspends a\n * namespaced element on that load inside the element's own Suspense\n * boundary, so React keeps the server's HTML in place until the bundle has\n * run, and the rest of the page hydrates without waiting.\n *\n * `undefined` as a whole means the surface loads no realm bundles in the\n * render path (the Besigner loads them before its canvas mounts), and no\n * element waits.\n */\nexport const RealmElementsContext = createContext<\n ((componentId: string) => Promise<void> | undefined) | undefined\n>(undefined)\nRealmElementsContext.displayName = 'RealmElementsContext'\n"],"names":["createContext","RealmElementsContext","undefined","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD,SAASA,aAAa,QAAQ,QAAO;AAErC;;;;;;;;;;;;;;;CAeC,GACD,OAAO,MAAMC,uBAAuBD,cAElCE,WAAU;AACZD,qBAAqBE,WAAW,GAAG"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/realm-elements-context.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 */\nimport { createContext } from 'react'\n\n/**\n * How a namespaced element waits for the realm bundle that registers it\n * (AGL-3390).\n *\n * A signed marketplace plugin's elements render on the server, and the\n * browser has to register the same component before it can hydrate that\n * HTML. The host app answers, for a component id, the load that registers\n * it, or `undefined` when no load on this page will. The renderer suspends a\n * namespaced element on that load inside the element's own Suspense\n * boundary, so React keeps the server's HTML in place until the bundle has\n * run, and the rest of the page hydrates without waiting.\n *\n * `undefined` as a whole means the surface loads no realm bundles in the\n * render path (the Besigner loads them before its canvas mounts), and no\n * element waits.\n */\nexport const RealmElementsContext = createContext<\n ((componentId: string) => Promise<void> | undefined) | undefined\n>(undefined)\nRealmElementsContext.displayName = 'RealmElementsContext'\n\n/**\n * The node id of the signed marketplace element a leaf renders inside\n * (AGL-3390, AGL-4195).\n *\n * The renderer gives each namespaced element a Suspense boundary of its own\n * and provides its node id here around the element and everything it draws;\n * an element nested inside another provides its own. The renderer reads it to\n * know the inner render from the boundary's, and the connection record hook\n * (`plugin-connection-record.ts`) reads it to know WHICH element is asking,\n * so an element can only ever be handed its own plugin's record.\n *\n * Deliberately NOT on the realm host surface: a bundle that could provide it\n * could claim to be another element. `NodeIdentityContext`, which is, says\n * which node a component renders as and proves nothing about who asked.\n */\nexport const RealmElementNodeContext = createContext<string | undefined>(undefined)\nRealmElementNodeContext.displayName = 'RealmBoundaryContext'\n"],"names":["createContext","RealmElementsContext","undefined","displayName","RealmElementNodeContext"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD,SAASA,aAAa,QAAQ,QAAO;AAErC;;;;;;;;;;;;;;;CAeC,GACD,OAAO,MAAMC,uBAAuBD,cAElCE,WAAU;AACZD,qBAAqBE,WAAW,GAAG;AAEnC;;;;;;;;;;;;;;CAcC,GACD,OAAO,MAAMC,0BAA0BJ,cAAkCE,WAAU;AACnFE,wBAAwBD,WAAW,GAAG"}
@@ -94,6 +94,7 @@
94
94
  "unregisterConsoleExtension",
95
95
  "useEnabledPlugins",
96
96
  "useNodeId",
97
+ "usePluginConnectionRecord",
97
98
  "useSite",
98
99
  "useSiteFetch"
99
100
  ]),
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/realm-host-surface.generated.ts"],"sourcesContent":["/**\n * GENERATED FILE — do not edit. Regenerate with:\n * node tools/scripts/generate-realm-host-exports.mjs\n *\n * The names each realm host module holds (AGL-3392), for the bundle\n * verifier: a bundle reading any other name from the host is refused,\n * because it would read `undefined` on every site.\n */\n/* eslint-disable */\n\nexport const REALM_HOST_SURFACE_NAMES: Readonly<\n Record<'aglyn' | 'mui' | 'muiStyles', ReadonlySet<string>>\n> = {\n aglyn: new Set([\"Aglyn\",\"CATEGORY_REQUIRED_CAPABILITY\",\"COMPONENT_CATEGORY_ORDER\",\"CONSOLE_HOST_GATED_WIDGET_SLOTS\",\"CONSOLE_SEARCH_LOAD_POINT\",\"CONSOLE_STAFF_WIDGET_SLOTS\",\"CONSOLE_WIDGET_SLOTS\",\"ComponentCategory\",\"EnabledPluginsContext\",\"FEATURE_FLAG\",\"FUNCTION_BUILTIN_NAMES\",\"FUNCTION_MAX_OPERATIONS\",\"FUNCTION_TOKEN_PATTERN\",\"FieldComponentType\",\"FieldValidatorType\",\"HOST_VARIABLE_TYPE_LABELS\",\"LinealDirectiveFlag\",\"MISSING_BINDING_LABEL\",\"MUI_BUNDLE_ID\",\"NAME_TOKEN_PATTERN\",\"NodeIdentityContext\",\"NodeType\",\"PREVIEW_REFUSED_STATUS\",\"PREVIEW_WRITE_BLOCKED_EVENT\",\"REUSABLE_COMPONENT_CATEGORY\",\"REUSABLE_EMAIL_BLOCK_CATEGORY\",\"RICH_TEXT_COMMANDS\",\"ScreenLinkContext\",\"SiteContext\",\"THEME_PRESETS_LOAD_POINT\",\"VARIABLE_ID_TOKEN_PATTERN\",\"VARIABLE_NAME_PATTERN\",\"aglyn\",\"attachFunctionDefinitions\",\"bindingTokenNeedsDeep\",\"canvas\",\"components\",\"defineUiFeatureBundle\",\"displayBindingTokens\",\"editableBindingTokens\",\"emitter\",\"evaluateExpression\",\"evaluateHostFunction\",\"expressionIdentifiers\",\"expressionSyntaxError\",\"formatFunctionIdToken\",\"formatFunctionParameterOptions\",\"formatVariableIdToken\",\"formatVariableValue\",\"functionGlobals\",\"functionReferencedNames\",\"hasBindings\",\"isCategoryCapabilityEnabled\",\"isConsoleHostGatedWidgetSlot\",\"isConsoleStaffWidgetSlot\",\"isFromEnabledPlugin\",\"isPreviewRefusal\",\"isSwitchedOffForRenderedSite\",\"isVariableName\",\"keyById\",\"listConsoleExtensions\",\"listConsoleNavItems\",\"listConsoleOrgNavItems\",\"listConsoleProviders\",\"listConsolePublicPages\",\"listConsoleSearchSources\",\"listConsoleStaffPages\",\"listConsoleThemePresets\",\"listConsoleWidgets\",\"logger\",\"nodesReferenceBinding\",\"normalizeBindingTokens\",\"normalizeConsolePublicPath\",\"parseFunctionParameterOptions\",\"plugins\",\"registerConsoleExtension\",\"resolveBindings\",\"resolveConsoleOrgPluginPage\",\"resolveConsolePluginPage\",\"resolveConsolePublicPage\",\"resolveConsoleStaffPage\",\"resolveNodesBindings\",\"rewriteBindingTokensDeep\",\"textReferencesBinding\",\"unregisterConsoleExtension\",\"useEnabledPlugins\",\"useNodeId\",\"useSite\",\"useSiteFetch\"]),\n mui: new Set([\"Alert\",\"Box\",\"Button\",\"Card\",\"CardContent\",\"Checkbox\",\"Chip\",\"CircularProgress\",\"Collapse\",\"Divider\",\"FormControl\",\"FormControlLabel\",\"FormHelperText\",\"IconButton\",\"InputAdornment\",\"InputLabel\",\"Link\",\"List\",\"ListItem\",\"ListItemText\",\"MenuItem\",\"Paper\",\"Radio\",\"RadioGroup\",\"Select\",\"Stack\",\"SvgIcon\",\"Switch\",\"Table\",\"TableBody\",\"TableCell\",\"TableHead\",\"TableRow\",\"TextField\",\"Tooltip\",\"Typography\",\"createSvgIcon\",\"useMediaQuery\"]),\n muiStyles: new Set([\"alpha\",\"css\",\"darken\",\"emphasize\",\"getContrastRatio\",\"keyframes\",\"lighten\",\"styled\",\"useColorScheme\",\"useTheme\"]),\n}\n"],"names":["REALM_HOST_SURFACE_NAMES","aglyn","Set","mui","muiStyles"],"mappings":"AAAA;;;;;;;CAOC,GACD,kBAAkB,GAElB,OAAO,MAAMA,2BAET;IACFC,OAAO,IAAIC,IAAI;QAAC;QAAQ;QAA+B;QAA2B;QAAkC;QAA4B;QAA6B;QAAuB;QAAoB;QAAwB;QAAe;QAAyB;QAA0B;QAAyB;QAAqB;QAAqB;QAA4B;QAAsB;QAAwB;QAAgB;QAAqB;QAAsB;QAAW;QAAyB;QAA8B;QAA8B;QAAgC;QAAqB;QAAoB;QAAc;QAA2B;QAA4B;QAAwB;QAAQ;QAA4B;QAAwB;QAAS;QAAa;QAAwB;QAAuB;QAAwB;QAAU;QAAqB;QAAuB;QAAwB;QAAwB;QAAwB;QAAiC;QAAwB;QAAsB;QAAkB;QAA0B;QAAc;QAA8B;QAA+B;QAA2B;QAAsB;QAAmB;QAA+B;QAAiB;QAAU;QAAwB;QAAsB;QAAyB;QAAuB;QAAyB;QAA2B;QAAwB;QAA0B;QAAqB;QAAS;QAAwB;QAAyB;QAA6B;QAAgC;QAAU;QAA2B;QAAkB;QAA8B;QAA2B;QAA2B;QAA0B;QAAuB;QAA2B;QAAwB;QAA6B;QAAoB;QAAY;QAAU;KAAe;IACh/DC,KAAK,IAAID,IAAI;QAAC;QAAQ;QAAM;QAAS;QAAO;QAAc;QAAW;QAAO;QAAmB;QAAW;QAAU;QAAc;QAAmB;QAAiB;QAAa;QAAiB;QAAa;QAAO;QAAO;QAAW;QAAe;QAAW;QAAQ;QAAQ;QAAa;QAAS;QAAQ;QAAU;QAAS;QAAQ;QAAY;QAAY;QAAY;QAAW;QAAY;QAAU;QAAa;QAAgB;KAAgB;IAC/bE,WAAW,IAAIF,IAAI;QAAC;QAAQ;QAAM;QAAS;QAAY;QAAmB;QAAY;QAAU;QAAS;QAAiB;KAAW;AACvI,EAAC"}
1
+ {"version":3,"sources":["../../../../../../libs/aglyn/src/lib/app-utils/realm-host-surface.generated.ts"],"sourcesContent":["/**\n * GENERATED FILE — do not edit. Regenerate with:\n * node tools/scripts/generate-realm-host-exports.mjs\n *\n * The names each realm host module holds (AGL-3392), for the bundle\n * verifier: a bundle reading any other name from the host is refused,\n * because it would read `undefined` on every site.\n */\n/* eslint-disable */\n\nexport const REALM_HOST_SURFACE_NAMES: Readonly<\n Record<'aglyn' | 'mui' | 'muiStyles', ReadonlySet<string>>\n> = {\n aglyn: new Set([\"Aglyn\",\"CATEGORY_REQUIRED_CAPABILITY\",\"COMPONENT_CATEGORY_ORDER\",\"CONSOLE_HOST_GATED_WIDGET_SLOTS\",\"CONSOLE_SEARCH_LOAD_POINT\",\"CONSOLE_STAFF_WIDGET_SLOTS\",\"CONSOLE_WIDGET_SLOTS\",\"ComponentCategory\",\"EnabledPluginsContext\",\"FEATURE_FLAG\",\"FUNCTION_BUILTIN_NAMES\",\"FUNCTION_MAX_OPERATIONS\",\"FUNCTION_TOKEN_PATTERN\",\"FieldComponentType\",\"FieldValidatorType\",\"HOST_VARIABLE_TYPE_LABELS\",\"LinealDirectiveFlag\",\"MISSING_BINDING_LABEL\",\"MUI_BUNDLE_ID\",\"NAME_TOKEN_PATTERN\",\"NodeIdentityContext\",\"NodeType\",\"PREVIEW_REFUSED_STATUS\",\"PREVIEW_WRITE_BLOCKED_EVENT\",\"REUSABLE_COMPONENT_CATEGORY\",\"REUSABLE_EMAIL_BLOCK_CATEGORY\",\"RICH_TEXT_COMMANDS\",\"ScreenLinkContext\",\"SiteContext\",\"THEME_PRESETS_LOAD_POINT\",\"VARIABLE_ID_TOKEN_PATTERN\",\"VARIABLE_NAME_PATTERN\",\"aglyn\",\"attachFunctionDefinitions\",\"bindingTokenNeedsDeep\",\"canvas\",\"components\",\"defineUiFeatureBundle\",\"displayBindingTokens\",\"editableBindingTokens\",\"emitter\",\"evaluateExpression\",\"evaluateHostFunction\",\"expressionIdentifiers\",\"expressionSyntaxError\",\"formatFunctionIdToken\",\"formatFunctionParameterOptions\",\"formatVariableIdToken\",\"formatVariableValue\",\"functionGlobals\",\"functionReferencedNames\",\"hasBindings\",\"isCategoryCapabilityEnabled\",\"isConsoleHostGatedWidgetSlot\",\"isConsoleStaffWidgetSlot\",\"isFromEnabledPlugin\",\"isPreviewRefusal\",\"isSwitchedOffForRenderedSite\",\"isVariableName\",\"keyById\",\"listConsoleExtensions\",\"listConsoleNavItems\",\"listConsoleOrgNavItems\",\"listConsoleProviders\",\"listConsolePublicPages\",\"listConsoleSearchSources\",\"listConsoleStaffPages\",\"listConsoleThemePresets\",\"listConsoleWidgets\",\"logger\",\"nodesReferenceBinding\",\"normalizeBindingTokens\",\"normalizeConsolePublicPath\",\"parseFunctionParameterOptions\",\"plugins\",\"registerConsoleExtension\",\"resolveBindings\",\"resolveConsoleOrgPluginPage\",\"resolveConsolePluginPage\",\"resolveConsolePublicPage\",\"resolveConsoleStaffPage\",\"resolveNodesBindings\",\"rewriteBindingTokensDeep\",\"textReferencesBinding\",\"unregisterConsoleExtension\",\"useEnabledPlugins\",\"useNodeId\",\"usePluginConnectionRecord\",\"useSite\",\"useSiteFetch\"]),\n mui: new Set([\"Alert\",\"Box\",\"Button\",\"Card\",\"CardContent\",\"Checkbox\",\"Chip\",\"CircularProgress\",\"Collapse\",\"Divider\",\"FormControl\",\"FormControlLabel\",\"FormHelperText\",\"IconButton\",\"InputAdornment\",\"InputLabel\",\"Link\",\"List\",\"ListItem\",\"ListItemText\",\"MenuItem\",\"Paper\",\"Radio\",\"RadioGroup\",\"Select\",\"Stack\",\"SvgIcon\",\"Switch\",\"Table\",\"TableBody\",\"TableCell\",\"TableHead\",\"TableRow\",\"TextField\",\"Tooltip\",\"Typography\",\"createSvgIcon\",\"useMediaQuery\"]),\n muiStyles: new Set([\"alpha\",\"css\",\"darken\",\"emphasize\",\"getContrastRatio\",\"keyframes\",\"lighten\",\"styled\",\"useColorScheme\",\"useTheme\"]),\n}\n"],"names":["REALM_HOST_SURFACE_NAMES","aglyn","Set","mui","muiStyles"],"mappings":"AAAA;;;;;;;CAOC,GACD,kBAAkB,GAElB,OAAO,MAAMA,2BAET;IACFC,OAAO,IAAIC,IAAI;QAAC;QAAQ;QAA+B;QAA2B;QAAkC;QAA4B;QAA6B;QAAuB;QAAoB;QAAwB;QAAe;QAAyB;QAA0B;QAAyB;QAAqB;QAAqB;QAA4B;QAAsB;QAAwB;QAAgB;QAAqB;QAAsB;QAAW;QAAyB;QAA8B;QAA8B;QAAgC;QAAqB;QAAoB;QAAc;QAA2B;QAA4B;QAAwB;QAAQ;QAA4B;QAAwB;QAAS;QAAa;QAAwB;QAAuB;QAAwB;QAAU;QAAqB;QAAuB;QAAwB;QAAwB;QAAwB;QAAiC;QAAwB;QAAsB;QAAkB;QAA0B;QAAc;QAA8B;QAA+B;QAA2B;QAAsB;QAAmB;QAA+B;QAAiB;QAAU;QAAwB;QAAsB;QAAyB;QAAuB;QAAyB;QAA2B;QAAwB;QAA0B;QAAqB;QAAS;QAAwB;QAAyB;QAA6B;QAAgC;QAAU;QAA2B;QAAkB;QAA8B;QAA2B;QAA2B;QAA0B;QAAuB;QAA2B;QAAwB;QAA6B;QAAoB;QAAY;QAA4B;QAAU;KAAe;IAC5gEC,KAAK,IAAID,IAAI;QAAC;QAAQ;QAAM;QAAS;QAAO;QAAc;QAAW;QAAO;QAAmB;QAAW;QAAU;QAAc;QAAmB;QAAiB;QAAa;QAAiB;QAAa;QAAO;QAAO;QAAW;QAAe;QAAW;QAAQ;QAAQ;QAAa;QAAS;QAAQ;QAAU;QAAS;QAAQ;QAAY;QAAY;QAAY;QAAW;QAAY;QAAU;QAAa;QAAgB;KAAgB;IAC/bE,WAAW,IAAIF,IAAI;QAAC;QAAQ;QAAM;QAAS;QAAY;QAAmB;QAAY;QAAU;QAAS;QAAiB;KAAW;AACvI,EAAC"}
@@ -29,7 +29,7 @@ import { type PluginReleaseFlagKey } from './plugin-release-flags.generated';
29
29
  * Every release flag: the ones plugins declare (compiled from
30
30
  * plugins.config.json, AGL-3080) and the platform's own below.
31
31
  */
32
- export type ReleaseFlagKey = PluginReleaseFlagKey | 'release_addon_store' | 'release_native_checkout' | 'release_edit_bar' | 'release_assist' | 'release_video_uploads' | 'release_video_delivery' | 'release_ai_generative' | 'release_ai_site_import' | 'release_ai_site_import_generative' | 'release_crm_assist_whole_record' | 'release_ai_site_inspiration' | 'release_ad_audience_sync' | 'release_site_starters' | 'release_video_embed_posters';
32
+ export type ReleaseFlagKey = PluginReleaseFlagKey | 'release_addon_store' | 'release_native_checkout' | 'release_direct_charges' | 'release_edit_bar' | 'release_assist' | 'release_video_uploads' | 'release_video_delivery' | 'release_ai_generative' | 'release_ai_site_import' | 'release_ai_site_import_generative' | 'release_crm_assist_whole_record' | 'release_ai_site_inspiration' | 'release_ad_audience_sync' | 'release_site_starters' | 'release_video_embed_posters';
33
33
  export interface ReleaseFlagDefinition {
34
34
  key: ReleaseFlagKey;
35
35
  label: string;
@@ -61,6 +61,17 @@ export function isReleaseFlagStage(value) {
61
61
  description: 'Storefront shoppers pay on the merchant\u2019s own site: the Payment ' + 'Element, email, shipping address and method, and a live total with ' + 'tax open in place under the Buy or Checkout button, styled with the ' + 'site theme, instead of a redirect to checkout.stripe.com (AGL-1944). ' + 'Released to every workspace 2026-10-06 (AGL-3606). The webhook is ' + 'still the only thing that fulfils. Also gated on ' + 'NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY, so a deployment without one keeps ' + 'the redirect; turning this off returns every storefront to the redirect.',
62
62
  defaultEnabled: true
63
63
  },
64
+ // Off until the Terms of Service say a site's own Stripe account is the
65
+ // seller of record. On (globally or for one org by override), a store that
66
+ // sets up payments gets a full Stripe account of its own and its site sales
67
+ // become direct charges on it. Off changes nothing for an account already
68
+ // created: the account itself decides how its sales are charged.
69
+ {
70
+ key: 'release_direct_charges',
71
+ label: 'Sellers get their own Stripe account',
72
+ description: 'When a store sets up payments it gets a full Stripe account of its own ' + '(Stripe bills it, Stripe Dashboard included), and its site sales, ' + 'quotes, invoices and bookings are charged directly on that account: ' + 'the store is the seller of record, owns refunds, disputes and sales ' + 'tax, and the platform keeps only its plan take as an application fee. The ' + 'register, Tap to Pay and plugin marketplace sales stay on the ' + 'platform account. Off: new stores get the platform-managed account ' + 'and destination charges, as before. Accounts already created keep ' + 'whichever shape they were created with.',
73
+ defaultEnabled: false
74
+ },
64
75
  // Released to every site 2026-09-16 (AGL-3041). Still the whole surface's
65
76
  // kill switch, globally or for one org by override: off, the tenant slot
66
77
  // renders nothing, both token mints refuse, and `/api/edit-context` turns