@kya-os/consent 0.2.3 → 0.3.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 +217 -3
  2. package/dist/bundle/index.d.ts +10 -0
  3. package/dist/bundle/index.d.ts.map +1 -1
  4. package/dist/bundle/index.js +10 -0
  5. package/dist/bundle/index.js.map +1 -1
  6. package/dist/bundle/inline.d.ts.map +1 -1
  7. package/dist/bundle/inline.js +4 -4
  8. package/dist/bundle/inline.js.map +1 -1
  9. package/dist/cjs/bundle/index.js +10 -0
  10. package/dist/cjs/bundle/index.js.map +1 -1
  11. package/dist/cjs/bundle/inline.js +4 -4
  12. package/dist/cjs/bundle/inline.js.map +1 -1
  13. package/dist/cjs/components/consent-action-bar.js +66 -15
  14. package/dist/cjs/components/consent-action-bar.js.map +1 -1
  15. package/dist/cjs/components/consent-agent-header.js +5 -1
  16. package/dist/cjs/components/consent-agent-header.js.map +1 -1
  17. package/dist/cjs/components/consent-capabilities-screen.js +17 -1
  18. package/dist/cjs/components/consent-capabilities-screen.js.map +1 -1
  19. package/dist/cjs/components/consent-checkbox.js +2 -2
  20. package/dist/cjs/components/consent-checkbox.js.map +1 -1
  21. package/dist/cjs/components/consent-duration.js +187 -0
  22. package/dist/cjs/components/consent-duration.js.map +1 -0
  23. package/dist/cjs/components/consent-folder-scope.js +169 -0
  24. package/dist/cjs/components/consent-folder-scope.js.map +1 -0
  25. package/dist/cjs/components/consent-footer.js +13 -2
  26. package/dist/cjs/components/consent-footer.js.map +1 -1
  27. package/dist/cjs/components/consent-grant-terms.js +321 -0
  28. package/dist/cjs/components/consent-grant-terms.js.map +1 -0
  29. package/dist/cjs/components/consent-input.js +47 -27
  30. package/dist/cjs/components/consent-input.js.map +1 -1
  31. package/dist/cjs/components/consent-otp-input.js +49 -42
  32. package/dist/cjs/components/consent-otp-input.js.map +1 -1
  33. package/dist/cjs/components/consent-phone-handoff.js +219 -0
  34. package/dist/cjs/components/consent-phone-handoff.js.map +1 -0
  35. package/dist/cjs/components/consent-request-expiry.js +159 -0
  36. package/dist/cjs/components/consent-request-expiry.js.map +1 -0
  37. package/dist/cjs/components/consent-revoke.js +308 -0
  38. package/dist/cjs/components/consent-revoke.js.map +1 -0
  39. package/dist/cjs/components/consent-shell.js +3 -0
  40. package/dist/cjs/components/consent-shell.js.map +1 -1
  41. package/dist/cjs/components/consent-terms.js +2 -2
  42. package/dist/cjs/components/consent-terms.js.map +1 -1
  43. package/dist/cjs/components/consent-wallet-check.js +107 -0
  44. package/dist/cjs/components/consent-wallet-check.js.map +1 -0
  45. package/dist/cjs/components/consent-wallet-notice.js +189 -0
  46. package/dist/cjs/components/consent-wallet-notice.js.map +1 -0
  47. package/dist/cjs/components/consent-wallet-orb.js +273 -0
  48. package/dist/cjs/components/consent-wallet-orb.js.map +1 -0
  49. package/dist/cjs/components/consent-wallet-signature.js +104 -0
  50. package/dist/cjs/components/consent-wallet-signature.js.map +1 -0
  51. package/dist/cjs/components/grant-field-styles.js +85 -0
  52. package/dist/cjs/components/grant-field-styles.js.map +1 -0
  53. package/dist/cjs/components/index.js +32 -1
  54. package/dist/cjs/components/index.js.map +1 -1
  55. package/dist/cjs/components/mcp-consent.js +18 -1
  56. package/dist/cjs/components/mcp-consent.js.map +1 -1
  57. package/dist/cjs/components/template-link.js +32 -0
  58. package/dist/cjs/components/template-link.js.map +1 -0
  59. package/dist/cjs/components/wallet-globe.js +184 -0
  60. package/dist/cjs/components/wallet-globe.js.map +1 -0
  61. package/dist/cjs/components/wallet-icons.js +19 -0
  62. package/dist/cjs/components/wallet-icons.js.map +1 -0
  63. package/dist/cjs/components/wallet-status.js +34 -0
  64. package/dist/cjs/components/wallet-status.js.map +1 -0
  65. package/dist/cjs/copy/tokens.js +91 -0
  66. package/dist/cjs/copy/tokens.js.map +1 -1
  67. package/dist/cjs/grant/index.js +24 -0
  68. package/dist/cjs/grant/index.js.map +1 -0
  69. package/dist/cjs/grant/terms.js +148 -0
  70. package/dist/cjs/grant/terms.js.map +1 -0
  71. package/dist/cjs/index.js +2 -0
  72. package/dist/cjs/index.js.map +1 -1
  73. package/dist/cjs/mcp-app/inline.js +2 -2
  74. package/dist/cjs/mcp-app/inline.js.map +1 -1
  75. package/dist/cjs/react/index.js +120 -1
  76. package/dist/cjs/react/index.js.map +1 -1
  77. package/dist/components/consent-action-bar.d.ts +17 -0
  78. package/dist/components/consent-action-bar.d.ts.map +1 -1
  79. package/dist/components/consent-action-bar.js +67 -16
  80. package/dist/components/consent-action-bar.js.map +1 -1
  81. package/dist/components/consent-agent-header.d.ts.map +1 -1
  82. package/dist/components/consent-agent-header.js +5 -1
  83. package/dist/components/consent-agent-header.js.map +1 -1
  84. package/dist/components/consent-capabilities-screen.d.ts +10 -0
  85. package/dist/components/consent-capabilities-screen.d.ts.map +1 -1
  86. package/dist/components/consent-capabilities-screen.js +17 -1
  87. package/dist/components/consent-capabilities-screen.js.map +1 -1
  88. package/dist/components/consent-checkbox.d.ts +1 -1
  89. package/dist/components/consent-checkbox.js +2 -2
  90. package/dist/components/consent-checkbox.js.map +1 -1
  91. package/dist/components/consent-duration.d.ts +64 -0
  92. package/dist/components/consent-duration.d.ts.map +1 -0
  93. package/dist/components/consent-duration.js +184 -0
  94. package/dist/components/consent-duration.js.map +1 -0
  95. package/dist/components/consent-folder-scope.d.ts +70 -0
  96. package/dist/components/consent-folder-scope.d.ts.map +1 -0
  97. package/dist/components/consent-folder-scope.js +166 -0
  98. package/dist/components/consent-folder-scope.js.map +1 -0
  99. package/dist/components/consent-footer.d.ts.map +1 -1
  100. package/dist/components/consent-footer.js +13 -2
  101. package/dist/components/consent-footer.js.map +1 -1
  102. package/dist/components/consent-grant-terms.d.ts +88 -0
  103. package/dist/components/consent-grant-terms.d.ts.map +1 -0
  104. package/dist/components/consent-grant-terms.js +318 -0
  105. package/dist/components/consent-grant-terms.js.map +1 -0
  106. package/dist/components/consent-input.d.ts +4 -4
  107. package/dist/components/consent-input.d.ts.map +1 -1
  108. package/dist/components/consent-input.js +49 -29
  109. package/dist/components/consent-input.js.map +1 -1
  110. package/dist/components/consent-otp-input.d.ts +4 -4
  111. package/dist/components/consent-otp-input.d.ts.map +1 -1
  112. package/dist/components/consent-otp-input.js +51 -44
  113. package/dist/components/consent-otp-input.js.map +1 -1
  114. package/dist/components/consent-phone-handoff.d.ts +50 -0
  115. package/dist/components/consent-phone-handoff.d.ts.map +1 -0
  116. package/dist/components/consent-phone-handoff.js +215 -0
  117. package/dist/components/consent-phone-handoff.js.map +1 -0
  118. package/dist/components/consent-request-expiry.d.ts +52 -0
  119. package/dist/components/consent-request-expiry.d.ts.map +1 -0
  120. package/dist/components/consent-request-expiry.js +154 -0
  121. package/dist/components/consent-request-expiry.js.map +1 -0
  122. package/dist/components/consent-revoke.d.ts +53 -0
  123. package/dist/components/consent-revoke.d.ts.map +1 -0
  124. package/dist/components/consent-revoke.js +305 -0
  125. package/dist/components/consent-revoke.js.map +1 -0
  126. package/dist/components/consent-shell.d.ts.map +1 -1
  127. package/dist/components/consent-shell.js +3 -0
  128. package/dist/components/consent-shell.js.map +1 -1
  129. package/dist/components/consent-terms.d.ts +1 -1
  130. package/dist/components/consent-terms.js +2 -2
  131. package/dist/components/consent-terms.js.map +1 -1
  132. package/dist/components/consent-wallet-check.d.ts +45 -0
  133. package/dist/components/consent-wallet-check.d.ts.map +1 -0
  134. package/dist/components/consent-wallet-check.js +102 -0
  135. package/dist/components/consent-wallet-check.js.map +1 -0
  136. package/dist/components/consent-wallet-notice.d.ts +54 -0
  137. package/dist/components/consent-wallet-notice.d.ts.map +1 -0
  138. package/dist/components/consent-wallet-notice.js +186 -0
  139. package/dist/components/consent-wallet-notice.js.map +1 -0
  140. package/dist/components/consent-wallet-orb.d.ts +48 -0
  141. package/dist/components/consent-wallet-orb.d.ts.map +1 -0
  142. package/dist/components/consent-wallet-orb.js +269 -0
  143. package/dist/components/consent-wallet-orb.js.map +1 -0
  144. package/dist/components/consent-wallet-signature.d.ts +26 -0
  145. package/dist/components/consent-wallet-signature.d.ts.map +1 -0
  146. package/dist/components/consent-wallet-signature.js +101 -0
  147. package/dist/components/consent-wallet-signature.js.map +1 -0
  148. package/dist/components/grant-field-styles.d.ts +9 -0
  149. package/dist/components/grant-field-styles.d.ts.map +1 -0
  150. package/dist/components/grant-field-styles.js +82 -0
  151. package/dist/components/grant-field-styles.js.map +1 -0
  152. package/dist/components/index.d.ts +10 -0
  153. package/dist/components/index.d.ts.map +1 -1
  154. package/dist/components/index.js +13 -0
  155. package/dist/components/index.js.map +1 -1
  156. package/dist/components/mcp-consent.d.ts.map +1 -1
  157. package/dist/components/mcp-consent.js +18 -1
  158. package/dist/components/mcp-consent.js.map +1 -1
  159. package/dist/components/template-link.d.ts +24 -0
  160. package/dist/components/template-link.d.ts.map +1 -0
  161. package/dist/components/template-link.js +29 -0
  162. package/dist/components/template-link.js.map +1 -0
  163. package/dist/components/wallet-globe.d.ts +29 -0
  164. package/dist/components/wallet-globe.d.ts.map +1 -0
  165. package/dist/components/wallet-globe.js +181 -0
  166. package/dist/components/wallet-globe.js.map +1 -0
  167. package/dist/components/wallet-icons.d.ts +16 -0
  168. package/dist/components/wallet-icons.d.ts.map +1 -0
  169. package/dist/components/wallet-icons.js +16 -0
  170. package/dist/components/wallet-icons.js.map +1 -0
  171. package/dist/components/wallet-status.d.ts +19 -0
  172. package/dist/components/wallet-status.d.ts.map +1 -0
  173. package/dist/components/wallet-status.js +29 -0
  174. package/dist/components/wallet-status.js.map +1 -0
  175. package/dist/consent.js +3126 -783
  176. package/dist/consent.min.js +1331 -272
  177. package/dist/copy/tokens.d.ts +91 -0
  178. package/dist/copy/tokens.d.ts.map +1 -1
  179. package/dist/copy/tokens.js +91 -0
  180. package/dist/copy/tokens.js.map +1 -1
  181. package/dist/grant/index.d.ts +8 -0
  182. package/dist/grant/index.d.ts.map +1 -0
  183. package/dist/grant/index.js +8 -0
  184. package/dist/grant/index.js.map +1 -0
  185. package/dist/grant/terms.d.ts +97 -0
  186. package/dist/grant/terms.d.ts.map +1 -0
  187. package/dist/grant/terms.js +139 -0
  188. package/dist/grant/terms.js.map +1 -0
  189. package/dist/index.d.ts +1 -0
  190. package/dist/index.d.ts.map +1 -1
  191. package/dist/index.js +2 -0
  192. package/dist/index.js.map +1 -1
  193. package/dist/mcp-app/inline.d.ts.map +1 -1
  194. package/dist/mcp-app/inline.js +2 -2
  195. package/dist/mcp-app/inline.js.map +1 -1
  196. package/dist/react/index.d.ts +74 -0
  197. package/dist/react/index.d.ts.map +1 -1
  198. package/dist/react/index.js +119 -0
  199. package/dist/react/index.js.map +1 -1
  200. package/package.json +10 -4
package/README.md CHANGED
@@ -35,7 +35,7 @@ npm install @kya-os/id # only if you import @kya-os/consent/passkey
35
35
  ```
36
36
 
37
37
  Without `@kya-os/id`, importing a passkey entry point fails with a module-not-found error for `@kya-os/id/wallet/passkey`.
38
- Install `@kya-os/id@^0.6.0` to fix it.
38
+ Install `@kya-os/id` 0.6, 0.7 or 0.8 to fix it.
39
39
  Every other entry point works without it, and so does the self-contained `consent.js` bundle, which inlines the passkey code.
40
40
 
41
41
  ## A standalone scope grant
@@ -61,7 +61,7 @@ screen.description = "Review the grant before using your passkey.";
61
61
  screen.submitLabel = "Approve grant";
62
62
  screen.cancelLabel = "Deny";
63
63
  screen.addEventListener("capabilities-allow", async (event) => {
64
- // event.detail: { selectedCapabilityIds: string[], selectedScopes: string[] }
64
+ // event.detail: { selectedCapabilityIds: string[], selectedScopes: string[], grantTerms? }
65
65
  screen.loading = true;
66
66
  try {
67
67
  await hostApprove(event.detail);
@@ -83,6 +83,142 @@ Empty selections cannot emit approval.
83
83
  `allSelected` (`all-selected`) seeds every capability as checked; rerendering the same capability IDs preserves the human's subsequent selection.
84
84
  HTML attributes for custom labels are `submit-label` and `cancel-label`; JavaScript properties are `submitLabel` and `cancelLabel`.
85
85
 
86
+ ## Grant terms
87
+
88
+ `<consent-grant-terms>` lets the person choose how long a grant lasts and which folder it covers.
89
+ It stays closed under one line that says what is in effect, such as "8 hours · Every folder", next to a Customize button.
90
+ Put it in the screen's `details` slot, and `capabilities-allow` carries the person's choice as `event.detail.grantTerms`.
91
+ Allow stays off while the terms can't be used, such as a folder path with `..` in it.
92
+
93
+ ```html
94
+ <consent-capabilities-screen>
95
+ <consent-grant-terms slot="details" chained></consent-grant-terms>
96
+ </consent-capabilities-screen>
97
+ ```
98
+
99
+ `grantTerms` is `{ notAfter, crispScopes }`, with `notAfter` in seconds.
100
+ Those are the field names of `@kya-os/id`'s `DelegationRequest`, so the terms spread into `wallet.issueDelegation()` unchanged.
101
+ The package root declares the type itself and never imports `@kya-os/id`.
102
+
103
+ With no child elements, the group shows a `<consent-duration>` and a `<consent-folder-scope>` with their defaults.
104
+ Put your own in it to configure them:
105
+
106
+ ```html
107
+ <consent-grant-terms slot="details">
108
+ <consent-duration max="86400" value="3600"></consent-duration>
109
+ <consent-folder-scope
110
+ everything-label="Entire vault"
111
+ only-template="Limited to {Folder}"
112
+ ></consent-folder-scope>
113
+ </consent-grant-terms>
114
+ ```
115
+
116
+ - `<consent-duration>` offers `options` (15 minutes to 30 days by default) up to `max`.
117
+ A `value` it doesn't offer shows as the longest shorter choice, so a grant never lasts longer than you asked for.
118
+ - `<consent-folder-scope>` reads a path the way the verifier's `path-prefix` matcher does.
119
+ `/notes/*` is `notes/`, and `notes/` never covers `notesx/`.
120
+ A path with a `.` or `..` segment is refused with a message, instead of becoming a grant that covers nothing.
121
+ - Both are form-associated.
122
+ Inside a `<form>` they submit under their `name`, and the folder field blocks submission while it is invalid.
123
+ - Any child element with a `grantTerms` property is a field, so you can add your own.
124
+ It may also have `summary` (its part of the closed line) and `valid`, and it should dispatch `consent-grant-field-change` when they change.
125
+ When more than one field sets a duration, the shortest wins.
126
+ - `chained` adds a line saying the agent can pass on only a narrower grant, which is true of every `@kya-os/id` delegation chain.
127
+
128
+ `@kya-os/consent/grant` exports the pure helpers behind them: `readFolder`, `folderTerms`, `mergeGrantTerms`, `pickDuration`, `formatDuration` and `DURATION_OPTIONS`.
129
+ It imports no other package, so a host that draws its own fields, or checks terms on its server, can use it on its own.
130
+
131
+ ## Taking a grant back
132
+
133
+ `<consent-revoke>` asks before a grant ends, lists what ends, and confirms once it has.
134
+ It revokes nothing itself.
135
+ It fires `consent-revoke`, then your code revokes the grant and sets `loading`, then `revoked` or `error`.
136
+ With `chained`, the list adds every narrower grant the agent passed on, because revoking a `@kya-os/id` credential revokes the ones minted under it.
137
+
138
+ ```ts
139
+ const revoke = document.querySelector("consent-revoke");
140
+ revoke.agentName = grant.agentName;
141
+ revoke.items = ["Read your notes", "Write to journal/"];
142
+ revoke.chained = true;
143
+ revoke.addEventListener("consent-revoke", async () => {
144
+ revoke.loading = true;
145
+ revoke.error = "";
146
+ try {
147
+ await wallet.revoke(grant.id); // the hub flips the grant's status bit
148
+ revoke.revoked = true;
149
+ } catch {
150
+ revoke.error = "Your account couldn't be reached. Try again.";
151
+ } finally {
152
+ revoke.loading = false;
153
+ }
154
+ });
155
+ revoke.addEventListener("consent-keep", closeDialog);
156
+ ```
157
+
158
+ ## Signing with a wallet
159
+
160
+ When the person approves by signing with their own wallet, as they do with `@kya-os/id`, these elements cover the moments around the signature.
161
+ Each shows state your page already has, and none of them calls a server.
162
+
163
+ - `<consent-wallet-check>` shows whether this browser's wallet can sign, as an orb and one line.
164
+ Set `status` to `checking`, `syncing`, `ready`, `conflict` or `error`.
165
+ The orb is a globe inside a dial of 48 ticks.
166
+ While the check runs, the globe turns and a light runs round the dial.
167
+ Once the wallet is ready, the dial closes and a check is drawn; when this browser can't sign, the dial stays open at the top.
168
+ - `<consent-wallet-orb>` is that orb on its own, for a screen whose own words already say what is happening.
169
+ It takes the same `status`, and one more: `idle`, for before anything has started, when the globe turns and the dial rests.
170
+ `--cs-wallet-orb-size`, `--cs-wallet-accent`, `--cs-wallet-success` and `--cs-wallet-muted` theme it.
171
+ - `<consent-wallet-notice>` says what to do when this browser can't sign.
172
+ It shows only for a `conflict` or an `error`.
173
+ `reason` picks the advice: `passkey-unreachable`, `key-drift` or `superseded`.
174
+ `credentials-url` links the page where the person manages their wallet, and the `more` slot replaces the advice under an unreachable passkey.
175
+ - `<consent-request-expiry>` counts down the time left to approve, from `expires-at` in epoch milliseconds or an ISO date.
176
+ At zero it says the request expired and fires `consent-request-expired` once, with `{ expiresAt }`.
177
+ - `<consent-phone-handoff>` is a QR code of the request's link, for a person whose passkey is on their phone.
178
+ It draws the code itself, so the link never goes to an image service.
179
+ Hide it on phones yourself: the element can't tell which device it is on.
180
+ - `<consent-wallet-signature>` is the small print under the buttons: the wallet signs the grant, and `revoke-url` is where to take it back.
181
+
182
+ The action bar takes `submit-icon="passkey"` for a fingerprint on Approve, and `loading-label` for what it says while it signs.
183
+
184
+ ```html
185
+ <consent-wallet-check status="checking"></consent-wallet-check>
186
+ <consent-wallet-notice
187
+ app-name="Northwind"
188
+ credentials-url="/settings/credentials"
189
+ ></consent-wallet-notice>
190
+ <consent-request-expiry
191
+ expires-at="2026-11-12T09:05:00Z"
192
+ ></consent-request-expiry>
193
+ <consent-action-bar
194
+ submit-label="Approve"
195
+ cancel-label="Deny"
196
+ submit-icon="passkey"
197
+ loading-label="Signing…"
198
+ disabled
199
+ ></consent-action-bar>
200
+ <consent-wallet-signature
201
+ revoke-url="/settings/credentials"
202
+ ></consent-wallet-signature>
203
+ <consent-phone-handoff
204
+ url="https://app.example/c/chal_123"
205
+ updates-on-its-own
206
+ ></consent-phone-handoff>
207
+ ```
208
+
209
+ ```ts
210
+ // Your wallet check's outcome drives the check, the notice and Approve.
211
+ check.status = notice.status = outcome.status; // "ready", "conflict", …
212
+ notice.reason = outcome.reason; // "passkey-unreachable", …
213
+ bar.disabled = outcome.status !== "ready";
214
+ expiry.addEventListener("consent-request-expired", () => {
215
+ bar.disabled = true;
216
+ });
217
+ ```
218
+
219
+ The notice names the app from `app-name`, or says "this app" without one.
220
+ Where your own words fit better, the check takes a `caption`, the notice a `message` and its `more` slot, and the phone handoff a `heading` and a `description`.
221
+
86
222
  ## React
87
223
 
88
224
  `@kya-os/consent/react` has a React component for every element, such as `ConsentCapabilitiesScreenReact` for the screen above.
@@ -112,6 +248,7 @@ The components keep the handlers typed in both versions.
112
248
  `react` and `@lit/react` are peers, so the components use your app's copy of React.
113
249
  No other entry point imports either one.
114
250
  `<consent-passkey>` has its own component, `ConsentPasskeyReact`, in `@kya-os/consent/passkey/react` (see [Passkey mode](#passkey-mode)).
251
+ Slotted parts are children, as in `<ConsentGrantTermsReact slot="details" chained />` inside the screen.
115
252
 
116
253
  ## Host content and styling
117
254
 
@@ -271,13 +408,90 @@ It loads the element from `{serverUrl}/consent.js`, and like the element it make
271
408
  It re-dispatches the element's three events to a same-origin opener or parent window as `postMessage({ source: "consent-passkey", type, detail }, "/")`.
272
409
  Required terms keep the element disabled until accepted, and without a usable `passkeyStep` the page fails closed.
273
410
 
411
+ ## A consent page for `@kya-os/id`
412
+
413
+ [`@kya-os/id`](https://www.npmjs.com/package/@kya-os/id) mints the grant, and these components ask the person for it.
414
+ Together they make the page an `@kya-os/id` MCP server sends people to when an agent needs access.
415
+
416
+ On the server, `createMcpRouter` calls your `createConsentChallenge` when a tool call has no grant that covers it.
417
+ Store the request and return the page's URL.
418
+ The agent relays the URL to the person, and its next call carries the challenge back as a resume token.
419
+
420
+ ```ts
421
+ import { createMcpRouter } from "@kya-os/id/mcp";
422
+
423
+ const router = createMcpRouter({
424
+ ...options, // serverInfo, didResolver, findUserByDid, tools
425
+ createConsentChallenge: async ({ capability, agentLabel }) => {
426
+ const challenge = await consentRequests.create({ capability, agentLabel });
427
+ return { challenge, consentUrl: `${BASE_URL}/c/${challenge}` };
428
+ },
429
+ resolveResumeDelegation: ({ resumeToken }) =>
430
+ consentRequests.jwtFor(resumeToken),
431
+ });
432
+ ```
433
+
434
+ The page at `/c/:challenge` is the capabilities screen with the grant terms in its `details` slot.
435
+ On Allow, the person's passkey wallet signs one credential with the terms they chose, and the page hands its JWT to your server for `jwtFor` to return.
436
+
437
+ ```html
438
+ <consent-capabilities-screen>
439
+ <consent-grant-terms slot="details" chained></consent-grant-terms>
440
+ </consent-capabilities-screen>
441
+ ```
442
+
443
+ ```ts
444
+ import "@kya-os/consent/bundle";
445
+ import { createWallet } from "@kya-os/id/wallet";
446
+
447
+ const wallet = createWallet();
448
+ const screen = document.querySelector("consent-capabilities-screen");
449
+ screen.capabilities = [
450
+ {
451
+ id: request.capability,
452
+ label: request.label, // e.g. "Read your notes"
453
+ description: request.description,
454
+ icon: "eye",
455
+ riskLevel: "low",
456
+ defaultOn: true,
457
+ scopes: [request.capability],
458
+ },
459
+ ];
460
+ screen.addEventListener("capabilities-allow", async (event) => {
461
+ const { selectedScopes, grantTerms } = event.detail;
462
+ screen.loading = true;
463
+ try {
464
+ const stored = await wallet.issueDelegation({
465
+ ...grantTerms, // { notAfter, crispScopes }
466
+ capabilities: selectedScopes,
467
+ subjectDid: request.subjectDid,
468
+ audience: request.audience,
469
+ });
470
+ await fetch(`/api/consent/${challenge}`, {
471
+ method: "POST",
472
+ headers: { "content-type": "application/json" },
473
+ body: JSON.stringify({ jwt: stored.jwt }),
474
+ });
475
+ } finally {
476
+ screen.loading = false;
477
+ }
478
+ });
479
+ ```
480
+
481
+ A grant the person's wallet signs needs no passkey assertion on top: the signature is the approval.
482
+ When your server approves the request instead, use the assertion mode.
483
+ Open the ceremony with `createCommittedChallenge` from `@kya-os/id/server/passkey`, which commits the challenge to the request's id and scopes, put `<consent-passkey>` in the screen's `auth` slot, and keep Allow off with `allow-disabled` until the server has verified the assertion (see [Passkey mode](#passkey-mode)).
484
+
485
+ Where the person manages their grants, `<consent-revoke>` and `wallet.revoke(id)` take one back (see [Taking a grant back](#taking-a-grant-back)).
486
+ The code above type-checks against `@kya-os/id` 0.8.
487
+
274
488
  ## Validation and preview
275
489
 
276
490
  Run `pnpm test` and `pnpm build` for the package suite and all bundle formats.
277
491
  The build also verifies that the browser, ESM, CJS, and MCP App inline bundles contain the same UI.
278
492
  Run `pnpm test:browser` in a Python environment with Playwright installed for real Chromium tests of the public component contract.
279
493
  Set `CHROMIUM` to use an existing Chromium executable; otherwise Playwright's installed Chromium is used.
280
- The browser suite covers scope-only and Cedar rendering, custom content, mobile layout, empty and disabled approval, frozen scope selection while loading, actual main-component form submission, scope mismatch refusal, and fixed-grant authentication gates.
494
+ The browser suite covers scope-only and Cedar rendering, custom content, mobile layout, empty and disabled approval, frozen scope selection while loading, actual main-component form submission, scope mismatch refusal, fixed-grant authentication gates, and the grant terms and revoke panel: form association, keyboard order, Allow carrying the terms, and the fit at 320px.
281
495
  It also runs `<consent-passkey>` against a CDP virtual authenticator: passkey registration and a user-verified assertion, a failed user verification, and a browser without WebAuthn.
282
496
 
283
497
  After building, serve this directory and open `preview/all-templates.html#scope-passkey-preview` for the fictional Google account and passkey host example.
@@ -37,6 +37,16 @@ import "../components/consent-footer.js";
37
37
  import "../components/consent-revocation-notice.js";
38
38
  import "../components/consent-connector-header.js";
39
39
  import "../components/consent-capabilities-screen.js";
40
+ import "../components/consent-duration.js";
41
+ import "../components/consent-folder-scope.js";
42
+ import "../components/consent-grant-terms.js";
43
+ import "../components/consent-revoke.js";
44
+ import "../components/consent-wallet-orb.js";
45
+ import "../components/consent-wallet-check.js";
46
+ import "../components/consent-wallet-notice.js";
47
+ import "../components/consent-wallet-signature.js";
48
+ import "../components/consent-request-expiry.js";
49
+ import "../components/consent-phone-handoff.js";
40
50
  import "../components/mcp-consent.js";
41
51
  export { McpConsent } from "../components/mcp-consent.js";
42
52
  export { ConsentButton } from "../components/consent-button.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bundle/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,iCAAiC,CAAC;AACzC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,gCAAgC,CAAC;AACxC,OAAO,gCAAgC,CAAC;AACxC,OAAO,sCAAsC,CAAC;AAC9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AgC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AACrF,OAAO,EAAE,sBAAsB,EAAE,MAAM,2CAA2C,CAAC;AACnF,OAAO,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AACzF,OAAO,EAAE,6BAA6B,EAAE,MAAM,8BAA8B,CAAC;AAG7E,YAAY,EACV,aAAa,EACb,qBAAqB,GACtB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,YAAY,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC"}
@@ -38,6 +38,16 @@ import "../components/consent-footer.js";
38
38
  import "../components/consent-revocation-notice.js";
39
39
  import "../components/consent-connector-header.js";
40
40
  import "../components/consent-capabilities-screen.js";
41
+ import "../components/consent-duration.js";
42
+ import "../components/consent-folder-scope.js";
43
+ import "../components/consent-grant-terms.js";
44
+ import "../components/consent-revoke.js";
45
+ import "../components/consent-wallet-orb.js";
46
+ import "../components/consent-wallet-check.js";
47
+ import "../components/consent-wallet-notice.js";
48
+ import "../components/consent-wallet-signature.js";
49
+ import "../components/consent-request-expiry.js";
50
+ import "../components/consent-phone-handoff.js";
41
51
  import "../components/mcp-consent.js";
42
52
  // Re-export the main composite component for programmatic use
43
53
  export { McpConsent } from "../components/mcp-consent.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bundle/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,iEAAiE;AACjE,OAAO,iCAAiC,CAAC;AACzC,OAAO,mCAAmC,CAAC;AAC3C,OAAO,gCAAgC,CAAC;AACxC,OAAO,gCAAgC,CAAC;AACxC,OAAO,sCAAsC,CAAC;AAC9C,OAAO,gCAAgC,CAAC;AACxC,OAAO,uCAAuC,CAAC;AAC/C,OAAO,oCAAoC,CAAC;AAC5C,OAAO,uCAAuC,CAAC;AAC/C,OAAO,mCAAmC,CAAC;AAC3C,OAAO,0CAA0C,CAAC;AAClD,OAAO,qCAAqC,CAAC;AAC7C,OAAO,iCAAiC,CAAC;AACzC,OAAO,4CAA4C,CAAC;AACpD,OAAO,2CAA2C,CAAC;AACnD,OAAO,8CAA8C,CAAC;AACtD,OAAO,8BAA8B,CAAC;AAEtC,8DAA8D;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,8BAA8B,CAAC;AAE1D,qDAAqD;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAC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Eti6S;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAe,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAA2B,CAAC;AAE9D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAuC,CAAC"}
1
+ {"version":3,"file":"inline.d.ts","sourceRoot":"","sources":["../../src/bundle/inline.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;GAGG;AACH,eAAO,MAAM,cAAc,EAAE,MAA4omW,CAAC;AAE1qmW;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAe,CAAC;AAElD;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAA2B,CAAC;AAE9D;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAuC,CAAC"}