@pithy-sh/auth 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -2
- package/dist/audit/actions.d.ts +39 -0
- package/dist/audit/actions.d.ts.map +1 -1
- package/dist/audit/actions.js +40 -1
- package/dist/audit/emit.d.ts +34 -0
- package/dist/audit/emit.d.ts.map +1 -1
- package/dist/audit/emit.js +47 -1
- package/dist/audit/evidence.d.ts +8 -2
- package/dist/audit/evidence.d.ts.map +1 -1
- package/dist/capability.d.ts +31 -11
- package/dist/capability.d.ts.map +1 -1
- package/dist/capability.js +38 -5
- 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 +25 -4
- package/dist/data/tables.d.ts.map +1 -1
- package/dist/data/tables.js +5 -3
- package/dist/data/userLifecycle.d.ts +9 -0
- package/dist/data/userLifecycle.d.ts.map +1 -1
- package/dist/data/userLifecycle.js +6 -2
- 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 +56 -10
- package/dist/http/csrf.d.ts.map +1 -1
- package/dist/http/csrf.js +2 -1
- package/dist/http/guards.d.ts +15 -11
- package/dist/http/guards.d.ts.map +1 -1
- package/dist/http/guards.js +46 -11
- 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 +12 -0
- package/dist/http/middleware.d.ts.map +1 -1
- package/dist/http/middleware.js +25 -4
- package/dist/http/resolve.d.ts.map +1 -1
- package/dist/http/resolve.js +9 -3
- package/dist/http/responses.d.ts +142 -0
- package/dist/http/responses.d.ts.map +1 -1
- package/dist/http/responses.js +66 -10
- package/dist/http/routes.d.ts +2 -0
- package/dist/http/routes.d.ts.map +1 -1
- package/dist/http/routes.js +35 -4
- package/dist/http/schemas.d.ts +57 -0
- package/dist/http/schemas.d.ts.map +1 -1
- package/dist/http/schemas.js +44 -1
- package/dist/http/views.d.ts +22 -2
- package/dist/http/views.d.ts.map +1 -1
- package/dist/http/views.js +40 -4
- 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 +86 -41
- 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/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/transitions.d.ts +22 -1
- package/dist/lifecycle/transitions.d.ts.map +1 -1
- package/dist/lifecycle/transitions.js +51 -4
- 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/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/set.d.ts +4 -1
- package/dist/migrations/set.d.ts.map +1 -1
- package/dist/migrations/set.js +8 -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 +20 -5
- package/dist/purge/contribution.d.ts.map +1 -1
- package/dist/purge/contribution.js +20 -6
- package/dist/purge/run.d.ts +75 -5
- package/dist/purge/run.d.ts.map +1 -1
- package/dist/purge/run.js +117 -14
- package/dist/purge/workflow.d.ts +15 -2
- package/dist/purge/workflow.d.ts.map +1 -1
- package/dist/purge/workflow.js +51 -7
- package/dist/test-utils/accountFootprint.d.ts +5 -2
- package/dist/test-utils/accountFootprint.d.ts.map +1 -1
- package/dist/test-utils/accountFootprint.js +7 -2
- 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 +59 -7
- 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 +39 -0
- package/src/audit/emit.ts +63 -0
- package/src/audit/evidence.ts +8 -4
- package/src/capability.ts +80 -23
- 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 +15 -3
- package/src/data/verificationOutcome.ts +86 -0
- package/src/email/send.ts +2 -2
- package/src/http/adminRoutes.ts +68 -3
- package/src/http/csrf.ts +4 -1
- package/src/http/guards.ts +48 -11
- package/src/http/handoff.ts +350 -0
- package/src/http/middleware.ts +29 -3
- package/src/http/resolve.ts +25 -25
- package/src/http/responses.ts +134 -8
- package/src/http/routes.ts +63 -4
- package/src/http/schemas.ts +85 -0
- package/src/http/views.ts +46 -2
- package/src/index.ts +2 -0
- package/src/instance/auth.ts +51 -1
- package/src/instance/plugins.ts +20 -2
- package/src/ledger/read.ts +133 -0
- package/src/ledger/record.ts +198 -0
- package/src/lifecycle/erasure.ts +118 -0
- package/src/lifecycle/inactivity.ts +56 -0
- package/src/lifecycle/transitions.ts +75 -5
- 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/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/set.ts +7 -1
- package/src/processing/activities.ts +14 -0
- package/src/purge/contribution.ts +37 -10
- package/src/purge/run.ts +179 -16
- package/src/purge/workflow.ts +65 -7
- package/src/seeds/example.ts +2 -2
- package/src/test-utils/accountFootprint.ts +10 -1
- 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,15 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
import type { Migration } from "kysely/migration";
|
|
4
|
+
/**
|
|
5
|
+
* When an account was last active — stamped on `pithy_auth_users` by every session the account opens, so the
|
|
6
|
+
* retention policy's class ages have a clock that a sign-out cannot erase: a session row goes when its holder signs
|
|
7
|
+
* out, and this column stays.
|
|
8
|
+
*
|
|
9
|
+
* **Every existing account starts its clock now.** A row written before this column existed has no record of its
|
|
10
|
+
* last sign-in, and reading its absence as "never" would soft-delete an account somebody used last week the first
|
|
11
|
+
* night the pass runs. So `up` stamps the migration's own instant on every row, and an account becomes inactive no
|
|
12
|
+
* sooner than its class age after the upgrade. `down` drops the column and the index.
|
|
13
|
+
*/
|
|
14
|
+
export declare const auth_0008_last_active: Migration;
|
|
15
|
+
//# sourceMappingURL=0008_last_active.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0008_last_active.d.ts","sourceRoot":"","sources":["../../src/migrations/0008_last_active.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAKlD;;;;;;;;;GASG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAUnC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
import { sql } from "kysely";
|
|
4
|
+
//#region src/migrations/0008_last_active.ts
|
|
5
|
+
/** The inactivity pass's index: every account by when it was last active. */
|
|
6
|
+
const LAST_ACTIVE_INDEX = "pithyAuthUsersLastActiveAtIdx";
|
|
7
|
+
/**
|
|
8
|
+
* When an account was last active — stamped on `pithy_auth_users` by every session the account opens, so the
|
|
9
|
+
* retention policy's class ages have a clock that a sign-out cannot erase: a session row goes when its holder signs
|
|
10
|
+
* out, and this column stays.
|
|
11
|
+
*
|
|
12
|
+
* **Every existing account starts its clock now.** A row written before this column existed has no record of its
|
|
13
|
+
* last sign-in, and reading its absence as "never" would soft-delete an account somebody used last week the first
|
|
14
|
+
* night the pass runs. So `up` stamps the migration's own instant on every row, and an account becomes inactive no
|
|
15
|
+
* sooner than its class age after the upgrade. `down` drops the column and the index.
|
|
16
|
+
*/
|
|
17
|
+
const auth_0008_last_active = {
|
|
18
|
+
async up(db) {
|
|
19
|
+
await db.schema.alterTable("pithyAuthUsers").addColumn("lastActiveAt", "integer").execute();
|
|
20
|
+
await sql`update pithy_auth_users set last_active_at = cast(strftime('%s', 'now') as integer) * 1000`.execute(db);
|
|
21
|
+
await db.schema.createIndex(LAST_ACTIVE_INDEX).on("pithyAuthUsers").column("lastActiveAt").execute();
|
|
22
|
+
},
|
|
23
|
+
async down(db) {
|
|
24
|
+
await db.schema.dropIndex(LAST_ACTIVE_INDEX).execute();
|
|
25
|
+
await db.schema.alterTable("pithyAuthUsers").dropColumn("lastActiveAt").execute();
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
//#endregion
|
|
29
|
+
export { auth_0008_last_active };
|
package/dist/migrations/set.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* migration. Adding a `0002` turned all five into a schema one column short of the code, and the symptom
|
|
11
11
|
* was `table pithy_auth_sessions has no column named authenticated_at` in thirteen unrelated tests.
|
|
12
12
|
*
|
|
13
|
-
* `0003
|
|
13
|
+
* `0003` through `0007` appended here and reached every reader, which is the point. `0001_init.workers.test.ts` is deliberately not a reader:
|
|
14
14
|
* its subject is that one migration's own `up` and `down`, so it names it directly.
|
|
15
15
|
*/
|
|
16
16
|
export declare const AUTH_MIGRATIONS: {
|
|
@@ -19,5 +19,8 @@ export declare const AUTH_MIGRATIONS: {
|
|
|
19
19
|
readonly "0003_account_issuer_nullable": import("kysely/migration").Migration;
|
|
20
20
|
readonly "0004_user_lifecycle": import("kysely/migration").Migration;
|
|
21
21
|
readonly "0005_purge_once": import("kysely/migration").Migration;
|
|
22
|
+
readonly "0006_verification_outcomes": import("kysely/migration").Migration;
|
|
23
|
+
readonly "0007_erasure_record": import("kysely/migration").Migration;
|
|
24
|
+
readonly "0008_last_active": import("kysely/migration").Migration;
|
|
22
25
|
};
|
|
23
26
|
//# sourceMappingURL=set.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../src/migrations/set.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"set.d.ts","sourceRoot":"","sources":["../../src/migrations/set.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,eAAe;aAC1B,WAAW;aACX,+BAA+B;aAC/B,8BAA8B;aAC9B,qBAAqB;aACrB,iBAAiB;aACjB,4BAA4B;aAC5B,qBAAqB;aACrB,kBAAkB;CACV,CAAC"}
|
package/dist/migrations/set.js
CHANGED
|
@@ -5,6 +5,9 @@ import { auth_0002_session_authenticated_at } from "./0002_session_authenticated
|
|
|
5
5
|
import { auth_0003_account_issuer_nullable } from "./0003_account_issuer_nullable.js";
|
|
6
6
|
import { auth_0004_user_lifecycle } from "./0004_user_lifecycle.js";
|
|
7
7
|
import { auth_0005_purge_once } from "./0005_purge_once.js";
|
|
8
|
+
import { auth_0006_verification_outcomes } from "./0006_verification_outcomes.js";
|
|
9
|
+
import { auth_0007_erasure_record } from "./0007_erasure_record.js";
|
|
10
|
+
import { auth_0008_last_active } from "./0008_last_active.js";
|
|
8
11
|
//#region src/migrations/set.ts
|
|
9
12
|
/**
|
|
10
13
|
* Every migration `@pithy-sh/auth` ships, keyed as `pithy migrate` composes them.
|
|
@@ -16,7 +19,7 @@ import { auth_0005_purge_once } from "./0005_purge_once.js";
|
|
|
16
19
|
* migration. Adding a `0002` turned all five into a schema one column short of the code, and the symptom
|
|
17
20
|
* was `table pithy_auth_sessions has no column named authenticated_at` in thirteen unrelated tests.
|
|
18
21
|
*
|
|
19
|
-
* `0003
|
|
22
|
+
* `0003` through `0007` appended here and reached every reader, which is the point. `0001_init.workers.test.ts` is deliberately not a reader:
|
|
20
23
|
* its subject is that one migration's own `up` and `down`, so it names it directly.
|
|
21
24
|
*/
|
|
22
25
|
const AUTH_MIGRATIONS = {
|
|
@@ -24,7 +27,10 @@ const AUTH_MIGRATIONS = {
|
|
|
24
27
|
"0002_session_authenticated_at": auth_0002_session_authenticated_at,
|
|
25
28
|
"0003_account_issuer_nullable": auth_0003_account_issuer_nullable,
|
|
26
29
|
"0004_user_lifecycle": auth_0004_user_lifecycle,
|
|
27
|
-
"0005_purge_once": auth_0005_purge_once
|
|
30
|
+
"0005_purge_once": auth_0005_purge_once,
|
|
31
|
+
"0006_verification_outcomes": auth_0006_verification_outcomes,
|
|
32
|
+
"0007_erasure_record": auth_0007_erasure_record,
|
|
33
|
+
"0008_last_active": auth_0008_last_active
|
|
28
34
|
};
|
|
29
35
|
//#endregion
|
|
30
36
|
export { AUTH_MIGRATIONS };
|
package/dist/peer.d.ts
CHANGED
|
@@ -23,8 +23,8 @@ export declare const authPeer: {
|
|
|
23
23
|
readonly authDatabase: typeof authDatabase;
|
|
24
24
|
readonly User: import("zod").ZodObject<{
|
|
25
25
|
id: import("zod").ZodString;
|
|
26
|
-
name: import("zod").ZodString
|
|
27
|
-
email: import("zod").ZodString
|
|
26
|
+
name: import("@pithy-sh/core/src/privacy/classes").Marked<import("zod").ZodString, "pii">;
|
|
27
|
+
email: import("@pithy-sh/core/src/privacy/classes").Marked<import("zod").ZodString, "pii">;
|
|
28
28
|
emailVerified: import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodLiteral<0>, import("zod").ZodLiteral<1>, import("zod").ZodBoolean, import("zod").ZodString]>, import("zod").ZodBoolean>;
|
|
29
29
|
image: import("zod").ZodNullable<import("zod").ZodString>;
|
|
30
30
|
locale: import("zod").ZodNullable<import("zod").ZodString>;
|
|
@@ -34,6 +34,7 @@ export declare const authPeer: {
|
|
|
34
34
|
suspendedUntil: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodDate]>, import("zod").ZodDate>>>;
|
|
35
35
|
deletedAt: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodDate]>, import("zod").ZodDate>>>;
|
|
36
36
|
purgeAfter: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodDate]>, import("zod").ZodDate>>>;
|
|
37
|
+
lastActiveAt: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodCodec<import("zod").ZodUnion<readonly [import("zod").ZodNumber, import("zod").ZodString, import("zod").ZodDate]>, import("zod").ZodDate>>>;
|
|
37
38
|
}, import("zod/v4/core").$strip>;
|
|
38
39
|
readonly Device: import("zod").ZodObject<{
|
|
39
40
|
id: import("zod").ZodString;
|
package/dist/peer.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"peer.d.ts","sourceRoot":"","sources":["../src/peer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,QAAQ
|
|
1
|
+
{"version":3,"file":"peer.d.ts","sourceRoot":"","sources":["../src/peer.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAA0C,CAAC;AAEhE,4DAA4D;AAC5D,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
import type { ProcessingActivityInput } from "@pithy-sh/core/src/processing/activity";
|
|
4
|
+
/** What auth does with personal data: it keeps accounts and signs their holders in. */
|
|
5
|
+
export declare const AUTH_PROCESSING: readonly ProcessingActivityInput[];
|
|
6
|
+
//# sourceMappingURL=activities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"activities.d.ts","sourceRoot":"","sources":["../../src/processing/activities.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEtF,uFAAuF;AACvF,eAAO,MAAM,eAAe,EAAE,SAAS,uBAAuB,EAO7D,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
//#region src/processing/activities.ts
|
|
4
|
+
/** What auth does with personal data: it keeps accounts and signs their holders in. */
|
|
5
|
+
const AUTH_PROCESSING = [{
|
|
6
|
+
id: "auth.account",
|
|
7
|
+
purpose: "Keep a person's account, sign them in, and keep the sessions that prove it.",
|
|
8
|
+
classes: ["pii"],
|
|
9
|
+
legalBasis: "contract"
|
|
10
|
+
}];
|
|
11
|
+
//#endregion
|
|
12
|
+
export { AUTH_PROCESSING };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
3
|
import type { D1Database } from "@cloudflare/workers-types";
|
|
4
|
-
import type {
|
|
4
|
+
import type { ErasingPurgeContribution } from "@pithy-sh/core/src/capability/purge";
|
|
5
|
+
import { type CompiledQuery, type Kysely } from "kysely";
|
|
5
6
|
import { type AuthDatabase } from "../data/tables";
|
|
6
7
|
import type { AuthUserExport } from "../http/responses";
|
|
7
8
|
/**
|
|
@@ -9,8 +10,8 @@ import type { AuthUserExport } from "../http/responses";
|
|
|
9
10
|
* exporting them hands back.
|
|
10
11
|
*
|
|
11
12
|
* **Every row keyed to the account goes, except its history.** The user row, its sessions, its linked
|
|
12
|
-
* providers, its devices, its refresh-token ledger, any sign-in code or link still pending for its address,
|
|
13
|
-
* and its rows in every table a composed Better Auth plugin created keyed by `userId` — a two-factor secret
|
|
13
|
+
* providers, its devices, its refresh-token ledger, any sign-in code or link still pending for its address, its
|
|
14
|
+
* rows in the verification ledger (#829), and its rows in every table a composed Better Auth plugin created keyed by `userId` — a two-factor secret
|
|
14
15
|
* and its backup codes, a passkey, an API key. Those tables have no foreign key to the user row, so deleting
|
|
15
16
|
* it removes nothing from them; they are named by the plugin plan (`../migrations/pluginTables.ts`). `pithy_auth_user_lifecycle` stays: it is the record that the account existed, was deleted and was
|
|
16
17
|
* erased, and it names the account by id and holds nothing else about the person (`../data/userLifecycle.ts`).
|
|
@@ -24,7 +25,13 @@ import type { AuthUserExport } from "../http/responses";
|
|
|
24
25
|
* mail, because the address that mail is sent to lives on the user row this deletes.
|
|
25
26
|
*/
|
|
26
27
|
/** The one sentence the purge records with this step. */
|
|
27
|
-
export declare const AUTH_PURGE_SUMMARY = "Deletes the account, its sessions, linked providers, devices, refresh-token ledger, pending sign-in codes and its rows in the tables its Better Auth plugins created. Its lifecycle history stays.";
|
|
28
|
+
export declare const AUTH_PURGE_SUMMARY = "Deletes the account, its sessions, linked providers, devices, refresh-token ledger, pending sign-in codes, the record of the sign-in links and codes it was sent, and its rows in the tables its Better Auth plugins created. Its lifecycle history stays.";
|
|
29
|
+
/** The auth Kysely without its table map — a plugin's table is named by the plan, not by `authTables`. */
|
|
30
|
+
export declare function untyped(db: AuthDatabase): Kysely<Record<string, Record<string, unknown>>>;
|
|
31
|
+
/** The D1 binding the auth tables live in, off a run's env — or a wiring fault naming it. */
|
|
32
|
+
export declare function bindingOf(env: Record<string, unknown>, database: string): D1Database;
|
|
33
|
+
/** Bind a compiled statement to D1, so it can join a `batch`. */
|
|
34
|
+
export declare function prepared(d1: D1Database, compiled: CompiledQuery): import("@cloudflare/workers-types").D1PreparedStatement;
|
|
28
35
|
/**
|
|
29
36
|
* Erase one account's `pithy_auth_*` rows, its history excepted. Succeeds, having found nothing, when they are
|
|
30
37
|
* already gone.
|
|
@@ -39,9 +46,17 @@ export declare function eraseAuthUser(db: AuthDatabase, d1: D1Database, userId:
|
|
|
39
46
|
* history, every list whole. `null` when there is no account to export.
|
|
40
47
|
*/
|
|
41
48
|
export declare function exportAuthUser(db: AuthDatabase, userId: string, pluginTables?: readonly string[]): Promise<AuthUserExport | null>;
|
|
49
|
+
/** One plugin table's rows about the account, every column but a credential's. */
|
|
50
|
+
export declare function pluginRows(db: AuthDatabase, table: string, userId: string): Promise<Record<string, unknown>[]>;
|
|
42
51
|
/**
|
|
43
52
|
* The contribution `auth()` declares, over the D1 binding its config names. The export of an account that is
|
|
44
53
|
* not there is an empty object, which the route never reaches: it answers 404 before it reads any capability.
|
|
45
54
|
*/
|
|
46
|
-
|
|
55
|
+
/**
|
|
56
|
+
* An account's address by user id, over the env's auth database — what auth answers through core's `addressOf`
|
|
57
|
+
* seam, so a capability holding state by address (email's suppression list) finds it without importing auth.
|
|
58
|
+
* `null` for an account that has none, or no longer exists.
|
|
59
|
+
*/
|
|
60
|
+
export declare function authAddressOf(database: string): (env: Record<string, unknown>, userId: string) => Promise<string | null>;
|
|
61
|
+
export declare function authPurgeContribution(database: string, pluginTables?: readonly string[]): ErasingPurgeContribution;
|
|
47
62
|
//# sourceMappingURL=contribution.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contribution.d.ts","sourceRoot":"","sources":["../../src/purge/contribution.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAgB,
|
|
1
|
+
{"version":3,"file":"contribution.d.ts","sourceRoot":"","sources":["../../src/purge/contribution.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,KAAK,EAAE,wBAAwB,EAAgB,MAAM,qCAAqC,CAAC;AAElG,OAAO,EAAE,KAAK,aAAa,EAAE,KAAK,MAAM,EAAqB,MAAM,QAAQ,CAAC;AAG5E,OAAO,EAAE,KAAK,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAGjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAIxD;;;;;;;;;;;;;;;;;;GAkBG;AAEH,yDAAyD;AACzD,eAAO,MAAM,kBAAkB,+PAC+N,CAAC;AAS/P,0GAA0G;AAC1G,wBAAgB,OAAO,CAAC,EAAE,EAAE,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAEzF;AAED,6FAA6F;AAC7F,wBAAgB,SAAS,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAUpF;AAOD,iEAAiE;AACjE,wBAAgB,QAAQ,CAAC,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,2DAE/D;AAED;;;;;;;GAOG;AACH,wBAAsB,aAAa,CACjC,EAAE,EAAE,YAAY,EAChB,EAAE,EAAE,UAAU,EACd,MAAM,EAAE,MAAM,EACd,YAAY,GAAE,SAAS,MAAM,EAAO,GACnC,OAAO,CAAC,IAAI,CAAC,CAiCf;AAED;;;GAGG;AACH,wBAAsB,cAAc,CAClC,EAAE,EAAE,YAAY,EAChB,MAAM,EAAE,MAAM,EACd,YAAY,GAAE,SAAS,MAAM,EAAO,GACnC,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CA6ChC;AAED,kFAAkF;AAClF,wBAAsB,UAAU,CAAC,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,CAKpH;AAED;;;GAGG;AACH;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,SAC/B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,UAAU,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAE9E;AAED,wBAAgB,qBAAqB,CACnC,QAAQ,EAAE,MAAM,EAChB,YAAY,GAAE,SAAS,MAAM,EAAO,GACnC,wBAAwB,CAc1B"}
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
import { Account, Session, User } from "../data/betterAuth.js";
|
|
4
4
|
import { Device } from "../data/device.js";
|
|
5
5
|
import { UserLifecycleEvent } from "../data/userLifecycle.js";
|
|
6
|
+
import { VerificationOutcome } from "../data/verificationOutcome.js";
|
|
6
7
|
import { authDatabase } from "../data/tables.js";
|
|
8
|
+
import { purgeAddress } from "../lifecycle/transitions.js";
|
|
7
9
|
import { authUserExportView } from "../http/views.js";
|
|
8
10
|
import { InternalError } from "@pithy-sh/core/src/error/pithyError";
|
|
9
11
|
import { sql } from "kysely";
|
|
@@ -13,8 +15,8 @@ import { sql } from "kysely";
|
|
|
13
15
|
* exporting them hands back.
|
|
14
16
|
*
|
|
15
17
|
* **Every row keyed to the account goes, except its history.** The user row, its sessions, its linked
|
|
16
|
-
* providers, its devices, its refresh-token ledger, any sign-in code or link still pending for its address,
|
|
17
|
-
* and its rows in every table a composed Better Auth plugin created keyed by `userId` — a two-factor secret
|
|
18
|
+
* providers, its devices, its refresh-token ledger, any sign-in code or link still pending for its address, its
|
|
19
|
+
* rows in the verification ledger (#829), and its rows in every table a composed Better Auth plugin created keyed by `userId` — a two-factor secret
|
|
18
20
|
* and its backup codes, a passkey, an API key. Those tables have no foreign key to the user row, so deleting
|
|
19
21
|
* it removes nothing from them; they are named by the plugin plan (`../migrations/pluginTables.ts`). `pithy_auth_user_lifecycle` stays: it is the record that the account existed, was deleted and was
|
|
20
22
|
* erased, and it names the account by id and holds nothing else about the person (`../data/userLifecycle.ts`).
|
|
@@ -28,7 +30,7 @@ import { sql } from "kysely";
|
|
|
28
30
|
* mail, because the address that mail is sent to lives on the user row this deletes.
|
|
29
31
|
*/
|
|
30
32
|
/** The one sentence the purge records with this step. */
|
|
31
|
-
const AUTH_PURGE_SUMMARY = "Deletes the account, its sessions, linked providers, devices, refresh-token ledger, pending sign-in codes and its rows in the tables its Better Auth plugins created. Its lifecycle history stays.";
|
|
33
|
+
const AUTH_PURGE_SUMMARY = "Deletes the account, its sessions, linked providers, devices, refresh-token ledger, pending sign-in codes, the record of the sign-in links and codes it was sent, and its rows in the tables its Better Auth plugins created. Its lifecycle history stays.";
|
|
32
34
|
/**
|
|
33
35
|
* A plugin table's column that holds a credential — a TOTP secret, backup codes, a key or its hash, a token.
|
|
34
36
|
* The export leaves these out, as it leaves out a session's token and a provider's: an access request is
|
|
@@ -71,7 +73,8 @@ async function eraseAuthUser(db, d1, userId, pluginTables = []) {
|
|
|
71
73
|
db.deleteFrom("pithyAuthSessions").where("userId", "=", userId),
|
|
72
74
|
db.deleteFrom("pithyAuthAccounts").where("userId", "=", userId),
|
|
73
75
|
db.deleteFrom("pithyAuthDevices").where("userId", "=", userId),
|
|
74
|
-
db.deleteFrom("pithyAuthRotatedTokens").where("userId", "=", userId)
|
|
76
|
+
db.deleteFrom("pithyAuthRotatedTokens").where("userId", "=", userId),
|
|
77
|
+
db.deleteFrom("pithyAuthVerificationOutcomes").where("userId", "=", userId)
|
|
75
78
|
].map((query) => prepared(d1, query.compile()));
|
|
76
79
|
for (const table of pluginTables) statements.push(prepared(d1, untyped(db).deleteFrom(table).where("userId", "=", userId).compile()));
|
|
77
80
|
if (user) {
|
|
@@ -92,14 +95,16 @@ async function eraseAuthUser(db, d1, userId, pluginTables = []) {
|
|
|
92
95
|
async function exportAuthUser(db, userId, pluginTables = []) {
|
|
93
96
|
const row = await db.selectFrom("pithyAuthUsers").selectAll().where("id", "=", userId).executeTakeFirst();
|
|
94
97
|
if (!row) return null;
|
|
95
|
-
const [sessions, accounts, devices, history, plugins] = await Promise.all([
|
|
98
|
+
const [sessions, accounts, devices, history, verifications, plugins] = await Promise.all([
|
|
96
99
|
db.selectFrom("pithyAuthSessions").selectAll().where("userId", "=", userId).orderBy("createdAt", "desc").orderBy("id", "desc").execute(),
|
|
97
100
|
db.selectFrom("pithyAuthAccounts").select(["providerId", "createdAt"]).where("userId", "=", userId).orderBy("providerId", "asc").execute(),
|
|
98
101
|
db.selectFrom("pithyAuthDevices").selectAll().where("userId", "=", userId).orderBy("lastSeenAt", "desc").orderBy("id", "desc").execute(),
|
|
99
102
|
db.selectFrom("pithyAuthUserLifecycle").selectAll().where("userId", "=", userId).orderBy("id", "asc").execute(),
|
|
103
|
+
db.selectFrom("pithyAuthVerificationOutcomes").selectAll().where("userId", "=", userId).orderBy("issuedAt", "desc").orderBy("id", "desc").execute(),
|
|
100
104
|
Promise.all(pluginTables.map(async (table) => [table, await pluginRows(db, table, userId)]))
|
|
101
105
|
]);
|
|
102
106
|
return authUserExportView({
|
|
107
|
+
now: /* @__PURE__ */ new Date(),
|
|
103
108
|
user: User.parse(row),
|
|
104
109
|
sessions: sessions.map((session) => Session.parse(session)),
|
|
105
110
|
accounts: accounts.map((account) => Account.pick({
|
|
@@ -108,6 +113,7 @@ async function exportAuthUser(db, userId, pluginTables = []) {
|
|
|
108
113
|
}).parse(account)),
|
|
109
114
|
devices: devices.map((device) => Device.parse(device)),
|
|
110
115
|
history: history.map((event) => UserLifecycleEvent.parse(event)),
|
|
116
|
+
verifications: verifications.map((row) => VerificationOutcome.parse(row)),
|
|
111
117
|
plugins: Object.fromEntries(plugins)
|
|
112
118
|
});
|
|
113
119
|
}
|
|
@@ -119,6 +125,14 @@ async function pluginRows(db, table, userId) {
|
|
|
119
125
|
* The contribution `auth()` declares, over the D1 binding its config names. The export of an account that is
|
|
120
126
|
* not there is an empty object, which the route never reaches: it answers 404 before it reads any capability.
|
|
121
127
|
*/
|
|
128
|
+
/**
|
|
129
|
+
* An account's address by user id, over the env's auth database — what auth answers through core's `addressOf`
|
|
130
|
+
* seam, so a capability holding state by address (email's suppression list) finds it without importing auth.
|
|
131
|
+
* `null` for an account that has none, or no longer exists.
|
|
132
|
+
*/
|
|
133
|
+
function authAddressOf(database) {
|
|
134
|
+
return (env, userId) => purgeAddress(authDatabase(bindingOf(env, database)), userId);
|
|
135
|
+
}
|
|
122
136
|
function authPurgeContribution(database, pluginTables = []) {
|
|
123
137
|
const open = (context) => {
|
|
124
138
|
const d1 = bindingOf(context.env, database);
|
|
@@ -138,4 +152,4 @@ function authPurgeContribution(database, pluginTables = []) {
|
|
|
138
152
|
};
|
|
139
153
|
}
|
|
140
154
|
//#endregion
|
|
141
|
-
export { AUTH_PURGE_SUMMARY, authPurgeContribution, eraseAuthUser, exportAuthUser };
|
|
155
|
+
export { AUTH_PURGE_SUMMARY, authAddressOf, authPurgeContribution, bindingOf, eraseAuthUser, exportAuthUser, pluginRows, prepared, untyped };
|
package/dist/purge/run.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// SPDX-FileCopyrightText: 2026 Pithy
|
|
2
2
|
// SPDX-License-Identifier: MIT
|
|
3
|
-
import type
|
|
3
|
+
import { type PurgeStep } from "@pithy-sh/core/src/capability/purge";
|
|
4
|
+
import type { LegalHolds } from "@pithy-sh/core/src/retention/holds";
|
|
4
5
|
import { type TerminalErrorConstructor, type WorkflowStepLike } from "@pithy-sh/core/src/workflow/faults";
|
|
5
6
|
import { type DuePurge, type LifecycleDeps } from "../lifecycle/transitions";
|
|
6
7
|
import { type AuthPurgeDueParams, type AuthPurgeParams } from "./specs";
|
|
@@ -13,7 +14,8 @@ import { type AuthPurgeDueParams, type AuthPurgeParams } from "./specs";
|
|
|
13
14
|
* and one already erased all end the run here, having erased nothing. This is the one check a cron-started
|
|
14
15
|
* purge and a hard deletion's both pass through, so re-running a purge for the same subject exits cleanly.
|
|
15
16
|
* 2. **`erase <capability>`** — one step per composed contribution, in composition order, each recording that it
|
|
16
|
-
* ran in `pithy_auth_user_lifecycle`.
|
|
17
|
+
* ran in `pithy_auth_user_lifecycle`. A contribution that **retains** its rows (#814) is a `retain <capability>`
|
|
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
|
|
17
19
|
* contract and runs code the kit did not write, so any fault in it is worth another attempt (`./retryPolicy.ts`).
|
|
18
20
|
* A failing contribution retries alone, and the ones that finished are served from the journal.
|
|
19
21
|
* 3. **`mail`** — the deletion-complete mail, **before the address is erased**: every other capability's rows are
|
|
@@ -21,6 +23,24 @@ import { type AuthPurgeDueParams, type AuthPurgeParams } from "./specs";
|
|
|
21
23
|
* one, so it is in no Workflow's journal.
|
|
22
24
|
* 4. **`erase auth`** — auth's own contribution, last for that reason.
|
|
23
25
|
* 5. **`complete`** — the `purged` record, the audit event, `onUserPurged`. Once.
|
|
26
|
+
*
|
|
27
|
+
* Every step from 2 on records an audit event as well as its row (#823), which the erasure attestation cites.
|
|
28
|
+
*
|
|
29
|
+
* ## A legal hold stops it
|
|
30
|
+
*
|
|
31
|
+
* Before `due` hands over, and again before every step after it, the purge asks whether a legal hold stands on the
|
|
32
|
+
* account — each ask its own step, `hold <next>`, so a replay serves the answer it got. A hold found ends the run as
|
|
33
|
+
* `held`, having erased nothing more: the steps that finished stay finished, the rest wait. Released, the account is
|
|
34
|
+
* still deleted and still due, so the next daily pass starts a fresh purge, whose idempotent steps find nothing to
|
|
35
|
+
* erase where the first one did and carry on from there. A hold that cannot be read fails its step, which retries:
|
|
36
|
+
* a purge never erases past a hold it could not see.
|
|
37
|
+
*
|
|
38
|
+
* ## A purge that gives up says where (#823)
|
|
39
|
+
*
|
|
40
|
+
* A step that exhausts its retries fails the instance, and the daily pass starts a fresh one tomorrow. Until then the
|
|
41
|
+
* record would read as a purge still running. So the failure is caught once, recorded in its own `fail` step —
|
|
42
|
+
* the step it stopped at, in the history and the trail — and thrown on unchanged, so the instance still fails
|
|
43
|
+
* exactly as it did. A `fail` step that cannot write either is swallowed: the original failure is the one to report.
|
|
24
44
|
*/
|
|
25
45
|
/** What a purge does with the account's own records — the transitions, over one set of dependencies. */
|
|
26
46
|
export interface PurgeOps {
|
|
@@ -28,6 +48,13 @@ export interface PurgeOps {
|
|
|
28
48
|
due(userId: string): Promise<"due" | "not_due" | "gone">;
|
|
29
49
|
/** Record that one capability's step erased its rows. */
|
|
30
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>;
|
|
53
|
+
/**
|
|
54
|
+
* The account's address, read now, or `null` once it is gone (#814). Handed to each step as
|
|
55
|
+
* `PurgeContext.address`, so a capability holding rows by address reads it inside its own step.
|
|
56
|
+
*/
|
|
57
|
+
address(userId: string): Promise<string | null>;
|
|
31
58
|
/**
|
|
32
59
|
* Send the deletion-complete mail to the account's address, if it is still there to read, unless this purge's
|
|
33
60
|
* `notify` or the deletion's own saved choice is false. Says whether.
|
|
@@ -35,17 +62,26 @@ export interface PurgeOps {
|
|
|
35
62
|
mailComplete(userId: string, notify: boolean | undefined): Promise<boolean>;
|
|
36
63
|
/** Write the `purged` record, the audit event and the hook. Says whether this call wrote them. */
|
|
37
64
|
complete(userId: string): Promise<boolean>;
|
|
65
|
+
/** Record that the purge gave up at `step`, in the history and the trail (#823). */
|
|
66
|
+
fail(userId: string, step: string): Promise<void>;
|
|
67
|
+
/** Whether a legal hold stands on the account. Throws when it cannot say. */
|
|
68
|
+
held(userId: string): Promise<boolean>;
|
|
38
69
|
}
|
|
39
70
|
/** The operations, over the lifecycle transitions. */
|
|
40
|
-
export declare function purgeOps(deps: LifecycleDeps): PurgeOps;
|
|
71
|
+
export declare function purgeOps(deps: LifecycleDeps, holds: LegalHolds): PurgeOps;
|
|
41
72
|
/** What one purge did: the account, how it ended, and the capabilities whose rows it erased. */
|
|
42
73
|
export interface PurgeOutcome {
|
|
43
74
|
/** The account. */
|
|
44
75
|
readonly userId: string;
|
|
45
|
-
/**
|
|
46
|
-
|
|
76
|
+
/**
|
|
77
|
+
* `purged`; or why nothing was erased: `not_due` (restored, or inside its window) and `gone` (no account); or
|
|
78
|
+
* `held`, a legal hold stopped it before the step it would have run next.
|
|
79
|
+
*/
|
|
80
|
+
readonly state: "purged" | "not_due" | "gone" | "held";
|
|
47
81
|
/** Every step that erased its rows, in the order it ran. Empty when nothing was erased. */
|
|
48
82
|
readonly erased: readonly string[];
|
|
83
|
+
/** Every step that kept its rows under a stated basis (#814), in the order it ran. */
|
|
84
|
+
readonly retained: readonly string[];
|
|
49
85
|
/** Whether the deletion-complete mail was enqueued. */
|
|
50
86
|
readonly mailed: boolean;
|
|
51
87
|
}
|
|
@@ -74,6 +110,11 @@ export interface PurgeDueRun {
|
|
|
74
110
|
* started, and the pass does not count it.
|
|
75
111
|
*/
|
|
76
112
|
start(due: DuePurge): Promise<boolean>;
|
|
113
|
+
/**
|
|
114
|
+
* Whether a legal hold stands on the account. A held account is not started; absent, every due account is,
|
|
115
|
+
* and each purge's own hold check stops it before its first step.
|
|
116
|
+
*/
|
|
117
|
+
held?(userId: string): Promise<boolean>;
|
|
77
118
|
}
|
|
78
119
|
/**
|
|
79
120
|
* The daily pass (#622): list every account past its window, and start a purge for each — in pages, one step
|
|
@@ -85,4 +126,33 @@ export declare function startDuePurges(run: PurgeDueRun, step: WorkflowStepLike,
|
|
|
85
126
|
}>;
|
|
86
127
|
/** The daily pass's reads, over the lifecycle transitions. */
|
|
87
128
|
export declare function duePurgesOf(deps: LifecycleDeps): PurgeDueRun["due"];
|
|
129
|
+
/** How many inactive accounts one pass soft-deletes, at most: a backlog drains over nights, never in one. */
|
|
130
|
+
export declare const INACTIVE_DEFAULT_LIMIT = 200;
|
|
131
|
+
/** What the inactivity pass reads and deletes through. */
|
|
132
|
+
export interface InactivityRun {
|
|
133
|
+
/**
|
|
134
|
+
* The longest an account may sit inactive, in days — the strictest class age it holds — or null for no limit.
|
|
135
|
+
* Asked inside a step, so a replay serves the answer it got.
|
|
136
|
+
*/
|
|
137
|
+
days(): Promise<number | null>;
|
|
138
|
+
/** Every account inactive since `cutoff`, oldest first, at most `limit`. */
|
|
139
|
+
inactive(cutoff: Date, limit: number): Promise<string[]>;
|
|
140
|
+
/** Whether a legal hold stands on the account. */
|
|
141
|
+
held(userId: string): Promise<boolean>;
|
|
142
|
+
/** Soft-delete one account through the lifecycle, with its notice mail and window. Says whether it was deleted. */
|
|
143
|
+
remove(userId: string, days: number): Promise<boolean>;
|
|
144
|
+
/** Now. */
|
|
145
|
+
now(): Date;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* The inactivity pass: every account untouched for longer than the strictest class age it holds is
|
|
149
|
+
* soft-deleted through the lifecycle — its deletion-scheduled mail, its window, then the purge the daily pass starts
|
|
150
|
+
* once that window closes. A held account is skipped. With no class age that applies, the pass does nothing.
|
|
151
|
+
*
|
|
152
|
+
* Listed in one step, deleted in pages of steps, so a pass that dies part-way resumes after the page it finished.
|
|
153
|
+
* A deletion is no transition on an account already deleted, so a repeated page deletes nobody twice.
|
|
154
|
+
*/
|
|
155
|
+
export declare function deleteInactiveAccounts(run: InactivityRun, step: WorkflowStepLike, terminalError: TerminalErrorConstructor, limit?: number): Promise<{
|
|
156
|
+
deleted: number;
|
|
157
|
+
}>;
|
|
88
158
|
//# sourceMappingURL=run.d.ts.map
|
package/dist/purge/run.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/purge/run.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../src/purge/run.ts"],"names":[],"mappings":"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"}
|