@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
@@ -16,7 +16,7 @@
16
16
  */
17
17
  import type { PluginContributions } from '../plugin-manager/plugin-contributions';
18
18
  /** The areas the verifier reports on, in the order a reviewer reads them. */
19
- export type BundleCheckId = 'parse' | 'entry' | 'self-contained' | 'host-abi' | 'size' | 'code-execution' | 'globals' | 'storage' | 'dynamic-import' | 'network' | 'obfuscation' | 'contributions' | 'credentials';
19
+ export type BundleCheckId = 'parse' | 'entry' | 'self-contained' | 'host-abi' | 'size' | 'code-execution' | 'globals' | 'storage' | 'dynamic-import' | 'network' | 'obfuscation' | 'contributions' | 'credentials' | 'connections';
20
20
  export interface BundleCheckProblem {
21
21
  level: 'error' | 'warning';
22
22
  message: string;
@@ -88,8 +88,10 @@ export declare const MAX_PLUGIN_BUNDLE_BYTES = 1000000;
88
88
  * 7 — inputs that collect a password, card or one-time code (AGL-3362).
89
89
  * 8 — declared network origins that are a brand's lookalike (AGL-3365).
90
90
  * 9 — lookups on the host ABI name only keys a host provides (AGL-3392).
91
+ * 11 — declared connections are validated, and a bundle that calls one of
92
+ * their hosts itself is refused (AGL-4193).
91
93
  */
92
- export declare const PLUGIN_VERIFIER_VERSION = 10;
94
+ export declare const PLUGIN_VERIFIER_VERSION = 11;
93
95
  /** A verdict as stored on a `pluginVersions` doc (AGL-962). */
94
96
  export interface StoredBundleVerdict {
95
97
  ok?: boolean;
@@ -137,6 +139,16 @@ interface CheckOptions {
137
139
  * not turn them red after the fact.
138
140
  */
139
141
  requireContributions?: boolean;
142
+ /**
143
+ * The manifest's `connections` block, as the publisher wrote it (AGL-4193):
144
+ * `null` (or an empty list) when it declares none, `undefined` when no
145
+ * manifest was supplied, which leaves the row `unknown`. Validated here with
146
+ * the same function `validatePluginManifest` uses, so the local CLI refuses
147
+ * what the publish API refuses, and compared with the bundle's network
148
+ * calls: a connection's hosts are the PLATFORM's to call with the site's
149
+ * token, so a bundle that calls one itself is refused.
150
+ */
151
+ declaredConnections?: unknown;
140
152
  }
141
153
  /**
142
154
  * Run the checks over a bundle. NEVER throws (AGL-1094).
@@ -38,6 +38,7 @@ import { _ as _extends } from "@swc/helpers/_/_extends";
38
38
  // type, autocomplete token and raw HTML (AGL-3362).
39
39
  import { credentialForInputAttribute, credentialInHtml } from "@aglyn/shared-util-email/hosted-page-screen";
40
40
  import { lookalikeBrandForHost } from "@aglyn/shared-util-email/outbound-phishing-screen";
41
+ import { pluginConnectionEndpointHosts, pluginConnectionHostMatches, validatePluginConnections } from "./plugin-connections.js";
41
42
  import { PLUGIN_HOST_ABI_KEYS, PLUGIN_HOST_GLOBAL, PLUGIN_HOST_MODULE_KEYS } from "./plugin-host-abi.js";
42
43
  import { REALM_HOST_SURFACE_NAMES } from "./realm-host-surface.generated.js";
43
44
  const CHECK_LABELS = {
@@ -53,7 +54,8 @@ const CHECK_LABELS = {
53
54
  network: 'Network calls match the manifest',
54
55
  obfuscation: 'No obfuscation shapes',
55
56
  contributions: 'Registrations match the declared contributions',
56
- credentials: 'No password, card or one-time-code inputs'
57
+ credentials: 'No password, card or one-time-code inputs',
58
+ connections: 'Declared connections are well formed and never called directly'
57
59
  };
58
60
  /** Check order as displayed — findings first would reorder on every bundle. */ const CHECK_ORDER = [
59
61
  'parse',
@@ -68,7 +70,8 @@ const CHECK_LABELS = {
68
70
  'network',
69
71
  'obfuscation',
70
72
  'contributions',
71
- 'credentials'
73
+ 'credentials',
74
+ 'connections'
72
75
  ];
73
76
  export const MAX_PLUGIN_BUNDLE_BYTES = 1000000;
74
77
  /**
@@ -90,7 +93,9 @@ export const MAX_PLUGIN_BUNDLE_BYTES = 1000000;
90
93
  * 7 — inputs that collect a password, card or one-time code (AGL-3362).
91
94
  * 8 — declared network origins that are a brand's lookalike (AGL-3365).
92
95
  * 9 — lookups on the host ABI name only keys a host provides (AGL-3392).
93
- */ export const PLUGIN_VERIFIER_VERSION = 10;
96
+ * 11 — declared connections are validated, and a bundle that calls one of
97
+ * their hosts itself is refused (AGL-4193).
98
+ */ export const PLUGIN_VERIFIER_VERSION = 11;
94
99
  /**
95
100
  * Whether a stored verdict may be served instead of re-running the checks.
96
101
  *
@@ -1011,9 +1016,25 @@ function analyseBundle(source, options) {
1011
1016
  check
1012
1017
  });
1013
1018
  };
1014
- /** Mark the areas that never ran, so they cannot read as clean. */ const unknownFrom = (...ids)=>{
1015
- for (const id of ids)status.set(id, 'unknown');
1019
+ /**
1020
+ * Mark the areas that never ran, so they cannot read as clean. A row that
1021
+ * already failed keeps its failure: the connections schema is judged before
1022
+ * the bundle is parsed, and an unparseable bundle must not hide it.
1023
+ */ const unknownFrom = (...ids)=>{
1024
+ for (const id of ids)if (status.get(id) !== 'fail') status.set(id, 'unknown');
1016
1025
  };
1026
+ // Declared connections (AGL-4193): the schema first, since it needs no
1027
+ // parse; the comparison with the bundle's calls runs once they are known.
1028
+ let connections = null;
1029
+ if ((options == null ? void 0 : options.declaredConnections) !== undefined) {
1030
+ const verdict = validatePluginConnections(options.declaredConnections);
1031
+ if (verdict.ok === false) {
1032
+ add('error', 'connections', `the manifest's connections are refused: ${verdict.error}`);
1033
+ } else {
1034
+ connections = verdict.value;
1035
+ details.set('connections', connections.length ? `declares ${connections.map((connection)=>connection.id).join(', ')}` : 'declares none');
1036
+ }
1037
+ }
1017
1038
  const summarise = ()=>CHECK_ORDER.map((id)=>{
1018
1039
  var _status_get;
1019
1040
  return _extends({
@@ -1029,7 +1050,7 @@ function analyseBundle(source, options) {
1029
1050
  details.set('size', `${bytes.toLocaleString('en-US')} bytes of ${maxBytes.toLocaleString('en-US')}`);
1030
1051
  if (bytes === 0) {
1031
1052
  add('error', 'size', 'bundle is empty');
1032
- unknownFrom('parse', 'entry', 'self-contained', 'host-abi', 'code-execution', 'globals', 'storage', 'dynamic-import', 'network', 'obfuscation', 'contributions', 'credentials');
1053
+ unknownFrom('parse', 'entry', 'self-contained', 'host-abi', 'code-execution', 'globals', 'storage', 'dynamic-import', 'network', 'obfuscation', 'contributions', 'credentials', 'connections');
1033
1054
  return {
1034
1055
  ok: false,
1035
1056
  problems,
@@ -1058,7 +1079,7 @@ function analyseBundle(source, options) {
1058
1079
  // Nothing else ran, and saying so is the whole point of `unknown`: a
1059
1080
  // bundle nobody could read must not show nine green rows.
1060
1081
  add('error', 'parse', `bundle does not parse as an ES module: ${error instanceof Error ? error.message : String(error)}`);
1061
- unknownFrom('entry', 'self-contained', 'host-abi', 'code-execution', 'globals', 'storage', 'dynamic-import', 'network', 'obfuscation', 'contributions', 'credentials');
1082
+ unknownFrom('entry', 'self-contained', 'host-abi', 'code-execution', 'globals', 'storage', 'dynamic-import', 'network', 'obfuscation', 'contributions', 'credentials', 'connections');
1062
1083
  return {
1063
1084
  ok: false,
1064
1085
  problems,
@@ -1458,6 +1479,26 @@ function analyseBundle(source, options) {
1458
1479
  details.set('host-abi', abi.read.size ? `reads ${[
1459
1480
  ...abi.read
1460
1481
  ].sort().join(', ')}` : 'reads nothing by name');
1482
+ if ((options == null ? void 0 : options.declaredConnections) === undefined) {
1483
+ // No manifest: a bundle that calls nothing reaches no connection's host
1484
+ // either, which is a pass; one that calls something was not compared.
1485
+ if (networkOrigins.size || unresolvedOrigins.size || runtimeUrls) {
1486
+ status.set('connections', 'unknown');
1487
+ details.set('connections', 'no declared connections were supplied, so the calls were not compared');
1488
+ } else {
1489
+ details.set('connections', 'no network calls');
1490
+ }
1491
+ }
1492
+ compareConnections({
1493
+ connections,
1494
+ calledOrigins: [
1495
+ ...networkOrigins,
1496
+ ...unresolvedOrigins
1497
+ ],
1498
+ declaredNetwork: declared != null ? declared : [],
1499
+ add,
1500
+ details
1501
+ });
1461
1502
  const detected = detectRegistrations(program, constants);
1462
1503
  for (const message of credentialInputsIn(program, constants)){
1463
1504
  add('warning', 'credentials', message);
@@ -1474,6 +1515,40 @@ function analyseBundle(source, options) {
1474
1515
  contributions: detected
1475
1516
  };
1476
1517
  }
1518
+ /**
1519
+ * A connection's hosts are the platform's (AGL-4193). The platform calls them
1520
+ * with the site's token; the plugin's own code never holds one, so a bundle
1521
+ * that calls a connection's API, token or authorization host itself — or
1522
+ * declares one under `capabilities.network`, which is the same reach — is
1523
+ * trying to do in the browser what the declaration exists to keep on the
1524
+ * server. Refused, with the host named.
1525
+ */ function compareConnections(input) {
1526
+ const { connections } = input;
1527
+ if (!(connections == null ? void 0 : connections.length)) return;
1528
+ const hostOf = (origin)=>{
1529
+ try {
1530
+ return new URL(origin).hostname.toLowerCase();
1531
+ } catch (unused) {
1532
+ return null;
1533
+ }
1534
+ };
1535
+ const owner = (host)=>connections.find((connection)=>connection.apiHosts.some((pattern)=>pluginConnectionHostMatches(pattern, host)) || pluginConnectionEndpointHosts(connection).includes(host));
1536
+ const flagged = new Set();
1537
+ for (const origin of input.calledOrigins){
1538
+ const host = hostOf(origin);
1539
+ const connection = host ? owner(host) : undefined;
1540
+ if (!host || !connection || flagged.has(host)) continue;
1541
+ flagged.add(host);
1542
+ input.add('error', 'connections', `the bundle calls ${origin}, a host of the declared connection "${connection.id}" — ` + 'the platform makes those calls with the site’s token, and plugin code never can');
1543
+ }
1544
+ for (const origin of input.declaredNetwork){
1545
+ const host = hostOf(origin);
1546
+ const connection = host ? owner(host) : undefined;
1547
+ if (!host || !connection || flagged.has(host)) continue;
1548
+ flagged.add(host);
1549
+ input.add('error', 'connections', `capabilities.network declares ${origin}, a host of the declared connection "${connection.id}" — ` + 'remove it: the platform calls that host, the plugin never does');
1550
+ }
1551
+ }
1477
1552
  /**
1478
1553
  * Run the checks over a bundle. NEVER throws (AGL-1094).
1479
1554
  *