@kya-os/consent 0.3.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (226) hide show
  1. package/README.md +185 -20
  2. package/dist/bundle/index.d.ts +4 -0
  3. package/dist/bundle/index.d.ts.map +1 -1
  4. package/dist/bundle/index.js +6 -0
  5. package/dist/bundle/index.js.map +1 -1
  6. package/dist/bundle/inline.d.ts.map +1 -1
  7. package/dist/bundle/inline.js +4 -4
  8. package/dist/bundle/inline.js.map +1 -1
  9. package/dist/cjs/bundle/index.js +15 -1
  10. package/dist/cjs/bundle/index.js.map +1 -1
  11. package/dist/cjs/bundle/inline.js +4 -4
  12. package/dist/cjs/bundle/inline.js.map +1 -1
  13. package/dist/cjs/components/consent-action-bar.js +97 -25
  14. package/dist/cjs/components/consent-action-bar.js.map +1 -1
  15. package/dist/cjs/components/consent-agent-header.js +7 -105
  16. package/dist/cjs/components/consent-agent-header.js.map +1 -1
  17. package/dist/cjs/components/consent-button.js +6 -1
  18. package/dist/cjs/components/consent-button.js.map +1 -1
  19. package/dist/cjs/components/consent-capabilities-screen.js +488 -66
  20. package/dist/cjs/components/consent-capabilities-screen.js.map +1 -1
  21. package/dist/cjs/components/consent-capability-card.js +197 -42
  22. package/dist/cjs/components/consent-capability-card.js.map +1 -1
  23. package/dist/cjs/components/consent-checkbox.js +7 -0
  24. package/dist/cjs/components/consent-checkbox.js.map +1 -1
  25. package/dist/cjs/components/consent-connector-header.js +206 -43
  26. package/dist/cjs/components/consent-connector-header.js.map +1 -1
  27. package/dist/cjs/components/consent-duration.js +1 -1
  28. package/dist/cjs/components/consent-footer.js +13 -12
  29. package/dist/cjs/components/consent-footer.js.map +1 -1
  30. package/dist/cjs/components/consent-headline.js +445 -30
  31. package/dist/cjs/components/consent-headline.js.map +1 -1
  32. package/dist/cjs/components/consent-oauth-button.js +71 -62
  33. package/dist/cjs/components/consent-oauth-button.js.map +1 -1
  34. package/dist/cjs/components/consent-otp-input.js +5 -0
  35. package/dist/cjs/components/consent-otp-input.js.map +1 -1
  36. package/dist/cjs/components/consent-phone-handoff.js +3 -3
  37. package/dist/cjs/components/consent-request-expiry.js +1 -1
  38. package/dist/cjs/components/consent-revocation-notice.js +4 -2
  39. package/dist/cjs/components/consent-revocation-notice.js.map +1 -1
  40. package/dist/cjs/components/consent-revoke.js +9 -4
  41. package/dist/cjs/components/consent-revoke.js.map +1 -1
  42. package/dist/cjs/components/consent-secured-by.js +106 -0
  43. package/dist/cjs/components/consent-secured-by.js.map +1 -0
  44. package/dist/cjs/components/consent-shell.js +1 -1
  45. package/dist/cjs/components/consent-terms.js +7 -0
  46. package/dist/cjs/components/consent-terms.js.map +1 -1
  47. package/dist/cjs/components/consent-wallet-check.js +1 -1
  48. package/dist/cjs/components/consent-wallet-notice.js +1 -1
  49. package/dist/cjs/components/consent-wallet-orb.js +1 -1
  50. package/dist/cjs/components/consent-wallet-signature.js +1 -1
  51. package/dist/cjs/components/decision-icons.js +33 -0
  52. package/dist/cjs/components/decision-icons.js.map +1 -0
  53. package/dist/cjs/components/edit-region.js +309 -0
  54. package/dist/cjs/components/edit-region.js.map +1 -0
  55. package/dist/cjs/components/grant-field-styles.js +2 -2
  56. package/dist/cjs/components/index.js +5 -1
  57. package/dist/cjs/components/index.js.map +1 -1
  58. package/dist/cjs/components/mcp-consent.js +81 -36
  59. package/dist/cjs/components/mcp-consent.js.map +1 -1
  60. package/dist/cjs/components/preview.js +67 -0
  61. package/dist/cjs/components/preview.js.map +1 -0
  62. package/dist/cjs/constants/capabilities.js +21 -2
  63. package/dist/cjs/constants/capabilities.js.map +1 -1
  64. package/dist/cjs/copy/tokens.js +60 -21
  65. package/dist/cjs/copy/tokens.js.map +1 -1
  66. package/dist/cjs/identity/agent-identity.js +3 -2
  67. package/dist/cjs/identity/agent-identity.js.map +1 -1
  68. package/dist/cjs/mcp-app/inline.js +2 -2
  69. package/dist/cjs/mcp-app/inline.js.map +1 -1
  70. package/dist/cjs/react/index.js +11 -2
  71. package/dist/cjs/react/index.js.map +1 -1
  72. package/dist/cjs/styles/brand.js +385 -0
  73. package/dist/cjs/styles/brand.js.map +1 -0
  74. package/dist/cjs/styles/index.js +1 -0
  75. package/dist/cjs/styles/index.js.map +1 -1
  76. package/dist/cjs/styles/theme.js +100 -30
  77. package/dist/cjs/styles/theme.js.map +1 -1
  78. package/dist/cjs/types/capabilities.types.js +1 -2
  79. package/dist/cjs/types/capabilities.types.js.map +1 -1
  80. package/dist/cjs/types/decision.types.js +13 -0
  81. package/dist/cjs/types/decision.types.js.map +1 -0
  82. package/dist/cjs/types/edit.types.js +80 -0
  83. package/dist/cjs/types/edit.types.js.map +1 -0
  84. package/dist/cjs/types/index.js +2 -0
  85. package/dist/cjs/types/index.js.map +1 -1
  86. package/dist/components/consent-action-bar.d.ts +20 -1
  87. package/dist/components/consent-action-bar.d.ts.map +1 -1
  88. package/dist/components/consent-action-bar.js +97 -25
  89. package/dist/components/consent-action-bar.js.map +1 -1
  90. package/dist/components/consent-agent-header.d.ts +4 -17
  91. package/dist/components/consent-agent-header.d.ts.map +1 -1
  92. package/dist/components/consent-agent-header.js +7 -105
  93. package/dist/components/consent-agent-header.js.map +1 -1
  94. package/dist/components/consent-button.d.ts +2 -0
  95. package/dist/components/consent-button.d.ts.map +1 -1
  96. package/dist/components/consent-button.js +6 -1
  97. package/dist/components/consent-button.js.map +1 -1
  98. package/dist/components/consent-capabilities-screen.d.ts +93 -14
  99. package/dist/components/consent-capabilities-screen.d.ts.map +1 -1
  100. package/dist/components/consent-capabilities-screen.js +488 -67
  101. package/dist/components/consent-capabilities-screen.js.map +1 -1
  102. package/dist/components/consent-capability-card.d.ts +42 -5
  103. package/dist/components/consent-capability-card.d.ts.map +1 -1
  104. package/dist/components/consent-capability-card.js +196 -41
  105. package/dist/components/consent-capability-card.js.map +1 -1
  106. package/dist/components/consent-checkbox.d.ts +2 -0
  107. package/dist/components/consent-checkbox.d.ts.map +1 -1
  108. package/dist/components/consent-checkbox.js +7 -0
  109. package/dist/components/consent-checkbox.js.map +1 -1
  110. package/dist/components/consent-connector-header.d.ts +39 -7
  111. package/dist/components/consent-connector-header.d.ts.map +1 -1
  112. package/dist/components/consent-connector-header.js +206 -43
  113. package/dist/components/consent-connector-header.js.map +1 -1
  114. package/dist/components/consent-duration.js +1 -1
  115. package/dist/components/consent-footer.d.ts +6 -4
  116. package/dist/components/consent-footer.d.ts.map +1 -1
  117. package/dist/components/consent-footer.js +13 -12
  118. package/dist/components/consent-footer.js.map +1 -1
  119. package/dist/components/consent-headline.d.ts +76 -12
  120. package/dist/components/consent-headline.d.ts.map +1 -1
  121. package/dist/components/consent-headline.js +445 -32
  122. package/dist/components/consent-headline.js.map +1 -1
  123. package/dist/components/consent-oauth-button.d.ts +7 -3
  124. package/dist/components/consent-oauth-button.d.ts.map +1 -1
  125. package/dist/components/consent-oauth-button.js +74 -65
  126. package/dist/components/consent-oauth-button.js.map +1 -1
  127. package/dist/components/consent-otp-input.d.ts.map +1 -1
  128. package/dist/components/consent-otp-input.js +5 -0
  129. package/dist/components/consent-otp-input.js.map +1 -1
  130. package/dist/components/consent-passkey.d.ts +6 -0
  131. package/dist/components/consent-passkey.d.ts.map +1 -1
  132. package/dist/components/consent-passkey.js +67 -9
  133. package/dist/components/consent-passkey.js.map +1 -1
  134. package/dist/components/consent-phone-handoff.js +3 -3
  135. package/dist/components/consent-request-expiry.js +1 -1
  136. package/dist/components/consent-revocation-notice.d.ts.map +1 -1
  137. package/dist/components/consent-revocation-notice.js +4 -2
  138. package/dist/components/consent-revocation-notice.js.map +1 -1
  139. package/dist/components/consent-revoke.d.ts +2 -0
  140. package/dist/components/consent-revoke.d.ts.map +1 -1
  141. package/dist/components/consent-revoke.js +9 -4
  142. package/dist/components/consent-revoke.js.map +1 -1
  143. package/dist/components/consent-secured-by.d.ts +25 -0
  144. package/dist/components/consent-secured-by.d.ts.map +1 -0
  145. package/dist/components/consent-secured-by.js +103 -0
  146. package/dist/components/consent-secured-by.js.map +1 -0
  147. package/dist/components/consent-shell.js +1 -1
  148. package/dist/components/consent-terms.d.ts +2 -0
  149. package/dist/components/consent-terms.d.ts.map +1 -1
  150. package/dist/components/consent-terms.js +7 -0
  151. package/dist/components/consent-terms.js.map +1 -1
  152. package/dist/components/consent-wallet-check.js +1 -1
  153. package/dist/components/consent-wallet-notice.js +1 -1
  154. package/dist/components/consent-wallet-orb.js +1 -1
  155. package/dist/components/consent-wallet-signature.js +1 -1
  156. package/dist/components/decision-icons.d.ts +22 -0
  157. package/dist/components/decision-icons.d.ts.map +1 -0
  158. package/dist/components/decision-icons.js +30 -0
  159. package/dist/components/decision-icons.js.map +1 -0
  160. package/dist/components/edit-region.d.ts +50 -0
  161. package/dist/components/edit-region.d.ts.map +1 -0
  162. package/dist/components/edit-region.js +305 -0
  163. package/dist/components/edit-region.js.map +1 -0
  164. package/dist/components/grant-field-styles.js +2 -2
  165. package/dist/components/index.d.ts +3 -2
  166. package/dist/components/index.d.ts.map +1 -1
  167. package/dist/components/index.js +3 -2
  168. package/dist/components/index.js.map +1 -1
  169. package/dist/components/mcp-consent.d.ts +15 -0
  170. package/dist/components/mcp-consent.d.ts.map +1 -1
  171. package/dist/components/mcp-consent.js +81 -36
  172. package/dist/components/mcp-consent.js.map +1 -1
  173. package/dist/components/preview.d.ts +38 -0
  174. package/dist/components/preview.d.ts.map +1 -0
  175. package/dist/components/preview.js +61 -0
  176. package/dist/components/preview.js.map +1 -0
  177. package/dist/consent.js +2200 -389
  178. package/dist/consent.min.js +1308 -496
  179. package/dist/constants/capabilities.d.ts +14 -2
  180. package/dist/constants/capabilities.d.ts.map +1 -1
  181. package/dist/constants/capabilities.js +21 -2
  182. package/dist/constants/capabilities.js.map +1 -1
  183. package/dist/copy/tokens.d.ts +60 -21
  184. package/dist/copy/tokens.d.ts.map +1 -1
  185. package/dist/copy/tokens.js +60 -21
  186. package/dist/copy/tokens.js.map +1 -1
  187. package/dist/identity/agent-identity.d.ts +3 -2
  188. package/dist/identity/agent-identity.d.ts.map +1 -1
  189. package/dist/identity/agent-identity.js +3 -2
  190. package/dist/identity/agent-identity.js.map +1 -1
  191. package/dist/mcp-app/inline.d.ts.map +1 -1
  192. package/dist/mcp-app/inline.js +2 -2
  193. package/dist/mcp-app/inline.js.map +1 -1
  194. package/dist/react/index.d.ts +6 -1
  195. package/dist/react/index.d.ts.map +1 -1
  196. package/dist/react/index.js +10 -1
  197. package/dist/react/index.js.map +1 -1
  198. package/dist/styles/brand.d.ts +184 -0
  199. package/dist/styles/brand.d.ts.map +1 -0
  200. package/dist/styles/brand.js +372 -0
  201. package/dist/styles/brand.js.map +1 -0
  202. package/dist/styles/index.d.ts +1 -0
  203. package/dist/styles/index.d.ts.map +1 -1
  204. package/dist/styles/index.js +1 -0
  205. package/dist/styles/index.js.map +1 -1
  206. package/dist/styles/theme.d.ts +73 -13
  207. package/dist/styles/theme.d.ts.map +1 -1
  208. package/dist/styles/theme.js +96 -29
  209. package/dist/styles/theme.js.map +1 -1
  210. package/dist/types/capabilities.types.d.ts +12 -14
  211. package/dist/types/capabilities.types.d.ts.map +1 -1
  212. package/dist/types/capabilities.types.js +1 -2
  213. package/dist/types/capabilities.types.js.map +1 -1
  214. package/dist/types/decision.types.d.ts +57 -0
  215. package/dist/types/decision.types.d.ts.map +1 -0
  216. package/dist/types/decision.types.js +12 -0
  217. package/dist/types/decision.types.js.map +1 -0
  218. package/dist/types/edit.types.d.ts +73 -0
  219. package/dist/types/edit.types.d.ts.map +1 -0
  220. package/dist/types/edit.types.js +76 -0
  221. package/dist/types/edit.types.js.map +1 -0
  222. package/dist/types/index.d.ts +2 -0
  223. package/dist/types/index.d.ts.map +1 -1
  224. package/dist/types/index.js +2 -0
  225. package/dist/types/index.js.map +1 -1
  226. package/package.json +2 -2
@@ -2,11 +2,13 @@
2
2
  /**
3
3
  * Consent Capabilities Screen
4
4
  *
5
- * The composite layout from Peter's mockup: eyebrow + serif headline +
6
- * subhead (consent-headline, its parts exported) + agent identity tile +
7
- * capability rows + revocation notice + action bar + footer. Used when the resolved consent config includes
8
- * `capabilities` (the new humanized layout). Falls back to the legacy
9
- * permissions list otherwise.
5
+ * The consent decision page, as Checkpoint draws it: the connector above a
6
+ * card holding the eyebrow, the serif headline that names the agent (its name
7
+ * opens what is known about it), a warning when the agent registered itself,
8
+ * who is signing in (`approver`), the permission rows, the "Permission
9
+ * details" box (`grantDetails`, else the revocation notice) and Allow and
10
+ * Deny; under the card, "Secured by" and the Vouched lockup, and the host's
11
+ * legal links. Used when the resolved consent config includes `capabilities`.
10
12
  *
11
13
  * This component is purely presentational. It accepts the resolved data
12
14
  * (capabilities, agent metadata, copy values) and emits `capabilities-allow` /
@@ -14,6 +16,23 @@
14
16
  * window. Selection state for the checkboxes is owned here to keep the
15
17
  * parent simple.
16
18
  *
19
+ * Each row's parts are forwarded with a `capability-` prefix
20
+ * (`capability-row`, `capability-label` and so on, see
21
+ * CAPABILITY_ROW_EXPORT_PARTS). The other parts are `connector`, `card`,
22
+ * `eyebrow`, `headline`, `agent-name`, `host`, `subhead`, `agent-details`,
23
+ * `unverified`, `approver`, `permissions`, `grant-details`, `actions`,
24
+ * `submit`, `cancel` and `below`. A host puts content in a row by giving it
25
+ * `slot="capability-<capability id>"`, words the headline itself through the
26
+ * `headline` slot, replaces the lockup through `footer` and adds its legal
27
+ * links through `legal`.
28
+ *
29
+ * With `preview` the screen draws as it would live and acts on nothing: it
30
+ * sends no `capabilities-allow` or `capabilities-deny`, and no link inside it
31
+ * goes anywhere; rows still tick. With `editable` as well, the subhead, the
32
+ * organization's name (in "Connects to"), each row's label and description
33
+ * and both button labels are regions a person types into (see
34
+ * `CONSENT_EDIT_KEYS`), and the rows stop toggling.
35
+ *
17
36
  * @module components/consent-capabilities-screen
18
37
  */
19
38
  var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
@@ -23,7 +42,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
23
42
  return c > 3 && r && Object.defineProperty(target, key, r), r;
24
43
  };
25
44
  Object.defineProperty(exports, "__esModule", { value: true });
26
- exports.ConsentCapabilitiesScreen = void 0;
45
+ exports.ConsentCapabilitiesScreen = exports.CAPABILITY_ROW_EXPORT_PARTS = void 0;
46
+ exports.capabilitySlotName = capabilitySlotName;
27
47
  const lit_1 = require("lit");
28
48
  const decorators_js_1 = require("lit/decorators.js");
29
49
  const tokens_js_1 = require("../copy/tokens.js");
@@ -33,15 +53,39 @@ const agent_identity_js_1 = require("../identity/agent-identity.js");
33
53
  const compile_js_1 = require("../cedar/compile.js");
34
54
  const credential_capabilities_js_1 = require("../resolution/credential-capabilities.js");
35
55
  const capabilities_js_1 = require("../constants/capabilities.js");
36
- require("./consent-agent-header.js");
37
- require("./consent-headline.js");
38
- require("./consent-capability-card.js");
56
+ const edit_types_js_1 = require("../types/edit.types.js");
57
+ const resolve_branding_js_1 = require("../resolution/resolve-branding.js");
58
+ const edit_region_js_1 = require("./edit-region.js");
59
+ const decision_icons_js_1 = require("./decision-icons.js");
60
+ const preview_js_1 = require("./preview.js");
61
+ const consent_headline_js_1 = require("./consent-headline.js");
62
+ const consent_capability_card_js_1 = require("./consent-capability-card.js");
39
63
  require("./consent-action-bar.js");
40
- require("./consent-footer.js");
64
+ require("./consent-secured-by.js");
41
65
  require("./consent-revocation-notice.js");
42
66
  require("./consent-connector-header.js");
43
67
  const consent_grant_terms_js_1 = require("./consent-grant-terms.js");
44
68
  const terms_js_1 = require("../grant/terms.js");
69
+ /** Each row part the screen forwards, as `<row part>: capability-<row part>`. */
70
+ exports.CAPABILITY_ROW_EXPORT_PARTS = consent_capability_card_js_1.CAPABILITY_ROW_PARTS.map((part) => `${part}: capability-${part}`).join(", ");
71
+ /** The screen slot whose content shows inside the row for `capabilityId`. */
72
+ function capabilitySlotName(capabilityId) {
73
+ return `${capabilities_js_1.CONSENT_CAPABILITIES_FEATURES.capabilitySlotPrefix}${capabilityId}`;
74
+ }
75
+ /**
76
+ * Whether a `capability-toggle` reached the rows through a row's slot, so came
77
+ * from the host's content there and not from a row: that content cannot tick or
78
+ * untick any row. Only the path below the listener counts, so a screen that is
79
+ * itself slotted somewhere is not mistaken for slotted content.
80
+ */
81
+ function cameThroughARowSlot(event) {
82
+ const path = event.composedPath();
83
+ const listener = event.currentTarget ? path.indexOf(event.currentTarget) : -1;
84
+ return path
85
+ .slice(0, listener === -1 ? path.length : listener)
86
+ .some((node) => node instanceof HTMLSlotElement &&
87
+ node.name.startsWith(capabilities_js_1.CONSENT_CAPABILITIES_FEATURES.capabilitySlotPrefix));
88
+ }
45
89
  let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends lit_1.LitElement {
46
90
  constructor() {
47
91
  super();
@@ -56,8 +100,11 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends lit_1.Li
56
100
  this.loading = false;
57
101
  /** Blocks approval while allowing the human to decline. */
58
102
  this.disabled = false;
103
+ /** The subhead. Empty draws none. */
59
104
  this.description = "";
60
105
  this.submitLabel = "";
106
+ /** Draw each row's icon tile. */
107
+ this.showIcons = false;
61
108
  this.cancelLabel = "";
62
109
  /**
63
110
  * Seed every capability as selected. The credential path grants a fixed,
@@ -89,9 +136,29 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends lit_1.Li
89
136
  * reach this screen the same way it reaches the other consent screens.
90
137
  */
91
138
  this.serverLogoUrl = "";
139
+ /**
140
+ * The connector's bridge: `bridge` (default), dashed lines and a shield in
141
+ * the page's tint, or `dots`. Forwarded to the connector header.
142
+ */
143
+ this.connectorVariant = "bridge";
144
+ /**
145
+ * Who carries the connection, such as the host's product name: read out as
146
+ * "{agent} is connecting to {org} via {via}" and shown on the connector's
147
+ * shield. Empty: the connector names only the agent and the org.
148
+ */
149
+ this.via = "";
92
150
  /** Fixed grants require every disclosed capability to remain selected. */
93
151
  this.requireAll = false;
152
+ /**
153
+ * Draws as it would live and acts on nothing: no decision event, no link
154
+ * followed. Every part inside gets it.
155
+ */
156
+ this.preview = false;
157
+ /** With `preview`: the screen's words can be edited in place. */
158
+ this.editable = false;
94
159
  this.selected = new Set();
160
+ /** Whether the host filled the `legal` slot. */
161
+ this.hasLegal = false;
95
162
  /**
96
163
  * Last capability set this component seeded `selected` from, per
97
164
  * `capabilitySeedKey`. Re-seeding is keyed on this value rather than on
@@ -101,6 +168,8 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends lit_1.Li
101
168
  this.onCapabilityToggle = (event) => {
102
169
  if (this.loading || this.disabled || !(event instanceof CustomEvent))
103
170
  return;
171
+ if (cameThroughARowSlot(event))
172
+ return;
104
173
  const detail = event.detail;
105
174
  if (!detail ||
106
175
  typeof detail !== "object" ||
@@ -118,7 +187,7 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends lit_1.Li
118
187
  this.selected = next;
119
188
  };
120
189
  this.onAllow = () => {
121
- if (this.loading || this.approvalDisabled)
190
+ if (this.preview || this.loading || this.approvalDisabled)
122
191
  return;
123
192
  const selectedCapabilities = this.capabilities.filter((c) => this.selected.has(c.id));
124
193
  if (selectedCapabilities.length === 0)
@@ -140,15 +209,21 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends lit_1.Li
140
209
  }));
141
210
  };
142
211
  this.onDeny = () => {
143
- if (this.loading)
212
+ if (this.preview || this.loading)
144
213
  return;
145
214
  this.dispatchEvent(new CustomEvent("capabilities-deny", { bubbles: true, composed: true }));
146
215
  };
216
+ this.readLegalSlot = (event) => {
217
+ this.hasLegal =
218
+ event.target.assignedNodes({ flatten: true })
219
+ .length > 0;
220
+ };
147
221
  // Grant terms in the `details` slot can turn Allow off and on.
148
222
  const refresh = () => this.requestUpdate();
149
223
  this.addEventListener("consent-grant-terms-change", refresh);
150
224
  for (const type of consent_grant_terms_js_1.GRANT_FIELD_EVENTS)
151
225
  this.addEventListener(type, refresh);
226
+ (0, preview_js_1.guardPreviewNavigation)(this);
152
227
  }
153
228
  connectedCallback() {
154
229
  super.connectedCallback();
@@ -158,6 +233,7 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends lit_1.Li
158
233
  if (changed.has("capabilities") || changed.has("allSelected")) {
159
234
  this.seedDefaults();
160
235
  }
236
+ (0, preview_js_1.warnIfEditableWithoutPreview)(this);
161
237
  }
162
238
  /**
163
239
  * Seed `selected` from the capability defaults, but only when the
@@ -174,8 +250,12 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends lit_1.Li
174
250
  this.seedKey = key;
175
251
  this.selected = new Set((0, credential_capabilities_js_1.capabilityIdsFor)(this.capabilities, this.allSelected));
176
252
  }
253
+ /**
254
+ * The theme, as values the page can override: a `--cs-*` property set on
255
+ * this element or on any ancestor wins over the theme's own.
256
+ */
177
257
  hostStyle() {
178
- return `:host { ${(0, theme_js_1.themeToCssVariables)((0, theme_js_1.getConsentTheme)(this.theme))} }`;
258
+ return (0, theme_js_1.themeScopeStyle)((0, theme_js_1.getConsentTheme)(this.theme), ".card, consent-connector-header, .below");
179
259
  }
180
260
  /** Grant terms in the `details` slot. None when rendered without a DOM. */
181
261
  get slottedTerms() {
@@ -218,12 +298,10 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends lit_1.Li
218
298
  }
219
299
  }
220
300
  render() {
221
- const tokens = tokens_js_1.CONSENT_COPY_TOKENS;
222
301
  const agent = this.resolveAgent();
302
+ // Only an editable preview passes editable on, so no part warns on its own.
303
+ const editing = (0, preview_js_1.isEditing)(this);
223
304
  const agentName = agent?.name || "this agent";
224
- const sectionHeader = (0, tokens_js_1.formatToken)(tokens.section.capabilitiesHeader, {
225
- Agent: agentName.toUpperCase(),
226
- });
227
305
  return (0, lit_1.html) `
228
306
  <style>
229
307
  ${this.hostStyle()}
@@ -237,35 +315,27 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends lit_1.Li
237
315
  server-logo-url="${this.serverLogoUrl}"
238
316
  server-domain="${this.serverDomain}"
239
317
  logo-dev-token="${this.logoDevToken}"
318
+ variant=${this.connectorVariant}
319
+ via=${this.via}
240
320
  ></consent-connector-header>
241
321
  <div class="card" part="card">
242
322
  <consent-headline
243
- exportparts="eyebrow, headline, subhead"
323
+ exportparts="eyebrow, headline, agent-name, host, subhead, agent-details"
244
324
  agent-name="${agent?.name ?? ""}"
245
- org-name="${this.orgName}"
325
+ .agent=${agent}
246
326
  verb="${this.headlineVerb}"
247
327
  description="${this.description}"
328
+ ?preview=${this.preview}
329
+ ?editable=${editing}
330
+ .editSource=${this.editSource}
331
+ ><slot name="headline" slot="headline"></slot
248
332
  ></consent-headline>
249
333
  <slot name="recovery"></slot>
334
+ ${this.renderUnverified(agent)}
250
335
  <slot name="identity"></slot>
251
- ${agent
252
- ? (0, lit_1.html) `<consent-agent-header
253
- part="agent"
254
- agentName="${agent.name}"
255
- vendor="${agent.vendor || ""}"
256
- surfaceLabel="${agent.surfaceLabel || ""}"
257
- verification="${(0, capabilities_types_js_1.agentVerification)(agent)}"
258
- domain="${agent.domain || ""}"
259
- logoUrl="${agent.logoUrl || ""}"
260
- connectedAt="${agent.connectedAt || ""}"
261
- ></consent-agent-header>`
262
- : lit_1.nothing}
336
+ ${this.renderApprover()}
263
337
  <slot name="agent-key"></slot>
264
338
  <div part="permissions">
265
- <div class="section-header">
266
- <span>${sectionHeader}</span>
267
- <span class="hint">${tokens.section.tapToToggle}</span>
268
- </div>
269
339
  <div class="rows" @capability-toggle=${this.onCapabilityToggle}>
270
340
  ${this.capabilities.map((capability) => (0, lit_1.html) `
271
341
  <consent-capability-card
@@ -276,23 +346,35 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends lit_1.Li
276
346
  riskLevel="${capability.riskLevel}"
277
347
  ?checked=${this.selected.has(capability.id)}
278
348
  ?disabled=${this.loading || this.disabled}
349
+ ?show-icon=${this.showIcons}
279
350
  .scopes=${capability.scopes}
280
351
  compiled-cedar="${this.compileCapabilityCedar(capability)}"
352
+ ?preview=${this.preview}
353
+ ?editable=${editing}
354
+ .editSource=${this.editSource}
355
+ exportparts=${exports.CAPABILITY_ROW_EXPORT_PARTS}
356
+ ><slot
357
+ name=${capabilitySlotName(capability.id)}
358
+ slot="extra"
359
+ ></slot
281
360
  ></consent-capability-card>
282
361
  `)}
283
362
  </div>
284
363
  </div>
285
364
  <slot name="auth"></slot>
286
365
  <slot name="details"></slot>
366
+ ${this.renderGrantDetails(editing)}
287
367
  <slot name="notice"
288
- ><consent-revocation-notice
289
- revocationPath="${this.revocationPath}"
290
- orgName="${this.orgName || "this site"}"
291
- inactivityDays=${this.inactivityDays}
292
- ?fixed-expiry=${this.fixedExpiry}
293
- fixed-expiry-days=${this.fixedExpiryDays ?? lit_1.nothing}
294
- ></consent-revocation-notice
295
- ></slot>
368
+ >${this.grantDetails
369
+ ? lit_1.nothing
370
+ : (0, lit_1.html) `<consent-revocation-notice
371
+ revocationPath="${this.revocationPath}"
372
+ orgName="${this.orgName || "this site"}"
373
+ inactivityDays=${this.inactivityDays}
374
+ ?fixed-expiry=${this.fixedExpiry}
375
+ fixed-expiry-days=${this.fixedExpiryDays ?? lit_1.nothing}
376
+ ></consent-revocation-notice>`}</slot
377
+ >
296
378
  <consent-action-bar
297
379
  part="actions"
298
380
  agentName="${agentName}"
@@ -301,28 +383,153 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends lit_1.Li
301
383
  ?disabled=${this.approvalDisabled}
302
384
  submit-label=${this.submitLabel}
303
385
  cancel-label=${this.cancelLabel}
386
+ ?preview=${this.preview}
387
+ ?editable=${editing}
388
+ .editSource=${this.editSource}
304
389
  exportparts="submit, cancel"
305
390
  @consent-allow=${this.onAllow}
306
391
  @consent-deny=${this.onDeny}
307
392
  ></consent-action-bar>
308
- <slot name="footer"
309
- ><consent-footer
310
- theme="${this.theme}"
311
- howItWorksUrl="${this.howItWorksUrl}"
312
- ></consent-footer
313
- ></slot>
393
+ </div>
394
+ <div class="below" part="below">
395
+ <slot name="footer"><consent-secured-by></consent-secured-by></slot>
396
+ ${this.renderLegal()}
314
397
  </div>
315
398
  `;
316
399
  }
400
+ /** The warning for an agent that registered itself: its name is not checked. */
401
+ renderUnverified(agent) {
402
+ if (!agent || (0, capabilities_types_js_1.agentVerification)(agent) !== "unverified")
403
+ return lit_1.nothing;
404
+ const copy = tokens_js_1.CONSENT_COPY_TOKENS;
405
+ return (0, lit_1.html) `<div class="unverified" part="unverified">
406
+ <p class="unverified-heading">
407
+ ${(0, decision_icons_js_1.decisionIcon)("warning")}${copy.unverifiedAgent.heading}
408
+ </p>
409
+ <p class="unverified-body">
410
+ ${copy.agentDetails.unverifiedExplanation}
411
+ ${copy.unverifiedAgent.advice}
412
+ </p>
413
+ </div>`;
414
+ }
415
+ /** Who is signing in, and the checks they passed; nothing when there is neither. */
416
+ renderApprover() {
417
+ const identifier = this.approver?.identifier?.trim() ?? "";
418
+ const checks = (this.approver?.checks ?? []).filter((check) => check.label.trim());
419
+ if (!identifier && checks.length === 0)
420
+ return lit_1.nothing;
421
+ return (0, lit_1.html) `<div class="approver tinted" part="approver">
422
+ ${identifier
423
+ ? (0, lit_1.html) `<div class="signed-in">
424
+ <span class="avatar" aria-hidden="true"
425
+ >${(0, consent_headline_js_1.initialOf)(identifier)}</span
426
+ >
427
+ <span class="who">
428
+ <span class="small"
429
+ >${tokens_js_1.CONSENT_COPY_TOKENS.approver.signedIn}</span
430
+ >
431
+ <span class="identifier">${identifier}</span>
432
+ </span>
433
+ </div>`
434
+ : lit_1.nothing}
435
+ ${checks.map((check, index) => (0, lit_1.html) `<div class="check${identifier || index > 0 ? " ruled" : ""}">
436
+ <span class="check-icon">${(0, decision_icons_js_1.decisionIcon)("check")}</span>
437
+ <span class="who">
438
+ <span class="strong">${check.label}</span>
439
+ ${check.summary ? (0, lit_1.html) `<span>${check.summary}</span>` : lit_1.nothing}
440
+ ${check.source
441
+ ? (0, lit_1.html) `<span class="small">${check.source}</span>`
442
+ : lit_1.nothing}
443
+ </span>
444
+ </div>`)}
445
+ </div>`;
446
+ }
447
+ /** The "Permission details" box, when the host gives `grantDetails`. */
448
+ renderGrantDetails(editing) {
449
+ const details = this.grantDetails;
450
+ if (!details)
451
+ return lit_1.nothing;
452
+ const copy = tokens_js_1.CONSENT_COPY_TOKENS.grantDetails;
453
+ const org = this.orgName.trim();
454
+ const resource = details.resource?.trim() ?? "";
455
+ const orgValue = editing
456
+ ? (0, edit_region_js_1.editRegion)(edit_types_js_1.CONSENT_EDIT_KEYS.orgName, tokens_js_1.CONSENT_COPY_TOKENS.editRegions.orgName, org, this.editSource)
457
+ : org;
458
+ const rows = [];
459
+ if (org || resource || editing) {
460
+ rows.push({
461
+ icon: "resource",
462
+ label: copy.connectsTo,
463
+ values: org || editing ? [orgValue] : [resource],
464
+ ...(resource && (org || editing) ? { note: resource } : {}),
465
+ });
466
+ }
467
+ const fact = (icon, label, given) => {
468
+ const values = (given?.values ?? []).filter((value) => value.trim());
469
+ const note = given?.note?.trim();
470
+ if (values.length > 0 || note) {
471
+ rows.push({ icon, label, values, ...(note ? { note } : {}) });
472
+ }
473
+ };
474
+ fact("duration", copy.duration, details.duration);
475
+ if (details.budget?.trim()) {
476
+ rows.push({
477
+ icon: "budget",
478
+ label: copy.budget,
479
+ values: [details.budget.trim()],
480
+ });
481
+ }
482
+ fact("amountLimits", copy.amountLimits, details.amountLimits);
483
+ fact("alreadyGranted", copy.alreadyGranted, details.alreadyGranted);
484
+ if (rows.length === 0)
485
+ return lit_1.nothing;
486
+ return (0, lit_1.html) `<section
487
+ class="grant-details tinted"
488
+ part="grant-details"
489
+ aria-labelledby="grant-details-heading"
490
+ >
491
+ <h2 id="grant-details-heading">${copy.heading}</h2>
492
+ <dl>
493
+ ${rows.map((row) => (0, lit_1.html) `<div class="fact">
494
+ <span class="fact-icon">${(0, decision_icons_js_1.decisionIcon)(row.icon)}</span>
495
+ <div class="fact-text">
496
+ <dt class="small">${row.label}</dt>
497
+ ${row.values.map((value) => (0, lit_1.html) `<dd class="value">${value}</dd>`)}
498
+ ${row.note
499
+ ? (0, lit_1.html) `<dd class="note small">${row.note}</dd>`
500
+ : lit_1.nothing}
501
+ </div>
502
+ </div>`)}
503
+ </dl>
504
+ </section>`;
505
+ }
506
+ /**
507
+ * The host's legal links, or a "How does this work?" link when the host
508
+ * gives its address; nothing when there is neither.
509
+ */
510
+ renderLegal() {
511
+ const howItWorks = (0, resolve_branding_js_1.sanitizeLinkUrl)(this.howItWorksUrl);
512
+ return (0, lit_1.html) `<div class="legal" ?hidden=${!this.hasLegal && !howItWorks}>
513
+ <slot name="legal" @slotchange=${this.readLegalSlot}
514
+ >${howItWorks
515
+ ? (0, lit_1.html) `<a href=${howItWorks} target="_blank" rel="noopener noreferrer"
516
+ >${tokens_js_1.CONSENT_COPY_TOKENS.attribution.howThisWorks}</a
517
+ >`
518
+ : lit_1.nothing}</slot
519
+ >
520
+ </div>`;
521
+ }
317
522
  };
318
523
  exports.ConsentCapabilitiesScreen = ConsentCapabilitiesScreen;
319
524
  ConsentCapabilitiesScreen.features = capabilities_js_1.CONSENT_CAPABILITIES_FEATURES;
320
525
  ConsentCapabilitiesScreen.styles = (0, lit_1.css) `
526
+ ${edit_region_js_1.editRegionStyles}
527
+
321
528
  :host {
322
529
  display: block;
323
530
  box-sizing: border-box;
324
531
  width: 100%;
325
- max-width: var(--cs-screen-max-width, 560px);
532
+ max-width: var(--cs-screen-max-width, 576px);
326
533
  margin: 0 auto;
327
534
  }
328
535
 
@@ -330,43 +537,231 @@ ConsentCapabilitiesScreen.styles = (0, lit_1.css) `
330
537
  min-width: 0;
331
538
  background: var(--cs-surface-card);
332
539
  border: 1px solid var(--cs-surface-border);
333
- border-radius: 22px;
540
+ border-radius: var(--cs-card-radius, 12px);
334
541
  box-shadow: var(--cs-card-shadow);
335
- padding: var(--cs-card-padding, 28px 28px 22px);
542
+ padding: var(--cs-card-padding, 28px 28px 24px);
336
543
  display: flex;
337
544
  flex-direction: column;
338
545
  gap: var(--cs-card-gap, 22px);
339
546
  color: var(--cs-text-primary);
340
547
  }
341
548
 
342
- .section-header {
549
+ .rows {
550
+ display: flex;
551
+ flex-direction: column;
552
+ }
553
+
554
+ svg {
555
+ flex-shrink: 0;
556
+ }
557
+
558
+ .unverified {
559
+ display: flex;
560
+ flex-direction: column;
561
+ gap: 2px;
562
+ margin-top: 12px;
563
+ font-size: 14px;
564
+ line-height: 1.45;
565
+ }
566
+
567
+ .unverified p {
568
+ margin: 0;
569
+ }
570
+
571
+ .unverified-heading {
343
572
  display: flex;
344
573
  align-items: center;
345
- justify-content: space-between;
346
- font-size: 11px;
347
- letter-spacing: 0.14em;
574
+ gap: 6px;
575
+ font-weight: 500;
576
+ color: var(--cs-warning-text, #8c4a00);
577
+ }
578
+
579
+ .unverified-heading svg {
580
+ width: 16px;
581
+ height: 16px;
582
+ }
583
+
584
+ .unverified-body {
585
+ color: var(--cs-text-secondary);
586
+ }
587
+
588
+ .tinted {
589
+ border-radius: 12px;
590
+ border: 1px solid var(--cs-tint-line);
591
+ background: var(--cs-tint);
592
+ }
593
+
594
+ .approver {
595
+ margin-top: 16px;
596
+ padding: 12px 16px;
597
+ font-size: 14px;
598
+ line-height: 1.45;
599
+ }
600
+
601
+ .signed-in,
602
+ .check {
603
+ display: flex;
604
+ align-items: center;
605
+ gap: 12px;
606
+ }
607
+
608
+ .check {
609
+ align-items: flex-start;
610
+ }
611
+
612
+ .ruled {
613
+ margin-top: 12px;
614
+ padding-top: 12px;
615
+ border-top: 1px solid var(--cs-tint-line);
616
+ }
617
+
618
+ .avatar,
619
+ .check-icon {
620
+ display: grid;
621
+ place-items: center;
622
+ width: 40px;
623
+ height: 40px;
624
+ flex-shrink: 0;
625
+ }
626
+
627
+ .avatar {
628
+ border-radius: 50%;
629
+ background: var(--cs-surface-accent);
630
+ color: var(--cs-surface-accent-text);
348
631
  font-weight: 600;
632
+ }
633
+
634
+ .check-icon {
635
+ color: var(--cs-mark);
636
+ }
637
+
638
+ .check-icon svg {
639
+ width: 20px;
640
+ height: 20px;
641
+ }
642
+
643
+ .who {
644
+ display: flex;
645
+ flex-direction: column;
646
+ gap: 2px;
647
+ min-width: 0;
648
+ }
649
+
650
+ .identifier {
651
+ font-weight: 500;
652
+ overflow: hidden;
653
+ text-overflow: ellipsis;
654
+ white-space: nowrap;
655
+ }
656
+
657
+ .small {
658
+ font-size: 12px;
349
659
  color: var(--cs-text-tertiary);
350
- text-transform: uppercase;
660
+ }
661
+
662
+ .strong {
663
+ font-weight: 500;
664
+ }
665
+
666
+ .grant-details {
667
+ margin-top: 16px;
668
+ padding: 16px;
669
+ font-size: 14px;
670
+ line-height: 1.45;
671
+ }
672
+
673
+ .grant-details h2 {
674
+ margin: 0 0 12px;
675
+ font-size: 14px;
676
+ font-weight: 600;
677
+ }
678
+
679
+ .grant-details dl {
680
+ display: flex;
681
+ flex-direction: column;
351
682
  gap: 12px;
352
- flex-wrap: wrap;
683
+ margin: 0;
353
684
  }
354
685
 
355
- .section-header .hint {
356
- letter-spacing: 0;
357
- font-weight: 400;
358
- text-transform: none;
359
- font-size: 12px;
686
+ .fact {
687
+ display: flex;
688
+ align-items: flex-start;
689
+ gap: 12px;
360
690
  }
361
691
 
362
- .rows {
692
+ .fact-icon {
693
+ display: grid;
694
+ place-items: center;
695
+ width: 32px;
696
+ height: 32px;
697
+ flex-shrink: 0;
698
+ border-radius: 6px;
699
+ border: 1px solid var(--cs-surface-border);
700
+ background: var(--cs-surface-card);
701
+ color: var(--cs-mark);
702
+ }
703
+
704
+ .fact-icon svg {
705
+ width: 16px;
706
+ height: 16px;
707
+ }
708
+
709
+ .fact-text {
363
710
  display: flex;
711
+ flex: 1;
364
712
  flex-direction: column;
713
+ gap: 2px;
714
+ min-width: 0;
365
715
  }
366
716
 
367
- @media (max-width: 480px) {
717
+ .fact dd {
718
+ margin: 0;
719
+ }
720
+
721
+ .fact .value {
722
+ font-weight: 500;
723
+ overflow-wrap: anywhere;
724
+ }
725
+
726
+ .fact .note {
727
+ overflow-wrap: break-word;
728
+ }
729
+
730
+ .below {
731
+ display: flex;
732
+ flex-direction: column;
733
+ align-items: center;
734
+ margin-top: 16px;
735
+ color: var(--cs-text-tertiary);
736
+ }
737
+
738
+ .legal {
739
+ display: flex;
740
+ justify-content: center;
741
+ gap: 20px;
742
+ padding-top: 48px;
743
+ font-size: 12px;
744
+ }
745
+
746
+ .legal a {
747
+ color: inherit;
748
+ text-decoration: underline;
749
+ text-underline-offset: 2px;
750
+ border-radius: 2px;
751
+ }
752
+
753
+ .legal a:hover {
754
+ color: var(--cs-text-primary);
755
+ }
756
+
757
+ .legal a:focus-visible {
758
+ outline: 2px solid var(--cs-focus-ring);
759
+ outline-offset: 2px;
760
+ }
761
+
762
+ @media (max-width: 640px) {
368
763
  .card {
369
- padding: var(--cs-card-padding-mobile, 20px 18px);
764
+ padding: var(--cs-card-padding-mobile, 20px 20px 24px);
370
765
  }
371
766
  }
372
767
  `;
@@ -418,6 +813,15 @@ __decorate([
418
813
  __decorate([
419
814
  (0, decorators_js_1.property)({ type: String, attribute: "submit-label" })
420
815
  ], ConsentCapabilitiesScreen.prototype, "submitLabel", void 0);
816
+ __decorate([
817
+ (0, decorators_js_1.property)({ attribute: false })
818
+ ], ConsentCapabilitiesScreen.prototype, "approver", void 0);
819
+ __decorate([
820
+ (0, decorators_js_1.property)({ attribute: false })
821
+ ], ConsentCapabilitiesScreen.prototype, "grantDetails", void 0);
822
+ __decorate([
823
+ (0, decorators_js_1.property)({ type: Boolean, attribute: "show-icons" })
824
+ ], ConsentCapabilitiesScreen.prototype, "showIcons", void 0);
421
825
  __decorate([
422
826
  (0, decorators_js_1.property)({ type: String, attribute: "cancel-label" })
423
827
  ], ConsentCapabilitiesScreen.prototype, "cancelLabel", void 0);
@@ -436,12 +840,30 @@ __decorate([
436
840
  __decorate([
437
841
  (0, decorators_js_1.property)({ type: String, attribute: "server-logo-url" })
438
842
  ], ConsentCapabilitiesScreen.prototype, "serverLogoUrl", void 0);
843
+ __decorate([
844
+ (0, decorators_js_1.property)({ type: String, attribute: "connector-variant" })
845
+ ], ConsentCapabilitiesScreen.prototype, "connectorVariant", void 0);
846
+ __decorate([
847
+ (0, decorators_js_1.property)({ type: String })
848
+ ], ConsentCapabilitiesScreen.prototype, "via", void 0);
439
849
  __decorate([
440
850
  (0, decorators_js_1.property)({ type: Boolean, attribute: "require-all" })
441
851
  ], ConsentCapabilitiesScreen.prototype, "requireAll", void 0);
852
+ __decorate([
853
+ (0, decorators_js_1.property)({ type: Boolean, reflect: true })
854
+ ], ConsentCapabilitiesScreen.prototype, "preview", void 0);
855
+ __decorate([
856
+ (0, decorators_js_1.property)({ type: Boolean, reflect: true })
857
+ ], ConsentCapabilitiesScreen.prototype, "editable", void 0);
858
+ __decorate([
859
+ (0, decorators_js_1.property)({ attribute: false })
860
+ ], ConsentCapabilitiesScreen.prototype, "editSource", void 0);
442
861
  __decorate([
443
862
  (0, decorators_js_1.state)()
444
863
  ], ConsentCapabilitiesScreen.prototype, "selected", void 0);
864
+ __decorate([
865
+ (0, decorators_js_1.state)()
866
+ ], ConsentCapabilitiesScreen.prototype, "hasLegal", void 0);
445
867
  exports.ConsentCapabilitiesScreen = ConsentCapabilitiesScreen = __decorate([
446
868
  (0, decorators_js_1.customElement)("consent-capabilities-screen")
447
869
  ], ConsentCapabilitiesScreen);