@kya-os/consent 0.2.1 → 0.2.3

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 (132) hide show
  1. package/README.md +128 -0
  2. package/dist/bundle/index.d.ts +38 -36
  3. package/dist/bundle/index.d.ts.map +1 -1
  4. package/dist/bundle/index.js +35 -33
  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/bundle/shell.d.ts +7 -0
  10. package/dist/bundle/shell.d.ts.map +1 -1
  11. package/dist/bundle/shell.js +5 -0
  12. package/dist/bundle/shell.js.map +1 -1
  13. package/dist/cjs/bundle/index.js +4 -1
  14. package/dist/cjs/bundle/index.js.map +1 -1
  15. package/dist/cjs/bundle/inline.js +4 -4
  16. package/dist/cjs/bundle/inline.js.map +1 -1
  17. package/dist/cjs/bundle/shell.js +5 -0
  18. package/dist/cjs/bundle/shell.js.map +1 -1
  19. package/dist/cjs/components/consent-agent-header.js +15 -9
  20. package/dist/cjs/components/consent-agent-header.js.map +1 -1
  21. package/dist/cjs/components/consent-capabilities-screen.js +40 -78
  22. package/dist/cjs/components/consent-capabilities-screen.js.map +1 -1
  23. package/dist/cjs/components/consent-headline.js +138 -0
  24. package/dist/cjs/components/consent-headline.js.map +1 -0
  25. package/dist/cjs/components/consent-otp-input.js +35 -18
  26. package/dist/cjs/components/consent-otp-input.js.map +1 -1
  27. package/dist/cjs/components/index.js +3 -1
  28. package/dist/cjs/components/index.js.map +1 -1
  29. package/dist/cjs/components/mcp-consent.js +42 -1
  30. package/dist/cjs/components/mcp-consent.js.map +1 -1
  31. package/dist/cjs/copy/tokens.js +16 -1
  32. package/dist/cjs/copy/tokens.js.map +1 -1
  33. package/dist/cjs/identity/agent-identity.js +314 -0
  34. package/dist/cjs/identity/agent-identity.js.map +1 -0
  35. package/dist/cjs/identity/documents.js +212 -0
  36. package/dist/cjs/identity/documents.js.map +1 -0
  37. package/dist/cjs/identity/entity-card.js +128 -0
  38. package/dist/cjs/identity/entity-card.js.map +1 -0
  39. package/dist/cjs/identity/index.js +31 -0
  40. package/dist/cjs/identity/index.js.map +1 -0
  41. package/dist/cjs/identity/resolve.js +122 -0
  42. package/dist/cjs/identity/resolve.js.map +1 -0
  43. package/dist/cjs/identity/schemas.js +88 -0
  44. package/dist/cjs/identity/schemas.js.map +1 -0
  45. package/dist/cjs/index.js +3 -1
  46. package/dist/cjs/index.js.map +1 -1
  47. package/dist/cjs/mcp-app/inline.js +2 -2
  48. package/dist/cjs/mcp-app/inline.js.map +1 -1
  49. package/dist/cjs/mcp-app/types.js +1 -1
  50. package/dist/cjs/popup/launcher.js +3 -3
  51. package/dist/cjs/react/index.js +141 -25
  52. package/dist/cjs/react/index.js.map +1 -1
  53. package/dist/cjs/templates/index.js +1 -1
  54. package/dist/cjs/types/index.js +1 -1
  55. package/dist/components/consent-agent-header.d.ts +3 -1
  56. package/dist/components/consent-agent-header.d.ts.map +1 -1
  57. package/dist/components/consent-agent-header.js +15 -9
  58. package/dist/components/consent-agent-header.js.map +1 -1
  59. package/dist/components/consent-capabilities-screen.d.ts +13 -3
  60. package/dist/components/consent-capabilities-screen.d.ts.map +1 -1
  61. package/dist/components/consent-capabilities-screen.js +40 -78
  62. package/dist/components/consent-capabilities-screen.js.map +1 -1
  63. package/dist/components/consent-headline.d.ts +42 -0
  64. package/dist/components/consent-headline.d.ts.map +1 -0
  65. package/dist/components/consent-headline.js +135 -0
  66. package/dist/components/consent-headline.js.map +1 -0
  67. package/dist/components/consent-otp-input.d.ts +7 -2
  68. package/dist/components/consent-otp-input.d.ts.map +1 -1
  69. package/dist/components/consent-otp-input.js +35 -18
  70. package/dist/components/consent-otp-input.js.map +1 -1
  71. package/dist/components/index.d.ts +18 -17
  72. package/dist/components/index.d.ts.map +1 -1
  73. package/dist/components/index.js +18 -17
  74. package/dist/components/index.js.map +1 -1
  75. package/dist/components/mcp-consent.d.ts +16 -0
  76. package/dist/components/mcp-consent.d.ts.map +1 -1
  77. package/dist/components/mcp-consent.js +42 -1
  78. package/dist/components/mcp-consent.js.map +1 -1
  79. package/dist/consent.js +493 -100
  80. package/dist/consent.min.js +244 -232
  81. package/dist/copy/tokens.d.ts +16 -1
  82. package/dist/copy/tokens.d.ts.map +1 -1
  83. package/dist/copy/tokens.js +16 -1
  84. package/dist/copy/tokens.js.map +1 -1
  85. package/dist/identity/agent-identity.d.ts +199 -0
  86. package/dist/identity/agent-identity.d.ts.map +1 -0
  87. package/dist/identity/agent-identity.js +305 -0
  88. package/dist/identity/agent-identity.js.map +1 -0
  89. package/dist/identity/documents.d.ts +63 -0
  90. package/dist/identity/documents.d.ts.map +1 -0
  91. package/dist/identity/documents.js +206 -0
  92. package/dist/identity/documents.js.map +1 -0
  93. package/dist/identity/entity-card.d.ts +80 -0
  94. package/dist/identity/entity-card.d.ts.map +1 -0
  95. package/dist/identity/entity-card.js +119 -0
  96. package/dist/identity/entity-card.js.map +1 -0
  97. package/dist/identity/index.d.ts +15 -0
  98. package/dist/identity/index.d.ts.map +1 -0
  99. package/dist/identity/index.js +15 -0
  100. package/dist/identity/index.js.map +1 -0
  101. package/dist/identity/resolve.d.ts +31 -0
  102. package/dist/identity/resolve.d.ts.map +1 -0
  103. package/dist/identity/resolve.js +119 -0
  104. package/dist/identity/resolve.js.map +1 -0
  105. package/dist/identity/schemas.d.ts +404 -0
  106. package/dist/identity/schemas.d.ts.map +1 -0
  107. package/dist/identity/schemas.js +84 -0
  108. package/dist/identity/schemas.js.map +1 -0
  109. package/dist/index.d.ts +2 -1
  110. package/dist/index.d.ts.map +1 -1
  111. package/dist/index.js +3 -1
  112. package/dist/index.js.map +1 -1
  113. package/dist/kya-os/index.d.ts +55 -0
  114. package/dist/kya-os/index.d.ts.map +1 -0
  115. package/dist/kya-os/index.js +235 -0
  116. package/dist/kya-os/index.js.map +1 -0
  117. package/dist/mcp-app/inline.d.ts.map +1 -1
  118. package/dist/mcp-app/inline.js +2 -2
  119. package/dist/mcp-app/inline.js.map +1 -1
  120. package/dist/mcp-app/types.d.ts +1 -1
  121. package/dist/mcp-app/types.js +1 -1
  122. package/dist/popup/launcher.d.ts +3 -3
  123. package/dist/popup/launcher.js +3 -3
  124. package/dist/react/index.d.ts +108 -22
  125. package/dist/react/index.d.ts.map +1 -1
  126. package/dist/react/index.js +151 -35
  127. package/dist/react/index.js.map +1 -1
  128. package/dist/templates/index.d.ts +1 -1
  129. package/dist/templates/index.js +1 -1
  130. package/dist/types/index.d.ts +1 -1
  131. package/dist/types/index.js +1 -1
  132. package/package.json +41 -6
package/dist/consent.js CHANGED
@@ -2640,18 +2640,15 @@ var ConsentOTPInput = class extends i4 {
2640
2640
  }
2641
2641
  handleKeyDown(index, e8) {
2642
2642
  switch (e8.key) {
2643
- case "Backspace":
2644
- if (!this.digits[index] && index > 0) {
2645
- e8.preventDefault();
2646
- this.inputs[index - 1]?.focus();
2647
- this.digits[index - 1] = "";
2648
- this.digits = [...this.digits];
2649
- } else {
2650
- this.digits[index] = "";
2651
- this.digits = [...this.digits];
2643
+ case "Backspace": {
2644
+ e8.preventDefault();
2645
+ const target = !this.digits[index] && index > 0 ? index - 1 : index;
2646
+ if (target !== index) {
2647
+ this.inputs[target]?.focus();
2652
2648
  }
2653
- this.value = this.getFullValue();
2649
+ this.clearDigit(target);
2654
2650
  break;
2651
+ }
2655
2652
  case "ArrowLeft":
2656
2653
  e8.preventDefault();
2657
2654
  if (index > 0) {
@@ -2665,12 +2662,36 @@ var ConsentOTPInput = class extends i4 {
2665
2662
  }
2666
2663
  break;
2667
2664
  case "Delete":
2668
- this.digits[index] = "";
2669
- this.digits = [...this.digits];
2670
- this.value = this.getFullValue();
2665
+ e8.preventDefault();
2666
+ this.clearDigit(index);
2671
2667
  break;
2672
2668
  }
2673
2669
  }
2670
+ /**
2671
+ * Clear one digit and report the new value. A page that enables a button
2672
+ * once the code is complete relies on this to disable it again.
2673
+ */
2674
+ clearDigit(index) {
2675
+ if (!this.digits[index]) return;
2676
+ this.digits[index] = "";
2677
+ this.digits = [...this.digits];
2678
+ const fullValue = this.getFullValue();
2679
+ this.value = fullValue;
2680
+ this.dispatchEvent(
2681
+ new CustomEvent("input", {
2682
+ detail: { value: fullValue, index, digit: "" },
2683
+ bubbles: true,
2684
+ composed: true
2685
+ })
2686
+ );
2687
+ this.dispatchEvent(
2688
+ new CustomEvent("change", {
2689
+ detail: { value: fullValue },
2690
+ bubbles: true,
2691
+ composed: true
2692
+ })
2693
+ );
2694
+ }
2674
2695
  handlePaste(e8) {
2675
2696
  e8.preventDefault();
2676
2697
  const pastedData = e8.clipboardData?.getData("text") || "";
@@ -2730,7 +2751,7 @@ var ConsentOTPInput = class extends i4 {
2730
2751
  }
2731
2752
  renderDigitInput(index) {
2732
2753
  const digit = this.digits[index] || "";
2733
- const isFilled = digit !== "";
2754
+ const isFilled2 = digit !== "";
2734
2755
  return b2`
2735
2756
  <input
2736
2757
  part="input"
@@ -2741,7 +2762,7 @@ var ConsentOTPInput = class extends i4 {
2741
2762
  .value=${digit}
2742
2763
  ?disabled=${this.disabled}
2743
2764
  placeholder="○"
2744
- class=${isFilled ? "filled" : ""}
2765
+ class=${isFilled2 ? "filled" : ""}
2745
2766
  @input=${(e8) => this.handleInput(index, e8)}
2746
2767
  @keydown=${(e8) => this.handleKeyDown(index, e8)}
2747
2768
  @paste=${this.handlePaste}
@@ -2901,7 +2922,22 @@ var CONSENT_COPY_TOKENS = {
2901
2922
  * names the client, it does not verify it.
2902
2923
  */
2903
2924
  domainPillPrefix: "Identified by",
2904
- /** `{Vendor}` → vendor name. `{Surface}` → surface label. */
2925
+ /**
2926
+ * The meta line under the agent's name is built from the parts that are
2927
+ * known, joined by `metaSeparator`: an unknown vendor or surface is left
2928
+ * out rather than filled with a placeholder.
2929
+ *
2930
+ * `{Vendor}` → vendor name.
2931
+ */
2932
+ madeBy: "Made by {Vendor}",
2933
+ /** `{Surface}` → surface label, e.g. "Mac". */
2934
+ askingFrom: "Asking from your {Surface}",
2935
+ metaSeparator: " \xB7 ",
2936
+ /**
2937
+ * @deprecated The header no longer uses this: it can't leave out an
2938
+ * unknown vendor or surface. Use `madeBy`, `askingFrom` and
2939
+ * `metaSeparator`.
2940
+ */
2905
2941
  metaTemplate: "Made by {Vendor} \xB7 Asking from your {Surface} \xB7 {Connected}",
2906
2942
  connectedJustNow: "Connected just now",
2907
2943
  /** `{Minutes}` → minutes since connection. */
@@ -3039,15 +3075,17 @@ var ConsentAgentHeader = class extends i4 {
3039
3075
  Minutes: minutes
3040
3076
  });
3041
3077
  }
3078
+ /** Only the parts that are known: an unknown vendor or surface is left out. */
3042
3079
  renderMeta() {
3043
- if (!this.vendor && !this.surfaceLabel) {
3044
- return this.renderConnectedFragment();
3045
- }
3046
- return formatToken(CONSENT_COPY_TOKENS.agentTile.metaTemplate, {
3047
- Vendor: this.vendor || "\u2014",
3048
- Surface: this.surfaceLabel || "this device",
3049
- Connected: this.renderConnectedFragment()
3050
- });
3080
+ const tokens = CONSENT_COPY_TOKENS.agentTile;
3081
+ const known = (value) => typeof value === "string" ? value.trim() : "";
3082
+ const vendor = known(this.vendor);
3083
+ const surface = known(this.surfaceLabel);
3084
+ return [
3085
+ vendor && formatToken(tokens.madeBy, { Vendor: vendor }),
3086
+ surface && formatToken(tokens.askingFrom, { Surface: surface }),
3087
+ this.renderConnectedFragment()
3088
+ ].filter(Boolean).join(tokens.metaSeparator);
3051
3089
  }
3052
3090
  renderPill() {
3053
3091
  const tokens = CONSENT_COPY_TOKENS.agentTile;
@@ -3244,6 +3282,101 @@ ConsentAgentHeader = __decorateClass([
3244
3282
  t3("consent-agent-header")
3245
3283
  ], ConsentAgentHeader);
3246
3284
 
3285
+ // src/components/consent-headline.ts
3286
+ var PLACEHOLDER = /(\{Agent\}|\{Verb\}|\{Org\})/;
3287
+ var ConsentHeadline = class extends i4 {
3288
+ constructor() {
3289
+ super(...arguments);
3290
+ this.agentName = "";
3291
+ this.orgName = "";
3292
+ this.verb = "";
3293
+ this.description = "";
3294
+ this.eyebrow = "";
3295
+ }
3296
+ render() {
3297
+ const tokens = CONSENT_COPY_TOKENS;
3298
+ const subhead = this.description.trim() || formatToken(tokens.subhead.template, {
3299
+ Agent: this.agentName.trim() || "this agent"
3300
+ });
3301
+ return b2`
3302
+ <span class="eyebrow" part="eyebrow"
3303
+ >${this.eyebrow.trim() || tokens.eyebrow.permissionRequest}</span
3304
+ >
3305
+ <h1 class="headline" part="headline">${this.headlinePieces()}</h1>
3306
+ <p class="subhead" part="subhead">${subhead}</p>
3307
+ `;
3308
+ }
3309
+ /** The headline, with each name as text in its own `em`. */
3310
+ headlinePieces() {
3311
+ const tokens = CONSENT_COPY_TOKENS;
3312
+ const verb = this.verb.trim();
3313
+ const template = verb && verb !== "use" ? tokens.headline.template : tokens.headline.fallbackTemplate;
3314
+ const agent = this.agentName.trim() || "An assistant";
3315
+ const org = this.orgName.trim() || "this site";
3316
+ return template.split(PLACEHOLDER).map((piece) => {
3317
+ if (piece === "{Agent}") return b2`<em>${agent}</em>`;
3318
+ if (piece === "{Org}") return b2`<em>${org}</em>`;
3319
+ if (piece === "{Verb}") return verb;
3320
+ return piece;
3321
+ });
3322
+ }
3323
+ };
3324
+ ConsentHeadline.styles = i`
3325
+ :host {
3326
+ display: flex;
3327
+ flex-direction: column;
3328
+ gap: var(--cs-card-gap, 22px);
3329
+ min-width: 0;
3330
+ }
3331
+
3332
+ .eyebrow {
3333
+ font-size: 11px;
3334
+ letter-spacing: 0.16em;
3335
+ font-weight: 600;
3336
+ color: var(--cs-text-tertiary, #64748b);
3337
+ text-transform: uppercase;
3338
+ }
3339
+
3340
+ .headline {
3341
+ font-family: "Times New Roman", Georgia, serif;
3342
+ font-size: var(--cs-headline-font-size, clamp(24px, 5vw, 30px));
3343
+ line-height: 1.18;
3344
+ letter-spacing: -0.01em;
3345
+ color: var(--cs-text-primary, #0f172a);
3346
+ margin: 0;
3347
+ overflow-wrap: anywhere;
3348
+ }
3349
+
3350
+ .headline em {
3351
+ font-style: italic;
3352
+ }
3353
+
3354
+ .subhead {
3355
+ font-size: var(--cs-subhead-font-size, 14.5px);
3356
+ color: var(--cs-text-secondary, #334155);
3357
+ line-height: 1.55;
3358
+ margin: 0;
3359
+ }
3360
+ `;
3361
+ __decorateClass([
3362
+ n4({ type: String, attribute: "agent-name" })
3363
+ ], ConsentHeadline.prototype, "agentName", 2);
3364
+ __decorateClass([
3365
+ n4({ type: String, attribute: "org-name" })
3366
+ ], ConsentHeadline.prototype, "orgName", 2);
3367
+ __decorateClass([
3368
+ n4({ type: String })
3369
+ ], ConsentHeadline.prototype, "verb", 2);
3370
+ __decorateClass([
3371
+ n4({ type: String })
3372
+ ], ConsentHeadline.prototype, "description", 2);
3373
+ __decorateClass([
3374
+ n4({ type: String })
3375
+ ], ConsentHeadline.prototype, "eyebrow", 2);
3376
+ ConsentHeadline = __decorateClass([
3377
+ t3("consent-headline")
3378
+ ], ConsentHeadline);
3379
+
3247
3380
  // src/cedar/explain.ts
3248
3381
  var ACTION_SINGLE = /action\s*==\s*Action::"([^"]+)"/g;
3249
3382
  var ACTION_LIST = /action\s+in\s*\[([^\]]+)\]/g;
@@ -4417,6 +4550,267 @@ function camelToKebab(value) {
4417
4550
  return value.replace(/[A-Z]/g, (c4) => `-${c4.toLowerCase()}`);
4418
4551
  }
4419
4552
 
4553
+ // src/identity/entity-card.ts
4554
+ var ENTITY_TYPES = [
4555
+ "mcp",
4556
+ "agent",
4557
+ "client",
4558
+ "verifier",
4559
+ "human"
4560
+ ];
4561
+ var ENTITY_DID_PATTERN = /^did:(key|web):.+$/;
4562
+ var DID_WEB_PREFIX = "did:web:";
4563
+ function didWebHost(did) {
4564
+ if (!did.startsWith(DID_WEB_PREFIX)) return null;
4565
+ const authority = did.slice(DID_WEB_PREFIX.length).split(":")[0] ?? "";
4566
+ let host;
4567
+ try {
4568
+ host = decodeURIComponent(authority);
4569
+ } catch {
4570
+ return null;
4571
+ }
4572
+ if (!host || /[/?#@\\\s]/.test(host)) return null;
4573
+ return hostOf(`https://${host}`);
4574
+ }
4575
+ function httpsHost(url) {
4576
+ return hostOf(url);
4577
+ }
4578
+ function hostOf(url) {
4579
+ let parsed;
4580
+ try {
4581
+ parsed = new URL(url);
4582
+ } catch {
4583
+ return null;
4584
+ }
4585
+ if (parsed.protocol !== "https:" || !parsed.host) return null;
4586
+ if (parsed.username || parsed.password) return null;
4587
+ return parsed.host.toLowerCase();
4588
+ }
4589
+ function sameDid(a3, b3) {
4590
+ return a3 === b3 || canonicalDid(a3) === canonicalDid(b3);
4591
+ }
4592
+ function canonicalDid(did) {
4593
+ if (!did.startsWith(DID_WEB_PREFIX)) return did;
4594
+ try {
4595
+ const [host = "", ...path] = did.slice(DID_WEB_PREFIX.length).split(":").map(decodeURIComponent);
4596
+ return `${DID_WEB_PREFIX}${[host.toLowerCase(), ...path].map(encodeURIComponent).join(":")}`;
4597
+ } catch {
4598
+ return did;
4599
+ }
4600
+ }
4601
+ function cardDomain(card) {
4602
+ const didHost = didWebHost(card.id);
4603
+ if (!card.cimd) return didHost;
4604
+ const clientHost = httpsHost(card.cimd.clientId);
4605
+ if (!clientHost) return null;
4606
+ if (didHost !== null && didHost !== clientHost) return null;
4607
+ return clientHost;
4608
+ }
4609
+
4610
+ // src/identity/agent-identity.ts
4611
+ var CONFORMANCE_LEVELS = ["L1", "L2", "L3"];
4612
+ var KEY_PROOF_METHODS = ["holder-proof", "cimd-key"];
4613
+ var MAX_VERIFICATION_REASON = 300;
4614
+ var MAX_DID_LENGTH = 500;
4615
+ var TILE_LIMITS = { name: 80, vendor: 80, surfaceLabel: 40 };
4616
+ var AgentIdentityError = class extends Error {
4617
+ constructor(message) {
4618
+ super(message);
4619
+ this.name = "AgentIdentityError";
4620
+ }
4621
+ };
4622
+ function bindVerification(card, verification) {
4623
+ if (verification === void 0) {
4624
+ return { status: "unverified", reason: "not_checked" };
4625
+ }
4626
+ const meta = verificationMeta(verification);
4627
+ if (verification.status === "verified") {
4628
+ if (sameDid(verification.did, card.id)) return verification;
4629
+ return {
4630
+ status: "unverified",
4631
+ reason: limitReason(
4632
+ `verified ${verification.did}, not this card's ${card.id}`
4633
+ ),
4634
+ ...meta
4635
+ };
4636
+ }
4637
+ if (verification.status === "domain") {
4638
+ const domain = cardDomain(card);
4639
+ if (domain !== null && verification.domain.trim().toLowerCase() === domain) {
4640
+ return { status: "domain", domain, ...meta };
4641
+ }
4642
+ return {
4643
+ status: "unverified",
4644
+ reason: limitReason(`${verification.domain} is not this card's domain`),
4645
+ ...meta
4646
+ };
4647
+ }
4648
+ return verification;
4649
+ }
4650
+ function agentMetadataFromIdentity(identity) {
4651
+ const read = readAgentIdentity(identity);
4652
+ const bound = bindVerification(read.card, read.verification);
4653
+ const verification = bound.status;
4654
+ const metadata = {
4655
+ name: read.card.name,
4656
+ did: read.card.id,
4657
+ verification
4658
+ };
4659
+ if (bound.status === "domain") metadata.domain = bound.domain;
4660
+ if (read.vendor !== void 0) metadata.vendor = read.vendor;
4661
+ if (read.surfaceLabel !== void 0)
4662
+ metadata.surfaceLabel = read.surfaceLabel;
4663
+ if (read.logoUrl !== void 0) metadata.logoUrl = read.logoUrl;
4664
+ if (read.connectedAt !== void 0) metadata.connectedAt = read.connectedAt;
4665
+ return metadata;
4666
+ }
4667
+ function readAgentIdentity(value) {
4668
+ if (!isRecord(value)) fail("", "An agent identity is an object");
4669
+ const card = readCard(value.card);
4670
+ const identity = { card };
4671
+ if (value.verification !== void 0) {
4672
+ identity.verification = readVerification(value.verification);
4673
+ }
4674
+ if (typeof value.vendor === "string") {
4675
+ identity.vendor = fit(value.vendor, TILE_LIMITS.vendor);
4676
+ }
4677
+ if (typeof value.surfaceLabel === "string") {
4678
+ identity.surfaceLabel = fit(value.surfaceLabel, TILE_LIMITS.surfaceLabel);
4679
+ }
4680
+ if (typeof value.logoUrl === "string" && isUrl(value.logoUrl)) {
4681
+ identity.logoUrl = value.logoUrl;
4682
+ }
4683
+ if (typeof value.connectedAt === "string") {
4684
+ identity.connectedAt = value.connectedAt;
4685
+ }
4686
+ return identity;
4687
+ }
4688
+ function readCard(value) {
4689
+ if (!isRecord(value)) fail("card", "Required");
4690
+ if (!isEntityDid(value.id)) {
4691
+ fail(
4692
+ "card.id",
4693
+ `Must be a did:key or did:web DID of at most ${MAX_DID_LENGTH} characters`
4694
+ );
4695
+ }
4696
+ if (!ENTITY_TYPES.includes(value.entityType)) {
4697
+ fail("card.entityType", `Must be one of ${ENTITY_TYPES.join(", ")}`);
4698
+ }
4699
+ if (typeof value.name !== "string" || value.name.trim() === "") {
4700
+ fail("card.name", "Required");
4701
+ }
4702
+ if (value.cimd !== void 0) {
4703
+ const cimd = value.cimd;
4704
+ if (!isRecord(cimd) || !isFilled(cimd.clientId) || !isFilled(cimd.jwksUri)) {
4705
+ fail("card.cimd", "Must name a clientId and a jwksUri");
4706
+ }
4707
+ }
4708
+ return {
4709
+ ...value,
4710
+ name: fit(value.name, TILE_LIMITS.name)
4711
+ };
4712
+ }
4713
+ function readVerification(value) {
4714
+ if (!isRecord(value)) fail("verification", "Must be an object");
4715
+ const meta = {};
4716
+ if (value.verifier !== void 0) {
4717
+ if (!isFilled(value.verifier))
4718
+ fail("verification.verifier", "Must be a string");
4719
+ meta.verifier = value.verifier;
4720
+ }
4721
+ if (value.checkedAt !== void 0) {
4722
+ if (!isFilled(value.checkedAt))
4723
+ fail("verification.checkedAt", "Must be a string");
4724
+ meta.checkedAt = value.checkedAt;
4725
+ }
4726
+ switch (value.status) {
4727
+ case "verified": {
4728
+ if (!isEntityDid(value.did)) {
4729
+ fail("verification.did", "Must be a did:key or did:web DID");
4730
+ }
4731
+ if (!KEY_PROOF_METHODS.includes(value.method)) {
4732
+ fail(
4733
+ "verification.method",
4734
+ `Must be one of ${KEY_PROOF_METHODS.join(", ")}`
4735
+ );
4736
+ }
4737
+ const level = value.conformanceLevel;
4738
+ if (level !== void 0 && !CONFORMANCE_LEVELS.includes(level)) {
4739
+ fail(
4740
+ "verification.conformanceLevel",
4741
+ `Must be one of ${CONFORMANCE_LEVELS.join(", ")}`
4742
+ );
4743
+ }
4744
+ return {
4745
+ status: "verified",
4746
+ did: value.did,
4747
+ method: value.method,
4748
+ ...level !== void 0 ? { conformanceLevel: level } : {},
4749
+ ...meta
4750
+ };
4751
+ }
4752
+ case "domain":
4753
+ if (!isFilled(value.domain)) fail("verification.domain", "Required");
4754
+ return { status: "domain", domain: value.domain, ...meta };
4755
+ case "unverified":
4756
+ if (value.reason !== void 0 && typeof value.reason !== "string") {
4757
+ fail("verification.reason", "Must be a string");
4758
+ }
4759
+ return {
4760
+ status: "unverified",
4761
+ ...typeof value.reason === "string" ? { reason: limitReason(value.reason) } : {},
4762
+ ...meta
4763
+ };
4764
+ default:
4765
+ return fail(
4766
+ "verification.status",
4767
+ "Must be verified, domain or unverified"
4768
+ );
4769
+ }
4770
+ }
4771
+ function limitReason(reason) {
4772
+ return fit(reason, MAX_VERIFICATION_REASON);
4773
+ }
4774
+ function fit(text, max) {
4775
+ if (text.length <= max) return text;
4776
+ let cut = "";
4777
+ for (const char of text) {
4778
+ if (cut.length + char.length + 1 > max) break;
4779
+ cut += char;
4780
+ }
4781
+ return `${cut}\u2026`;
4782
+ }
4783
+ function fail(path, message) {
4784
+ throw new AgentIdentityError(
4785
+ `agentIdentity: ${path ? `${path}: ` : ""}${message}`
4786
+ );
4787
+ }
4788
+ function isEntityDid(value) {
4789
+ return typeof value === "string" && value.length <= MAX_DID_LENGTH && ENTITY_DID_PATTERN.test(value);
4790
+ }
4791
+ function isFilled(value) {
4792
+ return typeof value === "string" && value.length > 0;
4793
+ }
4794
+ function isUrl(value) {
4795
+ try {
4796
+ new URL(value);
4797
+ return true;
4798
+ } catch {
4799
+ return false;
4800
+ }
4801
+ }
4802
+ function isRecord(value) {
4803
+ return typeof value === "object" && value !== null && !Array.isArray(value);
4804
+ }
4805
+ function verificationMeta(verification) {
4806
+ const meta = {};
4807
+ if (verification.verifier !== void 0)
4808
+ meta.verifier = verification.verifier;
4809
+ if (verification.checkedAt !== void 0)
4810
+ meta.checkedAt = verification.checkedAt;
4811
+ return meta;
4812
+ }
4813
+
4420
4814
  // src/cedar/compile.ts
4421
4815
  var PLACEHOLDER_PATTERN = /\{\{\s*(agent_did|user_did|org|deployment)\s*\}\}/g;
4422
4816
  function compileSingleCapability(capability, context) {
@@ -4634,33 +5028,21 @@ var ConsentCapabilitiesScreen = class extends i4 {
4634
5028
  return cedar;
4635
5029
  }
4636
5030
  }
4637
- renderHeadline() {
4638
- const agentName = this.agentMetadata?.name?.trim() || "An assistant";
4639
- const tokens = CONSENT_COPY_TOKENS;
4640
- const verb = this.headlineVerb.trim();
4641
- const raw = formatToken(
4642
- verb && verb !== "use" ? tokens.headline.template : tokens.headline.fallbackTemplate,
4643
- {
4644
- Agent: "@@AGENT@@",
4645
- Verb: verb,
4646
- Org: "@@ORG@@"
4647
- }
4648
- );
4649
- const escaped = escapeHtml(raw);
4650
- const withSerifEntities = escaped.replace("@@AGENT@@", `<em>${escapeHtml(agentName)}</em>`).replace(
4651
- "@@ORG@@",
4652
- `<em>${escapeHtml(this.orgName || "this site")}</em>`
4653
- );
4654
- return b2`<h1
4655
- class="headline"
4656
- part="headline"
4657
- .innerHTML=${withSerifEntities}
4658
- ></h1>`;
5031
+ /** The agent tile: from `agentIdentity` when it is set, else `agentMetadata`. */
5032
+ resolveAgent() {
5033
+ if (this.agentIdentity === void 0 || this.agentIdentity === null) {
5034
+ return this.agentMetadata;
5035
+ }
5036
+ try {
5037
+ return agentMetadataFromIdentity(this.agentIdentity);
5038
+ } catch {
5039
+ return void 0;
5040
+ }
4659
5041
  }
4660
5042
  render() {
4661
5043
  const tokens = CONSENT_COPY_TOKENS;
4662
- const agentName = this.agentMetadata?.name || "this agent";
4663
- const subhead = this.description || formatToken(tokens.subhead.template, { Agent: agentName });
5044
+ const agent = this.resolveAgent();
5045
+ const agentName = agent?.name || "this agent";
4664
5046
  const sectionHeader = formatToken(tokens.section.capabilitiesHeader, {
4665
5047
  Agent: agentName.toUpperCase()
4666
5048
  });
@@ -4670,31 +5052,33 @@ var ConsentCapabilitiesScreen = class extends i4 {
4670
5052
  </style>
4671
5053
  <consent-connector-header
4672
5054
  part="connector"
4673
- clientName="${this.agentMetadata?.name || ""}"
4674
- clientDid="${this.agentMetadata?.did || ""}"
4675
- client-logo-url="${this.agentMetadata?.logoUrl || ""}"
5055
+ clientName="${agent?.name || ""}"
5056
+ clientDid="${agent?.did || ""}"
5057
+ client-logo-url="${agent?.logoUrl || ""}"
4676
5058
  serverName="${this.orgName || ""}"
4677
5059
  server-logo-url="${this.serverLogoUrl}"
4678
5060
  server-domain="${this.serverDomain}"
4679
5061
  logo-dev-token="${this.logoDevToken}"
4680
5062
  ></consent-connector-header>
4681
5063
  <div class="card" part="card">
4682
- <span class="eyebrow" part="eyebrow"
4683
- >${tokens.eyebrow.permissionRequest}</span
4684
- >
4685
- ${this.renderHeadline()}
4686
- <p class="subhead" part="subhead">${subhead}</p>
5064
+ <consent-headline
5065
+ exportparts="eyebrow, headline, subhead"
5066
+ agent-name="${agent?.name ?? ""}"
5067
+ org-name="${this.orgName}"
5068
+ verb="${this.headlineVerb}"
5069
+ description="${this.description}"
5070
+ ></consent-headline>
4687
5071
  <slot name="recovery"></slot>
4688
5072
  <slot name="identity"></slot>
4689
- ${this.agentMetadata ? b2`<consent-agent-header
5073
+ ${agent ? b2`<consent-agent-header
4690
5074
  part="agent"
4691
- agentName="${this.agentMetadata.name}"
4692
- vendor="${this.agentMetadata.vendor || ""}"
4693
- surfaceLabel="${this.agentMetadata.surfaceLabel || ""}"
4694
- verification="${agentVerification(this.agentMetadata)}"
4695
- domain="${this.agentMetadata.domain || ""}"
4696
- logoUrl="${this.agentMetadata.logoUrl || ""}"
4697
- connectedAt="${this.agentMetadata.connectedAt || ""}"
5075
+ agentName="${agent.name}"
5076
+ vendor="${agent.vendor || ""}"
5077
+ surfaceLabel="${agent.surfaceLabel || ""}"
5078
+ verification="${agentVerification(agent)}"
5079
+ domain="${agent.domain || ""}"
5080
+ logoUrl="${agent.logoUrl || ""}"
5081
+ connectedAt="${agent.connectedAt || ""}"
4698
5082
  ></consent-agent-header>` : A}
4699
5083
  <slot name="agent-key"></slot>
4700
5084
  <div part="permissions">
@@ -4776,35 +5160,6 @@ ConsentCapabilitiesScreen.styles = i`
4776
5160
  color: var(--cs-text-primary);
4777
5161
  }
4778
5162
 
4779
- .eyebrow {
4780
- font-size: 11px;
4781
- letter-spacing: 0.16em;
4782
- font-weight: 600;
4783
- color: var(--cs-text-tertiary);
4784
- text-transform: uppercase;
4785
- }
4786
-
4787
- .headline {
4788
- font-family: "Times New Roman", Georgia, serif;
4789
- font-size: var(--cs-headline-font-size, clamp(24px, 5vw, 30px));
4790
- line-height: 1.18;
4791
- letter-spacing: -0.01em;
4792
- color: var(--cs-text-primary);
4793
- margin: 0;
4794
- overflow-wrap: anywhere;
4795
- }
4796
-
4797
- .headline em {
4798
- font-style: italic;
4799
- }
4800
-
4801
- .subhead {
4802
- font-size: var(--cs-subhead-font-size, 14.5px);
4803
- color: var(--cs-text-secondary);
4804
- line-height: 1.55;
4805
- margin: 0;
4806
- }
4807
-
4808
5163
  .section-header {
4809
5164
  display: flex;
4810
5165
  align-items: center;
@@ -4842,6 +5197,9 @@ __decorateClass([
4842
5197
  __decorateClass([
4843
5198
  n4({ type: Object })
4844
5199
  ], ConsentCapabilitiesScreen.prototype, "agentMetadata", 2);
5200
+ __decorateClass([
5201
+ n4({ type: Object })
5202
+ ], ConsentCapabilitiesScreen.prototype, "agentIdentity", 2);
4845
5203
  __decorateClass([
4846
5204
  n4({ type: Object })
4847
5205
  ], ConsentCapabilitiesScreen.prototype, "cedarContext", 2);
@@ -4908,9 +5266,6 @@ __decorateClass([
4908
5266
  ConsentCapabilitiesScreen = __decorateClass([
4909
5267
  t3("consent-capabilities-screen")
4910
5268
  ], ConsentCapabilitiesScreen);
4911
- function escapeHtml(value) {
4912
- return value.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;");
4913
- }
4914
5269
 
4915
5270
  // src/resolution/resolve-copy.ts
4916
5271
  var AGENT_NAME_PLACEHOLDER = "[AI Agent]";
@@ -6058,6 +6413,24 @@ var McpConsent = class extends i4 {
6058
6413
  return this.renderConsentOnly();
6059
6414
  }
6060
6415
  }
6416
+ /**
6417
+ * What the capability screen gets for the agent tile. A host that sent
6418
+ * `agentIdentity` meant it, so it is the only source then. The form submits
6419
+ * `agent-did` as the delegation's subject: an identity whose card names any
6420
+ * other DID would show the human someone else, so the tile is left out
6421
+ * rather than falling back to `agentMetadata`.
6422
+ */
6423
+ agentForScreen() {
6424
+ const identity = this.agentIdentity;
6425
+ if (identity === void 0 || identity === null) {
6426
+ return { agentMetadata: this.agentMetadata };
6427
+ }
6428
+ const cardDid = identity.card?.id;
6429
+ if (this.agentDid && (typeof cardDid !== "string" || !sameDid(cardDid, this.agentDid))) {
6430
+ return {};
6431
+ }
6432
+ return { agentIdentity: identity };
6433
+ }
6061
6434
  /**
6062
6435
  * Render the new humanized capability layout. Selection state is owned by
6063
6436
  * `<consent-capabilities-screen>`; on `capabilities-allow`, we hydrate the
@@ -6065,6 +6438,7 @@ var McpConsent = class extends i4 {
6065
6438
  * existing handleApprove submission logic.
6066
6439
  */
6067
6440
  renderCapabilitiesScreen() {
6441
+ const agent = this.agentForScreen();
6068
6442
  const projection = this.getRequestedCapabilities();
6069
6443
  const flatCapabilities = projection.ok ? projection.capabilities : [];
6070
6444
  const error = this.error || (!projection.ok ? projection.error : void 0);
@@ -6073,7 +6447,8 @@ var McpConsent = class extends i4 {
6073
6447
  return b2`
6074
6448
  <consent-capabilities-screen
6075
6449
  .capabilities=${flatCapabilities}
6076
- .agentMetadata=${this.agentMetadata}
6450
+ .agentMetadata=${agent.agentMetadata}
6451
+ .agentIdentity=${agent.agentIdentity}
6077
6452
  .cedarContext=${this.cedarContext}
6078
6453
  orgName="${this.orgName || this.resolved?.branding.companyName || ""}"
6079
6454
  server-logo-url="${this.resolved?.branding.logoUrl || ""}"
@@ -6647,6 +7022,23 @@ __decorateClass([
6647
7022
  }
6648
7023
  })
6649
7024
  ], McpConsent.prototype, "agentMetadata", 2);
7025
+ __decorateClass([
7026
+ n4({
7027
+ type: Object,
7028
+ attribute: "agent-identity",
7029
+ converter: {
7030
+ fromAttribute: (value) => {
7031
+ if (!value) return void 0;
7032
+ try {
7033
+ return JSON.parse(value);
7034
+ } catch {
7035
+ return void 0;
7036
+ }
7037
+ },
7038
+ toAttribute: (value) => value ? JSON.stringify(value) : ""
7039
+ }
7040
+ })
7041
+ ], McpConsent.prototype, "agentIdentity", 2);
6650
7042
  __decorateClass([
6651
7043
  n4({ type: String, attribute: "org-name" })
6652
7044
  ], McpConsent.prototype, "orgName", 2);
@@ -6744,7 +7136,7 @@ McpConsent = __decorateClass([
6744
7136
  t3("mcp-consent")
6745
7137
  ], McpConsent);
6746
7138
 
6747
- // ../../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_86a9bc07372aea147cc0a0db8a7984f5/node_modules/@kya-os/id/dist/base64url.js
7139
+ // ../../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_72689bf9896b7b2f1f46eed3d099ac4e/node_modules/@kya-os/id/dist/base64url.js
6748
7140
  function bytesToBase64Url(bytes) {
6749
7141
  let b642;
6750
7142
  if (typeof Buffer !== "undefined") {
@@ -6779,14 +7171,14 @@ function base64UrlToBytesStrict(s4) {
6779
7171
  return bytesToBase64Url(bytes) === s4 ? bytes : null;
6780
7172
  }
6781
7173
 
6782
- // ../../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_86a9bc07372aea147cc0a0db8a7984f5/node_modules/@kya-os/id/dist/passkey/types.js
7174
+ // ../../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_72689bf9896b7b2f1f46eed3d099ac4e/node_modules/@kya-os/id/dist/passkey/types.js
6783
7175
  var PASSKEY_COSE_ALGORITHMS = Object.freeze([
6784
7176
  -8,
6785
7177
  -7,
6786
7178
  -257
6787
7179
  ]);
6788
7180
 
6789
- // ../../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_86a9bc07372aea147cc0a0db8a7984f5/node_modules/@kya-os/id/dist/wallet/passkey.js
7181
+ // ../../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_72689bf9896b7b2f1f46eed3d099ac4e/node_modules/@kya-os/id/dist/wallet/passkey.js
6790
7182
  var PasskeyCeremonyError = class extends Error {
6791
7183
  constructor(code, message, options) {
6792
7184
  super(message, options);
@@ -7319,6 +7711,7 @@ export {
7319
7711
  ConsentCheckbox,
7320
7712
  ConsentConnectorHeader,
7321
7713
  ConsentFooter,
7714
+ ConsentHeadline,
7322
7715
  ConsentInput,
7323
7716
  ConsentOAuthButton,
7324
7717
  ConsentOTPInput,