@kya-os/consent 0.1.50 → 0.2.0

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 (200) hide show
  1. package/README.md +72 -9
  2. package/dist/bundle/browser.d.ts +18 -0
  3. package/dist/bundle/browser.d.ts.map +1 -0
  4. package/dist/bundle/browser.js +18 -0
  5. package/dist/bundle/browser.js.map +1 -0
  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/bundle/shell.d.ts +2 -0
  10. package/dist/bundle/shell.d.ts.map +1 -1
  11. package/dist/bundle/shell.js +16 -43
  12. package/dist/bundle/shell.js.map +1 -1
  13. package/dist/cjs/bundle/inline.js +4 -4
  14. package/dist/cjs/bundle/inline.js.map +1 -1
  15. package/dist/cjs/bundle/shell.js +16 -43
  16. package/dist/cjs/bundle/shell.js.map +1 -1
  17. package/dist/cjs/components/consent-agent-header.js +73 -16
  18. package/dist/cjs/components/consent-agent-header.js.map +1 -1
  19. package/dist/cjs/components/consent-button.js +15 -12
  20. package/dist/cjs/components/consent-button.js.map +1 -1
  21. package/dist/cjs/components/consent-capabilities-screen.js +11 -5
  22. package/dist/cjs/components/consent-capabilities-screen.js.map +1 -1
  23. package/dist/cjs/components/consent-checkbox.js +19 -15
  24. package/dist/cjs/components/consent-checkbox.js.map +1 -1
  25. package/dist/cjs/components/consent-permissions.js +16 -15
  26. package/dist/cjs/components/consent-permissions.js.map +1 -1
  27. package/dist/cjs/components/consent-shell.js +34 -16
  28. package/dist/cjs/components/consent-shell.js.map +1 -1
  29. package/dist/cjs/components/consent-terms.js +25 -21
  30. package/dist/cjs/components/consent-terms.js.map +1 -1
  31. package/dist/cjs/components/mcp-consent.js +218 -42
  32. package/dist/cjs/components/mcp-consent.js.map +1 -1
  33. package/dist/cjs/constants/auth-modes.js +1 -1
  34. package/dist/cjs/constants/auth-modes.js.map +1 -1
  35. package/dist/cjs/constants/colors.js +5 -0
  36. package/dist/cjs/constants/colors.js.map +1 -1
  37. package/dist/cjs/copy/tokens.js +39 -0
  38. package/dist/cjs/copy/tokens.js.map +1 -1
  39. package/dist/cjs/mcp-app/inline.js +2 -2
  40. package/dist/cjs/mcp-app/inline.js.map +1 -1
  41. package/dist/cjs/resolution/resolve-branding.js +3 -1
  42. package/dist/cjs/resolution/resolve-branding.js.map +1 -1
  43. package/dist/cjs/schemas/branding.schemas.js +3 -0
  44. package/dist/cjs/schemas/branding.schemas.js.map +1 -1
  45. package/dist/cjs/schemas/capabilities.schemas.js +48 -3
  46. package/dist/cjs/schemas/capabilities.schemas.js.map +1 -1
  47. package/dist/cjs/schemas/modes.schemas.js +1 -0
  48. package/dist/cjs/schemas/modes.schemas.js.map +1 -1
  49. package/dist/cjs/styles/contrast.js +100 -0
  50. package/dist/cjs/styles/contrast.js.map +1 -0
  51. package/dist/cjs/styles/css-variables.js +36 -1
  52. package/dist/cjs/styles/css-variables.js.map +1 -1
  53. package/dist/cjs/styles/index.js +1 -0
  54. package/dist/cjs/styles/index.js.map +1 -1
  55. package/dist/cjs/styles/stylesheet.js +10 -5
  56. package/dist/cjs/styles/stylesheet.js.map +1 -1
  57. package/dist/cjs/templates/index.js +1 -0
  58. package/dist/cjs/templates/index.js.map +1 -1
  59. package/dist/cjs/templates/modes/credentials.template.js +9 -7
  60. package/dist/cjs/templates/modes/credentials.template.js.map +1 -1
  61. package/dist/cjs/templates/modes/index.js +3 -1
  62. package/dist/cjs/templates/modes/index.js.map +1 -1
  63. package/dist/cjs/templates/modes/passkey.template.js +178 -0
  64. package/dist/cjs/templates/modes/passkey.template.js.map +1 -0
  65. package/dist/cjs/templates/modes/success.template.js +2 -7
  66. package/dist/cjs/templates/modes/success.template.js.map +1 -1
  67. package/dist/cjs/templates/registry.js +1 -0
  68. package/dist/cjs/templates/registry.js.map +1 -1
  69. package/dist/cjs/types/capabilities.types.js +27 -2
  70. package/dist/cjs/types/capabilities.types.js.map +1 -1
  71. package/dist/cjs/types/modes.types.js +8 -1
  72. package/dist/cjs/types/modes.types.js.map +1 -1
  73. package/dist/components/consent-agent-header.d.ts +16 -3
  74. package/dist/components/consent-agent-header.d.ts.map +1 -1
  75. package/dist/components/consent-agent-header.js +73 -16
  76. package/dist/components/consent-agent-header.js.map +1 -1
  77. package/dist/components/consent-button.d.ts +5 -4
  78. package/dist/components/consent-button.d.ts.map +1 -1
  79. package/dist/components/consent-button.js +17 -14
  80. package/dist/components/consent-button.js.map +1 -1
  81. package/dist/components/consent-capabilities-screen.d.ts +1 -1
  82. package/dist/components/consent-capabilities-screen.d.ts.map +1 -1
  83. package/dist/components/consent-capabilities-screen.js +11 -5
  84. package/dist/components/consent-capabilities-screen.js.map +1 -1
  85. package/dist/components/consent-checkbox.d.ts +4 -2
  86. package/dist/components/consent-checkbox.d.ts.map +1 -1
  87. package/dist/components/consent-checkbox.js +21 -17
  88. package/dist/components/consent-checkbox.js.map +1 -1
  89. package/dist/components/consent-passkey.d.ts +128 -0
  90. package/dist/components/consent-passkey.d.ts.map +1 -0
  91. package/dist/components/consent-passkey.js +408 -0
  92. package/dist/components/consent-passkey.js.map +1 -0
  93. package/dist/components/consent-permissions.d.ts +4 -3
  94. package/dist/components/consent-permissions.d.ts.map +1 -1
  95. package/dist/components/consent-permissions.js +18 -17
  96. package/dist/components/consent-permissions.js.map +1 -1
  97. package/dist/components/consent-shell.d.ts +2 -2
  98. package/dist/components/consent-shell.d.ts.map +1 -1
  99. package/dist/components/consent-shell.js +36 -18
  100. package/dist/components/consent-shell.js.map +1 -1
  101. package/dist/components/consent-terms.d.ts +4 -2
  102. package/dist/components/consent-terms.d.ts.map +1 -1
  103. package/dist/components/consent-terms.js +27 -23
  104. package/dist/components/consent-terms.js.map +1 -1
  105. package/dist/components/mcp-consent.d.ts +9 -1
  106. package/dist/components/mcp-consent.d.ts.map +1 -1
  107. package/dist/components/mcp-consent.js +218 -42
  108. package/dist/components/mcp-consent.js.map +1 -1
  109. package/dist/consent.js +1026 -118
  110. package/dist/consent.min.js +453 -216
  111. package/dist/constants/auth-modes.js +1 -1
  112. package/dist/constants/auth-modes.js.map +1 -1
  113. package/dist/constants/colors.d.ts +5 -0
  114. package/dist/constants/colors.d.ts.map +1 -1
  115. package/dist/constants/colors.js +5 -0
  116. package/dist/constants/colors.js.map +1 -1
  117. package/dist/copy/tokens.d.ts +39 -0
  118. package/dist/copy/tokens.d.ts.map +1 -1
  119. package/dist/copy/tokens.js +39 -0
  120. package/dist/copy/tokens.js.map +1 -1
  121. package/dist/mcp-app/inline.d.ts.map +1 -1
  122. package/dist/mcp-app/inline.js +2 -2
  123. package/dist/mcp-app/inline.js.map +1 -1
  124. package/dist/passkey/index.d.ts +19 -0
  125. package/dist/passkey/index.d.ts.map +1 -0
  126. package/dist/passkey/index.js +18 -0
  127. package/dist/passkey/index.js.map +1 -0
  128. package/dist/passkey/react.d.ts +34 -0
  129. package/dist/passkey/react.d.ts.map +1 -0
  130. package/dist/passkey/react.js +39 -0
  131. package/dist/passkey/react.js.map +1 -0
  132. package/dist/resolution/resolve-branding.d.ts.map +1 -1
  133. package/dist/resolution/resolve-branding.js +3 -1
  134. package/dist/resolution/resolve-branding.js.map +1 -1
  135. package/dist/schemas/api.schemas.d.ts +49 -8
  136. package/dist/schemas/api.schemas.d.ts.map +1 -1
  137. package/dist/schemas/branding.schemas.d.ts +24 -0
  138. package/dist/schemas/branding.schemas.d.ts.map +1 -1
  139. package/dist/schemas/branding.schemas.js +3 -0
  140. package/dist/schemas/branding.schemas.js.map +1 -1
  141. package/dist/schemas/capabilities.schemas.d.ts +38 -4
  142. package/dist/schemas/capabilities.schemas.d.ts.map +1 -1
  143. package/dist/schemas/capabilities.schemas.js +47 -2
  144. package/dist/schemas/capabilities.schemas.js.map +1 -1
  145. package/dist/schemas/config.schemas.d.ts +82 -12
  146. package/dist/schemas/config.schemas.d.ts.map +1 -1
  147. package/dist/schemas/modes.schemas.d.ts +8 -0
  148. package/dist/schemas/modes.schemas.d.ts.map +1 -1
  149. package/dist/schemas/modes.schemas.js +1 -0
  150. package/dist/schemas/modes.schemas.js.map +1 -1
  151. package/dist/styles/contrast.d.ts +33 -0
  152. package/dist/styles/contrast.d.ts.map +1 -0
  153. package/dist/styles/contrast.js +92 -0
  154. package/dist/styles/contrast.js.map +1 -0
  155. package/dist/styles/css-variables.d.ts +20 -0
  156. package/dist/styles/css-variables.d.ts.map +1 -1
  157. package/dist/styles/css-variables.js +35 -1
  158. package/dist/styles/css-variables.js.map +1 -1
  159. package/dist/styles/index.d.ts +1 -0
  160. package/dist/styles/index.d.ts.map +1 -1
  161. package/dist/styles/index.js +1 -0
  162. package/dist/styles/index.js.map +1 -1
  163. package/dist/styles/stylesheet.d.ts +1 -1
  164. package/dist/styles/stylesheet.d.ts.map +1 -1
  165. package/dist/styles/stylesheet.js +10 -5
  166. package/dist/styles/stylesheet.js.map +1 -1
  167. package/dist/templates/index.d.ts +1 -0
  168. package/dist/templates/index.d.ts.map +1 -1
  169. package/dist/templates/index.js +1 -0
  170. package/dist/templates/index.js.map +1 -1
  171. package/dist/templates/modes/credentials.template.d.ts.map +1 -1
  172. package/dist/templates/modes/credentials.template.js +9 -7
  173. package/dist/templates/modes/credentials.template.js.map +1 -1
  174. package/dist/templates/modes/index.d.ts +1 -0
  175. package/dist/templates/modes/index.d.ts.map +1 -1
  176. package/dist/templates/modes/index.js +1 -0
  177. package/dist/templates/modes/index.js.map +1 -1
  178. package/dist/templates/modes/passkey.template.d.ts +62 -0
  179. package/dist/templates/modes/passkey.template.d.ts.map +1 -0
  180. package/dist/templates/modes/passkey.template.js +174 -0
  181. package/dist/templates/modes/passkey.template.js.map +1 -0
  182. package/dist/templates/modes/success.template.d.ts.map +1 -1
  183. package/dist/templates/modes/success.template.js +2 -7
  184. package/dist/templates/modes/success.template.js.map +1 -1
  185. package/dist/templates/registry.d.ts.map +1 -1
  186. package/dist/templates/registry.js +3 -2
  187. package/dist/templates/registry.js.map +1 -1
  188. package/dist/types/branding.types.d.ts +6 -0
  189. package/dist/types/branding.types.d.ts.map +1 -1
  190. package/dist/types/capabilities.types.d.ts +44 -7
  191. package/dist/types/capabilities.types.d.ts.map +1 -1
  192. package/dist/types/capabilities.types.js +26 -2
  193. package/dist/types/capabilities.types.js.map +1 -1
  194. package/dist/types/modes.types.d.ts +28 -1
  195. package/dist/types/modes.types.d.ts.map +1 -1
  196. package/dist/types/modes.types.js +7 -0
  197. package/dist/types/modes.types.js.map +1 -1
  198. package/dist/types/page.types.d.ts +7 -1
  199. package/dist/types/page.types.d.ts.map +1 -1
  200. package/package.json +26 -3
package/dist/consent.js CHANGED
@@ -1,5 +1,6 @@
1
1
  var __defProp = Object.defineProperty;
2
2
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
4
  var __decorateClass = (decorators, target, key, kind) => {
4
5
  var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
6
  for (var i6 = decorators.length - 1, decorator; i6 >= 0; i6--)
@@ -8,6 +9,7 @@ var __decorateClass = (decorators, target, key, kind) => {
8
9
  if (kind && result) __defProp(target, key, result);
9
10
  return result;
10
11
  };
12
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
11
13
 
12
14
  // ../../node_modules/.pnpm/@lit+reactive-element@2.1.2/node_modules/@lit/reactive-element/css-tag.js
13
15
  var t = globalThis;
@@ -670,7 +672,9 @@ ConsentButton.styles = i`
670
672
  font-weight: 500;
671
673
  font-family: inherit;
672
674
  cursor: pointer;
673
- transition: opacity 0.15s ease, background-color 0.15s ease;
675
+ transition:
676
+ opacity 0.15s ease,
677
+ background-color 0.15s ease;
674
678
  border: none;
675
679
  width: 100%;
676
680
  display: inline-flex;
@@ -680,23 +684,23 @@ ConsentButton.styles = i`
680
684
  }
681
685
 
682
686
  /* Primary variant */
683
- :host([variant='primary']) button {
687
+ :host([variant="primary"]) button {
684
688
  background-color: var(--consent-primary, #2563eb);
685
- color: white;
689
+ color: var(--consent-on-primary, white);
686
690
  }
687
691
 
688
- :host([variant='primary']) button:hover:not(:disabled) {
692
+ :host([variant="primary"]) button:hover:not(:disabled) {
689
693
  opacity: 0.9;
690
694
  }
691
695
 
692
696
  /* Secondary variant */
693
- :host([variant='secondary']) button {
697
+ :host([variant="secondary"]) button {
694
698
  background-color: transparent;
695
699
  color: #374151;
696
700
  border: 1px solid #d1d5db;
697
701
  }
698
702
 
699
- :host([variant='secondary']) button:hover:not(:disabled) {
703
+ :host([variant="secondary"]) button:hover:not(:disabled) {
700
704
  background-color: #f9fafb;
701
705
  }
702
706
 
@@ -820,7 +824,7 @@ ConsentCheckbox.styles = i`
820
824
  }
821
825
 
822
826
  /* Custom checkbox styling - matches Checkpoint exactly */
823
- input[type='checkbox'] {
827
+ input[type="checkbox"] {
824
828
  /* Reset */
825
829
  appearance: none;
826
830
  -webkit-appearance: none;
@@ -842,39 +846,41 @@ ConsentCheckbox.styles = i`
842
846
  /* Interaction */
843
847
  cursor: pointer;
844
848
  position: relative;
845
- transition: background-color 0.15s ease, border-color 0.15s ease;
849
+ transition:
850
+ background-color 0.15s ease,
851
+ border-color 0.15s ease;
846
852
  }
847
853
 
848
- input[type='checkbox']:hover:not(:disabled) {
854
+ input[type="checkbox"]:hover:not(:disabled) {
849
855
  border-color: var(--consent-primary, #2563eb);
850
856
  }
851
857
 
852
- input[type='checkbox']:focus-visible {
858
+ input[type="checkbox"]:focus-visible {
853
859
  outline: 2px solid var(--consent-primary, #2563eb);
854
860
  outline-offset: 2px;
855
861
  }
856
862
 
857
863
  /* Checked state */
858
- input[type='checkbox']:checked {
864
+ input[type="checkbox"]:checked {
859
865
  background-color: var(--consent-primary, #2563eb);
860
866
  border-color: var(--consent-primary, #2563eb);
861
867
  }
862
868
 
863
869
  /* Checkmark */
864
- input[type='checkbox']:checked::after {
865
- content: '';
870
+ input[type="checkbox"]:checked::after {
871
+ content: "";
866
872
  position: absolute;
867
873
  left: 4px;
868
874
  top: 1px;
869
875
  width: 5px;
870
876
  height: 9px;
871
- border: solid white;
877
+ border: solid var(--consent-on-primary, white);
872
878
  border-width: 0 2px 2px 0;
873
879
  transform: rotate(45deg);
874
880
  }
875
881
 
876
882
  /* Disabled */
877
- input[type='checkbox']:disabled {
883
+ input[type="checkbox"]:disabled {
878
884
  cursor: not-allowed;
879
885
  opacity: 0.5;
880
886
  }
@@ -886,7 +892,7 @@ ConsentCheckbox.styles = i`
886
892
 
887
893
  /* Links in label */
888
894
  ::slotted(a) {
889
- color: var(--consent-primary, #2563eb);
895
+ color: var(--consent-link, var(--consent-primary, #2563eb));
890
896
  text-decoration: underline;
891
897
  }
892
898
 
@@ -1181,7 +1187,130 @@ ConsentInput = __decorateClass([
1181
1187
  t3("consent-input")
1182
1188
  ], ConsentInput);
1183
1189
 
1190
+ // src/constants/colors.ts
1191
+ var DEFAULT_COLORS = {
1192
+ /** Primary brand color - Tailwind blue-600 */
1193
+ PRIMARY: "#2563EB",
1194
+ /** Secondary/accent color - Tailwind blue-100 */
1195
+ SECONDARY: "#DBEAFE",
1196
+ /**
1197
+ * Text on a secondary fill (the scope badges), kept wherever it reaches
1198
+ * WCAG AA on the brand's secondary color.
1199
+ */
1200
+ ON_SECONDARY: "#0E2249",
1201
+ /** Background color */
1202
+ BACKGROUND: "#F9FAFB",
1203
+ /** Text colors */
1204
+ TEXT_PRIMARY: "#111827",
1205
+ TEXT_SECONDARY: "#6B7280",
1206
+ TEXT_MUTED: "#9CA3AF",
1207
+ /** Border colors */
1208
+ BORDER: "#E5E7EB",
1209
+ BORDER_DARK: "#D1D5DB",
1210
+ /** Success color - Tailwind green-600 */
1211
+ SUCCESS: "#16A34A",
1212
+ /** Error color - Tailwind red-600 */
1213
+ ERROR: "#DC2626",
1214
+ /** Warning color - Tailwind amber-500 */
1215
+ WARNING: "#F59E0B"
1216
+ };
1217
+
1218
+ // src/styles/contrast.ts
1219
+ var AA_TEXT_CONTRAST = 4.5;
1220
+ var WHITE = "#FFFFFF";
1221
+ var BLACK = "#000000";
1222
+ var HEX_COLOR = /^#[0-9A-Fa-f]{6}$/;
1223
+ function isHexColor(value) {
1224
+ return typeof value === "string" && HEX_COLOR.test(value);
1225
+ }
1226
+ function channels(hex) {
1227
+ if (!isHexColor(hex)) {
1228
+ throw new RangeError(
1229
+ `Expected a #rrggbb color, got ${JSON.stringify(hex)}`
1230
+ );
1231
+ }
1232
+ return [1, 3, 5].map((at) => parseInt(hex.slice(at, at + 2), 16));
1233
+ }
1234
+ function toHex(rgb) {
1235
+ return `#${rgb.map((c4) => c4.toString(16).padStart(2, "0")).join("")}`.toUpperCase();
1236
+ }
1237
+ function linear(value) {
1238
+ const c4 = value / 255;
1239
+ return c4 <= 0.03928 ? c4 / 12.92 : ((c4 + 0.055) / 1.055) ** 2.4;
1240
+ }
1241
+ function relativeLuminance(hex) {
1242
+ const [r7, g2, b3] = channels(hex);
1243
+ return 0.2126 * linear(r7) + 0.7152 * linear(g2) + 0.0722 * linear(b3);
1244
+ }
1245
+ function contrastRatio(a3, b3) {
1246
+ const la = relativeLuminance(a3);
1247
+ const lb = relativeLuminance(b3);
1248
+ return (Math.max(la, lb) + 0.05) / (Math.min(la, lb) + 0.05);
1249
+ }
1250
+ function readableTextOn(background, preferred) {
1251
+ if (preferred !== void 0 && contrastRatio(preferred, background) >= AA_TEXT_CONTRAST) {
1252
+ return preferred;
1253
+ }
1254
+ return contrastRatio(BLACK, background) >= contrastRatio(WHITE, background) ? BLACK : WHITE;
1255
+ }
1256
+ function readableTextColor(color, surface = WHITE) {
1257
+ if (contrastRatio(color, surface) >= AA_TEXT_CONTRAST) return color;
1258
+ const [r7, g2, b3] = channels(color);
1259
+ const [tr, tg, tb] = channels(readableTextOn(surface));
1260
+ const toward = (c4, target, amount) => {
1261
+ const exact = c4 + (target - c4) * amount;
1262
+ return target > c4 ? Math.ceil(exact) : Math.floor(exact);
1263
+ };
1264
+ const mix = (amount) => toHex([
1265
+ toward(r7, tr, amount),
1266
+ toward(g2, tg, amount),
1267
+ toward(b3, tb, amount)
1268
+ ]);
1269
+ let low = 0;
1270
+ let high = 1;
1271
+ for (let step = 0; step < 16; step++) {
1272
+ const middle = (low + high) / 2;
1273
+ if (contrastRatio(mix(middle), surface) >= AA_TEXT_CONTRAST) high = middle;
1274
+ else low = middle;
1275
+ }
1276
+ return mix(high);
1277
+ }
1278
+
1279
+ // src/styles/css-variables.ts
1280
+ var CSS_VAR_NAMES = {
1281
+ PRIMARY: "--consent-primary",
1282
+ SECONDARY: "--consent-secondary",
1283
+ PRIMARY_RGB: "--consent-primary-rgb",
1284
+ SECONDARY_RGB: "--consent-secondary-rgb",
1285
+ ON_PRIMARY: "--consent-on-primary",
1286
+ ON_SECONDARY: "--consent-on-secondary",
1287
+ LINK: "--consent-link",
1288
+ BACKGROUND: "--consent-background",
1289
+ TEXT_PRIMARY: "--consent-text-primary",
1290
+ TEXT_SECONDARY: "--consent-text-secondary",
1291
+ BORDER: "--consent-border"
1292
+ };
1293
+ function generateContrastCSSVariables(primary, secondary) {
1294
+ return {
1295
+ ...isHexColor(primary) && {
1296
+ "--consent-on-primary": readableTextOn(primary),
1297
+ "--consent-link": readableTextColor(primary)
1298
+ },
1299
+ ...isHexColor(secondary) && {
1300
+ "--consent-on-secondary": readableTextOn(
1301
+ secondary,
1302
+ DEFAULT_COLORS.ON_SECONDARY
1303
+ )
1304
+ }
1305
+ };
1306
+ }
1307
+
1184
1308
  // src/components/consent-shell.ts
1309
+ var CONTRAST_VARS = [
1310
+ CSS_VAR_NAMES.ON_PRIMARY,
1311
+ CSS_VAR_NAMES.ON_SECONDARY,
1312
+ CSS_VAR_NAMES.LINK
1313
+ ];
1185
1314
  var ConsentShell = class extends i4 {
1186
1315
  constructor() {
1187
1316
  super(...arguments);
@@ -1224,6 +1353,15 @@ var ConsentShell = class extends i4 {
1224
1353
  if (changedProperties.has("primaryColor") || changedProperties.has("secondaryColor")) {
1225
1354
  this.style.setProperty("--consent-primary", this.primaryColor);
1226
1355
  this.style.setProperty("--consent-secondary", this.secondaryColor);
1356
+ const derived = generateContrastCSSVariables(
1357
+ this.primaryColor,
1358
+ this.secondaryColor
1359
+ );
1360
+ for (const name of CONTRAST_VARS) {
1361
+ const value = derived[name];
1362
+ if (value) this.style.setProperty(name, value);
1363
+ else this.style.removeProperty(name);
1364
+ }
1227
1365
  }
1228
1366
  }
1229
1367
  render() {
@@ -1250,8 +1388,9 @@ ConsentShell.styles = i`
1250
1388
  :host {
1251
1389
  display: block;
1252
1390
  /* System font stack with font smoothing for crisp text */
1253
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
1254
- 'Helvetica Neue', Arial, sans-serif;
1391
+ font-family:
1392
+ -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
1393
+ Arial, sans-serif;
1255
1394
  -webkit-font-smoothing: antialiased;
1256
1395
  -moz-osx-font-smoothing: grayscale;
1257
1396
  /* Allow customization via CSS variables */
@@ -1577,7 +1716,7 @@ ConsentPermissions.styles = i`
1577
1716
  .icon-check svg {
1578
1717
  width: 0.75rem;
1579
1718
  height: 0.75rem;
1580
- color: white;
1719
+ color: var(--consent-on-primary, white);
1581
1720
  }
1582
1721
 
1583
1722
  .icon-bullet {
@@ -1645,13 +1784,13 @@ ConsentPermissions.styles = i`
1645
1784
  }
1646
1785
 
1647
1786
  .checkbox:checked::after {
1648
- content: '';
1787
+ content: "";
1649
1788
  position: absolute;
1650
1789
  left: 4px;
1651
1790
  top: 1px;
1652
1791
  width: 5px;
1653
1792
  height: 9px;
1654
- border: solid white;
1793
+ border: solid var(--consent-on-primary, white);
1655
1794
  border-width: 0 2px 2px 0;
1656
1795
  transform: rotate(45deg);
1657
1796
  }
@@ -1683,7 +1822,10 @@ __decorateClass([
1683
1822
  try {
1684
1823
  const parsed = JSON.parse(value);
1685
1824
  if (!Array.isArray(parsed)) {
1686
- console.warn("[consent-permissions] Expected array, got:", typeof parsed);
1825
+ console.warn(
1826
+ "[consent-permissions] Expected array, got:",
1827
+ typeof parsed
1828
+ );
1687
1829
  return [];
1688
1830
  }
1689
1831
  return parsed;
@@ -1814,7 +1956,7 @@ ConsentTerms.styles = i`
1814
1956
  }
1815
1957
 
1816
1958
  /* Custom checkbox styling - matches Checkpoint exactly */
1817
- input[type='checkbox'] {
1959
+ input[type="checkbox"] {
1818
1960
  appearance: none;
1819
1961
  -webkit-appearance: none;
1820
1962
  margin: 0;
@@ -1835,39 +1977,41 @@ ConsentTerms.styles = i`
1835
1977
  /* Interaction */
1836
1978
  cursor: pointer;
1837
1979
  position: relative;
1838
- transition: background-color 0.15s ease, border-color 0.15s ease;
1980
+ transition:
1981
+ background-color 0.15s ease,
1982
+ border-color 0.15s ease;
1839
1983
  }
1840
1984
 
1841
- input[type='checkbox']:hover:not(:disabled) {
1985
+ input[type="checkbox"]:hover:not(:disabled) {
1842
1986
  border-color: var(--_primary);
1843
1987
  }
1844
1988
 
1845
- input[type='checkbox']:focus-visible {
1989
+ input[type="checkbox"]:focus-visible {
1846
1990
  outline: 2px solid var(--_primary);
1847
1991
  outline-offset: 2px;
1848
1992
  }
1849
1993
 
1850
1994
  /* Checked state */
1851
- input[type='checkbox']:checked {
1995
+ input[type="checkbox"]:checked {
1852
1996
  background-color: var(--_primary);
1853
1997
  border-color: var(--_primary);
1854
1998
  }
1855
1999
 
1856
2000
  /* Checkmark */
1857
- input[type='checkbox']:checked::after {
1858
- content: '';
2001
+ input[type="checkbox"]:checked::after {
2002
+ content: "";
1859
2003
  position: absolute;
1860
2004
  left: 4px;
1861
2005
  top: 1px;
1862
2006
  width: 5px;
1863
2007
  height: 9px;
1864
- border: solid white;
2008
+ border: solid var(--consent-on-primary, white);
1865
2009
  border-width: 0 2px 2px 0;
1866
2010
  transform: rotate(45deg);
1867
2011
  }
1868
2012
 
1869
2013
  /* Disabled */
1870
- input[type='checkbox']:disabled {
2014
+ input[type="checkbox"]:disabled {
1871
2015
  cursor: not-allowed;
1872
2016
  opacity: 0.5;
1873
2017
  }
@@ -1879,7 +2023,7 @@ ConsentTerms.styles = i`
1879
2023
 
1880
2024
  /* Links */
1881
2025
  a {
1882
- color: var(--_primary);
2026
+ color: var(--consent-link, var(--_primary));
1883
2027
  text-decoration: underline;
1884
2028
  text-underline-offset: 2px;
1885
2029
  }
@@ -2630,7 +2774,8 @@ var CONSENT_COPY_TOKENS = {
2630
2774
  * `{Verb}` → operator verb, default "use".
2631
2775
  * `{Org}` → organization display name (serif italic at render time).
2632
2776
  */
2633
- template: "{Agent} would like to {Verb} at {Org} for you."
2777
+ template: "{Agent} would like to {Verb} at {Org} for you.",
2778
+ fallbackTemplate: "{Agent} is requesting permission at {Org}."
2634
2779
  },
2635
2780
  subhead: {
2636
2781
  /** `{Agent}` → agent display name. */
@@ -2639,6 +2784,12 @@ var CONSENT_COPY_TOKENS = {
2639
2784
  agentTile: {
2640
2785
  verifiedPill: "Verified",
2641
2786
  unverifiedPill: "UNVERIFIED",
2787
+ /**
2788
+ * Read by screen readers before the domain in a domain-bound agent's
2789
+ * pill, which shows only the domain. Never "Verified": a domain binding
2790
+ * names the client, it does not verify it.
2791
+ */
2792
+ domainPillPrefix: "Identified by",
2642
2793
  /** `{Vendor}` → vendor name. `{Surface}` → surface label. */
2643
2794
  metaTemplate: "Made by {Vendor} \xB7 Asking from your {Surface} \xB7 {Connected}",
2644
2795
  connectedJustNow: "Connected just now",
@@ -2694,6 +2845,38 @@ var CONSENT_COPY_TOKENS = {
2694
2845
  /** Dark theme. */
2695
2846
  securedBy: "Secured by Checkpoint",
2696
2847
  howThisWorks: "How does this work?"
2848
+ },
2849
+ /**
2850
+ * `consent-passkey` defaults. `PasskeyConfig.instructions`, `buttonText`
2851
+ * and `unsupportedText` override these for both ceremonies.
2852
+ */
2853
+ passkey: {
2854
+ register: {
2855
+ title: "Create a passkey",
2856
+ instructions: "Your device asks for your fingerprint, face or screen lock. The passkey stays on this device.",
2857
+ button: "Create a passkey",
2858
+ done: "Passkey created"
2859
+ },
2860
+ authenticate: {
2861
+ title: "Use your passkey",
2862
+ instructions: "Confirm with your fingerprint, face or screen lock to approve this request.",
2863
+ button: "Use your passkey",
2864
+ done: "Passkey confirmed"
2865
+ },
2866
+ checking: "Checking this device for passkey support",
2867
+ waiting: "Waiting for your device",
2868
+ unsupportedTitle: "This device can't use a passkey",
2869
+ unsupportedText: "This request needs a passkey, and this browser can't create or use one. Open the link on a device with a screen lock and a current browser.",
2870
+ compatibilityInfo: "Passkeys work in current versions of Chrome, Edge, Firefox and Safari on a device with a screen lock.",
2871
+ /** Keyed by `PasskeyCeremonyError.code` from `@kya-os/id/wallet/passkey`. */
2872
+ errors: {
2873
+ not_allowed: "The passkey request was cancelled or timed out, or no passkey matched. Try again.",
2874
+ invalid_state: "This device already holds a passkey for this account. Use that passkey instead.",
2875
+ not_supported: "This browser or device can't complete a user-verified passkey check.",
2876
+ security: "Passkeys can't be used on this page.",
2877
+ aborted: "The passkey request was interrupted. Try again.",
2878
+ unknown: "The passkey check failed. Try again."
2879
+ }
2697
2880
  }
2698
2881
  };
2699
2882
  function formatToken(template, values) {
@@ -2703,6 +2886,20 @@ function formatToken(template, values) {
2703
2886
  });
2704
2887
  }
2705
2888
 
2889
+ // src/types/capabilities.types.ts
2890
+ var AGENT_VERIFICATIONS = [
2891
+ "verified",
2892
+ "domain",
2893
+ "unverified"
2894
+ ];
2895
+ function agentVerification(agent) {
2896
+ const stated = agent.verification;
2897
+ if (stated !== void 0 && AGENT_VERIFICATIONS.includes(stated)) {
2898
+ return stated === "domain" && !agent.domain?.trim() ? "unverified" : stated;
2899
+ }
2900
+ return agent.verified === true ? "verified" : "unverified";
2901
+ }
2902
+
2706
2903
  // src/components/consent-agent-header.ts
2707
2904
  var ConsentAgentHeader = class extends i4 {
2708
2905
  constructor() {
@@ -2710,6 +2907,7 @@ var ConsentAgentHeader = class extends i4 {
2710
2907
  this.agentName = "";
2711
2908
  this.vendor = "";
2712
2909
  this.surfaceLabel = "";
2910
+ this.domain = "";
2713
2911
  this.verified = false;
2714
2912
  this.logoUrl = "";
2715
2913
  this.connectedAt = "";
@@ -2740,10 +2938,25 @@ var ConsentAgentHeader = class extends i4 {
2740
2938
  Connected: this.renderConnectedFragment()
2741
2939
  });
2742
2940
  }
2941
+ renderPill() {
2942
+ const tokens = CONSENT_COPY_TOKENS.agentTile;
2943
+ const state = agentVerification({
2944
+ verification: this.verification,
2945
+ verified: this.verified,
2946
+ domain: this.domain
2947
+ });
2948
+ if (state === "domain") {
2949
+ return b2`<span class="pill domain" part="pill"
2950
+ ><span class="visually-hidden">${tokens.domainPillPrefix} </span
2951
+ >${this.domain.trim()}</span
2952
+ >`;
2953
+ }
2954
+ return b2`<span class="pill ${state}" part="pill">
2955
+ ${state === "verified" ? tokens.verifiedPill : tokens.unverifiedPill}
2956
+ </span>`;
2957
+ }
2743
2958
  render() {
2744
2959
  const initial = (this.agentName || "?").trim().charAt(0).toUpperCase();
2745
- const verifiedLabel = this.verified ? CONSENT_COPY_TOKENS.agentTile.verifiedPill : CONSENT_COPY_TOKENS.agentTile.unverifiedPill;
2746
- const verifiedClass = this.verified ? "verified" : "unverified";
2747
2960
  return b2`
2748
2961
  <div class="tile" part="tile">
2749
2962
  <div class="logo" aria-hidden="true">
@@ -2752,9 +2965,7 @@ var ConsentAgentHeader = class extends i4 {
2752
2965
  <div class="body">
2753
2966
  <div class="row-name">
2754
2967
  <span class="name">${this.agentName || A}</span>
2755
- <span class="pill ${verifiedClass}" part="pill">
2756
- ${verifiedLabel}
2757
- </span>
2968
+ ${this.renderPill()}
2758
2969
  </div>
2759
2970
  <div class="meta">${this.renderMeta()}</div>
2760
2971
  </div>
@@ -2785,7 +2996,7 @@ ConsentAgentHeader.styles = i`
2785
2996
  height: 44px;
2786
2997
  border-radius: 12px;
2787
2998
  flex-shrink: 0;
2788
- background: var(--cs-agent-tile-bg, #FFFFFF);
2999
+ background: var(--cs-agent-tile-bg, #ffffff);
2789
3000
  display: flex;
2790
3001
  align-items: center;
2791
3002
  justify-content: center;
@@ -2804,7 +3015,7 @@ ConsentAgentHeader.styles = i`
2804
3015
  width: 100%;
2805
3016
  height: 100%;
2806
3017
  background: transparent;
2807
- color: var(--cs-agent-tile-text, #0F172A);
3018
+ color: var(--cs-agent-tile-text, #0f172a);
2808
3019
  display: flex;
2809
3020
  align-items: center;
2810
3021
  justify-content: center;
@@ -2829,7 +3040,7 @@ ConsentAgentHeader.styles = i`
2829
3040
  .name {
2830
3041
  font-size: 16px;
2831
3042
  font-weight: 600;
2832
- color: var(--cs-text-primary, #0F172A);
3043
+ color: var(--cs-text-primary, #0f172a);
2833
3044
  letter-spacing: -0.01em;
2834
3045
  }
2835
3046
 
@@ -2845,19 +3056,52 @@ ConsentAgentHeader.styles = i`
2845
3056
  }
2846
3057
 
2847
3058
  .pill.verified {
2848
- background: var(--cs-pill-verified-bg, #DCFCE7);
3059
+ background: var(--cs-pill-verified-bg, #dcfce7);
2849
3060
  color: var(--cs-pill-verified-text, #166534);
2850
3061
  }
2851
3062
 
2852
3063
  .pill.unverified {
2853
- background: var(--cs-pill-unverified-bg, #F1F5F9);
3064
+ background: var(--cs-pill-unverified-bg, #f1f5f9);
2854
3065
  color: var(--cs-pill-unverified-text, #475569);
2855
3066
  letter-spacing: 0.08em;
2856
3067
  }
2857
3068
 
3069
+ /*
3070
+ * Domain-bound: a tint and an outline from the brand primary, with the
3071
+ * theme's own text color, so the domain reads in light and dark
3072
+ * whatever the brand color is.
3073
+ */
3074
+ .pill.domain {
3075
+ background: var(
3076
+ --cs-pill-domain-bg,
3077
+ color-mix(in srgb, var(--consent-primary, #2563eb) 14%, transparent)
3078
+ );
3079
+ box-shadow: inset 0 0 0 1px
3080
+ var(
3081
+ --cs-pill-domain-border,
3082
+ color-mix(in srgb, var(--consent-primary, #2563eb) 40%, transparent)
3083
+ );
3084
+ color: var(--cs-pill-domain-text, var(--cs-text-primary, #0f172a));
3085
+ font-weight: 500;
3086
+ letter-spacing: 0;
3087
+ overflow-wrap: anywhere;
3088
+ }
3089
+
3090
+ .visually-hidden {
3091
+ position: absolute;
3092
+ width: 1px;
3093
+ height: 1px;
3094
+ margin: -1px;
3095
+ padding: 0;
3096
+ overflow: hidden;
3097
+ clip: rect(0, 0, 0, 0);
3098
+ white-space: nowrap;
3099
+ border: 0;
3100
+ }
3101
+
2858
3102
  .meta {
2859
3103
  font-size: 12px;
2860
- color: var(--cs-text-tertiary, #64748B);
3104
+ color: var(--cs-text-tertiary, #64748b);
2861
3105
  line-height: 1.5;
2862
3106
  }
2863
3107
  `;
@@ -2870,6 +3114,12 @@ __decorateClass([
2870
3114
  __decorateClass([
2871
3115
  n4({ type: String })
2872
3116
  ], ConsentAgentHeader.prototype, "surfaceLabel", 2);
3117
+ __decorateClass([
3118
+ n4({ type: String })
3119
+ ], ConsentAgentHeader.prototype, "verification", 2);
3120
+ __decorateClass([
3121
+ n4({ type: String })
3122
+ ], ConsentAgentHeader.prototype, "domain", 2);
2873
3123
  __decorateClass([
2874
3124
  n4({ type: Boolean })
2875
3125
  ], ConsentAgentHeader.prototype, "verified", 2);
@@ -4091,6 +4341,7 @@ var AUTH_MODES = {
4091
4341
  /** Identity verification (future) - Auth → Consent → Success (3 screens) */
4092
4342
  IDV: "idv"
4093
4343
  };
4344
+ var PASSKEY_CEREMONIES = ["register", "authenticate"];
4094
4345
  var PROVIDER_TYPES = {
4095
4346
  /** Consent-only - no authentication, just clickwrap agreement */
4096
4347
  NONE: "none",
@@ -4156,7 +4407,7 @@ var ConsentCapabilitiesScreen = class extends i4 {
4156
4407
  super(...arguments);
4157
4408
  this.capabilities = [];
4158
4409
  this.orgName = "";
4159
- this.headlineVerb = "use";
4410
+ this.headlineVerb = "";
4160
4411
  this.revocationPath = "Account \u2192 Connected Agents";
4161
4412
  this.inactivityDays = 90;
4162
4413
  this.fixedExpiry = false;
@@ -4269,13 +4520,17 @@ var ConsentCapabilitiesScreen = class extends i4 {
4269
4520
  }
4270
4521
  }
4271
4522
  renderHeadline() {
4272
- const agentName = this.agentMetadata?.name || "this agent";
4523
+ const agentName = this.agentMetadata?.name?.trim() || "An assistant";
4273
4524
  const tokens = CONSENT_COPY_TOKENS;
4274
- const raw = formatToken(tokens.headline.template, {
4275
- Agent: "@@AGENT@@",
4276
- Verb: this.headlineVerb || "use",
4277
- Org: "@@ORG@@"
4278
- });
4525
+ const verb = this.headlineVerb.trim();
4526
+ const raw = formatToken(
4527
+ verb && verb !== "use" ? tokens.headline.template : tokens.headline.fallbackTemplate,
4528
+ {
4529
+ Agent: "@@AGENT@@",
4530
+ Verb: verb,
4531
+ Org: "@@ORG@@"
4532
+ }
4533
+ );
4279
4534
  const escaped = escapeHtml(raw);
4280
4535
  const withSerifEntities = escaped.replace("@@AGENT@@", `<em>${escapeHtml(agentName)}</em>`).replace(
4281
4536
  "@@ORG@@",
@@ -4314,13 +4569,15 @@ var ConsentCapabilitiesScreen = class extends i4 {
4314
4569
  >
4315
4570
  ${this.renderHeadline()}
4316
4571
  <p class="subhead" part="subhead">${subhead}</p>
4572
+ <slot name="recovery"></slot>
4317
4573
  <slot name="identity"></slot>
4318
4574
  ${this.agentMetadata ? b2`<consent-agent-header
4319
4575
  part="agent"
4320
4576
  agentName="${this.agentMetadata.name}"
4321
4577
  vendor="${this.agentMetadata.vendor || ""}"
4322
4578
  surfaceLabel="${this.agentMetadata.surfaceLabel || ""}"
4323
- ?verified=${this.agentMetadata.verified}
4579
+ verification="${agentVerification(this.agentMetadata)}"
4580
+ domain="${this.agentMetadata.domain || ""}"
4324
4581
  logoUrl="${this.agentMetadata.logoUrl || ""}"
4325
4582
  connectedAt="${this.agentMetadata.connectedAt || ""}"
4326
4583
  ></consent-agent-header>` : A}
@@ -4540,29 +4797,6 @@ function escapeHtml(value) {
4540
4797
  return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
4541
4798
  }
4542
4799
 
4543
- // src/constants/colors.ts
4544
- var DEFAULT_COLORS = {
4545
- /** Primary brand color - Tailwind blue-600 */
4546
- PRIMARY: "#2563EB",
4547
- /** Secondary/accent color - Tailwind blue-100 */
4548
- SECONDARY: "#DBEAFE",
4549
- /** Background color */
4550
- BACKGROUND: "#F9FAFB",
4551
- /** Text colors */
4552
- TEXT_PRIMARY: "#111827",
4553
- TEXT_SECONDARY: "#6B7280",
4554
- TEXT_MUTED: "#9CA3AF",
4555
- /** Border colors */
4556
- BORDER: "#E5E7EB",
4557
- BORDER_DARK: "#D1D5DB",
4558
- /** Success color - Tailwind green-600 */
4559
- SUCCESS: "#16A34A",
4560
- /** Error color - Tailwind red-600 */
4561
- ERROR: "#DC2626",
4562
- /** Warning color - Tailwind amber-500 */
4563
- WARNING: "#F59E0B"
4564
- };
4565
-
4566
4800
  // src/constants/defaults.ts
4567
4801
  var DEFAULT_BRANDING = {
4568
4802
  primaryColor: DEFAULT_COLORS.PRIMARY,
@@ -4635,7 +4869,11 @@ function generateBrandingCSSVars(branding) {
4635
4869
  "--consent-primary": branding.primaryColor,
4636
4870
  "--consent-secondary": branding.secondaryColor,
4637
4871
  "--consent-primary-rgb": hexToRgb(branding.primaryColor),
4638
- "--consent-secondary-rgb": hexToRgb(branding.secondaryColor)
4872
+ "--consent-secondary-rgb": hexToRgb(branding.secondaryColor),
4873
+ ...generateContrastCSSVariables(
4874
+ branding.primaryColor,
4875
+ branding.secondaryColor
4876
+ )
4639
4877
  };
4640
4878
  }
4641
4879
  function resolveConsentBranding(branding) {
@@ -4902,9 +5140,10 @@ var McpConsent = class extends i4 {
4902
5140
  this.credentialProviderUserId = "";
4903
5141
  this.oauthUrl = "";
4904
5142
  this.nativeScopeSelection = false;
5143
+ this.requestExpiresAt = 0;
4905
5144
  this.capabilities = [];
4906
5145
  this.orgName = "";
4907
- this.headlineVerb = "use";
5146
+ this.headlineVerb = "";
4908
5147
  this.revocationPath = "Account \u2192 Connected Agents";
4909
5148
  this.inactivityDays = 90;
4910
5149
  this.consentTheme = "light";
@@ -4919,6 +5158,13 @@ var McpConsent = class extends i4 {
4919
5158
  this.resendCooldown = 0;
4920
5159
  this.selectedScopes = [];
4921
5160
  this.closeFailed = false;
5161
+ this.restartApprovalPage = () => {
5162
+ if (!this.approvalRecovery?.reload || !this.anchorSid || typeof window === "undefined")
5163
+ return;
5164
+ const target = new URL("/consent", window.location.origin);
5165
+ target.searchParams.set("sid", this.anchorSid);
5166
+ window.location.assign(target.toString());
5167
+ };
4922
5168
  this.onCapabilitiesAllow = (event) => {
4923
5169
  if (this.loading) return;
4924
5170
  const selection = resolveCapabilitySelection(
@@ -4969,6 +5215,7 @@ var McpConsent = class extends i4 {
4969
5215
  this.currentMode = this.mode ?? determineAuthMode(this.config) ?? AUTH_MODES.CONSENT_ONLY;
4970
5216
  this.selectedScopes = [...this.scopes];
4971
5217
  this.readIdentityAssertionFromLocation();
5218
+ this.scheduleRequestExpiry();
4972
5219
  }
4973
5220
  /**
4974
5221
  * Read the grant-bound signed identity assertion the worker delivers via
@@ -5002,12 +5249,15 @@ var McpConsent = class extends i4 {
5002
5249
  }
5003
5250
  disconnectedCallback() {
5004
5251
  super.disconnectedCallback();
5252
+ clearTimeout(this.requestExpiryTimer);
5005
5253
  if (this.resendCooldownInterval !== void 0) {
5006
5254
  clearInterval(this.resendCooldownInterval);
5007
5255
  this.resendCooldownInterval = void 0;
5008
5256
  }
5009
5257
  }
5010
5258
  updated(changedProperties) {
5259
+ if (changedProperties.has("requestExpiresAt") || changedProperties.has("nativeScopeSelection"))
5260
+ this.scheduleRequestExpiry();
5011
5261
  if (changedProperties.has("config") || changedProperties.has("agentName")) {
5012
5262
  this.resolved = resolveConsentConfig(this.config, this.agentName);
5013
5263
  }
@@ -5018,14 +5268,11 @@ var McpConsent = class extends i4 {
5018
5268
  this.selectedScopes = [...this.scopes];
5019
5269
  }
5020
5270
  if (this.resolved) {
5021
- this.style.setProperty(
5022
- "--consent-primary",
5023
- this.resolved.branding.primaryColor
5024
- );
5025
- this.style.setProperty(
5026
- "--consent-secondary",
5027
- this.resolved.branding.secondaryColor
5028
- );
5271
+ for (const [name, value] of Object.entries(
5272
+ this.resolved.branding.cssVars
5273
+ )) {
5274
+ if (value) this.style.setProperty(name, value);
5275
+ }
5029
5276
  }
5030
5277
  }
5031
5278
  // === FORM SUBMISSION ===
@@ -5079,6 +5326,9 @@ var McpConsent = class extends i4 {
5079
5326
  */
5080
5327
  async handleApprove(e8) {
5081
5328
  e8?.preventDefault();
5329
+ if (this.nativeScopeSelection && this.requestExpiresAt > 0 && Date.now() >= this.requestExpiresAt)
5330
+ this.setApprovalRecovery("kyaos/pickup-expired");
5331
+ if (this.approvalRecovery) return;
5082
5332
  if (this.loading) {
5083
5333
  return;
5084
5334
  }
@@ -5096,6 +5346,7 @@ var McpConsent = class extends i4 {
5096
5346
  }
5097
5347
  this.loading = true;
5098
5348
  this.error = void 0;
5349
+ let credentialsRejected = false;
5099
5350
  try {
5100
5351
  const formData = new FormData();
5101
5352
  formData.append("tool", this.tool);
@@ -5152,17 +5403,35 @@ var McpConsent = class extends i4 {
5152
5403
  Object.entries(this.formData).forEach(([key, value]) => {
5153
5404
  formData.append(key, value);
5154
5405
  });
5155
- const response = await fetch(`${this.serverUrl}/consent/approve`, {
5156
- method: "POST",
5157
- body: formData
5158
- });
5406
+ let response;
5407
+ try {
5408
+ response = await fetch(`${this.serverUrl}/consent/approve`, {
5409
+ method: "POST",
5410
+ body: formData
5411
+ });
5412
+ } catch (error) {
5413
+ if (this.nativeScopeSelection)
5414
+ this.setApprovalRecovery("kyaos/consent-network-interrupted");
5415
+ throw error;
5416
+ }
5159
5417
  if (!response.ok) {
5160
- const errorData = await response.json().catch(() => ({}));
5418
+ const errorData = await response.json().catch(() => null);
5419
+ const data = errorData && typeof errorData === "object" ? errorData : {};
5420
+ if (this.nativeScopeSelection) {
5421
+ const code = typeof data.error_code === "string" ? data.error_code : void 0;
5422
+ credentialsRejected = this.currentMode === AUTH_MODES.CREDENTIALS && response.status === 401 && code === "kyaos/credentials-not-accepted";
5423
+ if (!credentialsRejected)
5424
+ this.setApprovalRecovery(
5425
+ code ?? (response.status === 410 ? "kyaos/pickup-expired" : "kyaos/consent-request-unavailable")
5426
+ );
5427
+ }
5161
5428
  throw new Error(
5162
- errorData.error || errorData.message || "Approval failed"
5429
+ credentialsRejected ? "Those credentials were not accepted. Please check them and try again." : typeof data.error === "string" ? data.error : typeof data.message === "string" ? data.message : "Approval failed"
5163
5430
  );
5164
5431
  }
5165
5432
  const result = await response.json();
5433
+ if (this.nativeScopeSelection && (!result || result.success !== true || typeof result.delegation_id !== "string" || !result.delegation_id))
5434
+ throw new Error("Invalid approval response");
5166
5435
  if (result.redirectUrl) {
5167
5436
  this.dispatchEvent(
5168
5437
  new CustomEvent("mcp-consent:approve", {
@@ -5187,10 +5456,13 @@ var McpConsent = class extends i4 {
5187
5456
  })
5188
5457
  );
5189
5458
  } catch (e9) {
5190
- this.error = e9 instanceof Error ? e9.message : "Unknown error";
5459
+ if (this.nativeScopeSelection && !credentialsRejected && !this.approvalRecovery)
5460
+ this.setApprovalRecovery("kyaos/consent-request-unavailable");
5461
+ const message = this.approvalRecoveryMessage() ?? (e9 instanceof Error ? e9.message : "Unknown error");
5462
+ this.error = message;
5191
5463
  this.dispatchEvent(
5192
5464
  new CustomEvent("mcp-consent:error", {
5193
- detail: { error: this.error },
5465
+ detail: { error: message },
5194
5466
  bubbles: true,
5195
5467
  composed: true
5196
5468
  })
@@ -5250,6 +5522,7 @@ var McpConsent = class extends i4 {
5250
5522
  <section class="agent-key" aria-label="Agent key">
5251
5523
  <p><strong>Agent key</strong></p>
5252
5524
  <p>This permission is bound to this key.</p>
5525
+ <p>The agent provider has not been verified.</p>
5253
5526
  <code>${this.agentDid}</code>
5254
5527
  </section>
5255
5528
  `;
@@ -5325,9 +5598,60 @@ var McpConsent = class extends i4 {
5325
5598
  </div>
5326
5599
  `;
5327
5600
  }
5601
+ approvalRecoveryMessage() {
5602
+ return this.approvalRecovery?.message;
5603
+ }
5604
+ setApprovalRecovery(code) {
5605
+ const expired = code === "kyaos/pickup-expired";
5606
+ const invalidForm = code === "kyaos/consent-form-invalid";
5607
+ const mismatch = code === "kyaos/session-mismatch";
5608
+ const missing = code === "kyaos/consent-request-not-found";
5609
+ const network = code === "kyaos/consent-network-interrupted";
5610
+ this.approvalRecovery = {
5611
+ code: expired || invalidForm || mismatch || missing || network ? code : "kyaos/consent-request-unavailable",
5612
+ title: expired ? "This approval request has expired" : invalidForm ? "We couldn't verify this approval page" : mismatch ? "This sign-in could not be verified" : missing ? "This approval request is no longer available" : network ? "The connection was interrupted" : "We couldn't check this approval request",
5613
+ message: expired || missing || mismatch ? "Return to your assistant for a new approval link, then review the permissions again." : invalidForm ? "Reload and sign in again, then review the permissions. This submission did not approve access." : network ? "We couldn't confirm whether approval completed. Return to your assistant to check the request before trying again." : "Return to your assistant to check this request before trying again.",
5614
+ // Only a server-confirmed valid pinned anchor permits a GET restart.
5615
+ reload: invalidForm
5616
+ };
5617
+ }
5618
+ scheduleRequestExpiry() {
5619
+ clearTimeout(this.requestExpiryTimer);
5620
+ if (!this.nativeScopeSelection || !Number.isSafeInteger(this.requestExpiresAt) || this.requestExpiresAt <= 0)
5621
+ return;
5622
+ const remaining = this.requestExpiresAt - Date.now();
5623
+ if (remaining <= 0) {
5624
+ if (this.step !== "success")
5625
+ this.setApprovalRecovery("kyaos/pickup-expired");
5626
+ } else {
5627
+ this.requestExpiryTimer = setTimeout(
5628
+ () => {
5629
+ if (this.step !== "success")
5630
+ this.setApprovalRecovery("kyaos/pickup-expired");
5631
+ },
5632
+ Math.min(remaining, 2147483647)
5633
+ );
5634
+ }
5635
+ }
5328
5636
  renderError() {
5637
+ if (this.approvalRecovery)
5638
+ return b2` <section
5639
+ class="error-message"
5640
+ role="alert"
5641
+ aria-live="assertive"
5642
+ aria-atomic="true"
5643
+ >
5644
+ <h2>${this.approvalRecovery.title}</h2>
5645
+ <p>${this.approvalRecovery.message}</p>
5646
+ ${this.approvalRecovery.reload ? b2`<consent-button
5647
+ variant="secondary"
5648
+ @click=${this.restartApprovalPage}
5649
+ >Reload and sign in again</consent-button
5650
+ >` : A}
5651
+ <p><small>Reference: ${this.approvalRecovery.code}</small></p>
5652
+ </section>`;
5329
5653
  if (!this.error) return A;
5330
- return b2`<div class="error-message">${this.error}</div>`;
5654
+ return b2`<div class="error-message" role="alert">${this.error}</div>`;
5331
5655
  }
5332
5656
  /**
5333
5657
  * Whether the user's identity has already been established, either via a
@@ -5353,7 +5677,7 @@ var McpConsent = class extends i4 {
5353
5677
  <consent-button
5354
5678
  variant="primary"
5355
5679
  ?loading=${this.loading}
5356
- ?disabled=${this.currentMode === AUTH_MODES.CONSENT_ONLY && this.resolved?.terms.required && !this.termsAccepted}
5680
+ ?disabled=${!!this.approvalRecovery || this.currentMode === AUTH_MODES.CONSENT_ONLY && this.resolved?.terms.required && !this.termsAccepted}
5357
5681
  @click=${this.handleApprove}
5358
5682
  >
5359
5683
  ${submitText ?? this.resolved?.ui.submitButtonText ?? "Allow access"}
@@ -5425,7 +5749,7 @@ var McpConsent = class extends i4 {
5425
5749
  <p style="text-align: right; margin-bottom: 1rem;">
5426
5750
  <a
5427
5751
  href=${creds.forgotPasswordUrl}
5428
- style="font-size: 0.75rem; color: var(--_primary);"
5752
+ style="font-size: 0.75rem; color: var(--consent-link, var(--_primary));"
5429
5753
  >
5430
5754
  Forgot password?
5431
5755
  </a>
@@ -5465,14 +5789,13 @@ var McpConsent = class extends i4 {
5465
5789
  >
5466
5790
  <div slot="content">
5467
5791
  ${this.renderError()} ${this.renderAgentInfo()}
5468
-
5469
- <consent-oauth-button
5470
- provider=${provider}
5471
- provider-name=${providerName}
5472
- url=${oauthButtonUrl}
5473
- button-text=${oauth?.buttonText ?? `Continue with ${providerName}`}
5474
- full-width
5475
- ></consent-oauth-button>
5792
+ ${this.approvalRecovery ? A : b2`<consent-oauth-button
5793
+ provider=${provider}
5794
+ provider-name=${providerName}
5795
+ url=${oauthButtonUrl}
5796
+ button-text=${oauth?.buttonText ?? `Continue with ${providerName}`}
5797
+ full-width
5798
+ ></consent-oauth-button>`}
5476
5799
  </div>
5477
5800
  ${this.renderFooter({ allowSubmit: this.hasEstablishedIdentity })}
5478
5801
  </consent-shell>
@@ -5733,17 +6056,6 @@ var McpConsent = class extends i4 {
5733
6056
  const credentials = shouldSelectAllCapabilities(this.currentMode);
5734
6057
  const allSelected = this.requiresAllCapabilities;
5735
6058
  return b2`
5736
- ${error ? b2`<div
5737
- role="alert"
5738
- style="
5739
- color: var(--cs-text-danger, #b91c1c);
5740
- margin: 0 auto 12px;
5741
- max-width: 560px;
5742
- font-size: 13px;
5743
- "
5744
- >
5745
- ${error}
5746
- </div>` : A}
5747
6059
  <consent-capabilities-screen
5748
6060
  .capabilities=${flatCapabilities}
5749
6061
  .agentMetadata=${this.agentMetadata}
@@ -5759,11 +6071,21 @@ var McpConsent = class extends i4 {
5759
6071
  how-it-works-url="${this.howItWorksUrl}"
5760
6072
  ?loading=${this.loading}
5761
6073
  ?all-selected=${allSelected}
6074
+ ?disabled=${!!this.approvalRecovery}
5762
6075
  ?require-all=${allSelected}
5763
- ?allow-disabled=${!projection.ok || credentials && !areCredentialsComplete(this.formData)}
6076
+ ?allow-disabled=${!!this.approvalRecovery || !projection.ok || credentials && !areCredentialsComplete(this.formData)}
5764
6077
  @capabilities-allow=${this.onCapabilitiesAllow}
5765
6078
  @capabilities-deny=${this.handleDeny}
5766
6079
  >
6080
+ ${error || this.approvalRecovery ? b2`<div slot="recovery">
6081
+ ${this.renderError()}${!this.error && !this.approvalRecovery && error ? b2`<div class="error-message" role="alert">${error}</div>` : A}
6082
+ </div>` : A}
6083
+ ${this.nativeScopeSelection && (!this.approvalRecovery || this.approvalRecovery.reload) && Number.isSafeInteger(this.requestExpiresAt) && this.requestExpiresAt > 0 ? b2`<p slot="details">
6084
+ Approval request expires at
6085
+ <time datetime=${new Date(this.requestExpiresAt).toISOString()}
6086
+ >${new Date(this.requestExpiresAt).toLocaleString()}</time
6087
+ >.
6088
+ </p>` : A}
5767
6089
  ${this.nativeScopeSelection && this.agentDid ? b2`<div slot="agent-key">${this.renderNativeAgentKey()}</div>` : A}
5768
6090
  ${allSelected ? b2`<div slot="auth">
5769
6091
  <p>
@@ -5902,6 +6224,19 @@ McpConsent.styles = i`
5902
6224
  font-size: 0.875rem;
5903
6225
  }
5904
6226
 
6227
+ .error-message h2 {
6228
+ font: inherit;
6229
+ font-weight: 650;
6230
+ margin: 0 0 0.5rem;
6231
+ }
6232
+ .error-message p {
6233
+ margin: 0.5rem 0;
6234
+ line-height: 1.5;
6235
+ }
6236
+ .error-message small {
6237
+ overflow-wrap: anywhere;
6238
+ }
6239
+
5905
6240
  /* Form fields */
5906
6241
  .form-fields {
5907
6242
  display: flex;
@@ -6074,7 +6409,7 @@ McpConsent.styles = i`
6074
6409
 
6075
6410
  .permission-badge {
6076
6411
  background: var(--_secondary);
6077
- color: #0e2249;
6412
+ color: var(--consent-on-secondary, #0e2249);
6078
6413
  font-family:
6079
6414
  "Geist",
6080
6415
  -apple-system,
@@ -6157,7 +6492,7 @@ McpConsent.styles = i`
6157
6492
  .otp-resend button {
6158
6493
  background: none;
6159
6494
  border: none;
6160
- color: var(--_primary);
6495
+ color: var(--consent-link, var(--_primary));
6161
6496
  cursor: pointer;
6162
6497
  text-decoration: underline;
6163
6498
  }
@@ -6257,6 +6592,12 @@ __decorateClass([
6257
6592
  __decorateClass([
6258
6593
  n4({ type: Boolean, attribute: "native-scope-selection" })
6259
6594
  ], McpConsent.prototype, "nativeScopeSelection", 2);
6595
+ __decorateClass([
6596
+ n4({ type: Number, attribute: "request-expires-at" })
6597
+ ], McpConsent.prototype, "requestExpiresAt", 2);
6598
+ __decorateClass([
6599
+ r5()
6600
+ ], McpConsent.prototype, "approvalRecovery", 2);
6260
6601
  __decorateClass([
6261
6602
  n4({
6262
6603
  type: Array,
@@ -6387,6 +6728,572 @@ __decorateClass([
6387
6728
  McpConsent = __decorateClass([
6388
6729
  t3("mcp-consent")
6389
6730
  ], McpConsent);
6731
+
6732
+ // ../../node_modules/.pnpm/@kya-os+id@0.6.0_@cfworker+json-schema@4.1.1_better-auth@1.7.7_@opentelemetry+api@1.9.0_7249a8d4ac238abc31d023752ef508a4/node_modules/@kya-os/id/dist/base64url.js
6733
+ function bytesToBase64Url(bytes) {
6734
+ let b642;
6735
+ if (typeof Buffer !== "undefined") {
6736
+ b642 = Buffer.from(bytes).toString("base64");
6737
+ } else {
6738
+ let bin = "";
6739
+ for (let i6 = 0; i6 < bytes.length; i6++)
6740
+ bin += String.fromCharCode(bytes[i6]);
6741
+ b642 = btoa(bin);
6742
+ }
6743
+ return b642.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
6744
+ }
6745
+ function base64UrlToBytes(b64url) {
6746
+ const pad = b64url.length % 4;
6747
+ const padded = pad === 2 ? `${b64url}==` : pad === 3 ? `${b64url}=` : pad === 1 ? "" : b64url;
6748
+ const b642 = padded.replace(/-/g, "+").replace(/_/g, "/");
6749
+ if (typeof Buffer !== "undefined") {
6750
+ return new Uint8Array(Buffer.from(b642, "base64"));
6751
+ }
6752
+ const bin = atob(b642);
6753
+ const out = new Uint8Array(bin.length);
6754
+ for (let i6 = 0; i6 < bin.length; i6++)
6755
+ out[i6] = bin.charCodeAt(i6);
6756
+ return out;
6757
+ }
6758
+ function base64UrlToBytesStrict(s4) {
6759
+ if (typeof s4 !== "string")
6760
+ return null;
6761
+ if (!/^[A-Za-z0-9_-]*$/.test(s4) || s4.length % 4 === 1)
6762
+ return null;
6763
+ const bytes = base64UrlToBytes(s4);
6764
+ return bytesToBase64Url(bytes) === s4 ? bytes : null;
6765
+ }
6766
+
6767
+ // ../../node_modules/.pnpm/@kya-os+id@0.6.0_@cfworker+json-schema@4.1.1_better-auth@1.7.7_@opentelemetry+api@1.9.0_7249a8d4ac238abc31d023752ef508a4/node_modules/@kya-os/id/dist/passkey/types.js
6768
+ var PASSKEY_COSE_ALGORITHMS = Object.freeze([
6769
+ -8,
6770
+ -7,
6771
+ -257
6772
+ ]);
6773
+
6774
+ // ../../node_modules/.pnpm/@kya-os+id@0.6.0_@cfworker+json-schema@4.1.1_better-auth@1.7.7_@opentelemetry+api@1.9.0_7249a8d4ac238abc31d023752ef508a4/node_modules/@kya-os/id/dist/wallet/passkey.js
6775
+ var PasskeyCeremonyError = class extends Error {
6776
+ constructor(code, message, options) {
6777
+ super(message, options);
6778
+ __publicField(this, "code");
6779
+ this.name = "PasskeyCeremonyError";
6780
+ this.code = code;
6781
+ }
6782
+ };
6783
+ async function isPasskeySupported() {
6784
+ if (typeof window === "undefined")
6785
+ return false;
6786
+ if (window.isSecureContext === false)
6787
+ return false;
6788
+ if (typeof PublicKeyCredential === "undefined")
6789
+ return false;
6790
+ return credentialsContainer() !== null;
6791
+ }
6792
+ async function createPasskey(o8) {
6793
+ const json = {
6794
+ rp: { id: o8.rpId, name: o8.rpName },
6795
+ user: { id: o8.user.id, name: o8.user.name, displayName: o8.user.displayName },
6796
+ challenge: o8.challenge,
6797
+ pubKeyCredParams: PASSKEY_COSE_ALGORITHMS.map((alg) => ({
6798
+ type: "public-key",
6799
+ alg
6800
+ })),
6801
+ excludeCredentials: (o8.excludeCredentialIds ?? []).map((id) => ({
6802
+ id,
6803
+ type: "public-key"
6804
+ })),
6805
+ authenticatorSelection: {
6806
+ residentKey: "required",
6807
+ requireResidentKey: true,
6808
+ userVerification: "required"
6809
+ },
6810
+ attestation: "none",
6811
+ ...o8.timeoutMs === void 0 ? {} : { timeout: o8.timeoutMs }
6812
+ };
6813
+ const manual = {
6814
+ ...json,
6815
+ user: { ...json.user, id: toBuffer(json.user.id, "user.id") },
6816
+ challenge: toBuffer(json.challenge, "challenge"),
6817
+ excludeCredentials: json.excludeCredentials.map((c4) => ({
6818
+ ...c4,
6819
+ id: toBuffer(c4.id, "excludeCredentialIds[]")
6820
+ }))
6821
+ };
6822
+ const container = requireCredentialsContainer();
6823
+ let credential;
6824
+ try {
6825
+ const parsers = jsonParsers();
6826
+ const publicKey = typeof parsers.parseCreationOptionsFromJSON === "function" ? parsers.parseCreationOptionsFromJSON(json) : manual;
6827
+ credential = await container.create({ publicKey });
6828
+ } catch (err) {
6829
+ throw toCeremonyError(err);
6830
+ }
6831
+ if (!credential) {
6832
+ throw new PasskeyCeremonyError("unknown", "navigator.credentials.create() resolved with no credential");
6833
+ }
6834
+ return registrationToJSON(credential);
6835
+ }
6836
+ async function getPasskeyAssertion(o8) {
6837
+ const json = {
6838
+ challenge: o8.challenge,
6839
+ rpId: o8.rpId,
6840
+ allowCredentials: (o8.allowCredentialIds ?? []).map((id) => ({
6841
+ id,
6842
+ type: "public-key"
6843
+ })),
6844
+ userVerification: "required",
6845
+ ...o8.timeoutMs === void 0 ? {} : { timeout: o8.timeoutMs }
6846
+ };
6847
+ const manual = {
6848
+ ...json,
6849
+ challenge: toBuffer(json.challenge, "challenge"),
6850
+ allowCredentials: json.allowCredentials.map((c4) => ({
6851
+ ...c4,
6852
+ id: toBuffer(c4.id, "allowCredentialIds[]")
6853
+ }))
6854
+ };
6855
+ const container = requireCredentialsContainer();
6856
+ let credential;
6857
+ try {
6858
+ const parsers = jsonParsers();
6859
+ const publicKey = typeof parsers.parseRequestOptionsFromJSON === "function" ? parsers.parseRequestOptionsFromJSON(json) : manual;
6860
+ credential = await container.get({ publicKey });
6861
+ } catch (err) {
6862
+ throw toCeremonyError(err);
6863
+ }
6864
+ if (!credential) {
6865
+ throw new PasskeyCeremonyError("unknown", "navigator.credentials.get() resolved with no credential");
6866
+ }
6867
+ return assertionToJSON(credential);
6868
+ }
6869
+ var CODE_BY_DOM_NAME = {
6870
+ NotAllowedError: "not_allowed",
6871
+ InvalidStateError: "invalid_state",
6872
+ NotSupportedError: "not_supported",
6873
+ // Raised when the authenticator cannot meet a requirement (user
6874
+ // verification, discoverable credential): the same outcome for the caller.
6875
+ ConstraintError: "not_supported",
6876
+ SecurityError: "security",
6877
+ AbortError: "aborted"
6878
+ };
6879
+ var MESSAGE_BY_CODE = {
6880
+ not_allowed: "The passkey ceremony was cancelled, timed out, or found no matching passkey",
6881
+ invalid_state: "This authenticator already holds a passkey for this account",
6882
+ not_supported: "This browser or authenticator cannot create or use a user-verified passkey",
6883
+ security: "The passkey RP ID is not valid for this page's origin",
6884
+ aborted: "The passkey ceremony was aborted",
6885
+ unknown: "The passkey ceremony failed"
6886
+ };
6887
+ function toCeremonyError(err) {
6888
+ const name = typeof err === "object" && err !== null && "name" in err ? String(err.name) : "";
6889
+ const code = CODE_BY_DOM_NAME[name] ?? "unknown";
6890
+ return new PasskeyCeremonyError(code, MESSAGE_BY_CODE[code], { cause: err });
6891
+ }
6892
+ function credentialsContainer() {
6893
+ const container = typeof navigator === "undefined" ? void 0 : navigator.credentials;
6894
+ if (!container || typeof container.create !== "function" || typeof container.get !== "function") {
6895
+ return null;
6896
+ }
6897
+ return container;
6898
+ }
6899
+ function requireCredentialsContainer() {
6900
+ const container = typeof PublicKeyCredential === "undefined" ? null : credentialsContainer();
6901
+ if (!container) {
6902
+ throw new PasskeyCeremonyError("not_supported", "WebAuthn is not available in this runtime");
6903
+ }
6904
+ return container;
6905
+ }
6906
+ function jsonParsers() {
6907
+ return PublicKeyCredential;
6908
+ }
6909
+ function toBuffer(value, field) {
6910
+ const bytes = base64UrlToBytesStrict(value);
6911
+ if (!bytes) {
6912
+ throw new TypeError(`passkey option ${field} must be base64url without padding`);
6913
+ }
6914
+ const out = new ArrayBuffer(bytes.length);
6915
+ new Uint8Array(out).set(bytes);
6916
+ return out;
6917
+ }
6918
+ function b64(buffer) {
6919
+ return bytesToBase64Url(ArrayBuffer.isView(buffer) ? new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength) : new Uint8Array(buffer));
6920
+ }
6921
+ function attachment(credential) {
6922
+ const value = credential.authenticatorAttachment;
6923
+ return value === "platform" || value === "cross-platform" ? { authenticatorAttachment: value } : {};
6924
+ }
6925
+ function extensionResults(credential) {
6926
+ return typeof credential.getClientExtensionResults === "function" ? credential.getClientExtensionResults() : {};
6927
+ }
6928
+ function registrationToJSON(credential) {
6929
+ if (typeof credential.toJSON === "function") {
6930
+ return credential.toJSON();
6931
+ }
6932
+ const response = credential.response;
6933
+ const transports = response.getTransports?.();
6934
+ const publicKeyAlgorithm = response.getPublicKeyAlgorithm?.();
6935
+ const publicKey = response.getPublicKey?.();
6936
+ const authenticatorData = response.getAuthenticatorData?.();
6937
+ return {
6938
+ id: credential.id,
6939
+ rawId: b64(credential.rawId),
6940
+ type: "public-key",
6941
+ response: {
6942
+ clientDataJSON: b64(response.clientDataJSON),
6943
+ attestationObject: b64(response.attestationObject),
6944
+ ...Array.isArray(transports) ? { transports: [...transports] } : {},
6945
+ ...typeof publicKeyAlgorithm === "number" ? { publicKeyAlgorithm } : {},
6946
+ ...publicKey ? { publicKey: b64(publicKey) } : {},
6947
+ ...authenticatorData ? { authenticatorData: b64(authenticatorData) } : {}
6948
+ },
6949
+ clientExtensionResults: extensionResults(credential),
6950
+ ...attachment(credential)
6951
+ };
6952
+ }
6953
+ function assertionToJSON(credential) {
6954
+ if (typeof credential.toJSON === "function") {
6955
+ return credential.toJSON();
6956
+ }
6957
+ const response = credential.response;
6958
+ return {
6959
+ id: credential.id,
6960
+ rawId: b64(credential.rawId),
6961
+ type: "public-key",
6962
+ response: {
6963
+ clientDataJSON: b64(response.clientDataJSON),
6964
+ authenticatorData: b64(response.authenticatorData),
6965
+ signature: b64(response.signature),
6966
+ ...response.userHandle ? { userHandle: b64(response.userHandle) } : {}
6967
+ },
6968
+ clientExtensionResults: extensionResults(credential),
6969
+ ...attachment(credential)
6970
+ };
6971
+ }
6972
+
6973
+ // src/components/consent-passkey.ts
6974
+ var CONSENT_PASSKEY_EVENTS = {
6975
+ /** The ceremony succeeded. Detail: {@link ConsentPasskeyCompleteDetail}. */
6976
+ complete: "consent-passkey:complete",
6977
+ /** The ceremony failed. Detail: {@link ConsentPasskeyErrorDetail}. */
6978
+ error: "consent-passkey:error",
6979
+ /** This browser can't run a ceremony. Detail: {@link ConsentPasskeyUnsupportedDetail}. */
6980
+ unsupported: "consent-passkey:unsupported"
6981
+ };
6982
+ var ERROR_COPY = CONSENT_COPY_TOKENS.passkey.errors;
6983
+ var ConsentPasskey = class extends i4 {
6984
+ constructor() {
6985
+ super(...arguments);
6986
+ this.disabled = false;
6987
+ this.supportResult = null;
6988
+ this.phase = "checking";
6989
+ /** Bumped on every start and every new step, so a stale result is dropped. */
6990
+ this.run = 0;
6991
+ }
6992
+ /**
6993
+ * Whether this browser can run a passkey ceremony: `null` until the
6994
+ * support check answers, then `true` or `false`. It is set before
6995
+ * `consent-passkey:unsupported` fires. That event fires as the element
6996
+ * connects, so a host that attaches listeners later (a React effect, a
6997
+ * late script) reads this instead.
6998
+ */
6999
+ get supported() {
7000
+ return this.supportResult;
7001
+ }
7002
+ connectedCallback() {
7003
+ super.connectedCallback();
7004
+ this.supportCheck ?? (this.supportCheck = this.checkSupport());
7005
+ }
7006
+ willUpdate(changed) {
7007
+ if (changed.has("options") || changed.has("ceremony")) {
7008
+ this.run++;
7009
+ this.errorCode = void 0;
7010
+ if (this.phase === "running" || this.phase === "done") {
7011
+ this.phase = "ready";
7012
+ }
7013
+ }
7014
+ }
7015
+ async checkSupport() {
7016
+ let supported = false;
7017
+ try {
7018
+ supported = await isPasskeySupported();
7019
+ } catch {
7020
+ supported = false;
7021
+ }
7022
+ this.supportResult = supported;
7023
+ if (supported) {
7024
+ if (this.phase === "checking") this.phase = "ready";
7025
+ return;
7026
+ }
7027
+ this.phase = "unsupported";
7028
+ this.emit(
7029
+ CONSENT_PASSKEY_EVENTS.unsupported,
7030
+ { ceremony: this.validCeremony() }
7031
+ );
7032
+ }
7033
+ validCeremony() {
7034
+ const value = this.ceremony;
7035
+ return PASSKEY_CEREMONIES.find((ceremony) => ceremony === value);
7036
+ }
7037
+ canStart() {
7038
+ return this.phase === "ready" && !this.disabled && this.validCeremony() !== void 0 && typeof this.options === "object" && this.options !== null;
7039
+ }
7040
+ /** The button's click handler: the only path that starts a ceremony. */
7041
+ async handleClick() {
7042
+ const ceremony = this.validCeremony();
7043
+ const options = this.options;
7044
+ if (!this.canStart() || ceremony === void 0 || !options) return;
7045
+ const run = ++this.run;
7046
+ this.phase = "running";
7047
+ this.errorCode = void 0;
7048
+ let detail;
7049
+ try {
7050
+ detail = ceremony === "register" ? {
7051
+ ceremony,
7052
+ response: await createPasskey(options)
7053
+ } : {
7054
+ ceremony,
7055
+ response: await getPasskeyAssertion(options)
7056
+ };
7057
+ } catch (error) {
7058
+ if (run !== this.run) return;
7059
+ const failure = toErrorDetail(error);
7060
+ this.phase = "ready";
7061
+ this.errorCode = failure.code;
7062
+ this.emit(
7063
+ CONSENT_PASSKEY_EVENTS.error,
7064
+ failure
7065
+ );
7066
+ return;
7067
+ }
7068
+ if (run !== this.run) return;
7069
+ this.phase = "done";
7070
+ this.emit(
7071
+ CONSENT_PASSKEY_EVENTS.complete,
7072
+ detail
7073
+ );
7074
+ }
7075
+ emit(name, detail) {
7076
+ this.dispatchEvent(
7077
+ new CustomEvent(name, { detail, bubbles: true, composed: true })
7078
+ );
7079
+ }
7080
+ render() {
7081
+ const copy = CONSENT_COPY_TOKENS.passkey;
7082
+ const ceremonyCopy = copy[this.validCeremony() ?? "authenticate"];
7083
+ const showCompatibility = this.config?.showCompatibilityInfo !== false;
7084
+ if (this.phase === "unsupported") {
7085
+ return b2`
7086
+ <div class="container" part="container">
7087
+ <div class="heading">
7088
+ ${renderIcon()}
7089
+ <div>
7090
+ <p class="title" part="title">${copy.unsupportedTitle}</p>
7091
+ <p class="instructions" part="instructions">
7092
+ ${this.config?.unsupportedText || copy.unsupportedText}
7093
+ </p>
7094
+ </div>
7095
+ </div>
7096
+ ${showCompatibility ? b2`<p class="compatibility" part="compatibility">
7097
+ ${copy.compatibilityInfo}
7098
+ </p>` : A}
7099
+ </div>
7100
+ `;
7101
+ }
7102
+ const running = this.phase === "running";
7103
+ const done = this.phase === "done";
7104
+ const status = running ? copy.waiting : this.phase === "checking" ? copy.checking : done ? ceremonyCopy.done : "";
7105
+ const errorCode = this.errorCode;
7106
+ return b2`
7107
+ <div
7108
+ class="container"
7109
+ part="container"
7110
+ aria-busy=${running ? "true" : "false"}
7111
+ >
7112
+ <div class="heading">
7113
+ ${renderIcon()}
7114
+ <div>
7115
+ <p class="title" part="title">${ceremonyCopy.title}</p>
7116
+ <p class="instructions" part="instructions">
7117
+ ${this.config?.instructions || ceremonyCopy.instructions}
7118
+ </p>
7119
+ </div>
7120
+ </div>
7121
+ <button
7122
+ part="button"
7123
+ type="button"
7124
+ ?disabled=${!this.canStart()}
7125
+ @click=${this.handleClick}
7126
+ >
7127
+ ${this.config?.buttonText || ceremonyCopy.button}
7128
+ </button>
7129
+ <p class="status" part="status" role="status" aria-live="polite">
7130
+ ${status}
7131
+ </p>
7132
+ ${errorCode ? b2`<p class="error" part="error" role="alert">
7133
+ ${ERROR_COPY[errorCode]}
7134
+ </p>` : A}
7135
+ ${errorCode === "not_supported" && showCompatibility ? b2`<p class="compatibility" part="compatibility">
7136
+ ${copy.compatibilityInfo}
7137
+ </p>` : A}
7138
+ </div>
7139
+ `;
7140
+ }
7141
+ };
7142
+ ConsentPasskey.styles = i`
7143
+ :host {
7144
+ display: block;
7145
+ color: var(--cs-text-primary, #0f172a);
7146
+ font-family: inherit;
7147
+ }
7148
+
7149
+ .container {
7150
+ display: flex;
7151
+ flex-direction: column;
7152
+ gap: 12px;
7153
+ padding: 16px;
7154
+ border-radius: 12px;
7155
+ border: 1px solid var(--cs-surface-border, rgba(15, 23, 42, 0.1));
7156
+ background: var(--cs-surface-card, #ffffff);
7157
+ }
7158
+
7159
+ .heading {
7160
+ display: flex;
7161
+ align-items: flex-start;
7162
+ gap: 12px;
7163
+ }
7164
+
7165
+ .icon {
7166
+ width: 36px;
7167
+ height: 36px;
7168
+ flex-shrink: 0;
7169
+ padding: 8px;
7170
+ box-sizing: border-box;
7171
+ border-radius: 10px;
7172
+ background: var(--cs-surface-inset, #f1ece2);
7173
+ color: var(--cs-text-secondary, #334155);
7174
+ }
7175
+
7176
+ .title {
7177
+ margin: 0;
7178
+ font-size: 15px;
7179
+ font-weight: 600;
7180
+ line-height: 1.4;
7181
+ }
7182
+
7183
+ .instructions {
7184
+ margin: 2px 0 0;
7185
+ font-size: 13.5px;
7186
+ line-height: 1.5;
7187
+ color: var(--cs-text-secondary, #334155);
7188
+ }
7189
+
7190
+ button {
7191
+ width: 100%;
7192
+ padding: 14px 18px;
7193
+ border: none;
7194
+ border-radius: 999px;
7195
+ min-height: var(--cs-action-min-height, 0px);
7196
+ background: var(--cs-surface-accent, #0f172a);
7197
+ color: var(--cs-surface-accent-text, #ffffff);
7198
+ font-size: var(--cs-action-font-size, 15px);
7199
+ font-weight: 500;
7200
+ font-family: inherit;
7201
+ cursor: pointer;
7202
+ transition: opacity 0.15s ease;
7203
+ }
7204
+
7205
+ button:hover:not(:disabled) {
7206
+ opacity: 0.92;
7207
+ }
7208
+
7209
+ button:disabled {
7210
+ opacity: 0.5;
7211
+ cursor: not-allowed;
7212
+ }
7213
+
7214
+ button:focus-visible {
7215
+ outline: 2px solid var(--cs-focus-ring, #0f172a);
7216
+ outline-offset: 3px;
7217
+ }
7218
+
7219
+ .status {
7220
+ margin: 0;
7221
+ min-height: 1em;
7222
+ font-size: 12.5px;
7223
+ color: var(--cs-text-tertiary, #64748b);
7224
+ }
7225
+
7226
+ .status:empty {
7227
+ display: none;
7228
+ }
7229
+
7230
+ .error {
7231
+ margin: 0;
7232
+ padding: 10px 12px;
7233
+ border-radius: 10px;
7234
+ background: var(--cs-chip-risk-bg, #fce7b6);
7235
+ color: var(--cs-chip-risk-text, #7a4f00);
7236
+ font-size: 13px;
7237
+ line-height: 1.45;
7238
+ }
7239
+
7240
+ .compatibility {
7241
+ margin: 0;
7242
+ font-size: 12.5px;
7243
+ line-height: 1.5;
7244
+ color: var(--cs-text-tertiary, #64748b);
7245
+ }
7246
+ `;
7247
+ __decorateClass([
7248
+ n4({ type: String, reflect: true })
7249
+ ], ConsentPasskey.prototype, "ceremony", 2);
7250
+ __decorateClass([
7251
+ n4({ attribute: false })
7252
+ ], ConsentPasskey.prototype, "options", 2);
7253
+ __decorateClass([
7254
+ n4({ attribute: false })
7255
+ ], ConsentPasskey.prototype, "config", 2);
7256
+ __decorateClass([
7257
+ n4({ type: Boolean, reflect: true })
7258
+ ], ConsentPasskey.prototype, "disabled", 2);
7259
+ __decorateClass([
7260
+ r5()
7261
+ ], ConsentPasskey.prototype, "supportResult", 2);
7262
+ __decorateClass([
7263
+ r5()
7264
+ ], ConsentPasskey.prototype, "phase", 2);
7265
+ __decorateClass([
7266
+ r5()
7267
+ ], ConsentPasskey.prototype, "errorCode", 2);
7268
+ ConsentPasskey = __decorateClass([
7269
+ t3("consent-passkey")
7270
+ ], ConsentPasskey);
7271
+ function toErrorDetail(error) {
7272
+ if (error instanceof PasskeyCeremonyError) {
7273
+ return { code: error.code, message: error.message };
7274
+ }
7275
+ return {
7276
+ code: "unknown",
7277
+ message: error instanceof Error ? error.message : String(error)
7278
+ };
7279
+ }
7280
+ function renderIcon() {
7281
+ return b2`
7282
+ <svg
7283
+ class="icon"
7284
+ viewBox="0 0 24 24"
7285
+ fill="none"
7286
+ stroke="currentColor"
7287
+ stroke-width="1.6"
7288
+ stroke-linecap="round"
7289
+ stroke-linejoin="round"
7290
+ aria-hidden="true"
7291
+ >
7292
+ <circle cx="8" cy="9" r="4" />
7293
+ <path d="M11 12.5 20 21.5M16.5 18l2-2M14.5 16l2-2" />
7294
+ </svg>
7295
+ `;
7296
+ }
6390
7297
  export {
6391
7298
  CONSENT_CAPABILITIES_FEATURES,
6392
7299
  ConsentActionBar,
@@ -6400,6 +7307,7 @@ export {
6400
7307
  ConsentInput,
6401
7308
  ConsentOAuthButton,
6402
7309
  ConsentOTPInput,
7310
+ ConsentPasskey,
6403
7311
  ConsentPermissions,
6404
7312
  ConsentRevocationNotice,
6405
7313
  ConsentShell,