@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
@@ -0,0 +1,18 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ import type { PithyHonoEnv } from "@pithy-sh/core/src/capability/capability";
4
+ import type { Context } from "hono";
5
+ import type { AuthWiring } from "../capability";
6
+ import type { LifecycleAuditContext, LifecycleDeps } from "./transitions";
7
+ /**
8
+ * The transitions' dependencies, resolved from one request — what a lifecycle route hands `./transitions.ts`.
9
+ *
10
+ * One function so every route resolves them the same way: this request's database, its audit seam and logger,
11
+ * the composed email capability's enqueue bound to this request's env, and the adopter's hooks as `auth()` was
12
+ * handed them. A route that assembled its own would be the second place a hook could be forgotten.
13
+ *
14
+ * `context` is what the caller adds to each audit event: the request's correlation, and for a management call
15
+ * the connection it came through. The caller passes it because only the caller knows who it is.
16
+ */
17
+ export declare function lifecycleDeps(c: Context<PithyHonoEnv>, wiring: AuthWiring, context?: LifecycleAuditContext): LifecycleDeps;
18
+ //# sourceMappingURL=request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/lifecycle/request.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAE7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAGhD,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE1E;;;;;;;;;GASG;AACH,wBAAgB,aAAa,CAC3B,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,EACxB,MAAM,EAAE,UAAU,EAClB,OAAO,CAAC,EAAE,qBAAqB,GAC9B,aAAa,CAaf"}
@@ -0,0 +1,31 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ import { authDatabase } from "../data/tables.js";
4
+ import { resolveDb } from "../http/resolve.js";
5
+ //#region src/lifecycle/request.ts
6
+ /**
7
+ * The transitions' dependencies, resolved from one request — what a lifecycle route hands `./transitions.ts`.
8
+ *
9
+ * One function so every route resolves them the same way: this request's database, its audit seam and logger,
10
+ * the composed email capability's enqueue bound to this request's env, and the adopter's hooks as `auth()` was
11
+ * handed them. A route that assembled its own would be the second place a hook could be forgotten.
12
+ *
13
+ * `context` is what the caller adds to each audit event: the request's correlation, and for a management call
14
+ * the connection it came through. The caller passes it because only the caller knows who it is.
15
+ */
16
+ function lifecycleDeps(c, wiring, context) {
17
+ const d1 = resolveDb(c.env, wiring.config.database);
18
+ const enqueue = wiring.enqueueEmail;
19
+ return {
20
+ db: authDatabase(d1),
21
+ d1,
22
+ emit: c.var.emit,
23
+ config: wiring.config,
24
+ hooks: wiring.lifecycleHooks ?? {},
25
+ enqueueEmail: enqueue ? (input) => enqueue(c.env, input) : void 0,
26
+ log: c.var.log?.child("auth"),
27
+ ...context ? { context } : {}
28
+ };
29
+ }
30
+ //#endregion
31
+ export { lifecycleDeps };
@@ -0,0 +1,64 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ import { PithyError } from "@pithy-sh/core/src/error/pithyError";
4
+ import type { z } from "zod";
5
+ /**
6
+ * What an account's four lifecycle columns mean, decided once.
7
+ *
8
+ * Every enforcement point — the session middleware, sign-in, token refresh — reads the state through
9
+ * {@link accountStanding} and refuses through {@link lifecycleRefusal}. Enforcement written twice is
10
+ * enforcement that disagrees, and the first disagreement would be a suspension one door honors and another
11
+ * does not.
12
+ */
13
+ /**
14
+ * The four columns, decoded off whatever carries them: a `pithy_auth_users` row, or the user object Better
15
+ * Auth resolved for a session, which carries them because `../data/kitFields.ts` declares them. Unknown keys
16
+ * are dropped, and a key that is absent — a row read before `0004_user_lifecycle` — reads as null.
17
+ */
18
+ export declare const LifecycleColumns: z.ZodObject<{
19
+ suspendedAt: z.ZodOptional<z.ZodNullable<z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodDate]>, z.ZodDate>>>;
20
+ suspendedUntil: z.ZodOptional<z.ZodNullable<z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodDate]>, z.ZodDate>>>;
21
+ deletedAt: z.ZodOptional<z.ZodNullable<z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodDate]>, z.ZodDate>>>;
22
+ purgeAfter: z.ZodOptional<z.ZodNullable<z.ZodCodec<z.ZodUnion<readonly [z.ZodNumber, z.ZodString, z.ZodDate]>, z.ZodDate>>>;
23
+ }, z.core.$strip>;
24
+ export type LifecycleColumns = z.output<typeof LifecycleColumns>;
25
+ /** Where an account stands, at one instant. */
26
+ export type AccountStanding = {
27
+ readonly state: "active";
28
+ } | {
29
+ readonly state: "suspended";
30
+ readonly until: Date | null;
31
+ } | {
32
+ readonly state: "deleted";
33
+ readonly purgeAfter: Date | null;
34
+ };
35
+ /**
36
+ * Where an account stands at `now`.
37
+ *
38
+ * **Deleted outranks suspended.** An account deleted while it was suspended is deleted: the suspension's end
39
+ * passing must not reopen it.
40
+ *
41
+ * **A suspension past its `suspendedUntil` is not a suspension**, and no write expires it. The end is
42
+ * exclusive — at the instant it names, the account is active again. A column nobody has cleared is a
43
+ * fact about the past, not about now, and reading it that way is what lets a timed suspension end on time
44
+ * with nothing scheduled to end it.
45
+ *
46
+ * **A deletion past its `purgeAfter` is still a deletion.** Only the purge ends that state, by erasing the
47
+ * account, and until it has run the account must stay shut.
48
+ */
49
+ export declare function accountStanding(columns: Partial<LifecycleColumns>, now: Date): AccountStanding;
50
+ /**
51
+ * The refusal for an account that may not act, or `null` for one that may.
52
+ *
53
+ * **The reason an operator gave is the public `message`**, because it is written for the person who is locked
54
+ * out and it is the one thing their screen cannot invent. `params` carries the end of a suspension, or the
55
+ * last day a deletion can be undone, as ISO-8601, for a client that renders the date in its reader's own
56
+ * words. Neither the account id nor who acted crosses: `detail` holds the id for the log, and `clientError`
57
+ * strips it with `action`.
58
+ *
59
+ * 403 for both, never 401: the credential is genuine, and signing in again cannot help.
60
+ */
61
+ export declare function lifecycleRefusal(userId: string, standing: AccountStanding, reason: string | null): PithyError | null;
62
+ /** Whether a caught error is one of the two lifecycle refusals. */
63
+ export declare function isLifecycleRefusal(error: unknown): error is PithyError;
64
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../src/lifecycle/state.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,UAAU,EAAE,MAAM,qCAAqC,CAAC;AACjE,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAG7B;;;;;;;GAOG;AAEH;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;;;;;iBAKoD,CAAC;AAClF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEjE,+CAA+C;AAC/C,MAAM,MAAM,eAAe,GACvB;IAAE,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAA;CAAE,GAC5B;IAAE,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,GAAG,IAAI,CAAA;CAAE,GAC5D;IAAE,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,UAAU,EAAE,IAAI,GAAG,IAAI,CAAA;CAAE,CAAC;AAEpE;;;;;;;;;;;;;GAaG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,gBAAgB,CAAC,EAAE,GAAG,EAAE,IAAI,GAAG,eAAe,CAO9F;AAKD;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,UAAU,GAAG,IAAI,CAoBpH;AAED,mEAAmE;AACnE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAKtE"}
@@ -0,0 +1,90 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ import { User } from "../data/betterAuth.js";
4
+ import { PithyError } from "@pithy-sh/core/src/error/pithyError";
5
+ //#region src/lifecycle/state.ts
6
+ /**
7
+ * What an account's four lifecycle columns mean, decided once.
8
+ *
9
+ * Every enforcement point — the session middleware, sign-in, token refresh — reads the state through
10
+ * {@link accountStanding} and refuses through {@link lifecycleRefusal}. Enforcement written twice is
11
+ * enforcement that disagrees, and the first disagreement would be a suspension one door honors and another
12
+ * does not.
13
+ */
14
+ /**
15
+ * The four columns, decoded off whatever carries them: a `pithy_auth_users` row, or the user object Better
16
+ * Auth resolved for a session, which carries them because `../data/kitFields.ts` declares them. Unknown keys
17
+ * are dropped, and a key that is absent — a row read before `0004_user_lifecycle` — reads as null.
18
+ */
19
+ const LifecycleColumns = User.pick({
20
+ suspendedAt: true,
21
+ suspendedUntil: true,
22
+ deletedAt: true,
23
+ purgeAfter: true
24
+ }).describe("An account's lifecycle columns, as `pithy_auth_users` stores them.");
25
+ /**
26
+ * Where an account stands at `now`.
27
+ *
28
+ * **Deleted outranks suspended.** An account deleted while it was suspended is deleted: the suspension's end
29
+ * passing must not reopen it.
30
+ *
31
+ * **A suspension past its `suspendedUntil` is not a suspension**, and no write expires it. The end is
32
+ * exclusive — at the instant it names, the account is active again. A column nobody has cleared is a
33
+ * fact about the past, not about now, and reading it that way is what lets a timed suspension end on time
34
+ * with nothing scheduled to end it.
35
+ *
36
+ * **A deletion past its `purgeAfter` is still a deletion.** Only the purge ends that state, by erasing the
37
+ * account, and until it has run the account must stay shut.
38
+ */
39
+ function accountStanding(columns, now) {
40
+ if (columns.deletedAt) return {
41
+ state: "deleted",
42
+ purgeAfter: columns.purgeAfter ?? null
43
+ };
44
+ if (columns.suspendedAt) {
45
+ const until = columns.suspendedUntil ?? null;
46
+ if (until === null || until.getTime() > now.getTime()) return {
47
+ state: "suspended",
48
+ until
49
+ };
50
+ }
51
+ return { state: "active" };
52
+ }
53
+ /** What a suspended account is told when nobody wrote a reason. */
54
+ const UNEXPLAINED_SUSPENSION = "This account is suspended.";
55
+ /**
56
+ * The refusal for an account that may not act, or `null` for one that may.
57
+ *
58
+ * **The reason an operator gave is the public `message`**, because it is written for the person who is locked
59
+ * out and it is the one thing their screen cannot invent. `params` carries the end of a suspension, or the
60
+ * last day a deletion can be undone, as ISO-8601, for a client that renders the date in its reader's own
61
+ * words. Neither the account id nor who acted crosses: `detail` holds the id for the log, and `clientError`
62
+ * strips it with `action`.
63
+ *
64
+ * 403 for both, never 401: the credential is genuine, and signing in again cannot help.
65
+ */
66
+ function lifecycleRefusal(userId, standing, reason) {
67
+ if (standing.state === "active") return null;
68
+ if (standing.state === "suspended") return new PithyError({
69
+ code: "auth/account_suspended",
70
+ status: 403,
71
+ message: reason ?? UNEXPLAINED_SUSPENSION,
72
+ ...standing.until ? { params: { suspendedUntil: standing.until.toISOString() } } : {},
73
+ action: "An operator suspended this account. Reinstate it from the management surface, or let it run out.",
74
+ detail: `user ${userId} is suspended${standing.until ? ` until ${standing.until.toISOString()}` : ""}`
75
+ });
76
+ return new PithyError({
77
+ code: "auth/account_deleted",
78
+ status: 403,
79
+ message: "This account is deleted.",
80
+ ...standing.purgeAfter ? { params: { purgeAfter: standing.purgeAfter.toISOString() } } : {},
81
+ action: "The account is inside its purge window. Restore it from the management surface before the purge runs.",
82
+ detail: `user ${userId} is deleted${standing.purgeAfter ? `, purge after ${standing.purgeAfter.toISOString()}` : ""}`
83
+ });
84
+ }
85
+ /** Whether a caught error is one of the two lifecycle refusals. */
86
+ function isLifecycleRefusal(error) {
87
+ return error instanceof PithyError && (error.payload.code === "auth/account_suspended" || error.payload.code === "auth/account_deleted");
88
+ }
89
+ //#endregion
90
+ export { LifecycleColumns, accountStanding, isLifecycleRefusal, lifecycleRefusal };
@@ -0,0 +1,272 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ import type { D1Database } from "@cloudflare/workers-types";
4
+ import type { AuditEmit } from "@pithy-sh/core/src/audit/recorder";
5
+ import type { Logger } from "@pithy-sh/core/src/logger/logger";
6
+ import type { EnqueueInput } from "@pithy-sh/email/src/send/enqueue";
7
+ import type { AuthConfig } from "../capability";
8
+ import type { AuthDatabase } from "../data/tables";
9
+ import type { UserLifecycleActorType } from "../data/userLifecycle";
10
+ import type { UserLifecycleHooks } from "./hooks";
11
+ /**
12
+ * The account-lifecycle transitions — the one place an account's state is ever changed (#620).
13
+ *
14
+ * The admin routes (#621, #622), the self-service deletion, and the purge Workflow call these and write
15
+ * nothing themselves, so each transition happens the same way whoever asked for it:
16
+ *
17
+ * 1. **The columns move, conditionally, and the history row is written with them.** The `update` names the
18
+ * state it expects to find, so of two concurrent suspensions exactly one changes a row, and only that one
19
+ * goes on. A request that finds the account already where it asked to put it is `changed: false` and does
20
+ * nothing else — no row, no mail, no hook — which is what "once per transition" means.
21
+ * 2. **The row in `pithy_auth_user_lifecycle`** — the actor, the reason, the time — is the second statement of
22
+ * the same `d1.batch()`, which D1 runs as one transaction, and it is written only when the first moved the
23
+ * account. Two awaits would leave a gap: a failed insert after a committed update, and a retry that finds
24
+ * the account already moved, returns `changed: false`, and loses the row, the event, the mail and the hook.
25
+ * 3. **The audit event is emitted** — the trail answers who and from where; the row answers what happened.
26
+ * 4. **The mail is enqueued**, when the config sends it, in the account's own language.
27
+ * 5. **The hook fires.**
28
+ *
29
+ * Steps 3 to 5 report something that has already happened, so none of them can undo it: each swallows its own
30
+ * failure, and a throwing hook or an email binding that is not there is logged and the transition stands.
31
+ *
32
+ * **What these do not do is end sessions.** Enforcement does not need them to — a suspended account's session
33
+ * is refused at every door the moment the column is written (`./enforce.ts`) — and revoking them is a route's
34
+ * decision, made through Better Auth so `onSessionRevoked` hears about it.
35
+ */
36
+ /** Who made a transition. */
37
+ export interface LifecycleActor {
38
+ /** The kind of principal. */
39
+ readonly type: UserLifecycleActorType;
40
+ /** Its id — the connection's for a management client, the user's own for self-service — or null. */
41
+ readonly id: string | null;
42
+ }
43
+ /** Everything a transition needs, resolved by the caller from its own context. */
44
+ export interface LifecycleDeps {
45
+ /** The auth tables. */
46
+ readonly db: AuthDatabase;
47
+ /** The same database as a binding, for the hooks — see `UserLifecycleListener`. */
48
+ readonly d1: D1Database;
49
+ /** The audit seam. A no-op when the audit capability is absent. */
50
+ readonly emit: AuditEmit;
51
+ /** The resolved config: the purge window, and which mails are sent. */
52
+ readonly config: Pick<AuthConfig, "retention" | "lifecycleEmails">;
53
+ /** The adopter's hooks. */
54
+ readonly hooks: UserLifecycleHooks;
55
+ /** The email capability's enqueue, bound to this run's env. Absent, nothing is mailed. */
56
+ readonly enqueueEmail?: ((input: EnqueueInput) => Promise<unknown>) | undefined;
57
+ /** Where a swallowed failure is reported. Absent, it is swallowed silently. */
58
+ readonly log?: Logger | undefined;
59
+ /** The clock. Defaults to the system's. */
60
+ readonly now?: (() => Date) | undefined;
61
+ /**
62
+ * The request a transition was asked from, carried onto its audit event: the correlation every admin event
63
+ * carries, and metadata the caller adds — the management connection's id, for a control-plane call.
64
+ */
65
+ readonly context?: LifecycleAuditContext | undefined;
66
+ }
67
+ /** What the caller's request adds to a transition's audit event. */
68
+ export interface LifecycleAuditContext {
69
+ /** The caller's address, from `cf-connecting-ip`. */
70
+ readonly ip?: string | undefined;
71
+ /** The caller's user agent. */
72
+ readonly userAgent?: string | undefined;
73
+ /** The request's id, from `cf-ray`. */
74
+ readonly requestId?: string | undefined;
75
+ /** Extra metadata, merged under the transition's own. */
76
+ readonly metadata?: Record<string, unknown> | undefined;
77
+ }
78
+ /** What a transition did. */
79
+ export interface LifecycleTransition {
80
+ /** Whether the account moved. `false` when it was already where the call asked to put it. */
81
+ readonly changed: boolean;
82
+ /** Whether a lifecycle mail was enqueued for the account. False when the config, the call or a missing email capability sent none. */
83
+ readonly mailed: boolean;
84
+ }
85
+ /** What a suspension did, and the suspension it left in force. */
86
+ export interface SuspendTransition extends LifecycleTransition {
87
+ /**
88
+ * True when the account was already suspended and this call restated the reason and the end instead (#621).
89
+ * That is not a transition — `changed` is false and no hook fires — but it is written, audited and mailed.
90
+ */
91
+ readonly updated: boolean;
92
+ /** When the suspension in force began. A restatement keeps the original start. */
93
+ readonly suspendedAt: Date;
94
+ /** When it ends by itself, or null for one that lasts until a reinstatement. */
95
+ readonly suspendedUntil: Date | null;
96
+ }
97
+ /**
98
+ * Suspend an account, until `until` or until it is reinstated.
99
+ *
100
+ * A deleted account cannot be suspended — deletion already shuts it, and outranks a suspension — so that is a
101
+ * conflict rather than a no-op, and names `restoreRoute` when the caller gives one. A suspension whose end has
102
+ * passed is not in force, and a new one replaces it.
103
+ *
104
+ * **An account already suspended has its terms restated (#621).** The reason and the end are replaced, a
105
+ * `suspended` row records the new reason — the newest one is what the person is shown — and the audit event
106
+ * and the mail say so. The start is kept, and no hook fires: the account was suspended and still is, so
107
+ * nothing transitioned. A fresh suspension that loses the race to another suspension finds the account
108
+ * suspended, so it retries once as a restatement rather than failing. A write that finds the account moved
109
+ * under it any other way, by a reinstatement or a deletion that landed first, is a conflict: what the caller
110
+ * asked for no longer describes the account.
111
+ *
112
+ * `notify: false` sends no mail, whatever the config says; the config can only turn mail off, never on.
113
+ */
114
+ export declare function suspendUser(deps: LifecycleDeps, input: {
115
+ userId: string;
116
+ actor: LifecycleActor;
117
+ reason: string | null;
118
+ until?: Date | null;
119
+ notify?: boolean;
120
+ restoreRoute?: string;
121
+ }): Promise<SuspendTransition>;
122
+ /**
123
+ * Lift a suspension. An account that is not suspended — including one whose suspension ran out — is a no-op.
124
+ *
125
+ * Where the account stands is read through `accountStanding`, never off the raw column, because a suspension
126
+ * past its end leaves `suspendedAt` set and is not a suspension. A deleted account is a conflict, as it is
127
+ * for `suspendUser`: deletion outranks the suspension it keeps, so lifting that suspension would mail "you can
128
+ * sign in again" to somebody every sign-in still refuses. Restore it first.
129
+ *
130
+ * `notify: false` sends no mail, on the same rule as `suspendUser`.
131
+ */
132
+ export declare function reinstateUser(deps: LifecycleDeps, input: {
133
+ userId: string;
134
+ actor: LifecycleActor;
135
+ reason: string | null;
136
+ notify?: boolean;
137
+ restoreRoute?: string;
138
+ }): Promise<LifecycleTransition>;
139
+ /** How a deletion runs: shut now and purged once the window closes, or purged now. */
140
+ export type DeletionMode = "soft" | "hard";
141
+ /** What a deletion did, and the deletion it left in force. */
142
+ export interface DeleteTransition extends LifecycleTransition {
143
+ /**
144
+ * `deleted` when this call deleted an account in good standing; `brought_forward` when the account was
145
+ * already deleted and a hard deletion moved its purge to now; `unchanged` when it was already deleted and
146
+ * this call had nothing to move.
147
+ */
148
+ readonly outcome: "deleted" | "brought_forward" | "unchanged";
149
+ /** When the account was deleted. A deletion brought forward keeps its original start. */
150
+ readonly deletedAt: Date;
151
+ /** When the purge may erase it — now, for a hard deletion. Restorable until then. */
152
+ readonly purgeAfter: Date;
153
+ }
154
+ /**
155
+ * Delete an account. Audited as the account's own deletion when its holder is the actor.
156
+ *
157
+ * **Soft, the default**: it is shut now, and its data is erased once `retention.purgeAfterDays` have passed.
158
+ * Restorable until then. The deletion-scheduled mail carries the purge date and, when the config names one,
159
+ * the restore path. A deleted account deleted softly again is no transition.
160
+ *
161
+ * **Hard** (#622): `purgeAfter` is now, so the window is already closed — nothing can restore it — and the
162
+ * caller starts the purge. No deletion-scheduled mail, because nothing is scheduled; the purge sends the
163
+ * deletion-complete one. An account already deleted softly has its purge brought forward to now, which is
164
+ * written and audited but fires no hook: the account was deleted and still is. One already due is unchanged.
165
+ *
166
+ * A suspension the account was under is left in place, so restoring the account does not lift it.
167
+ * `notify: false` sends no mail, whatever the config says.
168
+ */
169
+ export declare function deleteUser(deps: LifecycleDeps, input: {
170
+ userId: string;
171
+ actor: LifecycleActor;
172
+ reason: string | null;
173
+ mode?: DeletionMode;
174
+ notify?: boolean;
175
+ }): Promise<DeleteTransition>;
176
+ /** What a restoration did, and where it left the account. */
177
+ export interface RestoreTransition extends LifecycleTransition {
178
+ /** Where the account stands now: `active`, or `suspended` when a suspension it was under is still in force. */
179
+ readonly state: "active" | "suspended";
180
+ }
181
+ /**
182
+ * Restore a deleted account inside its purge window.
183
+ *
184
+ * **Only inside it.** Once `purgeAfter` has passed the purge is due, may already be running, and erases each
185
+ * capability's rows in turn, so restoring then would hand back an account with some of its data gone. That
186
+ * is a conflict naming the date the window closed. After the purge there is no account at all, and that is a
187
+ * 404 whose action says the data is gone — read off the history row the purge leaves behind, so it is told
188
+ * apart from an id that never existed.
189
+ *
190
+ * An account that is not deleted is no transition. A suspension it was under is still in force after.
191
+ */
192
+ export declare function restoreUser(deps: LifecycleDeps, input: {
193
+ userId: string;
194
+ actor: LifecycleActor;
195
+ reason: string | null;
196
+ }): Promise<RestoreTransition>;
197
+ /**
198
+ * The account's row, or the refusal for one that is not there — the 404 that says the data is gone when the
199
+ * purge erased it, and the plain one otherwise. For a route that reads an account outside a transition: the
200
+ * export.
201
+ */
202
+ export declare function requirePresent(db: AuthDatabase, userId: string): Promise<void>;
203
+ /** Who the purge's last mail goes to, captured before any step erases the address. */
204
+ export interface PurgeRecipient {
205
+ readonly email: string;
206
+ readonly name: string | null;
207
+ readonly locale: string | null;
208
+ }
209
+ /**
210
+ * Whether one account is due for its purge, who its last mail goes to, and whether it goes (#622).
211
+ *
212
+ * `due` only for an account that is deleted and whose `purgeAfter` has passed — the cron and a hard deletion
213
+ * both start a purge, and this is the one check either passes through, so an account restored in between is
214
+ * `not_due` and nothing is erased. `gone` when there is no row: the purge already erased it, or the id never
215
+ * existed, and either way there is nothing to do. The recipient is read here, before the first step, because
216
+ * the last step erases it.
217
+ *
218
+ * `notify` is what the deletion in force asked of the last mail — its newest `deleted` row's — so a hard
219
+ * deletion's `notify: false` holds for a purge the daily pass started, which was handed no such parameter.
220
+ */
221
+ export declare function purgeSubject(deps: LifecycleDeps, userId: string): Promise<{
222
+ state: "due";
223
+ recipient: PurgeRecipient;
224
+ notify: boolean | null;
225
+ } | {
226
+ state: "not_due";
227
+ } | {
228
+ state: "gone";
229
+ }>;
230
+ /** One account whose purge is due: which, and the deletion it is due under — ms-epoch, so a Workflow journal holds it. */
231
+ export interface DuePurge {
232
+ readonly userId: string;
233
+ readonly deletedAt: number;
234
+ }
235
+ /**
236
+ * The accounts whose purge is due — deleted, with `purgeAfter` passed — oldest first, at most `limit` (#622).
237
+ * What the daily cron starts a purge for. An account still inside its window is not here, and neither is one
238
+ * that was restored. Each carries its deletion's start, which names the purge's instance (`../purge/start.ts`).
239
+ */
240
+ export declare function duePurges(deps: LifecycleDeps, limit: number): Promise<DuePurge[]>;
241
+ /**
242
+ * Record that one purge step — one capability's contribution — erased its rows. The contribution's summary is
243
+ * the row's reason, so the history says what the step erased and not only that it ran.
244
+ */
245
+ export declare function recordPurgeStep(deps: LifecycleDeps, input: {
246
+ userId: string;
247
+ step: string;
248
+ summary?: string | null;
249
+ }): Promise<void>;
250
+ /**
251
+ * The deletion-complete mail, sent **before the address is erased** (#622). The purge calls this after every
252
+ * other capability's rows are gone and before auth's own, which holds the address, so the last mail is
253
+ * enqueued while there is still an account to have sent it to. The address is handed in, captured before the
254
+ * first step. `notify: false` sends nothing, whatever the config says.
255
+ */
256
+ export declare function mailPurgeComplete(deps: LifecycleDeps, input: {
257
+ recipient: PurgeRecipient;
258
+ notify?: boolean;
259
+ }): Promise<LifecycleTransition>;
260
+ /**
261
+ * Finish a purge: the record, the audit event, the hook. The last thing that happens to the account.
262
+ *
263
+ * By the time a purge finishes the user row is gone, so this reads nothing about the account. Finishing a
264
+ * purge that already finished is a no-op, so a retried Workflow step records and fires once — and so do two
265
+ * purges of one account that overlapped. **The insert is the check**: `0005_purge_once` allows one `purged` row
266
+ * per account, the insert ignores a second, and only the call whose row landed audits and fires. A read
267
+ * before the insert would let two concurrent calls both find nothing and both write.
268
+ */
269
+ export declare function completePurge(deps: LifecycleDeps, input: {
270
+ userId: string;
271
+ }): Promise<LifecycleTransition>;
272
+ //# sourceMappingURL=transitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transitions.d.ts","sourceRoot":"","sources":["../../src/lifecycle/transitions.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAuB,MAAM,2BAA2B,CAAC;AAEjF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAInE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAGrE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,g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