@pithy-sh/auth 0.10.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -2
- package/dist/admin/users.js +1 -1
- package/dist/audit/actions.d.ts +58 -0
- package/dist/audit/actions.d.ts.map +1 -1
- package/dist/audit/actions.js +59 -1
- package/dist/audit/emit.d.ts +36 -0
- package/dist/audit/emit.d.ts.map +1 -1
- package/dist/audit/emit.js +48 -2
- package/dist/audit/evidence.d.ts +8 -2
- package/dist/audit/evidence.d.ts.map +1 -1
- package/dist/capability.d.ts +47 -8
- package/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +56 -6
- package/dist/client/api.d.ts +55 -12
- package/dist/client/api.d.ts.map +1 -1
- package/dist/client/api.js +57 -18
- package/dist/client/bearer.d.ts +110 -0
- package/dist/client/bearer.d.ts.map +1 -0
- package/dist/client/bearer.js +265 -0
- package/dist/client/handoff.d.ts +77 -0
- package/dist/client/handoff.d.ts.map +1 -0
- package/dist/client/handoff.js +119 -0
- package/dist/client/mcp.d.ts +70 -0
- package/dist/client/mcp.d.ts.map +1 -0
- package/dist/client/mcp.js +65 -0
- package/dist/data/betterAuth.d.ts +3 -2
- package/dist/data/betterAuth.d.ts.map +1 -1
- package/dist/data/betterAuth.js +5 -3
- package/dist/data/kitFields.d.ts +5 -0
- package/dist/data/kitFields.d.ts.map +1 -1
- package/dist/data/kitFields.js +5 -0
- package/dist/data/tables.d.ts +26 -4
- package/dist/data/tables.d.ts.map +1 -1
- package/dist/data/tables.js +5 -3
- package/dist/data/userLifecycle.d.ts +10 -0
- package/dist/data/userLifecycle.d.ts.map +1 -1
- package/dist/data/userLifecycle.js +8 -3
- package/dist/data/verificationOutcome.d.ts +53 -0
- package/dist/data/verificationOutcome.d.ts.map +1 -0
- package/dist/data/verificationOutcome.js +50 -0
- package/dist/email/send.js +6 -2
- package/dist/http/adminRoutes.d.ts.map +1 -1
- package/dist/http/adminRoutes.js +319 -8
- package/dist/http/csrf.d.ts.map +1 -1
- package/dist/http/csrf.js +2 -1
- package/dist/http/guards.d.ts +15 -10
- package/dist/http/guards.d.ts.map +1 -1
- package/dist/http/guards.js +76 -10
- package/dist/http/handoff.d.ts +76 -0
- package/dist/http/handoff.d.ts.map +1 -0
- package/dist/http/handoff.js +316 -0
- package/dist/http/middleware.d.ts +37 -1
- package/dist/http/middleware.d.ts.map +1 -1
- package/dist/http/middleware.js +68 -6
- package/dist/http/resolve.d.ts.map +1 -1
- package/dist/http/resolve.js +9 -3
- package/dist/http/responses.d.ts +322 -0
- package/dist/http/responses.d.ts.map +1 -1
- package/dist/http/responses.js +202 -5
- package/dist/http/routes.d.ts +3 -0
- package/dist/http/routes.d.ts.map +1 -1
- package/dist/http/routes.js +78 -5
- package/dist/http/schemas.d.ts +114 -0
- package/dist/http/schemas.d.ts.map +1 -1
- package/dist/http/schemas.js +94 -1
- package/dist/http/views.d.ts +60 -3
- package/dist/http/views.d.ts.map +1 -1
- package/dist/http/views.js +143 -3
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -2
- package/dist/instance/auth.d.ts +148 -10
- package/dist/instance/auth.d.ts.map +1 -1
- package/dist/instance/auth.js +87 -42
- package/dist/instance/plugins.d.ts +6 -0
- package/dist/instance/plugins.d.ts.map +1 -1
- package/dist/instance/plugins.js +14 -1
- package/dist/ledger/read.d.ts +53 -0
- package/dist/ledger/read.d.ts.map +1 -0
- package/dist/ledger/read.js +85 -0
- package/dist/ledger/record.d.ts +35 -0
- package/dist/ledger/record.d.ts.map +1 -0
- package/dist/ledger/record.js +98 -0
- package/dist/lifecycle/audited.d.ts +48 -0
- package/dist/lifecycle/audited.d.ts.map +1 -0
- package/dist/lifecycle/audited.js +65 -0
- package/dist/lifecycle/enforce.d.ts +37 -2
- package/dist/lifecycle/enforce.d.ts.map +1 -1
- package/dist/lifecycle/enforce.js +46 -5
- package/dist/lifecycle/erasure.d.ts +9 -0
- package/dist/lifecycle/erasure.d.ts.map +1 -0
- package/dist/lifecycle/erasure.js +96 -0
- package/dist/lifecycle/inactivity.d.ts +19 -0
- package/dist/lifecycle/inactivity.d.ts.map +1 -0
- package/dist/lifecycle/inactivity.js +28 -0
- package/dist/lifecycle/reason.d.ts +11 -0
- package/dist/lifecycle/reason.d.ts.map +1 -0
- package/dist/lifecycle/reason.js +13 -0
- package/dist/lifecycle/request.d.ts +5 -2
- package/dist/lifecycle/request.d.ts.map +1 -1
- package/dist/lifecycle/request.js +6 -2
- package/dist/lifecycle/transitions.d.ts +179 -18
- package/dist/lifecycle/transitions.d.ts.map +1 -1
- package/dist/lifecycle/transitions.js +391 -70
- package/dist/mcp/argumentClass.d.ts +51 -0
- package/dist/mcp/argumentClass.d.ts.map +1 -0
- package/dist/mcp/argumentClass.js +69 -0
- package/dist/mcp/capability.d.ts +50 -0
- package/dist/mcp/capability.d.ts.map +1 -0
- package/dist/mcp/capability.js +140 -0
- package/dist/mcp/clientMetadata.d.ts +40 -0
- package/dist/mcp/clientMetadata.d.ts.map +1 -0
- package/dist/mcp/clientMetadata.js +68 -0
- package/dist/mcp/consent.d.ts +49 -0
- package/dist/mcp/consent.d.ts.map +1 -0
- package/dist/mcp/consent.js +69 -0
- package/dist/mcp/dispatch.d.ts +35 -0
- package/dist/mcp/dispatch.d.ts.map +1 -0
- package/dist/mcp/dispatch.js +135 -0
- package/dist/mcp/floor.d.ts +37 -0
- package/dist/mcp/floor.d.ts.map +1 -0
- package/dist/mcp/floor.js +41 -0
- package/dist/mcp/host.d.ts +34 -0
- package/dist/mcp/host.d.ts.map +1 -0
- package/dist/mcp/host.js +2 -0
- package/dist/mcp/http/redirectList.d.ts +9 -0
- package/dist/mcp/http/redirectList.d.ts.map +1 -0
- package/dist/mcp/http/redirectList.js +24 -0
- package/dist/mcp/http/responses.d.ts +143 -0
- package/dist/mcp/http/responses.d.ts.map +1 -0
- package/dist/mcp/http/responses.js +83 -0
- package/dist/mcp/http/routes.d.ts +28 -0
- package/dist/mcp/http/routes.d.ts.map +1 -0
- package/dist/mcp/http/routes.js +517 -0
- package/dist/mcp/http/schemas.d.ts +24 -0
- package/dist/mcp/http/schemas.d.ts.map +1 -0
- package/dist/mcp/http/schemas.js +18 -0
- package/dist/mcp/marker.d.ts +15 -0
- package/dist/mcp/marker.d.ts.map +1 -0
- package/dist/mcp/marker.js +15 -0
- package/dist/mcp/provider.d.ts +78 -0
- package/dist/mcp/provider.d.ts.map +1 -0
- package/dist/mcp/provider.js +108 -0
- package/dist/mcp/purge.d.ts +15 -0
- package/dist/mcp/purge.d.ts.map +1 -0
- package/dist/mcp/purge.js +31 -0
- package/dist/mcp/rpc.d.ts +79 -0
- package/dist/mcp/rpc.d.ts.map +1 -0
- package/dist/mcp/rpc.js +103 -0
- package/dist/mcp/toolAudit.d.ts +76 -0
- package/dist/mcp/toolAudit.d.ts.map +1 -0
- package/dist/mcp/toolAudit.js +86 -0
- package/dist/migrations/0005_purge_once.d.ts +22 -0
- package/dist/migrations/0005_purge_once.d.ts.map +1 -0
- package/dist/migrations/0005_purge_once.js +35 -0
- package/dist/migrations/0006_verification_outcomes.d.ts +15 -0
- package/dist/migrations/0006_verification_outcomes.d.ts.map +1 -0
- package/dist/migrations/0006_verification_outcomes.js +35 -0
- package/dist/migrations/0007_erasure_record.d.ts +17 -0
- package/dist/migrations/0007_erasure_record.d.ts.map +1 -0
- package/dist/migrations/0007_erasure_record.js +36 -0
- package/dist/migrations/0008_last_active.d.ts +15 -0
- package/dist/migrations/0008_last_active.d.ts.map +1 -0
- package/dist/migrations/0008_last_active.js +29 -0
- package/dist/migrations/pluginTables.d.ts +8 -0
- package/dist/migrations/pluginTables.d.ts.map +1 -1
- package/dist/migrations/pluginTables.js +8 -1
- package/dist/migrations/set.d.ts +5 -1
- package/dist/migrations/set.d.ts.map +1 -1
- package/dist/migrations/set.js +10 -2
- package/dist/peer.d.ts +3 -2
- package/dist/peer.d.ts.map +1 -1
- package/dist/processing/activities.d.ts +6 -0
- package/dist/processing/activities.d.ts.map +1 -0
- package/dist/processing/activities.js +12 -0
- package/dist/purge/contribution.d.ts +62 -0
- package/dist/purge/contribution.d.ts.map +1 -0
- package/dist/purge/contribution.js +155 -0
- package/dist/purge/retryPolicy.d.ts +22 -0
- package/dist/purge/retryPolicy.d.ts.map +1 -0
- package/dist/purge/retryPolicy.js +26 -0
- package/dist/purge/run.d.ts +158 -0
- package/dist/purge/run.d.ts.map +1 -0
- package/dist/purge/run.js +205 -0
- package/dist/purge/specs.d.ts +71 -0
- package/dist/purge/specs.d.ts.map +1 -0
- package/dist/purge/specs.js +72 -0
- package/dist/purge/start.d.ts +42 -0
- package/dist/purge/start.d.ts.map +1 -0
- package/dist/purge/start.js +37 -0
- package/dist/purge/workflow.d.ts +71 -0
- package/dist/purge/workflow.d.ts.map +1 -0
- package/dist/purge/workflow.js +140 -0
- package/dist/test-utils/accountFootprint.d.ts +13 -0
- package/dist/test-utils/accountFootprint.d.ts.map +1 -0
- package/dist/test-utils/accountFootprint.js +49 -0
- package/dist/test-utils/liveApp.d.ts +6 -0
- package/dist/test-utils/liveApp.d.ts.map +1 -1
- package/dist/test-utils/liveApp.js +7 -2
- package/dist/token/handoff.d.ts +80 -0
- package/dist/token/handoff.d.ts.map +1 -0
- package/dist/token/handoff.js +136 -0
- package/dist/version.generated.d.ts +1 -1
- package/dist/version.generated.js +1 -1
- package/docs/account-lifecycle.md +176 -12
- package/docs/apple-signin.md +32 -4
- package/docs/facebook-oauth.md +2 -2
- package/docs/github-oauth.md +2 -2
- package/docs/google-oauth.md +9 -7
- package/docs/microsoft-oauth.md +2 -2
- package/package.json +11 -5
- package/pithy.manifest.json +2 -2
- package/pithy.mcp.manifest.json +36 -0
- package/src/audit/actions.ts +58 -0
- package/src/audit/emit.ts +66 -1
- package/src/audit/evidence.ts +8 -4
- package/src/capability.ts +122 -18
- package/src/client/api.ts +69 -19
- package/src/client/bearer.ts +388 -0
- package/src/client/handoff.ts +172 -0
- package/src/client/mcp.ts +140 -0
- package/src/data/betterAuth.ts +8 -4
- package/src/data/kitFields.ts +2 -0
- package/src/data/tables.ts +4 -2
- package/src/data/userLifecycle.ts +19 -4
- package/src/data/verificationOutcome.ts +86 -0
- package/src/email/send.ts +2 -2
- package/src/http/adminRoutes.ts +465 -4
- package/src/http/csrf.ts +4 -1
- package/src/http/guards.ts +79 -10
- package/src/http/handoff.ts +350 -0
- package/src/http/middleware.ts +74 -5
- package/src/http/resolve.ts +25 -25
- package/src/http/responses.ts +374 -3
- package/src/http/routes.ts +116 -5
- package/src/http/schemas.ts +195 -0
- package/src/http/views.ts +192 -3
- package/src/index.ts +2 -0
- package/src/instance/auth.ts +58 -3
- package/src/instance/plugins.ts +20 -2
- package/src/ledger/read.ts +133 -0
- package/src/ledger/record.ts +198 -0
- package/src/lifecycle/audited.ts +104 -0
- package/src/lifecycle/enforce.ts +55 -5
- package/src/lifecycle/erasure.ts +118 -0
- package/src/lifecycle/inactivity.ts +56 -0
- package/src/lifecycle/reason.ts +11 -0
- package/src/lifecycle/request.ts +10 -2
- package/src/lifecycle/transitions.ts +552 -93
- package/src/mcp/argumentClass.ts +112 -0
- package/src/mcp/capability.ts +194 -0
- package/src/mcp/clientMetadata.ts +81 -0
- package/src/mcp/consent.ts +95 -0
- package/src/mcp/dispatch.ts +154 -0
- package/src/mcp/floor.ts +62 -0
- package/src/mcp/host.ts +36 -0
- package/src/mcp/http/redirectList.ts +26 -0
- package/src/mcp/http/responses.ts +157 -0
- package/src/mcp/http/routes.ts +635 -0
- package/src/mcp/http/schemas.ts +37 -0
- package/src/mcp/marker.ts +18 -0
- package/src/mcp/provider.ts +151 -0
- package/src/mcp/purge.ts +39 -0
- package/src/mcp/rpc.ts +135 -0
- package/src/mcp/toolAudit.ts +132 -0
- package/src/migrations/0005_purge_once.ts +42 -0
- package/src/migrations/0006_verification_outcomes.ts +51 -0
- package/src/migrations/0007_erasure_record.ts +43 -0
- package/src/migrations/0008_last_active.ts +30 -0
- package/src/migrations/pluginTables.ts +19 -1
- package/src/migrations/set.ts +9 -1
- package/src/processing/activities.ts +14 -0
- package/src/purge/contribution.ts +218 -0
- package/src/purge/retryPolicy.ts +26 -0
- package/src/purge/run.ts +348 -0
- package/src/purge/specs.ts +95 -0
- package/src/purge/start.ts +79 -0
- package/src/purge/workflow.ts +202 -0
- package/src/seeds/example.ts +2 -2
- package/src/test-utils/accountFootprint.ts +104 -0
- package/src/test-utils/liveApp.ts +10 -1
- package/src/token/handoff.ts +180 -0
- package/src/version.generated.ts +1 -1
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
import { AuthAuditActions } from "../audit/actions.js";
|
|
4
|
+
import { UserLifecycleEvent } from "../data/userLifecycle.js";
|
|
5
|
+
import { authDatabase } from "../data/tables.js";
|
|
6
|
+
import { resolveDb } from "../http/resolve.js";
|
|
7
|
+
import { SQLiteDate } from "@pithy-sh/core/src/data/codecs";
|
|
8
|
+
//#region src/lifecycle/erasure.ts
|
|
9
|
+
/**
|
|
10
|
+
* **A user's erasure record, read back for the control plane's attestation (#823).**
|
|
11
|
+
*
|
|
12
|
+
* `pithy_auth_user_lifecycle` is the one `pithy_auth_*` table a purge leaves behind, and it names the account by id
|
|
13
|
+
* and nothing else. This reads the rows an erasure is made of — the deletion, any restore, each step, a failure, the
|
|
14
|
+
* end — and hands them to core through the {@link ErasureRecords} seam, so the control plane never imports auth.
|
|
15
|
+
*/
|
|
16
|
+
/** The rows an erasure is made of. A suspension is not one. */
|
|
17
|
+
const ERASURE_ACTIONS = [
|
|
18
|
+
"deleted",
|
|
19
|
+
"restored",
|
|
20
|
+
"purge_step",
|
|
21
|
+
"purge_retained",
|
|
22
|
+
"purge_failed",
|
|
23
|
+
"purged"
|
|
24
|
+
];
|
|
25
|
+
/** The rows that are the purge itself, rather than the deletion it runs under. */
|
|
26
|
+
const PURGE_ACTIONS = [
|
|
27
|
+
"purge_step",
|
|
28
|
+
"purge_retained",
|
|
29
|
+
"purge_failed",
|
|
30
|
+
"purged"
|
|
31
|
+
];
|
|
32
|
+
/** The rows that end a deletion: its purge finishing, or the subject coming back. */
|
|
33
|
+
const CLOSING_ACTIONS = ["purged", "restored"];
|
|
34
|
+
/** The reader, over one auth database. */
|
|
35
|
+
function userErasureReader(db) {
|
|
36
|
+
return {
|
|
37
|
+
history: async (userIds) => {
|
|
38
|
+
if (userIds.length === 0) return [];
|
|
39
|
+
return (await db.selectFrom("pithyAuthUserLifecycle").selectAll().where("userId", "in", [...userIds]).where("action", "in", [...ERASURE_ACTIONS]).orderBy("id", "asc").execute()).map((raw) => {
|
|
40
|
+
const row = UserLifecycleEvent.parse(raw);
|
|
41
|
+
return {
|
|
42
|
+
subjectId: row.userId,
|
|
43
|
+
action: row.action,
|
|
44
|
+
actorType: row.actorType,
|
|
45
|
+
reason: row.reason,
|
|
46
|
+
step: row.step,
|
|
47
|
+
mode: row.mode,
|
|
48
|
+
purgeAfter: row.purgeAfter,
|
|
49
|
+
at: row.createdAt
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
subjectsIn: async (since, until) => {
|
|
54
|
+
const from = SQLiteDate.encode(since);
|
|
55
|
+
const to = SQLiteDate.encode(until);
|
|
56
|
+
return (await db.selectFrom("pithyAuthUserLifecycle as row").select("row.userId").distinct().where((eb) => eb.or([
|
|
57
|
+
eb.and([
|
|
58
|
+
eb("row.action", "in", [...PURGE_ACTIONS]),
|
|
59
|
+
eb("row.createdAt", ">=", from),
|
|
60
|
+
eb("row.createdAt", "<=", to)
|
|
61
|
+
]),
|
|
62
|
+
eb.and([
|
|
63
|
+
eb("row.action", "=", "deleted"),
|
|
64
|
+
eb("row.purgeAfter", ">=", from),
|
|
65
|
+
eb("row.purgeAfter", "<=", to)
|
|
66
|
+
]),
|
|
67
|
+
eb.and([
|
|
68
|
+
eb("row.action", "=", "deleted"),
|
|
69
|
+
eb("row.createdAt", "<=", to),
|
|
70
|
+
eb.or([eb("row.purgeAfter", "<=", to), eb("row.purgeAfter", "is", null)]),
|
|
71
|
+
eb.not(eb.exists(eb.selectFrom("pithyAuthUserLifecycle as closed").select("closed.id").whereRef("closed.userId", "=", "row.userId").whereRef("closed.id", ">", "row.id").where("closed.action", "in", [...CLOSING_ACTIONS]).where("closed.createdAt", "<", from)))
|
|
72
|
+
])
|
|
73
|
+
])).orderBy("row.userId").execute()).map((row) => row.userId);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/** What auth declares: the `user` subject, the actions its purge records, and the reader over its database. */
|
|
78
|
+
function authErasureRecords(database) {
|
|
79
|
+
return {
|
|
80
|
+
subject: "user",
|
|
81
|
+
resourceType: "user",
|
|
82
|
+
auditActions: {
|
|
83
|
+
deleted: [
|
|
84
|
+
AuthAuditActions.adminUserSoftDeleted,
|
|
85
|
+
AuthAuditActions.adminUserHardDeleted,
|
|
86
|
+
AuthAuditActions.userSelfDeleted
|
|
87
|
+
],
|
|
88
|
+
step: AuthAuditActions.adminUserPurgeStep,
|
|
89
|
+
failed: AuthAuditActions.adminUserPurgeFailed,
|
|
90
|
+
purged: AuthAuditActions.adminUserPurged
|
|
91
|
+
},
|
|
92
|
+
read: (env) => userErasureReader(authDatabase(resolveDb(env, database)))
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
//#endregion
|
|
96
|
+
export { authErasureRecords, userErasureReader };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
import type { AuthDatabase } from "../data/tables";
|
|
4
|
+
/**
|
|
5
|
+
* **Inactivity, as the retention policy's class ages count it.**
|
|
6
|
+
*
|
|
7
|
+
* An account is active when it opens a session: a sign-in, or a token refresh. Each one stamps `lastActiveAt` on the
|
|
8
|
+
* account, and a live session refreshed since counts too. An account untouched for longer than the strictest class
|
|
9
|
+
* age it holds is soft-deleted through the lifecycle — `../purge/run.ts` runs the pass — with the same notice mail,
|
|
10
|
+
* the same window and the same purge as any other deletion.
|
|
11
|
+
*/
|
|
12
|
+
/** Stamp an account active now. Moves the clock forward only, so a late write never makes it look older. */
|
|
13
|
+
export declare function recordActivity(db: AuthDatabase, userId: string, at: Date): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* The accounts inactive since `cutoff`, oldest first, at most `limit`: not deleted, last active before it (or, never
|
|
16
|
+
* stamped, created before it), and holding no session refreshed since.
|
|
17
|
+
*/
|
|
18
|
+
export declare function inactiveAccounts(db: AuthDatabase, cutoff: Date, limit: number): Promise<string[]>;
|
|
19
|
+
//# sourceMappingURL=inactivity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inactivity.d.ts","sourceRoot":"","sources":["../../src/lifecycle/inactivity.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEnD;;;;;;;GAOG;AAEH,4GAA4G;AAC5G,wBAAsB,cAAc,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAQ9F;AAED;;;GAGG;AACH,wBAAsB,gBAAgB,CAAC,EAAE,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAyBvG"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
import { SQLiteDate } from "@pithy-sh/core/src/data/codecs";
|
|
4
|
+
//#region src/lifecycle/inactivity.ts
|
|
5
|
+
/**
|
|
6
|
+
* **Inactivity, as the retention policy's class ages count it.**
|
|
7
|
+
*
|
|
8
|
+
* An account is active when it opens a session: a sign-in, or a token refresh. Each one stamps `lastActiveAt` on the
|
|
9
|
+
* account, and a live session refreshed since counts too. An account untouched for longer than the strictest class
|
|
10
|
+
* age it holds is soft-deleted through the lifecycle — `../purge/run.ts` runs the pass — with the same notice mail,
|
|
11
|
+
* the same window and the same purge as any other deletion.
|
|
12
|
+
*/
|
|
13
|
+
/** Stamp an account active now. Moves the clock forward only, so a late write never makes it look older. */
|
|
14
|
+
async function recordActivity(db, userId, at) {
|
|
15
|
+
const ms = SQLiteDate.encode(at);
|
|
16
|
+
await db.updateTable("pithyAuthUsers").set({ lastActiveAt: ms }).where("id", "=", userId).where((eb) => eb.or([eb("lastActiveAt", "is", null), eb("lastActiveAt", "<", ms)])).execute();
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The accounts inactive since `cutoff`, oldest first, at most `limit`: not deleted, last active before it (or, never
|
|
20
|
+
* stamped, created before it), and holding no session refreshed since.
|
|
21
|
+
*/
|
|
22
|
+
async function inactiveAccounts(db, cutoff, limit) {
|
|
23
|
+
const ms = SQLiteDate.encode(cutoff);
|
|
24
|
+
const iso = cutoff.toISOString();
|
|
25
|
+
return (await db.selectFrom("pithyAuthUsers").select("id").where("deletedAt", "is", null).where((eb) => eb.or([eb("lastActiveAt", "<", ms), eb.and([eb("lastActiveAt", "is", null), eb("createdAt", "<", iso)])])).where(({ not, exists, selectFrom }) => not(exists(selectFrom("pithyAuthSessions").select("pithyAuthSessions.id").whereRef("pithyAuthSessions.userId", "=", "pithyAuthUsers.id").where("pithyAuthSessions.updatedAt", ">=", iso)))).orderBy("lastActiveAt", "asc").orderBy("id", "asc").limit(limit).execute()).map((row) => row.id);
|
|
26
|
+
}
|
|
27
|
+
//#endregion
|
|
28
|
+
export { inactiveAccounts, recordActivity };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
/**
|
|
4
|
+
* The longest reason the kit stores. It is shown to the person, so it is a sentence, not a case file.
|
|
5
|
+
*
|
|
6
|
+
* A leaf with no imports, because two programs read it: the transitions, which refuse a longer one, and the
|
|
7
|
+
* request schemas in `../http/schemas.ts`, which a browser program compiles (`tooling/browser-scopes`). Kept
|
|
8
|
+
* in `./transitions.ts`, it pulled the email capability and the Workers types into that program (#621).
|
|
9
|
+
*/
|
|
10
|
+
export declare const MAX_REASON = 500;
|
|
11
|
+
//# sourceMappingURL=reason.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reason.d.ts","sourceRoot":"","sources":["../../src/lifecycle/reason.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,eAAO,MAAM,UAAU,MAAM,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
//#region src/lifecycle/reason.ts
|
|
4
|
+
/**
|
|
5
|
+
* The longest reason the kit stores. It is shown to the person, so it is a sentence, not a case file.
|
|
6
|
+
*
|
|
7
|
+
* A leaf with no imports, because two programs read it: the transitions, which refuse a longer one, and the
|
|
8
|
+
* request schemas in `../http/schemas.ts`, which a browser program compiles (`tooling/browser-scopes`). Kept
|
|
9
|
+
* in `./transitions.ts`, it pulled the email capability and the Workers types into that program (#621).
|
|
10
|
+
*/
|
|
11
|
+
const MAX_REASON = 500;
|
|
12
|
+
//#endregion
|
|
13
|
+
export { MAX_REASON };
|
|
@@ -3,13 +3,16 @@
|
|
|
3
3
|
import type { PithyHonoEnv } from "@pithy-sh/core/src/capability/capability";
|
|
4
4
|
import type { Context } from "hono";
|
|
5
5
|
import type { AuthWiring } from "../capability";
|
|
6
|
-
import type { LifecycleDeps } from "./transitions";
|
|
6
|
+
import type { LifecycleAuditContext, LifecycleDeps } from "./transitions";
|
|
7
7
|
/**
|
|
8
8
|
* The transitions' dependencies, resolved from one request — what a lifecycle route hands `./transitions.ts`.
|
|
9
9
|
*
|
|
10
10
|
* One function so every route resolves them the same way: this request's database, its audit seam and logger,
|
|
11
11
|
* the composed email capability's enqueue bound to this request's env, and the adopter's hooks as `auth()` was
|
|
12
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.
|
|
13
16
|
*/
|
|
14
|
-
export declare function lifecycleDeps(c: Context<PithyHonoEnv>, wiring: AuthWiring): LifecycleDeps;
|
|
17
|
+
export declare function lifecycleDeps(c: Context<PithyHonoEnv>, wiring: AuthWiring, context?: LifecycleAuditContext): LifecycleDeps;
|
|
15
18
|
//# sourceMappingURL=request.d.ts.map
|
|
@@ -1 +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,aAAa,EAAE,MAAM,eAAe,CAAC;
|
|
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"}
|
|
@@ -9,8 +9,11 @@ import { resolveDb } from "../http/resolve.js";
|
|
|
9
9
|
* One function so every route resolves them the same way: this request's database, its audit seam and logger,
|
|
10
10
|
* the composed email capability's enqueue bound to this request's env, and the adopter's hooks as `auth()` was
|
|
11
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.
|
|
12
15
|
*/
|
|
13
|
-
function lifecycleDeps(c, wiring) {
|
|
16
|
+
function lifecycleDeps(c, wiring, context) {
|
|
14
17
|
const d1 = resolveDb(c.env, wiring.config.database);
|
|
15
18
|
const enqueue = wiring.enqueueEmail;
|
|
16
19
|
return {
|
|
@@ -20,7 +23,8 @@ function lifecycleDeps(c, wiring) {
|
|
|
20
23
|
config: wiring.config,
|
|
21
24
|
hooks: wiring.lifecycleHooks ?? {},
|
|
22
25
|
enqueueEmail: enqueue ? (input) => enqueue(c.env, input) : void 0,
|
|
23
|
-
log: c.var.log?.child("auth")
|
|
26
|
+
log: c.var.log?.child("auth"),
|
|
27
|
+
...context ? { context } : {}
|
|
24
28
|
};
|
|
25
29
|
}
|
|
26
30
|
//#endregion
|
|
@@ -58,24 +58,67 @@ export interface LifecycleDeps {
|
|
|
58
58
|
readonly log?: Logger | undefined;
|
|
59
59
|
/** The clock. Defaults to the system's. */
|
|
60
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;
|
|
61
77
|
}
|
|
62
78
|
/** What a transition did. */
|
|
63
79
|
export interface LifecycleTransition {
|
|
64
80
|
/** Whether the account moved. `false` when it was already where the call asked to put it. */
|
|
65
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;
|
|
66
96
|
}
|
|
67
97
|
/**
|
|
68
98
|
* Suspend an account, until `until` or until it is reinstated.
|
|
69
99
|
*
|
|
70
100
|
* A deleted account cannot be suspended — deletion already shuts it, and outranks a suspension — so that is a
|
|
71
|
-
* conflict rather than a no-op
|
|
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.
|
|
72
113
|
*/
|
|
73
114
|
export declare function suspendUser(deps: LifecycleDeps, input: {
|
|
74
115
|
userId: string;
|
|
75
116
|
actor: LifecycleActor;
|
|
76
117
|
reason: string | null;
|
|
77
118
|
until?: Date | null;
|
|
78
|
-
|
|
119
|
+
notify?: boolean;
|
|
120
|
+
restoreRoute?: string;
|
|
121
|
+
}): Promise<SuspendTransition>;
|
|
79
122
|
/**
|
|
80
123
|
* Lift a suspension. An account that is not suspended — including one whose suspension ran out — is a no-op.
|
|
81
124
|
*
|
|
@@ -83,50 +126,168 @@ export declare function suspendUser(deps: LifecycleDeps, input: {
|
|
|
83
126
|
* past its end leaves `suspendedAt` set and is not a suspension. A deleted account is a conflict, as it is
|
|
84
127
|
* for `suspendUser`: deletion outranks the suspension it keeps, so lifting that suspension would mail "you can
|
|
85
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`.
|
|
86
131
|
*/
|
|
87
132
|
export declare function reinstateUser(deps: LifecycleDeps, input: {
|
|
88
133
|
userId: string;
|
|
89
134
|
actor: LifecycleActor;
|
|
90
135
|
reason: string | null;
|
|
136
|
+
notify?: boolean;
|
|
137
|
+
restoreRoute?: string;
|
|
91
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";
|
|
92
141
|
/**
|
|
93
|
-
*
|
|
94
|
-
*
|
|
142
|
+
* How many days a soft deletion stays restorable: the Worker's `retention.purgeWindows.user` when its block
|
|
143
|
+
* names one, else `retention.purgeAfterDays` from this capability's own config.
|
|
144
|
+
*/
|
|
145
|
+
export declare function userPurgeWindowDays(config: Pick<LifecycleDeps["config"], "retention">): number;
|
|
146
|
+
/** What a deletion did, and the deletion it left in force. */
|
|
147
|
+
export interface DeleteTransition extends LifecycleTransition {
|
|
148
|
+
/**
|
|
149
|
+
* `deleted` when this call deleted an account in good standing; `brought_forward` when the account was
|
|
150
|
+
* already deleted and a hard deletion moved its purge to now; `unchanged` when it was already deleted and
|
|
151
|
+
* this call had nothing to move.
|
|
152
|
+
*/
|
|
153
|
+
readonly outcome: "deleted" | "brought_forward" | "unchanged";
|
|
154
|
+
/** When the account was deleted. A deletion brought forward keeps its original start. */
|
|
155
|
+
readonly deletedAt: Date;
|
|
156
|
+
/** When the purge may erase it — now, for a hard deletion. Restorable until then. */
|
|
157
|
+
readonly purgeAfter: Date;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Delete an account. Audited as the account's own deletion when its holder is the actor.
|
|
161
|
+
*
|
|
162
|
+
* **Soft, the default**: it is shut now, and its data is erased once `retention.purgeAfterDays` have passed.
|
|
163
|
+
* Restorable until then. The deletion-scheduled mail carries the purge date and, when the config names one,
|
|
164
|
+
* the restore path. A deleted account deleted softly again is no transition.
|
|
165
|
+
*
|
|
166
|
+
* **Hard** (#622): `purgeAfter` is now, so the window is already closed — nothing can restore it — and the
|
|
167
|
+
* caller starts the purge. No deletion-scheduled mail, because nothing is scheduled; the purge sends the
|
|
168
|
+
* deletion-complete one. An account already deleted softly has its purge brought forward to now, which is
|
|
169
|
+
* written and audited but fires no hook: the account was deleted and still is. One already due is unchanged.
|
|
95
170
|
*
|
|
96
171
|
* A suspension the account was under is left in place, so restoring the account does not lift it.
|
|
172
|
+
* `notify: false` sends no mail, whatever the config says.
|
|
97
173
|
*/
|
|
98
174
|
export declare function deleteUser(deps: LifecycleDeps, input: {
|
|
99
175
|
userId: string;
|
|
100
176
|
actor: LifecycleActor;
|
|
101
177
|
reason: string | null;
|
|
102
|
-
|
|
178
|
+
mode?: DeletionMode;
|
|
179
|
+
notify?: boolean;
|
|
180
|
+
}): Promise<DeleteTransition>;
|
|
181
|
+
/** What a restoration did, and where it left the account. */
|
|
182
|
+
export interface RestoreTransition extends LifecycleTransition {
|
|
183
|
+
/** Where the account stands now: `active`, or `suspended` when a suspension it was under is still in force. */
|
|
184
|
+
readonly state: "active" | "suspended";
|
|
185
|
+
}
|
|
103
186
|
/**
|
|
104
|
-
* Restore a deleted account inside its purge window.
|
|
105
|
-
*
|
|
187
|
+
* Restore a deleted account inside its purge window.
|
|
188
|
+
*
|
|
189
|
+
* **Only inside it.** Once `purgeAfter` has passed the purge is due, may already be running, and erases each
|
|
190
|
+
* capability's rows in turn, so restoring then would hand back an account with some of its data gone. That
|
|
191
|
+
* is a conflict naming the date the window closed. After the purge there is no account at all, and that is a
|
|
192
|
+
* 404 whose action says the data is gone — read off the history row the purge leaves behind, so it is told
|
|
193
|
+
* apart from an id that never existed.
|
|
194
|
+
*
|
|
195
|
+
* An account that is not deleted is no transition. A suspension it was under is still in force after.
|
|
106
196
|
*/
|
|
107
197
|
export declare function restoreUser(deps: LifecycleDeps, input: {
|
|
108
198
|
userId: string;
|
|
109
199
|
actor: LifecycleActor;
|
|
110
200
|
reason: string | null;
|
|
111
|
-
}): Promise<
|
|
112
|
-
/**
|
|
201
|
+
}): Promise<RestoreTransition>;
|
|
202
|
+
/**
|
|
203
|
+
* The account's row, or the refusal for one that is not there — the 404 that says the data is gone when the
|
|
204
|
+
* purge erased it, and the plain one otherwise. For a route that reads an account outside a transition: the
|
|
205
|
+
* export.
|
|
206
|
+
*/
|
|
207
|
+
export declare function requirePresent(db: AuthDatabase, userId: string): Promise<void>;
|
|
208
|
+
/** Who the purge's last mail goes to, captured before any step erases the address. */
|
|
209
|
+
export interface PurgeRecipient {
|
|
210
|
+
readonly email: string;
|
|
211
|
+
readonly name: string | null;
|
|
212
|
+
readonly locale: string | null;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Whether one account is due for its purge, who its last mail goes to, and whether it goes (#622).
|
|
216
|
+
*
|
|
217
|
+
* `due` only for an account that is deleted and whose `purgeAfter` has passed — the cron and a hard deletion
|
|
218
|
+
* both start a purge, and this is the one check either passes through, so an account restored in between is
|
|
219
|
+
* `not_due` and nothing is erased. `gone` when there is no row: the purge already erased it, or the id never
|
|
220
|
+
* existed, and either way there is nothing to do. The recipient is read here, before the first step, because
|
|
221
|
+
* the last step erases it.
|
|
222
|
+
*
|
|
223
|
+
* `notify` is what the deletion in force asked of the last mail — its newest `deleted` row's — so a hard
|
|
224
|
+
* deletion's `notify: false` holds for a purge the daily pass started, which was handed no such parameter.
|
|
225
|
+
*/
|
|
226
|
+
export declare function purgeSubject(deps: LifecycleDeps, userId: string): Promise<{
|
|
227
|
+
state: "due";
|
|
228
|
+
recipient: PurgeRecipient;
|
|
229
|
+
notify: boolean | null;
|
|
230
|
+
} | {
|
|
231
|
+
state: "not_due";
|
|
232
|
+
} | {
|
|
233
|
+
state: "gone";
|
|
234
|
+
}>;
|
|
235
|
+
/**
|
|
236
|
+
* The account's address, as a purge step reads it (#814) — `null` when there is no account, or no address. Read
|
|
237
|
+
* inside the step that asks, so it is never carried in a Workflow's journal.
|
|
238
|
+
*/
|
|
239
|
+
export declare function purgeAddress(db: AuthDatabase, userId: string): Promise<string | null>;
|
|
240
|
+
/** One account whose purge is due: which, and the deletion it is due under — ms-epoch, so a Workflow journal holds it. */
|
|
241
|
+
export interface DuePurge {
|
|
242
|
+
readonly userId: string;
|
|
243
|
+
readonly deletedAt: number;
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* The accounts whose purge is due — deleted, with `purgeAfter` passed — oldest first, at most `limit` (#622).
|
|
247
|
+
* What the daily cron starts a purge for. An account still inside its window is not here, and neither is one
|
|
248
|
+
* that was restored. Each carries its deletion's start, which names the purge's instance (`../purge/start.ts`).
|
|
249
|
+
*/
|
|
250
|
+
export declare function duePurges(deps: LifecycleDeps, limit: number): Promise<DuePurge[]>;
|
|
251
|
+
/**
|
|
252
|
+
* Record that one purge step — one capability's contribution — erased its rows. The contribution's summary is
|
|
253
|
+
* the row's reason, so the history says what the step erased and not only that it ran. With `retained`, the step
|
|
254
|
+
* kept its rows instead (#814): the row is `purge_retained`, and its reason is the basis the capability gave.
|
|
255
|
+
*/
|
|
113
256
|
export declare function recordPurgeStep(deps: LifecycleDeps, input: {
|
|
114
257
|
userId: string;
|
|
115
258
|
step: string;
|
|
259
|
+
summary?: string | null;
|
|
260
|
+
retained?: boolean;
|
|
116
261
|
}): Promise<void>;
|
|
117
262
|
/**
|
|
118
|
-
*
|
|
263
|
+
* Record that a purge gave up (#823): the step it stopped at, in the history and in the trail. The daily pass starts
|
|
264
|
+
* the purge again tomorrow, so this is where it stands until then, not an end. The failure's message is never
|
|
265
|
+
* written: it is code the kit did not write, and it may name the person.
|
|
266
|
+
*/
|
|
267
|
+
export declare function recordPurgeFailure(deps: LifecycleDeps, input: {
|
|
268
|
+
userId: string;
|
|
269
|
+
step: string;
|
|
270
|
+
}): Promise<void>;
|
|
271
|
+
/**
|
|
272
|
+
* The deletion-complete mail, sent **before the address is erased** (#622). The purge calls this after every
|
|
273
|
+
* other capability's rows are gone and before auth's own, which holds the address, so the last mail is
|
|
274
|
+
* enqueued while there is still an account to have sent it to. The address is handed in, captured before the
|
|
275
|
+
* first step. `notify: false` sends nothing, whatever the config says.
|
|
276
|
+
*/
|
|
277
|
+
export declare function mailPurgeComplete(deps: LifecycleDeps, input: {
|
|
278
|
+
recipient: PurgeRecipient;
|
|
279
|
+
notify?: boolean;
|
|
280
|
+
}): Promise<LifecycleTransition>;
|
|
281
|
+
/**
|
|
282
|
+
* Finish a purge: the record, the audit event, the hook. The last thing that happens to the account.
|
|
119
283
|
*
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
284
|
+
* By the time a purge finishes the user row is gone, so this reads nothing about the account. Finishing a
|
|
285
|
+
* purge that already finished is a no-op, so a retried Workflow step records and fires once — and so do two
|
|
286
|
+
* purges of one account that overlapped. **The insert is the check**: `0005_purge_once` allows one `purged` row
|
|
287
|
+
* per account, the insert ignores a second, and only the call whose row landed audits and fires. A read
|
|
288
|
+
* before the insert would let two concurrent calls both find nothing and both write.
|
|
123
289
|
*/
|
|
124
290
|
export declare function completePurge(deps: LifecycleDeps, input: {
|
|
125
291
|
userId: string;
|
|
126
|
-
recipient: {
|
|
127
|
-
email: string;
|
|
128
|
-
name: string | null;
|
|
129
|
-
locale: string | null;
|
|
130
|
-
};
|
|
131
292
|
}): Promise<LifecycleTransition>;
|
|
132
293
|
//# sourceMappingURL=transitions.d.ts.map
|
|
@@ -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;
|
|
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;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