@pithy-sh/auth 0.11.0 → 0.12.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 (246) hide show
  1. package/README.md +30 -2
  2. package/dist/audit/actions.d.ts +39 -0
  3. package/dist/audit/actions.d.ts.map +1 -1
  4. package/dist/audit/actions.js +40 -1
  5. package/dist/audit/emit.d.ts +34 -0
  6. package/dist/audit/emit.d.ts.map +1 -1
  7. package/dist/audit/emit.js +47 -1
  8. package/dist/audit/evidence.d.ts +8 -2
  9. package/dist/audit/evidence.d.ts.map +1 -1
  10. package/dist/capability.d.ts +31 -11
  11. package/dist/capability.d.ts.map +1 -1
  12. package/dist/capability.js +38 -5
  13. package/dist/client/api.d.ts +55 -12
  14. package/dist/client/api.d.ts.map +1 -1
  15. package/dist/client/api.js +57 -18
  16. package/dist/client/bearer.d.ts +110 -0
  17. package/dist/client/bearer.d.ts.map +1 -0
  18. package/dist/client/bearer.js +265 -0
  19. package/dist/client/handoff.d.ts +77 -0
  20. package/dist/client/handoff.d.ts.map +1 -0
  21. package/dist/client/handoff.js +119 -0
  22. package/dist/client/mcp.d.ts +70 -0
  23. package/dist/client/mcp.d.ts.map +1 -0
  24. package/dist/client/mcp.js +65 -0
  25. package/dist/data/betterAuth.d.ts +3 -2
  26. package/dist/data/betterAuth.d.ts.map +1 -1
  27. package/dist/data/betterAuth.js +5 -3
  28. package/dist/data/kitFields.d.ts +5 -0
  29. package/dist/data/kitFields.d.ts.map +1 -1
  30. package/dist/data/kitFields.js +5 -0
  31. package/dist/data/tables.d.ts +25 -4
  32. package/dist/data/tables.d.ts.map +1 -1
  33. package/dist/data/tables.js +5 -3
  34. package/dist/data/userLifecycle.d.ts +9 -0
  35. package/dist/data/userLifecycle.d.ts.map +1 -1
  36. package/dist/data/userLifecycle.js +6 -2
  37. package/dist/data/verificationOutcome.d.ts +53 -0
  38. package/dist/data/verificationOutcome.d.ts.map +1 -0
  39. package/dist/data/verificationOutcome.js +50 -0
  40. package/dist/email/send.js +6 -2
  41. package/dist/http/adminRoutes.d.ts.map +1 -1
  42. package/dist/http/adminRoutes.js +56 -10
  43. package/dist/http/csrf.d.ts.map +1 -1
  44. package/dist/http/csrf.js +2 -1
  45. package/dist/http/guards.d.ts +15 -11
  46. package/dist/http/guards.d.ts.map +1 -1
  47. package/dist/http/guards.js +46 -11
  48. package/dist/http/handoff.d.ts +76 -0
  49. package/dist/http/handoff.d.ts.map +1 -0
  50. package/dist/http/handoff.js +316 -0
  51. package/dist/http/middleware.d.ts +12 -0
  52. package/dist/http/middleware.d.ts.map +1 -1
  53. package/dist/http/middleware.js +25 -4
  54. package/dist/http/resolve.d.ts.map +1 -1
  55. package/dist/http/resolve.js +9 -3
  56. package/dist/http/responses.d.ts +142 -0
  57. package/dist/http/responses.d.ts.map +1 -1
  58. package/dist/http/responses.js +66 -10
  59. package/dist/http/routes.d.ts +2 -0
  60. package/dist/http/routes.d.ts.map +1 -1
  61. package/dist/http/routes.js +35 -4
  62. package/dist/http/schemas.d.ts +57 -0
  63. package/dist/http/schemas.d.ts.map +1 -1
  64. package/dist/http/schemas.js +44 -1
  65. package/dist/http/views.d.ts +22 -2
  66. package/dist/http/views.d.ts.map +1 -1
  67. package/dist/http/views.js +40 -4
  68. package/dist/index.d.ts +2 -0
  69. package/dist/index.d.ts.map +1 -1
  70. package/dist/index.js +4 -2
  71. package/dist/instance/auth.d.ts +148 -10
  72. package/dist/instance/auth.d.ts.map +1 -1
  73. package/dist/instance/auth.js +86 -41
  74. package/dist/instance/plugins.d.ts +6 -0
  75. package/dist/instance/plugins.d.ts.map +1 -1
  76. package/dist/instance/plugins.js +14 -1
  77. package/dist/ledger/read.d.ts +53 -0
  78. package/dist/ledger/read.d.ts.map +1 -0
  79. package/dist/ledger/read.js +85 -0
  80. package/dist/ledger/record.d.ts +35 -0
  81. package/dist/ledger/record.d.ts.map +1 -0
  82. package/dist/ledger/record.js +98 -0
  83. package/dist/lifecycle/erasure.d.ts +9 -0
  84. package/dist/lifecycle/erasure.d.ts.map +1 -0
  85. package/dist/lifecycle/erasure.js +96 -0
  86. package/dist/lifecycle/inactivity.d.ts +19 -0
  87. package/dist/lifecycle/inactivity.d.ts.map +1 -0
  88. package/dist/lifecycle/inactivity.js +28 -0
  89. package/dist/lifecycle/transitions.d.ts +22 -1
  90. package/dist/lifecycle/transitions.d.ts.map +1 -1
  91. package/dist/lifecycle/transitions.js +51 -4
  92. package/dist/mcp/argumentClass.d.ts +51 -0
  93. package/dist/mcp/argumentClass.d.ts.map +1 -0
  94. package/dist/mcp/argumentClass.js +69 -0
  95. package/dist/mcp/capability.d.ts +50 -0
  96. package/dist/mcp/capability.d.ts.map +1 -0
  97. package/dist/mcp/capability.js +140 -0
  98. package/dist/mcp/clientMetadata.d.ts +40 -0
  99. package/dist/mcp/clientMetadata.d.ts.map +1 -0
  100. package/dist/mcp/clientMetadata.js +68 -0
  101. package/dist/mcp/consent.d.ts +49 -0
  102. package/dist/mcp/consent.d.ts.map +1 -0
  103. package/dist/mcp/consent.js +69 -0
  104. package/dist/mcp/dispatch.d.ts +35 -0
  105. package/dist/mcp/dispatch.d.ts.map +1 -0
  106. package/dist/mcp/dispatch.js +135 -0
  107. package/dist/mcp/floor.d.ts +37 -0
  108. package/dist/mcp/floor.d.ts.map +1 -0
  109. package/dist/mcp/floor.js +41 -0
  110. package/dist/mcp/host.d.ts +34 -0
  111. package/dist/mcp/host.d.ts.map +1 -0
  112. package/dist/mcp/host.js +2 -0
  113. package/dist/mcp/http/redirectList.d.ts +9 -0
  114. package/dist/mcp/http/redirectList.d.ts.map +1 -0
  115. package/dist/mcp/http/redirectList.js +24 -0
  116. package/dist/mcp/http/responses.d.ts +143 -0
  117. package/dist/mcp/http/responses.d.ts.map +1 -0
  118. package/dist/mcp/http/responses.js +83 -0
  119. package/dist/mcp/http/routes.d.ts +28 -0
  120. package/dist/mcp/http/routes.d.ts.map +1 -0
  121. package/dist/mcp/http/routes.js +517 -0
  122. package/dist/mcp/http/schemas.d.ts +24 -0
  123. package/dist/mcp/http/schemas.d.ts.map +1 -0
  124. package/dist/mcp/http/schemas.js +18 -0
  125. package/dist/mcp/marker.d.ts +15 -0
  126. package/dist/mcp/marker.d.ts.map +1 -0
  127. package/dist/mcp/marker.js +15 -0
  128. package/dist/mcp/provider.d.ts +78 -0
  129. package/dist/mcp/provider.d.ts.map +1 -0
  130. package/dist/mcp/provider.js +108 -0
  131. package/dist/mcp/purge.d.ts +15 -0
  132. package/dist/mcp/purge.d.ts.map +1 -0
  133. package/dist/mcp/purge.js +31 -0
  134. package/dist/mcp/rpc.d.ts +79 -0
  135. package/dist/mcp/rpc.d.ts.map +1 -0
  136. package/dist/mcp/rpc.js +103 -0
  137. package/dist/mcp/toolAudit.d.ts +76 -0
  138. package/dist/mcp/toolAudit.d.ts.map +1 -0
  139. package/dist/mcp/toolAudit.js +86 -0
  140. package/dist/migrations/0006_verification_outcomes.d.ts +15 -0
  141. package/dist/migrations/0006_verification_outcomes.d.ts.map +1 -0
  142. package/dist/migrations/0006_verification_outcomes.js +35 -0
  143. package/dist/migrations/0007_erasure_record.d.ts +17 -0
  144. package/dist/migrations/0007_erasure_record.d.ts.map +1 -0
  145. package/dist/migrations/0007_erasure_record.js +36 -0
  146. package/dist/migrations/0008_last_active.d.ts +15 -0
  147. package/dist/migrations/0008_last_active.d.ts.map +1 -0
  148. package/dist/migrations/0008_last_active.js +29 -0
  149. package/dist/migrations/set.d.ts +4 -1
  150. package/dist/migrations/set.d.ts.map +1 -1
  151. package/dist/migrations/set.js +8 -2
  152. package/dist/peer.d.ts +3 -2
  153. package/dist/peer.d.ts.map +1 -1
  154. package/dist/processing/activities.d.ts +6 -0
  155. package/dist/processing/activities.d.ts.map +1 -0
  156. package/dist/processing/activities.js +12 -0
  157. package/dist/purge/contribution.d.ts +20 -5
  158. package/dist/purge/contribution.d.ts.map +1 -1
  159. package/dist/purge/contribution.js +20 -6
  160. package/dist/purge/run.d.ts +75 -5
  161. package/dist/purge/run.d.ts.map +1 -1
  162. package/dist/purge/run.js +117 -14
  163. package/dist/purge/workflow.d.ts +15 -2
  164. package/dist/purge/workflow.d.ts.map +1 -1
  165. package/dist/purge/workflow.js +51 -7
  166. package/dist/test-utils/accountFootprint.d.ts +5 -2
  167. package/dist/test-utils/accountFootprint.d.ts.map +1 -1
  168. package/dist/test-utils/accountFootprint.js +7 -2
  169. package/dist/test-utils/liveApp.d.ts +6 -0
  170. package/dist/test-utils/liveApp.d.ts.map +1 -1
  171. package/dist/test-utils/liveApp.js +7 -2
  172. package/dist/token/handoff.d.ts +80 -0
  173. package/dist/token/handoff.d.ts.map +1 -0
  174. package/dist/token/handoff.js +136 -0
  175. package/dist/version.generated.d.ts +1 -1
  176. package/dist/version.generated.js +1 -1
  177. package/docs/account-lifecycle.md +59 -7
  178. package/docs/apple-signin.md +32 -4
  179. package/docs/facebook-oauth.md +2 -2
  180. package/docs/github-oauth.md +2 -2
  181. package/docs/google-oauth.md +9 -7
  182. package/docs/microsoft-oauth.md +2 -2
  183. package/package.json +11 -5
  184. package/pithy.manifest.json +2 -2
  185. package/pithy.mcp.manifest.json +36 -0
  186. package/src/audit/actions.ts +39 -0
  187. package/src/audit/emit.ts +63 -0
  188. package/src/audit/evidence.ts +8 -4
  189. package/src/capability.ts +80 -23
  190. package/src/client/api.ts +69 -19
  191. package/src/client/bearer.ts +388 -0
  192. package/src/client/handoff.ts +172 -0
  193. package/src/client/mcp.ts +140 -0
  194. package/src/data/betterAuth.ts +8 -4
  195. package/src/data/kitFields.ts +2 -0
  196. package/src/data/tables.ts +4 -2
  197. package/src/data/userLifecycle.ts +15 -3
  198. package/src/data/verificationOutcome.ts +86 -0
  199. package/src/email/send.ts +2 -2
  200. package/src/http/adminRoutes.ts +68 -3
  201. package/src/http/csrf.ts +4 -1
  202. package/src/http/guards.ts +48 -11
  203. package/src/http/handoff.ts +350 -0
  204. package/src/http/middleware.ts +29 -3
  205. package/src/http/resolve.ts +25 -25
  206. package/src/http/responses.ts +134 -8
  207. package/src/http/routes.ts +63 -4
  208. package/src/http/schemas.ts +85 -0
  209. package/src/http/views.ts +46 -2
  210. package/src/index.ts +2 -0
  211. package/src/instance/auth.ts +51 -1
  212. package/src/instance/plugins.ts +20 -2
  213. package/src/ledger/read.ts +133 -0
  214. package/src/ledger/record.ts +198 -0
  215. package/src/lifecycle/erasure.ts +118 -0
  216. package/src/lifecycle/inactivity.ts +56 -0
  217. package/src/lifecycle/transitions.ts +75 -5
  218. package/src/mcp/argumentClass.ts +112 -0
  219. package/src/mcp/capability.ts +194 -0
  220. package/src/mcp/clientMetadata.ts +81 -0
  221. package/src/mcp/consent.ts +95 -0
  222. package/src/mcp/dispatch.ts +154 -0
  223. package/src/mcp/floor.ts +62 -0
  224. package/src/mcp/host.ts +36 -0
  225. package/src/mcp/http/redirectList.ts +26 -0
  226. package/src/mcp/http/responses.ts +157 -0
  227. package/src/mcp/http/routes.ts +635 -0
  228. package/src/mcp/http/schemas.ts +37 -0
  229. package/src/mcp/marker.ts +18 -0
  230. package/src/mcp/provider.ts +151 -0
  231. package/src/mcp/purge.ts +39 -0
  232. package/src/mcp/rpc.ts +135 -0
  233. package/src/mcp/toolAudit.ts +132 -0
  234. package/src/migrations/0006_verification_outcomes.ts +51 -0
  235. package/src/migrations/0007_erasure_record.ts +43 -0
  236. package/src/migrations/0008_last_active.ts +30 -0
  237. package/src/migrations/set.ts +7 -1
  238. package/src/processing/activities.ts +14 -0
  239. package/src/purge/contribution.ts +37 -10
  240. package/src/purge/run.ts +179 -16
  241. package/src/purge/workflow.ts +65 -7
  242. package/src/seeds/example.ts +2 -2
  243. package/src/test-utils/accountFootprint.ts +10 -1
  244. package/src/test-utils/liveApp.ts +10 -1
  245. package/src/token/handoff.ts +180 -0
  246. package/src/version.generated.ts +1 -1
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Passwordless auth for Cloudflare. Magic link, email OTP, Google, Apple, Facebook, GitHub, Microsoft. Mobile and web, both first-class. Built on Better Auth. No email and password, ever.
4
4
 
5
- This capability fills core's identity seams. It mints sessions, issues short-lived JWT access tokens, registers devices, and validates every request — so other capabilities just call `requireAuth()`.
5
+ This capability fills core's identity seams. It mints and rotates sessions, whose token is the bearer credential, issues short-lived JWTs for services outside the Worker, registers devices, and validates every request — so other capabilities just call `requireAuth()`.
6
6
 
7
7
  ```sh
8
8
  pithy add auth
@@ -39,6 +39,8 @@ type AppAuth = AuthInstance<[ReturnType<typeof organization>]>;
39
39
  // …then `inferAdditionalFields<AppAuth>()` in the plugins list above.
40
40
  ```
41
41
 
42
+ **A native app takes the kit's own client, with an `origin`.** `src/client/api.ts` calls the Worker by rooted path on the page's own origin, with its httpOnly cookie, until an `origin` is set: then every request goes to that origin, sends no cookie, and carries the credential the handed-in `fetch` adds. `createBearerSession` in `src/client/bearer.ts` builds that fetch. The credential is the raw session token a sign-in answers with, held in memory and persisted through a secure store (`expo-secure-store`'s Keychain or Keystore), and sent as `Authorization: Bearer` to the Worker's origin and nowhere else. It rotates through `POST /auth/token/rotate` before it expires, one rotation in flight at a time, and the successor is stored before anything uses it. Another capability's client takes the session's `fetch` as its own. A redirect sign-in comes back with a one-time code rather than a cookie, and `src/client/handoff.ts` holds the helpers that trade it: `createHandoffVerifier`, `handoffCallbackURL`, `nativeSignInStartURL`, `handoffCode` and `exchangeHandoff` ([`docs/apple-signin.md`](docs/apple-signin.md) §6). `pithy ui add react-native` scaffolds an app wired to all three.
43
+
42
44
  **This section stays here.** `src/http/routes.ts` and `src/client/api.ts` both explain a design decision by pointing a reader at it by name — the flat response shape is read rather than rewritten precisely because `createAuthClient` is a first-class surface, and that argument is only checkable against the client this documents.
43
45
 
44
46
  ## Provider sign-in is identity-based, by design
@@ -60,7 +62,33 @@ So: **do not "improve" this by matching more addresses, and do not make the refu
60
62
 
61
63
  ## Account lifecycle
62
64
 
63
- An account can be suspended or deleted, and the kit refuses it at every door. An operator suspends and reinstates one through `POST /auth/admin/users/:userId/suspend` and `/reinstate`, under `auth:users:suspend`, with a reason the trail keeps. They delete one through `DELETE /auth/admin/users/:userId` — soft by default, restorable through `POST …/restore` until the purge window closes, or `mode: "hard"` to purge now — under `auth:users:delete`, and export everything the kit holds about one person through `GET …/export`, under `auth:users:export`. A person deletes their own account with `DELETE /auth/account { confirm: true }`, which is what the App Store and Google Play require of an app with accounts. A purge Workflow, hosted by your own Worker, erases a deleted account from every capability that holds it, one step per capability. Auth's own routes, sign-in and token refresh answer `auth/account_suspended` or `auth/account_deleted` (403); another capability's `requireAuth()` answers 401, and the client's next refresh gets the code. [`docs/account-lifecycle.md`](docs/account-lifecycle.md) has the two states, the record, the scopes, the routes, the purge and the Workflow classes to export for it, the mail, the hooks, the screens, and the purge contribution a capability declares for its own rows.
65
+ An account can be suspended or deleted, and the kit refuses it at every door. An operator suspends and reinstates one through `POST /auth/admin/users/:userId/suspend` and `/reinstate`, under `auth:users:suspend`, with a reason the trail keeps. They delete one through `DELETE /auth/admin/users/:userId` — soft by default, restorable through `POST …/restore` until the purge window closes, or `mode: "hard"` to purge now — under `auth:users:delete`, and export everything the kit holds about one person through `GET …/export`, under `auth:users:export`. A person deletes their own account with `DELETE /auth/account { confirm: true }`, which is what the App Store and Google Play require of an app with accounts. A purge Workflow, hosted by your own Worker, erases a deleted account from every capability that holds it, one step per capability; the four that keep a person's rows — payments, email, audit and the control plane's legal holds — say why, and the export says it with them. A legal hold on the account stops its purge until it is released, and when the Worker's `retention` block declares class ages, the daily pass soft-deletes an account inactive past them through this same lifecycle. Auth's own routes, sign-in and token refresh answer `auth/account_suspended` or `auth/account_deleted` (403); another capability's `requireAuth()` answers 401, and the client's next refresh gets the code. The admin user reads say where each account stands — `state`, `suspendedUntil` and `purgeAfter` — read the way enforcement reads them. [`docs/account-lifecycle.md`](docs/account-lifecycle.md) has the two states, the record, the scopes, the routes, the purge and the Workflow classes to export for it, the mail, the hooks, the screens, and the purge contribution a capability declares for its own rows.
66
+
67
+ **Every purge can be proved.** The purge records an audit event per step and on completion, and names the step it stopped at when it gives up. `GET /control-plane/erasure/user/:userId`, under `erasure:read`, attests one account's erasure from that record: when it was deleted, by which kind of actor and why, soft or hard, each step erased or kept with its reason, the purge's state, and the audit event behind each step by id and chain position. `GET /control-plane/erasure?since&until` counts every purge in a period and names each failed or overdue one. Nothing about the person crosses but the id. [`docs/CONTROL-PLANE.md` §12](../../docs/CONTROL-PLANE.md#erasure) has the shape.
68
+
69
+ ## Verification ledger
70
+
71
+ Every sign-in link and code auth sends is recorded in `pithy_auth_verification_outcomes`: its type (`magic_link` or `otp`), the verification row that carries it, the account it signs in to, the `pithy_email_jobs` id of the mail that carried it, and when it was issued, expires and was used. Never the token, never the address. Better Auth deletes a verification on its first use, so without this a used link leaves nothing behind and an unused one looks like one still waiting. A sign-up has no account when its link is sent: its row joins to its mail by the job id, and gains the account when the link is used. The row is written when the email seam answers, so a withheld mail is recorded with its suppressed job and a failed one with none, and it is stamped when the link or code creates a session. A wrong code moves the row with it, so the right one entered next still stamps it. A management client reads it through `GET /auth/admin/verifications`, under `auth:verifications:read`: over `since`/`until` (the last 30 days by default), the counts by type of issued, used, expired unused and still pending, and the rows, newest first and paged, narrowed by `type` or `state` if asked. Join `emailJobId` to `email:jobs:read` and `email:suppressions:read` to see which sign-ins failed because the mail did not land. The purge erases an account's rows with the rest of it, and the export carries them.
72
+
73
+ ## Agents: `mcp({ floor })`
74
+
75
+ `mcp` ships in this package beside `auth`, and lets your users' agents use your app as them. Composing it mounts an MCP endpoint at `POST /mcp` with the discovery an MCP client starts from, and composes an OAuth 2.1 authorization server into the auth instance: an agent identifies itself by the URL of a Client ID Metadata Document it publishes, or registers itself dynamically if it predates those, its user signs in and approves on your own consent screen, and the token it gets is bound to that endpoint and that user. A route is a tool only when its `describeRoute({ operation, tool })` says so, and every call runs through that route's own gates, so an agent does what its user can and nothing more.
76
+
77
+ ```sh
78
+ pithy add mcp --floor power:agents:use
79
+ ```
80
+
81
+ ```ts
82
+ mcp({ floor: { power: "agents:use" } }),
83
+ ```
84
+
85
+ **`floor` is required, and has no default.** `"signed-in"` admits every signed-in user, `{ power }` only a caller whose role holds it, `{ entitlement }` only a caller holding it. `pithy doctor` prints the floor in force. `database` must be the D1 binding `auth({ database })` uses; `pithy add mcp` writes it from auth's registration.
86
+
87
+ **Two screens.** `pithy ui add` writes `agent-consent.tsx`, where an agent's user signs in and approves, and `connected-applications.tsx`, where they see and revoke what they approved.
88
+
89
+ **Four tables**, `pithy_mcp_clients`, `pithy_mcp_consents`, `pithy_mcp_access_tokens` and `pithy_mcp_refresh_tokens`, in auth's database under the `mcp` migration namespace. `pithy migrate` creates them.
90
+
91
+ A Worker whose `auth({ plugins })` already composes an OAuth provider is refused: `mcp` composes the one its endpoint uses. [`docs/AGENT-ACCESS.md` §4](../../docs/AGENT-ACCESS.md#4-the-using-path) has the design.
64
92
 
65
93
  ## Server-authoritative writes
66
94
 
@@ -96,6 +96,19 @@ export declare const AuthAuditActions: {
96
96
  * behind it at all, not the row a cascade wrote.
97
97
  */
98
98
  readonly oauthUnlinked: "auth/oauth_unlinked";
99
+ /**
100
+ * A redirect sign-in ended on a native app's deep link, and the session it made was left there as a one-time
101
+ * code instead of a cookie. Attributed to the account; `sessionId` names the session the code stands for. Outcome
102
+ * `denied`, severity `warning`, when the deep link carried no challenge to bind a code to: no code is issued and
103
+ * the session is deleted.
104
+ */
105
+ readonly handoffIssued: "auth/handoff_issued";
106
+ /**
107
+ * A native app traded a one-time code for its session. Outcome `denied`, severity `warning`, for a code that was
108
+ * spent, expired, never issued or presented with the wrong verifier, with which of those in `metadata.reason` as
109
+ * `expired`, `unknown` or `mismatch`.
110
+ */
111
+ readonly handoffExchanged: "auth/handoff_exchanged";
99
112
  /** A device was registered or updated from sign-in metadata. */
100
113
  readonly deviceRegistered: "auth/device_registered";
101
114
  /** A device was revoked (its session(s) signed out). */
@@ -141,6 +154,8 @@ export declare const AuthAuditActions: {
141
154
  readonly adminUserRead: "auth/admin_user_read";
142
155
  /** The device registry was walked from the management surface. */
143
156
  readonly adminDevicesListed: "auth/admin_devices_listed";
157
+ /** The verification ledger was read from the management surface (#829): counts and rows over a window. */
158
+ readonly adminVerificationsListed: "auth/admin_verifications_listed";
144
159
  /** One named session was revoked from the management surface. */
145
160
  readonly adminSessionRevoked: "auth/admin_session_revoked";
146
161
  /** Every session a user held was revoked from the management surface — signed out everywhere. */
@@ -178,6 +193,17 @@ export declare const AuthAuditActions: {
178
193
  readonly adminUserRestored: "auth/admin_user_restored";
179
194
  /** A deleted account's data was erased. Recorded once, when the last purge step has run. */
180
195
  readonly adminUserPurged: "auth/admin_user_purged";
196
+ /**
197
+ * One purge step answered for a capability's rows: erased them, or kept them under a stated basis (#814).
198
+ * `metadata.step` names the capability and `metadata.disposition` says which. The erasure attestation cites it
199
+ * by event id and chain position (#823).
200
+ */
201
+ readonly adminUserPurgeStep: "auth/admin_user_purge_step";
202
+ /**
203
+ * A purge gave up at the step `metadata.step` names, until the next daily pass starts it again (#823). The
204
+ * erasure attestation cites it, and names every failed purge in a period.
205
+ */
206
+ readonly adminUserPurgeFailed: "auth/admin_user_purge_failed";
181
207
  /** The account's own holder deleted their account. Always a soft deletion, on the configured window. */
182
208
  readonly userSelfDeleted: "auth/user_self_deleted";
183
209
  /**
@@ -187,6 +213,19 @@ export declare const AuthAuditActions: {
187
213
  * answered; never with any of the data.
188
214
  */
189
215
  readonly adminUserExported: "auth/admin_user_exported";
216
+ /**
217
+ * A user let an MCP client act as them in this application. The one decision the consent screen asks,
218
+ * recorded with the client's id and the redirect it will send tokens to — the thing that identifies it, since
219
+ * its name is whatever it said. Asking again is a new consent and a new row.
220
+ */
221
+ readonly mcpGrantApproved: "auth/mcp_grant_approved";
222
+ /** A user refused an MCP client on the consent screen. */
223
+ readonly mcpGrantDenied: "auth/mcp_grant_denied";
224
+ /**
225
+ * A user revoked an MCP client from their connected applications. Its consent and refresh tokens are gone
226
+ * and its next call is refused. Revocation is the only narrowing the user has, so it is recorded like a grant.
227
+ */
228
+ readonly mcpGrantRevoked: "auth/mcp_grant_revoked";
190
229
  };
191
230
  /** One of the auth audit action codes. */
192
231
  export type AuthAuditAction = (typeof AuthAuditActions)[keyof typeof AuthAuditActions];
@@ -1 +1 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/audit/actions.ts"],"names":[],"mappings":"AAGA;;;;;;;GAOG;AACH,eAAO,MAAM,gBAAgB;IAC3B,+FAA+F;aAC/F,MAAM,EAAE,aAAa;IACrB;;;;;;;;OAQG;aACH,OAAO,EAAE,cAAc;IACvB;;;;OAIG;aACH,YAAY,EAAE,oBAAoB;IAClC,sHAAsH;aACtH,kBAAkB,EAAE,2BAA2B;IAC/C;;;;;OAKG;aACH,aAAa,EAAE,sBAAsB;IACrC;;;;;;;;;;;;;;;;;;;;;;OAsBG;aACH,OAAO,EAAE,eAAe;IACxB;;;;;;;;;;;;;;;;OAgBG;aACH,WAAW,EAAE,mBAAmB;IAChC;;;;;;;;;;;;;;;;OAgBG;aACH,aAAa,EAAE,qBAAqB;IACpC,gEAAgE;aAChE,gBAAgB,EAAE,wBAAwB;IAC1C,wDAAwD;aACxD,aAAa,EAAE,qBAAqB;IACpC;;;;;;;;;;OAUG;aACH,mBAAmB,EAAE,2BAA2B;IAChD;;;;;;;;;;OAUG;aACH,eAAe,EAAE,wBAAwB;IAEzC;;;;;;;;;;OAUG;IAEH,wGAAwG;aACxG,gBAAgB,EAAE,yBAAyB;IAC3C,sFAAsF;aACtF,aAAa,EAAE,sBAAsB;IACrC,kEAAkE;aAClE,kBAAkB,EAAE,2BAA2B;IAC/C,iEAAiE;aACjE,mBAAmB,EAAE,4BAA4B;IACjD,iGAAiG;aACjG,wBAAwB,EAAE,kCAAkC;IAC5D,wGAAwG;aACxG,kBAAkB,EAAE,2BAA2B;IAE/C;;;;;;;;;;;;;;OAcG;IAEH,iGAAiG;aACjG,kBAAkB,EAAE,2BAA2B;IAC/C,sEAAsE;aACtE,mBAAmB,EAAE,4BAA4B;IACjD,8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sF;aACtF,aAAa,EAAE,sBAAsB;IACrC,kEAAkE;aAClE,kBAAkB,EAAE,2BAA2B;IAC/C,0GAA0G;aAC1G,wBAAwB,EAAE,iCAAiC;IAC3D,iEAAiE;aACjE,mBAAmB,EAAE,4BAA4B;IACjD,iGAAiG;aACjG,wBAAwB,EAAE,kCAAkC;IAC5D,wGAAwG;aACxG,kBAAkB,EAAE,2BAA2B;IAE/C;;;;;;;;;;;;;;OAcG;IAEH,iGAAiG;aACjG,kBAAkB,EAAE,2BAA2B;IAC/C,sEAAsE;aACtE,mBAAmB,EAAE,4BAA4B;IACjD,8FAA8F;aAC9F,oBAAoB,EAAE,8BAA8B;IACpD;;;;OAIG;aACH,oBAAoB,EAAE,8BAA8B;IACpD,2FAA2F;aAC3F,iBAAiB,EAAE,0BAA0B;IAC7C,4FAA4F;aAC5F,eAAe,EAAE,wBAAwB;IACzC;;;;OAIG;aACH,kBAAkB,EAAE,4BAA4B;IAChD;;;OAGG;aACH,oBAAoB,EAAE,8BAA8B;IACpD,wGAAwG;aACxG,eAAe,EAAE,wBAAwB;IACzC;;;;;OAKG;aACH,iBAAiB,EAAE,0BAA0B;IAC7C;;;;OAIG;aACH,gBAAgB,EAAE,yBAAyB;IAC3C,0DAA0D;aAC1D,cAAc,EAAE,uBAAuB;IACvC;;;OAGG;aACH,eAAe,EAAE,wBAAwB;CACjC,CAAC;AAEX,0CAA0C;AAC1C,MAAM,MAAM,eAAe,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,OAAO,gBAAgB,CAAC,CAAC"}
@@ -97,6 +97,19 @@ const AuthAuditActions = {
97
97
  * behind it at all, not the row a cascade wrote.
98
98
  */
99
99
  oauthUnlinked: "auth/oauth_unlinked",
100
+ /**
101
+ * A redirect sign-in ended on a native app's deep link, and the session it made was left there as a one-time
102
+ * code instead of a cookie. Attributed to the account; `sessionId` names the session the code stands for. Outcome
103
+ * `denied`, severity `warning`, when the deep link carried no challenge to bind a code to: no code is issued and
104
+ * the session is deleted.
105
+ */
106
+ handoffIssued: "auth/handoff_issued",
107
+ /**
108
+ * A native app traded a one-time code for its session. Outcome `denied`, severity `warning`, for a code that was
109
+ * spent, expired, never issued or presented with the wrong verifier, with which of those in `metadata.reason` as
110
+ * `expired`, `unknown` or `mismatch`.
111
+ */
112
+ handoffExchanged: "auth/handoff_exchanged",
100
113
  /** A device was registered or updated from sign-in metadata. */
101
114
  deviceRegistered: "auth/device_registered",
102
115
  /** A device was revoked (its session(s) signed out). */
@@ -142,6 +155,8 @@ const AuthAuditActions = {
142
155
  adminUserRead: "auth/admin_user_read",
143
156
  /** The device registry was walked from the management surface. */
144
157
  adminDevicesListed: "auth/admin_devices_listed",
158
+ /** The verification ledger was read from the management surface (#829): counts and rows over a window. */
159
+ adminVerificationsListed: "auth/admin_verifications_listed",
145
160
  /** One named session was revoked from the management surface. */
146
161
  adminSessionRevoked: "auth/admin_session_revoked",
147
162
  /** Every session a user held was revoked from the management surface — signed out everywhere. */
@@ -179,6 +194,17 @@ const AuthAuditActions = {
179
194
  adminUserRestored: "auth/admin_user_restored",
180
195
  /** A deleted account's data was erased. Recorded once, when the last purge step has run. */
181
196
  adminUserPurged: "auth/admin_user_purged",
197
+ /**
198
+ * One purge step answered for a capability's rows: erased them, or kept them under a stated basis (#814).
199
+ * `metadata.step` names the capability and `metadata.disposition` says which. The erasure attestation cites it
200
+ * by event id and chain position (#823).
201
+ */
202
+ adminUserPurgeStep: "auth/admin_user_purge_step",
203
+ /**
204
+ * A purge gave up at the step `metadata.step` names, until the next daily pass starts it again (#823). The
205
+ * erasure attestation cites it, and names every failed purge in a period.
206
+ */
207
+ adminUserPurgeFailed: "auth/admin_user_purge_failed",
182
208
  /** The account's own holder deleted their account. Always a soft deletion, on the configured window. */
183
209
  userSelfDeleted: "auth/user_self_deleted",
184
210
  /**
@@ -187,7 +213,20 @@ const AuthAuditActions = {
187
213
  * capability's rows about the person. Recorded with the caller, the reason they gave, and which capabilities
188
214
  * answered; never with any of the data.
189
215
  */
190
- adminUserExported: "auth/admin_user_exported"
216
+ adminUserExported: "auth/admin_user_exported",
217
+ /**
218
+ * A user let an MCP client act as them in this application. The one decision the consent screen asks,
219
+ * recorded with the client's id and the redirect it will send tokens to — the thing that identifies it, since
220
+ * its name is whatever it said. Asking again is a new consent and a new row.
221
+ */
222
+ mcpGrantApproved: "auth/mcp_grant_approved",
223
+ /** A user refused an MCP client on the consent screen. */
224
+ mcpGrantDenied: "auth/mcp_grant_denied",
225
+ /**
226
+ * A user revoked an MCP client from their connected applications. Its consent and refresh tokens are gone
227
+ * and its next call is refused. Revocation is the only narrowing the user has, so it is recorded like a grant.
228
+ */
229
+ mcpGrantRevoked: "auth/mcp_grant_revoked"
191
230
  };
192
231
  //#endregion
193
232
  export { AuthAuditActions };
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  import type { AuditEmit } from "@pithy-sh/core/src/audit/recorder";
4
4
  import { z } from "zod";
5
+ import type { HandoffRefusal } from "../token/handoff";
5
6
  import { type AuthAuditAction } from "./actions";
6
7
  import type { AuthEmailDelivery, EndedSession } from "./evidence";
7
8
  /**
@@ -333,6 +334,39 @@ export declare function emitProviderChangeNotFresh(emit: AuditEmit, context: {
333
334
  sessionId: string;
334
335
  headers: Headers | undefined;
335
336
  }): Promise<void>;
337
+ /**
338
+ * Emit a `handoff_issued` event: a redirect sign-in's session left on a deep link as a one-time code, or, denied,
339
+ * a sign-in whose deep link carried no challenge, or a magic link to a custom scheme, so no code was issued.
340
+ */
341
+ export declare function emitHandoffIssued(emit: AuditEmit, context: ({
342
+ outcome: "success";
343
+ }
344
+ /** `unbound`: the link carried no challenge to bind a code to. `scheme`: a magic link to a custom scheme. */
345
+ | {
346
+ outcome: "denied";
347
+ reason: "unbound" | "scheme";
348
+ }) & {
349
+ userId: string;
350
+ sessionId: string;
351
+ ip?: string;
352
+ userAgent?: string;
353
+ }): Promise<void>;
354
+ /**
355
+ * Emit a `handoff_exchanged` event. A traded code is attributed to the account it signed in; a refused one is
356
+ * anonymous, because the code named nobody anybody can trust.
357
+ */
358
+ export declare function emitHandoffExchanged(emit: AuditEmit, context: {
359
+ outcome: "success";
360
+ userId: string;
361
+ sessionId: string;
362
+ ip?: string;
363
+ userAgent?: string;
364
+ } | {
365
+ outcome: "denied";
366
+ reason: HandoffRefusal;
367
+ ip?: string;
368
+ userAgent?: string;
369
+ }): Promise<void>;
336
370
  /** A blocked/failed auth attempt — recorded as `denied` (first-class). */
337
371
  export declare function emitDenied(emit: AuditEmit, context: {
338
372
  ip?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../src/audit/emit.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAEnE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,eAAe,EAAoB,MAAM,WAAW,CAAC;AACnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAElE;;;;;;;GAOG;AAEH,gFAAgF;AAChF,wBAAgB,WAAW,CAAC,OAAO,EAAE,OAAO,GAAG,SAAS,GAAG;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAK7F;AAUD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,MAAM,YAAY,GAAG,eAAe,GAAG,gBAAgB,GAAG,cAAc,CAAC;AAE/E;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElD,wGAAwG;AACxG,MAAM,WAAW,SAAS;IACxB,wCAAwC;IACxC,MAAM,EAAE,eAAe,CAAC;IACxB,6GAA6G;IAC7G,QAAQ,EAAE,YAAY,CAAC;IACvB,qGAAqG;IACrG,eAAe,EAAE,eAAe,CAAC;CAClC;AAED;;;;;;;;;;;;;;;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SAAS,EACf,OAAO,EACH;IAAE,OAAO,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GAC1F;IAAE,OAAO,EAAE,QAAQ,CAAC;IAAC,MAAM,EAAE,cAAc,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,GACjF,OAAO,CAAC,IAAI,CAAC,CAsBf;AAED,0EAA0E;AAC1E,wBAAsB,UAAU,CAC9B,IAAI,EAAE,SAAS,EACf,OAAO,EAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC5D,OAAO,CAAC,IAAI,CAAC,CASf"}
@@ -408,6 +408,52 @@ async function emitProviderChangeNotFresh(emit, context) {
408
408
  ...correlation(context.headers)
409
409
  });
410
410
  }
411
+ /**
412
+ * Emit a `handoff_issued` event: a redirect sign-in's session left on a deep link as a one-time code, or, denied,
413
+ * a sign-in whose deep link carried no challenge, or a magic link to a custom scheme, so no code was issued.
414
+ */
415
+ async function emitHandoffIssued(emit, context) {
416
+ await safeEmit(emit, {
417
+ action: AuthAuditActions.handoffIssued,
418
+ outcome: context.outcome,
419
+ ...context.outcome === "denied" ? {
420
+ severity: "warning",
421
+ metadata: { reason: context.reason }
422
+ } : {},
423
+ actorType: "user",
424
+ actorId: context.userId,
425
+ sessionId: context.sessionId,
426
+ ip: context.ip,
427
+ userAgent: context.userAgent
428
+ });
429
+ }
430
+ /**
431
+ * Emit a `handoff_exchanged` event. A traded code is attributed to the account it signed in; a refused one is
432
+ * anonymous, because the code named nobody anybody can trust.
433
+ */
434
+ async function emitHandoffExchanged(emit, context) {
435
+ if (context.outcome === "success") {
436
+ await safeEmit(emit, {
437
+ action: AuthAuditActions.handoffExchanged,
438
+ outcome: "success",
439
+ actorType: "user",
440
+ actorId: context.userId,
441
+ sessionId: context.sessionId,
442
+ ip: context.ip,
443
+ userAgent: context.userAgent
444
+ });
445
+ return;
446
+ }
447
+ await safeEmit(emit, {
448
+ action: AuthAuditActions.handoffExchanged,
449
+ outcome: "denied",
450
+ severity: "warning",
451
+ actorType: "anonymous",
452
+ ip: context.ip,
453
+ userAgent: context.userAgent,
454
+ metadata: { reason: context.reason }
455
+ });
456
+ }
411
457
  /** A blocked/failed auth attempt — recorded as `denied` (first-class). */
412
458
  async function emitDenied(emit, context) {
413
459
  await safeEmit(emit, {
@@ -420,4 +466,4 @@ async function emitDenied(emit, context) {
420
466
  });
421
467
  }
422
468
  //#endregion
423
- export { EVIDENCE_OBSERVERS, PATH_EVENTS, ProviderAccount, correlation, emitAfterRequest, emitControlPlaneAction, emitDenied, emitDeviceRevoked, emitProviderAccountChanged, emitProviderChangeNotFresh, emitProviderUnavailable, emitTokenRefresh, emitTokenReuseDetected, wasRefused };
469
+ export { EVIDENCE_OBSERVERS, PATH_EVENTS, ProviderAccount, correlation, emitAfterRequest, emitControlPlaneAction, emitDenied, emitDeviceRevoked, emitHandoffExchanged, emitHandoffIssued, emitProviderAccountChanged, emitProviderChangeNotFresh, emitProviderUnavailable, emitTokenRefresh, emitTokenReuseDetected, wasRefused };
@@ -56,14 +56,20 @@ export declare function sessionEndedDuring(requestContext: unknown): EndedSessio
56
56
  * error's text is the one thing in reach that nobody has vetted for what it might carry.
57
57
  */
58
58
  export type AuthEmailDelivery =
59
- /** Handed to the email seam, which wrote a job row for it. A send is what the trail may claim. */
59
+ /**
60
+ * Handed to the email seam, which wrote a job row for it. A send is what the trail may claim. `jobId` is that
61
+ * row's, for the verification ledger to join on (#829); optional, because a seam a test stands in for may not
62
+ * say.
63
+ */
60
64
  {
61
65
  readonly delivery: "queued";
66
+ readonly jobId?: string;
62
67
  }
63
- /** The capability withheld it, correctly, and named why. Not a fault, and not a send. */
68
+ /** The capability withheld it, correctly, and named why. Not a fault, and not a send. Its row is `jobId`. */
64
69
  | {
65
70
  readonly delivery: "withheld";
66
71
  readonly reason: string;
72
+ readonly jobId?: string;
67
73
  }
68
74
  /** The seam itself failed. Nothing was queued and something is wrong with this deployment. */
69
75
  | {
@@ -1 +1 @@
1
- {"version":3,"file":"evidence.d.ts","sourceRoot":"","sources":["../../src/audit/evidence.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,0GAA0G;AAC1G,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB;AAKD;;;;;;;;;;;GAWG;AACH,wBAAgB,gBAAgB,CAAC,cAAc,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI,CAK/E;AAED,8FAA8F;AAC9F,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,OAAO,GAAG,YAAY,GAAG,IAAI,CAG/E;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,iBAAiB;AAC3B,kGAAkG;AAChG;IAAE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE;AACjC,yFAAyF;GACvF;IAAE,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE;AAC5D,8FAA8F;GAC5F;IAAE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE7D,wGAAwG;AACxG,eAAO,MAAM,UAAU,mBAAmB,CAAC;AAK3C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAG9F;AAED,mHAAmH;A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,CAAC;AAqCvE,yGAAyG;AACzG,MAAM,WAAW,aAAa,CAAC,GAAG,EAAE,GAAG;IACrC,+EAA+E;IAC/E,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC9C,qGAAqG;IACrG,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,aAAa,CAAC,GAAG,SAAS,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE;IAC3D,mEAAmE;IACnE,EAAE,EAAE,YAAY,CAAC;IACjB,qFAAqF;IACrF,KAAK,EAAE,cAAc,CAAC;IACtB,0DAA0D;IAC1D,KAAK,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9C,GAAG,aAAa,CAAC,GAAG,EAAE,GAAG,CAAC,CAa1B;AAED,2GAA2G;AAC3G,MAAM,WAAW,gBAAgB;IAC/B,qGAAqG;IACrG,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,6GAA6G;IAC7G,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,iBAAiB,CAAC,aAAa,EAAE,OAAO,GAAG,gBAAgB,CAgB1E"}
@@ -5,11 +5,13 @@ import type { AuditEmit } from "@pithy-sh/core/src/audit/recorder";
5
5
  import type { Capability, PithyHonoEnv } from "@pithy-sh/core/src/capability/capability";
6
6
  import { type PurgeStep } from "@pithy-sh/core/src/capability/purge";
7
7
  import type { EmailCapability } from "@pithy-sh/email/src/capability";
8
- import { type TurnstileMode } from "@pithy-sh/turnstile/src/config/config";
8
+ import { type TurnstileCapability } from "@pithy-sh/turnstile/src/capability";
9
+ import { type TurnstileMode, type TurnstileTokenSource } from "@pithy-sh/turnstile/src/config/config";
9
10
  import type { Context } from "hono";
10
11
  import { z } from "zod";
11
12
  import type { GithubUserInfoResolver } from "./instance/githubUserInfo";
12
13
  import type { UserLifecycleHooks } from "./lifecycle/hooks";
14
+ import type { McpHost, McpWiring } from "./mcp/host";
13
15
  import { type AuthPeer } from "./peer";
14
16
  /** The auth capability's configuration — the thin surface an adopter owns in `pithy.config.ts`. */
15
17
  export declare const AuthConfig: z.ZodObject<{
@@ -58,6 +60,14 @@ export declare const AuthConfig: z.ZodObject<{
58
60
  }, z.core.$strip>;
59
61
  export type AuthConfig = z.output<typeof AuthConfig>;
60
62
  export type AuthConfigInput = z.input<typeof AuthConfig>;
63
+ /** The widget the sign-in routes are gated with, and where the gate reads its token. */
64
+ export interface TurnstileLoginGate {
65
+ mode: TurnstileMode;
66
+ /** The `token` source turnstile's config names, which its client projection hands a screen. */
67
+ token: TurnstileTokenSource;
68
+ }
69
+ /** The sign-in gate a composed turnstile asks for, or `undefined` when none is composed or sign-in is unprotected. */
70
+ export declare function turnstileLoginGate(capability: TurnstileCapability | undefined): TurnstileLoginGate | undefined;
61
71
  /**
62
72
  * The runtime wiring the middleware and routes close over. `config` is known at `auth()` call time;
63
73
  * `emailConfig` and `turnstile` are filled by `compose` from the composed peer capabilities, before
@@ -70,9 +80,7 @@ export interface AuthWiring {
70
80
  /** The email capability's bound enqueue seam — how magic-link/OTP are delivered. Set by `compose`. */
71
81
  enqueueEmail: EmailCapability["enqueue"] | undefined;
72
82
  /** The turnstile login gate, when the turnstile capability is composed. Set by `compose`. */
73
- turnstile: {
74
- mode: TurnstileMode;
75
- } | undefined;
83
+ turnstile: TurnstileLoginGate | undefined;
76
84
  /**
77
85
  * The adopter's session-revoked listener, or absent. See {@link AuthOptions.onSessionRevoked}.
78
86
  *
@@ -93,11 +101,21 @@ export interface AuthWiring {
93
101
  */
94
102
  lifecycleHooks?: UserLifecycleHooks | undefined;
95
103
  /**
96
- * Every composed capability's purge step for a user, auth's own among them, in composition order (#622). Filled
104
+ * Every composed capability's purge step for a user, auth's own among them, in composition order. Filled
97
105
  * by `compose`; the export route reads every capability's contribution from it, and the purge runs it.
98
106
  * Optional on the wiring for the reason `onSessionRevoked` is: a harness that builds this by hand composes none.
99
107
  */
100
108
  purgeSteps?: readonly PurgeStep[] | undefined;
109
+ /**
110
+ * The MCP capability's endpoint and consent screen, when one is composed beside this one. Set by
111
+ * `compose`; the instance then carries the OAuth provider that mints its tokens.
112
+ */
113
+ mcp?: McpWiring | undefined;
114
+ /**
115
+ * Every capability composed beside this one, auth among them. Set by `compose`; a rotation announces itself to
116
+ * each one's `sessionRotated` through core. Optional on the wiring for the reason `onSessionRevoked` is.
117
+ */
118
+ composed?: readonly Capability[] | undefined;
101
119
  }
102
120
  /** The session a {@link ScopeResolver} is asked about — the one Better Auth just resolved for this request. */
103
121
  export interface ScopeResolverSession {
@@ -107,7 +125,7 @@ export interface ScopeResolverSession {
107
125
  sessionId: string;
108
126
  }
109
127
  /**
110
- * Decide what this request's caller is, and answer the scopes that attests to (#560).
128
+ * Decide what this request's caller is, and answer the scopes that attests to.
111
129
  *
112
130
  * Called by the session middleware on every authenticated request, after Better Auth has resolved the
113
131
  * session and before any route runs. What it returns becomes `AuthContext.scopes`. It reads the **request**,
@@ -168,7 +186,7 @@ export type AuthOptions = AuthConfigInput & UserLifecycleHooks & {
168
186
  */
169
187
  onSessionRevoked?: SessionRevokedListener;
170
188
  /**
171
- * Decide, per request, what this request's caller is — and so which scope gates it opens (#560).
189
+ * Decide, per request, what this request's caller is — and so which scope gates it opens.
172
190
  *
173
191
  * `leaderboard:submit`, `rating:record`, `leaderboard:admin` and `ledger:admin` are **attestations about
174
192
  * the caller, not permissions granted to the user**: each says *this write came from the adopter's own
@@ -192,25 +210,27 @@ export interface AuthCapability extends Capability {
192
210
  authConfig: AuthConfig;
193
211
  /**
194
212
  * The adopter's account-lifecycle hooks, as `auth()` was handed them. Read by whatever runs a transition
195
- * outside a request this capability serves — the purge Workflow (#622) fires `onUserPurged` through it.
213
+ * outside a request this capability serves — the purge Workflow fires `onUserPurged` through it.
196
214
  */
197
215
  lifecycleHooks: UserLifecycleHooks;
198
216
  /**
199
- * Every composed capability's purge step for a user, auth's own among them, in composition order (#622). Empty
217
+ * Every composed capability's purge step for a user, auth's own among them, in composition order. Empty
200
218
  * until `compose` has run. Read by the purge Workflow, which runs in the Worker that composed it.
201
219
  */
202
220
  purgeSteps: readonly PurgeStep[];
203
221
  /**
204
222
  * The audit recorder for code with no request, over one run's env — the composed audit capability's, or the
205
- * no-op (#622). Read by the purge Workflow, which owes the trail its `auth/admin_user_purged`.
223
+ * no-op. Read by the purge Workflow, which owes the trail its `auth/admin_user_purged`.
206
224
  */
207
225
  auditFor: (env: Record<string, unknown>) => AuditEmit;
208
226
  /**
209
227
  * What a capability composed beside this one reads an account through — `matchmaking`, `support`,
210
228
  * `testers`. Found in their `compose` hooks, so none of them imports this package and a project without
211
- * auth bundles them (#645). See `peer.ts`.
229
+ * auth bundles them. See `peer.ts`.
212
230
  */
213
231
  authPeer: AuthPeer;
232
+ /** What the MCP capability composed beside this one reads. See `mcp/host.ts`. */
233
+ mcpHost: McpHost;
214
234
  }
215
235
  /**
216
236
  * The auth capability. Passwordless sign-in (magic link, OTP, Google, Apple), the hybrid bearer +
@@ -1 +1 @@
1
- {"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAmB,MAAM,0CAA0C,CAAC;AAE1G,OAAO,EAAE,KAAK,SAAS,EAAc,MAAM,qCAAqC,CAAC;AAEjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGtE,OAAO,EAA0B,KAAK,aAAa,EA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,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,EAAE,EAAE,UAAU,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEhH;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,eAAe,GACvC,kBAAkB,GAAG;IACnB;;;;;;;;;;;;;OAaG;IACH,qBAAqB,CAAC,EAAE,sBAAsB,CAAC;IAC/C;;;;;;;;;;;;;;OAcG;IACH,gBAAgB,CAAC,EAAE,sBAAsB,CAAC;IAC1C;;;;;;;;;;;;;;;;;OAiBG;IACH,aAAa,CAAC,EAAE,aAAa,CAAC;CAC/B,CAAC;AAEJ,6EAA6E;AAC7E,MAAM,WAAW,cAAe,SAAQ,UAAU;IAChD,UAAU,EAAE,UAAU,CAAC;IACvB;;;OAGG;IACH,cAAc,EAAE,kBAAkB,CAAC;IACnC;;;OAGG;IACH,UAAU,EAAE,SAAS,SAAS,EAAE,CAAC;IACjC;;;OAGG;IACH,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,SAAS,CAAC;IACtD;;;;OAIG;IACH,QAAQ,EAAE,QAAQ,CAAC;IACnB,iFAAiF;IACjF,OAAO,EAAE,OAAO,CAAC;CAClB;AAiCD;;;;;GAKG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,cAAc,CAkOzD;AAED,0DAA0D;AAC1D,wBAAgB,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,UAAU,IAAI,cAAc,CAErF"}
@@ -1,21 +1,27 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
+ import { AuthAuditActions } from "./audit/actions.js";
3
4
  import { authTables } from "./data/tables.js";
5
+ import { baseURLResolver } from "./http/baseUrl.js";
4
6
  import { publishSameOrigin } from "./http/csrf.js";
5
7
  import { authSecretsRegistryFor, inapplicableProviderSecrets } from "./instance/secrets.js";
6
8
  import { authDevSessionSeed } from "./seeds/devSession.js";
7
9
  import { AuthPlugin, assertAdditivePlugins } from "./instance/plugins.js";
10
+ import { getAuthInstance } from "./http/resolve.js";
8
11
  import { registerDevLoginRoute } from "./http/devLoginRoute.js";
9
12
  import { authAdminRoutes } from "./http/guards.js";
10
13
  import { createSessionMiddleware } from "./http/middleware.js";
11
14
  import { createRateLimitMiddleware } from "./http/rateLimit.js";
12
15
  import { authWorkflows } from "./purge/specs.js";
13
16
  import { createAuthRoutes } from "./http/routes.js";
17
+ import { authErasureRecords } from "./lifecycle/erasure.js";
18
+ import { isMcpCapability } from "./mcp/marker.js";
14
19
  import "./migrations/0001_init.js";
15
20
  import { authPluginPlan } from "./migrations/pluginTables.js";
16
21
  import { AUTH_MIGRATIONS } from "./migrations/set.js";
17
22
  import { authPeer } from "./peer.js";
18
- import { authPurgeContribution } from "./purge/contribution.js";
23
+ import { AUTH_PROCESSING } from "./processing/activities.js";
24
+ import { authAddressOf, authPurgeContribution } from "./purge/contribution.js";
19
25
  import { authExampleSeed } from "./seeds/example.js";
20
26
  import { PACKAGE_NAME, PACKAGE_VERSION } from "./version.generated.js";
21
27
  import { composedAuditEmit } from "@pithy-sh/core/src/audit/composed";
@@ -71,6 +77,14 @@ const AuthConfig = z.object({
71
77
  }).prefault({}).describe("Which account-lifecycle emails are sent. All four send by default, through `@pithy-sh/email`; switch one off by setting it to false."),
72
78
  plugins: z.array(AuthPlugin).default([]).describe("Additional Better Auth plugins to compose — `organization()`, `passkey()`, `twoFactor()`, `apiKey()`, a generic OAuth provider. Additive: they join the set the kit composes (i18n, bearer, jwt, magic-link, email-otp) and cannot replace one. Tables a plugin declares are created by `pithy migrate`; add the matching client plugin to `createAuthClient` for its typed client surface.")
73
79
  }).describe("Configuration for the auth capability.");
80
+ /** The sign-in gate a composed turnstile asks for, or `undefined` when none is composed or sign-in is unprotected. */
81
+ function turnstileLoginGate(capability) {
82
+ const mode = capability?.turnstileConfig.protect[TURNSTILE_LOGIN_ACTION];
83
+ return mode ? {
84
+ mode,
85
+ token: capability.turnstileConfig.token
86
+ } : void 0;
87
+ }
74
88
  /**
75
89
  * Refuse a composition where a Better Auth plugin's table is one another capability already declares in
76
90
  * the same database. `capabilities` is every capability composed into this backend, so this is the first
@@ -159,6 +173,18 @@ function auth(options) {
159
173
  }
160
174
  } },
161
175
  purge: [authPurgeContribution(resolved.database, pluginPlan.userTables)],
176
+ processing: AUTH_PROCESSING,
177
+ erasureRecords: authErasureRecords(resolved.database),
178
+ purgeWindow: {
179
+ subject: "user",
180
+ days: resolved.retention.purgeAfterDays
181
+ },
182
+ lifecycleAuditActions: [
183
+ AuthAuditActions.adminUserSuspended,
184
+ AuthAuditActions.adminUserReinstated,
185
+ AuthAuditActions.adminUserRestored
186
+ ],
187
+ addressOf: authAddressOf(resolved.database),
162
188
  workflows: authWorkflows,
163
189
  compose: ({ capabilities }) => {
164
190
  const email = capabilities.find(isEmailCapability);
@@ -167,11 +193,12 @@ function auth(options) {
167
193
  action: "Add `email(...)` to your capabilities — magic-link and OTP delivery enqueue email jobs."
168
194
  });
169
195
  wiring.enqueueEmail = email.enqueue;
170
- const loginMode = capabilities.find(isTurnstileCapability)?.turnstileConfig.protect[TURNSTILE_LOGIN_ACTION];
171
- wiring.turnstile = loginMode ? { mode: loginMode } : void 0;
196
+ wiring.turnstile = turnstileLoginGate(capabilities.find(isTurnstileCapability));
172
197
  assertPluginTablesUnclaimed(capabilities, resolved.database, pluginPlan.extensions);
173
198
  steps.splice(0, steps.length, ...purgeSteps(capabilities, "user"));
199
+ wiring.mcp = capabilities.find(isMcpCapability)?.mcpWiring;
174
200
  composition = capabilities;
201
+ wiring.composed = capabilities;
175
202
  },
176
203
  /**
177
204
  * The client-safe projection — what a sign-in screen needs and nothing more: where to call
@@ -226,7 +253,13 @@ function auth(options) {
226
253
  authPeer,
227
254
  lifecycleHooks,
228
255
  purgeSteps: steps,
229
- auditFor: (env) => composedAuditEmit(composition, env)
256
+ auditFor: (env) => composedAuditEmit(composition, env),
257
+ mcpHost: {
258
+ instance: (c) => getAuthInstance(c, wiring),
259
+ baseURL: (request) => baseURLResolver(resolved.baseURL)(request),
260
+ basePath: resolved.basePath,
261
+ database: resolved.database
262
+ }
230
263
  });
231
264
  }
232
265
  /** Type guard: is this capability the auth capability? */
@@ -234,4 +267,4 @@ function isAuthCapability(capability) {
234
267
  return capability.name === "auth" && "authConfig" in capability;
235
268
  }
236
269
  //#endregion
237
- export { AuthConfig, auth, isAuthCapability };
270
+ export { AuthConfig, auth, isAuthCapability, turnstileLoginGate };