@pithy-sh/auth 0.16.0 → 0.17.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 (59) hide show
  1. package/dist/capability.d.ts +9 -6
  2. package/dist/capability.d.ts.map +1 -1
  3. package/dist/capability.js +4 -2
  4. package/dist/data/tables.d.ts +1 -0
  5. package/dist/data/tables.d.ts.map +1 -1
  6. package/dist/data/userLifecycle.d.ts +1 -0
  7. package/dist/data/userLifecycle.d.ts.map +1 -1
  8. package/dist/data/userLifecycle.js +3 -2
  9. package/dist/hooks/runtime.d.ts +32 -0
  10. package/dist/hooks/runtime.d.ts.map +1 -0
  11. package/dist/hooks/runtime.js +25 -0
  12. package/dist/http/adminRoutes.d.ts.map +1 -1
  13. package/dist/http/adminRoutes.js +4 -2
  14. package/dist/http/resolve.d.ts.map +1 -1
  15. package/dist/http/resolve.js +2 -1
  16. package/dist/http/responses.d.ts +3 -0
  17. package/dist/http/responses.d.ts.map +1 -1
  18. package/dist/http/responses.js +2 -1
  19. package/dist/lifecycle/erasure.d.ts.map +1 -1
  20. package/dist/lifecycle/erasure.js +2 -1
  21. package/dist/lifecycle/hooks.d.ts +18 -10
  22. package/dist/lifecycle/hooks.d.ts.map +1 -1
  23. package/dist/lifecycle/request.d.ts +2 -1
  24. package/dist/lifecycle/request.d.ts.map +1 -1
  25. package/dist/lifecycle/request.js +4 -1
  26. package/dist/lifecycle/transitions.d.ts +24 -16
  27. package/dist/lifecycle/transitions.d.ts.map +1 -1
  28. package/dist/lifecycle/transitions.js +27 -16
  29. package/dist/migrations/0011_retained_basis_key.d.ts +10 -0
  30. package/dist/migrations/0011_retained_basis_key.d.ts.map +1 -0
  31. package/dist/migrations/0011_retained_basis_key.js +18 -0
  32. package/dist/migrations/set.d.ts +1 -0
  33. package/dist/migrations/set.d.ts.map +1 -1
  34. package/dist/migrations/set.js +3 -1
  35. package/dist/purge/run.d.ts +11 -11
  36. package/dist/purge/run.d.ts.map +1 -1
  37. package/dist/purge/run.js +9 -8
  38. package/dist/purge/workflow.d.ts +7 -1
  39. package/dist/purge/workflow.d.ts.map +1 -1
  40. package/dist/purge/workflow.js +6 -2
  41. package/dist/version.generated.d.ts +1 -1
  42. package/dist/version.generated.js +1 -1
  43. package/docs/account-lifecycle.md +46 -10
  44. package/package.json +5 -5
  45. package/src/capability.ts +21 -8
  46. package/src/data/userLifecycle.ts +9 -2
  47. package/src/hooks/runtime.ts +41 -0
  48. package/src/http/adminRoutes.ts +14 -7
  49. package/src/http/resolve.ts +8 -4
  50. package/src/http/responses.ts +7 -1
  51. package/src/lifecycle/erasure.ts +2 -1
  52. package/src/lifecycle/hooks.ts +22 -10
  53. package/src/lifecycle/request.ts +4 -1
  54. package/src/lifecycle/transitions.ts +47 -28
  55. package/src/migrations/0011_retained_basis_key.ts +19 -0
  56. package/src/migrations/set.ts +2 -0
  57. package/src/purge/run.ts +29 -17
  58. package/src/purge/workflow.ts +7 -3
  59. package/src/version.generated.ts +1 -1
@@ -1 +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;AAG/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,gBAAgB,CAAC;AACnD,OAAO,KAAK,EAAuB,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AACzF,OAAO,KAAK,EAA0B,kBAAkB,EAAyB,MAAM,SAAS,CAAC;AAIjG;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,6BAA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C;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAWpH;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,aAAa,EACnB,KAAK,EAAE;IAAE,SAAS,EAAE,cAAc,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,GACrD,OAAO,CAAC,mBAAmB,CAAC,CAY9B;AAED;;;;;;;;GAQG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,aAAa,EAAE,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAYhH"}
@@ -64,6 +64,7 @@ function encoded(row) {
64
64
  notify: row.notify === void 0 || row.notify === null ? null : SQLiteBoolean.encode(row.notify),
65
65
  mode: row.mode ?? null,
66
66
  purgeAfter: row.purgeAfter ? SQLiteDate.encode(row.purgeAfter) : null,
67
+ basisKey: row.basisKey ?? null,
67
68
  createdAt: SQLiteDate.encode(row.at)
68
69
  };
69
70
  }
@@ -156,7 +157,7 @@ async function mail(deps, enabled, to, locale, template, payload) {
156
157
  async function fire(deps, name, hook, event) {
157
158
  if (!hook) return;
158
159
  try {
159
- await hook(event, deps.d1);
160
+ await hook(event, deps.d1, deps.runtime);
160
161
  } catch (error) {
161
162
  deps.log?.warn(`${name} threw; the transition stands`, {
162
163
  userId: event.userId,
@@ -186,7 +187,7 @@ function raced(userId) {
186
187
  });
187
188
  }
188
189
  /**
189
- * The instant a purge-window guard compares against, **read when the statement runs**, as ms-epoch (#622).
190
+ * The instant a purge-window guard compares against, **read when the statement runs**, as ms-epoch.
190
191
  *
191
192
  * A restore and a purge's `due` check race for one account, and each has to see the window the other saw. A
192
193
  * timestamp the restore took before its statement went out is stale by the time D1 runs it: the window can
@@ -213,7 +214,7 @@ function windowClosed(userId, closes) {
213
214
  * conflict rather than a no-op, and names `restoreRoute` when the caller gives one. A suspension whose end has
214
215
  * passed is not in force, and a new one replaces it.
215
216
  *
216
- * **An account already suspended has its terms restated (#621).** The reason and the end are replaced, a
217
+ * **An account already suspended has its terms restated.** The reason and the end are replaced, a
217
218
  * `suspended` row records the new reason — the newest one is what the person is shown — and the audit event
218
219
  * and the mail say so. The start is kept, and no hook fires: the account was suspended and still is, so
219
220
  * nothing transitioned. A fresh suspension that loses the race to another suspension finds the account
@@ -342,7 +343,7 @@ function userPurgeWindowDays(config) {
342
343
  * Restorable until then. The deletion-scheduled mail carries the purge date and, when the config names one,
343
344
  * the restore path. A deleted account deleted softly again is no transition.
344
345
  *
345
- * **Hard** (#622): `purgeAfter` is now, so the window is already closed — nothing can restore it — and the
346
+ * **Hard**: `purgeAfter` is now, so the window is already closed — nothing can restore it — and the
346
347
  * caller starts the purge. No deletion-scheduled mail, because nothing is scheduled; the purge sends the
347
348
  * deletion-complete one. An account already deleted softly has its purge brought forward to now, which is
348
349
  * written and audited but fires no hook: the account was deleted and still is. One already due is unchanged.
@@ -441,7 +442,8 @@ async function deleteUser(deps, input) {
441
442
  * 404 whose action says the data is gone — read off the history row the purge leaves behind, so it is told
442
443
  * apart from an id that never existed.
443
444
  *
444
- * An account that is not deleted is no transition. A suspension it was under is still in force after.
445
+ * An account that is not deleted is no transition, and fires nothing. A suspension it was under is still in force
446
+ * after. `onUserRestored` fires once the restore is written, so an adopter can undo what it did on `onUserDeleted`.
445
447
  */
446
448
  async function restoreUser(deps, input) {
447
449
  const at = (deps.now ?? (() => /* @__PURE__ */ new Date()))();
@@ -485,6 +487,12 @@ async function restoreUser(deps, input) {
485
487
  throw raced(input.userId);
486
488
  }
487
489
  await audit(deps, AuthAuditActions.adminUserRestored, input.userId, input.actor, { reason });
490
+ await fire(deps, "onUserRestored", deps.hooks.onUserRestored, {
491
+ userId: input.userId,
492
+ actor: input.actor,
493
+ reason,
494
+ at
495
+ });
488
496
  return {
489
497
  changed: true,
490
498
  mailed: false,
@@ -506,12 +514,13 @@ async function purgedRefusal(db, userId) {
506
514
  });
507
515
  }
508
516
  /**
509
- * The account's row, or the refusal for one that is not there — the 404 that says the data is gone when the
510
- * purge erased it, and the plain one otherwise. For a route that reads an account outside a transition: the
511
- * export.
517
+ * The account's stored locale, or the refusal for an account that is not there — the 404 that says the data is gone
518
+ * when the purge erased it, and the plain one otherwise. For a route that reads an account outside a transition: the
519
+ * export, which answers in the person's own language.
512
520
  */
513
521
  async function requirePresent(db, userId) {
514
- if (await db.selectFrom("pithyAuthUsers").select("id").where("id", "=", userId).executeTakeFirst()) return;
522
+ const row = await db.selectFrom("pithyAuthUsers").select(["id", "locale"]).where("id", "=", userId).executeTakeFirst();
523
+ if (row) return { locale: row.locale ?? null };
515
524
  throw await purgedRefusal(db, userId) ?? new NotFoundError({
516
525
  message: "No such user.",
517
526
  detail: `no pithy_auth_users row for ${userId}`
@@ -523,7 +532,7 @@ const PURGE = {
523
532
  id: null
524
533
  };
525
534
  /**
526
- * Whether one account is due for its purge, who its last mail goes to, and whether it goes (#622).
535
+ * Whether one account is due for its purge, who its last mail goes to, and whether it goes.
527
536
  *
528
537
  * `due` only for an account that is deleted and whose `purgeAfter` has passed — the cron and a hard deletion
529
538
  * both start a purge, and this is the one check either passes through, so an account restored in between is
@@ -560,14 +569,14 @@ async function purgeSubject(deps, userId) {
560
569
  };
561
570
  }
562
571
  /**
563
- * The account's address, as a purge step reads it (#814) — `null` when there is no account, or no address. Read
572
+ * The account's address, as a purge step reads it — `null` when there is no account, or no address. Read
564
573
  * inside the step that asks, so it is never carried in a Workflow's journal.
565
574
  */
566
575
  async function purgeAddress(db, userId) {
567
576
  return (await db.selectFrom("pithyAuthUsers").select("email").where("id", "=", userId).executeTakeFirst())?.email ?? null;
568
577
  }
569
578
  /**
570
- * The accounts whose purge is due — deleted, with `purgeAfter` passed — oldest first, at most `limit` (#622).
579
+ * The accounts whose purge is due — deleted, with `purgeAfter` passed — oldest first, at most `limit`.
571
580
  * What the daily cron starts a purge for. An account still inside its window is not here, and neither is one
572
581
  * that was restored. Each carries its deletion's start, which names the purge's instance (`../purge/start.ts`).
573
582
  */
@@ -581,7 +590,8 @@ async function duePurges(deps, limit) {
581
590
  /**
582
591
  * Record that one purge step — one capability's contribution — erased its rows. The contribution's summary is
583
592
  * the row's reason, so the history says what the step erased and not only that it ran. With `retained`, the step
584
- * kept its rows instead (#814): the row is `purge_retained`, and its reason is the basis the capability gave.
593
+ * kept its rows instead: the row is `purge_retained`, its reason is the basis the capability gave, and its
594
+ * `basisKey` the catalog key that translates it, when the capability names one.
585
595
  */
586
596
  async function recordPurgeStep(deps, input) {
587
597
  const at = (deps.now ?? (() => /* @__PURE__ */ new Date()))();
@@ -591,7 +601,8 @@ async function recordPurgeStep(deps, input) {
591
601
  actor: PURGE,
592
602
  reason: input.summary?.trim() ? input.summary.trim().slice(0, 500) : null,
593
603
  at,
594
- step: input.step
604
+ step: input.step,
605
+ basisKey: input.retained ? input.basisKey ?? null : null
595
606
  });
596
607
  await audit(deps, AuthAuditActions.adminUserPurgeStep, input.userId, PURGE, {
597
608
  step: input.step,
@@ -599,7 +610,7 @@ async function recordPurgeStep(deps, input) {
599
610
  });
600
611
  }
601
612
  /**
602
- * Record that a purge gave up (#823): the step it stopped at, in the history and in the trail. The daily pass starts
613
+ * Record that a purge gave up: the step it stopped at, in the history and in the trail. The daily pass starts
603
614
  * the purge again tomorrow, so this is where it stands until then, not an end. The failure's message is never
604
615
  * written: it is code the kit did not write, and it may name the person.
605
616
  */
@@ -616,7 +627,7 @@ async function recordPurgeFailure(deps, input) {
616
627
  await audit(deps, AuthAuditActions.adminUserPurgeFailed, input.userId, PURGE, { step: input.step });
617
628
  }
618
629
  /**
619
- * The deletion-complete mail, sent **before the address is erased** (#622). The purge calls this after every
630
+ * The deletion-complete mail, sent **before the address is erased**. The purge calls this after every
620
631
  * other capability's rows are gone and before auth's own, which holds the address, so the last mail is
621
632
  * enqueued while there is still an account to have sent it to. The address is handed in, captured before the
622
633
  * first step. `notify: false` sends nothing, whatever the config says.
@@ -0,0 +1,10 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ import type { Migration } from "kysely/migration";
4
+ /**
5
+ * `basis_key` on `pithy_auth_user_lifecycle`: the catalog key a retained step's basis translates through, beside the
6
+ * English basis in `reason`. Null on every other row, on a retained step that names no key, and on one recorded
7
+ * before this ran. Appended: the chain is released history.
8
+ */
9
+ export declare const auth_0011_retained_basis_key: Migration;
10
+ //# sourceMappingURL=0011_retained_basis_key.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"0011_retained_basis_key.d.ts","sourceRoot":"","sources":["../../src/migrations/0011_retained_basis_key.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,4BAA4B,EAAE,SAO1C,CAAC"}
@@ -0,0 +1,18 @@
1
+ // SPDX-FileCopyrightText: 2026 Pithy
2
+ // SPDX-License-Identifier: MIT
3
+ //#region src/migrations/0011_retained_basis_key.ts
4
+ /**
5
+ * `basis_key` on `pithy_auth_user_lifecycle`: the catalog key a retained step's basis translates through, beside the
6
+ * English basis in `reason`. Null on every other row, on a retained step that names no key, and on one recorded
7
+ * before this ran. Appended: the chain is released history.
8
+ */
9
+ const auth_0011_retained_basis_key = {
10
+ async up(db) {
11
+ await db.schema.alterTable("pithyAuthUserLifecycle").addColumn("basisKey", "text").execute();
12
+ },
13
+ async down(db) {
14
+ await db.schema.alterTable("pithyAuthUserLifecycle").dropColumn("basisKey").execute();
15
+ }
16
+ };
17
+ //#endregion
18
+ export { auth_0011_retained_basis_key };
@@ -24,5 +24,6 @@ export declare const AUTH_MIGRATIONS: {
24
24
  readonly "0008_last_active": import("kysely/migration").Migration;
25
25
  readonly "0009_attestation_challenges": import("kysely/migration").Migration;
26
26
  readonly "0010_app_attest_keys": import("kysely/migration").Migration;
27
+ readonly "0011_retained_basis_key": import("kysely/migration").Migration;
27
28
  };
28
29
  //# sourceMappingURL=set.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../src/migrations/set.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe;aAC1B,WAAW;aACX,+BAA+B;aAC/B,8BAA8B;aAC9B,qBAAqB;aACrB,iBAAiB;aACjB,4BAA4B;aAC5B,qBAAqB;aACrB,kBAAkB;aAClB,6BAA6B;aAC7B,sBAAsB;CACd,CAAC"}
1
+ {"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../src/migrations/set.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe;aAC1B,WAAW;aACX,+BAA+B;aAC/B,8BAA8B;aAC9B,qBAAqB;aACrB,iBAAiB;aACjB,4BAA4B;aAC5B,qBAAqB;aACrB,kBAAkB;aAClB,6BAA6B;aAC7B,sBAAsB;aACtB,yBAAyB;CACjB,CAAC"}
@@ -10,6 +10,7 @@ import { auth_0007_erasure_record } from "./0007_erasure_record.js";
10
10
  import { auth_0008_last_active } from "./0008_last_active.js";
11
11
  import { auth_0009_attestation_challenges } from "./0009_attestation_challenges.js";
12
12
  import { auth_0010_app_attest_keys } from "./0010_app_attest_keys.js";
13
+ import { auth_0011_retained_basis_key } from "./0011_retained_basis_key.js";
13
14
  //#region src/migrations/set.ts
14
15
  /**
15
16
  * Every migration `@pithy-sh/auth` ships, keyed as `pithy migrate` composes them.
@@ -34,7 +35,8 @@ const AUTH_MIGRATIONS = {
34
35
  "0007_erasure_record": auth_0007_erasure_record,
35
36
  "0008_last_active": auth_0008_last_active,
36
37
  "0009_attestation_challenges": auth_0009_attestation_challenges,
37
- "0010_app_attest_keys": auth_0010_app_attest_keys
38
+ "0010_app_attest_keys": auth_0010_app_attest_keys,
39
+ "0011_retained_basis_key": auth_0011_retained_basis_key
38
40
  };
39
41
  //#endregion
40
42
  export { AUTH_MIGRATIONS };
@@ -1,12 +1,12 @@
1
1
  // SPDX-FileCopyrightText: 2026 Pithy
2
2
  // SPDX-License-Identifier: MIT
3
- import { type PurgeStep } from "@pithy-sh/core/src/capability/purge";
3
+ import { type PurgeStep, type RetainingPurgeContribution } from "@pithy-sh/core/src/capability/purge";
4
4
  import type { LegalHolds } from "@pithy-sh/core/src/retention/holds";
5
5
  import { type TerminalErrorConstructor, type WorkflowStepLike } from "@pithy-sh/core/src/workflow/faults";
6
6
  import { type DuePurge, type LifecycleDeps } from "../lifecycle/transitions";
7
7
  import { type AuthPurgeDueParams, type AuthPurgeParams } from "./specs";
8
8
  /**
9
- * The purge, as steps (#622) — the bodies `./workflow.ts` hands a Workflow's step runner to.
9
+ * The purge, as steps — the bodies `./workflow.ts` hands a Workflow's step runner to.
10
10
  *
11
11
  * ## One step per contribution, and the order they run in
12
12
  *
@@ -14,7 +14,7 @@ import { type AuthPurgeDueParams, type AuthPurgeParams } from "./specs";
14
14
  * and one already erased all end the run here, having erased nothing. This is the one check a cron-started
15
15
  * purge and a hard deletion's both pass through, so re-running a purge for the same subject exits cleanly.
16
16
  * 2. **`erase <capability>`** — one step per composed contribution, in composition order, each recording that it
17
- * ran in `pithy_auth_user_lifecycle`. A contribution that **retains** its rows (#814) is a `retain <capability>`
17
+ * ran in `pithy_auth_user_lifecycle`. A contribution that **retains** its rows is a `retain <capability>`
18
18
  * step instead: it erases nothing, and records `purge_retained` with the basis it gave. Handed to the platform's retry unclassified: an `erase` is idempotent by
19
19
  * contract and runs code the kit did not write, so any fault in it is worth another attempt (`./retryPolicy.ts`).
20
20
  * A failing contribution retries alone, and the ones that finished are served from the journal.
@@ -24,7 +24,7 @@ import { type AuthPurgeDueParams, type AuthPurgeParams } from "./specs";
24
24
  * 4. **`erase auth`** — auth's own contribution, last for that reason.
25
25
  * 5. **`complete`** — the `purged` record, the audit event, `onUserPurged`. Once.
26
26
  *
27
- * Every step from 2 on records an audit event as well as its row (#823), which the erasure attestation cites.
27
+ * Every step from 2 on records an audit event as well as its row, which the erasure attestation cites.
28
28
  *
29
29
  * ## A legal hold stops it
30
30
  *
@@ -35,7 +35,7 @@ import { type AuthPurgeDueParams, type AuthPurgeParams } from "./specs";
35
35
  * erase where the first one did and carry on from there. A hold that cannot be read fails its step, which retries:
36
36
  * a purge never erases past a hold it could not see.
37
37
  *
38
- * ## A purge that gives up says where (#823)
38
+ * ## A purge that gives up says where
39
39
  *
40
40
  * A step that exhausts its retries fails the instance, and the daily pass starts a fresh one tomorrow. Until then the
41
41
  * record would read as a purge still running. So the failure is caught once, recorded in its own `fail` step —
@@ -48,10 +48,10 @@ export interface PurgeOps {
48
48
  due(userId: string): Promise<"due" | "not_due" | "gone">;
49
49
  /** Record that one capability's step erased its rows. */
50
50
  recordStep(userId: string, step: string, summary: string): Promise<void>;
51
- /** Record that one capability's step kept its rows, and why (#814). */
52
- recordRetained(userId: string, step: string, basis: string): Promise<void>;
51
+ /** Record that one capability's step kept its rows, and why: its basis, and the catalog key that translates it. */
52
+ recordRetained(userId: string, step: string, retain: RetainingPurgeContribution["retain"]): Promise<void>;
53
53
  /**
54
- * The account's address, read now, or `null` once it is gone (#814). Handed to each step as
54
+ * The account's address, read now, or `null` once it is gone. Handed to each step as
55
55
  * `PurgeContext.address`, so a capability holding rows by address reads it inside its own step.
56
56
  */
57
57
  address(userId: string): Promise<string | null>;
@@ -62,7 +62,7 @@ export interface PurgeOps {
62
62
  mailComplete(userId: string, notify: boolean | undefined): Promise<boolean>;
63
63
  /** Write the `purged` record, the audit event and the hook. Says whether this call wrote them. */
64
64
  complete(userId: string): Promise<boolean>;
65
- /** Record that the purge gave up at `step`, in the history and the trail (#823). */
65
+ /** Record that the purge gave up at `step`, in the history and the trail. */
66
66
  fail(userId: string, step: string): Promise<void>;
67
67
  /** Whether a legal hold stands on the account. Throws when it cannot say. */
68
68
  held(userId: string): Promise<boolean>;
@@ -80,7 +80,7 @@ export interface PurgeOutcome {
80
80
  readonly state: "purged" | "not_due" | "gone" | "held";
81
81
  /** Every step that erased its rows, in the order it ran. Empty when nothing was erased. */
82
82
  readonly erased: readonly string[];
83
- /** Every step that kept its rows under a stated basis (#814), in the order it ran. */
83
+ /** Every step that kept its rows under a stated basis, in the order it ran. */
84
84
  readonly retained: readonly string[];
85
85
  /** Whether the deletion-complete mail was enqueued. */
86
86
  readonly mailed: boolean;
@@ -117,7 +117,7 @@ export interface PurgeDueRun {
117
117
  held?(userId: string): Promise<boolean>;
118
118
  }
119
119
  /**
120
- * The daily pass (#622): list every account past its window, and start a purge for each — in pages, one step
120
+ * The daily pass: list every account past its window, and start a purge for each — in pages, one step
121
121
  * each, so a pass that dies part-way resumes after the page it finished rather than starting every purge
122
122
  * again. An account still inside its window is not listed, so it is not started.
123
123
  */
@@ -1 +1 @@
1
- {"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/purge/run.ts"],"names":[],"mappings":"AAGA,OAAO,EAAiC,KAAK,SAAS,EAAE,MAAM,qCAAqC,CAAC;AACpG,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAEL,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EACtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAEL,KAAK,QAAQ,EAEb,KAAK,aAAa,EAMnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAmB,KAAK,kBAAkB,EAAE,KAAK,eAAe,EAAE,MAAM,SAAS,CAAC;AAEzF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,wGAAwG;AACxG,MAAM,WAAW,QAAQ;IACvB,oGAAoG;IACpG,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,GAAG,SAAS,GAAG,MAAM,CAAC,CAAC;IACzD,yDAAyD;IACzD,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzE,uEA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KAAK,CAAC,CAEnE;AAED,6GAA6G;AAC7G,eAAO,MAAM,sBAAsB,MAAM,CAAC;AAE1C,0DAA0D;AAC1D,MAAM,WAAW,aAAa;IAC5B;;;OAGG;IACH,IAAI,IAAI,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC/B,4EAA4E;IAC5E,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACzD,kDAAkD;IAClD,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvC,mHAAmH;IACnH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACvD,WAAW;IACX,GAAG,IAAI,IAAI,CAAC;CACb;AAED;;;;;;;GAOG;AACH,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,gBAAgB,EACtB,aAAa,EAAE,wBAAwB,EACvC,KAAK,SAAyB,GAC7B,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAmB9B"}
package/dist/purge/run.js CHANGED
@@ -15,11 +15,12 @@ function purgeOps(deps, holds) {
15
15
  step,
16
16
  summary
17
17
  }),
18
- recordRetained: (userId, step, basis) => recordPurgeStep(deps, {
18
+ recordRetained: (userId, step, retain) => recordPurgeStep(deps, {
19
19
  userId,
20
20
  step,
21
- summary: basis,
22
- retained: true
21
+ summary: retain.basis,
22
+ retained: true,
23
+ ...retain.basisKey === void 0 ? {} : { basisKey: retain.basisKey }
23
24
  }),
24
25
  address: (userId) => purgeAddress(deps.db, userId),
25
26
  mailComplete: async (userId, notify) => {
@@ -75,7 +76,7 @@ async function purgeUser(run, step, terminalError, params) {
75
76
  const runStep = async (each) => {
76
77
  const { contribution } = each;
77
78
  current = each.step;
78
- if (isRetained(contribution)) retained.push(await retainStep(step, run.ops, each.step, contribution.retain.basis, userId));
79
+ if (isRetained(contribution)) retained.push(await retainStep(step, run.ops, each.step, contribution.retain, userId));
79
80
  else erased.push(await eraseStep(step, run.ops, each, context));
80
81
  };
81
82
  try {
@@ -132,12 +133,12 @@ function eraseStep(step, ops, each, context) {
132
133
  });
133
134
  }
134
135
  /**
135
- * One capability's retained step (#814): nothing is erased, and the record says the rows were kept and why. Its own
136
+ * One capability's retained step: nothing is erased, and the record says the rows were kept and why. Its own
136
137
  * step, so the trail names it in the order it would have run, and a replay serves it from the journal.
137
138
  */
138
- function retainStep(step, ops, name, basis, userId) {
139
+ function retainStep(step, ops, name, retain, userId) {
139
140
  return step.do(`retain ${name}`, async () => {
140
- await ops.recordRetained(userId, name, basis);
141
+ await ops.recordRetained(userId, name, retain);
141
142
  return name;
142
143
  });
143
144
  }
@@ -146,7 +147,7 @@ const PURGE_START_PAGE = 50;
146
147
  /** The default size of one daily pass. */
147
148
  const PURGE_DUE_DEFAULT_LIMIT = 500;
148
149
  /**
149
- * The daily pass (#622): list every account past its window, and start a purge for each — in pages, one step
150
+ * The daily pass: list every account past its window, and start a purge for each — in pages, one step
150
151
  * each, so a pass that dies part-way resumes after the page it finished rather than starting every purge
151
152
  * again. An account still inside its window is not listed, so it is not started.
152
153
  */
@@ -3,10 +3,11 @@
3
3
  import type { Logger } from "@pithy-sh/core/src/logger/logger";
4
4
  import { type LegalHolds } from "@pithy-sh/core/src/retention/holds";
5
5
  import type { TerminalErrorConstructor, WorkflowStepLike } from "@pithy-sh/core/src/workflow/faults";
6
+ import { type AuthCapability } from "../capability";
6
7
  import { type LifecycleDeps } from "../lifecycle/transitions";
7
8
  import { type InactivityRun, type PurgeDueRun, type PurgeOutcome } from "./run";
8
9
  /**
9
- * The purge's two Workflow bodies (#622) — run by classes **the adopter's own Worker** exports, beside the
10
+ * The purge's two Workflow bodies — run by classes **the adopter's own Worker** exports, beside the
10
11
  * `createEntrypoint` it already exports, because a purge runs every composed capability's contribution and
11
12
  * those exist nowhere else:
12
13
  *
@@ -40,6 +41,11 @@ interface PurgeEvent {
40
41
  readonly workflowName?: string;
41
42
  readonly instanceId?: string;
42
43
  }
44
+ /**
45
+ * The lifecycle transitions' dependencies, for a run with no request: this env, and the composition's seams. The
46
+ * hooks run in this env with no `waitUntil`, since a Workflow has no `ExecutionContext`.
47
+ */
48
+ export declare function lifecycleFor(auth: AuthCapability, env: Record<string, unknown>, log: Logger): LifecycleDeps;
43
49
  /** Purge one account: every composed contribution, one step each, auth's last. See `./run.ts`. */
44
50
  export declare function runAuthPurge(env: Record<string, unknown>, event: PurgeEvent, step: WorkflowStepLike, terminalError: TerminalErrorConstructor): Promise<PurgeOutcome>;
45
51
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../../src/purge/workflow.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kCAAkC,CAAC;AAG/D,OAAO,EAAE,KAAK,UAAU,EAAc,MAAM,oCAAoC,CAAC;AAGjF,OAAO,KAAK,EAAE,wBAAwB,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAOrG,OAAO,EAAc,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,YAAY,EAIlB,MAAM,OAAO,CAAC;AAIf;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,0CAA0C;AAC1C,UAAU,UAAU;IAClB,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B;AAyBD,kGAAkG;AAClG,wBAAsB,YAAY,CAChC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC5B,KAAK,EAAE,UAAU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AE,MAAM,EACX,GAAG,GAAE,MAAM,IAAuB,GACjC,WAAW,CAAC,OAAO,CAAC,CAuBtB"}
@@ -17,7 +17,10 @@ import { composedCapabilities, composedCapability } from "@pithy-sh/core/src/cap
17
17
  import { legalHolds } from "@pithy-sh/core/src/retention/holds";
18
18
  import { enqueueFromEnv } from "@pithy-sh/email/src/send/fromComposition";
19
19
  //#region src/purge/workflow.ts
20
- /** The lifecycle transitions' dependencies, for a run with no request: this env, and the composition's seams. */
20
+ /**
21
+ * The lifecycle transitions' dependencies, for a run with no request: this env, and the composition's seams. The
22
+ * hooks run in this env with no `waitUntil`, since a Workflow has no `ExecutionContext`.
23
+ */
21
24
  function lifecycleFor(auth, env, log) {
22
25
  const d1 = resolveDb(env, auth.authConfig.database);
23
26
  return {
@@ -26,6 +29,7 @@ function lifecycleFor(auth, env, log) {
26
29
  emit: auth.auditFor(env),
27
30
  config: auth.authConfig,
28
31
  hooks: auth.lifecycleHooks,
32
+ runtime: { env },
29
33
  enqueueEmail: (input) => enqueueFromEnv(env, input),
30
34
  log
31
35
  };
@@ -137,4 +141,4 @@ function purgeStarter(env, log, now = () => /* @__PURE__ */ new Date()) {
137
141
  };
138
142
  }
139
143
  //#endregion
140
- export { inactivityOps, inactivityRun, purgeStarter, runAuthPurge, runAuthPurgeDue };
144
+ export { inactivityOps, inactivityRun, lifecycleFor, purgeStarter, runAuthPurge, runAuthPurgeDue };
@@ -3,5 +3,5 @@
3
3
  /** This package's npm name — the join key against a release feed. */
4
4
  export declare const PACKAGE_NAME = "@pithy-sh/auth";
5
5
  /** This package's version, stamped from its own package.json at generation time. */
6
- export declare const PACKAGE_VERSION = "0.16.0";
6
+ export declare const PACKAGE_VERSION = "0.17.0";
7
7
  //# sourceMappingURL=version.generated.d.ts.map
@@ -4,6 +4,6 @@
4
4
  /** This package's npm name — the join key against a release feed. */
5
5
  const PACKAGE_NAME = "@pithy-sh/auth";
6
6
  /** This package's version, stamped from its own package.json at generation time. */
7
- const PACKAGE_VERSION = "0.16.0";
7
+ const PACKAGE_VERSION = "0.17.0";
8
8
  //#endregion
9
9
  export { PACKAGE_NAME, PACKAGE_VERSION };
@@ -93,9 +93,9 @@ POST /auth/admin/users/:userId/export { reason }
93
93
 
94
94
  The response says what happened: `outcome` is `deleted`, `brought_forward`, or `unchanged` for an account already deleted. `purge` is `scheduled` for a soft deletion, `started` when this call started the purge, and `pending` when the account is due and this Worker binds no purge Workflow to start. `notify: false` silences the mail this call sends: the deletion-scheduled notice for soft, the deletion-complete notice for hard.
95
95
 
96
- **Restore** clears both columns inside the window and records it. The person signs in again; no session comes back. A suspension the account was under before the deletion is still there, and the response says `state: "suspended"`. Once `purge_after` has passed the purge is due, so a restore is a 409 naming the date. The window is checked against the database's clock as the restore's write runs, the same clock the purge checks it against, so a restore and a purge that race always agree on which one won. A window that closes while a restore is in flight, or that a hard deletion brings forward, is the same 409. After the purge there is no account: a 404, whose action says the data is gone.
96
+ **Restore** clears both columns inside the window, records it, and fires [`onUserRestored`](#hooks). The person signs in again; no session comes back. A suspension the account was under before the deletion is still there, and the response says `state: "suspended"`. Once `purge_after` has passed the purge is due, so a restore is a 409 naming the date. The window is checked against the database's clock as the restore's write runs, the same clock the purge checks it against, so a restore and a purge that race always agree on which one won. A window that closes while a restore is in flight, or that a hard deletion brings forward, is the same 409. After the purge there is no account: a 404, whose action says the data is gone.
97
97
 
98
- **Export** answers an access request. It returns one JSON document, validated by `AdminUserExportResponse` from `@pithy-sh/auth/src/http/responses`: the subject, when it was read, and one entry per composed capability that declares a purge contribution, in the order the purge runs them. Each entry says what a purge does with its rows — `disposition` is `erase` or `retain`, and a `retain` entry carries the `basis` it is kept on, in the sentence written for the person — and then what it answered: `exported` with that capability's data, `not_exported` when it erases rows it does not say how to export, or `unavailable` when its rows would not read. Every kit capability that holds rows about a person exports them, so `not_exported` is only ever an adopter's own capability; [what each one does](#what-each-capability-does-with-a-persons-rows) is below. Auth's own part is `AuthUserExport`: the account, its sessions, linked providers, devices, history, the sign-in links and codes the verification ledger records for it, and its rows in the user-keyed tables its Better Auth plugins created, and no credential — no session token, no provider token, no push token, no two-factor secret or backup code, no key. No kit capability's part carries one either: no opt-in token, no share link, no invitation digest, no provider payload, no Google Play purchase token, no message variables. It is audited as a disclosure, `auth/admin_user_exported`, with the operator, the reason, and which parts answered, never the data. An unknown or purged account is a 404.
98
+ **Export** answers an access request. It returns one JSON document, validated by `AdminUserExportResponse` from `@pithy-sh/auth/src/http/responses`: the subject, when it was read, and one entry per composed capability that declares a purge contribution, in the order the purge runs them. Each entry says what a purge does with its rows — `disposition` is `erase` or `retain`, and a `retain` entry carries the `basis` it is kept on, in the sentence written for the person and in their stored locale where the contribution names a `basisKey` a catalog translates ([`docs/I18N.md`](../../../docs/I18N.md#a-purges-retained-basis-reads-in-the-persons-language)), with that `basisKey` beside it — and then what it answered: `exported` with that capability's data, `not_exported` when it erases rows it does not say how to export, or `unavailable` when its rows would not read. Every kit capability that holds rows about a person exports them, so `not_exported` is only ever an adopter's own capability; [what each one does](#what-each-capability-does-with-a-persons-rows) is below. Auth's own part is `AuthUserExport`: the account, its sessions, linked providers, devices, history, the sign-in links and codes the verification ledger records for it, and its rows in the user-keyed tables its Better Auth plugins created, and no credential — no session token, no provider token, no push token, no two-factor secret or backup code, no key. No kit capability's part carries one either: no opt-in token, no share link, no invitation digest, no provider payload, no Google Play purchase token, no message variables. It is audited as a disclosure, `auth/admin_user_exported`, with the operator, the reason, and which parts answered, never the data. An unknown or purged account is a 404.
99
99
 
100
100
  Every call is audited, as for suspend and reinstate: a deletion under `auth/admin_user_soft_deleted` or `auth/admin_user_hard_deleted`, a restore under `auth/admin_user_restored`, with the operator, the connection, the reason and the user id. A refusal is `denied` with its code, and a call that changed nothing is a success with `changed: false`.
101
101
 
@@ -115,7 +115,7 @@ It is always soft, on the configured window, and the subject is always the sessi
115
115
 
116
116
  ## The purge
117
117
 
118
- A purge erases one deleted account from every capability that holds rows about it. It runs as a Workflow, **one step per composed purge contribution**, named for its capability, so a capability that fails retries alone and the steps that finished are not run again. Each step records that it ran in `pithy_auth_user_lifecycle`, with the contribution's summary. A contribution that **retains** its rows is a step too, and erases nothing: it records `purge_retained`, with the basis it gave as the reason, so the history never reads a kept step as an erased one. The order:
118
+ A purge erases one deleted account from every capability that holds rows about it. It runs as a Workflow, **one step per composed purge contribution**, named for its capability, so a capability that fails retries alone and the steps that finished are not run again. Each step records that it ran in `pithy_auth_user_lifecycle`, with the contribution's summary. A contribution that **retains** its rows is a step too, and erases nothing: it records `purge_retained`, with the basis it gave as the reason and its `basisKey` in `basis_key`, so the history never reads a kept step as an erased one. The order:
119
119
 
120
120
  1. Is the account due — deleted, with its window closed? A restored account, one inside its window, and one already erased end the run here, having erased nothing. Re-running a purge for the same subject exits without error.
121
121
  2. Every composed contribution but auth's, in composition order, your `app` last. Each reads the account's address, when it needs one, inside its own step.
@@ -189,22 +189,58 @@ Four templates in `@pithy-sh/email`, all transactional, so an unsubscribe never
189
189
  ```ts
190
190
  auth({
191
191
  baseURL: "https://api.example.com",
192
- onUserSuspended: async (event, d1) => {},
193
- onUserReinstated: async (event, d1) => {},
194
- onUserDeleted: async (event, d1) => {},
195
- onUserPurged: async (event, d1) => {},
192
+ onUserSuspended: async (event, d1, runtime) => {},
193
+ onUserReinstated: async (event, d1, runtime) => {},
194
+ onUserDeleted: async (event, d1, runtime) => {},
195
+ onUserRestored: async (event, d1, runtime) => {},
196
+ onUserPurged: async (event, d1, runtime) => {},
196
197
  });
197
198
  ```
198
199
 
199
200
  Each fires once per transition. A call that finds the account already where it asked to put it fires nothing, and neither does restating a suspension. A hook that throws is logged and changes nothing: the transition is already written.
200
201
 
202
+ `onUserRestored` fires when a deleted account is restored inside its window, with the operator, the reason and `at`, the same event the other hooks get. Restoring an account that is not deleted fires nothing, and neither does a restore refused because the window closed. It is where you undo what `onUserDeleted` did:
203
+
204
+ ```ts
205
+ auth({
206
+ baseURL: "https://api.example.com",
207
+ onUserDeleted: async ({ userId, at }, d1) => {
208
+ await d1.prepare("update members set removed_at = ? where user_id = ?").bind(at.getTime(), userId).run();
209
+ },
210
+ onUserRestored: async ({ userId }, d1) => {
211
+ await d1.prepare("update members set removed_at = null where user_id = ?").bind(userId).run();
212
+ },
213
+ });
214
+ ```
215
+
216
+ Each hook is handed the event, the D1 binding, and `runtime`: `{ env, waitUntil? }`. `env` is the Worker's environment, so a hook can read a secret, start a Workflow, send to a queue, or call out. Pass your own `Env` to `auth<Env>()` and `runtime.env` is typed as it, with no cast. `onSessionRevoked` is handed the same `runtime` as its third argument.
217
+
218
+ `waitUntil` is the request's `ExecutionContext.waitUntil`. It is there when the hook fires inside a request, and absent when it fires from the purge Workflow, which has no `ExecutionContext`. `onUserPurged` always fires from the Workflow, and so does `onUserDeleted` for an account the daily inactivity pass deletes. Check for it before you call it.
219
+
220
+ Outside work belongs in a Workflow. The hook only starts it, which suits the hook's contract: it cannot fail the transition, and the Workflow retries the call.
221
+
222
+ ```ts
223
+ interface Env {
224
+ REVOKE_LINKED_ITEMS: Workflow<{ userId: string }>;
225
+ }
226
+
227
+ auth<Env>({
228
+ baseURL: "https://api.example.com",
229
+ onUserDeleted: async ({ userId }, _d1, { env }) => {
230
+ await env.REVOKE_LINKED_ITEMS.create({ params: { userId } });
231
+ },
232
+ });
233
+ ```
234
+
235
+ A hook written as `(event, d1)` still compiles and runs unchanged.
236
+
201
237
  ## Screens
202
238
 
203
239
  Three screens ship with auth and are yours after `pithy ui add react`, or in React Native primitives after `pithy ui add react-native`: account suspended, account deleted, and organization suspended. Each says what happened, what it means, and who to ask, in its own English. None renders a reason or a date from its URL, because anybody can write a URL. The details are in the mail.
204
240
 
205
241
  ## What each capability does with a person's rows
206
242
 
207
- Every kit capability that holds rows about a person declares a `user` contribution, and every one exports what it holds. Most erase. Four keep their rows, because the law or the record needs them, and say why.
243
+ Every kit capability that holds rows about a person declares a `user` contribution, and every one exports what it holds. Most erase. Five keep their rows, because the law or the record needs them, and say why — each basis under its own `<capability>/purge.retained` key, in English and Spanish, so the export reads it in the person's language.
208
244
 
209
245
  | Capability | Disposition | What |
210
246
  |---|---|---|
@@ -253,13 +289,13 @@ defineCapability({ name: "app", requiredBindings: [], purge: [purge] });
253
289
 
254
290
  The purge runs every composed contribution as its own step, named for its capability, so a failure retries that capability alone. That is why there is at most one per subject per capability, and why `erase` must succeed when the rows are already gone: a step is retried after a failure that may have come once they were. Any fault in `erase` is retried with the platform's backoff, because the contract makes it safe to. `export` is optional; without one, the export lists the capability as `not_exported`. A throw from it costs its own entry, never the document. The kit knows two subjects, `user` and `organization` — the second for rows scoped to a tenant, which `@pithy-sh/organization`'s purge runs ([`organization-lifecycle.md`](../../organization/docs/organization-lifecycle.md#the-purge)) — and `defineCapability` refuses a contribution for any other. Declare one on your own `app` capability for your own tables.
255
291
 
256
- **Or keep the rows, and say why.** Not every row about a person should go: a payment record is commonly kept for tax law, a suppression has to outlive the person or the unsubscribe stops holding, and an audit trail is the record of who acted. A contribution with `retain` is the third disposition beside erase and anonymize. It takes a basis, one sentence written for the person, and an `export`, which it may not leave out — rows that are kept are rows an access request is answered with — and no `erase`. `defineCapability` refuses one without a basis, without an export, or with an erase as well. The purge records the step as `purge_retained` and erases nothing; the export carries the rows, `disposition: "retain"` and the basis.
292
+ **Or keep the rows, and say why.** Not every row about a person should go: a payment record is commonly kept for tax law, a suppression has to outlive the person or the unsubscribe stops holding, and an audit trail is the record of who acted. A contribution with `retain` is the third disposition beside erase and anonymize. It takes a basis, one sentence written for the person, optionally the `basisKey` that translates it, and an `export`, which it may not leave out — rows that are kept are rows an access request is answered with — and no `erase`. `defineCapability` refuses one without a basis, with a `basisKey` outside its own domain, without an export, or with an erase as well. The purge records the step as `purge_retained`, with the basis and its key, and erases nothing; the export carries the rows, `disposition: "retain"`, the basis read in the person's locale, and the key. The basis stays required: it is the English every reader gets when nothing translates the key.
257
293
 
258
294
  ```ts
259
295
  const kept: PurgeContribution = {
260
296
  subject: "user",
261
297
  summary: "Keeps the user's invoices.",
262
- retain: { basis: "Kept for tax records." },
298
+ retain: { basis: "Kept for tax records.", basisKey: "app/purge.invoices_kept" },
263
299
  export: async ({ subject, env }) => ({ invoices: [] }),
264
300
  };
265
301
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pithy-sh/auth",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,10 +46,10 @@
46
46
  "better-auth": "^1.7.11"
47
47
  },
48
48
  "peerDependencies": {
49
- "@pithy-sh/core": "^0.24.0",
50
- "@pithy-sh/email": "^0.10.7",
51
- "@pithy-sh/secrets": "^0.6.12",
52
- "@pithy-sh/turnstile": "^0.9.0",
49
+ "@pithy-sh/core": "^0.25.0",
50
+ "@pithy-sh/email": "^0.11.0",
51
+ "@pithy-sh/secrets": "^0.6.13",
52
+ "@pithy-sh/turnstile": "^0.9.1",
53
53
  "hono": "^4.13.2",
54
54
  "kysely": "^0.29.0",
55
55
  "zod": "^4.4.0"