@kya-os/consent 0.4.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 +182 -22
  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 +454 -68
  20. package/dist/cjs/components/consent-capabilities-screen.js.map +1 -1
  21. package/dist/cjs/components/consent-capability-card.js +131 -27
  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 +399 -33
  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 +4 -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 +12 -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 +85 -17
  99. package/dist/components/consent-capabilities-screen.d.ts.map +1 -1
  100. package/dist/components/consent-capabilities-screen.js +456 -70
  101. package/dist/components/consent-capabilities-screen.js.map +1 -1
  102. package/dist/components/consent-capability-card.d.ts +23 -3
  103. package/dist/components/consent-capability-card.d.ts.map +1 -1
  104. package/dist/components/consent-capability-card.js +131 -27
  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 +55 -16
  120. package/dist/components/consent-headline.d.ts.map +1 -1
  121. package/dist/components/consent-headline.js +398 -34
  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 +2 -1
  166. package/dist/components/index.d.ts.map +1 -1
  167. package/dist/components/index.js +2 -1
  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 +2104 -389
  178. package/dist/consent.min.js +1289 -497
  179. package/dist/constants/capabilities.d.ts +12 -3
  180. package/dist/constants/capabilities.d.ts.map +1 -1
  181. package/dist/constants/capabilities.js +12 -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` /
@@ -15,10 +17,20 @@
15
17
  *
16
18
  * Each row's parts are forwarded with a `capability-` prefix
17
19
  * (`capability-row`, `capability-label` and so on, see
18
- * CAPABILITY_ROW_EXPORT_PARTS), and the header above the rows is the
19
- * `section-header` part. A host puts content in a row by giving it
20
- * `slot="capability-<capability id>"`, and words the headline itself through
21
- * the `headline` slot.
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.
22
34
  *
23
35
  * @module components/consent-capabilities-screen
24
36
  */
@@ -30,18 +42,22 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
30
42
  };
31
43
  import { LitElement, html, css, nothing } from "lit";
32
44
  import { customElement, property, state } from "lit/decorators.js";
33
- import { CONSENT_COPY_TOKENS, formatToken } from "../copy/tokens.js";
34
- import { getConsentTheme, themeToCssVariables } from "../styles/theme.js";
45
+ import { CONSENT_COPY_TOKENS } from "../copy/tokens.js";
46
+ import { getConsentTheme, themeScopeStyle } from "../styles/theme.js";
35
47
  import { agentVerification, } from "../types/capabilities.types.js";
36
48
  import { agentMetadataFromIdentity, } from "../identity/agent-identity.js";
37
49
  import { compileSingleCapability } from "../cedar/compile.js";
38
50
  import { capabilityIdsFor, capabilitySeedKey, } from "../resolution/credential-capabilities.js";
39
51
  import { CONSENT_CAPABILITIES_FEATURES } from "../constants/capabilities.js";
40
- import "./consent-agent-header.js";
41
- import "./consent-headline.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";
42
58
  import { CAPABILITY_ROW_PARTS } from "./consent-capability-card.js";
43
59
  import "./consent-action-bar.js";
44
- import "./consent-footer.js";
60
+ import "./consent-secured-by.js";
45
61
  import "./consent-revocation-notice.js";
46
62
  import "./consent-connector-header.js";
47
63
  import { GRANT_FIELD_EVENTS } from "./consent-grant-terms.js";
@@ -80,8 +96,11 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends LitEleme
80
96
  this.loading = false;
81
97
  /** Blocks approval while allowing the human to decline. */
82
98
  this.disabled = false;
99
+ /** The subhead. Empty draws none. */
83
100
  this.description = "";
84
101
  this.submitLabel = "";
102
+ /** Draw each row's icon tile. */
103
+ this.showIcons = false;
85
104
  this.cancelLabel = "";
86
105
  /**
87
106
  * Seed every capability as selected. The credential path grants a fixed,
@@ -113,9 +132,29 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends LitEleme
113
132
  * reach this screen the same way it reaches the other consent screens.
114
133
  */
115
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 = "";
116
146
  /** Fixed grants require every disclosed capability to remain selected. */
117
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;
118
155
  this.selected = new Set();
156
+ /** Whether the host filled the `legal` slot. */
157
+ this.hasLegal = false;
119
158
  /**
120
159
  * Last capability set this component seeded `selected` from, per
121
160
  * `capabilitySeedKey`. Re-seeding is keyed on this value rather than on
@@ -144,7 +183,7 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends LitEleme
144
183
  this.selected = next;
145
184
  };
146
185
  this.onAllow = () => {
147
- if (this.loading || this.approvalDisabled)
186
+ if (this.preview || this.loading || this.approvalDisabled)
148
187
  return;
149
188
  const selectedCapabilities = this.capabilities.filter((c) => this.selected.has(c.id));
150
189
  if (selectedCapabilities.length === 0)
@@ -166,15 +205,21 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends LitEleme
166
205
  }));
167
206
  };
168
207
  this.onDeny = () => {
169
- if (this.loading)
208
+ if (this.preview || this.loading)
170
209
  return;
171
210
  this.dispatchEvent(new CustomEvent("capabilities-deny", { bubbles: true, composed: true }));
172
211
  };
212
+ this.readLegalSlot = (event) => {
213
+ this.hasLegal =
214
+ event.target.assignedNodes({ flatten: true })
215
+ .length > 0;
216
+ };
173
217
  // Grant terms in the `details` slot can turn Allow off and on.
174
218
  const refresh = () => this.requestUpdate();
175
219
  this.addEventListener("consent-grant-terms-change", refresh);
176
220
  for (const type of GRANT_FIELD_EVENTS)
177
221
  this.addEventListener(type, refresh);
222
+ guardPreviewNavigation(this);
178
223
  }
179
224
  connectedCallback() {
180
225
  super.connectedCallback();
@@ -184,6 +229,7 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends LitEleme
184
229
  if (changed.has("capabilities") || changed.has("allSelected")) {
185
230
  this.seedDefaults();
186
231
  }
232
+ warnIfEditableWithoutPreview(this);
187
233
  }
188
234
  /**
189
235
  * Seed `selected` from the capability defaults, but only when the
@@ -200,8 +246,12 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends LitEleme
200
246
  this.seedKey = key;
201
247
  this.selected = new Set(capabilityIdsFor(this.capabilities, this.allSelected));
202
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
+ */
203
253
  hostStyle() {
204
- return `:host { ${themeToCssVariables(getConsentTheme(this.theme))} }`;
254
+ return themeScopeStyle(getConsentTheme(this.theme), ".card, consent-connector-header, .below");
205
255
  }
206
256
  /** Grant terms in the `details` slot. None when rendered without a DOM. */
207
257
  get slottedTerms() {
@@ -244,12 +294,10 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends LitEleme
244
294
  }
245
295
  }
246
296
  render() {
247
- const tokens = CONSENT_COPY_TOKENS;
248
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);
249
300
  const agentName = agent?.name || "this agent";
250
- const sectionHeader = formatToken(tokens.section.capabilitiesHeader, {
251
- Agent: agentName.toUpperCase(),
252
- });
253
301
  return html `
254
302
  <style>
255
303
  ${this.hostStyle()}
@@ -263,36 +311,27 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends LitEleme
263
311
  server-logo-url="${this.serverLogoUrl}"
264
312
  server-domain="${this.serverDomain}"
265
313
  logo-dev-token="${this.logoDevToken}"
314
+ variant=${this.connectorVariant}
315
+ via=${this.via}
266
316
  ></consent-connector-header>
267
317
  <div class="card" part="card">
268
318
  <consent-headline
269
- exportparts="eyebrow, headline, subhead"
319
+ exportparts="eyebrow, headline, agent-name, host, subhead, agent-details"
270
320
  agent-name="${agent?.name ?? ""}"
271
- org-name="${this.orgName}"
321
+ .agent=${agent}
272
322
  verb="${this.headlineVerb}"
273
323
  description="${this.description}"
324
+ ?preview=${this.preview}
325
+ ?editable=${editing}
326
+ .editSource=${this.editSource}
274
327
  ><slot name="headline" slot="headline"></slot
275
328
  ></consent-headline>
276
329
  <slot name="recovery"></slot>
330
+ ${this.renderUnverified(agent)}
277
331
  <slot name="identity"></slot>
278
- ${agent
279
- ? html `<consent-agent-header
280
- part="agent"
281
- agentName="${agent.name}"
282
- vendor="${agent.vendor || ""}"
283
- surfaceLabel="${agent.surfaceLabel || ""}"
284
- verification="${agentVerification(agent)}"
285
- domain="${agent.domain || ""}"
286
- logoUrl="${agent.logoUrl || ""}"
287
- connectedAt="${agent.connectedAt || ""}"
288
- ></consent-agent-header>`
289
- : nothing}
332
+ ${this.renderApprover()}
290
333
  <slot name="agent-key"></slot>
291
334
  <div part="permissions">
292
- <div class="section-header" part="section-header">
293
- <span>${sectionHeader}</span>
294
- <span class="hint">${tokens.section.tapToToggle}</span>
295
- </div>
296
335
  <div class="rows" @capability-toggle=${this.onCapabilityToggle}>
297
336
  ${this.capabilities.map((capability) => html `
298
337
  <consent-capability-card
@@ -303,8 +342,12 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends LitEleme
303
342
  riskLevel="${capability.riskLevel}"
304
343
  ?checked=${this.selected.has(capability.id)}
305
344
  ?disabled=${this.loading || this.disabled}
345
+ ?show-icon=${this.showIcons}
306
346
  .scopes=${capability.scopes}
307
347
  compiled-cedar="${this.compileCapabilityCedar(capability)}"
348
+ ?preview=${this.preview}
349
+ ?editable=${editing}
350
+ .editSource=${this.editSource}
308
351
  exportparts=${CAPABILITY_ROW_EXPORT_PARTS}
309
352
  ><slot
310
353
  name=${capabilitySlotName(capability.id)}
@@ -316,15 +359,18 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends LitEleme
316
359
  </div>
317
360
  <slot name="auth"></slot>
318
361
  <slot name="details"></slot>
362
+ ${this.renderGrantDetails(editing)}
319
363
  <slot name="notice"
320
- ><consent-revocation-notice
321
- revocationPath="${this.revocationPath}"
322
- orgName="${this.orgName || "this site"}"
323
- inactivityDays=${this.inactivityDays}
324
- ?fixed-expiry=${this.fixedExpiry}
325
- fixed-expiry-days=${this.fixedExpiryDays ?? nothing}
326
- ></consent-revocation-notice
327
- ></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
+ >
328
374
  <consent-action-bar
329
375
  part="actions"
330
376
  agentName="${agentName}"
@@ -333,27 +379,152 @@ let ConsentCapabilitiesScreen = class ConsentCapabilitiesScreen extends LitEleme
333
379
  ?disabled=${this.approvalDisabled}
334
380
  submit-label=${this.submitLabel}
335
381
  cancel-label=${this.cancelLabel}
382
+ ?preview=${this.preview}
383
+ ?editable=${editing}
384
+ .editSource=${this.editSource}
336
385
  exportparts="submit, cancel"
337
386
  @consent-allow=${this.onAllow}
338
387
  @consent-deny=${this.onDeny}
339
388
  ></consent-action-bar>
340
- <slot name="footer"
341
- ><consent-footer
342
- theme="${this.theme}"
343
- howItWorksUrl="${this.howItWorksUrl}"
344
- ></consent-footer
345
- ></slot>
389
+ </div>
390
+ <div class="below" part="below">
391
+ <slot name="footer"><consent-secured-by></consent-secured-by></slot>
392
+ ${this.renderLegal()}
346
393
  </div>
347
394
  `;
348
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
+ }
349
518
  };
350
519
  ConsentCapabilitiesScreen.features = CONSENT_CAPABILITIES_FEATURES;
351
520
  ConsentCapabilitiesScreen.styles = css `
521
+ ${editRegionStyles}
522
+
352
523
  :host {
353
524
  display: block;
354
525
  box-sizing: border-box;
355
526
  width: 100%;
356
- max-width: var(--cs-screen-max-width, 560px);
527
+ max-width: var(--cs-screen-max-width, 576px);
357
528
  margin: 0 auto;
358
529
  }
359
530
 
@@ -361,43 +532,231 @@ ConsentCapabilitiesScreen.styles = css `
361
532
  min-width: 0;
362
533
  background: var(--cs-surface-card);
363
534
  border: 1px solid var(--cs-surface-border);
364
- border-radius: 22px;
535
+ border-radius: var(--cs-card-radius, 12px);
365
536
  box-shadow: var(--cs-card-shadow);
366
- padding: var(--cs-card-padding, 28px 28px 22px);
537
+ padding: var(--cs-card-padding, 28px 28px 24px);
367
538
  display: flex;
368
539
  flex-direction: column;
369
540
  gap: var(--cs-card-gap, 22px);
370
541
  color: var(--cs-text-primary);
371
542
  }
372
543
 
373
- .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 {
567
+ display: flex;
568
+ align-items: center;
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 {
374
598
  display: flex;
375
599
  align-items: center;
376
- justify-content: space-between;
377
- font-size: 11px;
378
- letter-spacing: 0.14em;
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);
379
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;
380
654
  color: var(--cs-text-tertiary);
381
- 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;
382
677
  gap: 12px;
383
- flex-wrap: wrap;
678
+ margin: 0;
384
679
  }
385
680
 
386
- .section-header .hint {
387
- letter-spacing: 0;
388
- font-weight: 400;
389
- text-transform: none;
390
- font-size: 12px;
681
+ .fact {
682
+ display: flex;
683
+ align-items: flex-start;
684
+ gap: 12px;
391
685
  }
392
686
 
393
- .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 {
394
705
  display: flex;
706
+ flex: 1;
395
707
  flex-direction: column;
708
+ gap: 2px;
709
+ min-width: 0;
710
+ }
711
+
712
+ .fact dd {
713
+ margin: 0;
396
714
  }
397
715
 
398
- @media (max-width: 480px) {
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) {
399
758
  .card {
400
- padding: var(--cs-card-padding-mobile, 20px 18px);
759
+ padding: var(--cs-card-padding-mobile, 20px 20px 24px);
401
760
  }
402
761
  }
403
762
  `;
@@ -449,6 +808,15 @@ __decorate([
449
808
  __decorate([
450
809
  property({ type: String, attribute: "submit-label" })
451
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);
452
820
  __decorate([
453
821
  property({ type: String, attribute: "cancel-label" })
454
822
  ], ConsentCapabilitiesScreen.prototype, "cancelLabel", void 0);
@@ -467,12 +835,30 @@ __decorate([
467
835
  __decorate([
468
836
  property({ type: String, attribute: "server-logo-url" })
469
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);
470
844
  __decorate([
471
845
  property({ type: Boolean, attribute: "require-all" })
472
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);
473
856
  __decorate([
474
857
  state()
475
858
  ], ConsentCapabilitiesScreen.prototype, "selected", void 0);
859
+ __decorate([
860
+ state()
861
+ ], ConsentCapabilitiesScreen.prototype, "hasLegal", void 0);
476
862
  ConsentCapabilitiesScreen = __decorate([
477
863
  customElement("consent-capabilities-screen")
478
864
  ], ConsentCapabilitiesScreen);