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