@pithy-sh/auth 0.9.0 → 0.11.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 (188) hide show
  1. package/README.md +8 -2
  2. package/dist/admin/users.js +1 -1
  3. package/dist/audit/actions.d.ts +40 -0
  4. package/dist/audit/actions.d.ts.map +1 -1
  5. package/dist/audit/actions.js +41 -1
  6. package/dist/audit/emit.d.ts +2 -0
  7. package/dist/audit/emit.d.ts.map +1 -1
  8. package/dist/audit/emit.js +2 -2
  9. package/dist/capability.d.ts +45 -1
  10. package/dist/capability.d.ts.map +1 -1
  11. package/dist/capability.js +40 -5
  12. package/dist/client/lifecycle.d.ts +19 -0
  13. package/dist/client/lifecycle.d.ts.map +1 -0
  14. package/dist/client/lifecycle.js +25 -0
  15. package/dist/client/projection.d.ts +4 -0
  16. package/dist/client/projection.d.ts.map +1 -1
  17. package/dist/data/betterAuth.d.ts +4 -0
  18. package/dist/data/betterAuth.d.ts.map +1 -1
  19. package/dist/data/betterAuth.js +6 -2
  20. package/dist/data/kitFields.d.ts +20 -25
  21. package/dist/data/kitFields.d.ts.map +1 -1
  22. package/dist/data/kitFields.js +28 -32
  23. package/dist/data/tables.d.ts +29 -2
  24. package/dist/data/tables.d.ts.map +1 -1
  25. package/dist/data/tables.js +5 -3
  26. package/dist/data/userLifecycle.d.ts +62 -0
  27. package/dist/data/userLifecycle.d.ts.map +1 -0
  28. package/dist/data/userLifecycle.js +51 -0
  29. package/dist/http/adminRoutes.d.ts.map +1 -1
  30. package/dist/http/adminRoutes.js +270 -5
  31. package/dist/http/guards.d.ts +24 -1
  32. package/dist/http/guards.d.ts.map +1 -1
  33. package/dist/http/guards.js +59 -3
  34. package/dist/http/lifecycleGate.d.ts +18 -0
  35. package/dist/http/lifecycleGate.d.ts.map +1 -0
  36. package/dist/http/lifecycleGate.js +75 -0
  37. package/dist/http/middleware.d.ts +30 -1
  38. package/dist/http/middleware.d.ts.map +1 -1
  39. package/dist/http/middleware.js +89 -7
  40. package/dist/http/providerRefusal.d.ts.map +1 -1
  41. package/dist/http/providerRefusal.js +8 -0
  42. package/dist/http/resolve.d.ts.map +1 -1
  43. package/dist/http/resolve.js +7 -4
  44. package/dist/http/responses.d.ts +180 -0
  45. package/dist/http/responses.d.ts.map +1 -1
  46. package/dist/http/responses.js +142 -1
  47. package/dist/http/routes.d.ts +1 -0
  48. package/dist/http/routes.d.ts.map +1 -1
  49. package/dist/http/routes.js +65 -4
  50. package/dist/http/schemas.d.ts +57 -0
  51. package/dist/http/schemas.d.ts.map +1 -1
  52. package/dist/http/schemas.js +51 -1
  53. package/dist/http/views.d.ts +39 -2
  54. package/dist/http/views.d.ts.map +1 -1
  55. package/dist/http/views.js +105 -1
  56. package/dist/instance/auth.d.ts +55 -3
  57. package/dist/instance/auth.d.ts.map +1 -1
  58. package/dist/instance/auth.js +53 -2
  59. package/dist/instance/microsoftEmail.d.ts +70 -0
  60. package/dist/instance/microsoftEmail.d.ts.map +1 -0
  61. package/dist/instance/microsoftEmail.js +96 -0
  62. package/dist/instance/providerSignInGate.d.ts +7 -6
  63. package/dist/instance/providerSignInGate.d.ts.map +1 -1
  64. package/dist/instance/providerSignInGate.js +7 -6
  65. package/dist/instance/providers.d.ts +7 -5
  66. package/dist/instance/providers.d.ts.map +1 -1
  67. package/dist/instance/providers.js +5 -3
  68. package/dist/instance/secrets.d.ts +64 -3
  69. package/dist/instance/secrets.d.ts.map +1 -1
  70. package/dist/instance/secrets.js +44 -5
  71. package/dist/lifecycle/audited.d.ts +48 -0
  72. package/dist/lifecycle/audited.d.ts.map +1 -0
  73. package/dist/lifecycle/audited.js +65 -0
  74. package/dist/lifecycle/enforce.d.ts +75 -0
  75. package/dist/lifecycle/enforce.d.ts.map +1 -0
  76. package/dist/lifecycle/enforce.js +111 -0
  77. package/dist/lifecycle/hooks.d.ts +53 -0
  78. package/dist/lifecycle/hooks.d.ts.map +1 -0
  79. package/dist/lifecycle/hooks.js +2 -0
  80. package/dist/lifecycle/reason.d.ts +11 -0
  81. package/dist/lifecycle/reason.d.ts.map +1 -0
  82. package/dist/lifecycle/reason.js +13 -0
  83. package/dist/lifecycle/request.d.ts +18 -0
  84. package/dist/lifecycle/request.d.ts.map +1 -0
  85. package/dist/lifecycle/request.js +31 -0
  86. package/dist/lifecycle/state.d.ts +64 -0
  87. package/dist/lifecycle/state.d.ts.map +1 -0
  88. package/dist/lifecycle/state.js +90 -0
  89. package/dist/lifecycle/transitions.d.ts +272 -0
  90. package/dist/lifecycle/transitions.d.ts.map +1 -0
  91. package/dist/lifecycle/transitions.js +623 -0
  92. package/dist/migrations/0004_user_lifecycle.d.ts +28 -0
  93. package/dist/migrations/0004_user_lifecycle.d.ts.map +1 -0
  94. package/dist/migrations/0004_user_lifecycle.js +47 -0
  95. package/dist/migrations/0005_purge_once.d.ts +22 -0
  96. package/dist/migrations/0005_purge_once.d.ts.map +1 -0
  97. package/dist/migrations/0005_purge_once.js +35 -0
  98. package/dist/migrations/pluginTables.d.ts +8 -0
  99. package/dist/migrations/pluginTables.d.ts.map +1 -1
  100. package/dist/migrations/pluginTables.js +8 -1
  101. package/dist/migrations/set.d.ts +3 -1
  102. package/dist/migrations/set.d.ts.map +1 -1
  103. package/dist/migrations/set.js +6 -2
  104. package/dist/peer.d.ts +4 -0
  105. package/dist/peer.d.ts.map +1 -1
  106. package/dist/purge/contribution.d.ts +47 -0
  107. package/dist/purge/contribution.d.ts.map +1 -0
  108. package/dist/purge/contribution.js +141 -0
  109. package/dist/purge/retryPolicy.d.ts +22 -0
  110. package/dist/purge/retryPolicy.d.ts.map +1 -0
  111. package/dist/purge/retryPolicy.js +26 -0
  112. package/dist/purge/run.d.ts +88 -0
  113. package/dist/purge/run.d.ts.map +1 -0
  114. package/dist/purge/run.js +102 -0
  115. package/dist/purge/specs.d.ts +71 -0
  116. package/dist/purge/specs.d.ts.map +1 -0
  117. package/dist/purge/specs.js +72 -0
  118. package/dist/purge/start.d.ts +42 -0
  119. package/dist/purge/start.d.ts.map +1 -0
  120. package/dist/purge/start.js +37 -0
  121. package/dist/purge/workflow.d.ts +58 -0
  122. package/dist/purge/workflow.d.ts.map +1 -0
  123. package/dist/purge/workflow.js +96 -0
  124. package/dist/test-utils/accountFootprint.d.ts +10 -0
  125. package/dist/test-utils/accountFootprint.d.ts.map +1 -0
  126. package/dist/test-utils/accountFootprint.js +44 -0
  127. package/dist/test-utils/liveApp.d.ts +21 -0
  128. package/dist/test-utils/liveApp.d.ts.map +1 -1
  129. package/dist/test-utils/liveApp.js +1 -0
  130. package/dist/test-utils/scopedBackend.d.ts +21 -0
  131. package/dist/test-utils/scopedBackend.d.ts.map +1 -1
  132. package/dist/test-utils/scopedBackend.js +7 -1
  133. package/dist/version.generated.d.ts +1 -1
  134. package/dist/version.generated.d.ts.map +1 -1
  135. package/dist/version.generated.js +1 -1
  136. package/docs/account-lifecycle.md +217 -0
  137. package/docs/apple-signin.md +7 -1
  138. package/docs/facebook-oauth.md +7 -1
  139. package/docs/github-oauth.md +7 -1
  140. package/docs/google-oauth.md +7 -1
  141. package/docs/microsoft-oauth.md +177 -0
  142. package/package.json +5 -5
  143. package/pithy.manifest.json +17 -3
  144. package/src/audit/actions.ts +42 -0
  145. package/src/audit/emit.ts +4 -2
  146. package/src/capability.ts +170 -52
  147. package/src/client/lifecycle.ts +27 -0
  148. package/src/client/projection.ts +4 -0
  149. package/src/data/betterAuth.ts +21 -1
  150. package/src/data/kitFields.ts +27 -0
  151. package/src/data/tables.ts +4 -2
  152. package/src/data/userLifecycle.ts +83 -0
  153. package/src/http/adminRoutes.ts +398 -2
  154. package/src/http/guards.ts +61 -1
  155. package/src/http/lifecycleGate.ts +78 -0
  156. package/src/http/middleware.ts +104 -2
  157. package/src/http/providerRefusal.ts +10 -0
  158. package/src/http/resolve.ts +8 -3
  159. package/src/http/responses.ts +245 -0
  160. package/src/http/routes.ts +93 -4
  161. package/src/http/schemas.ts +110 -0
  162. package/src/http/views.ts +147 -2
  163. package/src/instance/auth.ts +74 -2
  164. package/src/instance/microsoftEmail.ts +111 -0
  165. package/src/instance/providerSignInGate.ts +7 -6
  166. package/src/instance/providers.ts +8 -4
  167. package/src/instance/secrets.ts +59 -5
  168. package/src/lifecycle/audited.ts +104 -0
  169. package/src/lifecycle/enforce.ts +139 -0
  170. package/src/lifecycle/hooks.ts +54 -0
  171. package/src/lifecycle/reason.ts +11 -0
  172. package/src/lifecycle/request.ts +39 -0
  173. package/src/lifecycle/state.ts +101 -0
  174. package/src/lifecycle/transitions.ts +872 -0
  175. package/src/migrations/0004_user_lifecycle.ts +68 -0
  176. package/src/migrations/0005_purge_once.ts +42 -0
  177. package/src/migrations/pluginTables.ts +19 -1
  178. package/src/migrations/set.ts +5 -1
  179. package/src/purge/contribution.ts +191 -0
  180. package/src/purge/retryPolicy.ts +26 -0
  181. package/src/purge/run.ts +185 -0
  182. package/src/purge/specs.ts +95 -0
  183. package/src/purge/start.ts +79 -0
  184. package/src/purge/workflow.ts +144 -0
  185. package/src/test-utils/accountFootprint.ts +95 -0
  186. package/src/test-utils/liveApp.ts +2 -1
  187. package/src/test-utils/scopedBackend.ts +2 -1
  188. package/src/version.generated.ts +1 -1
@@ -26,7 +26,7 @@
26
26
  * every legitimate management call, permanently, and **no credential could fix it** — there is no user
27
27
  * to sign in as. `controlPlaneIsolation.workers.test.ts` pins both directions of that separation.
28
28
  *
29
- * ## Five scopes, because these are five different blast radii
29
+ * ## Eight scopes, because these are eight different blast radii
30
30
  *
31
31
  * The temptation is one `auth:admin` flag, and on this capability it is the most dangerous version of
32
32
  * that mistake. **Reading a user is a privacy operation; revoking their sessions is an availability
@@ -84,15 +84,41 @@ const AUTH_USERS_LOGOUT_SCOPE = "auth:users:logout";
84
84
  */
85
85
  const AUTH_DEVICES_REVOKE_SCOPE = "auth:devices:revoke";
86
86
  /**
87
+ * Suspend an account and reinstate it (#620): `POST {base}/admin/users/:userId/suspend` and `/reinstate` (#621). Ending somebody's access is an availability
88
+ * operation on one person, and reversible — which is what separates it from deleting them, and why it is
89
+ * granted apart from both reading them and erasing them.
90
+ */
91
+ const AUTH_USERS_SUSPEND_SCOPE = "auth:users:suspend";
92
+ /**
93
+ * Delete an account, restore one inside its purge window, and start a purge (#620):
94
+ * `DELETE {base}/admin/users/:userId` and `POST …/restore` (#622). The
95
+ * one scope on this surface whose worst case cannot be undone: once the window closes, the person's rows are
96
+ * gone from every capability that held them.
97
+ */
98
+ const AUTH_USERS_DELETE_SCOPE = "auth:users:delete";
99
+ /**
100
+ * Export everything the kit holds about one account — the answer to an access request (#620):
101
+ * `GET {base}/admin/users/:userId/export` (#622). A disclosure, and a far larger one than reading the user: it carries every capability's rows about
102
+ * them, so it is granted on its own and audited as one.
103
+ */
104
+ const AUTH_USERS_EXPORT_SCOPE = "auth:users:export";
105
+ /**
87
106
  * Every control-plane scope auth defines — what `pithy dashboard connect` offers for this capability,
88
107
  * and the list a manifest or a doc quotes rather than re-typing.
108
+ *
109
+ * **The lifecycle scopes were declared before the routes that require them** (#620): suspend and reinstate
110
+ * landed in #621, delete, restore and export in #622. Declaring the vocabulary here, once, is what let those
111
+ * issues build on one name each rather than each choosing its own.
89
112
  */
90
113
  const AUTH_CONTROL_PLANE_SCOPES = [
91
114
  AUTH_USERS_READ_SCOPE,
92
115
  AUTH_DEVICES_READ_SCOPE,
93
116
  AUTH_SESSIONS_REVOKE_SCOPE,
94
117
  AUTH_USERS_LOGOUT_SCOPE,
95
- AUTH_DEVICES_REVOKE_SCOPE
118
+ AUTH_DEVICES_REVOKE_SCOPE,
119
+ AUTH_USERS_SUSPEND_SCOPE,
120
+ AUTH_USERS_DELETE_SCOPE,
121
+ AUTH_USERS_EXPORT_SCOPE
96
122
  ];
97
123
  /**
98
124
  * Auth's management surface, as `GET /control-plane/manifest` reports it.
@@ -143,8 +169,38 @@ function authAdminRoutes(basePath) {
143
169
  path: `${basePath}/admin/users/:userId/devices/revoke`,
144
170
  scope: AUTH_DEVICES_REVOKE_SCOPE,
145
171
  summary: "Sign one device out and forget it — for a phone reported lost."
172
+ },
173
+ {
174
+ method: "POST",
175
+ path: `${basePath}/admin/users/:userId/suspend`,
176
+ scope: AUTH_USERS_SUSPEND_SCOPE,
177
+ summary: "Suspend a user, with a reason. Their sessions end and every sign-in is refused."
178
+ },
179
+ {
180
+ method: "POST",
181
+ path: `${basePath}/admin/users/:userId/reinstate`,
182
+ scope: AUTH_USERS_SUSPEND_SCOPE,
183
+ summary: "Lift a suspension, with a reason. They sign in again; no session comes back."
184
+ },
185
+ {
186
+ method: "DELETE",
187
+ path: `${basePath}/admin/users/:userId`,
188
+ scope: AUTH_USERS_DELETE_SCOPE,
189
+ summary: "Delete a user, with a reason. Soft by default: restorable until the purge window closes. Hard, when named: erased now."
190
+ },
191
+ {
192
+ method: "POST",
193
+ path: `${basePath}/admin/users/:userId/restore`,
194
+ scope: AUTH_USERS_DELETE_SCOPE,
195
+ summary: "Restore a deleted user inside the purge window, with a reason. They sign in again."
196
+ },
197
+ {
198
+ method: "GET",
199
+ path: `${basePath}/admin/users/:userId/export`,
200
+ scope: AUTH_USERS_EXPORT_SCOPE,
201
+ summary: "Everything the kit holds about one user, from every capability — the answer to an access request."
146
202
  }
147
203
  ];
148
204
  }
149
205
  //#endregion
150
- export { AUTH_CONTROL_PLANE_SCOPES, AUTH_DEVICES_READ_SCOPE, AUTH_DEVICES_REVOKE_SCOPE, AUTH_SESSIONS_REVOKE_SCOPE, AUTH_USERS_LOGOUT_SCOPE, AUTH_USERS_READ_SCOPE, authAdminRoutes };
206
+ export { AUTH_CONTROL_PLANE_SCOPES, AUTH_DEVICES_READ_SCOPE, AUTH_DEVICES_REVOKE_SCOPE, AUTH_SESSIONS_REVOKE_SCOPE, AUTH_USERS_DELETE_SCOPE, AUTH_USERS_EXPORT_SCOPE, AUTH_USERS_LOGOUT_SCOPE, AUTH_USERS_READ_SCOPE, AUTH_USERS_SUSPEND_SCOPE, authAdminRoutes };
@@ -0,0 +1,18 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ import type { PithyError } from "@pithy-sh/core/src/error/pithyError";
4
+ /** Whether a refused account's credential may still reach this Better Auth endpoint (path relative to `basePath`). */
5
+ export declare function admitsRefusedAccount(path: string): boolean;
6
+ /**
7
+ * The redirect a refused magic link answers with: back to the screen the link named, carrying the code as
8
+ * `?error=`, exactly as Better Auth's own `redirectWithError` does for the refusals it raises itself
9
+ * (`plugins/magic-link/index.mjs`). `null` when the target is not one this Worker trusts, and the caller
10
+ * answers the refusal as JSON instead.
11
+ *
12
+ * A browser following a magic link is mid-navigation, so a 403 body would strand it on the API's origin
13
+ * with nothing to read; the adopter's screen is where the copy for this state lives. Better Auth has already
14
+ * checked the URLs by the time a session is refused, so the trust check is defense in depth — a refusal must
15
+ * not become an open redirect.
16
+ */
17
+ export declare function lifecycleRedirect(requestUrl: URL, baseURL: string, trustedOrigins: readonly string[], refusal: PithyError): Response | null;
18
+ //# sourceMappingURL=lifecycleGate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycleGate.d.ts","sourceRoot":"","sources":["../../src/http/lifecycleGate.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AA8BtE,sHAAsH;AACtH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAG1D;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,GAAG,EACf,OAAO,EAAE,MAAM,EACf,cAAc,EAAE,SAAS,MAAM,EAAE,EACjC,OAAO,EAAE,UAAU,GAClB,QAAQ,GAAG,IAAI,CAYjB"}
@@ -0,0 +1,75 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ //#region src/http/lifecycleGate.ts
4
+ /**
5
+ * Where a suspended or deleted account meets Better Auth's own endpoints (#620).
6
+ *
7
+ * The session middleware refuses such an account an `AuthContext`, which closes every kit route. Better Auth's
8
+ * catch-all is the one place that does not ask: it resolves the session itself, so `/token` would mint a fresh
9
+ * access token for an account the rest of the Worker refuses. `handleBetterAuth` therefore refuses the
10
+ * middleware's verdict here too — everywhere except the endpoints below.
11
+ */
12
+ /**
13
+ * The endpoints that never act as the account the presented credential names, relative to `basePath`.
14
+ *
15
+ * Signing out must always work. And each of the rest *starts* a session rather than using one, so a stale
16
+ * cookie a suspended person left on a shared machine must not stop somebody else signing in — the session
17
+ * that results is checked where it is created, in `session.create.before`. Everything else is refused by
18
+ * default: an endpoint nobody listed may be one a plugin added, and an account that may not act may not act
19
+ * there either.
20
+ */
21
+ const ADMITTED_PREFIXES = [
22
+ "/sign-out",
23
+ "/sign-in/",
24
+ "/magic-link/verify",
25
+ "/email-otp/",
26
+ "/callback/",
27
+ "/oauth2/callback/"
28
+ ];
29
+ const ADMITTED_EXACT = /* @__PURE__ */ new Set([
30
+ "/jwks",
31
+ "/ok",
32
+ "/error"
33
+ ]);
34
+ /** Whether a refused account's credential may still reach this Better Auth endpoint (path relative to `basePath`). */
35
+ function admitsRefusedAccount(path) {
36
+ if (ADMITTED_EXACT.has(path)) return true;
37
+ return ADMITTED_PREFIXES.some((prefix) => path === prefix || path.startsWith(prefix));
38
+ }
39
+ /**
40
+ * The redirect a refused magic link answers with: back to the screen the link named, carrying the code as
41
+ * `?error=`, exactly as Better Auth's own `redirectWithError` does for the refusals it raises itself
42
+ * (`plugins/magic-link/index.mjs`). `null` when the target is not one this Worker trusts, and the caller
43
+ * answers the refusal as JSON instead.
44
+ *
45
+ * A browser following a magic link is mid-navigation, so a 403 body would strand it on the API's origin
46
+ * with nothing to read; the adopter's screen is where the copy for this state lives. Better Auth has already
47
+ * checked the URLs by the time a session is refused, so the trust check is defense in depth — a refusal must
48
+ * not become an open redirect.
49
+ */
50
+ function lifecycleRedirect(requestUrl, baseURL, trustedOrigins, refusal) {
51
+ const named = requestUrl.searchParams.get("errorCallbackURL") || requestUrl.searchParams.get("callbackURL") || "/";
52
+ let target;
53
+ try {
54
+ target = new URL(named, baseURL);
55
+ } catch {
56
+ return null;
57
+ }
58
+ if (!(/* @__PURE__ */ new Set([new URL(baseURL).origin, ...trustedOrigins.flatMap((origin) => originOf(origin))])).has(target.origin)) return null;
59
+ target.searchParams.set("error", refusal.payload.code);
60
+ return new Response(null, {
61
+ status: 302,
62
+ headers: { location: target.toString() }
63
+ });
64
+ }
65
+ /** An origin's canonical form, or nothing for an entry that is not a URL (a bare deep-link scheme). */
66
+ function originOf(value) {
67
+ try {
68
+ const origin = new URL(value).origin;
69
+ return origin === "null" ? [] : [origin];
70
+ } catch {
71
+ return [];
72
+ }
73
+ }
74
+ //#endregion
75
+ export { admitsRefusedAccount, lifecycleRedirect };
@@ -1,12 +1,41 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
3
  import type { PithyHonoEnv, PithyMiddleware } from "@pithy-sh/core/src/capability/capability";
4
- import type { MiddlewareHandler } from "hono";
4
+ import type { Context, MiddlewareHandler } from "hono";
5
5
  import type { AuthWiring } from "../capability";
6
6
  export declare function createSessionMiddleware(wiring: AuthWiring): PithyMiddleware;
7
7
  /**
8
8
  * The gate other capabilities stack on a protected route. Rejects a request whose `AuthContext` was
9
9
  * not filled (no valid credential) with a `PithyError` `auth/invalid_token` (401).
10
+ *
11
+ * **A genuine credential for an account that may not act is refused with what happened to it** —
12
+ * `auth/account_suspended` or `auth/account_deleted`, 403 — rather than the 401, because signing in again
13
+ * cannot help and a client that read it as an expired token would loop. The verdict is the session
14
+ * middleware's, remembered for this request; this guard only raises it.
10
15
  */
11
16
  export declare function requireAuth(): MiddlewareHandler<PithyHonoEnv>;
17
+ /** Whose account a request may act on as its own holder: the signed-in account, or a suspended one's. */
18
+ export interface AccountHolder {
19
+ /** The account. */
20
+ readonly userId: string;
21
+ /** The session the request presented. */
22
+ readonly sessionId: string;
23
+ /** Whether the account is suspended — every other route refuses it. */
24
+ readonly suspended: boolean;
25
+ }
26
+ /**
27
+ * The account this request's credential opens, for a route a **suspended** account may still use — and there is
28
+ * exactly one, deleting it (#622). The App Store and Google Play require that a person can delete their account
29
+ * from inside the app, and a suspension is no reason to keep somebody who wants to leave.
30
+ *
31
+ * A deleted account is not admitted: there is nothing left to delete. Neither is a request whose standing could
32
+ * not be checked.
33
+ */
34
+ export declare function accountHolder(c: Context<PithyHonoEnv>): AccountHolder | null;
35
+ /**
36
+ * The gate for that route: `requireAuth()`, with a suspended account's genuine credential admitted. Everything
37
+ * `requireAuth()` refuses otherwise, it refuses the same way — a deleted account with its code, anything else
38
+ * with `auth/invalid_token`.
39
+ */
40
+ export declare function requireAccountHolder(): MiddlewareHandler<PithyHonoEnv>;
12
41
  //# sourceMappingURL=middleware.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/http/middleware.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAI9F,OAAO,KAAK,EAAW,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAuC,MAAM,eAAe,CAAC;AA0DrF,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,UAAU,GAAG,eAAe,CAqB3E;AA2CD;;;GAGG;AACH,wBAAgB,WAAW,IAAI,iBAAiB,CAAC,YAAY,CAAC,CAU7D"}
1
+ {"version":3,"file":"middleware.d.ts","sourceRoot":"","sources":["../../src/http/middleware.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAI9F,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAuC,MAAM,eAAe,CAAC;AA6DrF,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,UAAU,GAAG,eAAe,CAqB3E;AA4FD;;;;;;;;GAQG;AACH,wBAAgB,WAAW,IAAI,iBAAiB,CAAC,YAAY,CAAC,CAY7D;AAED,yGAAyG;AACzG,MAAM,WAAW,aAAa;IAC5B,mBAAmB;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,yCAAyC;IACzC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,uEAAuE;IACvE,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,GAAG,aAAa,GAAG,IAAI,CAI5E;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,IAAI,iBAAiB,CAAC,YAAY,CAAC,CAYtE"}
@@ -1,8 +1,11 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
- import { getAuthInstance } from "./resolve.js";
3
+ import { authDatabase } from "../data/tables.js";
4
+ import { LifecycleColumns } from "../lifecycle/state.js";
5
+ import { lifecycleRefusalFor, noteRefusal, noticedRefusal, suspendedHolder } from "../lifecycle/enforce.js";
6
+ import { getAuthInstance, resolveDb } from "./resolve.js";
4
7
  import { withResignedCredentials } from "./credentialResign.js";
5
- import { UnauthorizedError } from "@pithy-sh/core/src/error/pithyError";
8
+ import { InternalError, UnauthorizedError } from "@pithy-sh/core/src/error/pithyError";
6
9
  import { isLocale } from "@pithy-sh/core/src/i18n/locale";
7
10
  import { AuthContext } from "@pithy-sh/core/src/http/authContext";
8
11
  //#region src/http/middleware.ts
@@ -74,6 +77,14 @@ async function resolveSession(c, wiring, instance) {
74
77
  try {
75
78
  const session = await instance.api.getSession({ headers });
76
79
  if (session) {
80
+ const refusal = await standingRefusal(c, wiring, session.user);
81
+ if (refusal) {
82
+ noteRefusal(c, refusal, {
83
+ userId: session.user.id,
84
+ sessionId: session.session.id
85
+ });
86
+ return;
87
+ }
77
88
  const scopes = await resolvedScopes(c, wiring.resolveScopes, {
78
89
  userId: session.user.id,
79
90
  sessionId: session.session.id
@@ -90,17 +101,88 @@ async function resolveSession(c, wiring, instance) {
90
101
  } catch {}
91
102
  }
92
103
  /**
104
+ * The refusal for the session's account, or `null` when it may act.
105
+ *
106
+ * **A check that cannot be made refuses**, rather than throwing into `resolveSession`'s catch. That catch
107
+ * leaves `auth` null and notes nothing, and `handleBetterAuth` only refuses on a noted verdict — so a failed
108
+ * read of a suspension's reason, or a column that will not decode, would let Better Auth's own `/token` mint a
109
+ * JWT for the suspended account it resolved on its own. So the failure is logged and becomes the verdict: a
110
+ * 500, since the fault is this Worker's, and every door that honors a lifecycle refusal honors this one.
111
+ */
112
+ async function standingRefusal(c, wiring, user) {
113
+ try {
114
+ return await lifecycleRefusalFor(authDatabase(resolveDb(c.env, wiring.config.database)), user.id, LifecycleColumns.parse(user), /* @__PURE__ */ new Date());
115
+ } catch (cause) {
116
+ c.var.log?.child("auth").warn("the account's standing could not be checked; the request is refused", {
117
+ userId: user.id,
118
+ reason: cause instanceof Error ? cause.message : String(cause)
119
+ });
120
+ return new InternalError({
121
+ message: "This account could not be checked. Try again shortly.",
122
+ action: "Check the auth database binding and that the auth migrations have run.",
123
+ detail: `lifecycle check for user ${user.id} failed`
124
+ }, { cause });
125
+ }
126
+ }
127
+ /**
93
128
  * The gate other capabilities stack on a protected route. Rejects a request whose `AuthContext` was
94
129
  * not filled (no valid credential) with a `PithyError` `auth/invalid_token` (401).
130
+ *
131
+ * **A genuine credential for an account that may not act is refused with what happened to it** —
132
+ * `auth/account_suspended` or `auth/account_deleted`, 403 — rather than the 401, because signing in again
133
+ * cannot help and a client that read it as an expired token would loop. The verdict is the session
134
+ * middleware's, remembered for this request; this guard only raises it.
95
135
  */
96
136
  function requireAuth() {
97
137
  return async (c, next) => {
98
- if (!c.var.auth) throw new UnauthorizedError({
99
- message: "Authentication required.",
100
- action: "Sign in and retry with a valid session or bearer token."
101
- });
138
+ if (!c.var.auth) {
139
+ const refusal = noticedRefusal(c);
140
+ if (refusal) throw refusal;
141
+ throw new UnauthorizedError({
142
+ message: "Authentication required.",
143
+ action: "Sign in and retry with a valid session or bearer token."
144
+ });
145
+ }
146
+ await next();
147
+ };
148
+ }
149
+ /**
150
+ * The account this request's credential opens, for a route a **suspended** account may still use — and there is
151
+ * exactly one, deleting it (#622). The App Store and Google Play require that a person can delete their account
152
+ * from inside the app, and a suspension is no reason to keep somebody who wants to leave.
153
+ *
154
+ * A deleted account is not admitted: there is nothing left to delete. Neither is a request whose standing could
155
+ * not be checked.
156
+ */
157
+ function accountHolder(c) {
158
+ if (c.var.auth) return {
159
+ userId: c.var.auth.userId,
160
+ sessionId: c.var.auth.sessionId,
161
+ suspended: false
162
+ };
163
+ const held = suspendedHolder(c);
164
+ return held ? {
165
+ ...held,
166
+ suspended: true
167
+ } : null;
168
+ }
169
+ /**
170
+ * The gate for that route: `requireAuth()`, with a suspended account's genuine credential admitted. Everything
171
+ * `requireAuth()` refuses otherwise, it refuses the same way — a deleted account with its code, anything else
172
+ * with `auth/invalid_token`.
173
+ */
174
+ function requireAccountHolder() {
175
+ return async (c, next) => {
176
+ if (!accountHolder(c)) {
177
+ const refusal = noticedRefusal(c);
178
+ if (refusal) throw refusal;
179
+ throw new UnauthorizedError({
180
+ message: "Authentication required.",
181
+ action: "Sign in and retry with a valid session or bearer token."
182
+ });
183
+ }
102
184
  await next();
103
185
  };
104
186
  }
105
187
  //#endregion
106
- export { createSessionMiddleware, requireAuth };
188
+ export { accountHolder, createSessionMiddleware, requireAccountHolder, requireAuth };
@@ -1 +1 @@
1
- {"version":3,"file":"providerRefusal.d.ts","sourceRoot":"","sources":["../../src/http/providerRefusal.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6FG;AAEH;;;;;;;GAOG;AACH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AAChF,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAA6B,CAAC;AAE3G,yFAAyF;AACzF,MAAM,WAAW,gBAAgB;IAC/B,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B;;;;;;OAMG;IACH,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AACH,wBAAgB,uBAAuB,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,gBAAgB,GAAG,SAAS,CA0D5G"}
@@ -153,6 +153,14 @@ const PROVIDER_REFUSAL_VERDICTS = {
153
153
  collapse: true,
154
154
  why: "Two producers, and the verdict follows the one that reads our rows. `linkOAuthAccount` (link-account.mjs:45/68) answers it on `/link-social`, where the caller is signed in as the user being changed. But `handleOAuthUserInfo` answers it too, inside `if (dbUser)` when the account write fails (:171/:184), so on the social callback it says a row matched, and `unable_to_create_user` is its other half. Collapsing costs the signed-in linker a specific code for a fault. Letting it travel would cost the oracle. Corrected in #787; the earlier verdict read only the link flow."
155
155
  },
156
+ "auth/account_suspended": {
157
+ collapse: false,
158
+ why: "The kit's own `session.create.before` hook (instance/auth.ts, #620). A session is only ever created for a user the callback has already resolved and linked — the caller has just proved control of a provider identity bound to this account — so the code is told to its holder, never to somebody probing an address. Collapsing it would leave a suspended person with a screen that says nothing happened."
159
+ },
160
+ "auth/account_deleted": {
161
+ collapse: false,
162
+ why: "The same hook, for an account inside its purge window, and the same reasoning: it is reached only after the caller authenticated as the account, so it names the state of their own account to them."
163
+ },
156
164
  no_code: {
157
165
  collapse: false,
158
166
  why: "The provider came back without a code. The shape of the request itself, settled before any lookup."
@@ -1 +1 @@
1
- {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/http/resolve.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAK7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,OAAO,EAAE,KAAK,YAAY,EAAY,MAAM,kBAAkB,CAAC;AAsB/D,2GAA2G;AAC3G,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,UAAU,CASvF;AA0BD,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAMnG"}
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../src/http/resolve.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAE5D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAK7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,OAAO,EAAE,KAAK,YAAY,EAAY,MAAM,kBAAkB,CAAC;AAuB/D,2GAA2G;AAC3G,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,EAAE,MAAM,GAAG,UAAU,CASvF;AA0BD,wBAAgB,eAAe,CAAC,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,YAAY,CAAC,CAMnG"}
@@ -2,7 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  import { authDatabase } from "../data/tables.js";
4
4
  import { baseURLResolver } from "./baseUrl.js";
5
- import { resolveAppleCredentials, resolveFacebookCredentials, resolveGithubCredentials, resolveGoogleCredentials, resolveSessionSecrets } from "../instance/secrets.js";
5
+ import { resolveAppleCredentials, resolveFacebookCredentials, resolveGithubCredentials, resolveGoogleCredentials, resolveMicrosoftCredentials, resolveSessionSecrets } from "../instance/secrets.js";
6
6
  import { makeSendAuthEmail } from "../email/send.js";
7
7
  import { resolveProvider } from "../instance/providers.js";
8
8
  import { makeAuth } from "../instance/auth.js";
@@ -63,12 +63,13 @@ async function buildAuthInstance(c, wiring) {
63
63
  detail: "auth.compose did not resolve the email enqueue seam; ensure email() is composed."
64
64
  });
65
65
  const env = c.env;
66
- const [sessionSecrets, google, apple, facebook, github] = await Promise.all([
66
+ const [sessionSecrets, google, apple, facebook, github, microsoft] = await Promise.all([
67
67
  resolveSessionSecrets(env),
68
68
  resolveProvider(cfg.google.enabled, () => resolveGoogleCredentials(env)),
69
69
  resolveProvider(cfg.apple.enabled, () => resolveAppleCredentials(env)),
70
70
  resolveProvider(cfg.facebook.enabled, () => resolveFacebookCredentials(env)),
71
- resolveProvider(cfg.github.enabled, () => resolveGithubCredentials(env))
71
+ resolveProvider(cfg.github.enabled, () => resolveGithubCredentials(env)),
72
+ resolveProvider(cfg.microsoft.enabled, () => resolveMicrosoftCredentials(env))
72
73
  ]);
73
74
  const expiresMinutes = Math.max(1, Math.round(cfg.verificationExpiresIn / 60));
74
75
  const d1 = resolveDb(c.env, cfg.database);
@@ -98,6 +99,7 @@ async function buildAuthInstance(c, wiring) {
98
99
  apple,
99
100
  facebook,
100
101
  github,
102
+ microsoft,
101
103
  sendEmail: makeSendAuthEmail((input) => enqueueEmail(env, input), expiresMinutes, recipientLocale(c, authDatabase(resolveDb(c.env, cfg.database)))),
102
104
  sessionExpiresIn: cfg.sessionExpiresIn,
103
105
  sessionUpdateAge: cfg.sessionUpdateAge,
@@ -108,7 +110,8 @@ async function buildAuthInstance(c, wiring) {
108
110
  google: cfg.google.allowSignUp,
109
111
  apple: cfg.apple.allowSignUp,
110
112
  facebook: cfg.facebook.allowSignUp,
111
- github: cfg.github.allowSignUp
113
+ github: cfg.github.allowSignUp,
114
+ microsoft: cfg.microsoft.allowSignUp
112
115
  },
113
116
  ...wiring.resolveGithubUserInfo ? { resolveGithubUserInfo: wiring.resolveGithubUserInfo } : {},
114
117
  emit: (event) => c.var.emit(event),
@@ -151,6 +151,176 @@ export declare const AdminDeviceRevokeResponse: z.ZodObject<{
151
151
  removed: z.ZodBoolean;
152
152
  }, z.core.$strip>;
153
153
  export type AdminDeviceRevokeResponse = z.output<typeof AdminDeviceRevokeResponse>;
154
+ /**
155
+ * `POST {base}/admin/users/:userId/suspend` (#621).
156
+ *
157
+ * The suspension the account is now under, how many sessions ended with it, and whether the person was told.
158
+ * Not the reason: the caller wrote it, the trail keeps it, and echoing it back would put it in one more place
159
+ * a dashboard logs.
160
+ */
161
+ export declare const AdminUserSuspendResponse: z.ZodObject<{
162
+ userId: z.ZodString;
163
+ state: z.ZodLiteral<"suspended">;
164
+ outcome: z.ZodEnum<{
165
+ suspended: "suspended";
166
+ updated: "updated";
167
+ }>;
168
+ suspendedAt: z.ZodISODateTime;
169
+ suspendedUntil: z.ZodNullable<z.ZodISODateTime>;
170
+ sessionsRevoked: z.ZodNumber;
171
+ mailed: z.ZodBoolean;
172
+ }, z.core.$strip>;
173
+ export type AdminUserSuspendResponse = z.output<typeof AdminUserSuspendResponse>;
174
+ /**
175
+ * `POST {base}/admin/users/:userId/reinstate` (#621).
176
+ *
177
+ * No session count: a reinstatement restores none. The person signs in again.
178
+ */
179
+ export declare const AdminUserReinstateResponse: z.ZodObject<{
180
+ userId: z.ZodString;
181
+ state: z.ZodLiteral<"active">;
182
+ outcome: z.ZodEnum<{
183
+ reinstated: "reinstated";
184
+ unchanged: "unchanged";
185
+ }>;
186
+ mailed: z.ZodBoolean;
187
+ }, z.core.$strip>;
188
+ export type AdminUserReinstateResponse = z.output<typeof AdminUserReinstateResponse>;
189
+ /**
190
+ * `DELETE {base}/admin/users/:userId` (#622).
191
+ *
192
+ * What the deletion left in force, how many sessions ended with it, whether the person was told, and what
193
+ * became of the purge. Not the reason: the caller wrote it and the trail keeps it.
194
+ */
195
+ export declare const AdminUserDeleteResponse: z.ZodObject<{
196
+ userId: z.ZodString;
197
+ state: z.ZodLiteral<"deleted">;
198
+ mode: z.ZodEnum<{
199
+ hard: "hard";
200
+ soft: "soft";
201
+ }>;
202
+ outcome: z.ZodEnum<{
203
+ brought_forward: "brought_forward";
204
+ deleted: "deleted";
205
+ unchanged: "unchanged";
206
+ }>;
207
+ deletedAt: z.ZodISODateTime;
208
+ purgeAfter: z.ZodISODateTime;
209
+ purge: z.ZodEnum<{
210
+ pending: "pending";
211
+ scheduled: "scheduled";
212
+ started: "started";
213
+ }>;
214
+ sessionsRevoked: z.ZodNumber;
215
+ mailed: z.ZodBoolean;
216
+ }, z.core.$strip>;
217
+ export type AdminUserDeleteResponse = z.output<typeof AdminUserDeleteResponse>;
218
+ /**
219
+ * `POST {base}/admin/users/:userId/restore` (#622). No session count: a restoration restores none.
220
+ */
221
+ export declare const AdminUserRestoreResponse: z.ZodObject<{
222
+ userId: z.ZodString;
223
+ state: z.ZodEnum<{
224
+ active: "active";
225
+ suspended: "suspended";
226
+ }>;
227
+ outcome: z.ZodEnum<{
228
+ restored: "restored";
229
+ unchanged: "unchanged";
230
+ }>;
231
+ }, z.core.$strip>;
232
+ export type AdminUserRestoreResponse = z.output<typeof AdminUserRestoreResponse>;
233
+ /**
234
+ * What `@pithy-sh/auth` holds about one account, as its purge contribution exports it (#622) — the `data` of
235
+ * the `auth` entry in an export.
236
+ *
237
+ * The person's own data and none of their credentials: no session token, no provider token, no push token.
238
+ * Every list is whole, because an export that stopped at a bound would answer an access request with part of
239
+ * an answer.
240
+ */
241
+ export declare const AuthUserExport: z.ZodObject<{
242
+ user: z.ZodObject<{
243
+ id: z.ZodString;
244
+ email: z.ZodString;
245
+ name: z.ZodString;
246
+ emailVerified: z.ZodBoolean;
247
+ image: z.ZodNullable<z.ZodString>;
248
+ locale: z.ZodOptional<z.ZodNullable<z.ZodString>>;
249
+ createdAt: z.ZodISODateTime;
250
+ updatedAt: z.ZodISODateTime;
251
+ suspendedAt: z.ZodNullable<z.ZodISODateTime>;
252
+ suspendedUntil: z.ZodNullable<z.ZodISODateTime>;
253
+ deletedAt: z.ZodNullable<z.ZodISODateTime>;
254
+ purgeAfter: z.ZodNullable<z.ZodISODateTime>;
255
+ }, z.core.$strip>;
256
+ sessions: z.ZodArray<z.ZodObject<{
257
+ id: z.ZodString;
258
+ deviceId: z.ZodNullable<z.ZodString>;
259
+ ipAddress: z.ZodNullable<z.ZodString>;
260
+ userAgent: z.ZodNullable<z.ZodString>;
261
+ createdAt: z.ZodISODateTime;
262
+ updatedAt: z.ZodISODateTime;
263
+ expiresAt: z.ZodISODateTime;
264
+ }, z.core.$strip>>;
265
+ providers: z.ZodArray<z.ZodObject<{
266
+ providerId: z.ZodString;
267
+ createdAt: z.ZodISODateTime;
268
+ }, z.core.$strip>>;
269
+ devices: z.ZodArray<z.ZodObject<{
270
+ id: z.ZodString;
271
+ userId: z.ZodString;
272
+ platform: z.ZodEnum<{
273
+ android: "android";
274
+ ios: "ios";
275
+ web: "web";
276
+ }>;
277
+ name: z.ZodNullable<z.ZodString>;
278
+ model: z.ZodNullable<z.ZodString>;
279
+ osVersion: z.ZodNullable<z.ZodString>;
280
+ appVersion: z.ZodNullable<z.ZodString>;
281
+ lastIp: z.ZodNullable<z.ZodString>;
282
+ lastSeenAt: z.ZodISODateTime;
283
+ createdAt: z.ZodISODateTime;
284
+ }, z.core.$strip>>;
285
+ history: z.ZodArray<z.ZodObject<{
286
+ action: z.ZodString;
287
+ actorType: z.ZodString;
288
+ reason: z.ZodNullable<z.ZodString>;
289
+ suspendedUntil: z.ZodNullable<z.ZodISODateTime>;
290
+ createdAt: z.ZodISODateTime;
291
+ }, z.core.$strip>>;
292
+ plugins: z.ZodRecord<z.ZodString, z.ZodArray<z.ZodRecord<z.ZodString, z.ZodUnknown>>>;
293
+ }, z.core.$strip>;
294
+ export type AuthUserExport = z.output<typeof AuthUserExport>;
295
+ /**
296
+ * `GET {base}/admin/users/:userId/export` (#622).
297
+ *
298
+ * Everything the kit holds about one account — the answer to an access request. One entry per composed
299
+ * capability that declares a purge contribution, in the order the purge runs them, each read on its own so
300
+ * one that will not read costs its own entry and not the document.
301
+ */
302
+ export declare const AdminUserExportResponse: z.ZodObject<{
303
+ subject: z.ZodObject<{
304
+ type: z.ZodLiteral<"user">;
305
+ id: z.ZodString;
306
+ }, z.core.$strip>;
307
+ exportedAt: z.ZodISODateTime;
308
+ capabilities: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
309
+ capability: z.ZodString;
310
+ summary: z.ZodString;
311
+ state: z.ZodLiteral<"exported">;
312
+ data: z.ZodRecord<z.ZodString, z.ZodUnknown>;
313
+ }, z.core.$strip>, z.ZodObject<{
314
+ capability: z.ZodString;
315
+ summary: z.ZodString;
316
+ state: z.ZodLiteral<"not_exported">;
317
+ }, z.core.$strip>, z.ZodObject<{
318
+ capability: z.ZodString;
319
+ summary: z.ZodString;
320
+ state: z.ZodLiteral<"unavailable">;
321
+ }, z.core.$strip>], "state">>;
322
+ }, z.core.$strip>;
323
+ export type AdminUserExportResponse = z.output<typeof AdminUserExportResponse>;
154
324
  /** `POST {base}/token/rotate`. */
155
325
  export declare const TokenRotateResponse: z.ZodObject<{
156
326
  accessToken: z.ZodString;
@@ -203,4 +373,14 @@ export declare const MyDeviceRevokeResponse: z.ZodObject<{
203
373
  revoked: z.ZodNumber;
204
374
  }, z.core.$strip>;
205
375
  export type MyDeviceRevokeResponse = z.output<typeof MyDeviceRevokeResponse>;
376
+ /**
377
+ * `DELETE {base}/account` (#622) — the signed-in person deleted their own account. Always soft, on the
378
+ * configured window. Their sessions end with it, this one included.
379
+ */
380
+ export declare const AccountDeleteResponse: z.ZodObject<{
381
+ state: z.ZodLiteral<"deleted">;
382
+ purgeAfter: z.ZodISODateTime;
383
+ mailed: z.ZodBoolean;
384
+ }, z.core.$strip>;
385
+ export type AccountDeleteResponse = z.output<typeof AccountDeleteResponse>;
206
386
  //# sourceMappingURL=responses.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"responses.d.ts","sourceRoot":"","sources":["../../src/http/responses.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAwCxB,kDAAkD;AAClD,eAAO,MAAM,aAAa;;;;;;;;;iBAiBsF,CAAC;AACjH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,aAAa,CAAC,CAAC;AAE3D,2FAA2F;AAC3F,eAAO,MAAM,gBAAgB;;;;;;;;iBAUiF,CAAC;AAC/G,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEjE,0GAA0G;AAC1G,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;iBAawF,CAAC;AACrH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,eAAe,CAAC,CAAC;AAE/D,gCAAgC;AAChC,eAAO,MAAM,kBAAkB;;;;;;;;;;;;iBAKQ,CAAC;AACxC,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAoDrE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAY3B,CAAC;AACJ,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAEnE,kCAAkC;AAClC,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;iBAKY,CAAC;AAC9C,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,oBAAoB,CAAC,C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